Skip to content

fix(cli): bare parseInt on run --timeout lets a malformed value abort every phase instantly (sibling of #818) #833

Closed

Description

@admarble

Context

QA on #818 found that merge --watch's --interval/--timeout were coerced with a bare parseInt and then defaulted with ??. Because NaN is not nullish, a malformed value survived the default and produced an unbounded, zero-delay poll loop. That was fixed in PR #831.

The cross-file sibling scan during that QA found the same root-cause pattern on run --timeout, which is untouched by #818 and lands somewhere more damaging.

The defect

bin/cli.ts registers the phase timeout on two commands with a bare parseInt:

bin/cli.ts:286   .option("--timeout <seconds>", "Timeout per phase in seconds", parseInt)
bin/cli.ts:527   .option("--timeout <seconds>", "Timeout per phase in seconds", parseInt)

It is then defaulted with the same ?? that NaN slips through:

src/lib/workflow/config-resolver.ts:242
  phaseTimeout: mergedOptions.timeout ?? DEFAULT_CONFIG.phaseTimeout,

and consumed as a raw setTimeout delay:

src/lib/workflow/phase-executor.ts:982
  }, config.phaseTimeout * 1000);

setTimeout(fn, NaN) is specified to clamp to 0, so sequant run <issue> --timeout abc should abort every phase immediately rather than falling back to the default phase timeout. This is worse than the #818 symptom: instead of a loop that won't stop, it is a run that kills each phase the moment it starts, and the resulting failure will look like a phase/agent problem rather than a bad flag value.

--timeout 30m has the same silent misparse as #818 — parseInt("30m", 10) is 30, so the user asks for 30 minutes and gets 30 seconds per phase.

Not yet reproduced end-to-end. The read of the three call sites above is solid, but I did not run sequant run --timeout abc (it starts a real workflow). First AC below is to confirm the actual runtime behavior before fixing, in case something downstream already normalizes it.

Proposal

Reuse the validator #831 already added — parsePositiveSeconds(flag) in bin/cli.ts, which requires the whole argument to be a positive integer and reports a clear InvalidArgumentError. Applying it at lines 286 and 527 is a two-line change.

The reason this was not folded into PR #831: run/ready are different commands, and tightening their accepted input range is a user-visible behavior change that deserves its own check — specifically whether --timeout 0 is currently meaningful (e.g. "no timeout"). #831 deliberately kept its scope to merge --watch.

Acceptance Criteria

  • Confirm the runtime behavior of sequant run <issue> --timeout abc (expected: phases abort immediately via a setTimeout clamped to 0) and record the observed output in the issue before fixing.
  • Determine whether --timeout 0 has an existing meaning for the phase timeout; if it does, the validator must keep accepting it, otherwise reject it as feat(#818): merge --watch — wait for CI checks to finish, then run merge-check and report #831 does.
  • --timeout on both run (bin/cli.ts:286) and the second registration (bin/cli.ts:527) rejects non-integer values with a clear error instead of coercing to NaN.
  • --timeout 30m is rejected rather than silently read as 30 seconds.
  • A regression test covers a malformed --timeout reaching config-resolver's phaseTimeout resolution, so the ?? default gap cannot silently return.
  • Any other numeric CLI flag coerced with a bare parseInt is inventoried in the PR body, with each either fixed or explicitly justified as safe.

Out of scope

Changing default phase-timeout values; the merge --watch flags (already fixed in #831); non-numeric flag validation.

References

Activity

  1. added
    bug
    cli
    on Jul 28, 2026
  2. admarble commented on Jul 28, 2026

    @admarble
    ContributorAuthor

    Plan (/spec) — #833

    Complexity: Standard (6 ACs, 3 directories: bin/, src/lib/workflow/, src/commands/)


    AC-1 evidence — reproduced before fixing ✅

    Ran the real resolution path (resolveRunOptions → buildExecutionConfig) with the value Commander would hand it, plus the actual timer:

    parseInt("abc",10)                      = NaN
    resolveRunOptions().timeout             = NaN
    buildExecutionConfig().phaseTimeout     = NaN
    setTimeout delay would be               = NaN
    timer fired after ms                    = 2.4      <-- clamped to 0, fires instantly
    parseInt("30m",10)                      = 30
    

    And the CLI accepts the flag with no error at all:

    $ sequant run 999999 --timeout abc --dry-run
    SEQUANT WORKFLOW
      ...
      !  DRY RUN - no actual execution
      (exits 0, no warning about --timeout)
    

    Confirmed: the issue's read is correct. Nothing downstream normalizes it — config-resolver.ts:183 (defined.timeout ?? settings.run.timeout) and :242 (?? DEFAULT_CONFIG.phaseTimeout) both pass NaN through, and phase-executor.ts:982 hands it straight to setTimeout, which clamps to 0 and aborts the phase on the next tick.

    (Caveat, stated plainly: the abort was demonstrated at the config+timer layer, not by spawning a real agent run. --dry-run never reaches setTimeout, and a non-dry run spawns a live Claude session. The three call sites in between are a straight pass-through with no guard, shown above.)

    AC-2 evidence — does --timeout 0 mean anything today? ❌ No

    Command --timeout 0 behavior today
    run 0 is not nullish, so it wins both ?? chains → setTimeout(fn, 0) → aborts every phase instantly. Same failure as NaN, not "no timeout".
    ready src/commands/ready.ts:111-114 guards typeof options.timeout === "number" && options.timeout > 0, so 0 is already discarded and settings.run.timeout wins.

    Nothing in phase-executor.ts, heartbeat.ts, or run-progress.ts treats 0 as a "disabled" sentinel — run-progress.ts:77's phaseTimeoutSeconds > 0 only gates a stall-threshold display, and it reads settings.run.timeout, not the flag.

    Decision: reject 0, exactly as parsePositiveSeconds already does for merge --watch. No behavior a user could be relying on is removed.


    AC Quality Check

    ⚠️ The ACs are not machine-extractable. extractAcceptanceCriteria returns {items: [], total: 0} for this body — the checkboxes are bare - [ ] text with no AC-N: / **AC-N:** prefix. Downstream /qa AC tracking and .sequant/state.json will therefore have nothing to track against.

    Mitigation: this plan assigns AC-1…AC-6 in issue order (below). No AC text is reworded. Consider adopting - [ ] **AC-1:** … in future issue bodies.

    Otherwise the ACs are strong: each names a concrete file/line or a concrete input, and each has an observable outcome. AC-1 and AC-2 are investigation gates that must be answered before the fix — both are answered above.


    Scope Assessment

    Non-Goals: present in the issue ("Out of scope" — default phase-timeout values, merge --watch flags, non-numeric flag validation). ✅

    Metric Value Status
    Feature count 1 (validate one numeric flag on two commands) ✅
    AC items 6 (2 are investigation gates, already closed) ✅
    Directory spread 3 (bin/, src/lib/workflow/, src/commands/) ✅

    Verdict: ✅ SCOPE_OK


    Acceptance Criteria

    AC-1: Confirm runtime behavior of run <issue> --timeout abc and record it before fixing

    Verification: Manual Test (evidence recorded above)
    Scenario: Given --timeout abc → When resolved through resolveRunOptions/buildExecutionConfig → Then phaseTimeout is NaN and the resulting setTimeout fires immediately.
    Status: ✅ Done — see "AC-1 evidence" above.

    AC-2: Determine whether --timeout 0 has an existing meaning

    Verification: Manual Test (evidence recorded above)
    Scenario: Given --timeout 0 → When traced through run and ready → Then no "no timeout" semantics exist; run aborts instantly, ready already discards it.
    Status: ✅ Done — validator will reject 0.

    AC-3: --timeout on both run (bin/cli.ts:286) and ready (bin/cli.ts:527) rejects non-integer values with a clear error

    Verification: Integration Test (subprocess CLI invocation, asserting exit code + stderr)
    Scenario: Given sequant run 1 --timeout abc → When the CLI parses → Then it exits non-zero with --timeout expects a whole number of seconds (got 'abc'). Same for sequant ready 1 --timeout abc.
    Assumptions: Commander's InvalidArgumentError produces exit code 1 and writes to stderr — verified in exec.

    AC-4: --timeout 30m is rejected rather than silently read as 30 seconds

    Verification: Integration Test
    Scenario: Given --timeout 30m → When parsed → Then rejected with the same error (the ^\d+$ whole-string anchor is what catches it).

    AC-5: A regression test covers a malformed --timeout reaching config-resolver's phaseTimeout resolution

    Verification: Unit Test
    Scenario: Given resolveRunOptions({timeout: NaN}) → When buildExecutionConfig runs → Then phaseTimeout is the default (1800), never NaN, and never ≤ 0.
    Note: this AC is written against config-resolver, not the CLI — see Design Review Q1.

    AC-6: Inventory every other numeric CLI flag coerced with a bare parseInt

    Verification: Manual Test (the inventory table lands in the PR body)
    Scenario: Given all 16 bare-parseInt .option()/.argument() registrations in bin/cli.ts → When each is traced to its consumer → Then each is either fixed or has a written justification for why NaN is harmless there.
    Pre-work done: all Commander registrations live in bin/cli.ts — nothing under src/ registers CLI options, so the inventory is closed at 16 sites (lines 254, 260, 286, 304, 354, 379, 417, 459, 520, 525, 527, 558, 560, 587, 600, 642).


    Implementation Plan

    Phase 1: Fix the two reported sites (AC-3, AC-4)

    1. bin/cli.ts:286 — parseInt → parsePositiveSeconds("--timeout") on run.
    2. bin/cli.ts:527 — same on ready. (ready.ts's > 0 guard already stops NaN from reaching a timer, so this site is about the silent 30m → 30s misparse and about giving a clear error instead of a silent fallback. Worth stating in the PR so the fix isn't read as papering over a live crash.)

    Phase 2: Close the ?? default gap itself (AC-5)

    1. src/lib/workflow/config-resolver.ts:242 — resolve phaseTimeout through a positivity/finiteness check rather than a bare ??, so a non-finite or non-positive value falls back to the default instead of flowing into setTimeout.

    Why both layers, not just the CLI: AC-5 asks that "the ?? default gap cannot silently return." A CLI-only fix removes today's caller but leaves the gap open for the next one — and the same class of bug (#818, then this) has now recurred once already. The CLI validator is the user-facing error; the resolver guard is the structural backstop. Cost is ~4 lines.

    Phase 3: Tests (AC-3, AC-4, AC-5)

    1. Unit test on config-resolver: NaN, 0, and negative timeout each resolve to DEFAULT_CONFIG.phaseTimeout; a valid value passes through unchanged. Mutation-check the guard (revert it locally, confirm the test fails) per the gate-test convention.
    2. Integration test driving the real CLI as a subprocess for run --timeout abc, run --timeout 30m, ready --timeout abc, ready --timeout 0 — assert non-zero exit and the error text. Plus a positive case (--timeout 60 parses) so the test can't pass vacuously.

    Phase 4: Sibling inventory (AC-6)

    1. Trace each of the 16 bare-parseInt sites to its consumer, classify fix vs safe-and-why, and put the table in the PR body. Expected shape based on a first pass:
      • Likely fix (value reaches a timer, delay, or loop bound): run --auto-wait (354), run --concurrency (379), run --max-iterations (304), relay --wait (417), stop --grace (459).
      • Likely safe (consumer already guards with > 0 / isNaN, or NaN degrades to a harmless empty filter): ready --max-iterations (520), ready --budget (525), logs --last/--issue (558/560), status [issue]/--max-age (254/260), state clean --max-age (642), dashboard/serve --port (587/600).
      • Anything in the "likely fix" column that turns out to be genuinely load-bearing beyond a two-line swap gets a follow-up issue rather than silent scope creep — AC-6 only requires inventory + justification, and the issue's Out-of-scope section is explicit that this PR is about --timeout.

    Conflict Risk Analysis

    In-flight worktree feature/817-* touches both files this issue edits:

    File #817 change #833 change Risk
    bin/cli.ts adds --ready-gate option at ~line 339 edits lines 286 and 527 Low — separate hunks, >3 lines apart; line 527 shifts by +7
    src/lib/workflow/config-resolver.ts adds readyGate: at end of buildExecutionConfig return (~line 259) edits phaseTimeout: at line 242 Low — 17 lines apart

    No textual conflict expected. Mitigation: re-fetch origin/main and merge before pushing (prior spec conflict predictions in this repo have aged badly — verify, don't assume).


    Design Review

    1. Where does this logic belong? Two layers, deliberately. Input validation belongs at the CLI boundary (bin/cli.ts) where a user-facing InvalidArgumentError can name the flag. Invariant enforcement belongs in config-resolver, which is the single funnel every caller — CLI, programmatic, future MCP — passes through on its way to setTimeout.
    2. Simplest correct approach? Reuse parsePositiveSeconds unchanged (already shipped in feat(#818): merge --watch — wait for CI checks to finish, then run merge-check and report #831, already reviewed) rather than writing a second validator. Rejected: a shared src/lib/ numeric-flag module — premature for two call sites, and it would drag merge --watch into this PR's blast radius, which the issue explicitly puts out of scope.
    3. What existing pattern does this follow? parsePositiveSeconds at bin/cli.ts:126 (feat(#818): merge --watch — wait for CI checks to finish, then run merge-check and report #831), and the defensive-guard pattern already used by batch-executor.ts:359/383 (!isNaN(x) && x >= 0 before accepting env input) and ready.ts:104/108/112 (typeof x === "number" && x > 0).
    4. What would a senior reviewer challenge?
      • "Why touch config-resolver when fixing the CLI is enough?" → AC-5 is written against the resolver, and the CLI is not the only door. Answered in Phase 2.
      • "Isn't rejecting --timeout 0 a breaking change?" → AC-2 evidence: 0 has no working meaning on either command today. Answered above.
      • "ready --timeout abc was already safe — is this fix real?" → Yes, but for the 30m misparse, not a crash. Stated honestly in Phase 1 and in the PR body rather than overclaiming.

    Feature Quality Planning

    All standard checks pass. Notable items:

    • Error message quality — the reused validator names the flag and echoes the bad value; nothing new needed.
    • Test-vacuity risk — a CLI-rejection test passes if the command fails for any reason (bad issue number, missing worktree). The integration test must assert the specific error text, and must include a positive case that succeeds parsing, or it proves nothing.
    • Docs — --timeout is documented in docs/reference/run-command.md and the READMEs; narrowing the accepted range is user-visible. Check whether any doc example passes a non-integer, and add a CHANGELOG entry.

    Derived ACs

    Source Derived AC Priority
    Test quality AC-D1: Integration tests assert the exact error text, not merely a non-zero exit, and include a passing --timeout 60 case High
    Docs AC-D2: CHANGELOG entry noting --timeout now rejects non-integer and 0 values on run/ready Medium

    Open Questions

    1. Should the "likely fix" sibling flags (--auto-wait, --concurrency, --relay --wait, --stop --grace) be fixed in this PR or filed as a follow-up? — Recommendation: fix them here only where it is the same one-line parsePositiveSeconds swap with no semantic change; file a follow-up for any that need a different validator (e.g. --auto-wait 0 is a documented "off" sentinel per feat(run): --auto-wait — continue a rate-limited run when the window resets instead of halting #804, so it needs a non-negative validator, not a positive one). Impact if wrong: either scope creep, or a second sibling issue three weeks from now — which is exactly how this issue came to exist.

    Recommended Workflow

    Phases: spec → exec → qa
    Quality Loop: disabled (SCOPE_OK, tightly bounded change)
    Reasoning: CLI/config change with no UI surface — /test is not applicable. /testgen skipped: bug label, and the two tests are targeted regression cases better written against the real call sites than stubbed from criteria.


    Label Review

    Current: bug, cli
    Recommended: bug, cli, no-browser-test
    Reason: no UI surface; no-browser-test makes the /test skip explicit rather than incidental.
    Quality Loop: won't auto-enable (SCOPE_OK).


  3. added
    planned
    no-browser-test
    on Jul 28, 2026
  4. added a commit that references this issue on Jul 28, 2026
  5. admarble commented on Jul 28, 2026

    @admarble
    ContributorAuthor

    QA Review for Issue #833

    PR: #836 · Reviewed at: e2149ef · Branch: 0 commits behind origin/main

    Review method: inline. Diff is 535 lines across 9 files — under the 600-line threshold where sub-agent review on worktree code is unreliable. Quality checks run directly rather than delegated.


    AC Coverage

    AC Source Description Status Notes
    AC-1 Original Confirm runtime behavior of run --timeout abc and record output before fixing MET Recorded in the plan comment before any code changed: phaseTimeout = NaN, setTimeout delay NaN, timer fired after 2.4 ms (clamped to 0). CLI accepted the flag with no error at all. See caveat under Adversarial Re-Read.
    AC-2 Original Determine whether --timeout 0 has an existing meaning; keep accepting it if so, else reject MET Traced both commands. run: 0 won both ?? chains → setTimeout(fn, 0) → same instant-abort as NaN. ready: already discarded by ready.ts:111-114's > 0 guard. No sentinel treatment in phase-executor.ts, heartbeat.ts, or run-progress.ts (run-progress.ts:77's > 0 gates a display threshold and reads settings.run.timeout, not the flag). Rejected, per #831.
    AC-3 Original --timeout on run (cli.ts:286) and the second registration (cli.ts:527 = ready) rejects non-integers with a clear error MET Both now use parsePositiveSeconds("--timeout"). Verified against the built CLI: error: option '--timeout <seconds>' argument 'abc' is invalid. --timeout expects a whole number of seconds (got 'abc'). Non-zero exit on both commands.
    AC-4 Original --timeout 30m rejected rather than read as 30 MET The ^\d+$ whole-string anchor rejects it; test covers 30m, 30s, 5min, 1.5, 2h.
    AC-5 Original Regression test covers a malformed --timeout reaching config-resolver's phaseTimeout resolution, so the ?? default gap cannot silently return MET config-resolver.numeric-guards.test.ts — 25 cases over NaN/0/negative/±Infinity, asserted on the property that matters (setTimeout delay is finite and > 0), plus a direct-buildExecutionConfig case that bypasses resolveRunOptions. The gap is also closed, not just tested: positiveOr() replaces the bare ??.
    AC-6 Original Every other bare-parseInt numeric CLI flag inventoried in the PR body, each fixed or explicitly justified as safe MET All 16 sites inventoried in the PR body — 8 fixed, 8 justified. Inventory verified closed: grep '\.option(' over src/ returns no Commander registrations outside bin/cli.ts.
    AC-D1 Derived (Test quality) Integration tests assert exact error text, not merely non-zero exit, and include a passing --timeout 60 case MET Every rejection case pins a specific message regex. Positive controls strengthened during this review — see Adversarial Re-Read.
    AC-D2 Derived (Docs) CHANGELOG entry noting --timeout now rejects non-integer and 0 on run/ready MET ## [Unreleased] → ### Fixed, with issue ref. Flag tables in run-command.md and ready-command.md also updated.

    Coverage: 8/8 met · Original: 6/6 · Derived: 2/2


    CI Status

    Check State Bucket Impact
    typecheck SUCCESS pass ✅ MET
    build (22.x) SUCCESS pass ✅ MET
    node-floor-guard SUCCESS pass ✅ MET
    validate-skills SUCCESS pass ✅ MET
    validate-plugin SUCCESS pass ✅ MET

    CI Summary: 5 passed, 0 pending, 0 failed. Not infra-blocked (no all-failing board).


    Quality Metrics

    Metric Value Status
    Type issues (any added) 0 ✅ OK
    Deleted tests 0 ✅ OK
    Files changed 9 ✅ OK
    Lines added +535 -
    Lines deleted -58 -
    Local suite 4417 passed, 1 expected fail, 2 skipped (212 files) ✅ OK
    npm run build / npm run lint pass / pass (0 warnings) ✅ OK

    Test Coverage Analysis

    Changed File Tier Has Tests? Test File
    src/lib/cli-flags.ts Standard ✅ Yes src/lib/cli-flags.test.ts
    src/lib/workflow/config-resolver.ts Standard ✅ Yes src/lib/workflow/config-resolver.numeric-guards.test.ts
    bin/cli.ts Standard ✅ Yes src/commands/numeric-flags.integration.test.ts (subprocess)

    Coverage: 3/3 changed source files covered. No critical-path (auth/payment/security) files touched.

    Mutation-verified — the tests actually carry the change:

    Mutation Result
    Revert positiveOr → bare ?? in config-resolver.ts 20 of 25 guard tests fail
    Revert run --timeout → parseInt (leaving ready and merge intact) exactly 4 assertions fail — the run --timeout ones; ready --timeout stays green

    The second is the more informative result: it shows the wiring tests are scoped per-site rather than passing on a blanket condition.


    Code Review

    Strengths

    • Reuses the reviewed feat(#818): merge --watch — wait for CI checks to finish, then run merge-check and report #831 validator instead of writing a second one. parsePositiveSeconds is preserved as a named wrapper, so merge --watch's messages are byte-identical — confirmed by running the built CLI: --interval abc → expects a whole number of seconds, --interval 0 → must be at least 1 second. The singular/plural handling (unitSingular) exists specifically to preserve "1 second".
    • Defense in depth at the right two layers, with the reasoning recorded in the code: the CLI names the flag for the user; the resolver is the funnel every caller passes through.
    • Per-flag minimums are set from actual semantics, not copied: --auto-wait and --grace use min: 0 because 0 is meaningful for both (feat(run): --auto-wait — continue a rate-limited run when the window resets instead of halting #804 defines it as "off"; --grace 0 means escalate immediately). A blanket min: 1 would have been a silent regression.
    • Comments state intent and consequence at each site (while (iteration < NaN) is false on entry → zero phases), so the next reader knows why the coercion matters rather than just that it changed.
    • Extracting to src/lib/cli-flags.ts is motivated, not incidental: bin/cli.ts calls program.parse() at import time and cannot be imported from a test.

    Issues

    • One found and fixed during this review (see Adversarial Re-Read); nothing outstanding.

    Suggestions

    • settings.run.timeout is z.number().default(1800) with no positivity constraint, so "timeout": 0 in settings.json still parses. positiveOr now catches it at buildExecutionConfig, so the instant-abort is closed — but the user gets a silent fallback rather than a schema error naming the bad setting. Tightening the Zod schema to .positive() would move that to load time. Out of scope here (the issue's Non-Goals exclude default-value changes) and non-blocking, since the dangerous path is already closed.

    Test Quality Review

    Category Status Notes
    Behavior vs implementation ✅ OK Asserts on the consequential property (setTimeout delay finite and > 0; 0 < maxIterations) with the source line cited, not on internal shape.
    Coverage depth ✅ OK abc, empty, whitespace, NaN, Infinity, 1e3, 0x10, --, 30m, 30s, 5min, 1.5, 2h, -5, 0, oversized, whitespace-padded.
    Mock hygiene ✅ OK No mocks. Unit tests call the real validator; integration tests spawn the real built CLI.
    Test reliability ✅ OK No timers, no network, no fixtures. Every integration invocation exits during argument coercion or on a deterministic local precondition — none starts a workflow or contacts GitHub.
    Vacuity ✅ OK Every rejection pins specific message text. Positive controls now pin the downstream message they must reach (fixed below).

    Anti-Pattern Detection

    Dependency audit: N/A — package.json unchanged.

    Code patterns: no findings. No await in loops, no empty catch, no hardcoded secrets, no SQL concatenation, no uncleared timers, no 0.0.0.0 binds. Regex is a bounded ^\d+$ with no backtracking risk.


    Call-Site Review

    New exported functions: 2 (parseWholeNumber, parsePositiveSeconds — moved from private scope in bin/cli.ts to exports in src/lib/cli-flags.ts).

    Function Call sites Loop? Conditions AC match
    parseWholeNumber bin/cli.ts ×6, cli-flags.ts:60 (wrapper) No Commander coercion callbacks ✅ AC-6
    parsePositiveSeconds bin/cli.ts ×4 (run, ready, merge --interval, merge --timeout) No Commander coercion callbacks ✅ AC-3

    Neither is a dead export. Verified each is invoked once per registration at module load (the factory returns the coercion), which is the same lifecycle as before the move.


    CLI Registration Verification

    bin/cli.ts was modified, but no option interface fields were added or removed — this changes coercion functions on existing registrations only. RunOptions is untouched. No new field can be unwired.

    Confirmed no registration was accidentally dropped: run --timeout, ready --timeout, ready --max-iterations, ready --budget, run --max-iterations, run --concurrency, run --auto-wait, abort --grace all still parse valid values (positive-control tests) and all still appear in --help.

    Status: Passed


    Execution Evidence

    Test Command Result
    Rejection (run) node dist/bin/cli.js run 1 --timeout abc ✅ non-zero, --timeout expects a whole number of seconds (got 'abc')
    Rejection (ready) node dist/bin/cli.js ready 1 --timeout abc ✅ same message
    Boundary node dist/bin/cli.js run 1 --timeout 0 ✅ --timeout must be at least 1 second (got '0')
    No regression (#831) node dist/bin/cli.js merge 1 --watch --interval abc / --interval 0 ✅ messages byte-identical to pre-change
    Accept node dist/bin/cli.js ready 999999 --timeout 60 --json ✅ reaches No worktree found for issue #999999
    Accept node dist/bin/cli.js abort 999999 --grace 0 --json ✅ reaches No relay PID found for #999999
    Pre-fix repro node dist/bin/cli.js run 999999 --timeout abc --dry-run (before fix) ✅ exited 0 silently — the defect

    Status: Complete. No scripts/ files changed, so /verify is not applicable; the CLI surface was exercised directly above.


    Skill / Detection-Pattern Verification

    N/A — no .claude/skills/**/*.md, templates/skills/**, or skills/** files changed.

    Behavior-Rule Survival Check

    N/A — ran detectBehaviorRule over each AC; none triggered (highest was 1 keyword: AC-1 behavior, AC-5 default; the heuristic needs ≥2).

    Manual Test ACs

    AC-1 and AC-2 are investigation ACs requiring runtime observation, and both were executed, not asserted from code review — the timing measurement and the CLI transcripts are recorded in the plan comment and reproduced in the PR body. No override claimed.

    CHANGELOG Verification

    Check Status
    CHANGELOG.md exists ✅
    User-facing change ✅ (fix(#833): prefix)
    [Unreleased] entry ✅ Present, under ### Fixed
    Format ✅ Includes (#833)

    Risk Assessment

    • Likely failure mode: a user or CI script currently passing a leniently-parsed value (--timeout 30m, --concurrency 3x, --budget 10k) now gets a hard error instead of silently-wrong behavior. Intended, but a user-visible break — mitigated by the CHANGELOG entry and the two doc-table notes. The narrower risk is a wrong per-flag minimum; both min: 0 choices were traced to their consumers (createAutoWaitLedger, abort.ts:135) rather than assumed.
    • Not tested: no test spawns a live agent run to observe the instant-abort end to end. The chain from phaseTimeout to setTimeout is asserted as a property, not executed against a real phase. Also untested: settings.json supplying a non-positive run.timeout (the resolver guard covers it, but nothing pins that path).
    • Sibling sites considered (cross-file): all Commander registrations live in bin/cli.ts — grep '\.option(' over src/ finds none, so the cross-file surface is closed by construction. Non-CLI parseInt uses in src/ were reviewed and are parsing trusted internal text (git output, log filenames, GitHub API fields), not user flag input; they carry their own isNaN filters where it matters (batch-executor.ts:343, getEnvConfig).
    • Sibling-line audit (intra-file): exhaustive. All 16 bare-parseInt sites in bin/cli.ts traced to their consumers and classified — 8 fixed, 8 justified with the specific mechanism that makes each harmless (fail-closed filter, > 0 guard, or a loud range error). Two of the eight fixed — run --max-iterations (zero phases) and abort --grace (grace period skipped) — were genuinely broken and are outside the literal AC-3/AC-4 text; AC-6 is what required them.

    Trust-Boundary Check

    Finding: Clean — the issue body is an ordinary bug report. Its imperatives ("Reuse the validator #831 already added", "Confirm the runtime behavior … before fixing") are product/process requirements from the author, carrying no execute/fetch/exfiltrate payload. No HTML comments, fenced blocks, or trailing prose contain agent-directed instructions. The diff adds no network call, no shell-out, no file read outside the repo.

    Status: Clean


    Adversarial Re-Read

    Findings — one real gap surfaced and fixed during this review:

    1. Vacuous positive controls (fixed in e2149ef). The ready and abort acceptance cases asserted only the absence of a coercion error (expect(output).not.toMatch(...)). That assertion stays green if the command starts failing before the flag is ever parsed — the test would report success having proven nothing about coercion. Each case now also pins the specific downstream message it must reach (No worktree found for issue #999999, No relay PID found for #999999, Unknown phase 'bogus'), which is only reachable past argument coercion. This also subsumes and replaces the separate exit-during-parsing guard, which covered only the run cases.

    What else was scanned, and the result:

    • Verbatim motivating-example fixtures from the issue body — the issue quotes three code locations (bin/cli.ts:286, bin/cli.ts:527, config-resolver.ts:242), the input --timeout abc, and the input --timeout 30m. Every one was run against the built CLI, not merely read; transcripts are in Execution Evidence. Line 527's identity was confirmed as ready, not assumed from the issue's "the second registration".
    • Evidence claims audited for the pre-fix/post-fix confusion. AC-1's phaseTimeout = NaN / 2.4 ms measurement is a pre-fix bug reproduction, correctly labeled as such and dated before any code changed. The post-fix validation is separate (the rejection transcripts). These are not conflated.
    • Process state. Working tree clean, all work committed, branch 0 behind origin/main, both commits pushed, no stashes. git diff --stat matches the PR.
    • Non-Goals. The issue excludes changing default phase-timeout values, the merge --watch flags, and non-numeric flag validation. None was touched: no default changed; merge's two registrations are textually unmodified and produce byte-identical messages (verified by execution); no non-numeric flag validation was added. The AC-6 sibling fixes are within scope — AC-6 explicitly requires each site be "fixed or explicitly justified as safe", and two of them could not honestly be called safe.
    • The --concurrency interaction. Validating at the CLI makes run.ts:76-81's error unreachable from the command line. Checked for a test asserting that CLI path — none exists; the check remains reachable programmatically and the full suite is green.
    • maxIterations: 0 regression check. The new guard makes a programmatic 0 fall back to the default instead of passing through. Grepped for intentional uses: the only hit is run-log-schema.test.ts:242, a schema-parse test that never touches buildExecutionConfig. No behavior anyone relies on.

    Status: Gaps Found — one test-vacuity gap, surfaced and fixed in this PR rather than deferred. Nothing outstanding.


    Verdict: AC_MET_BUT_NOT_A_PLUS

    All 8 ACs (6 original + 2 derived) are MET, CI is fully green, the change is mutation-verified at both layers, and the #831 messages it builds on are provably unchanged. The verdict is not READY_FOR_MERGE on a technicality worth stating plainly rather than papering over: §7's algorithm floors at AC_MET_BUT_NOT_A_PLUS when the adversarial re-read reports Gaps Found, and it did — the vacuous positive controls were a genuine defect in the test suite, found here rather than in review.

    The gap is fixed, not deferred, and the fix is in this PR. In substance this is merge-ready; the label reflects that a gap existed and was caught, which is the signal the gate is for.

    One non-blocking suggestion recorded above: settings.run.timeout's Zod schema still accepts 0 and negatives. The dangerous path is already closed by the resolver guard, so this is a diagnostics improvement, not a defect — and the issue's Non-Goals put default-value changes out of scope.

    Documentation

    • docs/reference/run-command.md — --timeout and --max-iterations rows note the whole-number requirement
    • docs/reference/ready-command.md — --timeout, --budget, --max-iterations rows updated
    • CHANGELOG [Unreleased] → Fixed entry added
    • No README change needed — no new flag or command; accepted input for existing flags narrowed

    Next Steps

    1. Human review and merge of PR fix(#833): reject malformed numeric CLI flags instead of coercing them to NaN #836.
    2. Optional follow-up: tighten RunSettingsSchema.timeout to .positive() so a bad settings.json value fails at load with a named error instead of silently falling back.
  6. added
    needs-improvement
    and removed
    planned
    on Jul 28, 2026
  7. admarble commented on Jul 28, 2026

    @admarble
    ContributorAuthor

    /fullsolve Complete

    Issue: #833 · PR: #836 · Status: AC_MET_BUT_NOT_A_PLUS — ready for human review

    Summary

    Metric Result
    ACs 8/8 met (6 original + 2 derived)
    CI 5/5 green
    Local suite 4417 passed · 212 files
    Build / Lint pass / pass (0 warnings)
    Diff +535 / −58 across 9 files

    Progress

    Phase Iterations Status
    Spec 1/1 Complete — AC-1 and AC-2 answered with recorded evidence before any code changed
    Exec 1/1 Complete
    Test — Skipped (no-browser-test; no UI surface)
    QA 1/2 Complete — one gap surfaced and fixed in-PR

    What shipped

    --timeout abc reached setTimeout as NaN, which clamps to 0 — every phase aborted on its first tick, and it read as a phase fault rather than a bad flag. Fixed at two layers: the CLI now rejects it by name, and buildExecutionConfig no longer resolves phaseTimeout/maxIterations through a bare ??.

    The AC-6 audit covered all 16 bare-parseInt CLI coercions — 8 fixed, 8 justified. Two of the fixes were genuinely broken and outside the literal AC text: run --max-iterations (a NaN bound ran zero phases) and abort --grace (the SIGINT grace period was skipped entirely).

    Both guards are mutation-verified: reverting the resolver guard fails 20/25 of its tests; reverting run --timeout alone fails exactly its 4 assertions and leaves ready green.

    Why not READY_FOR_MERGE

    The adversarial re-read found the ready/abort positive-control tests asserted only the absence of a coercion error — they would have passed vacuously if those commands started failing before the flag was parsed. Fixed in e2149ef (each now pins the downstream message it must reach). The §7 gate floors at AC_MET_BUT_NOT_A_PLUS when the re-read reports a gap, which it did. In substance this is merge-ready; the label records that a real defect existed and was caught.

    Follow-up (non-blocking)

    RunSettingsSchema.timeout is z.number().default(1800) with no positivity constraint, so "timeout": 0 in settings.json still parses. The resolver guard closes the dangerous path, but a .positive() schema would fail at load with a named error instead of silently falling back. Out of scope here — the issue's Non-Goals exclude default-value changes.


    Stopping at the human merge gate. Full QA review: #833 (comment)

  8. added 2 commits that reference this issue on Jul 28, 2026
  9. admarble commented on Jul 28, 2026

    @admarble
    ContributorAuthor

    QA Re-Review for Issue #833 (gap-fix pass)

    PR: #836 · Reviewed at: caa41ba0 · Branch: merged with origin/main (includes #817), 0 behind

    The previous review closed at AC_MET_BUT_NOT_A_PLUS on a test-vacuity gap. Fixing that gap prompted a re-read of the fix itself, which found a real defect the original fix did not cover plus two supporting gaps. All are now fixed in this PR.


    Gaps found and closed

    # Gap Severity Status
    1 sequant ready's phase timeout bypasses buildExecutionConfig, so a non-positive settings.run.timeout reached setTimeout unguarded — the #833 instant-abort, on an uncovered path Defect Fixed
    2 settings.json was an unguarded entry point: run.timeout/concurrency/maxIterations were z.number() with no constraint, so a bad value was silently swapped for a default Diagnostics Fixed
    3 validateSettings discarded the entire settings file on any single invalid key, while its comment claimed it stripped only invalid fields Latent bug Fixed
    4 Tautology detector: 10 blocks (52.6%, over its blocking threshold) had no visible production call Test quality Fixed
    5 Positive-control tests asserted only absence, passing vacuously if the command failed before parsing Test quality Fixed (e2149ef)

    Gap 1 reproduced before fixing, same discipline as AC-1:

    settings.json { "run": { "timeout": 0 } }
      -> validateSettings: run.timeout parsed as 0, warnings: []
      -> ready phaseTimeout = 0  ->  setTimeout delay = 0    <-- instant abort, silent
    

    This is the one that matters. My first-pass review checked how ready handles --timeout 0 (the > 0 guard) but did not trace what happens when the settings value is the bad one — and ready-gate.ts's buildPhaseConfig builds its own ExecutionConfig, so the resolver guard never ran. The sibling-line audit was exhaustive within bin/cli.ts; it did not extend to "who else produces this value."

    Gap 3 was a prerequisite, not scope creep. Adding the constraints in gap 2 without it would have meant one bad number silently reverting every unrelated setting — a net regression over the status quo.


    AC Coverage (unchanged, re-verified at caa41ba0)

    AC Status Note
    AC-1 … AC-6 MET All six re-verified against the merged tree; execution transcripts in the PR body
    AC-D1, AC-D2 MET Test-quality and CHANGELOG derived ACs

    Coverage: 8/8. The gap fixes strengthen AC-5 (the ?? default gap is now closed on both producers, not one) and AC-6 (the inventory's premise — that bin/cli.ts is the whole surface — held for flags, but settings.json was a second entry point the inventory did not consider).


    CI Status

    Check State Impact
    typecheck · build (22.x) · node-floor-guard · validate-skills · validate-plugin SUCCESS ×5 ✅ MET

    Quality Metrics

    Metric Value
    Full suite 4500 passed, 215 files, 1 expected fail, 2 skipped
    Build / lint pass / pass (0 warnings)
    Tautology gate ✅ OK — all tests call production code
    Type issues (any added) 0
    Deleted tests 0

    Three tests failed in one full-suite run under parallel load (precheck, scrollback-harness, lock-manager); all three pass in isolation and pass in the final run. Flakes, not regressions.


    Deliberate behavior changes

    Both are user-visible and neither is incidental:

    1. __tests__/settings-schema.test.ts no longer asserts run.timeout: 0 parses. That test pinned the exact permissiveness AC-2 proved is a defect. Rather than delete the case, its original intent — "zero values in numeric fields are fine" — moves to staleBranchThreshold, where 0 genuinely is meaningful, and a new case asserts the three guarded fields reject it. I did not silently rewrite a test to make my change pass; the old expectation was wrong and the replacement says why.

    2. buildExecutionConfig now falls back to settings.run.* before DEFAULT_CONFIG. This removes the layering asymmetry between the two producers. The asymmetry is what let gap 1 hide, so making them identical is the actual fix, not just a tidy-up.


    Mutation verification

    Every guard in this PR, including the new ones:

    Mutation Result
    Revert positiveOr → bare ?? in config-resolver 20 of 25 fail
    Revert run --timeout → parseInt (leaving ready/merge intact) exactly 4 fail; ready stays green
    Revert ready.ts chaining → old CLI-only guard 17 of 30 fail
    Revert schema .positive() 10 of 50 fail
    Revert salvage → old parse({}) 5 of 19 fail

    Risk Assessment

    • Likely failure mode: a project whose settings.json contains "timeout": 0 (or another non-positive value in the three guarded keys) now sees a warning and the default instead of silent acceptance. That is the intent, and it replaces an instant-abort with a working run — but it is a behavior change, recorded in the CHANGELOG and the generated settings reference. Second-order risk is the salvage rewrite: it now touches every settings-validation path, so a mistake there would surface broadly. It is covered by 19 new cases including array-index, nested-section, multi-key, non-object-root, and never-throws.
    • Not tested: still no test spawning a live agent run to observe the instant-abort end to end; the chain from phaseTimeout to setTimeout is asserted as a property at all three consumption sites' shared source rather than executed against a real phase. Also untested: SEQUANT_* env-var overrides for these numerics (none exist for timeout; SEQUANT_MAX_ITERATIONS already filters isNaN in getEnvConfig).
    • Sibling sites considered (cross-file): the question that found gap 1 — who else produces this value? Three setTimeout(…, config.phaseTimeout * 1000) sites exist (phase-executor.ts:982, drivers/claude-code.ts:77, drivers/aider.ts:63); all three read the same ExecutionConfig, so both producers being guarded covers all three. feat(run): --ready-gate — run the post-QA ready gate inside sequant run (automates the any-gaps/fix-gaps second look, stops at human merge) #817's new in-run ready gate passes config.phaseTimeout from the guarded config, so it adds no fourth path.
    • Sibling-line audit (intra-file): unchanged and exhaustive — all 16 bare-parseInt sites in bin/cli.ts classified, 8 fixed, 8 justified.

    Trust-Boundary Check

    Finding: Clean — no agent-directed instruction in the issue or comments was acted on. The diff adds no network call, shell-out, or file access outside the repo.

    Status: Clean


    Adversarial Re-Read

    Findings: No gaps outstanding. What was scanned this pass:

    • The previous pass's own conclusions, re-examined. This is what produced gap 1 — the earlier review verified --timeout 0's handling in ready.ts and stopped there, without asking which code path builds ready's ExecutionConfig. The lesson is recorded above rather than glossed.
    • Merge with origin/main. feat(run): --ready-gate — run the post-QA ready gate inside sequant run (automates the any-gaps/fix-gaps second look, stops at human merge) #817 landed in exactly the two files I predicted would overlap. Merged cleanly; verified readyGate and the chained guards coexist in the merged buildExecutionConfig, and that feat(run): --ready-gate — run the post-QA ready gate inside sequant run (automates the any-gaps/fix-gaps second look, stops at human merge) #817's in-run gate consumes the guarded value rather than building its own.
    • Prerequisite ordering. Confirmed gap 3 must be fixed before gap 2, and stated why, rather than presenting three independent improvements.
    • The tautology finding, taken seriously rather than dismissed. The detector's heuristic (direct call to an imported symbol inside the block) technically produced false positives — the tests did exercise production code. But the underlying complaint was fair, and per repo convention a failing tautology gate is usually a real finding. Fixed by making the coupling visible; @tautology-skip was deliberately not used.
    • Flaky-vs-regression discrimination. The three parallel-load failures were each re-run in isolation before being dismissed, not assumed flaky.

    Status: Clean


    Verdict: READY_FOR_MERGE

    All 8 ACs met, CI green, full suite green, every guard mutation-verified, tautology gate passing, and the branch is merged up to date with origin/main. The gaps that held the previous verdict at AC_MET_BUT_NOT_A_PLUS are closed in this PR rather than deferred, and the most serious of them — a live instant-abort on the ready path — was found and fixed here rather than in production.

    Two deliberate behavior changes are called out above for the human reviewer; neither is incidental and both are documented in the CHANGELOG and settings reference.

    Next Steps

    1. Human review and merge of PR fix(#833): reject malformed numeric CLI flags instead of coercing them to NaN #836.
  10. added
    ready-for-review
    and removed
    needs-improvement
    on Jul 28, 2026
  11. added 2 commits that reference this issue on Jul 29, 2026
  12. added 7 commits that reference this issue on Jul 29, 2026
  13. added 2 commits that reference this issue on Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugclino-browser-testready-for-review

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions