Skip to content

test(otdd): contract test suite + agenda/executor-router/workers-ai fixes#76

Merged
stackbilt-admin merged 13 commits into
mainfrom
auto/feature/issue-72
Jun 26, 2026
Merged

test(otdd): contract test suite + agenda/executor-router/workers-ai fixes#76
stackbilt-admin merged 13 commits into
mainfrom
auto/feature/issue-72

Conversation

@stackbilt-admin

Copy link
Copy Markdown
Member

Summary

  • Add OTDD contract test suite covering all five core entity types: AgendaItem, CcTask, Goal, ExecutorRoute, and MemoryEntry (1,121 lines of test coverage across five new test files)
  • Fix agenda.ts to guard terminal states in resolveAgendaItem (prevents illegal state transitions)
  • Fix executor-router.ts — add missing isDefault to ExecutorRoute interface (I5/I6 ordering)
  • Fix workers-ai-chat.ts — narrow Ai.run() overload cast via unknown to silence TS2769/TS2352 (also unblocks dependabot PR chore(ci): bump actions/checkout from 6 to 7 #70 which failed CI on this error)
  • Add OTDD contract ontology docs and update CHANGELOG/CONTRIBUTING

Relates to #75 (contract invariant enforcement — tests cover the invariant definitions; runtime wiring is tracked separately).

Test plan

  • npm run typecheck — clean
  • npm test — 82 files, 1767 passed, 1 skipped
  • All five new contract test files exercise schema validation, state machine transitions, invariants, and authority rules

🤖 Generated with Claude Code

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>
Aegis and others added 13 commits June 26, 2026 04:49
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>
@stackbilt-admin stackbilt-admin force-pushed the auto/feature/issue-72 branch from ae4f1ef to d004881 Compare June 26, 2026 09:49
@stackbilt-admin stackbilt-admin merged commit bf809e9 into main Jun 26, 2026
2 checks passed
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