Skip to content

test: fix Claude session-start drain live E2E - #5165

Merged
kunchenguid merged 3 commits into
mainfrom
fm/sessionstart-drain-test-fix-r1
Sep 21, 2026
Merged

kunchenguid merged 3 commits into
mainfrom
fm/sessionstart-drain-test-fix-r1

Conversation

@kunchenguid

@kunchenguid kunchenguid commented Sep 21, 2026 •

Copy link
Copy Markdown
Owner

Intent

The captain authorized fixing the session-start drain-count live E2E test that a Discord contributor reported failing. The prior investigation found two independent test failures on current Firstmate: the tracked Claude SessionStart hook now runs the full session-start digest before the model's first turn, so the live test's manual bin/fm-session-start.sh prompt instruction causes a double startup drain; and the post-#4119 Stop auto-arm rewake contract requires state/.watcher-down, which the live test's fake fm-watch-arm.sh does not write, so no rewake is delivered. Keep the change strictly test-only with no product or behavior change. Update tests/fm-claude-stop-autoarm-live-e2e.test.sh so the fake arm writes pending:downtime:fixture-generation- to state/.watcher-down and touches state/.last-watcher-beat before actionable output, remove the manual session-start instruction, and verify observable run-tier evidence: no model fm-session-start.sh call, the transcript's SessionStart hook_response contains the SESSION START digest with stale-lock reclaim, and the stale lock is gone. Keep the drain expectation at 3 for one hook startup drain plus two wake drains, and count only real rewakes as user turns whose text starts with Stop hook feedback:. Preserve the live-harness opt-in guard and make the reproduced failure durable regression coverage. Update the test header and the maintainer records in docs/watcher-continuity.md and docs/verification/supervision.md with a dated live pass, including the Claude version, exact command, and exact ok output. Do not change bin/fm-claude-stop-autoarm.sh, .claude/settings.json, bin/fm-session-start.sh, or implement the optional shared-fixture follow-up.

What Changed

  • Update the Claude live E2E fixture to publish watcher downtime and beacon state, rely on the tracked SessionStart hook, and count only structured Stop-feedback rewakes.
  • Assert the hook response contains the complete startup digest and stale-lock reclaim without a model-issued session-start call, while preserving the three-drain expectation.
  • Refresh supervision and watcher-continuity records with the 2026-09-21 Claude Code 2.1.278 live pass.

Risk Assessment

✅ Low: The test-only change directly addresses both reproduced fixture failures, validates the SessionStart digest within the correct transcript event, and introduces no unnecessary behavior or product changes.

Testing

Confirmed the opt-in guard, then ran the credentialed Claude 2.1.278 E2E: the tracked SessionStart hook delivered a complete digest, reclaimed the stale lock without a model-issued session-start call, and produced three drains across two real Stop-feedback rewakes. The fixture-based competing-owner control also passed, though a second concurrent credentialed Claude owner was not run.

  • Live validation: ✅ go - 3 of 4 scenarios driven live against the product
Scenario Result Live Evidence
A credentialed fresh Claude session receives one complete SessionStart digest, reclaims the stale owner, removes the stale lock, and makes no model-issued fm-session-start.sh call ✅ pass live FM_CLAUDE_LIVE_E2E=1 tests/fm-claude-stop-autoarm-live-e2e.test.sh; artifact “Claude Stop auto-arm live E2E transcript”
The Stop-owned lifecycle performs one startup drain plus two wake drains, with rewakes counted only from user turns beginning with Stop hook feedback ✅ pass live The credentialed E2E asserted exactly three drains, at least two qualifying user-turn rewakes, two fixture reasons, no model arm command, and a rewake epoch; artifact “Claude Stop auto-arm live E2E tr…
Running the credentialed regression without explicit opt-in does not start Claude ✅ pass live tests/fm-claude-stop-autoarm-live-e2e.test.sh returned skip: live: opt-in; set FM_CLAUDE_LIVE_E2E=1 to run; artifact “Claude live-test opt-in guard output”
A competing live Claude session owner prevents lock replacement, arming, epoch creation, and rewake ⏸️ untested no A second concurrent credentialed Claude session was deliberately outside this validation scope. Provide authorization to spend another Claude session and a guarded concurrent-session procedure to driv…
Evidence: Claude Stop auto-arm live E2E transcript

Source: Claude Stop auto-arm live E2E transcript

$ claude --version
2.1.278 (Claude Code)
$ FM_CLAUDE_LIVE_E2E=1 tests/fm-claude-stop-autoarm-live-e2e.test.sh
ok - Claude 2.1.278 (Claude Code) live E2E reclaimed a stale session lock through session start, completed two tokenless Stop-owned rewake cycles, and preserved the competing-live-owner boundary
Evidence: Claude live-test opt-in guard output

Source: Claude live-test opt-in guard output

$ tests/fm-claude-stop-autoarm-live-e2e.test.sh
skip: live: opt-in; set FM_CLAUDE_LIVE_E2E=1 to run

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 - 3 of 4 scenarios driven live against the product
Scenario Result Live Evidence
A credentialed fresh Claude session receives one complete SessionStart digest, reclaims the stale owner, removes the stale lock, and makes no model-issued fm-session-start.sh call ✅ pass live FM_CLAUDE_LIVE_E2E=1 tests/fm-claude-stop-autoarm-live-e2e.test.sh; artifact “Claude Stop auto-arm live E2E transcript”
The Stop-owned lifecycle performs one startup drain plus two wake drains, with rewakes counted only from user turns beginning with Stop hook feedback ✅ pass live The credentialed E2E asserted exactly three drains, at least two qualifying user-turn rewakes, two fixture reasons, no model arm command, and a rewake epoch; artifact “Claude Stop auto-arm live E2E tr…
Running the credentialed regression without explicit opt-in does not start Claude ✅ pass live tests/fm-claude-stop-autoarm-live-e2e.test.sh returned skip: live: opt-in; set FM_CLAUDE_LIVE_E2E=1 to run; artifact “Claude live-test opt-in guard output”
A competing live Claude session owner prevents lock replacement, arming, epoch creation, and rewake ⏸️ untested no A second concurrent credentialed Claude session was deliberately outside this validation scope. Provide authorization to spend another Claude session and a guarded concurrent-session procedure to driv…
  • tests/fm-claude-stop-autoarm-live-e2e.test.sh
  • claude --version
  • FM_CLAUDE_LIVE_E2E=1 tests/fm-claude-stop-autoarm-live-e2e.test.sh
  • Verified transient .claude-autoarm-live-e2e.* lab cleanup and a clean worktree
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

## Validation Scope

The accepted-intent scenarios were driven live 5/5 across Claude Code 2.1.278 (three runs), 2.1.236, and 2.1.219, covering the complete SessionStart digest, stale-lock reclaim, the three-drain/two-rewake contract, genuine Stop-feedback turns, and no model arm or session-start commands.

The no-start behavior is structurally guaranteed by the fm_live_gate opt-in guard, which requires FM_CLAUDE_LIVE_E2E=1 or FM_LIVE=1 and capability-skips without launching Claude when neither is set.

The competing-live-owner scenario is deliberately out of scope for this test-only fix because this guard targets the run-tier auto-arm rewake cycle.
Any additional lock-contention live coverage should be a separate follow-up task.

@kunchenguid kunchenguid changed the title test: repair Claude Stop auto-arm live regression test: fix Claude session-start drain live E2E Sep 21, 2026
@kunchenguid kunchenguid reopened this Sep 21, 2026
@kunchenguid
kunchenguid merged commit aec043c into main Sep 21, 2026
39 of 40 checks passed
@kunchenguid
kunchenguid deleted the fm/sessionstart-drain-test-fix-r1 branch September 21, 2026 19:08
JuanJoseGonGi pushed a commit to JuanJoseGonGi/firstmate that referenced this pull request Sep 22, 2026
* test: repair Claude live auto-arm regression

* no-mistakes(review): Assert SessionStart digest completeness within its hook_response event

* no-mistakes(document): Consolidate Claude live verification references