test(otdd): contract test suite + agenda/executor-router/workers-ai fixes#76
Merged
Conversation
stackbilt-admin
pushed a commit
that referenced
this pull request
Jun 26, 2026
…t dedup - Remove undeclared groq → workers_ai fallback from EXECUTOR_ROUTES (dispatch never reads route.fallback; false resilience signal removed; wiring tracked in #75) - Guard placeholder routes in dispatch default branch before EXECUTOR_FNS lookup so cerebras_mid/reasoning produce a clear error rather than 'Unknown executor' - Catch resolveAgendaItem throw in handleInProcessTool's resolve_agenda_item branch so an already-resolved item returns an error string to the model instead of killing the tool-call loop - Isolate resolveAgendaItem in agenda-triage into its own try/catch so a DB failure after a successful createIssue doesn't leave the item active and trigger duplicate issue creation on the next cycle - Add two missing tests for resolveAgendaItem: AND status='active' SQL guard and throw-on-changes=0 coverage - Extract duplicated Ai.run() overload cast into callAiRun() helper Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contract ExecutorRouteShapeSchema declared isDefault as a valid field but the ExecutorRoute interface omitted it, causing TS2353 on the workers_ai route. Aligns interface with contract. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
CF Workers AI's Ai.run() overload union is too wide for direct casts. Wrap the call via an explicit function signature cast so TypeScript resolves a single unambiguous overload, then cast the return to AiChatResponse. Removes the previous as-Record<string,unknown> hack that still leaked the intersection mismatch. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The UPDATE had no status check, allowing done/dismissed items to be re-resolved or re-dismissed. Contract declares both as terminal with no outgoing transitions. Add AND status='active' to the WHERE clause and throw when 0 rows are affected (item missing or already terminal). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…, authority 48 tests derived from agenda-item.contract.ts. Covers all schema field constraints, all operation input schemas, valid/invalid state machine transitions (done/dismissed as terminals), the resolved_has_timestamp invariant, and authority rules per operation. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…s, authority 53 tests derived from cc-task.contract.ts. Covers all schema constraints, operation inputs, multi-source cancel transition (pending|running→cancelled), proposed_task_needs_approval and completed_has_timestamp invariants, and authority rules. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…authority 65 tests derived from goal.contract.ts. Covers schema constraints, all valid transitions including multi-source (active|paused→completed/failed), terminal state enforcement, the completed_has_timestamp invariant, and authority rules (terminal ops and recordRun are system-only). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
4 tests filling the only gaps in executor-router-semantic.test.ts: the negative cases for I1 (anthropic routes must have a fallback) and I2 (free-tier routes are terminal). I3–I6 violation paths were already covered. All six invariants now have both happy and violation coverage. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
33 tests derived from memory-entry.contract.ts. Covers CRIX validation pipeline transitions (candidate→validated→expert→canonical), refute terminal edges, refuted_entry_not_canonical and high_confidence_for_canonical invariants (including 0.9 boundary), terminal stage enforcement, and authority rules. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Appends the audit telemetry entry from the OTDD baseline governance check. Trailer coverage at 0% is the primary drag; pattern definitions and policy docs are at full score. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- CHANGELOG.md: add Unreleased entry for OTDD test suites and three bug fixes (executor-router interface, workers-ai cast, agenda terminal guard) - docs/architecture.md: add Contract Ontology section documenting all six .contract.ts files, their invariants, and the OTDD approach; notes #75 for runtime enforcement wiring - CONTRIBUTING.md: add OTDD section explaining how to write contract tests (schema, state machine, invariants, authority — no mocks) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…t dedup - Remove undeclared groq → workers_ai fallback from EXECUTOR_ROUTES (dispatch never reads route.fallback; false resilience signal removed; wiring tracked in #75) - Guard placeholder routes in dispatch default branch before EXECUTOR_FNS lookup so cerebras_mid/reasoning produce a clear error rather than 'Unknown executor' - Catch resolveAgendaItem throw in handleInProcessTool's resolve_agenda_item branch so an already-resolved item returns an error string to the model instead of killing the tool-call loop - Isolate resolveAgendaItem in agenda-triage into its own try/catch so a DB failure after a successful createIssue doesn't leave the item active and trigger duplicate issue creation on the next cycle - Add two missing tests for resolveAgendaItem: AND status='active' SQL guard and throw-on-changes=0 coverage - Extract duplicated Ai.run() overload cast into callAiRun() helper Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
agenda-triage: inner catch now attempts dismiss as a fallback sentinel
when resolveAgendaItem('done') fails after a successful createIssue,
preventing the item from staying active and generating a duplicate
GitHub issue on the next cron cycle.
dispatch: hoist placeholder guard before the switch so any future named
case for a placeholder executor cannot silently bypass the check.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ae4f1ef to
d004881
Compare
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.
Summary
AgendaItem,CcTask,Goal,ExecutorRoute, andMemoryEntry(1,121 lines of test coverage across five new test files)agenda.tsto guard terminal states inresolveAgendaItem(prevents illegal state transitions)executor-router.ts— add missingisDefaulttoExecutorRouteinterface (I5/I6 ordering)workers-ai-chat.ts— narrowAi.run()overload cast viaunknownto silence TS2769/TS2352 (also unblocks dependabot PR chore(ci): bump actions/checkout from 6 to 7 #70 which failed CI on this error)Relates to #75 (contract invariant enforcement — tests cover the invariant definitions; runtime wiring is tracked separately).
Test plan
npm run typecheck— cleannpm test— 82 files, 1767 passed, 1 skipped🤖 Generated with Claude Code