Skip to content

fix(playbooks): stop the holder when cancelling a run - #1089

Open
BastiHu wants to merge 1 commit into
feat/playbooks-integrated-331968a7from
feat/playbooks-789-331968a7
Open

BastiHu wants to merge 1 commit into
feat/playbooks-integrated-331968a7from
feat/playbooks-789-331968a7

Conversation

@BastiHu

@BastiHu BastiHu commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #789.

Migration 070 records cancellation and archive recovery. Archive and delete events cancel the run and stop its current holder. A read or refused move before the event leaves that work to the event handler. The startup sweep records cancellations without interrupting holders.

The archive port passed 142 tests. The additional holder-limit and waiting-turn changes passed 27 relay and integration tests and server typecheck. Earlier tested head · Earlier stack verification.

December re-review

Current layer commit.

Historical submission and tests on earlier commits

The following records the original submission. The December re-review section above tracks current evidence.

Problem

Cancelling a playbook left its current worker running, while archiving a Crew incorrectly ended the Captain's run. Closes #789.

What changed

Cancellation now commits the ended run before stopping its recorded non-owner holder through the existing upstream Stop path. The durable result distinguishes idle, stopped, unavailable, and refused holders; retries never issue another Stop, including cancellations recorded before this upgrade. Owner archive/delete events and startup recovery cancel the owner's run. Crew archive preserves it for reassignment or takeback.

This is stacked on #1088. Migration 062 precedes checkpoint migration 063 in #1090; progress follows in #1091.

Live testing

Automated real-orchestrator coverage captures the active holder run, cancels the playbook, verifies that exact run becomes interrupted, and verifies retry adds no turn items. The owner-archive checkpoint closure is covered in the following integration layer.

Combined validation at bc432f7c64040976df0400625870a4b235a8e81b: check:changed passed: 568 tests across 43 files, all 36 affected package typechecks, 17 React compiler cases across 12 selected files, format, lint, Knip, and GraphQL. Captain browser smoke verified the approval-required library preview, Inbox loading, a completed free Replay turn, and restoration of that transcript after an at-rest server restart. Replay exercises provider rendering; it does not verify the Playbook approval flow. Detailed report: artifacts/test-reports/feat-playbooks-next-integrated-331968a7/bc432f7c6.md. Real-model Stop/Continue, held-turn restart, and migration rehearsal on copied real data remain unrun; the earlier request to authorize paid test models is still pending. No live deployment was performed.

Upstream impact

Only the measured agent context budget changes outside J5-owned code; recorded in FORK.md cases 2 and 110. Stop uses the existing provider-neutral implementation and Captain exception.

Checklist

  • One concern: cancellation and owner lifecycle
  • Tests cover changed behavior, retries, mode limits, and upgrade history
  • UI changes: no new control in this layer; readable history labels ship in the progress layer
  • Live testing: exercised and unexercised paths are stated above
  • Upstream-owned files recorded in FORK.md
  • Upstream product: existing behavior reused; no new divergence
  • Surfaces: MCP, shared store, lifecycle stream, and provider-neutral Stop path covered
  • Product and user docs updated

Implemented with GPT-6 Astra in the Codex harness and a J5 Crew.

@vercel

vercel Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
j5-code Ready Ready Preview Dec 1, 2026 7:21pm UTC

Request Review

@Jacksondr5

Copy link
Copy Markdown
Owner

Direction for the whole stack, before the full review, is in this comment on #1086. We'll review once the stack is rebased onto j5/main after #1205.

@BastiHu
BastiHu force-pushed the feat/playbooks-integrated-331968a7 branch from 82d64d2 to 59c1110 Compare November 24, 2026 11:00
@BastiHu
BastiHu force-pushed the feat/playbooks-789-331968a7 branch from f6032ac to 7078f14 Compare November 24, 2026 11:00
@BastiHu

BastiHu commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

@Jacksondr5, Migration 063 records cancellation and archive recovery. A delayed archive targets the old handoff and preserves replacement work. Peer handoffs enforce the owner’s current limits. The archive port passed 142 tests. The additional holder-limit and waiting-turn changes passed 27 relay and integration tests and server typecheck. Commit · Stack-wide response and outstanding evidence.

@Jacksondr5

Copy link
Copy Markdown
Owner
  • Blocking: archiving the owner doesn't stop the holder. PlaybookCrewRelay.ts:125-154: the archive and delete path interrupts only a turn that started from the step notice, and records already_idle otherwise. A holder's work on a step routinely spans turns (it asks the owner a question, gets steered), so this misses the common case. Reproduced live: the owner hands a step to a Peer; the Peer asks a question and the owner answers; archive the owner. The run is cancelled owner_archived and holder_stop records already_idle, but the Peer's command keeps running. Upstream's Stop already knows whether the thread has an active turn, so there's no need to guess from the notice. Fix: when the archive or delete event arrives, stop the holder with the same ordinary Stop that explicit cancel uses. When a cancellation is only caught later (startup sweep or a lazy read), don't stop anything: record that the holder wasn't stopped, and leave the ordinary Stop to the person.

  • Blocking (shows up with feat(playbooks): require the named persona for a step #1094): the hand-off ignores an approved persona's wider access.

    • Where: holderLimit (PlaybookCrewRelay.ts:89-101, applied at :246-247) holds the step notice to the owner's runtime and interaction mode. The comment there says a spawned Peer inherits the owner's ceiling, but a persona Peer runs with the persona's own access.
    • Reproduced live:
      1. A Supervised owner starts a run whose step needs a Full-access persona.
      2. An Owner approves the grouped request.
      3. The agent spawns the persona and assigns it.
    • Result: the delivery stays unresolved, and current reports pending. A Stop on cancel hits the same limit and records failed.
    • Fix: deliver the step notice the way a queued j5_send_message is delivered, with no owner-mode limit.
  • Should-fix: Stop recovery machinery. These cover a crash window:

    • the replay of Stop through run.interrupt from the startup sweep and on retries;
    • the placeholder outcome written before Stop runs;
    • migration 063's holder_stop_json backfill, which the filters never read.

    Please cut them to one ordinary Stop when the run is cancelled. If Stop fails, record that and leave the person the normal Stop action. Keep Playbooks: cancelling stops the step holder, and archiving a Crew keeps the run #789's rule that unarchive never reopens a run.

  • agent-tools.md History line for the cancel contract change.

This branch was successfully deployed

1 active deployment
Preview — 7f528424 Deployed Dec 1, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 effective changed lines (test files excluded in mixed PRs). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants