Skip to content

MARSOHS-2589: default --permission to ask and print the applied policy - #2112

Merged
SSharma-10 merged 6 commits into
digitalocean:mainfrom
nveerdixit:marsohs-2589-permission-default-ask
Nov 26, 2026
Merged

SSharma-10 merged 6 commits into
digitalocean:mainfrom
nveerdixit:marsohs-2589-permission-default-ask

Conversation

@nveerdixit

@nveerdixit nveerdixit commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Behaviour change. Needs the owner's approval before merge. Sessions created with --harness and no --permission now default to ask instead of allow. Runs stop and wait at the first tool call that needs approval.

Summary

doctl harness-runtime create and launch with --harness defaulted --permission to allow. The environment spec resolves an omitted permissions.default to ask, so the same environment got a different policy depending on how it was created, and the CLI never showed which one a session got. This PR changes two things:

  1. Default ask. --harness without --permission now writes default: ask. --permission allow|ask|deny still overrides it.
  2. Print the policy the server will apply. The server can change the requested default (for example, an allow default can be shipped as ask for agents without full capability data), so printing the flag value could be wrong. Alongside the create call, doctl calls the existing policy-validate endpoint with the manifest bytes create sends (secret values redacted), and once the session exists prints one line on stderr:
permissions.default: ask (server will apply)
permissions.default: ask (server will apply; requested allow)
permissions.default: allow (server will apply; the agent enforces ask: <server reason>)
permissions.default: ask (requested; server check failed: timed out)

The check runs in parallel with create and has a 5 second limit. If it fails or times out, the line is labelled "requested". A failed create prints no line.

What users need to know

  • With no terminal, create --harness ... --prompt ... without --on-hitl or an explicit --permission now refuses before any API call, naming --on-hitl approve, --permission allow, or --permission ask to keep the wait. Interactive use keeps the ask default.
  • Under ask, a run waits at the first tool call that needs approval, and the wait does not time out. Approve with doctl harness-runtime approve, in the chat, or with create --on-hitl approve. For unattended runs, use create --on-hitl approve or --permission allow. launch cannot auto-approve. The flag description and the create/launch help now say this.
  • MCP tool calls that cannot request approval fail under ask instead of waiting. The flag help says this too.

Scope and limits

  • Only the --harness path changes, for both create and launch. --spec, --from-config, bare sandboxes and --dry-run (which makes no API calls) print no line.
  • With -o json, the line goes to stderr so stdout stays valid JSON. The create JSON comes from a displayer shared with other commands, so no field was added.
  • The validate call is one more request per --harness create, but it runs alongside create, so it adds no latency, and it carries no secret values.
  • The validate call does not take create's query parameters (manage_model_access_key, openai_session_id, resume_on_topoff). The server resolves the policy from the manifest's permissions, template, agent and MCP servers only, so none of those parameters change its answer.

Testing

  • New tests cover:
    • the literal ask default;
    • the downgraded line (requested allow, shipped ask);
    • the enforced value differing from the shipped one;
    • shipped equal to requested;
    • an empty default in the response;
    • a check failure that does not block create and shows no URL or request ID;
    • the 5 second deadline and its exact line;
    • the manifest validated equals the one created with secret values redacted, using an expanded API-key variable;
    • a failed create printing no line;
    • the no-terminal refusal, and each case that passes it (terminal, explicit --permission ask, --on-hitl, no prompt, allow);
    • -o json stdout staying clean, with the line on stderr;
    • --spec never calling the check;
    • the launch --harness path.
  • Existing --harness tests now expect the check.
  • go test ./commands/ ./do/ passes except TestRegistryLogout, which also fails on unmodified main in my environment (it needs the OS keychain).

Refs: MARSOHS-2589

🤖 Generated with Claude Code

`create` and `launch` with --harness defaulted --permission to allow,
while the manifest spec resolves an omitted permissions.default to ask,
and the CLI never showed which policy a session got. The default is now
ask. Before creating the session, doctl asks the server which default it
will apply to the exact manifest being sent (5 second limit) and prints
one line on stderr; the server can change the requested value. If that
check fails, the create continues and the line shows the requested value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nveerdixit

Copy link
Copy Markdown
Contributor Author

Live check. create without --permission now prints the policy the server will apply (ask). An explicit --permission allow prints allow, and -o json keeps stdout valid JSON.

default ask

nveerdixit and others added 2 commits November 19, 2026 20:05
… test

TestRunAgentsCreate_HermesWithOpenAIKeySkipsManagedKey came from main
(digitalocean#2114) and assumed the old --permission default of allow. With this
branch's default of ask, a --harness create validates the policy before
creating, as every other --harness create test here already expects.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sanpj2292

Copy link
Copy Markdown
Contributor

Review notes.

  1. Unattended runs will stall. With defaultHarnessPermission = "ask" (commands/agents.go:767), an existing script like create --harness X --prompt "..." without --on-hitl now stops at the first tool call, and the help says the wait does not time out. Today that script finishes. Needs the owner's approval, and probably a release note. One option: when there is no TTY and no --on-hitl, fail fast or warn instead of leaving the session waiting.
  2. Extra load and latency on every --harness create. reportAppliedPermission (commands/agents.go:1270, called at commands/agents_run.go:852) makes a synchronous ValidatePolicy call before create. That's one more request per create, up to 5 seconds added on a slow path, and the expanded secret values are sent a second time. A lighter alternative: have the create response (or the session GET) return the applied permissions.default, and print it after create. That's one request, with no secrets sent twice.
  3. Can disagree with create. As the description notes, ValidatePolicy doesn't receive create's query params (for example manage_model_access_key, which MARSOHS-2740: use DigitalOcean Inference for --model on claude-code and codex #2118 now relies on for --model sessions). So the "server will apply" line can differ from what create applies, which works against the goal of printing the true policy.

@sdharavath sdharavath left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

…side create

With --permission defaulting to ask, `create --harness X --prompt ...` run
from a script with no terminal and no --on-hitl started a run that waited at
its first tool call with no timeout. That create now refuses before any API
call and names the three ways out: --on-hitl, --permission allow, or an
explicit --permission ask to keep the wait. A terminal keeps the ask default.

The policy check no longer delays create: it runs alongside the create call
and its line prints once the session exists (nothing prints when create
fails). It sends the manifest with secret values redacted, so secrets cross
the wire once; the server's policy resolution does not read them, nor any of
create's query parameters.

Co-authored-by: Cursor <cursoragent@cursor.com>
@nveerdixit

Copy link
Copy Markdown
Contributor Author

@sanpj2292 thanks. All three addressed in b837a19.

  1. Unattended runs stall. Fixed with fail-fast. A create --harness X --prompt "..." with no terminal, no --on-hitl and no explicit --permission now refuses before any API call:

    --permission defaults to ask, so this --prompt would wait at its first tool call for an approval nothing here can give, and the wait does not time out. Pass --on-hitl approve (or reject) to resolve approvals from this command, --permission allow to run tools without asking, or --permission ask to keep the wait and approve with `doctl harness-runtime approve`
    

    It passes on a terminal (interactive use keeps ask), with --on-hitl, with an explicit --permission ask, and when there is no --prompt (no run starts, so nothing waits). launch already requires a terminal. The existing script you describe now gets that error in place of a silent hang, which is also the release-note line. Behaviour change still needs owner approval, as the PR header says.

  2. Extra load, latency and secrets. The create response and session GET don't carry the applied permissions.default: create-time warnings only cover per-rule fidelity, not the default. So printing the true policy without a server change still needs ValidatePolicy. What changed:

    • It runs in parallel with the create call, so no latency is added on the happy path. The line prints once the session exists. A failed create cancels the check and prints nothing.
    • It sends the manifest with secret slot values redacted (the same redaction --dry-run uses). Policy resolution doesn't read them, so secrets cross the wire once.
    • It is still one extra request per --harness create. Returning the applied default on the create response would remove it. That is a server change, so I left it out of this PR.
  3. Can disagree with create. I checked the server side. Policy resolution on create and on validate is the same evaluation, over the manifest's permissions, template, agent kind and MCP servers. manage_model_access_key only changes which secrets/config get minted. openai_session_id and resume_on_topoff don't feed it either. So create's query params can't change the answer, and "server will apply" holds. The PR body's limitation bullet said otherwise, and I've corrected it.

Tests: go test -race on the create/launch/permission tests passes. go test ./commands/ ./do/ passes except TestRegistryLogout, which fails on unmodified main here too (OS keychain).

@sanpj2292

Copy link
Copy Markdown
Contributor

Thanks @nveerdixit. I checked b837a19d:

  • Fail-fast: refuseUnattendedAsk runs before any API call and lets through a terminal, --on-hitl, an explicit --permission, and runs with no --prompt.
  • Policy check: appliedPermissionLine runs in a goroutine alongside create, on redactManifestSecrets(manifest). It's cancelled when create fails, and its line prints after the create progress line.

Under -race the branch shows no new races. The races it reports come from the shared colorize/styling globals, the same as on main.

Still open for you:

  1. Server-side follow-up. Removing the extra ValidatePolicy request needs the create response, or the session GET, to return the applied permissions.default. Please file that with the API owners and link it here, so the extra request has a planned end.
  2. Merge conflicts: this PR now conflicts with MARSOHS-2738: clone --gh-repo into the workspace before the prompt #2119 (commands/agents_help.go, commands/agents_run_test.go), agents: report unknown fields in agent manifests #2093 (commands/agents.go), and MARSOHS-2587: print logs as JSON with -o json, add --pretty #2110 and MARSOHS-2747: accept --local-file on harness-runtime download #2115 (commands/agents_test.go). Whichever merges later needs a rebase.

The switch of the default to ask (and the new refusal for unattended runs) still needs the owner's approval, as the PR header says.

@SSharma-10

Copy link
Copy Markdown
Contributor

Please resolve the merge conflicts and address the open comment

Conflict in commands/agents_test.go: both sides appended tests at the
end of the file (this branch's JSON permission-line test, main's `logs`
tests). Kept both.

digitalocean#2118's --model create tests had no ValidatePolicy stub. Every --harness
create now runs the policy check alongside create, so the unexpected
call failed inside that goroutine and create waited on it forever (the
package timed out). They now allow the check without asserting its line,
since create is made to fail and the check may be cancelled.

Co-authored-by: Cursor <cursoragent@cursor.com>
@nveerdixit

Copy link
Copy Markdown
Contributor Author

@SSharma-10 @sanpj2292 the conflicts are resolved and the open comment is addressed, in a2b2b0b. It is a merge of main at e2e104d, not a rebase.

Merge conflicts. Git reported one conflict, in commands/agents_test.go. Both sides had added tests at the end of the file: this branch's JSON permission-line test and main's logs tests. I kept both. agents.go, agents_help.go and agents_run_test.go merged cleanly.

Interaction with #2118. The create path keeps both behaviours. The policy check runs alongside whichever create call needsManagedModelAccessKey picks: plain create, or the one with manage_model_access_key. #2118's --model create tests had no ValidatePolicy stub, so after the merge the unexpected call failed inside the check's goroutine, and create waited on it until the package timed out. Those tests now allow the check without asserting its line, because they make create fail and the check can be cancelled before it is sent.

Server-side follow-up. Filed as MARSOHS-3158: return the applied permissions.default on the create response and on the session GET, so doctl can drop the extra ValidatePolicy request.

Tests on a2b2b0b: go vet ./commands/ ./do/ is clean, and go test ./commands/ ./do/ passes except TestRegistryLogout (the OS keychain failure that also fails on main here). go test -race on the create, launch and permission tests passes.

The switch of the default to ask still needs the owner's approval.

@SSharma-10
SSharma-10 merged commit 8e1364e into digitalocean:main Nov 26, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants