Repository navigation
fix(security): centralize inherited credential redaction, launchArgs guards, and DSH goalSet refusal - #1004
Merged
Conversation
stamp-build Bot
added a commit
that referenced
this pull request
Nov 19, 2026
…or (#1011) <!-- stamp:review:v1 --> <sup><img src="https://api.raft.build/api/avatars/pixel/ZXll.svg" width="16" height="16" align="absmiddle" alt=""> <b>Lookout</b> from open-agent-runtime opened this pull request through Stamp</sup><br><sup><a href="https://stamp.build/review?receipt=prc_6b3f52f367243307afe4b49035f93641"><picture><source media="(prefers-color-scheme: dark)" srcset="https://stamp.build/assets/brand/stamp-glyph-dark.d907ffcadb44.svg"><img src="https://stamp.build/assets/brand/stamp-glyph-light.58a2c10ed108.svg" width="13" height="12" align="absmiddle" alt=""></picture> View in Stamp →</a></sup> --- <!-- /stamp:review:v1 --> Requested by `@raft:Cindy` in `#inspection:#35` (`msg=0e5280bd`). ## Verified doc corrections - **`docs/runtimes/qwen.md`:** - Clarify that on resume, `usage().total` remains `null` for the entire resumed session (even after new turns complete), matching `qwen/projection.ts` (`usageKnown: !resume`) and `docs/spec/runtime-matrix.md`. - Clarify that `listModels(installation, { timeoutMs })` sets one whole-query deadline (default 30 seconds across launch, `initialize`, and `get_available_models`), aborting the query, terminating the owned process tree, and closing stdin in cleanup without retries. - Clarify that `system/task_notification` emits `task_ended` only for terminal statuses (`completed`, `failed`, `stopped`); non-terminal notifications (and notifications missing a nonempty `data.task_id`) remain raw frames without emitting a task event (`qwen/tasks.ts`). - Note: the `launchArgs` managed-flag updates on `qwen.md:54` and `qoder.md:172` live in PR #1004 so the two PRs merge cleanly without conflicts. - **`docs/runtimes/qoder.md`:** - Fix the manual compaction settlement order to match `qoder/compaction.ts`: `started` gates recording subsequent `result` and manual `compact_boundary` frames; on terminal `command_lifecycle` (`completed` or `cancelled`), precedence is (1) post-`started` manual `compact_boundary` -> `completed`, (2) `cancelled` -> `aborted`, (3) `completed` with post-`started` error `result` -> `failed / native_failed`, (4) otherwise -> `failed / not_compacted`. - Clarify that `listModels()` opens a temporary daemon session (`daemon.initialize`, `daemon.open_session`, and session `initialize`) through `launchQoder` before issuing `daemon.get_models`, and that one whole-query `withQueryDeadline` (default 30 seconds, configurable via `timeoutMs`) bounds auth status, version probing, daemon handshake, `initialize`, and `get_models`. - Clarify effort context on startup failure: when `effort` is requested, post-validation launch/daemon-handshake and `initialize` failures include the requested effort as context (`qoderStartupError`), whereas pre-launch option/version refusals, `ModelConfirmationError`, and `get_settings` effort-confirmation failures keep their own specific errors. - **`docs/spec/goals.md`:** - Expand the refusal-code contract beyond `runtime_refused` to include `unsupported`, `error`, reachability refusals (`runtime_exited`, `disposed`, `session_released`), and runtime-reported `busy`/`no_active_turn`. - Separate general goal rules from per-runtime wire details: move Codex's `thread/goal/*` frames and `turn/started`/`turn/completed` boundaries into `## Codex boundary`, and document DSH's `goal/read` observation frame, `response.native` reply payload, `session/event:goal/change`, and `turn/start`/`turn/end` boundaries in `## DSH boundary`. - List `blocked`, `usageLimited`, and `budgetLimited` as refused `goal.set` statuses on DSH (`dsh/goal.ts`). ## Validation - Verified every doc edit against current `main` (`35289294`) source files (`qwen/{projection,list-models,tasks}.ts`, `qoder/{compaction,launch,daemon,list-models,session,protocol}.ts`, `codex/goal.ts`, `dsh/{goal,bridge-goal,projection,session}.ts`). - Verified zero em or en dashes in the diff. Co-authored-by: Lookout <[email protected]>
…guards, and DSH goalSet refusal
stamp-build
Bot
force-pushed
the
agent/lookout/qoder-security-dsh-goal
branch
from
November 19, 2026 13:52
b1b2165 to
6703aec
Compare
stamp-build Bot
added a commit
that referenced
this pull request
Nov 19, 2026
<!-- stamp:review:v1 --> <sup><img src="https://api.raft.build/api/avatars/pixel/bXVn.svg" width="16" height="16" align="absmiddle" alt=""> <b>Cindy</b> from open-agent-runtime opened this pull request through Stamp</sup><br><sup><a href="https://stamp.build/review?receipt=prc_e64147517ab394fe93b7cc8f4c9d751f"><picture><source media="(prefers-color-scheme: dark)" srcset="https://stamp.build/assets/brand/stamp-glyph-dark.d907ffcadb44.svg"><img src="https://stamp.build/assets/brand/stamp-glyph-light.58a2c10ed108.svg" width="13" height="12" align="absmiddle" alt=""></picture> View in Stamp →</a></sup> --- <!-- /stamp:review:v1 --> What a host needs to run Claude through OAR: CLI failures kept out of the model's text, a `model_refused` failure class, startup diagnostics, Claude's credential declaration, and per-category user configuration exclusion. Also a per-installation `contextUsage` declaration, cache-write TTL usage, and a light `@botiverse/oar/capabilities` entry. **Behavior changes for hosts:** `launchArgs` refuses flags OAR owns, stateful observers deliver the current state once when subscribed without a cursor, launch validation is stricter, Claude's synthetic messages produce no events, a `queue()` made from inside a `prompt` request now runs first, and several public unions grew (below). ## Behavior changes - `launchArgs` refuses more flags OAR manages, at open, with `UnsupportedOptionError("launchArgs")` (#1004). Use the matching `SessionOptions` fields (`model`, `effort`, `systemPrompt`, `appendSystemPrompt`, `name`) instead. - Claude: `--model`/`-m`, `--effort`, the system prompt and append system prompt flags and their `-file` forms, `--name`/`-n`, the partial and replayed message flags, and `--`. - Qoder: the same set, with `--reasoning-effort`. - Qwen: `--model`/`-m`, `--system-prompt`, `--append-system-prompt` and the partial message flags. - CodeBuddy: `--model`/`-m`, `--append-system-prompt` and `--append-system-prompt-file`. - Factory: `--`. - All five catch `--flag=value` and attached short flags (`-mfoo`); Qoder, Qwen and CodeBuddy also catch camelCase aliases. - Observers subscribed without a cursor: raw and flat event subscriptions deliver only new records. `observeConversation` and `observeSessionView` deliver one snapshot of the current state right away when the retained log is nonempty, then one state per new record; on an empty log they wait for the first record. Pass `afterSeq: -1` for a full replay. `events()`, `observeConversation` and `observeSessionView` throw on a cursor from another session (#1007). - Launch validation now matches configuration submission: a select value outside the declared options, a relative URL, and a required secret that resolves empty all fail. Two active fields supplying the same model or effort produce the new `ConfigIssue` code `conflicting_fields` (#1007). - Claude: assistant frames the CLI writes itself (`model: "<synthetic>"` or `is_api_error_message`, such as API errors and "No response requested.") no longer produce events, including `text_delta`. They stay readable as native frames, and a failure's text goes to the failed turn's `reason` (#1015). - Queue ordering on adapter-held sessions: a synchronous `rawEvents` observer that calls `queue()` from inside a `prompt` request now queues that input before `prompt` decides, so the `prompt` is refused as `busy` and the queued input runs. ACP controls are recorded synchronously at call time (#1003). - Public unions grew, so exhaustive switches or `Record`s over them need the new members: `FailureClass` (`model_refused`), `CredentialVariable.purpose` (six values), `RefusableSessionOption` (`partialUserConfiguration`), `ConfigIssue` codes (`conflicting_fields`), and `SessionOptions.userConfiguration` (an object form). ## Claude for hosts (#1015, #1017, #1018, #1019, #1020), feature - `FailureClass` gains `model_refused`. Claude's `stop_reason: "refusal"` and ACP's `stopReason: "refusal"` map to it, ahead of the CLI's generic `invalid_request`; Grok refusals map to it too, and more specific provider evidence on a CodeBuddy refusal still wins. `failureAdvice` gives it `{ retry: "no", userAction: false }`. On Claude, a verification failure is `auth`, a `usage_limit_reached` error is `quota` even without a reset time, and overload is `overloaded`. A quota failure can carry `rateLimitType`. - A native process that exits during session startup keeps its stderr. On Claude, Qoder and Qwen the tail goes on the open rejection, or on `exited.reason` when the session was already returned before its first frame. At most 8 KiB is kept, a leading partial line is dropped, and session credentials and recognizable key or JWT shapes are redacted. Other process adapters apply the same redaction to the stderr they already report (#1018). - `claudeRuntime.credentials` declares the environment variables and stores Claude Code reads, grouped by direct API and OAuth, federation, cloud provider and model routing. `CredentialVariable.purpose` adds `provider_selector`, `region`, `account_scope`, `model_route`, `credential_source` and `headers` (headers are secret). Variables carried by `stores[].directoryEnv` are not repeated in `env` (#1019). - `SessionOptions.userConfiguration` accepts `{ exclude: ("settings" | "mcp" | "instructions")[] }`. On Claude, `settings` drops user settings and user-scope MCP; `mcp` keeps only host MCP; `instructions` drops user rules, home memory and automatic memory while project instructions stay. An empty list keeps the native configuration and all three equal `"exclude"`. Cursor takes all or none and declares the new refusal key `partialUserConfiguration`; runtimes that refuse `userConfiguration` refuse any nonempty exclusion (#1020). - An explicitly selected macOS Claude Desktop cache executable reports Desktop as its update owner: `checkUpdate` is `unavailable` (`package_manager`) and `upgrade` is refused, before the binary runs. Automatic discovery still uses the standalone CLI (#1017). ## Capabilities and usage (#1013, #1014, #1016), feature - `SessionCapabilityDeclaration.contextUsage: { tokens, contextWindow }` says whether `contextUsage()` reports each by the end of every normally completed root turn, fresh or resumed. Declared true for both on Antigravity, Claude, DSH, Factory, Kimi, Pi, Codex from 0.151.0, Qwen from 0.26.0 and OpenCode on readable versions; tokens only on Cursor and Grok; neither on CodeBuddy, Qoder and Pi Durable; absent on Devin. Factory now waits up to one second for `droid.get_context_stats` before ending a turn. - `UsageReport.cacheWriteByTtl?: { "5m"?, "1h"? }`, per report. Claude reads it from the latest root model frame of the turn; Pi reports `"1h"` only and never derives `"5m"`. - `@botiverse/oar/capabilities` exports `installedSessionCapabilities` and its contract types without loading any runtime adapter or native SDK. ## Fixes - Queued input can be withdrawn immediately after `queue()`: ACP sessions (isolated and shared) before and after spawn, DSH image inputs and Pi Durable no longer answer `not_queued` and then run the input (#1003). - Inherited credentials go through the shared redactor: Qoder's inherited tokens and daemon handshake tokens, Cursor's inherited `CURSOR_API_KEY` in model listing and session errors, and Factory's inherited credential in account and usage reads. A DSH `goalSet` without a valid change is refused with `runtime_refused` rather than sending undefined fields (#1004). - Event subscriptions keep pending controls from the retained prefix, so a rejection keeps its action and a withdrawal its input id across the cursor. `initialSessionView(rootSessionId?)` and `viewOf(records, streamId, rootSessionId?)` take the host's root id, which child records cannot replace; session graphs drop self-links and cycle-closing edges. A typed model id can use the effort levels on its own model listing entry (#1007). - Morph: an adopted task emits one `turn_active`, and shell results parse the native exit-code envelope. OpenCode background child updates use the same version gate as prompt controls (#1010). - Pi Durable reads busy state through the session's own `status()` instead of the observation layer (#1009). ## Also - Tests: the Pi extension turn identity check no longer races Pi's message publication on Windows (#1012); Morph and Cybion run in every platform's unit checks (#1010). - Docs: Qwen, Qoder and goals pages (#1011), DSH compaction and image rows (#1006), and design page corrections from the DeepSeek audits (#1008). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Cindy <[email protected]> Co-authored-by: xxchan <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by
@raft:Cindyin#inspection:#35(msg=0e5280bd).Breaking change
launchArgsmanaged-flag enforcement (claude,qoder,qwen,codebuddy,factory):SessionOptions.launchArgsnow rejects flags owned by OAR (--model/-m,--effort/--reasoning-effort,--system-prompt,--system-prompt-file,--append-system-prompt,--append-system-prompt-file,--name/-n,--include-partial-messages/--no-include-partial-messages,--replay-user-messages/--no-replay-user-messages, and--, including--flag=value, attached short flags such as-pfoo/-rabc, and camelCase aliases where applicable) withUnsupportedOptionError("launchArgs", ...)at session open. Hosts passing those flags vialaunchArgsmust migrate to the matchingSessionOptionsfields (model,effort,systemPrompt,appendSystemPrompt,name, etc.).Adversarial reproduction
qoder/launch.ts,qoder/daemon.ts,qoder/protocol.ts,cursor/access.ts,factory/account-credential.ts):QODER_PERSONAL_ACCESS_TOKENorQODER_SERVICE_ACCOUNT_KEYwas inherited fromprocess.env,qoderDaemonAuth(env)read and sent it indaemon.initializewhile neitherqoderSessionnorqoderListModelsregistered the inherited value on the credential redactor; additionally,qoderDaemonSessionpassed an empty() => {}callback toqoderControlinstead ofrememberQoderSecrets, leaving handshake tokens such assessionTokenunredacted in subsequent records and error diagnostics.CURSOR_API_KEYwas inherited fromprocess.envunder Cursor'ssubprocess(inherit) orin_processaccess modes,callRedactionandcursorSessionWithonly inspected explicitoptions.env, allowing the inherited key to appear inlistModelserror causes and session failures.launchArgsprotocol and option bypasses (qoder/options.ts,qwen/options.ts,claude/launch-args.ts,codebuddy/options.ts,factory/options.ts):qoder/launch.tsappendedoptions.launchArgsafter OAR's own flags whilecheckQoderLaunchArgsdid not reject--include-partial-messages,--no-include-partial-messages,--model,-m,--system-prompt,--system-prompt-file,--append-system-prompt,--append-system-prompt-file, camelCase aliases, or attached short flags such as-phello.checkQwenLaunchArgs,checkCodebuddyLaunchArgs,checkFactoryLaunchArgs, andrefuseManagedLaunchArgshad analogous gaps.goalSetinvoking status mutations onundefined(dsh/bridge-goal.ts):goals.createorgoals.editreturnedundefined,goalSetcontinued intogoals.resume(agent, current)/goals.pause(agent, current)/goals.complete(agent, current)withcurrent === undefinedinstead of refusing immediately while truthfully recording the observed native goal state (goal/read, includingnull).Fix by class
shared/credential-redactor.ts): IntroducereadEnvironmentCredentialandrememberEnvironmentCredentials(usingenvironmentValuefor Windows case-insensitivity plus the shared length, path, and URL-password rules) and route Qoder (qoderDaemonAuth,launchQoder,qoderDaemonSession,qoderSession,qoderListModels), Cursor (subprocessAccess,callRedaction,cursorSessionWith), and Factory (factoryCredential,factoryAccountUsage) through it without scanning unrelated host environment variables (docs/spec/record-stream.md).launchArgsguard (shared/launch-args.ts) and runtime docs: CentralizenormalizeLaunchFlag(--flag=value, attached short-fvalue, optional--camelCasenormalization) andcheckManagedLaunchArgs, wireclaude,qoder,qwen,codebuddy, andfactoryonto it, migratesea-trial/harness/backends.tsandsea-trial/harness/acp-terminal-priority.tsfromlaunchArgs: ["--model", ...]tomodel, and updatedocs/runtimes/{claude,codebuddy,qoder,qwen,factory}.md.goalSetguard without suppressing native observations (dsh/bridge-goal.ts): Ifgoals.create/editreturnsundefined/null, emitobserveGoal(agent, goals, "set")so records faithfully reflect native reality (includinggoal: null) and immediately refuse withruntime_refusedwithout callingresume/pause/completewithundefined.Validation
main(35289294).OAR_TEST=codebuddy-aimock OAR_TEST_REQUIRE_AVAILABLE=1 pnpm run sea-trialpassed locally against real CodeBuddy2.173.0(17 passed, 3 skipped, 0 failed, includingsession.effort-never-substitutedandsession.effort-listed-levels-apply-across-resume).CI=1 pnpm run checkpassed locally (567test files /5,330tests +19mock behavior cases).