Skip to content

feat(mcp): configurable per-phase no-progress wall for sequant_run — judgment-tier exec phases die at the hard-coded 30 minutes #1049

Open

Description

@admarble

Tier: mechanical Found: 2026-09-10/11 running the wave-2 graph over MCP (#980, #990, #1024)

Why

PHASE_TIMEOUT in src/mcp/tools/run.ts is hard-coded to 1 800 000 ms and applied by spawnAsync as a no-progress kill, reset only on SEQUANT_PROGRESS lines — which exec emits only at phase boundaries. Any exec phase that takes longer than 30 minutes end-to-end is killed as "no progress", even when it is healthily running the test suite. run.timeout in .sequant/settings.json (5400 here) does not extend it. In wave 2 of sequant's own graph four exec phases died at that wall (#990 ×1, #980 ×2, #1024 ×1); two of them had already committed everything and were on their last full-suite run. Each kill costs a re-dispatch (spec context reload + worktree reuse) and, in one case (#1024), the worktree was reaped — only the branch commits survived.

The CLI path has no such wall (run.timeout governs it), so the limit is an MCP-only regression in capability for exactly the issues a runner tiers as judgment.

Proposed change

  • Add timeoutMinutes (or phaseTimeoutMs) to the sequant_run MCP input schema, bounded (e.g. 10–120 min), defaulting to the current 30; document the minimum server version in the description (NEEDS_VERIFICATION maps to ready_for_merge, blocking QA re-runs; MCP sequant_run ignores force #972 precedent: older servers drop unknown params silently).
  • Honour run.timeout from settings as the default when the param is absent, so the two paths agree.
  • Keep the no-progress semantics; optionally have exec emit a heartbeat progress line every N minutes while its agent is alive so a genuinely healthy long phase resets the watchdog and a hung one still dies.

Scope

  • may touch: src/mcp/tools/run.ts (schema, PHASE_TIMEOUT → resolved value), src/mcp/tools/run.test.ts, docs/reference/mcp-server.md (or wherever sequant_run params are documented), CHANGELOG.md (one bullet).
  • not in scope: the CLI's run.timeout semantics; exec-phase progress events (separate, optional follow-up).

Acceptance criteria

  • AC-1: sequant_run accepts timeoutMinutes; a value outside the bound is rejected with a clear error — Verify: npx vitest run src/mcp/tools/run.test.ts -t "timeoutMinutes" → accepted 45 forwards a 2 700 000 ms wall to spawnAsync; 5 and 500 are rejected.
  • AC-2: with the param absent, the wall equals run.timeout from settings when set, else 30 minutes — Verify: npx vitest run src/mcp/tools/run.test.ts -t "default wall".
  • AC-3: the tool description names the minimum server version that honours the param — Verify: grep -c "timeoutMinutes" src/mcp/tools/run.ts ≥ 2 (schema + description).
  • AC-4: documented — Verify: grep -rc "timeoutMinutes" docs/reference/ CHANGELOG.md ≥ 2.
  • AC-5: suite green — Verify: npm run build && npm test.

Related: #435 (progress notifications — the reset mechanism this relies on), #508 (in-process engine would remove the subprocess wall entirely), #1032 (the background-task stranding that shared the symptom).

Activity

  1. added
    enhancement
    on Sep 11, 2026
  2. admarble commented on Sep 11, 2026

    @admarble
    ContributorAuthor

    Complexity: Standard (5 ACs, 3 directories)

    AC Quality Check

    • All 5 AC use — Verify: clauses, not the house Evidence: format the AC parser scans for (constitution §2). None register as declared evidence, so extractAcceptanceCriteria falls back to keyword inference — which resolves all 5 to manual in state.json. Doesn't block planning (each Verify command is concrete and automatable); flagging so a future pass can rewrite them as Evidence: clauses for automation.
    • AC-3's verify command is weak. grep -c "timeoutMinutes" src/mcp/tools/run.ts ≥ 2 passes as soon as the schema field exists (field name + destructuring already produce ≥2 hits) — it never actually confirms a version string was written. See Open Questions.
    • AC-4's verify path is stale. docs/reference/ exists but has no mcp-server.md; the real sequant_run docs live at docs/features/mcp-server.md (has a "Tools Reference" → sequant_run section already). See Open Questions.

    Scope Assessment

    Non-Goals: ⚠️ Not found in issue body.

    Metric Value Status
    Feature count 1 ✅
    AC items 5 ✅
    Directory spread 4 (heuristic) ⚠️

    Verdict: ⚠️ SCOPE_WARNING (auto-enables quality loop)

    The directory-spread count is keyword-driven, not path-driven — it picked up "settings"/"test"/"docs" as directory tokens from AC prose rather than real paths. Actual touched locations: src/mcp/tools/ (run.ts, run.test.ts), docs/features/ (mcp-server.md), repo root (CHANGELOG.md) — 3. Treating the 4 as a heuristic false positive, but quality loop still auto-enables since Non-Goals is genuinely missing.

    Note: an empty worktree already exists for this issue (feature/1049-..., HEAD == main, no commits/diff) — leftover from a prior dispatch. Not a real conflict; /exec can reuse or recreate it.

    Acceptance Criteria

    AC-1: timeoutMinutes accepted; out-of-bound rejected

    Verification: Unit Test
    Scenario: Given runToolInputSchema → When parsed with timeoutMinutes: 45 → Then accepted and resolves to a 2,700,000ms wall passed to spawnAsync. Given 5 or 500 → rejected at schema validation.
    Assumptions: zod-level .min(10).max(120) is sufficient; no separate handler-level check needed.

    AC-2: default wall = run.timeout (settings) else 30 min

    Verification: Unit Test
    Scenario: Given timeoutMinutes absent and settings.run.timeout=5400 → resolves to 5,400,000ms. Given settings unavailable → resolves to 1,800,000ms (current behavior, unchanged).
    Assumptions: getSettings() already defaults run.timeout to 1800s when unset (settings.numeric-guards.test.ts), so the "else 30 min" branch is mostly about getSettings() itself failing (missing/corrupt .sequant/), not an unset field.

    AC-3: description names minimum server version

    Verification: Unit Test
    Scenario: runToolInputSchema.timeoutMinutes.description contains a version string, mirroring the existing fullQa precedent (run.test.ts:752-754, #982) — same assertion shape, not just the grep count.

    AC-4: documented

    Verification: Manual Test (doc content check)
    Scenario: docs/features/mcp-server.md's sequant_run Tools Reference section and one CHANGELOG.md Unreleased/Added bullet both mention timeoutMinutes.

    AC-5: suite green

    Verification: Integration Test (CI gate)
    Scenario: npm run build && npm test passes.

    Implementation Plan

    Phase 1: Schema + resolution (src/mcp/tools/run.ts)

    1. Import getSettings from ../../lib/settings.js.
    2. Add timeoutMinutes: z.number().int().min(10).max(120).optional().describe(...) to runToolInputSchema (~L504), naming the minimum server version (mirror fullQa's wording at ~L536).
    3. Extract a small exported resolvePhaseTimeoutMs(timeoutMinutes, settings) helper (same "exported for testing" convention as buildRunArgs/resolveCliBinary): timeoutMinutes present → *60_000; else settings.run.timeout*1000; wrap the getSettings() call in try/catch falling back to the PHASE_TIMEOUT constant.
    4. Replace timeout: PHASE_TIMEOUT (~L698) with timeout: phaseTimeoutMs.
    5. Update the tool's top-level description (~L578-583) — "up to 30 minutes" → reflects the configurable wall.

    Phase 2: Tests (src/mcp/tools/run.test.ts)

    1. Bound test via z.object(runToolInputSchema).safeParse(...) with 5/45/500 (mirrors the fullQa live-surface tripwire at L748).
    2. resolvePhaseTimeoutMs unit tests for both resolution branches.
    3. Description-version assertion, following run.test.ts:752-754 exactly.

    Phase 3: Docs + CHANGELOG

    1. docs/features/mcp-server.md — extend the sequant_run Tools Reference (~L219) and the "30-minute ceiling" prose (~L236).
    2. One CHANGELOG.md bullet under ## [Unreleased] → ### Added.

    Design Review

    1. Where does this belong? The resolution logic is pure — extract it as an exported function alongside buildRunArgs, not inline in the handler closure.
    2. Simplest correct approach? Declarative zod bound, no duplicate manual check.
    3. Existing pattern? fullQa (feat(run): fresh-session QA — never resume the exec session into qa; expose run.fullQa (setting + --full-qa + MCP param) #982): optional zod field + version note in .describe() + description-regex test + live-surface tripwire. Reuse that shape exactly.
    4. Senior-reviewer challenge? Why not expose MAX_TOTAL_TIMEOUT too? Out of scope per the issue's own list; the 120-min upper bound already sits at the existing 2h absolute ceiling, so no interaction to resolve.

    Open Questions

    1. AC-4's verify path (docs/reference/) vs. actual doc location (docs/features/mcp-server.md). Recommendation: document at the real location per the issue's own hedge ("or wherever ... documented"); note the correction in the PR rather than blocking. Impact if unresolved: AC-4's literal command needs the path substituted before it passes.
    2. Is AC-3's grep count sufficient alone? Recommendation: keep it (cheap, as written) but also add the run.test.ts:752-style description assertion, since that pattern already exists for the near-identical fullQa case. Impact if skipped: AC-3 could pass on a false positive (two bare mentions, no version string).

    Recommended Workflow

    Phases: spec → testgen → exec → qa
    Quality Loop: enabled
    Reasoning: AC-1/AC-2 are Unit Test verification (schema-bound rejection; settings-driven default) — testgen stubs both before implementation, mirroring the existing fullQa scaffolding in the same file. Quality loop auto-enables from SCOPE_WARNING (missing Non-Goals).

    Label Review

    Current: enhancement
    Recommended: enhancement, planned
    Reason: Standard-tier feature spec; 5 AC, no cross-cutting refactor.
    Quality Loop: Will auto-enable (SCOPE_WARNING — Non-Goals missing)

    → gh issue edit 1049 --add-label planned

  3. added
    planned
    on Sep 11, 2026
  4. admarble commented on Sep 16, 2026

    @admarble
    ContributorAuthor

    Field datapoint — the wall fired on #1059, 2026-09-15

    sequant_run over MCP, phases: spec,exec,qa on #1059. spec completed in 5 minutes; exec then ran past the wall and the task died:

    {"error":"EXECUTION_ERROR","message":"Process timed out: no progress for 1800000ms (total elapsed: 2113497ms)"}
    

    State was left currentPhase: exec, status: in_progress, and the worktree was reaped — /Users/tony/Projects/worktrees/feature/1059-… no longer existed afterwards.

    What saved the run: the exec agent had been told to commit chore(#1059): wip checkpoint roughly every 10 minutes, so three commits survived on the branch (710 insertions across init, doctor, the config template, README and five test files). A re-dispatch of exec,qa recreated the worktree from the branch and resumed. Nothing was lost.

    Two things this run suggests for the configurable wall:

    • The 30-minute budget is tight for an exec that must build and run a 6,400-test suite. That suite alone takes ~375s, and this issue's exec also had mutation-verification work; the phase was killed at 35 minutes elapsed.
    • The failure is silent from the orchestrator's side: the verdict never arrives, the state says in_progress, and only the worktree's absence hints at what happened. Whatever the configurable wall ends up being, a distinguishable "killed at the no-progress wall" signal in the run log would save the re-dispatch guesswork.

    Related: #1032 (bg-task stranding, which is what the wip-checkpoint rule came from).

  5. admarble commented on Sep 30, 2026

    @admarble
    ContributorAuthor

    New evidence (2026-09-29, field graph wave 3): the wall applies to the whole call, not to each issue.

    A single sequant_run for #1213, #1200, #1209 and #1198 was killed at 3561 s with no progress for 1800000ms. SEQUANT_PROGRESS from any issue resets the one watchdog. The last reset was #1213's qa completing at 15:54Z. The #1209 and #1198 execs (started 15:40Z and 15:48Z) were still committing WIP at 16:08–16:09Z, but mid-phase commits emit no progress event, so the whole batch died at 16:24Z. Re-dispatching each as its own call worked: #1209's exec took 24 min and #1198's 16 min.

    So a batch dies when its quick issues finish and its long ones are still in exec, even if every exec stays under 30 min measured from its own start. That makes the optional exec heartbeat in this issue's proposal more important than the configurable wall. A heartbeat would have saved this run; a larger wall only moves the cliff. The kill's aftermath (no run log, half-deleted worktree) is filed separately as #1222.

  6. admarble commented on Oct 1, 2026

    @admarble
    ContributorAuthor

    More evidence, 2026-10-01 (sequant 2.18.0 MCP server). Two more exec phases were killed at the 30-minute wall, this time on mechanical-tier issues, each in its own sequant_run call:

    In both, the implementation was finished and committed early, at chore(#N): wip checkpoint before the full suite. Exec then ran the full suite (10–13 min locally; 6–8.5 min in CI) and produced no SEQUANT_PROGRESS events until the watchdog fired. QA never ran, and the #1263 worktree was removed by the kill cleanup (the branch survived). Both PRs were finished by hand and merged (#1266, #1267).

    So the wall isn't only a judgment-tier problem. Any exec that runs the full suite as its last step can hit it. Options that would have saved both runs:

    1. Exec emits a heartbeat SEQUANT_PROGRESS while a long child command runs. That would also cover fix(exec): phase agent that backgrounds the test suite and waits for a notification strands uncommitted work — block Monitor/run_in_background under the orchestrator, WIP-commit on the no-commit guard #1032's background suite.
    2. Exec skips the full suite and leaves it to CI. Per-PR CI already runs it, and QA runs targeted tests.
    3. A configurable wall (this issue's original ask).

    Workaround in use: a context comment telling exec not to run the full npm test (see #1265).

  7. admarble commented on Oct 6, 2026

    @admarble
    ContributorAuthor

    Upstream note from the v2.1.287/288 assessments (#1331, #1334): Claude Code now stops background Bash commands after a time limit in unattended sessions (-p, Agent SDK, CI, cloud). The limit is the command's timeout with run_in_background, default 30 min, max 2 h. Phase agents run as -p, so raising Sequant's no-progress wall above 30 min does not by itself keep a backgrounded test suite alive. The agent's backgrounded command also needs an explicit timeout. Account for both limits in the design.

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

    enhancementplanned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions