Skip to content

feat(triggers): confirm a trigger stop with a configured final check - #1405

Open
jbr-sekoia wants to merge 3 commits into
mainfrom
feat/trigger-stop-final-check
Open

jbr-sekoia wants to merge 3 commits into
mainfrom
feat/trigger-stop-final-check

Conversation

@jbr-sekoia

@jbr-sekoia jbr-sekoia commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

A versioned stop trigger can now ask Switchboard to confirm, just before it ends the session, that the session's resume note is committed and its last turn is finished. The trigger carries only "finalCheck":{"notePath":"<absolute path>"}; the check itself is a command the user configures in the new global setting stopCheckCommand (an argv array, default null). Trigger files can never supply arguments or an executable.

stop trigger with finalCheck
  └─ before delivery (unchanged) → final idle + composer check (unchanged)
       └─ <stopCheckCommand> --sample-final --session-id <id> --note <path>     → {noteCommit, transcriptTurn}
            └─ <stopCheckCommand> --check-final … --expected-note-commit <hex40> --expected-transcript-turn <hex64>
                 └─ synchronous recheck: target, idle, composer, deadline → one deps.stop
Outcome Result reason Stop requested
check exits 0, recheck passes (existing success) yes
check exits 1 stop check refused (first stdout line in detail) no
exit 3 / other code / malformed sample stop check failed no
deadline passes stop check timed out no
setting unset or invalid, spawn error stop check unavailable no

None of these outcomes sets uncertain, and completed before delivery evidence is kept on refusal. A stop without finalCheck takes exactly the current path. On POSIX the check runs in its own process group, killed at the deadline or on output overflow; the result waits for the child's close within a 500 ms grace period.

scripts/assert-named-test.cjs runs one named node:test test and fails when no executed test matches (a bare --test-name-pattern that matches nothing exits 0); it backs the acceptance commands of this change and lives outside scripts/run-tests.js selection.

Consumer of this contract: JBR's session life-cycle harness (lifecycle_stop.py --sample-final/--check-final), which will only send finalCheck once a Switchboard release carries this change.

Docs

  • User: docs/automation.md (new section "Stop final check": stop request finalCheck, stopCheckCommand, the two argv forms, result reasons, Windows limits); docs/settings.md (stopCheckCommand among the settings no field sets)
  • Agent: .ai/contexts/trigger-watcher.md (trigger-actions entry)

Changelog

Entry under ## Unreleased → ### New.

Tests

  • node --test test/trigger-actions-stop.test.js test/trigger-actions-schema.test.js test/setting-defaults.test.js: 189 pass, 0 fail (Node 22, Linux).
  • 13 named acceptance commands (12 from the contract plus final check overflow keeps its reason past the deadline) node scripts/assert-named-test.cjs '<name>' <file>: all PASS; the timeout control (ASSERT_NAMED_TEST_TIMEOUT_MS=2000 … 'blocked' test/fixtures/assert-named-test-blocked.cjs) exits 1 with FAIL blocked timed out; the missing-name guard passes.
  • task check at c1b1ed68 (Linux, Node 22, LANG=C): exit 0, 14 972 + 495 tests pass, lint 0 errors.
  • Not verified: Windows (direct-child termination only, documented), Electron end to end.

Implemented with Codex; four adversarial review rounds (Codex) until no finding remained, each fix proved by a mutation that turns its test red.

🤖 Generated with Claude Code

A versioned stop trigger may carry finalCheck.notePath. Switchboard then
runs the global stopCheckCommand argv twice, --sample-final then
--check-final with the sampled evidence, rechecks target, idle state,
composer and deadline, and only then stops the session. A refusal, an
error, a timeout or a missing command returns its own result reason and
requests no stop; a stop without finalCheck keeps its current path. The
check's process group is killed at the deadline or on output overflow,
and the result waits for its close within a 500 ms grace period.

scripts/assert-named-test.cjs runs one named node:test test and fails
when no executed test matches, for the acceptance commands of this change.

Implemented with Codex, reviewed adversarially until no finding remained.
The global setting a stop trigger with finalCheck runs is listed with the
settings no field sets, and links to the new "Stop final check" section
of the automation guide.
@jbr-sekoia
jbr-sekoia requested a review from devsuitup December 2, 2026 12:35
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