Repository navigation
feat(bin): emit hold, reply, and wake spans to complete return-path tracing - #6
Merged
Merged
Conversation
andrewesweet
force-pushed
the
fm/fm-trace-return-spans
branch
from
September 13, 2026 07:58
e9b1a7d to
78e0c6c
Compare
Complete the return path of the firstmate lifecycle span catalogue. firstmate.hold covers a held task's recorded hold-set time through its answer, release, or verified reconcile close, with the close mode and a bounded reason captured from the pre-close record. firstmate.reply joins the second mate agent's trace through the parent home's own meta, covering a delivered request's confirmed delivery through its correlated settlement, once per newly settled record. firstmate.wake covers a task-keyed queue row from its queue time through a successful acknowledgement, and never emits for heartbeats, per-poll checks, or rows whose key maps to no task. All three emit through the existing bounded best-effort OTLP emitter only when their settlement or acknowledgement durably succeeds, stay silent for untraced tasks and disabled homes, and can never change hold, settlement, or acknowledgement outcomes. Verified through the hold lifecycle, pending-reply, remote-reply, and wake-queue suites with a recording fake curl, including disabled-session and untraced-task omission.
…-transport-lanes.test.sh: the fixture copies a subset of bin/ into a remote-root, and bin/fm-pending-reply-lib.sh now sources fm-trace-span-lib.sh unconditionally (per the round-2 ruling removing the presence fallback), so the worker died with "fm-trace-span-lib.sh: No such file or directory". Fixed by adding fm-trace-span-lib.sh and its sibling deps fm-trace-context-lib.sh and fm-timing-lib.sh to the fixture copy list. Ran the test locally: ALL TESTS PASSED. Shellcheck clean (pre-existing SC1091 info only). "PR must be raised via no-mistakes" is an attestation head_sha mismatch (e9b1a7d vs 78e0c6c) caused by a later pipeline push; not a code defect, resolved by the outer executor's re-push
andrewesweet
force-pushed
the
fm/fm-trace-return-spans
branch
from
September 13, 2026 09:30
7dc62c9 to
4d09daf
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Implement PR 6 of the accepted Firstmate end-to-end tracing design to complete the return path: firstmate.hold spans cover recorded hold time through answer/release or verified reconciliation; firstmate.reply spans cover delivered secondmate requests through correlated reply settlement in the parent home; firstmate.wake spans cover task-keyed queued events through successful acknowledgement. Use the task or secondmate's existing trace as appropriate. Do not emit taskless heartbeats or per-poll activity. Reuse bounded best-effort OTLP emission under the existing default-off decision, and preserve hold/answer, reply-settlement and acknowledgement correctness. Ship only to andrewesweet/firstmate, never upstream.
What Changed
bin/fm-captain-hold.shemits afirstmate.holdspan after a successful answer, release, or reconcile close is durably published, covering the recorded hold-set time through the settlement withfirstmate.hold.close_modeand a boundedfirstmate.hold.reason;--origincalls join the origin task's trace and idempotent replays emit nothing.bin/fm-pending-reply-lib.shemits onefirstmate.replyspan per newly settled pending-reply record from the parent home's meta, covering the delivered epoch through settlement withfirstmate.corrandfirstmate.reply.via;bin/fm-wake-drain.shpartitions acknowledged rows in one awk pass, emits afirstmate.wakespan per consumed task-keyed row (kind, seq, key) after the acknowledgement commit, and captures a telemetry-onlystate/.wake-trace.<task>at presentation so tasks torn down before acknowledgement still get their span.bin/fm-trace-span-lib.shcatalogues the three new spans;AGENTS.md,docs/trace-context.md, anddocs/verification/trace-context.mddocument the wake capture and the new entries; tests added intests/fm-captain-hold-lifecycle.test.sh,tests/fm-pending-reply.test.sh,tests/fm-remote-reply.test.sh, andtests/fm-wake-queue.test.sh, and the remote transport lanes fixture now copies the trace span lib and its deps.Risk Assessment
✅ Low: Each new emission sits after its durable settlement or acknowledgement commit, always returns 0, is gated by the frozen session decision and a validated carrier, and the single-pass queue partition preserves the prior actor/cutoff/ownership predicate byte-for-byte; the only new state is the telemetry-only .wake-trace capture whose task name is validated by fm_wake_status_key_map and which acknowledgement discards, and every new test drives real entrypoints with a recording fake curl.
Testing
Ran the six suites the change touches (fm-trace-span-lib, fm-captain-hold-lifecycle, fm-pending-reply, fm-wake-queue, fm-remote-reply, fm-remote-transport-lanes): all pass once the session's leaked FM_* env vars are unset (fm-captain-hold-lifecycle's pre-existing secondmate teardown test fails identically on the base commit under that leaked FM_PUBLIC_FOLLOWUP_PRIMARY_HOME, so it is an environment artefact, not a regression). Then drove the product live against a real Python OTLP/HTTP receiver with real curl: wake presentation writes captures and posts nothing; acknowledgement posts exactly one firstmate.wake per task-keyed signal row (none for stale/check/heartbeat), both spans share one end instant, the torn-down task's span uses the capture, captures are discarded, replay posts nothing, an unreachable receiver and a disabled home change nothing; captain answer, origin-linked answer and --release each post one firstmate.hold on the right trace from the FM_CAPTAIN_HOLD_NOW stamp with close_mode and a 160-char-bounded reason, replay and refused answer post nothing; fm-send creates the pending record and the watcher tick settles the correlated reply posting one firstmate.reply from delivered_epoch with corr and via=status, replay nothing, receiver-down settlement still resolves. Reconcile close and the remote fake-SSH chain are covered by the passing suites rather than a separate live drive. No UI surface, so no screenshots.
bash tests/fm-wake-queue.test.shtest_wake_spans_survive_teardown_and_share_one_acknowledgement_instant (real drain executable, .wake-trace.kept.tmp as directory)bash tests/fm-captain-hold-lifecycle.test.shtest_close_paths_emit_hold_spans_over_the_recorded_hold_time (real hold/answer/reconcile entrypoints, real tasks-axi backend)bash tests/fm-remote-reply.test.sh(real fake-SSH chain, ALL TESTS PASSED)bash tests/fm-remote-transport-lanes.test.shALL TESTS PASSEDEvidence: Live wake + hold transcript (real drain/hold scripts, real curl, real OTLP receiver)
Source: Live wake + hold transcript (real drain/hold scripts, real curl, real OTLP receiver)
Evidence: OTLP requests received by the receiver during wake + hold scenarios (JSONL, one POST per line)
Source: OTLP requests received by the receiver during wake + hold scenarios (JSONL, one POST per line)
Evidence: Live reply transcript (fm-send, watcher tick settlement, real OTLP receiver)
Source: Live reply transcript (fm-send, watcher tick settlement, real OTLP receiver)
Evidence: OTLP requests received during reply scenario (steer span from send, reply span from settlement)
Source: OTLP requests received during reply scenario (steer span from send, reply span from settlement)
Evidence: Wake spans as received (one per task-keyed row, shared end instant, torn-down task on captured trace)
Evidence: Hold spans as received (answer, origin-linked answer, release; replay and refused answer posted nothing)
Evidence: Reply span as received after watcher-tick settlement
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.
bash tests/fm-wake-queue.test.shtest_wake_spans_survive_teardown_and_share_one_acknowledgement_instant (real drain executable, .wake-trace.kept.tmp as directory)bash tests/fm-captain-hold-lifecycle.test.shtest_close_paths_emit_hold_spans_over_the_recorded_hold_time (real hold/answer/reconcile entrypoints, real tasks-axi backend)bash tests/fm-remote-reply.test.sh(real fake-SSH chain, ALL TESTS PASSED)bash tests/fm-remote-transport-lanes.test.shALL TESTS PASSEDbash tests/fm-trace-span-lib.test.sh(10 ok)env -u FM_PUBLIC_FOLLOWUP_PRIMARY_HOME ... bash tests/fm-captain-hold-lifecycle.test.sh(51 ok, includes test_close_paths_emit_hold_spans_over_the_recorded_hold_time)bash tests/fm-pending-reply.test.sh(41 ok, includes test_settle_emits_parent_reply_span_once)bash tests/fm-wake-queue.test.sh(43 ok, includes both wake-span tests incl. unwritable-capture fail-open)bash tests/fm-remote-reply.test.sh(20 ok, remote settle emits from parent home)bash tests/fm-remote-transport-lanes.test.sh(12 ok, fixture lib copy fix)Live:/tmp/nm-live/drive.sh— real fm-wake-drain.sh presentation +--ack-through+ replay, real fm-captain-hold.sh hold/answer/--origin/--release/replay/refused, real curl to python OTLP receiver on 127.0.0.1:43181; receiver-down and session-off variantsLive:/tmp/nm-live/drive-reply.sh— real fm-send.sh marked secondmate send (tmux stubbed as transport), correlated status reply,fm_pending_reply_ticksettlement, replay, receiver-down; real curl to OTLP receiver on 127.0.0.1:43182Base-commit comparison of fm-captain-hold-lifecycle under leaked env (fails identically at 8c1a640) to classify the env failure✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.