@arcforge/types 2.0.101 → 2.0.103

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,78 +20,137 @@
20
20
  * the runtime's lifecycle seams; this map is what the capsule itself emits.
21
21
  */
22
22
  import type { Activity } from "./activity"
23
+ import type { AxonErrorJSON } from "../../error"
24
+ import type { AxonCancellableSpan, AxonSpan } from "./span"
23
25
 
24
- export type CapsuleEventMap = {
25
- // ── Lifecycle ────────────────────────────────────────────────────────────
26
- "capsule:boot:start": {}
27
- "capsule:boot:complete": { durationMs: number }
28
- "capsule:boot:failed": { durationMs: number; error: string }
29
- "capsule:ready": {}
30
- "capsule:shutdown": {}
31
- /** Unhandled error inside the subprocess. Exit usually follows. */
32
- "capsule:crash": { error: string }
33
- /** The capsule subprocess itself exited (not a managed child process). */
34
- "capsule:exit": { code: number | null; reason?: string }
35
- /** A wire line failed to parse — the sandbox is speaking garbage. Never dropped silently. */
36
- "capsule:parse:error": { reason: string; line?: string }
26
+ /**
27
+ * Capsule failures carry AxonErrorJSON, not AxonError.
28
+ *
29
+ * Everywhere else in the system a :failed payload is a live AxonError, and
30
+ * JSON.stringify's toJSON() handles serialization on the way to disk. The
31
+ * capsule is the one boundary where that is a lie: these events are
32
+ * constructed inside a SUBPROCESS and cross a JSONL pipe, so what the host
33
+ * receives is already plain data — a parsed object with isAxonError: true,
34
+ * never an Error instance. Typing it as AxonError would promise a .render()
35
+ * and a live .cause chain that do not survive the pipe.
36
+ *
37
+ * The full structured value still crosses: code, title, description,
38
+ * captured frames with source snippets, and the cause chain. Only the
39
+ * behavior is lost, which is exactly what the JSON shape describes.
40
+ */
37
41
 
38
- // ── Supervision (host-side) ──────────────────────────────────────────────
39
- "capsule:restarting": { restartCount: number }
40
- "capsule:restarted": { restartCount: number }
41
- "capsule:dead": { reason: string }
42
+ export type CapsuleEventMap =
43
+ // ── Lifecycle ────────────────────────────────────────────────────────────
44
+ & AxonSpan<"capsule:boot", {}, {}, { error: AxonErrorJSON }>
45
+ & {
46
+ "capsule:ready": {}
47
+ "capsule:shutdown": {}
48
+ /** Unhandled error inside the subprocess. Exit usually follows. */
49
+ "capsule:crash": { error: AxonErrorJSON }
50
+ /** The capsule subprocess itself exited (not a managed child process). */
51
+ "capsule:exit": { code: number | null; reason?: string }
52
+ /** A wire line failed to parse — the sandbox is speaking garbage. Never dropped silently. */
53
+ "capsule:parse:error": { error: AxonErrorJSON; line?: string }
42
54
 
55
+ /**
56
+ * Supervision gave up — the capsule is gone and will not come back on
57
+ * its own. Terminal, and deliberately NOT capsule:restart:failed: it
58
+ * also fires when the restart budget is exhausted, which is a
59
+ * supervision verdict rather than one restart going wrong.
60
+ */
61
+ "capsule:dead": { error: AxonErrorJSON }
62
+ }
63
+ // ── Supervision (host-side) — one crash-and-recover cycle ───────────────
64
+ & AxonSpan<
65
+ "capsule:restart",
66
+ { restartCount: number },
67
+ { restartCount: number },
68
+ { restartCount: number; error: AxonErrorJSON }
69
+ >
43
70
  // ── Command execution (one run() = one command id) ──────────────────────
44
- "capsule:cmd:start": { id: string }
45
- "capsule:cmd:stdout": { id: string; data: string }
46
- "capsule:cmd:complete": { id: string; result: unknown; durationMs: number }
47
- "capsule:cmd:failed": { id: string; error: string; durationMs: number }
48
- "capsule:cmd:interrupt:requested": { id: string; reason: "abort" | "timeout" }
49
- "capsule:cmd:interrupted": { id: string; durationMs: number }
50
- "capsule:cmd:hard-killed": { id: string; graceMs: number }
51
-
71
+ & AxonCancellableSpan<
72
+ "capsule:cmd",
73
+ { id: string },
74
+ { id: string; result: unknown },
75
+ { id: string; error: AxonErrorJSON },
76
+ { id: string; durationMs: number }
77
+ >
78
+ & {
79
+ "capsule:cmd:stdout": { id: string; data: string }
80
+ "capsule:cmd:interrupt:requested": { id: string; reason: "abort" | "timeout" }
81
+ "capsule:cmd:hard-killed": { id: string; graceMs: number }
82
+ }
52
83
  // ── Tool call spans (mediated fn calls inside a command) ────────────────
53
- "capsule:fn:start": { commandId: string; module: string; fn: string; args: unknown[] }
54
- "capsule:fn:complete": { commandId: string; module: string; fn: string; durationMs: number; result: unknown }
55
- "capsule:fn:failed": { commandId: string; module: string; fn: string; durationMs: number; error: string }
56
-
84
+ & AxonSpan<
85
+ "capsule:fn",
86
+ { commandId: string; module: string; fn: string; args: unknown[] },
87
+ { commandId: string; module: string; fn: string; result: unknown },
88
+ { commandId: string; module: string; fn: string; error: AxonErrorJSON }
89
+ >
57
90
  // ── Tool loading ─────────────────────────────────────────────────────────
58
- "capsule:tool:loaded": { namespace: string; fns: string[] }
59
- "capsule:tool:unloaded": { namespace: string }
60
- "capsule:tool:error": { namespace: string; error: string }
91
+ // A dynamic import inside the sandbox: genuinely bracketed, and slow
92
+ // or hanging often enough that the :start half earns its place.
93
+ & AxonSpan<
94
+ "capsule:tool:load",
95
+ { namespace: string },
96
+ { namespace: string; fns: string[] },
97
+ { namespace: string; error: AxonErrorJSON }
98
+ >
99
+ // ── Managed child processes ──────────────────────────────────────────────
100
+ // One spawned process = one span. A non-zero exit is NOT :failed — the
101
+ // process ran exactly as asked and returned a code, which is ordinary
102
+ // and lives in the payload. :failed is reserved for the span itself
103
+ // breaking (the child could not be reaped, the handle was lost), which
104
+ // is why its payload carries no exit code: there isn't one.
105
+ & AxonSpan<
106
+ "capsule:proc",
107
+ { procId: string; pid: number; command: string; cwd: string; kind: "managed" | "run" },
108
+ { procId: string; code: number },
109
+ { procId: string; error: AxonErrorJSON }
110
+ >
111
+ & {
112
+ /**
113
+ * Unloading is a synchronous map delete — a settled fact with no
114
+ * interior, so it stays a bare event rather than a one-tick span.
115
+ */
116
+ "capsule:tool:unloaded": { namespace: string }
61
117
 
62
- // ── Trusted host bridge ─────────────────────────────────────────────────
63
- /** Private request transport for the capsule Axon facade. Never durable. */
64
- "capsule:host:request": { id: string; commandId: string | null; method: string; input: unknown }
118
+ // ── Trusted host bridge ──────────────────────────────────────────────
119
+ /** Private request transport for the capsule Axon facade. Never durable. */
120
+ "capsule:host:request": { id: string; commandId: string | null; method: string; input: unknown }
65
121
 
66
- // ── Managed child processes ──────────────────────────────────────────────
67
- "capsule:proc:spawned": { procId: string; pid: number; command: string; cwd: string; kind: "managed" | "run" }
68
- "capsule:proc:stdout": { procId: string; data: string }
69
- "capsule:proc:stderr": { procId: string; data: string }
70
- "capsule:proc:exit": { procId: string; code: number; durationMs?: number }
71
- "capsule:proc:denied": { procId: string; command: string; error: string }
72
- "capsule:proc:stdin:error": { procId: string; error: string }
122
+ // ── Child process byte streams ───────────────────────────────────────
123
+ "capsule:proc:stdout": { procId: string; data: string }
124
+ "capsule:proc:stderr": { procId: string; data: string }
125
+ /**
126
+ * A process the sandbox asked for was never created — refused by
127
+ * policy, killed before it could spawn, or the spawn itself failed.
128
+ * Outside the span triad on purpose: nothing started, so there is no
129
+ * bracket to close. Same rule as capsule:fn, which opens only once
130
+ * policy admits the call.
131
+ */
132
+ "capsule:proc:denied": { procId: string; command: string; error: AxonErrorJSON }
133
+ "capsule:proc:stdin:error": { procId: string; error: AxonErrorJSON }
73
134
 
74
- // ── Policy ───────────────────────────────────────────────────────────────
75
- "capsule:policy:updated": {}
76
- "capsule:policy:denied": { id: string; module: string; fn: string; args: unknown[]; rule: string }
77
- "capsule:policy:escalation": { id: string; module: string; fn: string; args: unknown[]; rule: string }
78
- /** Host-side: the escalate callback's verdict for a pending escalation. */
79
- "capsule:policy:decision": { id: string; allow: boolean; durationMs: number }
80
- "capsule:resource:exceeded": { id: string; limit: string; value: number; max: number }
135
+ // ── Policy ───────────────────────────────────────────────────────────
136
+ "capsule:policy:denied": { id: string; module: string; fn: string; args: unknown[]; rule: string }
137
+ "capsule:policy:escalation": { id: string; module: string; fn: string; args: unknown[]; rule: string }
138
+ /** Host-side: the escalate callback's verdict for a pending escalation. */
139
+ "capsule:policy:decision": { id: string; allow: boolean; durationMs: number }
81
140
 
82
- // ── Activities (semantic tool emissions) ─────────────────────────────────
83
- /**
84
- * A tool declared or settled a renderable activity (activity.ts) via the
85
- * ambient axon.activity(). Correlated to the running command the same way
86
- * capsule:console is; null only if emitted outside any command.
87
- */
88
- "capsule:activity": Activity & { commandId: string | null }
141
+ // ── Activities (semantic tool emissions) ─────────────────────────────
142
+ /**
143
+ * A tool declared or settled a renderable activity (activity.ts) via
144
+ * the ambient axon.activity(). Correlated to the running command the
145
+ * same way capsule:console is; null only if emitted outside any command.
146
+ */
147
+ "capsule:activity": Activity & { commandId: string | null }
89
148
 
90
- // ── Console + state ──────────────────────────────────────────────────────
91
- /** User console output, captured — correlated to the running command, never raw on stdout. */
92
- "capsule:console": { level: "log" | "info" | "warn" | "error" | "debug"; commandId: string | null; args: unknown[] }
93
- "capsule:cwd": { cwd: string }
94
- }
149
+ // ── Console + state ──────────────────────────────────────────────────
150
+ /** User console output, captured — correlated to the running command, never raw on stdout. */
151
+ "capsule:console": { level: "log" | "info" | "warn" | "error" | "debug"; commandId: string | null; args: unknown[] }
152
+ "capsule:cwd": { cwd: string }
153
+ }
95
154
 
96
155
  export type CapsuleEventName = keyof CapsuleEventMap
97
156
 
@@ -1,5 +1,6 @@
1
1
  import type { AxonError } from "../../error"
2
2
  import type { AxonLogEvents } from "./log"
3
+ import type { AxonCancellableSpan, AxonSpan } from "./span"
3
4
 
4
5
  /**
5
6
  * Cognet telemetry — the cognition artifact's own observability record.
@@ -21,26 +22,50 @@ import type { AxonLogEvents } from "./log"
21
22
  * the cognet layer, ticks and phases are the program's own clock; the
22
23
  * kernel neither knows nor cares that a program ticks.
23
24
  */
24
- export type CognetEventMap = AxonLogEvents<"cognet"> & {
25
+ export type CognetEventMap =
26
+ & AxonLogEvents<"cognet">
27
+ // ── Artifact lifecycle ───────────────────────────────────────────────────
28
+ //
29
+ // Emitted by the KERNEL, not by the cognet — deliberately the one family
30
+ // in this map the brain does not produce. exec'ing an untrusted artifact
31
+ // is the most failure-prone step in boot, and a cognet that dies inside
32
+ // load() cannot narrate its own failure: whatever bracket it opened would
33
+ // never close. The kernel is the only loader (see Kernel()), so it is the
34
+ // only thing positioned to record both halves honestly.
35
+ & AxonSpan<"cognet:load", { name: string }, { name: string }, { name: string; error: AxonError }>
36
+ & AxonSpan<"cognet:unload", { name: string }, { name: string }, { name: string; error: AxonError }>
25
37
  // ── World clock ──────────────────────────────────────────────────────────
26
- "cognet:tick:start": { tick: number }
27
- "cognet:tick:complete": { tick: number }
28
- "cognet:tick:failed": { tick: number; error: AxonError }
29
- /** The tick's own work threw because the wake was interrupted (Escape/Ctrl+C, engine abort) — cancellation, not a bug. Distinct from :failed so devtools/telemetry never conflate the two. */
30
- "cognet:tick:interrupted": { tick: number }
31
-
32
- "cognet:phase:start": { tick: number; phase: string }
33
- "cognet:phase:complete": { tick: number; phase: string }
34
- "cognet:phase:failed": { tick: number; phase: string; error: AxonError }
35
- /** Same rule as cognet:tick:interrupted, one level down. */
36
- "cognet:phase:interrupted": { tick: number; phase: string }
37
-
38
- "cognet:system:start": { tick: number; phase: string | null; system: string }
39
- "cognet:system:complete": { tick: number; phase: string | null; system: string; durationMs: number }
40
- "cognet:system:failed": { tick: number; phase: string | null; system: string; error: AxonError }
41
- /** Same rule as cognet:tick:interrupted, one level down. */
42
- "cognet:system:interrupted": { tick: number; phase: string | null; system: string }
43
-
38
+ //
39
+ // Three nested levels, each the four-state form: a tick contains phases,
40
+ // a phase contains systems. :interrupted at every level means the wake
41
+ // was cancelled (Escape/Ctrl+C, engine abort) — cancellation, not a bug,
42
+ // kept distinct from :failed so devtools never conflate the two.
43
+ //
44
+ // The bracket identity is in the payload (tick number, phase name,
45
+ // system name), which is what lets a reader pair a start with its own
46
+ // end when siblings of the same stem appear in one run.
47
+ & AxonCancellableSpan<
48
+ "cognet:tick",
49
+ { tick: number },
50
+ { tick: number },
51
+ { tick: number; error: AxonError },
52
+ { tick: number }
53
+ >
54
+ & AxonCancellableSpan<
55
+ "cognet:phase",
56
+ { tick: number; phase: string },
57
+ { tick: number; phase: string },
58
+ { tick: number; phase: string; error: AxonError },
59
+ { tick: number; phase: string }
60
+ >
61
+ & AxonCancellableSpan<
62
+ "cognet:system",
63
+ { tick: number; phase: string | null; system: string },
64
+ { tick: number; phase: string | null; system: string },
65
+ { tick: number; phase: string | null; system: string; error: AxonError },
66
+ { tick: number; phase: string | null; system: string }
67
+ >
68
+ & {
44
69
  // ── World writes ─────────────────────────────────────────────────────────
45
70
  "cognet:entity:add": { tick: number; phase: string | null; entity: string }
46
71
  "cognet:entity:remove": { tick: number; phase: string | null; entity: string }
@@ -1,5 +1,6 @@
1
1
  import type { AxonEngineFault, AxonEngineMessage, AxonEngineMeta } from "../../engine"
2
2
  import type { AxonLogEvents } from "./log"
3
+ import type { AxonCancellableSpan, AxonSpan } from "./span"
3
4
 
4
5
  /**
5
6
  * Kernel telemetry — the machinery's own record, emitted by the kernel and
@@ -9,36 +10,53 @@ import type { AxonLogEvents } from "./log"
9
10
  * Session-level: these describe how the machinery ran, never what the model
10
11
  * or client sees. runId rides in the event context.
11
12
  */
12
- export type AxonKernelEventMap = AxonLogEvents<"kernel"> & {
13
+ export type AxonKernelEventMap =
14
+ & AxonLogEvents<"kernel">
13
15
  // ── Run — one wake, exec to quiescence. The process accounting record. ──
14
- "kernel:run:start": {}
15
- "kernel:run:complete": { durationMs: number }
16
- // No error payload — err()'s sink already emitted the canonical "error"
17
- // session event at the throw site (see @axon/err/sink.ts). This is
18
- // pure run-accounting: the wake ended, and it ended badly.
19
- "kernel:run:failed": {}
20
- "kernel:run:interrupted": { reason: "user" | "shutdown" }
21
-
16
+ //
17
+ // :failed deliberately carries NO error payload — the first documented
18
+ // exception to the span standard. err()'s sink already emitted the
19
+ // canonical "axon:error" event at the throw site (see @axon/err/sink.ts),
20
+ // so duplicating the AxonError here would put the same failure in the
21
+ // log twice under two names. This is pure run-accounting: the wake
22
+ // ended, and it ended badly — the error's own record says how.
23
+ & AxonCancellableSpan<
24
+ "kernel:run",
25
+ {},
26
+ {},
27
+ {},
28
+ { reason: "user" | "shutdown" }
29
+ >
22
30
  // ── Engine calls — the billing and latency record ────────────────────────
23
31
  // Emitted by the Engine() manager around every call — a program cannot
24
32
  // skip them: every token passes this meter by construction.
25
- "kernel:engine:start": { provider: string; model?: string }
26
- /**
27
- * The rendered AIR document handed to the engine for this call — what the
28
- * model actually saw. Same spanId as the paired kernel:engine:start, so
29
- * a trace can pull a call's input by shared span without extra plumbing.
30
- * Devtools-only: never rendered to the user, never part of entry state.
31
- */
32
- "kernel:engine:input": { messages: AxonEngineMessage[]; bytes: number }
33
- "kernel:engine:retry": { attempt: number; nextAttempt: number; delayMs: number; fault: AxonEngineFault }
34
- /**
35
- * The other half of the call kernel:engine:input opened, same spanId —
36
- * together they tell the whole story: input (what the model saw),
37
- * output (exactly what it produced, raw, pre-AIR-parse), meta (billing/
38
- * observability). text/thinking are the same fields AxonEngineResponse
39
- * already carries in-process; this is that response actually made
40
- * durable instead of being dropped after the AIR parser consumes it.
41
- */
42
- "kernel:engine:complete": { attempts: number; text: string; thinking?: string; stopReason: "end" | "length" | "abort"; meta: AxonEngineMeta }
43
- "kernel:engine:failed": { attempts: number; fault: AxonEngineFault }
44
- }
33
+ //
34
+ // :failed carries AxonEngineFault, not AxonError — the second and last
35
+ // documented exception. A provider fault is a distinct, richer domain
36
+ // shape (code, provider, model, retryable, retryAfterMs) that drives
37
+ // retry policy; flattening it into a generic AxonError would lose the
38
+ // fields the retry loop and the billing view both read.
39
+ & AxonSpan<
40
+ "kernel:engine",
41
+ { provider: string; model?: string },
42
+ /**
43
+ * The other half of the call kernel:engine:input opened, same spanId —
44
+ * together they tell the whole story: input (what the model saw),
45
+ * output (exactly what it produced, raw, pre-AIR-parse), meta (billing/
46
+ * observability). text/thinking are the same fields AxonEngineResponse
47
+ * already carries in-process; this is that response actually made
48
+ * durable instead of being dropped after the AIR parser consumes it.
49
+ */
50
+ { attempts: number; text: string; thinking?: string; stopReason: "end" | "length" | "abort"; meta: AxonEngineMeta },
51
+ { attempts: number; fault: AxonEngineFault }
52
+ >
53
+ & {
54
+ /**
55
+ * The rendered AIR document handed to the engine for this call — what the
56
+ * model actually saw. Same spanId as the paired kernel:engine:start, so
57
+ * a trace can pull a call's input by shared span without extra plumbing.
58
+ * Devtools-only: never rendered to the user, never part of entry state.
59
+ */
60
+ "kernel:engine:input": { messages: AxonEngineMessage[]; bytes: number }
61
+ "kernel:engine:retry": { attempt: number; nextAttempt: number; delayMs: number; fault: AxonEngineFault }
62
+ }
@@ -1,5 +1,6 @@
1
1
  import type { AxonError } from "../../error"
2
2
  import type { AxonLogEvents } from "./log"
3
+ import type { AxonSpan } from "./span"
3
4
 
4
5
  /**
5
6
  * Runtime + continuity events — the session's own lifecycle record.
@@ -7,8 +8,8 @@ import type { AxonLogEvents } from "./log"
7
8
  * Two families in one map:
8
9
  * - Runtime facts (boot/shutdown/reload/server): "a runtime attached to this
9
10
  * session and did things". A session can span many boots.
10
- * - Continuity facts (session/capsule/compress): the small, load-bearing
11
- * subset hydration reads on resume.
11
+ * - Continuity facts (session/capsule): the small, load-bearing subset
12
+ * hydration reads on resume.
12
13
  *
13
14
  * No single prefix covers this map (boot:/shutdown:/session:/capsule:/
14
15
  * server:), so its log events use "runtime" as the namespace —
@@ -21,67 +22,90 @@ import type { AxonLogEvents } from "./log"
21
22
  * own code is running inside — not any one lifecycle prefix above — so it
22
23
  * gets its own namespace rather than folding into axon:log:*.
23
24
  */
24
- export type AxonRuntimeEvent = AxonLogEvents<"axon"> & {
25
+ export type AxonRuntimeEvent =
26
+ & AxonLogEvents<"axon">
25
27
  // ── Runtime lifecycle ────────────────────────────────────────────────────
26
- "axon:boot:start": { version: string; agentRoot: string; mode: "local" | "cloud" }
27
- "axon:boot:complete": { durationMs: number }
28
- "axon:boot:failed": { error: AxonError }
29
-
30
- "axon:shutdown:start": { reason?: string }
31
- "axon:shutdown:complete": { durationMs: number }
32
- "axon:shutdown:failed": { error: AxonError }
33
-
28
+ & AxonSpan<"axon:boot", { version: string; agentRoot: string; mode: "local" | "cloud" }>
29
+ & AxonSpan<"axon:shutdown", { reason?: string }>
34
30
  // ── Surface reload (blueprint/tools changed under a live runtime) ───────
35
- "axon:reload:start": { revision: number }
36
- "axon:reload:complete": { revision: number; durationMs: number; toolCount: number }
37
- "axon:reload:failed": { revision?: number; error: AxonError }
38
-
31
+ & AxonSpan<
32
+ "axon:reload",
33
+ { revision: number },
34
+ { revision: number; toolCount: number },
35
+ { revision?: number; error: AxonError }
36
+ >
39
37
  // ── Module install/uninstall (registry op, then a reload rides the same
40
38
  // hot-swap path above) ─────────────────────────────────────────────
41
- "axon:install:start": { name: string; version?: string }
42
- "axon:install:complete": { name: string; version: string; durationMs: number; alreadyInstalled: boolean }
43
- /**
44
- * No module by that name in the registry — a typo or an unpublished
45
- * package. A settled outcome, not a failure: nothing broke, so it must
46
- * not render as an error. Distinct from :failed, which means the
47
- * install itself went wrong (network, disk, a bad tarball).
48
- */
49
- "axon:install:not-found": { name: string; durationMs: number }
50
- "axon:install:failed": { name: string; version?: string; error: AxonError }
51
-
52
- "axon:uninstall:start": { name: string }
53
- "axon:uninstall:complete": { name: string; durationMs: number }
54
- "axon:uninstall:failed": { name: string; error: AxonError }
55
-
39
+ & AxonSpan<
40
+ "axon:install",
41
+ { name: string; version?: string },
42
+ { name: string; version: string; alreadyInstalled: boolean },
43
+ { name: string; version?: string; error: AxonError }
44
+ >
45
+ & {
46
+ /**
47
+ * No module by that name in the registry — a typo or an unpublished
48
+ * package. A settled outcome, not a failure: nothing broke, so it must
49
+ * not render as an error. Distinct from :failed, which means the
50
+ * install itself went wrong (network, disk, a bad tarball).
51
+ *
52
+ * Outside the span triad by design — a third settled outcome, the
53
+ * same way :interrupted is for cancellable operations.
54
+ */
55
+ "axon:install:not-found": { name: string; durationMs: number }
56
+ }
57
+ & AxonSpan<
58
+ "axon:uninstall",
59
+ { name: string },
60
+ { name: string },
61
+ { name: string; error: AxonError }
62
+ >
56
63
  // ── Module setup/teardown (boot-time defineModule() setup execution) ─────
57
64
  // The determinism ledger: one start/complete (or failed) per module,
58
65
  // in blueprint order, carrying the config content hash so two boots of
59
66
  // the same blueprint are provably the same wiring.
60
- "module:setup:start": { name: string; configHash: string; options: Record<string, unknown> }
61
- "module:setup:complete": { name: string; durationMs: number }
62
- "module:setup:failed": { name: string; error: AxonError }
63
- "module:dispose:start": { name: string }
64
- "module:dispose:complete": { name: string; durationMs: number }
65
- "module:dispose:failed": { name: string; error: AxonError }
66
-
67
+ & AxonSpan<
68
+ "module:setup",
69
+ { name: string; configHash: string; options: Record<string, unknown> },
70
+ { name: string },
71
+ { name: string; error: AxonError }
72
+ >
73
+ & AxonSpan<
74
+ "module:dispose",
75
+ { name: string },
76
+ { name: string },
77
+ { name: string; error: AxonError }
78
+ >
79
+ & {
67
80
  // ── Session continuity ───────────────────────────────────────────────────
68
- "axon:session:start": {}
81
+ // NOT a span, and deliberately not named like one. A session outlives
82
+ // the runtime that opened it: `opened` and `closed` can be days and
83
+ // several processes apart, with any number of boots in between, so
84
+ // there is no bracket here for a reader to match or a flame graph to
85
+ // draw. `axon:session:start` collided with the span vocabulary and
86
+ // read as a bracket that never closed — these verbs keep the
87
+ // continuity family honestly outside it.
88
+ "axon:session:opened": {}
69
89
  "axon:session:restored": {}
70
- "axon:session:end": {}
71
- "axon:session:error": { error: AxonError }
90
+ "axon:session:closed": {}
72
91
 
73
92
  // ── Capsule attachment (one capsule per session; telemetry lives in the capsule package) ──
74
93
  "capsule:attach": { capsuleId: string; cwd: string }
75
94
  "capsule:detach": { capsuleId: string; reason: "shutdown" | "crash" | "reload" }
76
95
 
77
- // ── Compression — summaries replacing aged entries ──────────────────────
78
- "axon:compress": { replaced: number; summaryEntryId: string }
79
-
80
96
  // ── Server ───────────────────────────────────────────────────────────────
81
97
  "axon:server:request": { method: string; path: string; status: number; durationMs: number }
82
98
 
83
99
  // ── Errors ───────────────────────────────────────────────────────────────
84
100
  "axon:error": { event?: string; error: AxonError }
85
- /** Matches the literal string the bus actually emits (platform/bus.ts) — "axon" names the runtime layer the failure happened in, not any one lifecycle prefix above. */
86
- "axon:bus:error": { event: string; error: string }
101
+ /**
102
+ * A bus handler threw. "axon" names the runtime layer the failure
103
+ * happened in, not any one lifecycle prefix above.
104
+ *
105
+ * Carries the full AxonError (envelope rule 4) — plugins and modules
106
+ * register handlers, so a stringified message would drop the stack at
107
+ * exactly the boundary where "which plugin broke?" is the only question
108
+ * worth answering.
109
+ */
110
+ "axon:bus:error": { event: string; error: AxonError }
87
111
  }