Skip to content
This repository was archived by the owner on Aug 25, 2026. It is now read-only.

test: use event-driven AFK injection waits - #33

Merged
JTInventory merged 4 commits into
mainfrom
fm/firstmate-behavior-test-runtime-fix-0701
Jul 1, 2026
Merged

JTInventory merged 4 commits into
mainfrom
fm/firstmate-behavior-test-runtime-fix-0701

Conversation

@JTInventory

Copy link
Copy Markdown
Owner

Intent

Reduce Firstmate behavior-test runtime without weakening assertions or gates by replacing fixed afk injection sleeps with bounded event-driven waits

What Changed

  • Captain, replaced fixed AFK injection sleeps with bounded polling helpers that wait for the specific daemon/log state and print focused diagnostics on timeout.
  • Added stable event waits for swallowed-Enter and digest delivery paths so the e2e verifies one clean digest and an empty escalation buffer after delivery.
  • Updated CONTRIBUTING.md to describe the AFK injection e2e as event-driven single-digest coverage.

Risk Assessment

✅ Low: Captain, the change is limited to one AFK e2e test file and the event-driven waits preserve the original assertions while adding a stability window for duplicate detection.

Testing

The configured full-suite baseline was already green; I then reran the focused AFK injection e2e with tmux 3.4, verified the PR target guard, captured reviewer-visible CLI evidence for all three AFK injection scenarios, and recorded that the target event-driven run finished in 19.88s versus the base test's 26s fixed-sleep floor.

Evidence: AFK injection e2e transcript
cwd: /root/.no-mistakes/worktrees/76db9585a6d5/01KWF2MXFAGQAESNS0PV539AGE
head: bc82f3499ad7ccdd700445672b244da5482925f7
branch: ## HEAD (no branch)
tmux: tmux 3.4
command: bash tests/fm-afk-inject-e2e.test.sh
ok - Scenario A: partial input defers injection; digest arrives clean after idle
ok - Scenario B: swallowed Enter produces exactly one clean digest
ok - Scenario C: a normal captain status injects exactly one clean single-line sentinel digest
all e2e injection tests passed
real 19.88
user 0.77
sys 1.51
Evidence: AFK runtime evidence
intent: Reduce Firstmate behavior-test runtime without weakening AFK injection assertions or gates by replacing fixed sleeps with bounded event-driven waits.

target_e2e_runtime:
command: bash tests/fm-afk-inject-e2e.test.sh
ok - Scenario A: partial input defers injection; digest arrives clean after idle
ok - Scenario B: swallowed Enter produces exactly one clean digest
ok - Scenario C: a normal captain status injects exactly one clean single-line sentinel digest
all e2e injection tests passed
real 19.88

base_fixed_sleep_floor:
254:  sleep 6
272:  sleep 6
324:  sleep 8
371:  sleep 6
sum: 6 + 6 + 8 + 6 = 26 seconds before setup/teardown

target_event_waits:
345:  wait_for_event "Scenario A pending-input defer" 60 scenario_a_deferred_with_pending_input
363:  wait_for_event "Scenario A digest after idle" 60 scenario_a_delivered_after_idle
415:  wait_for_stable_event "Scenario B one digest after swallowed Enter" 90 12 scenario_b_delivered_once_after_swallowed_enter
462:  wait_for_stable_event "Scenario C one digest" 70 12 scenario_c_delivered_once

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 1 issue found → auto-fixed (2) ✅
  • ⚠️ tests/fm-afk-inject-e2e.test.sh:259 - Captain, this wait now returns as soon as one digest is logged and the buffer is empty. The exact-count assertion runs immediately after, so a duplicate emitted on the next watcher or housekeeping cycle can arrive after the test already passed. Keep the event-driven wait, but add a short stability check that requires exactly one digest for at least one poll cycle after first delivery.

🔧 Fix: Stabilize AFK duplicate waits
1 warning still open:

  • ⚠️ tests/fm-afk-inject-e2e.test.sh:408 - Captain, the stability window is counted inside the overall timeout, so Scenario B only allows the digest to first appear by about 7.8s even though the old fixed wait allowed about 8s before asserting. Increase the timeout by at least stable_ticks or change wait_for_stable_event so the stability clock starts after first success; otherwise this can add CI flake while trying to make the test more event-driven.

🔧 Fix: Captain, stabilize AFK wait clocks
✅ Re-checked - no issues remain.

✅ **Test** - passed

✅ No issues found.

  • bash bin/fm-no-mistakes-pr-target-guard.sh || exit 1; command -v tmux >/dev/null || { echo "tmux is required for e2e tests" >&2; exit 1; }; tmux -V; rc=0; for t in tests/*.test.sh; do echo "== $t =="; bash "$t" || rc=1; done; exit "$rc"
  • Provided baseline already passed: bash bin/fm-no-mistakes-pr-target-guard.sh || exit 1; command -v tmux >/dev/null || { echo "tmux is required for e2e tests" >&2; exit 1; }; tmux -V; rc=0; for t in tests/*.test.sh; do echo "== $t =="; bash "$t" || rc=1; done; exit "$rc".
  • /usr/bin/time -p bash tests/fm-afk-inject-e2e.test.sh with transcript captured to /tmp/no-mistakes-evidence/01KWF2MXFAGQAESNS0PV539AGE/fm-afk-inject-e2e-transcript.txt.
  • command -v tmux && tmux -V && bash bin/fm-no-mistakes-pr-target-guard.sh.
  • Compared target event-driven waits against base fixed sleeps with git show 528ca21e3fc540cfbff6849eff8385bde8f878ee:tests/fm-afk-inject-e2e.test.sh | grep -n "sleep 6\|sleep 8" and grep -n "wait_for_event \|wait_for_stable_event " tests/fm-afk-inject-e2e.test.sh, recorded in /tmp/no-mistakes-evidence/01KWF2MXFAGQAESNS0PV539AGE/afk-runtime-evidence.txt.
  • git status --short --ignored=no confirmed no working-tree artifacts were left behind.
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@JTInventory
JTInventory merged commit 746c596 into main Jul 1, 2026
4 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant