Skip to content

fix: handle Pi 1.1 and 1.2 supervision events correctly - #7216

Merged
kunchenguid merged 17 commits into
kunchenguid:mainfrom
dar1us8:fm/firstmate-pi-sdk11-narrowing-correction
Oct 16, 2026
Merged

kunchenguid merged 17 commits into
kunchenguid:mainfrom
dar1us8:fm/firstmate-pi-sdk11-narrowing-correction

Conversation

@dar1us8

@dar1us8 dar1us8 commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

What Changed

  • Distinguish prompt-bearing startup events from custom triggers so custom messages cannot enter captain dialog or consume user wakes, while dedicated processing runs remain identifiable.
  • Pin strict extension typechecks to Pi 1.1.0, Pi 1.2.0, and TypeScript 5.9.3 with temporary dependencies; include them in gate lint.
  • Expand regression and real-SDK coverage for fallback delivery, startup context, processing cancellation, and history filtering; update related documentation and CI comments.

Risk Assessment

✅ Low: The compatibility correction is narrowly scoped, preserves existing ownership and cancellation controls, and introduces no substantiated material defects or unauthorized behavior.

Testing

Both SDK live guards, matched baselines, portable lifecycle regressions and actual transcript rendering passed. Requests, histories and rendered HTML were retained; disposable resources were removed. Both baselines also passed, so historical failures remain unexplained. Strict dual-SDK compilation is still required outside Test.

  • Live validation: ✅ go - 7 of 7 scenarios driven live against the product
Scenario Result Live Evidence
Submit a startup request and include it in the actual branch provider context before main persists it ✅ pass live STAGE_OK payloads in both SDK live transcripts; runtime-observations.json.
Park main during a dedicated processing opening without deleting history or leaking its envelope into the next request ✅ pass live SDK 1.2 processing CANCEL_OK payload, including subsequent provider requests and request-local contexts.
Park main while ordinary user or unrelated custom requests continue normally ✅ pass live User CANCEL_OK payloads on both SDKs and unrelated-custom CANCEL_OK on SDK 1.2.
Reject an unusable branch-model pin and return notification ownership to real main sessions ✅ pass live LIVE_OK payloads in both SDK live transcripts show actual main inputs, provider requests, settlements and successor confirmations.
Deliver notifications during streaming and idle periods while continuing the successor chain ✅ pass live Both SDK streaming guards and retained SDK 1.2 streaming session under sdk12-state/.
Retry repeated, differing and empty processing replies while preserving new answers and explicit acknowledgement ✅ pass live Both SDK retry guards; raw SDK 1.2 persisted retry messages and outcomes in runtime-observations.json and sdk12-state/.
Apply model and effort overrides across reopen and retain visible custom entries outside provider context ✅ pass live Both SDK model, effort and delivery guards; active-transcript.html and retained session records.
Evidence: Runtime report and limitations
# Runtime Test result: go (runtime phase only)

Head: `ad5fdf30f1ce4bd933482a1293fd0af6a82cf013`.
Base: `230db82145cf1376ad212b1dd4ae8c11e95fecc7`.

## Execution and isolation

Ran the existing `tests/fm-pi-branch-live-e2e.test.sh` through `bash bin/fm-test-run.sh` once per target SDK, with `FM_PI_BRANCH_LIVE_E2E=1`, a worktree-local `TMPDIR`, and inherited Firstmate root/state/data/config/projects overrides removed.
SDK 1.1.0 was the existing installed package, read only.
SDK 1.2.0 and its Pi siblings were provisioned with npm into a disposable worktree-local dependency root, without installation scripts or global changes.
Actual package versions, runtime hashes, platform, and SDK 1.2 npm integrity values are in `runtime-provenance.json`; registry provenance is retained separately.
No credentials, normal login, real operational home, live watcher, primary, fleet endpoint, Herdr resource, or default terminal session was used or changed.
The existing test's arm fixture was reused unchanged; it is not a production watcher proof.
A read-only artifact collector copied temporary SDK 1.2 session/outcome records before the existing test removed them.
No source or permanent test changes were made, no assertions or internal waits were changed, and neither target guard needed a retry.

## Live scenarios

1. **Current request reaches the actual branch before main persistence.** Both SDKs passed. SDK 1.1 emitted `prompt`, `systemPrompt`, `systemPromptOptions`, and `type`, with no `messageType`. While the later startup handler awaited branch settlement, its actual branch provider request contained the current captain request and main history did not yet contain it. SDK 1.2 also exercised the real no-prompt custom counterfactual and did not classify custom text as captain dialog. See `STAGE_OK` in both live logs and the structured observations.
2. **Parking cancels only a dedicated processing run and preserves history.** SDK 1.2 passed. Cancellation occurred before a second provider request; a subsequent ordinary request executed and omitted the retained processing envelope while retaining both ordinary user requests. The authoritative stored envelope and unprocessed outcome remained. See the processing `CANCEL_OK` payload in `sdk12-live.log`.
3. **Ordinary user and unrelated custom runs survive parking.** Ordinary user runs completed on both SDKs. The unrelated custom control completed on SDK 1.2. Each control made one provider completion and one settlement, retained its expected content, and left its outcome unprocessed. SDK 1.1 genuinely lacks the newer custom-opening boundary; only dependent custom cases were N/A, not its user, ownership, streaming, staging, or retry controls.
4. **An unusable model pin returns notification ownership to real main sessions.** Both SDKs passed. Actual rejected branch settlements were followed by real main input events, provider requests, stored user messages, and settlements for both the initially unpromptable branch and the unusable pin. Durable rows were retained and no branch outcome or claimed grant was fabricated. See `LIVE_OK` payloads. The separate 429 probe uses a real branch SDK but a simulated main callback and is not counted as additional live main-session evidence.
5. **Streaming and idle notifications retain successor delivery.** Both SDKs passed the actual AgentSession/ExtensionRunner guard: streaming follow-up input joined the running run through user `message_start`, without `before_agent_start`; idle delivery raised the prompt-bearing boundary, and both successor confirmations occurred. This uses the existing fixture arm; it does not prove production watcher continuity or a new native pending-wake replacement replay. The SDK 1.2 persisted streaming session is retained under `sdk12-state/`.
6. **Processing retries preserve new answers and acknowledgement semantics.** Both SDKs passed all four unchanged cases: repeated, differing, empty, and first-empty. The existing guard exercised actual session events, streaming renderer suppression, reopen, a subsequent ordinary answer, and acknowledgement. SDK 1.2 raw persisted sessions/outcomes are retained, with message payloads collected in `runtime-observations.json`; first and differing replies and the new user answer remain visible, exact repeats and empty finals do not become duplicate finals.
7. **Model/effort precedence and visible custom entries survive reopen.** Both SDKs passed actual model resolution, explicit create/reopen model and effort precedence, unsupported effort clamp, and custom-entry persistence/model-context exclusion. An additional evidence-only execution of the unchanged delivery probe, with its rendered output printed, produced `active-transcript.txt` and `active-transcript.html`. The HTML contains the real `InteractiveMode.chatContainer.render(240)` result, with ANSI styling removed; it is not a browser screenshot or a recreated mock. No interactive pty was started.

## Matched baseline and portable controls

Exported the base production tree into a disposable directory and ran the same current live guard against both real SDKs, changing only the copied test entrypoint to keep assertions matched.
Both fresh base runs passed; see `baseline-sdk11-live.log` and `baseline-sdk12-live.log`.
Thus these baseline executions do not reproduce the previously reported SDK 1.1 startup runtime failure and must not be presented as fail-before/pass-after evidence.
They also do not explain or erase historical pinned-delivery timeouts, failed setups, or successful replays.
The original type-narrowing regression is not established or disproved by JavaScript runtime success.
The separately excluded ordinary-dialog duplication defect was not repaired or made a delivery requirement.

Ran `bash bin/fm-test-run.sh tests/fm-pi-branch-extension.test.sh tests/fm-pi-watch-extension.test.sh --jobs 1` as separate portable regression controls.
Both passed, including generation/session ownership, pending-wake replacement and consumption, operational-envelope exclusion, stale callbacks, cancellation, and retained-history behavior.
Those stubbed controls are not labelled live SDK scenarios.

## Phase boundary and limitations

This is a truthful runtime-only go, not publication or final readiness approval.
No compiler, static analysis, linter, broad suite, publication, authentication probe, PR, or CI operation was executed in Test.
Fresh strict production-consumer checks against both real SDK 1.1.0 and 1.2.0 under TypeScript 5.9.3 remain mandatory in the compiler-owning lint/required exact-head hosted lane.
No historical compiler/CI result is substituted for that pending criterion.
A read-only inspection command was blocked by the host guard because its search pattern matched the guard's `pass` rule; it was not retried or bypassed, and direct file reading sufficed.
The disposable worktree-local source exports, dependencies, probes, caches, and fixtures were removed after evidence capture.
All fallback fixture-arm PIDs recorded in the four SDK runs were confirmed absent after the runs.
Evidence: SDK 1.1 live transcript
FM_TEST_BEGIN 2026-10-15T22:23:21Z tests/fm-pi-branch-live-e2e.test.sh family=live-harness-optin expected_gate_skip=live-capability
LIVE_OK {"requests":[{"model":"fm-live-main-model","messages":[{"role":"system","content":"You are an expert coding assistant operating inside pi, a coding agent harness. You help users by reading files, executing commands, editing code, and writing new files.\n\n<tools>\n- fm_branch_outcomes: Read what the supervision branch handled (durable outcome store).\n- fm_branch_processed: Acknowledge processed captain-facing supervision outcomes by sequence.\n- fm_watch_arm_pi: Start the first required Pi watcher cycle or repair a cycle reported missing, failed, or unhealthy; ordinary re-arming is automatic.\n\nIn addition to the tools above, you may have access to other custom tools depending on the project.\n</tools>\n\n<rules>\n- Call fm_watch_arm_pi only for the first required cycle or after a notification says the cycle is missing, failed, or unhealthy. Do not call it after ordinary work, turn completion, or ordinary signal, stale, check, or heartbeat handling because the Pi extension owns re-arming. Never run bin/fm-watch-arm.sh through bash.\n- Be concise in your responses\n- Show file paths clearly when working with files\n</rules>\n\n<docs>\nPi documentation (read only when the user asks about pi itself, its SDK, extensions, themes, skills, or TUI):\n- Main documentation: /opt/homebrew/lib/node_modules/@earendil-works/pi-coding-agent/README.md\n- Additional docs: /opt/homebrew/lib/node_modules/@earendil-works/pi-coding-agent/docs\n- Examples: /opt/homebrew/lib/node_modules/@earendil-works/pi-coding-agent/examples (extensions, custom tools, SDK)\n- When reading pi docs or examples, resolve docs/... under Additional docs and examples/... under Examples, not the current working directory\n- When asked about: extensions (docs/extensions.md, examples/extensions/), themes (docs/themes.md), skills (docs/skills.md), prompt templates (docs/prompt-templates.md), TUI components (docs/tui.md), keybindings (docs/keybindings.md), SDK integrations (docs/sdk.md), custom providers (docs/custom-provider.md), adding models (docs/models.md), pi packages (docs/packages.md), environment variables (docs/environment-variables.md), MCP servers (docs/mcp.md), codemode scripts and non-LLM models such as classifiers and image models (docs/codemode.md)\n- When working on pi topics, read the docs and examples, and follow .md cross-references before implementing\n- Always read pi .md files completely and follow links to related docs (e.g., tui.md for TUI API details)\n</docs>\n\n<cwd>\n~/firstmate/data/factum-v2-validation/nm-home-1.84.0/worktrees/ed75b620a487/01M504SGGF0TMF7JYA26Y5RWJJ/.runtime-validation/tmp/fm-pi-branch-live.W1ykz6/home\n</cwd>"},{"role":"user","content":[{"type":"text","text":"⁣FIRSTMATE_OP: v1 watcher: FIRSTMATE WATCHER WAKE: signal: live-sdk probe\n\nRun bin/fm-wake-drain.sh first and handle the queued wake. Watcher continuity is extension-owned."}]}],"stream":true,"stream_options":{"include_usage":true},"store":false,"max_completion_tokens":512,"tools":[{"type":"function","function":{"name":"fm_branch_outcomes","description":"Read the durable outcome store of the supervision branch: what fleet events it handled, each verdict, and each summary. Use when the captain asks what happened in the fleet.","parameters":{"type":"object","properties":{"recent":{"type":"number","description":"How many most-recent outcomes to read (default 20)"}}}}},{"type":"function","function":{"name":"fm_branch_processed","description":"Acknowledge that every captain-facing supervision outcome up to a sequence number has been processed by this conversation. Call it exactly once after handling a supervision processing request, with through set to the highest sequence that request listed; an outcome that is not acknowledged is presented again.","parameters":{"type":"object","required":["through"],"properties":{"through":{"type":"number","description":"The highest outcome sequence number this conversation has processed"}}}}},{"type":"function","function":{"name":"fm_watch_arm_pi","description":"Start the first required Pi watcher cycle, or repair one only after a notification says the cycle is missing, failed, or unhealthy. Do not call after ordinary work or ordinary notifications; the Pi extension re-arms automatically. Never run bin/fm-watch-arm.sh through bash.","parameters":{"type":"object","properties":{}}}}]},{"model":"fm-live-main-model","messages":[{"role":"system","content":"You are an expert coding assistant operating inside pi, a coding agent harness. You help users by reading files, executing commands, editing code, and writing new files.\n\n<tools>\n- fm_branch_outcomes: Read what the supervision branch handled (durable outcome store).\n- fm_branch_processed: Acknowledge processed captain-facing supervision outcomes by sequence.\n- fm_watch_arm_pi: Start the first required Pi watcher cycle or repair a cycle reported missing, failed, or unhealthy; ordinary re-arming is automatic.\n\nIn addition to the tools above, you may have access to other custom tools depending on the project.\n</tools>\n\n<rules>\n- Call fm_watch_arm_pi only for the first required cycle or after a notification says the cycle is missing, failed, or unhealthy. Do not call it after ordinary work, turn completion, or ordinary signal, stale, check, or heartbeat handling because the Pi extension owns re-arming. Never run bin/fm-watch-arm.sh through bash.\n- Be concise in your responses\n- Show file paths clearly when working with files\n</rules>\n\n<docs>\nPi documentation (read only when the user asks about pi itself, its SDK, extensions, themes, skills, or TUI):\n- Main documentation: /opt/homebrew/lib/node_modules/@earendil-works/pi-coding-agent/README.md\n- Additional docs: /opt/homebrew/lib/node_modules/@earendil-works/pi-coding-agent/docs\n- Examples: /opt/homebrew/lib/node_modules/@earendil-works/pi-coding-agent/examples (extensions, custom tools, SDK)\n- When reading pi docs or examples, resolve docs/... under Additional docs and examples/... under Examples, not the current working directory\n- When asked about: extensions (docs/extensions.md, examples/extensions/), themes (docs/themes.md), skills (docs/skills.md), prompt templates (docs/prompt-templates.md), TUI components (docs/tui.md), keybindings (docs/keybindings.md), SDK integrations (docs/sdk.md), custom providers (docs/custom-provider.md), adding models (docs/models.md), pi packages (docs/packages.md), environment variables (docs/environment-variables.md), MCP servers (docs/mcp.md), codemode scripts and non-LLM models such as classifiers and image models (docs/codemode.md)\n- When working on pi topics, read the docs and examples, and follow .md cross-references before implementing\n- Always read pi .md files completely and follow links to related docs (e.g., tui.md for TUI API details)\n</docs>\n\n<cwd>\n~/firstmate/data/factum-v2-validation/nm-home-1.84.0/worktrees/ed75b620a487/01M504SGGF0TMF7JYA26Y5RWJJ/.runtime-validation/tmp/fm-pi-branch-live.W1ykz6/home\n</cwd>"},{"role":"user","content":[{"type":"text","text":"⁣FIRSTMATE_OP: v1 watcher: FIRSTMATE WATCHER WAKE: signal: live pin probe\n\nRun bin/fm-wake-drain.sh first and handle the queued wake. Watcher continuity is extension-owned."}]}],"stream":true,"stream_options":{"include_usage":true},"store":false,"max_completion_tokens":512,"tools":[{"type":"function","function":{"name":"fm_branch_outcomes","description":"Read the durable outcome store of the supervision branch: what fleet events it handled, each verdict, and each summary. Use when the captain asks what happened in the fleet.","parameters":{"type":"object","properties":{"recent":{"type":"number","description":"How many most-recent outcomes to read (default 20)"}}}}},{"type":"function","function":{"name":"fm_branch_processed","description":"Acknowledge that every captain-facing supervision outcome up to a sequence number has been processed by this conversation. Call it exactly once after handling a supervision processing request, with through set to t

... [49513 bytes truncated] ...

 one owner of the rule."},"summary":{"type":"string","description":"One or two sentences in captain outcome language; include the full https:// PR URL when a PR is involved"},"wake":{"type":"string","description":"The wake reason line this outcome answers"},"silent":{"type":"boolean","description":"True only for an eligible routine no-change outcome; captain outcomes are never silent, and actions, state changes, or new results stay rendered"}}}}}]}],"persisted":[]}]}
ok - real Pi SDK 1.1.0 stages the current prompt into the actual branch provider request before a later startup handler returns
skip: Pi 1.1.0 predates the custom before_agent_start event contract
skip: Pi 1.1.0 has no custom before-agent boundary for the processing cancellation subprobe
CANCEL_OK {"mode":"user","completions":1,"settled":1,"requests":[{"model":"fm-live-stream-model","messages":[{"role":"system","content":"You are an expert coding assistant operating inside pi, a coding agent harness. You help users by reading files, executing commands, editing code, and writing new files.\n\n<tools>\n- fm_branch_outcomes: Read what the supervision branch handled (durable outcome store).\n- fm_branch_processed: Acknowledge processed captain-facing supervision outcomes by sequence.\n\nIn addition to the tools above, you may have access to other custom tools depending on the project.\n</tools>\n\n<rules>\n- Be concise in your responses\n- Show file paths clearly when working with files\n</rules>\n\n<docs>\nPi documentation (read only when the user asks about pi itself, its SDK, extensions, themes, skills, or TUI):\n- Main documentation: /opt/homebrew/lib/node_modules/@earendil-works/pi-coding-agent/README.md\n- Additional docs: /opt/homebrew/lib/node_modules/@earendil-works/pi-coding-agent/docs\n- Examples: /opt/homebrew/lib/node_modules/@earendil-works/pi-coding-agent/examples (extensions, custom tools, SDK)\n- When reading pi docs or examples, resolve docs/... under Additional docs and examples/... under Examples, not the current working directory\n- When asked about: extensions (docs/extensions.md, examples/extensions/), themes (docs/themes.md), skills (docs/skills.md), prompt templates (docs/prompt-templates.md), TUI components (docs/tui.md), keybindings (docs/keybindings.md), SDK integrations (docs/sdk.md), custom providers (docs/custom-provider.md), adding models (docs/models.md), pi packages (docs/packages.md), environment variables (docs/environment-variables.md), MCP servers (docs/mcp.md), codemode scripts and non-LLM models such as classifiers and image models (docs/codemode.md)\n- When working on pi topics, read the docs and examples, and follow .md cross-references before implementing\n- Always read pi .md files completely and follow links to related docs (e.g., tui.md for TUI API details)\n</docs>\n\n<cwd>\n~/firstmate/data/factum-v2-validation/nm-home-1.84.0/worktrees/ed75b620a487/01M504SGGF0TMF7JYA26Y5RWJJ/.runtime-validation/tmp/fm-pi-branch-live.W1ykz6/cancel-home-user\n</cwd>"},{"role":"user","content":[{"type":"text","text":"Original user turn."}]}],"stream":true,"stream_options":{"include_usage":true},"store":false,"max_completion_tokens":512,"tools":[{"type":"function","function":{"name":"fm_branch_outcomes","description":"Read the durable outcome store of the supervision branch: what fleet events it handled, each verdict, and each summary. Use when the captain asks what happened in the fleet.","parameters":{"type":"object","properties":{"recent":{"type":"number","description":"How many most-recent outcomes to read (default 20)"}}}}},{"type":"function","function":{"name":"fm_branch_processed","description":"Acknowledge that every captain-facing supervision outcome up to a sequence number has been processed by this conversation. Call it exactly once after handling a supervision processing request, with through set to the highest sequence that request listed; an outcome that is not acknowledged is presented again.","parameters":{"type":"object","required":["through"],"properties":{"through":{"type":"number","description":"The highest outcome sequence number this conversation has processed"}}}}}]}],"contexts":[[{"role":"system","content":"","sections":{"preamble":"You are an expert coding assistant operating inside pi, a coding agent harness. You help users by reading files, executing commands, editing code, and writing new files.","tools":"<tools>\n- fm_branch_outcomes: Read what the supervision branch handled (durable outcome store).\n- fm_branch_processed: Acknowledge processed captain-facing supervision outcomes by sequence.\n\nIn addition to the tools above, you may have access to other custom tools depending on the project.\n</tools>","rules":"<rules>\n- Be concise in your responses\n- Show file paths clearly when working with files\n</rules>","docs":"<docs>\nPi documentation (read only when the user asks about pi itself, its SDK, extensions, themes, skills, or TUI):\n- Main documentation: /opt/homebrew/lib/node_modules/@earendil-works/pi-coding-agent/README.md\n- Additional docs: /opt/homebrew/lib/node_modules/@earendil-works/pi-coding-agent/docs\n- Examples: /opt/homebrew/lib/node_modules/@earendil-works/pi-coding-agent/examples (extensions, custom tools, SDK)\n- When reading pi docs or examples, resolve docs/... under Additional docs and examples/... under Examples, not the current working directory\n- When asked about: extensions (docs/extensions.md, examples/extensions/), themes (docs/themes.md), skills (docs/skills.md), prompt templates (docs/prompt-templates.md), TUI components (docs/tui.md), keybindings (docs/keybindings.md), SDK integrations (docs/sdk.md), custom providers (docs/custom-provider.md), adding models (docs/models.md), pi packages (docs/packages.md), environment variables (docs/environment-variables.md), MCP servers (docs/mcp.md), codemode scripts and non-LLM models such as classifiers and image models (docs/codemode.md)\n- When working on pi topics, read the docs and examples, and follow .md cross-references before implementing\n- Always read pi .md files completely and follow links to related docs (e.g., tui.md for TUI API details)\n</docs>","cwd":"<cwd>\n~/firstmate/data/factum-v2-validation/nm-home-1.84.0/worktrees/ed75b620a487/01M504SGGF0TMF7JYA26Y5RWJJ/.runtime-validation/tmp/fm-pi-branch-live.W1ykz6/cancel-home-user\n</cwd>"},"timestamp":1792103015520,"toolsAdded":[{"name":"fm_branch_outcomes","description":"Read the durable outcome store of the supervision branch: what fleet events it handled, each verdict, and each summary. Use when the captain asks what happened in the fleet.","parameters":{"type":"object","properties":{"recent":{"type":"number","description":"How many most-recent outcomes to read (default 20)"}}}},{"name":"fm_branch_processed","description":"Acknowledge that every captain-facing supervision outcome up to a sequence number has been processed by this conversation. Call it exactly once after handling a supervision processing request, with through set to the highest sequence that request listed; an outcome that is not acknowledged is presented again.","parameters":{"type":"object","required":["through"],"properties":{"through":{"type":"number","description":"The highest outcome sequence number this conversation has processed"}}}}]},{"role":"user","content":[{"type":"text","text":"Original user turn."}],"timestamp":1792103015520}]],"cancellation":"not cancelled"}
skip: Pi 1.1.0 has no custom before-agent boundary for the unrelated cancellation subprobe
ok - real Pi SDK 1.1.0 preserves applicable user runs and unprocessed outcomes during away posture; newer custom-opening cases are N/A
FM_TEST_END 2026-10-15T22:23:35Z tests/fm-pi-branch-live-e2e.test.sh exit=0 duration_ms=14369 gate_skip=false
FM_TEST_SUMMARY total=1 failed=0 skipped_gate=0 duration_ms=14438
FM_TEST_SUMMARY_FAMILY family=live-harness-optin count=1 duration_ms=14369 failed=0
FM_TEST_SLOWEST rank=1 script=tests/fm-pi-branch-live-e2e.test.sh duration_ms=14369
fm-test-run: wrote timing artifact: ~/firstmate/data/factum-v2-validation/nm-home-1.84.0/evidence/01M504SGGF0TMF7JYA26Y5RWJJ/sdk11-timing.json
  • Evidence: SDK 1.2 live transcript (local file: ~/firstmate/data/factum-v2-validation/nm-home-1.84.0/evidence/01M504SGGF0TMF7JYA26Y5RWJJ/sdk12-live.log)
  • Evidence: Actual requests, events and persisted retry histories (local file: ~/firstmate/data/factum-v2-validation/nm-home-1.84.0/evidence/01M504SGGF0TMF7JYA26Y5RWJJ/runtime-observations.json)
Evidence: Actual Pi active-transcript render
<!doctype html><meta charset="utf-8"><title>Pi 1.2 active transcript</title><style>body{background:#151515;color:#ccc;margin:2rem;font:16px monospace}pre{overflow:auto}p{color:#aaa;font:14px sans-serif}</style><p>Actual Pi 1.2 InteractiveMode.chatContainer.render(240) output, immediately after appendEntry. ANSI styling removed; text and spacing retained. No interactive terminal or browser was launched.</p><pre>
 ⚓ [seq 234] email-intake-canary-next-page-diagnosis-v1: Completed diagnosis proves the prior assistant response was unrelated.                                                                                                                
</pre>
Evidence: SDK versions, runtime hashes and package integrity
{
  "head": "ad5fdf30f1ce4bd933482a1293fd0af6a82cf013",
  "node": "v24.5.0",
  "platform": "darwin",
  "arch": "arm64",
  "packages": [
    {
      "root": "/opt/homebrew/lib/node_modules/@earendil-works/pi-coding-agent",
      "version": "1.1.0",
      "piAI": "1.1.0",
      "piTUI": "1.1.0",
      "piAgentCore": "1.1.0",
      "runtime_sha256": {
        "package.json": "c662a36f8bc47843393a60dc8616a34dfcc8376e8fcc96dbc2f1020c60e38e2a",
        "dist/index.js": "5482298b995db935f7b96f5d6056fa1c36ac6fc80456be594ef65b83c62b0d30",
        "dist/core/agent-session.js": "0ba5c847b4fd2fd838f71ea84885b9f3a4f15d9bf4b5493e2e88a41d1507e20b",
        "dist/core/extensions/runner.js": "258f142bc56cc84d953ef6146222e5ff3a94cc908592a1b3d075d34bbcd68b36"
      }
    },
    {
      "root": "~/firstmate/data/factum-v2-validation/nm-home-1.84.0/worktrees/ed75b620a487/01M504SGGF0TMF7JYA26Y5RWJJ/.runtime-validation/sdk12/node_modules/@earendil-works/pi-coding-agent",
      "version": "1.2.0",
      "piAI": "1.2.0",
      "piTUI": "1.2.0",
      "piAgentCore": "1.2.0",
      "runtime_sha256": {
        "package.json": "d4231a02b6a2ccb357a8e9e420fab9c217490137ade958d4a45a12e169daad0c",
        "dist/index.js": "5482298b995db935f7b96f5d6056fa1c36ac6fc80456be594ef65b83c62b0d30",
        "dist/core/agent-session.js": "a5c9ff22e42215405804dc0c850e98aff424a1262829161155132a3da020b693",
        "dist/core/extensions/runner.js": "0e659fb4338069d91c4d0a3b032b51bf8d179a99e6417bc3e39e59b672aaec76"
      }
    }
  ],
  "sdk12_verified_npm_integrities": {
    "node_modules/@earendil-works/pi-coding-agent": {
      "version": "1.2.0",
      "integrity": "sha512-h/4WaVWv1VlCaY8x8qEN5U+7jbF/e7+Ck6moPeEOFn5juMTWwNAXjwgYM7gRgbBYh8Zppwt6qWvJDzNTf4GNEQ=="
    },
    "node_modules/@earendil-works/pi-coding-agent/node_modules/@earendil-works/pi-agent-core": {
      "version": "1.2.0",
      "integrity": "sha512-pUR0vYmGhHkBQGeCeWjwVIA+l1+MrDu6m6VGuysjh6KBzBpovTV/MlcVrEIOaM8jv/slpAyUmuCEQl1jOBqHJQ=="
    },
    "node_modules/@earendil-works/pi-coding-agent/node_modules/@earendil-works/pi-ai": {
      "version": "1.2.0",
      "integrity": "sha512-U5/1zXqfV1on7/9sbez03tT4Ru49Lvfb4+zXSDK3DBKF5cRk6KxvAOTOY3HJ4jimlZth+rs7vbJqN6iBQAoNuQ=="
    },
    "node_modules/@earendil-works/pi-coding-agent/node_modules/@earendil-works/pi-codemode": {
      "version": "1.2.0",
      "integrity": "sha512-UZF7IN0IIrf3bop2wTxrwoAakGctH6d3zdPwhPN+QHMECfoI5E6B6l6I17YGFZPj8cmGex6xX7mLCNJXRf7wsw=="
    },
    "node_modules/@earendil-works/pi-coding-agent/node_modules/@earendil-works/pi-mcp": {
      "version": "1.2.0",
      "integrity": "sha512-ertUv40rUBgssTzw2lIPlejjIBdhvdg4uw+whWCDJYKYHU+ldp1ezhbB0BzwpBfnwef6/YN+m6eKLscj+r3p7w=="
    },
    "node_modules/@earendil-works/pi-coding-agent/node_modules/@earendil-works/pi-tui": {
      "version": "1.2.0",
      "integrity": "sha512-OdJCiYklkL3TqmdmGKUflHoLy9zw18GBYO0DPASZvGlP4RkDXAZzLLDt7cidJ6wUR7DBrKb13rrekDsXgMF60g=="
    }
  }
}
  • Evidence: Matched base SDK 1.1 transcript (local file: ~/firstmate/data/factum-v2-validation/nm-home-1.84.0/evidence/01M504SGGF0TMF7JYA26Y5RWJJ/baseline-sdk11-live.log)
  • Evidence: Matched base SDK 1.2 transcript (local file: ~/firstmate/data/factum-v2-validation/nm-home-1.84.0/evidence/01M504SGGF0TMF7JYA26Y5RWJJ/baseline-sdk12-live.log)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 7 of 7 scenarios driven live against the product
Scenario Result Live Evidence
Submit a request during startup and include it in the actual branch provider context before main persists it ✅ pass live SDK1.1 and SDK1.2 provider-events artifacts; both baseline-control artifacts
Enter away posture as a dedicated processing run opens without deleting history or acknowledging its outcome ✅ pass live SDK1.2 provider-events artifact: processing CANCEL_OK requests and contexts
Keep ordinary user and unrelated custom requests running across the same away transition ✅ pass live SDK1.1 and SDK1.2 provider-events artifacts: user and unrelated CANCEL_OK controls
Reject an unusable branch-model pin and return notification ownership to a real main session ✅ pass live Both provider-events artifacts: LIVE_OK inputs, provider requests, settlements, and delivery confirmations; retained session and durable-row records indexed in runtime report
Deliver notifications while streaming and idle while maintaining the successor chain ✅ pass live SDK1.1 and SDK1.2 streaming-events artifacts
Retry processing with repeated, differing, empty, and first-empty replies while preserving new answers and acknowledgement semantics ✅ pass live Runtime report indexes sdk11-observations/retry-.json, sdk12-observations/retry-.json, and persisted session records
Reopen sessions with model and effort overrides and persist visible outcomes outside provider context ✅ pass live Runtime report indexes model/effort observations and append-entry state; actual transcript HTML
  • npm install --prefix .runtime-validation/sdk-1.2.0 --install-strategy=nested --ignore-scripts --no-audit --no-fund with pinned public SDK siblings
  • bash tests/fm-pi-branch-live-e2e.test.sh against installed SDK1.1.0 and workspace-local SDK1.2.0, including fresh isolated HOME and default agent-directory runs
  • Unchanged target live guard against archived base 9b1ada0401f9fa7ea3ee07a8a7f005a99ce0de58 under both SDKs; retained initial fixture failures and completed-baseline results
  • bash tests/fm-pi-branch-extension.test.sh
  • bash tests/fm-pi-watch-extension.test.sh
  • Both SDK live guards with observation-only serialization of actual streaming events, retry state, and model/effort results; original assertions and time limits unchanged
  • node .runtime-validation/delivery-probe.mjs under both SDKs, retaining actual InteractiveMode rendering and reopened state
  • Verified fixture-process cleanup and removed disposable dependencies, baseline copies, and capture files; final worktree clean

✅ No issues found.

  • Live validation: ✅ go - 7 of 7 scenarios driven live against the product
Scenario Result Live Evidence
Submit a startup request and include it in the actual branch provider context before main persists it ✅ pass live STAGE_OK payloads in both SDK live transcripts; runtime-observations.json.
Park main during a dedicated processing opening without deleting history or leaking its envelope into the next request ✅ pass live SDK 1.2 processing CANCEL_OK payload, including subsequent provider requests and request-local contexts.
Park main while ordinary user or unrelated custom requests continue normally ✅ pass live User CANCEL_OK payloads on both SDKs and unrelated-custom CANCEL_OK on SDK 1.2.
Reject an unusable branch-model pin and return notification ownership to real main sessions ✅ pass live LIVE_OK payloads in both SDK live transcripts show actual main inputs, provider requests, settlements and successor confirmations.
Deliver notifications during streaming and idle periods while continuing the successor chain ✅ pass live Both SDK streaming guards and retained SDK 1.2 streaming session under sdk12-state/.
Retry repeated, differing and empty processing replies while preserving new answers and explicit acknowledgement ✅ pass live Both SDK retry guards; raw SDK 1.2 persisted retry messages and outcomes in runtime-observations.json and sdk12-state/.
Apply model and effort overrides across reopen and retain visible custom entries outside provider context ✅ pass live Both SDK model, effort and delivery guards; active-transcript.html and retained session records.
  • FM_PI_BRANCH_LIVE_E2E=1 FM_PI_PACKAGE_DIR=/opt/homebrew/lib/node_modules/@earendil-works/pi-coding-agent bash bin/fm-test-run.sh tests/fm-pi-branch-live-e2e.test.sh with isolated worktree-local fixtures.
  • npm install --prefix &#34;$PWD/.runtime-validation/sdk12&#34; --install-strategy=nested --ignore-scripts --no-audit --no-fund with SDK 1.2.0 and matching Pi sibling pins.
  • FM_PI_BRANCH_LIVE_E2E=1 FM_PI_PACKAGE_DIR=&#34;$PWD/.runtime-validation/sdk12/node_modules/@earendil-works/pi-coding-agent&#34; bash bin/fm-test-run.sh tests/fm-pi-branch-live-e2e.test.sh with raw session evidence capture.
  • git archive 230db82145cf1376ad212b1dd4ae8c11e95fecc7 | tar -x -C .runtime-validation/baseline; ran the current live guard against that base production tree with both SDKs.
  • bash bin/fm-test-run.sh tests/fm-pi-branch-extension.test.sh tests/fm-pi-watch-extension.test.sh --jobs 1.
  • node .runtime-validation/render-probe.mjs: executed the existing delivery probe with unchanged assertions and printed its actual rendered transcript.
  • Retained provider requests, vendor events, persisted histories, package provenance and rendered HTML; verified recorded fixture-arm PIDs were absent.
  • rm -rf .runtime-validation; confirmed a clean worktree at the target commit. No compiler, lint, broad-suite, authentication, publication or CI commands ran.
✅ **Document** - passed

✅ No issues found.

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

✅ No issues found.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @dar1us8. This is careful work, and the SDK 1.1 narrowing correction plus the real-SDK custom-trigger probes are exactly the evidence this needs.

What I checked: the tip 819cefa8 against main 6407052f. The production change stays inside the two before_agent_start handlers. A Pi 1.2 custom trigger with no prompt is never staged as captain dialog and never consumes a pending user wake. It marks a dedicated processing run only when it is the queued fm-branch-process message. Pi 1.1 events always carry a prompt, so they keep the existing path. There's no workflow, network or secret surface, and the live guard stays opt-in and routes provider calls to .invalid hosts. The attestation matches 819cefa8, with live validation go 6/6.

CI: I approved the fork runs after the diff review: 38357978004 (CI) and 38357978035 (Require no-mistakes). Heads-up: main is also red on serial 4's fm-pi-branch-extension, where the MCP_TYPESCRIPT_PREAMBLE import from pi-codemode fails. This PR doesn't touch that, so if it fails here, that's main, not you.

Contract-class (mine): restore. The documented before_agent_start contract (stage captain prompts, consume user wakes, and in away posture cancel only a dedicated processing run) broke on Pi 1.2. This restores it without adding a new default surface.
VISION.md per rule: every rule aligns. It keeps a verified Pi adapter working across 1.1 and 1.2, which is what "the fleet outlives any vendor" asks for.

Overlap, for visibility: the same two handlers are also fixed in #7200, a standalone split of the #6327 hunk that was opened earlier, and inside #6327 and #6760. The differences I see: here, custom runs return before rememberMainModel / currentMainSession, and the processing match also checks customType. #7200 uses a structural view instead of a type predicate. Only one of these should land, and whichever does, the hunk drops out of the others. That choice is Kun's, and you don't need to do anything about it.

Next: this is waiting on CI. Nothing is needed from you right now, and nothing merges while main is red.

tiago-peixoto pushed a commit to tiago-peixoto/firstmate that referenced this pull request Oct 13, 2026
…ream 7216)

Carries upstream pull request kunchenguid#7216
at head commit 819cefa, squashed from its four commits:
7922116 fix(pi): retain custom-event handling and processing cancellation
2705f90 fix(pi): identify custom triggers before legacy prompt narrowing
1114ae0 no-mistakes(test): Correct branch fixture retirement and verify real notification ownership
819cefa no-mistakes(document): Clarify Pi event boundaries and verification scope

The fork drops this commit when upstream merges its own fix.
@dar1us8 dar1us8 changed the title fix: distinguish Pi custom triggers from user prompts fix: support Pi 1.1 and 1.2 supervision event shapes Oct 15, 2026

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks for the refresh, @dar1us8. Judging only the delta since the 2026-10-13 stamp (819cefa8 → 753893fc).

Delta: rebase onto current main plus dual-SDK (Pi 1.1.0 / 1.2.0) production-consumer typechecks moved into the lint-owned phase, live-e2e and docs clarifications for prompt-bearing vs no-prompt custom boundaries. Production change remains inside the two before_agent_start handlers: custom/no-prompt events are identified before prompt narrowing, never staged as captain dialog, never consume a pending user wake, and mark a dedicated processing run only for the queued fm-branch-process message. Attestation matches 753893fc; live validation still go.

Contract-class (mine): restore — same as before. The documented before_agent_start contract broke on Pi 1.2's custom shape; this restores it without a new default captain-facing surface.

VISION.md: every rule still aligns; fleet-outlives-vendor is the strongest fit (verified Pi adapter across 1.1 and 1.2).

#7242: related only in that both touch Pi supervision. #7242 is the watcher restoreAfterActionableClose dead-successor readiness gap; this PR does not address that path and does not close #7242.

Overlap (unchanged): #7200 / #6327 / #6760 still share related handler hunks — only one should land.

Next: fork CI re-approved for this head (38767548683 CI, 38767605369/38767548801 Require no-mistakes). Waiting on green. Nothing needed from you right now.

… inlining EXIT cleanup. Also fixed a reproduced macOS npm-prefix/lockfile path failure without changing dependency pins or assertions. Canonical targeted lint, strict TypeScript 5.9.3 checks against Pi 1.1.0 and 1.2.0, and success/failure cleanup checks pass. Both behavior-shard failures were upstream npm ETARGET errors in workflow steps unchanged from base; no workflow/runtime changes warranted. Hosted CI remains for the outer executor
@dar1us8
dar1us8 force-pushed the fm/firstmate-pi-sdk11-narrowing-correction branch from 52394cc to 0977548 Compare October 15, 2026 22:34