agent doctor / toolkit

The deterministic shell around AI coding agents. Agents are nondeterministic; the value is a layer that grounds and verifies them. Build leverage — ground truth, coordination, determinism — not judgment a smarter model already does well.

kernel

Code index

Content-addressed index of every TypeScript file: parse once, build a symbol graph, dependency edges, and structural fingerprints. Warm and incremental: re-parse one file in ~25µs.

L1

Policy / gate

ACL, architecture layering, protected paths, and region leases. A diff that breaks the rules is denied deterministically — exit non-zero. Same gate for humans, agents, and CI.

L2

Impact test selection

Which tests transitively reach a change, from the import graph. Turns “run 3000 tests” into “run the 12 that matter” — sub-µs once warm.

L3

Semantic merge

AST-level 3-way merge. Two agents adding different functions to the same file merge with zero conflict; only edits to the same declaration conflict. Drops in as a git merge driver.

L4

Context server

A warm kernel answering queries over stdio — plain JSON or MCP. The agent pulls ground truth (does this helper exist? what tests cover this?) instead of grepping.

L5

Orchestrator

The deterministic runner: lease, assemble context, run the agent, gate, then retry with the exact findings. The agent is the only nondeterministic step; everything around it is enforced.

L6

Agent-native VCS

A content-addressed operation log with per-agent/per-task attribution and deterministic undo, first-class leases, and semantic merge — our model on a git-compatible backend.

The loop

orchestrator: decompose, lease disjoint regions
  per task (parallel):
    assemble minimal context (kernel queries)
    run the agent            -- the only nondeterministic step
    gate the diff            -- deny? retry with the exact findings
    run impacted tests       -- fail? retry with the failures
    semantic-merge back      -- conflict? only the real one surfaces
    release lease

A hallucinating agent can't corrupt the repo — every mutation flows through the deterministic gate / test / merge it cannot bypass.

Commands

agent-doctor initscaffold policy, gitignore, MCP config, and the merge driver
agent-doctor gate --base main --actor medeny a diff that breaks policy/ACL/leases
agent-doctor impact --base mainthe tests reaching your diff
agent-doctor merge O A Bsemantic 3-way merge (git driver)
agent-doctor serve --mcpcontext server for your agent harness
agent-doctor orchestrate --executor '…'run a task ledger through the loop

Latency — release, Apple Silicon

projectbuildincrementalimpactgatemerge
zod (404 files)7.8ms25µs0.2µs4µs19µs
zustand (33 files)2.5ms46µs0.2µs53µs21µs

The harness drove out two real regressions, both fixed: impact 1300→0.2µs, gate 1193→4µs. CI gates cold-build µs/file.