test(terminal): add direct coverage for session state machine and auto-restart cap - #560
Open
Atman36 wants to merge 1 commit into
Open
test(terminal): add direct coverage for session state machine and auto-restart cap#560Atman36 wants to merge 1 commit into
Atman36 wants to merge 1 commit into
Conversation
…o-restart cap reduceSessionTransition had zero dedicated tests despite being the single reducer mapping process exit/hook events to reviewReason/state that issues cline#524 and cline#105 hinge on. Also exercise the MAX_AUTO_RESTARTS_PER_WINDOW boundary (the "stuck retry" scenario from cline#105) so both mechanisms have a documented, reviewable spec. No behavior changes.
|
PR author is not in the allowed authors list. |
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.
Why
reduceSessionTransition(src/terminal/session-state-machine.ts) is the single reducer that maps process/hook events toreviewReason+ session state — the chain that decides whether a finished run waits for review. It currently has no dedicated test file (it is only exercised indirectly throughsession-managermocks). Likewise, the PTY auto-restart cap (MAX_AUTO_RESTARTS_PER_WINDOW) is never exercised at its boundary — the "stuck retrying" scenario from #105.This PR adds tests only — zero behavior changes — to lock in the current contract of that state chain (context: #524 and #105 both hinge on it).
What's covered
test/runtime/terminal/session-state-machine.test.ts(15 tests): every switch case ofreduceSessionTransitionincl.default,process.exitwith exit 0 →reviewReason: "exit", nonzero →"error",nullexit code →"error", interrupted flag →"interrupted"+ state"interrupted", pid clearing, and thecanReturnToRunningvalue branch (reviewReason: "error"is resumable back torunning).session-manager-auto-restart.test.ts(append-only): cap boundary — 3 qualifying exits within the 5s window restart, the 4th is refused.Verification
npm run checkfully green (biome, typecheck, full root suite — 60 files / 597 tests);npm run buildexit 0; nosrc/changes in the diff.