Skip to content

test: fix Pi Calm, Pi branch, and remote-reply CI test flakes - #10

Merged
demy00 merged 2 commits into
mainfrom
feature/fm-ci-flakes-remote-reply-calm
Oct 8, 2026
Merged

demy00 merged 2 commits into
mainfrom
feature/fm-ci-flakes-remote-reply-calm

Conversation

@demy00

@demy00 demy00 commented Oct 8, 2026 •

Copy link
Copy Markdown
Owner

Intent

Two firstmate CI behavior tests fail intermittently or always, unrelated to the change on PR 9 (merge tool multi-waive): standing rule is to fix lint, test failures and test flakiness even when not caused by the current work.

  • tests/fm-calm-pi-extension.test.sh (job "Behavior portable serial 6"): failed twice on PR 9 run 37157270776 and is also red on main (run 36975878279). A recent fix (commit 1757302, "Pi Calm hidden-block geometry E2E did not complete the /reload viewport transition") tried to address it.
  • The fm-remote-reply NUL-byte capture timeout (job "Behavior portable serial 4"): failed once, passed on re-run.

What Changed

  • Pi export tests: fm-calm-pi-extension.test.sh and fm-pi-branch-extension.test.sh now pass the tool lookup to createToolHtmlRenderer as both getToolRenderers (the Pi 1.0.1 name) and getToolDefinition. They also count lookups and fail if the exporter never checked the registered tools, so the "renders nothing" assertions can no longer pass without testing anything.
  • Pi Calm test fixes:
    • The Chrome render-guard test now counts retries from the guard's own report instead of a counter written by the fake Chrome. On macOS, that counter could miss attempts.
    • The Calm hidden-block E2E sets tuiMode: "regular" so tmux scrollback still holds the restored rows. Pi 1.0.0 made the alternate-screen layout the default.
  • Remote-reply test: await_reply_result in fm-remote-reply.test.sh now checks listener ownership every 10 polls for the whole wait, not just once at the start. It restarts fm-procevent.sh start when no listener is live, with only one of its own starts running at a time. This covers the case where a listener exits as superseded just after the single check.

🤖 Generated with Claude Code

Risk Assessment

✅ Low: Test-only change: it fixes flaky or broken tests and touches no production code. I traced each new path and found no wrong result: the remote-reply restart guard, the render-guard report parsing, and the per-renderer export lookup counts all hold.

Testing

I ran the three changed test files against the latest Pi (1.1.0), installed in a temp prefix the same way CI installs it: - Pi branch extension: all tests pass, including the export-lookup guard. - Remote-reply: 5 consecutive runs all pass, including the NUL-byte capture case. No timeouts. - Calm Pi extension: passes up to the last step of its interactive E2E. That E2E now runs in regular TUI mode and passes until the Chrome export-render step. The render-guard test passes with its attempts now counted from the guard's own report. - Not run: the Chrome export-render step. Brave, the only Chromium browser on this host, cannot render headless in this sandbox. This branch changes only tests, so there is no UI. The artifacts are the test logs.

Evidence: Calm Pi extension test log against Pi 1.1.0

Source: Calm Pi extension test log against Pi 1.1.0

ok - Pi calm resolves its persistent home independently of Pi's launch directory
ok - Pi calm compatibility evidence never rejects a Pi version for being newer than 0.82.0, and still fails closed on a missing or malformed version
ok - a missing collapsed-thinking presentation API degrades only that Calm adapter with a clear skip reason, while the rest of Calm still registers
ok - missing Pi presentation class exports reach the independent adapter degradation path
ok - Calm hides queued Firstmate rows only on a session that can keep them, keeps hidden ones out of the editor on Escape, delivers them once in order, and leaves unsupported sessions and Calm off stock
ok - Calm registers none of its 7 built-in tool wrappers at load while config/calm is off, and all 7 synchronously at load while config/calm is on
ok - Calm's first same-session /calm activation claims every uncontested built-in, leaves a foreign bash tool fully intact and callable, warns prominently and logs the contested name, and only rows constructed before that activation - the documented bound - fail to retroactively collapse
ok - Pi calm centralizes transcript visibility, preserves execution/export data, keeps Pi's stock working row visible while no run is active, and persists its choice across session starts
ok - Pi calm on collapses mid-turn assistant working notes to zero height while Calm off keeps them, leaves streaming, truncated-final, and genuine final replies untouched, never mutates the messages, ignores every /calm argument, and restores a legacy persisted max as ordinary Calm on
ok - Pi operational follow-up E2E processes exact user-role notifications once while Calm hides current and adjacent rows, Calm off and absent render them, and restart preserves semantics
ok - Pi 1.1.0 with Calm on hides and retains queued Firstmate input through Escape, delivers it once, and leaves Calm off stock
ok - Pi Calm native /skill:ahoy geometry keeps every collapsed thinking and tool block at zero height while preserving expansion, history, restart, and Calm-off rendering
ok - Pi Calm working ship keeps its centered two-row asymmetric Unicode boat inside a deterministic long-wave trough, paints all water standard blue and the whole boat standard yellow with balanced resets, keeps ANSI-stripped width exact, reverses cleanly at both edges and every width, clamps visible and hidden resizes, falls back deterministically when narrow, freezes and resumes across settle/start without hidden-time jumps or duplicate timers, resets only on a fresh session, and leaves Calm-off visibility untouched
ok - the rendered-export-DOM guard renders in one pass, retries a bounded number of Chrome start-up failures, and reports the Chrome binary, Chrome version, Pi version, exit status, and Chrome diagnostic when every attempt fails
not ok - could not render calm-mode HTML export DOM: chrome=/Applications/Brave Browser.app/Contents/MacOS/Brave Browser chrome_version=Brave Browser 154.1.96.60  pi=1.1.0; attempt 1: exit=0 timed_out=yes bytes=0 stderr=.193648:ERROR:ui/display/mac/cv_display_link_mac.mm:188] CVDisplayLinkCreateWithCGDisplay failed. CVReturn: -6670 [54161:36731229:1008/115816.193835:ERROR:ui/display/mac/cv_display_link_mac.mm:188] CVDisplayLinkCreateWithCGDisplay failed. CVReturn: -6670 [54162:36731220:1008/115926.078839:ERROR:net/socket/ssl_client_socket_impl.cc:949] handshake failed; returned -1, SSL error code 1, net_error -3  attempt 2: exit=0 timed_out=yes bytes=0 stderr=5926.734584:ERROR:ui/display/mac/cv_display_link_mac.mm:188] CVDisplayLinkCreateWithCGDisplay failed. CVReturn: -6670 [66638:36748684:1008/115926.735168:ERROR:ui/display/mac/cv_display_link_mac.mm:188] CVDisplayLinkCreateWithCGDisplay failed. CVReturn: -6670 [66638:36748684:1008/115926.735282:ERROR:ui/display/mac/cv_display_link_mac.mm:188] CVDisplayLinkCreateWithCGDisplay failed. CVReturn: -6670  attempt 3: exit=0 timed_out=yes bytes=0 stderr=0037.737554:ERROR:ui/display/mac/cv_display_link_mac.mm:188] CVDisplayLinkCreateWithCGDisplay failed. CVReturn: -6670 [79380:36766319:1008/120037.737974:ERROR:ui/display/mac/cv_display_link_mac.mm:188] CVDisplayLinkCreateWithCGDisplay failed. CVReturn: -6670 [79380:36766319:1008/120037.739492:ERROR:ui/display/mac/cv_display_link_mac.mm:188] CVDisplayLinkCreateWithCGDisplay failed. CVReturn: -6670  
bash tests/fm-calm-pi-extension.test.sh  11.09s user 9.25s system 8% cpu 4:07.10 total
Evidence: Pi branch extension test log against Pi 1.1.0

Source: Pi branch extension test log against Pi 1.1.0

ok - fm_branch_outcomes and fm_branch_processed call headers match stock on Pi before and from 0.99
ok - fm_branch_outcomes hides through ToolExecutionComponent while Calm-off and HTML export stay stock
ok - the installed Pi still bounds the picker's list and ranks its search
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: Remote-reply test, 5 repeated runs

Source: Remote-reply test, 5 repeated runs

run 1 rc=0 157s 33 ok / 0 not ok run 2 rc=0 169s 33 ok / 0 not ok run 3 rc=0 172s 33 ok / 0 not ok run 4 rc=0 173s 33 ok / 0 not ok run 5 rc=0 172s 33 ok / 0 not ok

run 1 rc=0 157s 33 ok / 0 not ok
run 2 rc=0 169s 33 ok / 0 not ok
run 3 rc=0 172s 33 ok / 0 not ok
run 4 rc=0 173s 33 ok / 0 not ok
run 5 rc=0 172s 33 ok / 0 not ok
- Outcome: ⚠️ 1 warning across 1 run (21m44s)

Skills used

firstmate-coding-guidelines

Also tidied

  • test_export_dom_render_guard in tests/fm-calm-pi-extension.test.sh flaked on macOS: the never-finishing fake Chrome counted its own attempts, but each attempt is killed after three ticks and macOS spent 0.17-0.35s assessing the freshly written script before its first line ran. The hang case now reads the three attempts from the guard's own report, each required to be timed out.

Noticed

  • Other Pi-in-tmux E2Es in tests/fm-calm-pi-extension.test.sh (operational follow-up, queued-row Escape, hidden-block geometry) still run Pi in its 1.x fullscreen default rather than the regular layout Firstmate launches; they pass today.
  • tests/fm-remote-secondmate-trace-context.test.sh cleanup prints rm: cannot remove ... Permission denied in CI.
  • On a macOS host whose only bash is stock 3.2, five unchanged scripts fail in serial shards 3, 4 and 6 (fm-remote-herdr-guard, fm-afk-return, fm-backend, fm-watcher-lock, fm-calm-claude-mod); they pass on Linux CI.
  • Google Chrome for Testing 154 on macOS never finishes --dump-dom with a fresh --user-data-dir; chrome-headless-shell 154 renders the same export.

Better idea

The remote-reply handle replay could skip re-arming when the receipt already matches, so a manual replay never supersedes a live listener; the test would then not need to stand in for the watcher's restart.

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

⚠️ **Test** - 1 warning
  • ⚠️ tests/fm-calm-pi-extension.test.sh:4419 - I could not run the rendered-export-DOM step at the end of test_interactive_terminal_e2e locally. Google Chrome is not installed. The fallback, Brave 154 (passed via FM_CHROME_BIN), returns 0 bytes from --headless=new --dump-dom in this sandbox, even for a one-line HTML file. All 3 bounded attempts ended timed_out=yes with CVDisplayLinkCreateWithCGDisplay errors. render_export_dom itself is not changed by this branch. Everything in the interactive E2E before that step passed under the pinned tuiMode: "regular", including the /export completion. CI's Linux runner with Chrome is the remaining evidence for that one step. To check it locally, install Google Chrome or point FM_CHROME_BIN at a headless-capable Chromium.
  • Installed the latest @earendil-works/pi-coding-agent (1.1.0) into a temp global prefix /tmp/pi-g-5EMy, then pointed FM_PI_PACKAGE_DIR and PATH at it
  • FM_CHROME_BIN=<Brave> bash tests/fm-calm-pi-extension.test.sh: 14 of 15 tests pass against Pi 1.1.0. Passing: the HTML export stand-in with its lookup guard, the hidden-block geometry E2E, the rewritten export-DOM render-guard hang case, and the interactive E2E up to its Chrome render step
  • bash tests/fm-pi-branch-extension.test.sh: all 51 pass, including 'fm_branch_outcomes hides ... HTML export stay stock' with the per-renderer lookup guard
  • bash tests/fm-remote-reply.test.sh run 5 times in a row: 33/33 pass on every run, including 'NUL bytes are normalized in place before shell line processing'
  • Probed Brave headless --dump-dom on a trivial file to confirm the export-render failure is a host limitation
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

demy00 added 2 commits October 4, 2026 22:23
- Calm and branch export renderers: Pi 1.0.1 renamed the HTML exporter's
  lookup dependency from getToolDefinition to getToolRenderers, and the
  exporter swallows the TypeError a missing one raises. The stand-ins now pass
  the lookup under both names and count lookups, so the negative export
  assertions cannot pass vacuously.
- Calm interactive E2E: Pi 1.0.0 made the alternate-screen fullscreen layout
  the default, which keeps no tmux scrollback. The E2E now pins the regular
  layout Firstmate launches Pi in (fm-spawn's --tui-mode regular).
- Calm export-DOM render guard: the never-finishing fake Chrome counted its
  own attempts, but each attempt is killed after three ticks and macOS can
  spend that long assessing a freshly written script before its first line
  runs. The hang case now reads the attempts from the guard's own report.
- Remote reply: the manual handle replay re-arms the source, so a listener
  that adopted the previous registration exits as superseded at its next
  launch-floor check. The result wait now rechecks ownership for its whole
  duration and restarts the source the way the watcher's reconcile cycle does.
@demy00
demy00 merged commit bc3f178 into main Oct 8, 2026
20 of 21 checks passed
demy00 added a commit that referenced this pull request Oct 16, 2026
## Conflict resolutions

The trial merge listed 13 conflicted files; the actual merge also conflicts in `tests/fm-procevent.test.sh` (14 total).

| File | Fork origin | Resolution |
| --- | --- | --- |
| `.agents/skills/agent-skill-trigger-index/SKILL.md` | 09efd59 (#6, clickup-tickets) | Fork's `clickup-tickets` trigger line re-added to upstream's list unchanged. |
| `AGENTS.md` | 3843b2c (#8, skill selection); 89e1459 (#3, `feature/` prefix) | Fork's `fm-skill-select.sh --apply` line and the `feature/` default wording re-applied on upstream's new section 7 text (upstream added `--base-branch` and self-repo consent lines next to it; both kept). |
| `README.md` | 89e1459 (#3), via earlier fork syncs | Default ship-branch prefix wording stays `feature/` in upstream's rewritten bullet. |
| `bin/fm-captain-hold.sh` | 999f9d8 (#1, done-archive evidence) | Fork's done-archive lookup re-applied unchanged on upstream's version. |
| `bin/fm-dod-lib.sh` | 89e1459 (#3), 16cc4bd | Upstream's new base-branch/forge/consent code kept; its two `fm/$id` defaults now call `fm_task_branch` and the lib sources `fm-task-branch-lib.sh`, as the fork did before. |
| `bin/fm-procevent-lavish.sh` | 826e32b, 79d101b, d0ac8f4, cbfb295 (#7) | True clash, decided by the captain (option A) - see below. |
| `bin/fm-spawn.sh` | 89e1459 (#3), 16cc4bd, b7edc11, 153f4e2, de04c2d | Fork's `feature/` branch naming and legacy-brief branch binding re-applied unchanged on upstream's version. |
| `bin/fm-timeout-lib.sh` | 9e8b923 (bash without `BASHPID`) | Upstream fixed the same macOS bash 3.2 bug independently (5838f10, kunchenguid#6028, perl watchdog takes the pre-exec parent). Took upstream's code; the fork's regression test for it is kept and passes on upstream's fix. |
| `docs/architecture.md` | 89e1459 (#3) | `feature/` default and the `fm-task-branch-lib.sh` ownership line re-applied. |
| `tests/fm-brief.test.sh` | 89e1459 (#3), via earlier fork syncs | Expected branch names stay `feature/<id>` in upstream's updated cases. |
| `tests/fm-calm-pi-extension.test.sh` | bc3f178 (#10), 1757302 (#8 CI fix) | Upstream fixed the `/reload` geometry flake its own way (`wait_for_geometry_reload` on a durable status row), so the fork's `pipe-pane` version is dropped. Kept the fork's lookup-counting export renderer, the report-based Chrome hang attempt check, and the `tuiMode: regular` settings pin next to upstream's `--tui-mode regular` flag. |
| `tests/fm-procevent.test.sh` | #7 | Both test sets kept; see the Lavish decision. |
| `tests/fm-review-diff.test.sh` | 89e1459 (#3) | Fork's two unrecorded-`feature/` branch cases re-added; case letters shifted after upstream's new cases. |
| `tests/fm-timeout-lib.test.sh` | 9e8b923 | Fork's no-`BASHPID` test kept on top of upstream's tests. |

## Decision: Lavish list-form parser (captain chose option A)

Both sides fixed the same bug: Lavish emits queued feedback as a TOON list (not a table) when items carry nested content, and the adapter read it as an empty, complete result.

- Fork (#7): one parser that flattens and presents every nested field (table-cell `target:`, `attachments:`, other `fields:`, message uid/selector/text), adds `unpresented_items:`, and refuses `complete: yes` when nested content cannot be parsed.
- Upstream (fc8972c, kunchenguid#5404): one parser that skips nested targets and attachments; its tests assert nested content is absent from `read`. It also adds stricter refusals (unrecognized header keeps its declared count and counts as malformed; `answers`/`reconciles` exit 3 when not fully accounted for), and 228b27d renames the message count to `captain_message_count`.

Options:

- **A (chosen):** keep the fork's presenting parser, port upstream's strictness onto it (declared count + malformed on an unrecognized header, `answers`/`reconciles` exit 3, `captain_message_count`), keep both test sets, and adapt upstream's three "absent" assertions to check nested content appears only under its own labelled section and never replaces the item's own text.
  Cost: this region will likely conflict again on the next upstream sync.
- **B:** take upstream's parser and tests wholesale and drop the fork's nested presentation.
  Cost: Lavish reads lose table-cell location, text-selection range, and image attachment paths.
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