Skip to content

Simplify dispatch: agent-bound bus writer, plain JudgeDecision, no stray exports - #19

Merged
Tyler-R-Kendrick merged 1 commit into
mainfrom
claude/dispatch-ts-refactor-w7g40r
Jul 12, 2026
Merged

Simplify dispatch: agent-bound bus writer, plain JudgeDecision, no stray exports#19
Tyler-R-Kendrick merged 1 commit into
mainfrom
claude/dispatch-ts-refactor-w7g40r

Conversation

@Tyler-R-Kendrick

@Tyler-R-Kendrick Tyler-R-Kendrick commented Jul 12, 2026

Copy link
Copy Markdown
Owner

Cleans up the weirdness in packages/harness/src/dispatch.ts and the call sites around it.

What changed

Verbose bus.append → agent-bound writer. WriteAheadAgentBus.agent(actor) now returns a writer bound to one actor — write(kind, payload?) — so the write-ahead convention no longer restates { actor, kind, ...(payload === undefined ? {} : { payload }) } at every append. dispatchAction binds the acting agent once and every intent/failure/completion record flows through it. The bus still knows nothing about any actor; the writer is just currying.

judgeDecision.parse removed. Gates and judges are typed to return JudgeDecision, and every producer is under our control, so re-parsing their output bought nothing. JudgeDecision is now a plain "pass" | "fail" union defined next to ActionGate in dispatch.ts; the judgeDecision zod enum is deleted from schema.ts entirely.

Hard-coded strings named once. The "judge" actor and "agent.decision" kind are module-private constants behind a new recordDecision(bus, payload) helper, used by both dispatchAction and the harness's decide. The harness's actor names (student/teacher/adversary) and message kinds (agent.propose, agent.assess, agent.challenge, agent.revise-rubric) are likewise spelled once in as const tables. They stay strings rather than Symbol(...) because bus entries are serialized to storage — a symbol would not survive the round trip.

Stray exports trimmed. decisionKind is no longer exported (from dispatch.ts or the package index), the redundant export type { JudgeDecision } re-export in dispatch.ts is gone, and the judgeDecision zod value export is removed from the index. The new AgentWriter type is exported alongside the bus.

Verification

npm run check (typecheck of all packages, full test suite, core build) passes: 15 test files, 82 tests, including a new test covering the bound agent writer. src/providers/harness.ts, which imports type JudgeDecision from the package, still typechecks against the relocated type.

🤖 Generated with Claude Code

https://claude.ai/code/session_01BqYWeURqZQYQUKs7tqvEfA


Generated by Claude Code

Summary by CodeRabbit

  • New Features

    • Added actor-bound message writers for simpler, consistent event recording.
    • Added helpers for recording judge decisions and action outcomes.
    • Improved harness handling of judge verdicts and contextual decisions.
  • Documentation

    • Expanded message bus documentation with method-by-method API details.
  • Tests

    • Added coverage for actor-bound writers with and without payloads.

…named well-known strings

- WriteAheadAgentBus.agent(actor) returns a writer bound to one actor, so
  the write-ahead convention no longer restates { actor, kind, payload }
  at every append.
- JudgeDecision is now a plain union type on dispatch.ts; the judgeDecision
  zod enum and its .parse calls are gone — gates and judges are typed
  against the union, so their outputs are used as returned.
- The judge actor and agent.decision kind are module-private constants
  behind a recordDecision helper; decisionKind is no longer part of the
  public API. Harness actor/kind strings are likewise named once. They
  stay strings (not symbols) because bus entries are serialized to storage.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BqYWeURqZQYQUKs7tqvEfA
@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 9948ba49-faca-4849-bcd1-50f42863aafd

📥 Commits

Reviewing files that changed from the base of the PR and between 2920e87 and d73d51f.

📒 Files selected for processing (7)
  • packages/harness/README.md
  • packages/harness/src/bus.ts
  • packages/harness/src/dispatch.ts
  • packages/harness/src/harness.ts
  • packages/harness/src/index.ts
  • packages/harness/src/schema.ts
  • packages/harness/test/harness.test.ts
💤 Files with no reviewable changes (1)
  • packages/harness/src/schema.ts

📝 Walkthrough

Walkthrough

The harness adds actor-bound bus writers, centralizes judge decision recording, removes the schema-based judge decision export, and updates run-loop dispatches to use standardized actor and kind identifiers.

Changes

Agent bus and judge flow

Layer / File(s) Summary
Actor-bound bus writer API
packages/harness/src/bus.ts, packages/harness/src/index.ts, packages/harness/test/harness.test.ts, packages/harness/README.md
Adds AgentWriter, implements WriteAheadAgentBus.agent(actor), exports the writer type, tests optional payload handling, and documents the API.
Centralized decision and action recording
packages/harness/src/dispatch.ts, packages/harness/src/index.ts, packages/harness/src/schema.ts
Defines JudgeDecision and recordDecision(), routes dispatch records through actor-bound writers, and removes the schema-based judge decision exports.
Harness decision and dispatch integration
packages/harness/src/harness.ts
Standardizes actor and kind identifiers, records judge results through recordDecision, and updates participant dispatch and context reads.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Harness
  participant dispatchAction
  participant WriteAheadAgentBus
  participant Judge
  Harness->>Judge: provide bus context
  Judge-->>Harness: return pass or fail
  Harness->>dispatchAction: dispatch action with actor and kind
  dispatchAction->>WriteAheadAgentBus: record decision and action entries
  WriteAheadAgentBus-->>Harness: return recorded entries
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main changes: dispatch simplification, agent-bound bus writing, plain JudgeDecision typing, and export cleanup.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/dispatch-ts-refactor-w7g40r

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Tyler-R-Kendrick
Tyler-R-Kendrick merged commit b751276 into main Jul 12, 2026
3 checks passed
@Tyler-R-Kendrick
Tyler-R-Kendrick deleted the claude/dispatch-ts-refactor-w7g40r branch July 12, 2026 21:12
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.

2 participants