Skip to content

feat: six-part /bearings digest with flow mode, and narrow Pi before_agent_start events - #13

Merged
prishsu0730 merged 4 commits into
mainfrom
fm/maint-bearings-flow-fork
Oct 14, 2026
Merged

prishsu0730 merged 4 commits into
mainfrom
fm/maint-bearings-flow-fork

Conversation

@prishsu0730

@prishsu0730 prishsu0730 commented Oct 14, 2026 •

Copy link
Copy Markdown
Owner

Intent

Make the red CI check Behavior portable parallel 1 (tests/fm-pi-primary-types.test.sh) green on this PR by porting the upstream fix kunchenguid#7248: narrow before_agent_start events by messageType before reading the prompt in .pi/extensions/fm-branch-supervision.ts and .pi/extensions/fm-primary-pi-watch.ts, with the matching test fixture updates in tests/fm-pi-branch-extension.test.sh, tests/fm-pi-branch-live-e2e.test.sh, and tests/fm-pi-watch-extension.test.sh. Nothing else.

What Changed

  • Pi extensions (port of upstream fix(pi): narrow before_agent_start events before reading prompt kunchenguid/firstmate#7248): .pi/extensions/fm-branch-supervision.ts now checks event.messageType before it reads the prompt in before_agent_start. A processing turn counts as opened only when a custom processing message matches the queued content. The user-prompt mirror runs only for user events. .pi/extensions/fm-primary-pi-watch.ts skips non-user events before consumeWake. The test fixtures in tests/fm-pi-branch-extension.test.sh, tests/fm-pi-branch-live-e2e.test.sh, and tests/fm-pi-watch-extension.test.sh now send messageType: "user". The processing-turn case now sends messageType: "custom" with the processing message.
  • Bearings skill: .agents/skills/bearings/SKILL.md changes the chat digest from four sections to six parts: Outcome (with CONSTRAINT: and Recently landed: lines), Active, Waiting, Held, Needs Me, and Next. It adds a chat-only /bearings flow option. Constraint and Next lines use only the home's own ranking rule and print unknown or UNKNOWN when there is no rule or no clear answer.
  • Bearings data rules: Missing timestamps, dependencies, and unverified states render as UNKNOWN. A blocker id that appears nowhere in the snapshot shows as "blocker UNKNOWN (id not in snapshot)". Blockers for a non-main owner are matched inside that owner's home. The data-file report keeps its four data sections, and the skill now maps them to the six chat parts.

🤖 Generated with Claude Code

Risk Assessment

✅ Low: The commit is a small, faithful port of upstream kunchenguid#7248: it narrows before_agent_start by messageType before reading prompt or message. Processing-turn detection now keys on the custom message's content. Wakes are still consumed for user prompts, since watch wakes go through sendUserMessage, and message_start keeps its fallback. The test fixtures were updated to the new event shape.

Testing

I ran the two Pi extension tests this change edits on the fixed code. Both passed. I also ran them on the old extension code with the new test fixtures, and the branch test crashed on the missing prompt. So the tests really check the new messageType handling. The live end-to-end test and the strict type check (the red CI job) could not run here. tsc and @earendil-works/pi-coding-agent are missing, and installing them needs approval. Remote CI still has to show the type check is green.

  • Live validation: ✅ go - 4 of 6 scenarios driven live against the product
Scenario Result Live Evidence
A typed user prompt still reaches the dialog mirror and the operational-text filter (branch supervision) ✅ pass live bash tests/fm-pi-branch-extension.test.sh, branch-extension.log, including 'dialog mirror filters tool and operational traffic...'
A custom processing message opens the processing turn by its content, with no prompt field ✅ pass live branch-extension.log: 'a captain outcome opens one sequence-keyed processing turn...' and the away-posture test pass
Adversarial: without the fix, a custom-message event crashes the handler ✅ pass live branch-extension-without-fix.log: TypeError reading 'trim' at fm-branch-supervision.ts:1686, exit 1
Primary watch consumes a wake only from a user-type before_agent_start ✅ pass live bash tests/fm-pi-watch-extension.test.sh, watch-extension.log, 60 ok
Strict Pi type check (tests/fm-pi-primary-types.test.sh, the red CI job) passes ⏸️ untested no tsc is not on PATH, and @earendil-works/pi-coding-agent is not installed globally. Installing either one into a temp folder was denied, and the user's rules say never to install packages without a…
Live branch e2e with real Pi handlers ⏸️ untested no This test is opt-in and needs the installed Pi package. That package is not here, and installing it was denied (see above).
Evidence: Branch extension test, fixed code

Source: Branch extension test, fixed code

ok - fm_branch_outcomes and fm_branch_processed call headers match stock on Pi before and from 0.99
skip: installed @earendil-works/pi-coding-agent package not found
skip: installed @earendil-works/pi-coding-agent package not found
ok - branch owns accepted wakes with a stable prefix and deterministic verdict-driven delivery
ok - a captain outcome reaches main's model as one typed, sequence-keyed processing request while routine notes stay plain
ok - requested and unsolicited healthy outcomes keep distinct delivery and event ownership
ok - captain outcomes are exact and exactly once across crash, reload, busy main, compaction, and an unrelated assistant response
ok - a captain outcome opens one sequence-keyed processing turn, survives empty and unrelated answers, is re-presented at run end and session start, and closes only on its acknowledgement
ok - Pi: an abbreviated processing request points to the full outcome and instructs main to read it first
ok - Pi: a marker-less >1 MiB backlog is presented oldest first in bounded requests and continues after batch acknowledgement
ok - an unprocessed captain row the store lists without its age is reported to main, never formatted undated, and stays unprocessed until the store is healthy
ok - scopeForUnreadWake excludes every main-only class without vetoing eligible task-local rows, and writes the eligible snapshot
ok - second-mate signal rows route by their new span while crewmate and stale routing stay unchanged
ok - branch prompt_cache_key is stable per home across sessions and distinct between homes
ok - branch default-on eligibility (task-scoped, heartbeat, legacy flag ignored) binds and a broken branch rejects to watcher fallback
ok - under the away-posture record the wake carries the verbatim read-back tail, claims every row, opens no processing turn, cancels a pending request, and presents the accumulated rows after archive
ok - Pi branch: an unchanged held outcome reaches the captain once across cadences, and a later red check on the task still does
ok - an accepted away-only wake rejects after archive, while a drained task-local wake stays a quiet no-op
ok - a claimed heartbeat row on a non-heartbeat away wake lifts task scoping for the fleet report
ok - a heartbeat review survives a check row arriving before its drain
ok - fm_branch_report refuses a task the wake did not name, fleet included, while a heartbeat is unscoped
ok - pre-drain eligibility re-check excludes a newly main-owned row without deferring eligible work
ok - a co-present needs-decision row neither vetoes nor falsely settles routine branch delivery
ok - a settled branch turn without a durable outcome falls back and releases its grant for main replay
ok - provider-error latches cool down, re-probe once with backoff, and recover through a durable report
ok - selection changes preserve in-flight transcript ownership and reset provider-error streaks
ok - a stale main claim returns the durable wake to watcher delivery
ok - pre-drain eligibility re-check no-ops an already-drained wake
ok - dialog mirror filters tool and operational traffic, lands before wakes, and keeps a durable cursor
ok - the dialog mirror re-anchors for each session's new branch conversation and stays incremental within it
ok - every main session start begins a new branch conversation while one session keeps its own
ok - the current pin state binds every branch build, and clearing it returns the branch to main's model
ok - unpinned branches follow main model changes live while pinned branches stay fixed
ok - supervision-model command persists the captain's pick and rebinds the live branch
ok - supervision-model opens a bounded searchable list, follow main first, and pins the branch alone
ok - branch model picker keeps follow main first and filters the eligible catalog
ok - the effort pin binds every branch build, and clearing it returns the branch to main's effort
ok - unpinned branches follow main effort changes live while pinned branches stay fixed
ok - an extension-registered provider resolves in the isolated branch runtime
ok - supervision-model runs an effort picker after the model picker and persists both independently
ok - an unusable model pin rejects to watcher fallback and an unparseable one is treated as no pin
ok - replacement activation cleans old branch leases and retries failed cleanup
ok - branch activates on a cold start once the lock is acquired, never before
ok - queued wakes and mirrors stop mutating branch state after lock ownership is lost
ok - stale reports, shells, mirrors, cursors, leases, and prompts perform no side effects
ok - a Pi session that does not own the lock accepts nothing and mutates no branch state
ok - an extension rebind re-mirrors undelivered dialog instead of dropping it
ok - outcome delivery keeps the event loop running and interleaved reports stay ordered and exactly once
ok - a session replaced mid-delivery cancels cleanly and the stored outcome still arrives exactly once
ok - a failing store script surfaces to the branch and its outcome is neither lost nor delivered twice
ok - a failed cursor write re-delivers a routine note exactly once more while a captain outcome stays deduplicated
Evidence: Watch extension test, fixed code

Source: Watch extension test, fixed code

ok - Pi extension reports external healthy watcher output
ok - Pi custom tool exposes repair-only metadata and returns automatic-continuation guidance
ok - Pi redundant tool call returns ownership guidance and spawns no second child
ok - Pi scheduled retry remains extension-owned after another tool call
ok - Pi actionable close starts one successor before wake delivery settles
ok - Pi actionable output waits for predecessor close before successor restoration
ok - Pi dispatcher branch offer owns accepted wakes and falls back to main
ok - Pi dispatcher flags a fleet-wide heartbeat offer as branch-eligible
ok - a co-present check row neither vetoes nor rides a heartbeat into main
ok - every main-only check class still reaches main, never the supervision branch
ok - a captain-held signal trigger reaches main with routine rows present
ok - an unread pending-reply escalation keeps later stale aliases on main
ok - a mixed batch of two distinct files - one routine, one needs-decision - routes wholly to main
ok - a co-present needs-decision row neither vetoes nor rides a heartbeat into main
ok - heartbeat restoration failure stays on main
ok - watcher-failure repair stays with main even with a live, accepting branch listener
ok - under the away-posture record every actionable row is offered to the branch while broken-queue wakes and watcher-failure alarms still reach main
ok - Pi refused handling handshake is classified and not swallowed
ok - Pi confirm failure retires the named arm with distinct watcher pid
ok - Pi confirm failure for a stale successor spares the newer arm
ok - Pi superseded handling delivery carries no rejection appendix and is logged
ok - Pi superseded handling delivery is offered to the branch like a confirmed one
ok - Pi extension diagnostic log stays off unless opted in
ok - Pi repair starts a fresh arm instead of no-opping on a dead child
ok - Pi scheduled retry starts a fresh arm instead of stalling on a dead child
ok - Pi deferred close starts a fresh arm instead of stalling on a dead child
ok - Pi hung successor falls back to one typed actionable wake
ok - Pi unretired successor falls back without an overlapping retry
ok - Pi late unretired closes resume classified supervision
ok - Pi clean empty close triggers a bounded continuity retry
ok - Pi established clean closes stop at the configured retry limit
ok - Pi close handler verifies session-lock ownership before successor launch
ok - Pi watcher arm distinguishes all session lock ownership states
ok - Pi session transitions auto-arm through a generation owner across /new /resume /fork/reload, stale callbacks, and quit
ok - Pi session replacement auto-arms and carries its in-flight actionable close
ok - Pi replacement replays a streaming follow-up before consumption
ok - Pi streaming-time wake delivery keeps the successor chain and replays only unconsumed wakes
ok - Pi retries a verified successor that failed during wake delivery once that delivery settles
ok - Pi replacement receives actionable closes after retirement timeout
ok - Pi replacement handoff tokens stay unique across fresh modules
ok - Pi replacement persistence failure keeps its predecessor until a successor commits
ok - Pi process-exit cleanup listener remains singular across session replacement
ok - Pi process-exit cleanup stops the attached arm child
ok - OpenCode plugins have an explicit ESM boundary even under a typeless parent package
ok - OpenCode watcher plugin uses the effective FM_HOME state
ok - OpenCode watcher plugin sources the effective config
ok - OpenCode watcher plugin requires session lock ownership
ok - OpenCode watcher coordinator respects primary scope
ok - OpenCode watcher plugin starts one successor before wake prompt delivery settles
ok - OpenCode watcher plugin runs the supervision host on an opted-in home and relays every host line (away record)
ok - OpenCode watcher plugin runs the supervision host on an opted-in home and relays every host line (quiet record)
ok - OpenCode pre-ready actionable close preserves its successor
ok - OpenCode hung successor falls back to one typed actionable wake
ok - OpenCode unretired successor falls back without an overlapping retry
ok - OpenCode late unretired closes resume classified supervision
ok - OpenCode clean empty close triggers a bounded continuity retry
ok - OpenCode established clean closes stop at the configured retry limit
ok - OpenCode close handler verifies session-lock ownership before successor launch
ok - OpenCode watcher plugin coordinates with the turn-end guard
ok - OpenCode healthy arm output does not suppress the turn-end guard
Evidence: Branch extension test, old code (fails)

Source: Branch extension test, old code (fails)

not ok - the away posture must park main and present after archive: .../fm-branch-supervision.ts:1686 TypeError: Cannot read properties of undefined (reading 'trim')

ok - fm_branch_outcomes and fm_branch_processed call headers match stock on Pi before and from 0.99
skip: installed @earendil-works/pi-coding-agent package not found
skip: installed @earendil-works/pi-coding-agent package not found
ok - branch owns accepted wakes with a stable prefix and deterministic verdict-driven delivery
ok - a captain outcome reaches main's model as one typed, sequence-keyed processing request while routine notes stay plain
ok - requested and unsolicited healthy outcomes keep distinct delivery and event ownership
ok - captain outcomes are exact and exactly once across crash, reload, busy main, compaction, and an unrelated assistant response
ok - a captain outcome opens one sequence-keyed processing turn, survives empty and unrelated answers, is re-presented at run end and session start, and closes only on its acknowledgement
ok - Pi: an abbreviated processing request points to the full outcome and instructs main to read it first
ok - Pi: a marker-less >1 MiB backlog is presented oldest first in bounded requests and continues after batch acknowledgement
ok - an unprocessed captain row the store lists without its age is reported to main, never formatted undated, and stays unprocessed until the store is healthy
ok - scopeForUnreadWake excludes every main-only class without vetoing eligible task-local rows, and writes the eligible snapshot
ok - second-mate signal rows route by their new span while crewmate and stale routing stay unchanged
ok - branch prompt_cache_key is stable per home across sessions and distinct between homes
ok - branch default-on eligibility (task-scoped, heartbeat, legacy flag ignored) binds and a broken branch rejects to watcher fallback
not ok - the away posture must park main and present after archive: file:///private/var/folders/cp/dj_1dxy11bn_km_1vbw0m_p00000gn/T/fm-pi-branch-extension.x5ELJb/away-root/.pi/extensions/fm-branch-supervision.ts:1686
    const trimmed = prompt.trim();
                           ^

TypeError: Cannot read properties of undefined (reading 'trim')
    at file:///private/var/folders/cp/dj_1dxy11bn_km_1vbw0m_p00000gn/T/fm-pi-branch-extension.x5ELJb/away-root/.pi/extensions/fm-branch-supervision.ts:1686:28
    at process.processTicksAndRejections (node:internal/process/task_queues:104:5)
    at async fire (eval at <anonymous> (file://~/.no-mistakes/worktrees/6548ae86a5f1/01M4WGBDP6H3WST597DAPSEEGF/[eval1]:2:7), <anonymous>:186:63)
    at async file://~/.no-mistakes/worktrees/6548ae86a5f1/01M4WGBDP6H3WST597DAPSEEGF/[eval1]:114:1

Node.js v24.15.0: expected exit 0, got 1
Evidence: Live e2e test output

Source: Live e2e test output

skip: live: opt-in; set FM_PI_BRANCH_LIVE_E2E=1 to run
- Outcome: ⚠️ 1 info across 1 run (6m38s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

⚠️ **Test** - 1 info
  • ℹ️ tests/fm-pi-primary-types.test.sh - I could not run the strict type check here (tests/fm-pi-primary-types.test.sh), which is the job CI reported red. tsc and the Pi package are not installed, and the temp-folder install was denied. Remote CI must confirm the job is green.
  • Live validation: ✅ go - 4 of 6 scenarios driven live against the product
Scenario Result Live Evidence
A typed user prompt still reaches the dialog mirror and the operational-text filter (branch supervision) ✅ pass live bash tests/fm-pi-branch-extension.test.sh, branch-extension.log, including 'dialog mirror filters tool and operational traffic...'
A custom processing message opens the processing turn by its content, with no prompt field ✅ pass live branch-extension.log: 'a captain outcome opens one sequence-keyed processing turn...' and the away-posture test pass
Adversarial: without the fix, a custom-message event crashes the handler ✅ pass live branch-extension-without-fix.log: TypeError reading 'trim' at fm-branch-supervision.ts:1686, exit 1
Primary watch consumes a wake only from a user-type before_agent_start ✅ pass live bash tests/fm-pi-watch-extension.test.sh, watch-extension.log, 60 ok
Strict Pi type check (tests/fm-pi-primary-types.test.sh, the red CI job) passes ⏸️ untested no tsc is not on PATH, and @earendil-works/pi-coding-agent is not installed globally. Installing either one into a temp folder was denied, and the user's rules say never to install packages without a…
Live branch e2e with real Pi handlers ⏸️ untested no This test is opt-in and needs the installed Pi package. That package is not here, and installing it was denied (see above).
  • bash tests/fm-pi-branch-extension.test.sh on the fixed code: 49 ok, 0 not ok (2 picker tests skipped: Pi package not installed)
  • bash tests/fm-pi-watch-extension.test.sh on the fixed code: 60 ok, 0 not ok
  • bash tests/fm-pi-branch-live-e2e.test.sh: skipped, opt-in (FM_PI_BRANCH_LIVE_E2E=1) and needs the installed Pi package
  • Adversarial: put back the old .ts files from 7931b2a and reran both tests. The branch test failed with TypeError: Cannot read properties of undefined (reading &#39;trim&#39;) at fm-branch-supervision.ts:1686. Then I restored 24ba65c and the worktree was clean.
  • Tried npm install --prefix /tmp/fm-pitype-01M4 @earendil-works/pi-coding-agent typescript to run tests/fm-pi-primary-types.test.sh. Permission was denied.
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@prishsu0730 prishsu0730 changed the title feat(bearings): six-part chat digest with CONSTRAINT, Next, UNKNOWN, and /bearings flow feat: six-part /bearings digest with flow mode, and narrow Pi before_agent_start events Oct 14, 2026
@prishsu0730
prishsu0730 merged commit b9d7881 into main Oct 14, 2026
20 checks passed
@prishsu0730
prishsu0730 deleted the fm/maint-bearings-flow-fork branch October 22, 2026 17:01
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