Skip to content

fix: derive Lavish polling route from board session - #5334

Merged
kunchenguid merged 3 commits into
mainfrom
fm/lavish-session-derived-r1
Sep 22, 2026
Merged

kunchenguid merged 3 commits into
mainfrom
fm/lavish-session-derived-r1

Conversation

@kunchenguid

Copy link
Copy Markdown
Owner

Intent

A worker-hosted Lavish board showed Working while the worker was not working, and the agent reply did not appear until a manual refresh. Fix that durably. The live board is http://127.0.0.1:4387/session/63f385f41cd6a0bf. Do not answer it, do not send marks, and do not end that session.

After eight review fix rounds each adding guards around a stored-and-guarded session URL, the choice was B: stop and step back. Have the worker look for a simpler design, for example have the poll always derive the server from the board's own session instead of storing and guarding an address. Then revalidate from scratch.

What Changed

  • Resolve each Lavish poll attempt’s host and port from the board’s saved session URL instead of ambient or configured routing.
  • Refuse missing, malformed, or ambiguous session evidence before consuming a staged worker reply.
  • Update documentation and regression coverage for session-derived routing, retries, endpoint changes, Unicode paths, hostnames, and IPv6.

Risk Assessment

✅ Low: The change is well-bounded, derives each poll endpoint from validated board-session state, preserves staged replies on routing failure, and adds behavior-level regression coverage for direct, retried, and recovered polling paths.

Testing

Targeted process-event and Bearings tests passed; real Lavish/Chrome validation showed a worker reply immediately on the saved board session despite conflicting ambient and configured endpoints, returned browser feedback to the worker inbox, and failed safely when session evidence was missing. The first live Bearings run exposed a teardown race, which was fixed and passed on rerun. The protected user session at port 4387 was not touched.

  • Live validation: ✅ go - 5 of 5 scenarios driven live against the product
Scenario Result Live Evidence
A worker-owned listener started under conflicting ambient and configured addresses posts its reply to the board's saved session ✅ pass live Recovered worker reply screenshot and recovered-worker-routing-transcript.txt: saved endpoint was 127.0.0.1:14387 while arm, start, and config named three different endpoints.
The agent reply appears on the live board without a manual refresh or stale Working indicator ✅ pass live recovered-worker-session-routing.png visibly shows the reply in Conversation with no Working status.
Feedback sent from the real board returns through the listener and reaches the owning worker inbox ✅ pass live recovered-worker-routing-transcript.txt records feedback status, message, and worker_inbox=delivered.
Missing session routing refuses rather than falling back to an ambient server or consuming the worker reply ✅ pass live missing-session-refusal.txt records exit 1 and the unchanged staged reply.
Bearings establishes and recovers a real Lavish session before leaving its listener armed ✅ pass live bearings-live-transcript.txt shows the captain-ended session detection and successful real-session reopen on lavish-axi 0.1.77.

Recovered worker reply visible immediately on the correct Lavish board

Evidence: Worker routing and round-trip transcript

Source: Worker routing and round-trip transcript

opened_session_url=http://127.0.0.1:14387/session/0663a62bda756cc7
arm_environment=arming.invalid:24387
recovered_start_environment=recovery.invalid:34387
configured_host=wrong-config.example
browser_agent_reply=Recovered listener reply reached the saved board session.
captured_feedback_status=feedback
captured_feedback_message="",worker route confirmed,"",message,Freeform message
worker_inbox=delivered
Evidence: Missing-session fail-closed transcript

Source: Missing-session fail-closed transcript

command_exit=1
reply_after_refusal=must survive routing refusal
diagnostic=cannot read Lavish session store error: cannot resolve the board server from its Lavish session: ~/.no-mistakes/worktrees/016d88035d58/01M35EH1NCXEA79CWD6PZ1APX0/.live-routing/worker-board.html 
Evidence: Real Lavish Bearings lifecycle transcript

Source: Real Lavish Bearings lifecycle transcript

FM_TEST_BEGIN 2026-09-22T21:12:04Z tests/fm-bearings-board-lavish-live-e2e.test.sh family=live-harness-optin expected_gate_skip=live-capability
# lavish-axi 0.1.77
ok - lavish-axi 0.1.77 reports a captain-ended session without reopening it and without failing
ok - the board build reopens a captain-ended session against real lavish-axi instead of arming a dead one
FM_TEST_END 2026-09-22T21:12:27Z tests/fm-bearings-board-lavish-live-e2e.test.sh exit=0 duration_ms=22544 gate_skip=false
FM_TEST_SUMMARY total=1 failed=0 skipped_gate=0 duration_ms=22610
FM_TEST_SUMMARY_FAMILY family=live-harness-optin count=1 duration_ms=22544 failed=0
FM_TEST_SLOWEST rank=1 script=tests/fm-bearings-board-lavish-live-e2e.test.sh duration_ms=22544

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 5 of 5 scenarios driven live against the product
Scenario Result Live Evidence
A worker-owned listener started under conflicting ambient and configured addresses posts its reply to the board's saved session ✅ pass live Recovered worker reply screenshot and recovered-worker-routing-transcript.txt: saved endpoint was 127.0.0.1:14387 while arm, start, and config named three different endpoints.
The agent reply appears on the live board without a manual refresh or stale Working indicator ✅ pass live recovered-worker-session-routing.png visibly shows the reply in Conversation with no Working status.
Feedback sent from the real board returns through the listener and reaches the owning worker inbox ✅ pass live recovered-worker-routing-transcript.txt records feedback status, message, and worker_inbox=delivered.
Missing session routing refuses rather than falling back to an ambient server or consuming the worker reply ✅ pass live missing-session-refusal.txt records exit 1 and the unchanged staged reply.
Bearings establishes and recovers a real Lavish session before leaving its listener armed ✅ pass live bearings-live-transcript.txt shows the captain-ended session detection and successful real-session reopen on lavish-axi 0.1.77.
  • bin/fm-test-run.sh tests/fm-procevent.test.sh
  • bin/fm-test-run.sh tests/fm-bearings-board.test.sh
  • HOME="$PWD/.test-live-home" FM_BEARINGS_LAVISH_LIVE=1 bin/fm-test-run.sh tests/fm-bearings-board-lavish-live-e2e.test.sh
  • Opened an isolated real Lavish 0.1.77 board on port 14387, armed a worker-owned source under conflicting configuration, started it under recovery.invalid:34387, and drove feedback through Chrome
  • Ran bin/fm-procevent-lavish.sh poll with a missing isolated session store and confirmed it refused before consuming the staged reply
  • Ended both isolated Lavish sessions, swept the worker source, stopped the isolated server/browser, and removed transient worktree data
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@kunchenguid
kunchenguid merged commit 884d76b into main Sep 22, 2026
19 checks passed
@kunchenguid
kunchenguid deleted the fm/lavish-session-derived-r1 branch September 22, 2026 21:42
RajeshRajendiran added a commit to RajeshRajendiran/firstmate that referenced this pull request Sep 23, 2026
…store entry

Found the actual root cause behind "Behavior portable serial 5"
repeatedly failing on tests/fm-bearings-board-render.test.sh with
"source ... is not listening after reconcile (observed owner: none)".

The prior round's fix (widening await_source_owner's poll budget from
5s to 10s) treated this as generic scheduler flakiness, but the poll
budget was never the bottleneck. The upstream-synced commit that
reworked fm-procevent-lavish.sh's host resolution (kunchenguid#5334) made
cmd_poll resolve its server address from Lavish's own session store
(LAVISH_AXI_STATE_DIR/state.json) before it can do anything else. This
render test's fake lavish-axi never wrote that store, so every armed
listener now dies instantly instead of reaching the stub's blocking
`poll` case - collapsing what used to be a long, stable "live" claim
into a race decided by whether await_source_owner's poll happened to
land inside a millisecond-scale window. Under CI's scheduler this
essentially never won; locally it was fast enough to usually win,
which is why it never reproduced there.

Fixed by having the fake lavish-axi write a matching session-store
entry when it "opens" a board, the same way tests/fm-bearings-board.test.sh
already does for the same reason. The listener now reaches its
intended blocking poll and stays live, so reverted the unrelated
poll-budget widening back to its original 50 iterations.