Files
deepseek-harness/docs/event-producer-consumer.md
Tianyi Cui 4751a7be0b Merge origin/master: Code Mode composed with agent scopes
Master advanced 11 commits mid-merge (the Code Mode registry integration:
mode config, run_code, the tools:sdk section, the ACP run_code cards and
unified demos). The fusion makes Code Mode scope-aware end to end:

- wireSchemas(scope): the mode-aware wire contribution is computed from the
  CALLING SCOPE's visible set (scoped tools join, shadowing and restrictions
  apply) and feeds the {schemas, knownNames} provider protocol.
- knownNames under the mode collapse: a per-scope RESTRICTION is runtime
  state, so the universe stays pre-restriction (a restricted-away tool in
  toolOrder is a normal absence) — but the MODE collapse is deployment
  config, so under mode 'code' the universe is [run_code] and a toolOrder
  naming a native tool fails every assembly loud (master's tested decision,
  kept).
- The tools:sdk section renders per assembly CONTEXT: the SDK declares
  exactly the calling agent's callable set, using the section-text provider
  signature this branch already had.
- run_code bindings enumerate schemas(exec.agent) — a program can bind
  exactly what its prompt promised; sub-dispatches already threaded
  exec.agent through registry.execute, so scoped resolution and carriers
  flow unchanged.
- dsh-tools declares both sides' new deps (dsh-scope + dsh-session);
  lockfile and all generated catalogs/graphs/api-catalog regenerated.

Gates green on the merged tree: typecheck, lint, per-file 100% coverage
(2710 tests), snapshots (41), doc-sync, module graph, build, hygiene, demo
smoke.
2026-07-09 23:57:50 +08:00

7.7 KiB

Event Producer And Consumer Matrix

This matrix shows which packages dispatch each harness-owned event and which packages listen to it. It is intentionally a table rather than one large graph: events are many-to-many, and dense relation data is easier to review in rows. Dynamic dispatch overrides cover sites that deliberately bypass ctx.emit, such as subagent lifecycle containment.

Event Mode Declared in Dispatchers Listeners
agent/created emit packages/core/agent/src/types.ts:287 agent (emit) stdio-agent
agent/disposed emit packages/core/agent/src/types.ts:299 agent (emit) stdio-agent
agent/error emit packages/core/agent/src/types.ts:553 agent-loop (emit) -
agent/pre-step serial packages/core/agent/src/types.ts:404 agent-loop (serial) compact-basic
agent/prompt-submit waterfall packages/core/agent/src/types.ts:422 agent-loop (waterfall) hooks-claude, hooks-codex, repeat-tool-guard
agent/queued emit packages/core/agent/src/types.ts:327 agent-loop (emit) -
agent/request waterfall packages/core/agent/src/types.ts:451 agent-loop (waterfall) -
agent/session-prefix waterfall packages/core/agent/src/types.ts:503 agent-loop (waterfall) -
agent/session-start emit packages/core/agent/src/types.ts:347 agent-loop (emit) hooks-claude, hooks-codex, invariants
agent/status emit packages/core/agent/src/types.ts:313 agent-loop (emit) acp, invariants, repeat-tool-guard, stdio-agent
agent/step-result waterfall packages/core/agent/src/types.ts:518 agent-loop (waterfall) -
agent/turn-continuation waterfall packages/core/agent/src/types.ts:536 agent-loop (waterfall) hooks-claude, hooks-codex
fs/edit-intent waterfall packages/fs/fs/src/index.ts:123 tool-fs (waterfall) fs-policy
fs/observed emit packages/fs/fs/src/index.ts:138 tool-fs (emit) fs-policy
fs/write-intent waterfall packages/fs/fs/src/index.ts:109 tool-fs (waterfall) fs-policy
llm/stream waterfall packages/llm/llm/src/index.ts:39 llm (waterfall) invariants, llm-replay
session/created emit packages/core/session/src/index.ts:47 session (emit) invariants, session-persistence
session/event emit packages/core/session/src/index.ts:61 session (emit) acp, invariants, session-persistence, stdio-agent
session/flush parallel packages/core/session/src/index.ts:79 session (parallel) session-persistence
subagent/end emit packages/subagent/subagent/src/index.ts:107 subagent (events.dispatch) hooks-claude
subagent/provider-added emit packages/subagent/subagent/src/index.ts:73 subagent (emit) tool-subagent
subagent/provider-removed emit packages/subagent/subagent/src/index.ts:84 subagent (events.dispatch) tool-subagent
subagent/start emit packages/subagent/subagent/src/index.ts:96 subagent (events.dispatch) hooks-claude
system-prompt/assemble waterfall packages/core/system-prompt/src/index.ts:44 system-prompt (waterfall) -
system-prompt/change emit packages/core/system-prompt/src/index.ts:54 system-prompt (emit) -
tools/change emit packages/core/tools/src/index.ts:151 tools (emit) -
tools/execute waterfall packages/core/tools/src/index.ts:121 tools (waterfall) timeout-policy
tools/post-execute waterfall packages/core/tools/src/index.ts:141 tools (waterfall) hooks-claude, hooks-codex, repeat-tool-guard
tools/pre-execute waterfall packages/core/tools/src/index.ts:97 tools (waterfall) hooks-claude, hooks-codex

Non-harness or undeclared event strings seen in package source

Event string Dispatchers Listeners
internal/dispatch - invariants

Maintenance mode: hybrid generated: Cordis event declarations and most producer/listener edges are AST-scanned; dynamic dispatch sites are classified in scripts/gen-doc-graphs.ts.