Repository navigation
fix(orchestration): recover stripped task deps - #16743
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthrough
Merge Risk: 🔵 Low · up to The compatibility fallback currently accepts uppercase task IDs even though the intended format is lowercase-only. This is a bounded behavior mismatch and is mergeable with explicit owner follow-up to remove case-insensitive matching and add rejection coverage. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Description checkExplanation The description covers the required sections, explains the problem and solution, links issue Full details: Linked Issues checkExplanation The changes satisfy issue Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
7ec3027 to
eebbbf2
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
|
Rebased onto the latest
Local validation:
GitHub Actions for the new head are currently |
eebbbf2 to
7ba9774
Compare
|
Added the CLI/runtime integration regression CodeRabbit requested in
Validation after the change:
|
7ba9774 to
1c05c51
Compare
1c05c51 to
eb7f463
Compare
Greptile SummaryThe PR recovers PowerShell-stripped orchestration dependency arrays while preserving canonical JSON parsing.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| src/main/runtime/orchestration/task-deps-flag.ts | Adds canonical JSON parsing with a narrowly constrained fallback for PowerShell-stripped generated task IDs. |
| src/main/runtime/rpc/methods/orchestration.ts | Replaces inline dependency parsing in task creation with the shared parser. |
| src/main/cli/native-cli-powershell-argv-boundary.test.ts | Verifies the actual PowerShell 5.1 native argv transformation on Windows. |
| src/main/runtime/orchestration/task-deps-flag.test.ts | Covers canonical input, stripped input, malformed values, wrong JSON shapes, and generated-ID compatibility. |
| src/main/runtime/rpc/methods/orchestration-cli-runtime-boundary.test.ts | Exercises stripped dependencies end-to-end through CLI mapping, RPC validation, persistence, readiness gating, and dispatch. |
| src/main/persistence/restoring-sessions/session-worktree-ownership.ts | Classifies workspace document history as containing no worktree ownership references. |
Sequence Diagram
sequenceDiagram
participant PS as PowerShell
participant CLI as Orca CLI
participant RPC as taskCreate RPC
participant Parser as Dependency parser
participant DB as Orchestration DB
PS->>CLI: --deps [task_012345abcdef]
CLI->>RPC: raw deps string
RPC->>Parser: parse dependencies
Parser->>Parser: JSON parse, then strict argv fallback
Parser-->>RPC: task ID array
RPC->>DB: createTask with dependencies
DB-->>RPC: pending or ready task
Reviews (4): Last reviewed commit: "fix(orchestration): recover stripped tas..." | Re-trigger Greptile
eb7f463 to
fc8d85f
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: ed3ad0db-b440-469b-bec7-5b26c7130306
📥 Commits
Reviewing files that changed from the base of the PR and between 3031c23 and fc8d85f78b31c3558cb2f1753741fbff52bd1017.
📒 Files selected for processing (7)
src/cli/handlers/orchestration-task-create-cli.test.tssrc/main/cli/native-cli-powershell-argv-boundary.test.tssrc/main/runtime/orchestration/task-deps-flag.test.tssrc/main/runtime/orchestration/task-deps-flag.tssrc/main/runtime/rpc/methods/orchestration-cli-runtime-boundary.test.tssrc/main/runtime/rpc/methods/orchestration-tasks-dispatch.test.tssrc/main/runtime/rpc/methods/orchestration.ts
🚧 Files skipped from review as they are similar to previous changes (4)
- src/cli/handlers/orchestration-task-create-cli.test.ts
- src/main/runtime/rpc/methods/orchestration-tasks-dispatch.test.ts
- src/main/runtime/rpc/methods/orchestration-cli-runtime-boundary.test.ts
- src/main/runtime/rpc/methods/orchestration.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review.
| @@ -0,0 +1,34 @@ | |||
| const INVALID_DEPS_ERROR = 'Invalid --deps: must be a JSON array of task IDs' | |||
| const GENERATED_TASK_ID_PATTERN = /^task_[0-9a-f]{12}$/i | |||
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Reject uppercase fallback IDs.
The i flag accepts values such as [TASK_B2A580DB74D8]. Those values do not match the specified strict fallback grammar, task_[0-9a-f]{12}. Remove i and add uppercase rejection cases.
Proposed fix
-const GENERATED_TASK_ID_PATTERN = /^task_[0-9a-f]{12}$/i
+const GENERATED_TASK_ID_PATTERN = /^task_[0-9a-f]{12}$/📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const GENERATED_TASK_ID_PATTERN = /^task_[0-9a-f]{12}$/i | |
| const GENERATED_TASK_ID_PATTERN = /^task_[0-9a-f]{12}$/ |
fc8d85f to
fc475f3
Compare
fc475f3 to
ec3050a
Compare
Windows PowerShell 5.1 does not escape inner quotes when building a native command line, so `--options '["a","b"]'` reaches orca.exe as `--options [a,b]`. The value is correct when printed and damaged by the time argv is parsed, so the resulting "invalid JSON" error blamed the user's input rather than the shell. #16743 recovered this for `--deps`, which is safe only because generated task IDs have a fixed 12-hex grammar. The same mangling hits `--options`, `--payload` and `--result`, and those are NOT safely recoverable: `["1","2"]` and `[1,2]` arrive at argv identically, so a general repair would silently turn strings into numbers. Detect instead. `getOptionalJsonFlag` rejects the damaged shape up front with an error that names the shell and shows the workaround. It fires only when the value is bracketed, quote-free, fails JSON.parse, AND consists entirely of bare tokens that quoting would rescue, so valid JSON is untouched. Also share the generated-id contract: `task-deps-flag` hardcoded /^task_[0-9a-f]{12}$/i, which silently diverges if `generateId`'s byte count changes. It now calls `isGeneratedId`, with a test pinning the two together. Verified on a Windows host. Measured argv, which the new test pins as a fixture: PS_VALUE=["task_b2a580db74d8","task_c3b691ec85e9"] ARGV=["--deps","[task_b2a580db74d8,task_c3b691ec85e9]"] Before: Invalid --options: must be a JSON array of strings After: --options arrived as [a,b], which is not valid JSON. Windows PowerShell 5.1 strips the inner quotes ...
* fix(cli): name PowerShell when it strips quotes from JSON flags Windows PowerShell 5.1 does not escape inner quotes when building a native command line, so `--options '["a","b"]'` reaches orca.exe as `--options [a,b]`. The value is correct when printed and damaged by the time argv is parsed, so the resulting "invalid JSON" error blamed the user's input rather than the shell. #16743 recovered this for `--deps`, which is safe only because generated task IDs have a fixed 12-hex grammar. The same mangling hits `--options`, `--payload` and `--result`, and those are NOT safely recoverable: `["1","2"]` and `[1,2]` arrive at argv identically, so a general repair would silently turn strings into numbers. Detect instead. `getOptionalJsonFlag` rejects the damaged shape up front with an error that names the shell and shows the workaround. It fires only when the value is bracketed, quote-free, fails JSON.parse, AND consists entirely of bare tokens that quoting would rescue, so valid JSON is untouched. Also share the generated-id contract: `task-deps-flag` hardcoded /^task_[0-9a-f]{12}$/i, which silently diverges if `generateId`'s byte count changes. It now calls `isGeneratedId`, with a test pinning the two together. Verified on a Windows host. Measured argv, which the new test pins as a fixture: PS_VALUE=["task_b2a580db74d8","task_c3b691ec85e9"] ARGV=["--deps","[task_b2a580db74d8,task_c3b691ec85e9]"] Before: Invalid --options: must be a JSON array of strings After: --options arrived as [a,b], which is not valid JSON. Windows PowerShell 5.1 strips the inner quotes ... * fix(cli): scope JSON-flag detection to genuinely JSON flags Review found the detector wired to two flags that are not JSON: - `orchestration ask --options` is documented `<csv>` and the runtime splits it on commas, so `--options [a,b]` was a legitimate value being rejected. - `task-update --result` is stored verbatim and reused as dispatch failure text; existing tests pass free text, so a bracketed `[ok]` was being rejected. Both revert to `getOptionalStringFlag`. Only `gate-create --options` (`<json_array>`) and `send --payload` (`<json>`) are JSON-parsed and keep it. Three further review fixes: - Objects now require a `key:value` pair per entry. `{a,b}` and `{a:b,c}` were reported as quote-stripped although quoting them cannot produce valid JSON. - The raw value is no longer echoed. A `--payload` can carry secrets and this message reaches `--json` output; the flag name and guidance are enough. - The message hedges the shell attribution. Detection inspects only the value's shape, so it also fires when a macOS/Linux user forgets to quote, where PowerShell is not involved. Verified against a Windows host, all six cases: both JSON flags fire on the mangled shape and pass valid JSON through to the runtime; both non-JSON flags now reach the runtime again; and the secret in `{token:hunter2}` appears zero times in the error output.
…lyai#17351) * fix(cli): name PowerShell when it strips quotes from JSON flags Windows PowerShell 5.1 does not escape inner quotes when building a native command line, so `--options '["a","b"]'` reaches orca.exe as `--options [a,b]`. The value is correct when printed and damaged by the time argv is parsed, so the resulting "invalid JSON" error blamed the user's input rather than the shell. stablyai#16743 recovered this for `--deps`, which is safe only because generated task IDs have a fixed 12-hex grammar. The same mangling hits `--options`, `--payload` and `--result`, and those are NOT safely recoverable: `["1","2"]` and `[1,2]` arrive at argv identically, so a general repair would silently turn strings into numbers. Detect instead. `getOptionalJsonFlag` rejects the damaged shape up front with an error that names the shell and shows the workaround. It fires only when the value is bracketed, quote-free, fails JSON.parse, AND consists entirely of bare tokens that quoting would rescue, so valid JSON is untouched. Also share the generated-id contract: `task-deps-flag` hardcoded /^task_[0-9a-f]{12}$/i, which silently diverges if `generateId`'s byte count changes. It now calls `isGeneratedId`, with a test pinning the two together. Verified on a Windows host. Measured argv, which the new test pins as a fixture: PS_VALUE=["task_b2a580db74d8","task_c3b691ec85e9"] ARGV=["--deps","[task_b2a580db74d8,task_c3b691ec85e9]"] Before: Invalid --options: must be a JSON array of strings After: --options arrived as [a,b], which is not valid JSON. Windows PowerShell 5.1 strips the inner quotes ... * fix(cli): scope JSON-flag detection to genuinely JSON flags Review found the detector wired to two flags that are not JSON: - `orchestration ask --options` is documented `<csv>` and the runtime splits it on commas, so `--options [a,b]` was a legitimate value being rejected. - `task-update --result` is stored verbatim and reused as dispatch failure text; existing tests pass free text, so a bracketed `[ok]` was being rejected. Both revert to `getOptionalStringFlag`. Only `gate-create --options` (`<json_array>`) and `send --payload` (`<json>`) are JSON-parsed and keep it. Three further review fixes: - Objects now require a `key:value` pair per entry. `{a,b}` and `{a:b,c}` were reported as quote-stripped although quoting them cannot produce valid JSON. - The raw value is no longer echoed. A `--payload` can carry secrets and this message reaches `--json` output; the flag name and guidance are enough. - The message hedges the shell attribution. Detection inspects only the value's shape, so it also fires when a macOS/Linux user forgets to quote, where PowerShell is not involved. Verified against a Windows host, all six cases: both JSON flags fire on the mangled shape and pass valid JSON through to the runtime; both non-JSON flags now reach the runtime again; and the secret in `{token:hunter2}` appears zero times in the error output.
ELI5
PowerShell can hand Orca a dependency list where the JSON quotes are gone. Orca now still accepts that list when it clearly contains valid generated task IDs.
What Changed
orchestration task-create --depsas the primary path.[task_b2a580db74d8]after argv quote stripping.Why
The documented contract is still
--deps <json_array>, but Windows PowerShell can strip inner quotes before the value reaches the runtime. The fallback is intentionally strict: it only accepts bracketed, comma-separated IDs matchingtask_[0-9a-f]{12}. Malformed values and broader non-JSON input continue to fail.Linked Issue
Fixes #16706
Visual Proof
N/A — CLI/runtime behavior only; no UI or visual change.
Testing
Local checks run on Windows workspace:
pnpm exec vitest run --config config/vitest.config.ts src/cli/handlers/orchestration-task-create-cli.test.ts src/main/runtime/rpc/methods/orchestration-tasks-dispatch.test.ts --reporter=dotpnpm exec oxlint src/cli/handlers/orchestration-task-create-cli.test.ts src/main/runtime/rpc/methods/orchestration.ts src/main/runtime/rpc/methods/orchestration-tasks-dispatch.test.tspnpm exec oxfmt --check src/cli/handlers/orchestration-task-create-cli.test.ts src/main/runtime/rpc/methods/orchestration.ts src/main/runtime/rpc/methods/orchestration-tasks-dispatch.test.tspnpm run typecheck:nodepnpm run typecheck:cliNote: local typechecks emitted the existing engine warning because this environment uses Node v22.23.1 while the package declares Node 24.
AI Disclosure
Implemented with GPT-5 Codex assistance under user direction. I inspected the linked issue, made the focused change, and ran the checks listed above.
Review
Ready for maintainer review.
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
Cross-platform: normal JSON remains the preferred path on every platform; the fallback only handles a Windows argv stripping shape that still contains valid generated task IDs. SSH/remote: no wire shape changes. Backwards compatibility: accepted valid JSON behavior is unchanged; invalid non-JSON values still fail unless they match the narrow generated-ID fallback.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)