Repository navigation
Conversation
…nclaw#83902) `getCommandPathInternal` compared `arg === "--"` directly, while every other helper in `argv.ts` (`isHelpOrVersionInvocation`, `hasFlag`, `hasRootVersionAlias`, `isRootInvocationForFlags`, `getFlagValue`, `getCommandPositionals`, etc.) routes its terminator check through the imported `FLAG_TERMINATOR` constant from `infra/cli-root-options.ts`. Under the current value (`"--"`) the two paths agree, but any future change to the constant would silently desync command-path resolution from help/version detection — subcommand routing would break in a way that's hard to trace because the rest of the parser would still pick up the new terminator. Replace the hardcoded literal with `FLAG_TERMINATOR` and pin a regression test that pulls the live constant through the same module-resolution path the production code uses. Closes openclaw#83902.
|
Codex review: needs maintainer review before merge. Workflow note: Future ClawSweeper reviews update this same comment in place. How this review workflow works
Summary Reproducibility: yes. at source level: current main still imports PR rating Rank-up moves:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. PR egg Rarity: 🥚 common. What is this egg doing here?
Real behavior proof Risk before merge Maintainer options:
Next step before merge Security Review detailsBest possible solution: Land the small code/test fix after normal CI if maintainers accept keeping Do we have a high-confidence way to reproduce the issue? Yes at source level: current main still imports Is this the best way to solve the issue? Yes: replacing the literal with the existing imported constant is the narrowest maintainable fix. The added test is useful guard coverage, with CI still needed for execution proof. Label justifications:
What I checked:
Likely related people:
Codex review notes: model gpt-5.5, reasoning high; reviewed against aef93881af5f. |
Fixes #83902.
getCommandPathInternal(src/cli/argv.ts:225) was the sole helper inargv.tscomparingarg === "--"against the string literal instead of the importedFLAG_TERMINATORconstant frominfra/cli-root-options.ts. Every other helper in the same file (isHelpOrVersionInvocation,hasFlag,hasRootVersionAlias,isRootInvocationForFlags,getFlagValue,getCommandPositionals, etc.) routes its terminator check throughFLAG_TERMINATOR. Under the current value ("--") the two paths agree, but any future change to the constant would silently desync command-path resolution from help/version detection — subcommand routing would break in a way that's hard to trace.Changes
src/cli/argv.ts: replaceif (arg === "--")ingetCommandPathInternalwithif (arg === FLAG_TERMINATOR)(single-line fix as the issue recommended). Add a short comment explaining the consistency requirement.src/cli/argv.test.ts: regression test that pulls the liveFLAG_TERMINATORconstant frominfra/cli-root-options.tsand asserts bothgetCommandPathandgetCommandPathWithRootOptionsstop at it. The test will fail if the constant changes without a corresponding update here.Diff stat: 2 files, +24 / -1.
Real behavior proof
Behavior or issue addressed: Sanitized issue evidence —
argv.ts:4importsFLAG_TERMINATORand uses it in every helper exceptgetCommandPathInternalat line 225, which compares against the string literal"--". The issue's reasoning section notes that any future redefinition ofFLAG_TERMINATORwould silently break command-path resolution while help/version detection continues to track the new value.Real environment tested: Local Node 22.x. Probe at
/tmp/probe_83902.mjs(a) parses the patchedargv.tsand verifies the comparison now usesFLAG_TERMINATOR, no remainingarg === "--"string-literal ingetCommandPathInternal, and that=== FLAG_TERMINATORis used 8 times across the file (parser-wide consistency), and (b) replays both the patched and pre-fix shapes against the current"--"terminator (both produce["status"]— no observable difference under the default config) and a hypothetical"++"terminator (patched correctly stops at"++"and returns["status"]; buggy ignores the redefined constant and returns["status", "++"]).Exact steps or command run after this patch:
node /tmp/probe_83902.mjsEvidence after fix:
Observed result after fix: Under the current
FLAG_TERMINATOR = "--"value, behavior is unchanged (the existing"terminator cuts parsing"test still passes). Under any hypothetical change to the constant,getCommandPath/getCommandPathWithRootOptionstrack the new value in lock-step with the rest of the parser instead of silently using the old literal.What was not tested: A live build that physically changes
FLAG_TERMINATORto a non-"--"value — the regression test pins the assertion against the imported constant viaawait import("../infra/cli-root-options.js")so the relationship is enforced at test time, and the source-level probe verifies the comparison shape.Audit (per CLAUDE rules — all 5 steps)
FLAG_TERMINATORconstant. No new helper or import. PASSFLAG_TERMINATORhas 8 usage sites acrossargv.tsafter this patch (was 7); the new one is the same comparison shape as all the others.getCommandPathandgetCommandPathWithRootOptionsare exported and called bycommand-path.tsand other CLI plumbing — the behavior change is invisible under the current"--"value and matches the existing usage convention across the parser. PASSgh pr list --search '83902 in:title,body'andgh pr list --search 'FLAG_TERMINATOR in:title,body'return no open PRs. PASSgit log --oneline -5 -- src/cli/argv.tsshowse1061a8b46 test(live): tolerate provider drift in release checks— unrelated. PASS