h5p: Add Vitest test harness (63 tests)#21
Open
rjcorwin wants to merge 4 commits into
Open
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add poolFactory? to ExecutionContext for TestRunner injection - Export parseRalphVerdict for direct unit testing - Replace 7 createRunnerPool call sites with (ctx.poolFactory ?? createRunnerPool) - Add src/testing/test-runner.ts with TestRunner, makeTestPool, testPoolFactory - Add vitest.config.ts and "test": "vitest run" script - Write parser, loop, executor, race, template test files Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Full RPI cycle complete. Infrastructure is solid and non-invasive. Coverage is honest v1 — the harness exists and adding tests is now friction-free, but the original goal of full SPEC.md surface isn't there yet.
Status
63 tests passing across 5 files.
npm testruns in ~300ms with no real LLM calls, no Docker.npm run buildpasses with no TypeScript errors.What changed
src/executor.ts—ExecutionContextgains one optional field:Seven
createRunnerPool(...)calls replaced with(ctx.poolFactory ?? createRunnerPool)(...).parseRalphVerdictexported. In production nothing changes — the field is absent and behavior is identical.src/testing/test-runner.ts—TestRunner(queue-drivenAgentRunner),makeTestPool,testPoolFactoryhelpers.vitest.config.ts+"test": "vitest run"in package.json.Five test files covering: all AST node types and flags (parser),
parseGateVerdicttable tests and fullagentLooploop (loop),parseRalphVerdictdirect + executor integration with mocked Ink (executor),parseJudgeVerdict/buildJudgePrompt/sessionId(race),renderTemplate/loadCookMD(template).Architecture
graph TD A[ExecutionContext.poolFactory?] -->|set in tests| B[TestRunner — queue-driven mock] A -->|absent in production| C[createRunnerPool → NativeRunner / Docker / BareRunner] B --> D[responses queue controls LLM output in tests] E[execute / agentLoop] --> AKey decisions
poolFactoryonExecutionContextovervi.mockor a fake CLI binary — explicit, typed, propagates through all execution paths including composition branches.vi.mock('ink', ...)in executor.test.ts — every path touching a work or review node calls Ink'srender(); mocked to no-op to prevent TTY noise or hangs.Bug surfaced
parseRalphVerdict/APPROVEinconsistency.parseGateVerdictexplicitly handlesAPPROVEas a DONE keyword.parseRalphVerdictdoes not —RALPH_DONE_KEYWORDSis['DONE', 'COMPLETE', 'FINISHED']. Passing'APPROVE'toparseRalphVerdictreturns'DONE'via the fail-safe default (no keyword matched), not explicit handling. The behaviour is correct today but the two functions are inconsistent. If logic is ever reordered,APPROVEthrough ralph breaks silently. Tracked in TODO.md.Coverage gaps (not blocking merge, but honest accounting)
v3,compare,vswith review branches, nested operators (work x3 review v2 pick). The parser handles all of this — none of it is tested.agentLoopwithiteratePrompt— wheni > 1 && config.iteratePrompt, the loop uses the 'iterate' step instead of 'work'. Code path not exercised.agentLooperror handling — whenrunner.runAgentthrows, the loop catches and returns{ verdict: 'ITERATE' }. Not tested.executeReviewwith compound inner — the branch whereinner.type !== 'work'(e.g. repeat-then-review) is untested. Only the simpleinner.type === 'work'path is covered.Deferred (see TODO.md)
resolvePick/resolveMerge/resolveCompare)App.tsx,RaceApp.tsx,LogStream.tsx)loopEventssingleton refactor to injected EventEmitterTesting instructions
🤖 Generated with Claude Code