Skip to content

feat(workboard): import finished node ticket branches into the host clone - #19

Merged
tomorrowflow merged 1 commit into
mainfrom
feat/workboard-node-bundle-import
Oct 9, 2026
Merged

tomorrowflow merged 1 commit into
mainfrom
feat/workboard-node-bundle-import

Conversation

@tomorrowflow

Copy link
Copy Markdown
Owner

Summary

M1 slice 2 (D40): a finished node ticket's branch now comes back to the host. A done report no longer moves the card to review. It records a pending handoff, and the import is the only step that moves a node ticket to review.

 agent_end (node ticket)
   applyNodeTicketReport
-    done + passing proof → lifecycle move to review
+    done + passing proof → target.worktree.handoff = pending
+  lifecycle observation: idle (never review)
+  lifecycleSync.scheduleNodeHandoffs()        # service scheduler, detached from requester
+
+nodeHandoffs.resume()                         # scheduled run, and every 60 s sweep
+  pending:
+    node: git status --porcelain              # dirty → block
+    node: git bundle create <root>/wb-<card>.bundle <base>..factory/<card>
+    node.invoke file.fetch (16 MiB cap, sha256 checked)
+    host: git bundle verify / list-heads      # exactly refs/heads/factory/<card>
+    host: git fetch <bundle> <ref>; merge-base --is-ancestor <base> <head>
+    recheck card claim + handoff              # authority before the ref write
+    host: git update-ref refs/heads/factory/<card> <head> ""   # never moves an existing branch
+    proof "bundle import" + handoff = imported
+  imported:
+    node: worktree remove, branch -D, rm bundle   # failure → visible comment
+    syncLifecycle → review
  • Contract: WorkboardExecutionTarget.hostRepoPath (required, absolute) and WorkboardNodeWorktree.handoff (pending | imported).
  • Crash safety: pending reruns the idempotent import, and imported with the card still running only finishes cleanup and the move to review. The sweep resumes both after a restart.
  • Failure: a failed import blocks the card with the reason and the next step ("Fix the cause, then re-run the card"). The node worktree is kept.

Real-flow fixes to slice 1 code:

  • Re-run base: createNodeTicketWorktree recorded the reused worktree's HEAD as baseCommit, so a re-run after a blocked import bundled an empty range. It now keeps the recorded base.
  • Session label: labels were Workboard: <title>, and labels must be unique, so a second card with the same title failed to start ("label already in use"). The label now includes the card id prefix.

Out of scope: the dev push / draft-PR Workboard action (decided: a Workboard action with per-repo token; next slice), trust KPIs, per-owner concurrency.

Evidence

Real flow: isolated Gateway from this branch (profile m1) plus Docker node host, real Claude Code (Haiku 5.5) turns, real file.fetch through File Transfer policy.

Run Result
Card 1, first run Claude committed b76f746. The import blocked: file.fetch was refused because the node's command surface upgrade was still pending approval (a test-kit gap). The card was blocked with the reason, and the worktree was kept.
Card 1, re-run after approving Imported bfcf02e..b76f746 (original base kept). Host factory/<card> = b76f746, card in review. Node cleanup failed with "Gateway requester authority changed", because the handoff ran inside the agent_end requester scope.
Card 2, after switching to the service scheduler Claude committed 7e32bd2, imported bfcf02e..7e32bd2, card in review. Node worktree, branch, and bundle were removed, with no cleanup comment.

Tests: node-ticket-handoff.test.ts (6 tests). It uses a local-node fake that runs the node's system.run / file.fetch against real temp git repos, with the real SQLite store.

  • Happy path: host branch at the worktree head, proof range, and node cleanup.
  • Uncommitted work blocks and keeps the worktree.
  • An existing host branch at another commit is never moved.
  • A detached HEAD with later commits blocks instead of losing them.
  • An empty branch blocks.
  • A re-run after a blocked import imports from the original base. With the reuse fix removed, this test fails: expected 'blocked' to be 'review'.

pnpm test extensions/workboard/src/node-ticket-handoff.test.ts --maxWorkers=1: 14.2 s wall, about 2 s of test time, no timers. The full extensions/workboard + packages/workboard-contract suite passes: 406 + 15 tests.

Checks: tsgo:extensions, tsgo:extensions:test, lint:extensions, check:import-cycles, check:coercion-helpers, lint:plugins:no-extension-test-core-imports, the test temp-creation report, and the production dead-export scan pass. The inherited scripts/ unused exports are unchanged.

Review: autoreview (Codex, P1) found two issues, both fixed: (1) a clean worktree on a detached HEAD would bundle only the branch tip and then delete later commits; the import now requires HEAD on factory/<card> and the bundle head to equal it (test: "blocks instead of dropping commits made on a detached HEAD"). (2) the pre-write recheck now compares the whole target (node, repo, host clone, branch, base), not just the worktree path.

Merge Danger

Door: two-way

Not deployed. Node tickets exist only on test profiles, and hostRepoPath becomes required for node-claude targets. Main is not a shipped contract, so no migration is needed.

Blast Radius: Workboard

Only cards with a node-claude target change behavior. Other cards still move to review on agent_end as before. To live-deploy, the node's file.fetch command surface must be approved, and its allowReadPaths must cover <worktreesRoot>/*.bundle.

🤖 Generated with Claude Code

…lone

A done report from a node ticket now records a pending handoff instead of
moving the card to review. A lifecycle-scheduled handoff bundles
factory/<card> on the node, fetches it with file.fetch, verifies it on the
host (single ref, ancestry from the recorded base, worktree on the branch),
creates the host branch without moving an existing one, cleans the node, and
only then moves the card to review. Failures block the card with the reason.

Also keeps the recorded base commit when a re-run reuses the node worktree,
and makes node session labels unique per card.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@tomorrowflow
tomorrowflow merged commit f42aded into main Oct 9, 2026
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