Repository navigation
Description
Context
sequant run executes every phase through an AgentDriver (src/lib/workflow/drivers/agent-driver.ts: executePhase(prompt, config), isAvailable(), canResume(), resolvesSkills, usesSdkMcp) with four adapters: claude-code, codex, opencode, aider. All four spawn a local subprocess.
The 2026-09-24 matcha-maps credit plan needed to spend claude.ai cloud credits on a 16-issue backlog and found that the orchestrator cannot run there: a cloud session receives API credentials through a proxy, not as shell env, so a nested claude CLI has no auth. The plan therefore hand-rolled the driver: a local coordinator fires one one-shot cloud session per issue-phase (routine API via RemoteTrigger, or claude --cloud "<prompt>" on CLI 2.1.281), polls list_runs / get_run_log, reads the PR and the verdict comment, and continues locally. That loop is an AgentDriver in everything but name, and rebuilding it per project by hand loses the ledger, the tiering policy, the timeout, the token metrics (#986/#944) and the conformance guarantees (#1096).
Observed in the #1079 cloud run (sequant, 2026-09-17, Sonnet 5, 67 turns, 536 s): project-scope skills, hooks and CLAUDE.md load; npm ci, lint, build, suite and a mutation check ran; git commit passed the hook; the push failed only on GitHub App permissions.
Fix shape
src/lib/workflow/drivers/claude-cloud.ts:
executePhaselaunches a one-shot session on a configured environment with the phase prompt, setsSEQUANT_CHECKOUT=in-place(feat(exec/qa): explicit in-place checkout mode — run a phase on a branch in the current clone without creating or resolving a worktree #1136) plus the standardSEQUANT_*set in the session environment or prompt preamble, polls the run to completion, and maps the run log toAgentPhaseResult: verdict from the phase's issue comment,modelUsagefrom the run's usage,structuredErrorfrom the run's failure text.- Tiering is the session's model field:
run.phases.<phase>.modelmaps to it directly, no settings flip. - Per-phase driver selection comes from feat(run): per-phase agent selection — run.phases.<phase>.agent #1150 (
run.phases.<phase>.agent, split out 2026-09-24). Withrun.agent: "claude-code"andrun.phases.exec.agent: "claude-cloud", exec runs in the cloud and qa runs locally. The credit-plan finding behind that default: matcha-maps' vendoredqa/SKILL.mdis 179 KB (~45K tokens) and sits in every turn of an Opus cloud session, while local qa bills the subscription. - Timeout: cloud sessions have no 30-minute no-progress wall (feat(mcp): configurable per-phase no-progress wall for sequant_run — judgment-tier exec phases die at the hard-coded 30 minutes #1049), so the driver enforces
run.timeoutitself by polling and stopping the run; the result maps to the existing timeout outcome. - After a cloud exec pushes its branch, the driver fetches it into a local worktree so downstream local phases find it via
sequant worktree resolve. - Secrets never enter the prompt; the environment's own variable store holds what the build needs.
Launch mechanism (decided in the /spec comment, 2026-09-24): use the routines/sessions API (POST /v1/code/triggers one-shot + run, then poll GET /v1/code/sessions/{id}/events). claude --cloud "<prompt>" cannot create a session without a TTY on CLI 2.1.282: it errors with --cloud requires an interactive terminal and, with -p, --cloud cannot be combined with --print. claude -p "<msg>" --cloud <cse_id> is used only to steer an existing session.
Gate (owner decision, 2026-09-24; tracked as #1151): no exec until the Phase-0 probes are posted here:
- P-1: a Node process can authenticate to
/v1/code/triggerswith the token fromclaude setup-token. - P-2: the trigger accepts a model.
- P-3: the raw events carry
usage/modelUsage. - P-4: the call that stops a live session.
If P-1 fails, #1137 is parked. No LLM-mediated launcher shim.
Environment variables (owner decision, 2026-09-24): static values go in a dedicated cloud environment for the driver, which sets SEQUANT_CHECKOUT=in-place and SEQUANT_ORCHESTRATOR=sequant-run. Per-run SEQUANT_ISSUE/SEQUANT_PHASE go in the prompt preamble. The existing "Sequant in-place" environment stays unchanged: with SEQUANT_ORCHESTRATOR set, /exec skips its progress comment and defers the GitHub update to an orchestrator, and human-run sessions on that environment have none.
Conformance (#1096) mapping: item 1 commit inside the cloud sandbox (observed in #1079); item 2 gh api rate_limit from the session; item 3 typed errors need the routines API's real failure text (capture it during a Phase-0 probe, not synthesized, per #1115's rule); item 4 env injection via the session environment; item 5 tokensUsed > 0 from the run's usage; item 6 project-scope /exec load (observed).
Acceptance criteria
- AC-1: the driver is registered and the conformance suite enumerates it; every contract item passes or names a tracking issue in its skip reason — Evidence:
npx vitest run src/lib/workflow/drivers/__tests__/driver-conformance.test.ts -t "claude-cloud"green - AC-2:
isAvailable()returns false with a named reason when no environment id or cloud auth is configured — Evidence: unit test insrc/lib/workflow/drivers/claude-cloud.test.ts - AC-3: with
run.agent: "claude-code"andrun.phases.exec.agent: "claude-cloud"(the feat(run): per-phase agent selection — run.phases.<phase>.agent #1150 key), exec dispatches to the cloud driver and qa to the local claude-code driver — Evidence:src/lib/workflow/phase-executor.test.tscase asserting the driver chosen per phase, using feat(run): per-phase agent selection — run.phases.<phase>.agent #1150'sresolvePhaseAgent - AC-4: a run exceeding
run.timeoutis stopped by the driver and reported as the existing timeout outcome, not as success or an unknown failure — Evidence: unit test with a fake poller - AC-5: after a cloud exec completes,
sequant worktree resolve <N>in the local repo returns a worktree on the pushed branch — Evidence: integration test against a fake remote - AC-6: when the session events carry usage (probe P-3),
AgentPhaseResult.modelUsagehas non-zero input and output tokens; when they do not, tokens are reported unmeasured (never 0) and turns plus duration are recorded — Evidence: unit test on the run-log mapper against both a captured with-usage fixture and a captured without-usage fixture - AC-7: docs page for the driver covers the dedicated environment and its two static variables, the no-secrets rule, dependency install from the preamble, the absent
gh,permissions.askstalls, per-phase driver and model selection, the timeout behaviour and the daily fire cap — Evidence:grep -l "claude-cloud" docs/reference/*.mdnon-empty - AC-8:
npm run build && npm testgreen — Evidence: CItestjob - AC-9: the session's tool policy excludes
mcp__Claude_Code_Remote__*andPushNotification— Evidence: unit test insrc/lib/workflow/drivers/claude-cloud.test.tsasserting the trigger request body - AC-10: the prompt preamble never carries
SEQUANT_WORKTREEor any secret value — Evidence: unit test on the preamble builder insrc/lib/workflow/drivers/claude-cloud.test.ts - AC-11: the driver refuses to fire, with a named reason, when tracked
.claude/settings.jsonor.claude/settings.local.jsonhas a non-emptypermissions.ask— Evidence: unit test insrc/lib/workflow/drivers/claude-cloud.test.tsover a temp project - AC-12: the run-log mapper takes the first
result:after the phase prompt, not the last, and reads duration fromduration=, not timestamps — Evidence: unit test on a captured fixture with fourresult:lines - AC-13: the one-shot trigger is deleted or disabled after its run, on success, failure and timeout alike — Evidence: unit test with a fake transport asserting the cleanup call on each path
- AC-14:
<branch>--session-<id>checkpoint branches never resolve as the issue's worktree branch — Evidence: unit test onsequant worktree resolvewith a checkpoint branch present - AC-15: phase cost is reported as unmeasured, never $0, until the run's usage is observed — Evidence: unit test on the result mapping in
src/lib/workflow/drivers/claude-cloud.test.ts
Non-Goals
- MCP servers inside cloud sessions
- Running qa in the cloud by default
- Working around the routines daily fire cap (document it; there is no
claude --cloudfallback, since it cannot create a session headlessly) - An LLM-mediated launcher if P-1 fails (park instead)
Graph metadata
- Blocked by: feat(exec/qa): explicit in-place checkout mode — run a phase on a branch in the current clone without creating or resolving a worktree #1136, feat(run): per-phase agent selection — run.phases.<phase>.agent #1150, spike(#1137): Phase-0 probes for the claude-cloud driver — Node auth, model, usage, stop #1151
Related
#1096 (conformance) · #1115 (usage and typed errors for the other drivers) · #497 / #862 (the last two driver additions) · #1049 (no-progress wall) · #944 (cost baseline — cloud runs report real per-phase tokens) · #1079 (the proving run)
Activity
admarble commentedon Sep 24, 2026
Phase 0 field facts from the matcha-maps credit run (2026-09-24) — two one-shot routines on an Anthropic-hosted environment (
env_011CUvi781XSsaoVy7qTLDfS), Sonnet 5, each running one issue to a PR: admarble/matcha-maps#1046 (59 turns, 476 s) and admarble/matcha-maps#1047 (102 turns, 1094 s). Full notes:docs/internal/graph-2026-09-credits/HANDOFF.mdin that repo.(a)
SEQUANT_*in the session environment or in the prompt preamble? Neither the trigger nor the session can carry per-run env vars:RemoteTrigger createwithsession_request.environment_variablesis refused (see b). The environment's own variable store does reach the shell — the worker's probe (node -e "console.log(JSON.stringify(Object.keys(process.env).filter(k => /^(SEQUANT|NEXT_PUBLIC|CLAUDE)/.test(k)).sort()))") printed the fourNEXT_PUBLIC_*keys set in the environment UI plus ~50CLAUDE_*keys and noSEQUANT_*. So: a staticSEQUANT_*set can live in the environment store (one value per environment, not per run); anything per-run (SEQUANT_ISSUE,SEQUANT_PHASE) has to ride in the prompt preamble. Noteenv/printenvare permission-denied in the sandbox (Permission to use Bash with command env has been denied) and the repo's vendored hook blocks unanchored env greps — probe withnode -eand print key names only. RelevantCLAUDE_*keys seen:CLAUDE_CODE_REMOTE,CLAUDE_CODE_REMOTE_SESSION_ID,CLAUDE_CODE_REMOTE_HERMETIC_MODE,CLAUDE_CODE_SESSION_ATTENDED,CLAUDE_CODE_HOLD_UNANSWERED_PARKED_PERMISSION,CLAUDE_CODE_CONTAINER_ID,CLAUDE_CODE_ENVIRONMENT_RUNNER_VERSION.(b) Verbatim routines-API failure text (HTTP 400 both; no quota/auth/cap failure was hit in two runs):
(c) Complete
get_run_logfixture:docs/internal/graph-2026-09-credits/fixtures/get_run_log-P0-1.txtin admarble/matcha-maps (newest page of sessioncse_01R9TaSCgCDzyiJ97rt3wL3B, verbatim as the RemoteTrigger tool returns it). The shape the mapper needs:result: success is_error=false turns=59 duration=476s permission_denials=5 — <final assistant text>; a run can carry severalresult:lines because the session is re-woken by PR events (this one had four). Older pages are reached withcursor(here 252 → 52 → first event). Non-transcript event kinds are summarised in a header line (system/hook_response ×63, …), not listed.(d) Does a run stopped mid-way leave a readable partial log? Not exercised: neither probe overran. What was exercised: the worker of #1046, after "STOP", called
mcp__Claude_Code_Remote__send_laterand created its own follow-up routine (persist_session: true, "keep re-arming until the PR is merged");RemoteTrigger update <id> {"enabled": false}cancelled it (HTTP 200,enabled:falseread back, no run row created). Stopping a live session through the API is still untested. Two related facts the driver must plan for: (1) apermission promptevent onnpm ciblocked run #2 for ~4 hours and resolved within a minute of the owner's local Claude Code session waking from laptop sleep — the same prompt auto-resolved in <1 s in run #1 while that session was awake — sorun.timeoutenforcement by polling is necessary but the driver also needs the permission mode /auto_mode_*config sorted out or runs will stall unattended; (2)ghis not installed in the environment (which gh→ none); workers used the GitHub MCP connector (mcp__github__create_pull_request,issue_read,add_issue_comment) and plaingit push(write access via the Claude GitHub App).Other observed: project-scope skills load only when the prompt names the Skill tool (
skill "spec", args "979") — told merely to "invoke /exec", run #1's worker never called it and followed the prompt's inline discipline; the vendored hooks (pre-tool.shconventional-commit and env-dump guards) and a user-level stop hook run in the sandbox;npm ci37 s, jest suite 2 min 17 s,npm run build~65 s on the sandbox.admarble commentedon Sep 24, 2026
Design implications from the Phase 0 facts above (coordinator-side reading, 2026-09-24). Each one changes an AC or the fix shape; fold into
/specwhen this unblocks.mcp__Claude_Code_Remote__subscribe_pr_activityandmcp__Claude_Code_Remote__send_later, creating its own follow-up routine with fix-and-push authority. The driver'sallowed_tools(or the prompt's session rules) must excludemcp__Claude_Code_Remote__*andPushNotification. Same class as fix(containment): a phase agent killed its own orchestrator — no Bash signal guard, no process-group isolation, machine re-prompts read as human consent #934, one layer up.SEQUANT_*in the environment's variable store, per-runSEQUANT_ISSUE/SEQUANT_PHASEin the prompt preamble. The conformance probe must benode -eoverprocess.env—envandprintenvare permission-denied in the sandbox and the vendored hook blocks unanchoredenv | grep.permissions.askin the repo's tracked settings reaches the cloud session. admarble/matcha-maps tracks.claude/settings.local.jsonwith"ask": ["Bash(npm ci)", …]; both runs logged apermission promptevent onnpm ci. Run 1 resolved in <1 s while the owner's local Claude Code client was connected; run 2 blocked ~4 h while the laptop slept and resolved within a minute of it waking. The routines docs say routines "never stop for approval"; the log says otherwise. Driver preflight: scan.claude/settings.json+settings.local.jsonforpermissions.askand refuse (or warn loudly) before firing — a blocked run burns wall-clock and, per the 2× stop rule, would be killed as an overrun.ghis absent in cloud environments. The spec skill's preflight printedGITHUB_AVAILABLE=false; workers used the GitHub MCP connector. The driver docs must say: installghvia the environment's setup script, or accept MCP-only and make the platform preflight non-fatal.result:lines (PR-event re-wakes of 2–7 turns each); the phase outcome is the firstresult:after the prompt, not the last. Event timestamps are unreliable after a sandbox re-provision (~4 h skew observed); readduration=from theresult:line. The condensed log'sresult:line carriesturns,duration,permission_denialsand no token counts — AC-6 (modelUsagenon-zero) needs a usage field from the sessions API that Phase 0 did not see. Verify it exists before keeping AC-6 as written.RemoteTrigger update {enabled:false}cancels a scheduled routine; stopping a live session is untested. AC-4 needs the actual session-stop call identified first.Fixture for item 5:
docs/internal/graph-2026-09-credits/fixtures/get_run_log-P0-1.txtin admarble/matcha-maps.admarble commentedon Sep 24, 2026
Phase-0 evidence from the #1136 dogfood (sequant, 2026-09-24)
Not the matcha-maps credit run, but it answers the same four questions. Sessions:
cse_01NXWtKRSMZZPhMXuBkTtjbx(died at setup) andcse_01W6MSXo6CpVP1WmyNMwxWVz(opened PR #1142). Environmentenv_01QXpqvWm6CyRyTgxsA4C62d("Sequant in-place").SEQUANT_*in the session env: only what the environment config sets.printenv | grep '^SEQUANT_'inside the session printed exactlySEQUANT_CHECKOUT. Nothing from the orchestrator leaks in.npm cifails because it does not run in the repo checkout:npm error code EUSAGE … can only install with an existing package-lock.json. The runner logsenv[error]: Setup script failedand the session endsresult: error_during_execution is_error=true turns=0 duration=0s errors=["Setup script failed with exit code 1."]. Put dependency install in the prompt instead.GET /v1/code/sessions/{id}/eventsworks for ad-hoc web sessions, not only routine runs. It returns runner lines (env[info]: Allocating sandbox,Cloning repository,Using existing repository cloneson resume),init: model=… cwd=…, tool calls with truncated results, and a terminalresult:line withturnsandduration. Pages of 200 events, newest first,next_cursorfor older.Also relevant to the driver: no
ghin the sandbox (exit 127), so skill bash that shells out toghfails; the clone is shallow (51 commits), which false-failsevals-fixture-commit.test.ts(#1140); a skill-createdfeature/N-slugbranch pushes despite the session'sclaude/…outcome branch;claude -p '<msg>' --cloud <cse_id>delivers a mid-turn follow-up within seconds; the repo's Stop hook errors in the cloud.admarble commentedon Sep 24, 2026
Addendum to item 1 (containment): cancelling one self-scheduled routine does not stop the chain.
The matcha coordinator disabled the worker's first
send_laterroutine (trig_01Lnfk8WPJjcoDKdmYqUye5m) at 07:07Z and recorded the chain as stopped. The routines API shows it was not: the worker's earlier PR-event wake had already armedtrig_016sycASWYkdQtJSZuwhHxrv(07:07Z), and each subsequent fire armed the next —trig_014iU1WQGhvdGxRs2s93UeEc(08:09Z),trig_01KvkCQFHjQ46g3cdkgvBpzF(09:11Z),trig_01J2X4J4jpCGSDwWfGmTVKwj(10:13Z). Every fire re-provisioned a sandbox and ran ~6 turns in the original sessioncse_01R9TaSCgCDzyiJ97rt3wL3B(persist_session: true), solist_runson the new routines shows no rows; the evidence is only in the session's own log. The chain ended at 11:12Z because the PR merged, not because anything stopped it. Against a PR that never merges, the prompt's own rule ("keep re-arming until merged or closed") runs until the credits are gone.Driver consequences: (1) exclusion of
mcp__Claude_Code_Remote__*fromallowed_toolsis the only reliable guard — a stop-rule that disables routines by id chases a moving target; (2) the driver's stop path must act on the session (or kill its subscription), and Phase 0 still has not identified that call (item 6); (3) the run-log mapper must treat everyresult:line after the first as a wake, and the driver should sum them into the phase's cost rather than report only the first run'sturns=.admarble commentedon Sep 24, 2026
Complexity: Complex (8 ACs + 7 derived, 4 directories)
Decision: routines API to launch;
claude --cloudonly to steerRecommendation: launch each phase through the routines/sessions API (
POST /v1/code/triggersone-shot + run,get_run_log/GET /v1/code/sessions/{id}/events). Useclaude -p "<msg>" --cloud <cse_id>only for mid-run steering.claude --cloud "<prompt>"cannot start a session from a driver. Observed today on CLI 2.1.282; both commands failed during argument parsing, before any session was created:A driver spawns a subprocess with piped stdio, so creating a session with
--cloudis ruled out. The alternative, faking a TTY, is the pattern that SIGKILLs at ~106 s (#856). Two more facts count against it even where it works:--environmentaccepts only self-hostedccpool_…pools. Anenv_…id can only be chosen through theremote.defaultEnvironmentIdsetting.claude -p "<msg>" --cloud <cse_id>does work headless, and delivered a mid-turn follow-up within seconds on 2026-09-24. Keep it for steering.claude --cloudenv_…remote.defaultEnvironmentId)--modelget_run_log+ events API ✅The blocker: auth from Node. Every routine so far was fired by a Claude Code session calling the
RemoteTriggertool, which has the CLI's claude.ai OAuth. The SDK's session helpers (createCodeSession(baseUrl, accessToken, …)in@anthropic-ai/claude-agent-sdk/bridge) are documented as "thin HTTP wrappers … callers supply their own OAuth token". Reading the CLI's keychain token from sequant is not an option we should ship. Before any code, probe P-1:POST /v1/code/triggersaccept the long-lived token fromclaude setup-tokenas a bearer? Yes → plain HTTP client in the driver. No → the fallback is a launcher shim:claude -p --model haiku --allowedTools RemoteTrigger --output-format jsonwith a fixed JSON contract (create, run, poll, fetch log). That's the proven matcha coordinator shape, but LLM-mediated: roughly 1¢ per call, and not deterministic. If neither works, park feat(drivers): claude-cloud AgentDriver — run a phase as a claude.ai cloud session instead of a nested local CLI #1137.session_requestaccept a model field? Needed for per-phase tiering.GET /v1/code/sessions/{id}/events(not the condensedget_run_logtext) carry the SDKresultmessage withusage/modelUsage? The condensedresult:line has turns, duration and permission_denials, and no tokens. The SDK's browserquery()streams typedSDKMessages from…/events/stream, which suggests the raw events do./v1/sessions/{id}/archiveand aninterruptcontrol request. Identify and exercise one.Cost: ≤ $1 (two trivial sessions). Capture every response verbatim as a fixture, with identifiers scrubbed (this repo is public).
AC Quality Check
lintAcceptanceCriteriaflags AC-2/4/5/6 as incomplete: the error scenarios aren't enumerated. The derived ACs below enumerate them.run.driver: the setting isrun.agent.run.phases.<phase>(PhasePolicy) holds onlymodel/effort, and it's documented as claude-code-only. See OQ-2.Scope Assessment
Non-Goals: the "Not in scope" section: MCP servers inside cloud sessions, qa in the cloud by default, and the routines daily fire cap (documented, not worked around; the
--cloudfallback it names is not available, see above).performScopeAssessmentdidn't see this section because of its heading.drivers/,workflow/,settings,docs/reference)Verdict: ❌ SCOPE_SPLIT_RECOMMENDED. Carve AC-3 (per-phase driver selection) into its own issue. It is generic and local, has no cloud dependency, and touches every
config.agentread (phase-executor.ts:1324,:1369,:1598,:2050,skills-preflight.ts:151/167). #1137 then depends on it. The rest stays together, gated on P-1.Acceptance Criteria
AC-1: registered; conformance enumerates it; each item passes or names a tracking issue
Verification: Unit Test (
driver-conformance.test.ts -t "claude-cloud")Scenario: Given
DRIVERS["claude-cloud"]→ the registry test demands an adapter → items map as follows:unavailable:(needs a live session; observed in bug(codex): workspace-write disables network, so every phase runs offline — no gh, no comments, no push #1079/fix(#1123): --yes init no longer replaces an unparseable .mcp.json #1142).gh api rate_limit:structural:(the sandbox has nogh, exit 127; GitHub goes through MCP).error_during_execution, HTTP 400invalid_request_error). No synthesized strings (bug(drivers): opencode and aider report no token usage and no typed errors, so conformance items 3 and 5 cannot pass #1115).SEQUANT_PHASE/SEQUANT_ISSUEand the environment carries the static set (OQ-4).AC-2:
isAvailable()false, with a named reason, when no environment id or auth is configuredVerification: Unit Test (
claude-cloud.test.ts)Scenario: Given settings without
run.claudeCloud.environmentId→isAvailable()is false and the reason names the key. Same for missing auth (the P-1 outcome decides which credential).Assumptions: the interface returns
boolean. A reason needs a side channel such aslastUnavailableReason, or a widened return type. Check how codex/opencode surface theirs before adding a third pattern.AC-3: exec to cloud, qa to local → proposed for split (OQ-1)
Verification: Unit Test (phase-executor: driver chosen per phase)
AC-4: exceeding
run.timeoutstops the run and maps to the existing timeout outcomeVerification: Unit Test (fake poller + fake clock)
Assumptions: P-4 finds the stop call. The timeout must not read as "Out of credits" (the known 1800 s-timeout mislabel).
AC-5: after a cloud exec,
sequant worktree resolve <N>returns a worktree on the pushed branchVerification: Integration Test (bare-repo fake remote)
Scenario: The orchestrator creates the local worktree
feature/N-slugatorigin/mainbefore exec. The cloud pushes the same name, because the preamble passes the exact branch and the in-place block keeps a non-base branch. Afterwards the driver runsfetch origin <branch>+merge --ff-onlyin the worktree. A non-fast-forward result is a named failure, never a reset.AC-6:
modelUsagehas non-zero input/output tokens from a completed runVerification: Unit Test (mapper on a captured events fixture)
Assumptions: P-3. If usage is absent, reword to "tokens reported unmeasured (never 0), turns + duration recorded" (OQ-3).
AC-7:
docs/reference/claude-cloud-driver.mdVerification: Manual Test (
grep -l claude-cloud docs/reference/*.md)Covers: environment setup and the static env set, the no-secrets rule, install deps from the preamble (setup script runs outside the repo),
ghabsence,permissions.askstalls, model and driver selection, timeout, cost ceiling, daily fire cap.AC-8:
npm run build && npm testgreenVerification: CI
Implementation Plan
Phase 0: probes (gate, ≤ $1). P-1…P-4 above. Script:
scripts/probes/claude-cloud-probe.ts. Scrubbed fixtures go tosrc/lib/workflow/drivers/__fixtures__/claude-cloud/. Post results here, then stop for the go/no-go on P-1.Phase 1: pure core (no network).
drivers/claude-cloud/preamble.ts: builds the prompt. Deps install (npm ci), exact branch checkout,Skilltool invocation, per-runSEQUANT_ISSUE/SEQUANT_PHASE, and the tool exclusions. It never includesSEQUANT_WORKTREE(in-place + worktree → HALT) and never includes secrets.drivers/claude-cloud/run-log.ts: maps events toAgentPhaseResult. It uses the firstresult:after the prompt: PR-event re-wakes add later ones (4 in matcha P0-1). Duration comes fromduration=, never timestamps (~4 h skew observed).is_error+errors[]map to typed errors.drivers/claude-cloud/preflight.ts: refuses to fire when tracked.claude/settings*.jsonhaspermissions.ask(matcha: 4 h stall).Phase 2: driver.
4.
claude-cloud.ts:executePhase= create trigger (environment_id, model,run_once_at) → run → poll with backoff → delete trigger → map. It enforcesphaseTimeoutitself (no 30-min wall in the cloud), then stops the run.resolvesSkills: true,usesSdkMcp: false,canResumefalse in v1.5. Register it in
drivers/index.tsand add the settingsrun.claudeCloud { environmentId, model? }(zod + known keys; #1107'snetworkAccessmiss is the precedent).Phase 3: local handoff.
6. Post-exec, sync the worktree (AC-5). Ignore
<branch>--session-*checkpoint branches: the resolver'sfeature/(\d+)-key matches them. Localbatch-executordoes the GitHub side (PR/comment) with localgh.7. Add the conformance adapter and docs.
Design Review
src/lib/workflow/drivers/, the same layer as codex/opencode. The executor stays driver-agnostic apart from the AC-3 resolver.claude --cloud(TTY-only), and a PTY wrapper (Nested phase claude that hangs after its turn is killed at ~106s, taking down the parent sequant run #856).gh(22 lines ofexec/SKILL.mdreferencegh). The MCP route works but its failures are silent. Keep PR and comments local, whereghexists.Feature Quality Planning
Standard checks pass except the gaps above. Derived ACs:
mcp__Claude_Code_Remote__*andPushNotification. Asserted on the trigger request bodySEQUANT_WORKTREEor secrets; unit test on the builderpermissions.askin tracked settings, with a named reasonresult:after the prompt wins; a fixture with 4result:lines maps to the first--session-*checkpoint branches never resolve as the issue's worktree branchOpen Questions
run.phases.<phase>.agent, matchingrun.agent, rather than.driver. That also widensPhasePolicybeyond claude-code, so the doc comment changes. Impact: rename churn later.SEQUANT_ORCHESTRATOR=sequant-run+SEQUANT_CHECKOUT=in-placein the environment store (so skills take the orchestrated paths), with per-run values in the preamble. Impact: without it the cloud exec runs standalone and posts its own comments.Recommended Workflow
Phases: spec → testgen → exec → qa. Exec starts only after the P-1 go/no-go.
Quality Loop: enabled
Reasoning: 9 unit/integration ACs with pure mappers, which suits testgen. Complex scope and an external API contract, which suits the loop. qa stays local (the cost finding).
Label Review
Current: enhancement, multi-agent · Recommended: +
planned, +complex· Reason: 15 ACs, an external contract, and a gate before exec.admarble commentedon Sep 24, 2026
Owner decisions on the /spec open questions (2026-09-24)
run.phases.<phase>.agent, matchingrun.agent.modelUsageif the events carry usage (P-3); otherwise unmeasured (never 0), with turns and duration recorded. Both branches are verified against captured fixtures.SEQUANT_CHECKOUT=in-place+SEQUANT_ORCHESTRATOR=sequant-run. "Sequant in-place" stays unchanged, because orchestrated/execdrops its progress comment and human-run sessions have no orchestrator to post it. Create it only after P-1 passes.The issue body now carries all of this: the ACs, a Gate paragraph, Non-Goals and
Blocked by: #1136, #1150. Derived AC-9 to AC-15 from the spec are now body ACs. After these edits the scope heuristic still reads SPLIT_RECOMMENDED (15 ACs, 5 dirs); flagged, not acted on.admarble commentedon Sep 24, 2026
Driver environment created 2026-09-24: "Sequant Driver" (claude.ai cloud). It has
SEQUANT_CHECKOUT=in-placeandSEQUANT_ORCHESTRATOR=sequant-run, no setup script, and network set to Trusted. Itsenv_…id is not recorded yet: the Phase-0 probe (P-1) captures it and posts it here. "Sequant in-place" (env_01QXpqvWm6CyRyTgxsA4C62d) is unchanged.admarble commentedon Sep 24, 2026
The "Sequant Driver" environment id is
env_01GHgDSBdiWR6evstrUbX2xh(kind: anthropic_cloud,state: active).Found through
GET /v1/environment_providerswith the claude.ai browser session and anx-organization-uuidheader./v1/environmentsrejects theccr-byocbeta header, and/v1/code/environmentsreturns 404. This is useful for the driver'sisAvailable()check (AC-2): the list endpoint exists, and the Node-side auth question is still P-1.admarble commentedon Sep 25, 2026
P-1 (#1151 AC-1): fail, so #1137 is parked
The token came from
claude setup-token(CLI 2.1.282) and was sent as a bearer from a plain Node process. The headers match what the CLI sends to these endpoints:anthropic-version: 2023-06-01,anthropic-beta: ccr-byoc-2025-07-29andx-organization-uuid. Output ofnpx tsx scripts/probes/claude-cloud-probe.ts auth, redacted:{ "probe": "P-1", "verdict": "fail", "results": [ { "endpoint": "GET /v1/environment_providers", "status": 403, "body": { "type": "error", "error": { "type": "permission_error", "message": "OAuth token does not meet scope requirement any_of(org:sessions:claude_code, user:developer, user:sessions:claude_code, workspace:developer)" }, "request_id": "req_011CfPTDrf3doUQoE6m2f7Ma" } }, { "endpoint": "GET /v1/code/triggers", "status": 401, "body": { "error": { "message": "OAuth token lacks a scope this endpoint accepts", "reason": "oauth_scope_insufficient", "type": "authentication_error" }, "request_id": "req_011CfPTDs763raLHwrbMeXVV", "type": "error" } } ] }Why:
setup-tokenissues an inference-scoped token and takes no scope options (claude setup-token --helplists only-h). The session and trigger endpoints requireuser:sessions:claude_code(ororg:sessions:claude_code,user:developer,workspace:developer). Only the interactiveclaude auth logintoken carries that scope, and reading it out of the keychain is a Non-Goal of #1151.Decision (owner, 2026-09-24, item 5 of the /spec questions): P-1 fails → park #1137. No LLM-mediated launcher. P-2 to P-4 (#1151 AC-3 to AC-5) are not run, since they are conditional on P-1.
What would unpark it: a documented way to mint a long-lived token with a
sessions:claude_codescope (for example, a scope option onsetup-token), or a headless session-create path in the CLI (claude --cloudis TTY-only today). Either one is an upstream change.