Repository navigation
[US-737] feat: on-demand workflow supervisor - #767
Conversation
Add supervisor grammar, validation and protocol ADR.\n\nTask: T-1\nRefs: #737
Record supervisor events and restore history before escalation. Task: T-2 Refs: #737
Restore the workflow core boundary and refresh generated artifacts. Refs: #737
…ows-supervisor-on-demand-first-escalation # Conflicts: # .claude/skills/pair-capability-workflow/scripts/workflow.mjs # apps/pair-cli/src/commands/run/workflow-host.ts # packages/knowledge-hub/dataset/.skills/capability/workflow/scripts/workflow.mjs # packages/workflows/src/engine/index.ts
rucka
left a comment
There was a problem hiding this comment.
Verdict
risk:red · cost:yellow — CHANGES-REQUESTED — Supervisor guardrails, recovery and human handoff fail the story requirements.
Open findings: 10. First review. All findings are new.
PR: #767 · Story: #737 · Type: feature · Author / session identity: rucka · Reviewer: Codex · Date: 2026-11-28
Reviewed head: c96edab4657f913b67602364773f80b9530c5e82
Red tier calls for one reviewer, a two-working-day SLA and explicit human approval. No qualifying approval was present. This repository uses advisory enforcement.
Light row: n-a — no identity (session mode)
Classification matrix — per dimension
| Service | Diff | Business | Security | Coupling |
|---|---|---|---|---|
| green | red | red | red | green |
Assessments
Security — Input validation
Verdict: yellow — Directive fields and reply schema are checked.
Details
The host refuses invalid durations, unexpected fields and malformed decisions.
Security — Output handling
Verdict: yellow — Events are serialized and identified as untrusted.
Details
Context grows recursively. See F-737-08.
Security — Authentication
Verdict: green — IPC uses a scoped capability, with maintainer identity checked on card replies.
Details
The socket sits in an owner-only directory. Polling checks the original human author, question marker and timestamps.
Security — Authorization
Verdict: red — Supervisor privileges exceed the host directive boundary.
Details
Hard restrictions at the directive endpoint need corresponding restrictions on agent and nested workflow capabilities. See F-737-01.
Security — Introduced vulnerabilities
Verdict: red — One introduced authorization finding.
Details
F-737-01 concerns the new supervisor launch path.
Cost
Verdict: cost:yellow — On-demand model launches and bounded retries per trigger.
Details
Metering is present. Recursive history raises input costs as interventions accumulate.
Architecture (Coupling)
Verdict: green — The CLI, interpreter and MCP bridge share one owning context.
Details
The typed host interface keeps the engine independent of process and tracker I/O. The bridge communicates over local IPC.
Bug fix — Red test before fix
Verdict: not applicable — Feature PR.
Details
Card #737 introduces on-demand supervision.
Details
Findings by severity
Critical
- F-737-01 ·
apps/pair-cli/src/commands/run/workflow-host.ts:841· The supervisor inherits delivery-agent autonomy and host operations. ADR-038 needs enforced restrictions. Isolate external access while preserving local repair.
Major
- F-737-02 ·
packages/workflows/src/engine/index.ts:1843· AC-2. Idle-fault and single-round exhaustion replays made zero supervisor calls. Route both events through supervision before fallback escalation. - F-737-03 ·
packages/workflows/src/engine/index.ts:2036· AC-3. A retry advanced the round atmax: 2and parked atmax: 1. Apply directives before loop advancement. - F-737-04 ·
apps/pair-cli/src/commands/run/supervisor-question.ts:184· AC-4/6. Three polls spaced one second apart give maintainers roughly two seconds. Persist a meaningful deadline and use it across restarts. - F-737-05 ·
apps/pair-cli/src/commands/run/workflow-host.ts:1005· AC-5. Initial and resumed dispatch put the answer in history only. Supply the ADR-038answerfield and assert the actual event envelope. - F-737-06 ·
apps/pair-cli/src/commands/run/workflow-host.ts:1013· AC-7. Exhausted retries or budget reportno answerafter a valid reply, including on resume. Apply the original escalation. - F-737-07 ·
apps/pair-cli/src/commands/run/workflow-host.ts:794· AC-3. The handler exposeswaitbefore its timer completes. If the agent exits first, the engine treats it as immediate retry. Let the host own the deadline and completion. - F-737-08 ·
packages/workflows/src/engine/index.ts:1864· AC-8. Persisting events with prior history embeds the log recursively. Eight retries grew it from 212 to 53,933 bytes. Store flat rows and reconstruct history on read. - F-737-09 ·
packages/workflows/src/cli/supervisor/mcp.ts:111· AC-3/8. MCP acknowledges before engine state commits. Resume reads question and wait markers, so interruption can lose an acknowledgedkill. Replay directives idempotently. - F-737-10 ·
.pair/adoption/tech/workflows/supervisor.yaml:16· Recovery required a fixture-only prompt. The shipped prompt asked a human. The tracker run showed question posting. Supply both #737 real-run traces.
Minor: none. Questions: none.
Positive feedback
MCP tests exercise real stdio and local IPC.
Functionality & requirements (AC coverage)
AC-1, AC-9 and AC-10 supported. AC-2 through AC-8 have findings. Real-run DoD remains open.
Testing & quality gates
Build, review gate and 41 website E2E tests passed. Full quality gate failed twice in packages/workflows/test/session-command.test.ts under Node 26. Three focused cases passed on Node 20. Mutation not measured.
Adoption compliance
Level 1. The SDK is adopted and pinned. ADR-038 covers the architecture. F-737-01 and F-737-09 record runtime deviations.
Tech debt
Supervisor orchestration enlarges the existing CLI host module (DR-1).
Documentation
Grammar, schema, ADR, mirrors and changeset present. Glossary entry absent.
Performance & deployment
Opt-in deployment. F-737-08 tracks history growth.
|
First-round root cause: the supervisor is a separate authority and lifecycle, but the implementation inherits the delivery launcher and records supervision as transient side effects. Fix capability isolation before enabling any triggers. Then exercise stall, exhaustion, question, timeout and restart through one durable event/directive lifecycle. Persist flat events and ensure accepted directives survive interruption and are applied at most once. Cover fallback escalation and wait behavior at the engine boundary. Close with both real-run traces using the shipped workflow. |
|
Integration candidate is available locally in the sibling worktree 737-integration at 8b415264, based on the reviewed head 47e182a and main 4f7d8ff. It combines classification persistence with supervisor outcomes in the engine, keeps the new dependency, and regenerates both workflow bundles. TypeScript, the 15 engine supervisor tests, the bundle test and pre-commit passed. If your branch still has that head and your tree is clean, you can fast-forward to this candidate. Otherwise, use the tested resolution as reference when integrating your current changes. |
rucka
left a comment
There was a problem hiding this comment.
Verdict
APPROVED for integration on addcf70. The maintainer deferred #737's live GitHub question-and-answer trace to after integration. Keep #737 open for that acceptance check.
- F-737-01: restricted engine launch, scoped MCP tools and isolated local gates. The actual sandbox gate check passed on Ubuntu and macOS.
- F-737-02: watchdog stalling and loop exhaustion reach the supervisor before fallback. The regression tests pass.
- F-737-09: recovery tests cover interruption after acknowledgment for step and loop kills and human-answer directives.
- F-737-10: real Claude recovered a dirty disposable worktree through the shipped supervisor and preserved its untracked file. A separate real-engine run drafted a valid maintainer question and parked. The live GitHub round trip remains open.
- F-737-14: integrated main, regenerated both bundles, and verified a clean merge simulation.
The 246 focused tests and all GitHub checks passed. Prior resolved findings remain green. Mutation was not measured.
PR Information
Type: Feature
Story: #737
Merge strategy: squash
Refs #737
The live GitHub maintainer handoff remains open on #737. The maintainer authorized merging the implementation after all other review findings are resolved.
Summary
Adds an on-demand supervisor that diagnoses blocked workflow steps and directs the host through bounded recovery or a human decision.
Classification
risk:red·cost:yellowMatrix — per dimension
Confidence: high. Cost reflects bounded retries per trigger and on-demand model use.
Changes Made
Services to Release
@pair/pair-cliand@pair/workflows: supervisor host and protocol support.Testing
pnpm quality-gateandpnpm build: pass. Mutation: not measured.Reviewer Guide
Review directive guardrails, crash recovery, history replay, human polling and prompt safety. Inspect real-run limitations above. T-1 through T-8 follow the story's technical analysis and AC coverage; implementation approaches are captured in ADR-038 and the changed code.