Skip to content

feat(corch): CORCH-09 slot injection, worktree commands, PR lookup, memlog claim seam (stacked on #544) - #545

Merged
finedesignz merged 9 commits into
mainfrom
phase-corch-09-slot-injection-worktree
Nov 15, 2026
Merged

finedesignz merged 9 commits into
mainfrom
phase-corch-09-slot-injection-worktree

Conversation

@finedesignz

Copy link
Copy Markdown
Owner

CORCH-09 slot injection, worktree commands, PR lookup, memlog claim seam

Stacked on CORCH-08 (PR #544); base phase-corch-08-aaf-event-receiver.

REQ: CORCH-R4.1, R4.2, R4.3, R4.4, R4.5 complete. CORCH-R3.8 is BLOCKED-ON-MCP: no verified hub->memlog transport exists (memlog is gateway-only MCP; the hub has no gateway credential or MCP client). The memlog claim is an injected MemlogClient seam whose default refuses memlog_unavailable (items wait, one ticket); the full claim lifecycle is built and proven against a fake memlog. 7e request filed to mcp-servers via memlog_note (mem:mcp-servers:requests 1794637033307-0); autofix-report mcp-servers returned HTTP 401 invalid_key.

What it does

  • Supervisor: account_slot in supervisor.hello only with REMO_ACCOUNT_SLOT; slot spawn env (OAuth token + CLAUDE_CONFIG_DIR required with the slot, ANTHROPIC_API_KEY scrubbed, deploy creds scrubbed, runner output redacted); allowlisted corch.worktree_ensure|worktree_remove|pr_lookup (sandboxed, deterministic <root>/corch/<name>-<id> on corch/<id> off the remote default branch, clone origin bound, host-scoped credential helper, one shared deadline, never advertised to scheduled tasks).
  • Hub: real Workspace + PrLookup (built only when REMO_CORCH_ENABLED is ON; defaults still refuse), claim fencing per item, release on requeue/blocked/done/cancelled, worktree removal on done/cancelled (not blocked), reconciler heartbeats live and pr_open claims, haltBeforeMachineSend before every corch.* frame, gsd-console cancellations and AAF closures clean up.
  • Guards: hub/test/corch-no-token-guard.test.ts (no token/API key in hub, halt precedes every frame) + supervisor frame test.
  • No schema change, no route change. Docs: docs/corch.md, CLAUDE.md env.

Tests

supervisor corch-slot (11), corch-worktree (15, temp git repos + fake gh); the 3 named supervisor guards green. Hub corch-workspace (21), corch-no-token-guard (7), real-Postgres e2e/corch-slot.e2e.test.ts (10: claim -> worktree -> launch -> turn end -> lookup -> pr_open -> done release), corch-aaf-events (+1). bun run check-baseline: pass=4213 fail=0. 3 pre-existing supervisor PTY failures (pty-byte-relay etc.) also fail on the CORCH-08 base.

QC

Codex (external seat responded) rounds 1-3, each QC-FAIL (9 / 7 / 4 findings), all fixed; see .planning/phases/CORCH-09-slot-injection-worktree/QC-R1..R3.md and QC-ADJUDICATION.md. The round-3 fixes are verified by tests but were not re-reviewed externally (3-round cap). Adjudicated by design: a no-slot supervisor still inherits an operator-set CLAUDE_CODE_OAUTH_TOKEN (existing behavior, R4.2 keeps the human path unchanged); redaction cannot catch a secret split across events or re-encoded.

Flags / env (all default OFF / unset)

Supervisor-side only: REMO_ACCOUNT_SLOT, REMO_SLOT_CLAUDE_CONFIG_DIR, CLAUDE_CODE_OAUTH_TOKEN. Desktop MSIs never set them. No new hub env; REMO_CORCH_ENABLED stays OFF.

Cutover items this adds

Slot supervisor build/image (CORCH-10), a real MemlogClient once an mcp-servers endpoint exists, git credential env (GH_TOKEN) on each slot.

🤖 Generated with Claude Code

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-14T06:42:08.819706Z d857b20 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d857b20f5a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread hub/src/corch/workspace.ts Outdated
Comment on lines +190 to +192
if ((a.status === 'done' || a.status === 'cancelled') && supId) {
try {
const r = await send(a.userId, supId, 'corch.worktree_remove', [run.repo_ident, a.itemId])

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Stop per-item worker sessions before releasing their worktrees

When CORCH is used with a working memlog client, each item gets its own persistent worker session, but completion only ends the CORCH run and releases the claim/worktree; nothing stops the worker. SessionBridge forwards the final assistant message without exiting, and ProcessManager deliberately retains authenticated idle runners. Those workers therefore keep occupying the supervisor's concurrency slots (reserveSessionSlot in hub/src/sessions/budget.ts and the local cap in supervisor/src/process-manager.ts). After maxConcurrent distinct items, subsequent launches are refused even though CORCH considers the earlier runs finished; merging their PRs also deletes directories underneath still-running workers. Stop the item-owned session when its run finishes, with appropriate handling for retries, before removing its worktree.

Useful? React with 👍 / 👎.

@finedesignz
finedesignz force-pushed the phase-corch-08-aaf-event-receiver branch from 734be00 to c85bb36 Compare November 14, 2026 09:52
@finedesignz
finedesignz force-pushed the phase-corch-09-slot-injection-worktree branch from e3522b3 to a5718c2 Compare November 14, 2026 09:52
finedesignz and others added 7 commits November 14, 2026 18:18
…emlog claim seam

Supervisor: account_slot in hello only with REMO_ACCOUNT_SLOT; slot spawn env
(OAuth token + CLAUDE_CONFIG_DIR, fail closed, API key scrubbed); allowlisted
corch.worktree_ensure / worktree_remove / pr_lookup (sandboxed, deterministic
corch/<id> worktrees, gh PR lookup, no credential in replies).
Hub: real Workspace + PrLookup behind the CORCH-01 seams, memlog claim client
seam (default refuses memlog_unavailable: R3.8 BLOCKED-ON-MCP, no hub->memlog
transport exists), release on done/blocked, claim heartbeat from the
reconciler, haltBeforeMachineSend before every corch.* frame, no-token guard.
All flags stay OFF.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Redact the slot token from runner output, bind clone origin + scope the git
credential helper to github.com, stop advertising corch.* commands, sandbox and
branch-check worktree removal, kill stuck git/gh below the hub RPC timeout and
never release a claim on timeout, unwind claims on every requeue/blocked/failure
path, heartbeat pr_open claims, clean up gsd-console cancelled items.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Per-item lock and claim-owner fencing, claim release on attachSession failure,
no release on worktree RPC timeout, single 480s budget per worktree_ensure,
pr_lookup pinned with --repo (GH_REPO ignored), release finds the run that has
the worktree, paged pr_open heartbeats, token redaction covers git credentials
and object keys.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Timeout fence applies to cancel/done, removal resolves the host via the bound
account, gh lookup pins github.com and a 100-item window.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…okup, record worktree host before ensure, pin launch and clean every recorded host

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…BLOCKED-ON-MCP)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@finedesignz
finedesignz force-pushed the phase-corch-08-aaf-event-receiver branch from c85bb36 to 94c4b07 Compare November 15, 2026 02:19
@finedesignz
finedesignz force-pushed the phase-corch-09-slot-injection-worktree branch from a5718c2 to 70a43dc Compare November 15, 2026 02:19
@finedesignz
finedesignz changed the base branch from phase-corch-08-aaf-event-receiver to main November 15, 2026 04:22
finedesignz and others added 2 commits November 14, 2026 20:22
The release step added in CORCH-09 awaited before the pr.failed
notification claim, on the transitioned path only. A concurrent duplicate
delivery of the same event could then take the claim first, so the
delivery that applied the transition answered 503 notification_pending
(CI: corch-aaf e2e 'concurrent duplicate deliveries', 0 applied of 6).
State and notification count stayed correct; only the answer was wrong.
Moving the best-effort release after the claim restores the CORCH-08
ordering and stops the owner notification waiting on worktree cleanup.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@zero-exposure-app

Copy link
Copy Markdown
Contributor

Zero Exposure did not auto-merge this PR.

Blocking reason: auto-merge blocked: not eligible -- diff classifier: hub/test/corch-no-token-guard.test.ts: addition to a fetch/CORS/CSP allow-list: // 3. the corch.* command names live only in the one sender module and the RPC allowlist, and every sender call; diff classifier: hub/test/corch-quota-binding.test.ts: potential flag/safety change: identifier-shape heuristic matched "process.env.REMO_CORCH_ENABLED" added with a truthy value and no removed counterpart to pair against; semantic effect unverified; requires review: process.env.REMO_CORCH_ENABLED = '1'; diff classifier: hub/test/e2e/corch-slot.e2e.test.ts: potential flag/safety change: identifier-shape heuristic matched "process.env.REMO_CORCH_ENABLED" added with a truthy value and no removed counterpart to pair against; semantic effect unverified; requires review: process.env.REMO_CORCH_ENABLED = '1'

Reviewed commit: dff91b5. A human needs to resolve this (or merge the PR manually). This comment is updated in place when the reason changes; it is not re-posted per retry.

@finedesignz
finedesignz merged commit 0e4693b into main Nov 15, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant