Files
deepseek-harness/docs/event-producer-consumer.md
T
kingwl 63ced3e0e2 feat(mode): the session-mode core — logged per-agent policy state (@deepseek-ai/dsh-mode)
Plan mode's stage 1 (RFC 2026-07-07-plan-mode): a new packages/mode/ group
with one product package owning the mode/set SessionEventMap vocabulary
(log-only, non-surface, whole-value replace), the pure foldMode, and the
ctx.modes service (list/get/set). User flips are pending intents flushed
at turn/start / step/end — turn enclosure makes an idle append illegal —
with one coalesced context/message notice when the flushed mode differs
from what the last logged request header told the model; a folded mode
the config no longer defines reads as default plus one boundary notice.

Enforcement is two covering layers: a system-prompt/assemble wrapper
filters the RETURNED assembly's tools to the mode's allowlist (and shows
exit_plan_mode IFF the folded mode is plan) beside the mode:policy
section at order 50, and a tools/pre-execute gate denies deny-by-default
against the same allowlist, judging by the logged mode only. The default
mode is the absence of policy — assemblies stay byte-identical to a
no-dsh-mode deployment.

AgentOptions.mode (declaration-merged) seeds a child's initial mode
through the same flush on agent/created; the stdio app gains /mode
(print/switch, never sent to the model) over an opportunistic
ctx.get('modes'). Config is an explicit resolve step: the built-in plan
definition (read-only allowlist; bash/subagent excluded until the
sandbox family lands) merges unless overridden, 'default' as a key
throws at load, unknown names throw at set() time.
2026-07-10 01:38:39 +08:00

7.5 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:265 agent (emit) mode, stdio-agent
agent/disposed emit packages/core/agent/src/types.ts:272 agent (emit) stdio-agent
agent/error emit packages/core/agent/src/types.ts:476 agent-loop (emit) -
agent/pre-step serial packages/core/agent/src/types.ts:357 agent-loop (serial) compact-basic
agent/prompt-submit waterfall packages/core/agent/src/types.ts:370 agent-loop (waterfall) hooks-claude, hooks-codex, repeat-tool-guard
agent/queued emit packages/core/agent/src/types.ts:290 agent-loop (emit) -
agent/request waterfall packages/core/agent/src/types.ts:394 agent-loop (waterfall) -
agent/session-prefix waterfall packages/core/agent/src/types.ts:441 agent-loop (waterfall) -
agent/session-start emit packages/core/agent/src/types.ts:305 agent-loop (emit) hooks-claude, hooks-codex
agent/status emit packages/core/agent/src/types.ts:281 agent-loop (emit) acp, invariants, repeat-tool-guard, stdio-agent
agent/step-result waterfall packages/core/agent/src/types.ts:451 agent-loop (waterfall) -
agent/turn-continuation waterfall packages/core/agent/src/types.ts:464 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:39 session (emit) invariants, session-persistence
session/event emit packages/core/session/src/index.ts:47 session (emit) acp, invariants, mode, session-persistence, stdio-agent
session/flush parallel packages/core/session/src/index.ts:57 agent-loop (parallel) session-persistence
subagent/end emit packages/subagent/subagent/src/index.ts:98 subagent (events.dispatch) hooks-claude
subagent/provider-added emit packages/subagent/subagent/src/index.ts:72 subagent (emit) tool-subagent
subagent/provider-removed emit packages/subagent/subagent/src/index.ts:83 - tool-subagent
subagent/start emit packages/subagent/subagent/src/index.ts:91 subagent (events.dispatch) hooks-claude
system-prompt/assemble waterfall packages/core/system-prompt/src/index.ts:38 system-prompt (waterfall) mode
system-prompt/change emit packages/core/system-prompt/src/index.ts:44 system-prompt (emit) -
tools/change emit packages/core/tools/src/index.ts:132 tools (emit) -
tools/execute waterfall packages/core/tools/src/index.ts:111 tools (waterfall) timeout-policy
tools/post-execute waterfall packages/core/tools/src/index.ts:127 tools (waterfall) hooks-claude, hooks-codex, repeat-tool-guard
tools/pre-execute waterfall packages/core/tools/src/index.ts:91 tools (waterfall) hooks-claude, hooks-codex, mode

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.