@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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcforge/types",
3
- "version": "2.0.101",
3
+ "version": "2.0.103",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "main": "./src/index.ts",
@@ -1,4 +1,4 @@
1
- import type { BenchCell } from "./factor"
1
+ import type { BenchCell } from "./matrix"
2
2
  import type { BenchMeasurementWeighting } from "./measurement"
3
3
 
4
4
  export type BenchConfidenceInterval = {
@@ -1,14 +1,13 @@
1
1
  import type { BenchArtifactDefinition, BenchArtifactInput } from "./artifact"
2
2
  import type { BenchDimensionDefinition, BenchDimensionValue } from "./dimension"
3
- import type { BenchCell } from "./factor"
4
- import type { BenchFactor } from "./factor"
3
+ import type { BenchAxis, BenchCell, BenchMatrix } from "./matrix"
5
4
  import type { BenchMeasurementDefinition } from "./measurement"
6
5
  import type { BenchObservationIndex } from "./observation"
7
- import type { BenchResolvedWorkspaceDefinition, BenchWorkspaceDefinition } from "./workspace"
6
+ import type { BenchResolvedWorkspaceDefinition, BenchWorkspaceDefinition, BenchWorkspaceHandle } from "./workspace"
8
7
 
9
- export type BenchNormalizedConfig = Omit<BenchConfig, "factors" | "trials" | "tests" | "measurements" | "dimensions" | "artifacts" | "workspace"> & {
10
- identity: { name: string; version: string }
11
- factors: BenchFactor[]
8
+ export type BenchNormalizedConfig = Omit<BenchConfig, "matrix" | "trials" | "tests" | "measurements" | "dimensions" | "artifacts" | "workspace"> & {
9
+ identity: { name: string; version: string; description?: string }
10
+ axes: BenchAxis[]
12
11
  trials: number
13
12
  tests: string[]
14
13
  measurements: BenchMeasurementDefinition[]
@@ -30,19 +29,42 @@ export type BenchAttachOptions = {
30
29
 
31
30
  /** Public authoring handle. Generated declarations narrow its string IDs and values. */
32
31
  export type BenchHandle = {
33
- readonly workspace: string
34
- factor<T = unknown>(id: string): T
32
+ /**
33
+ * The agent's world for this trial. Stringifies to its path, so it can be
34
+ * passed anywhere a directory is expected, and carries the queries a
35
+ * scenario needs afterward — `changed()` and `diff()` in particular, which
36
+ * a test cannot compute alone because they need the world as it was before
37
+ * the agent booted.
38
+ */
39
+ readonly workspace: BenchWorkspaceHandle
40
+ axis<T = unknown>(key: string): T
35
41
  observe(measurementId: string, value: number | boolean | string, options?: BenchObserveOptions): void
36
42
  attach(definitionId: string, content: unknown, options?: BenchAttachOptions): Promise<void>
37
43
  }
38
44
 
39
45
  /** Published benchmark contract. Native Bun test files define its executable cases. */
40
46
  export type BenchConfig = {
41
- description: string
42
47
  workspace?: BenchWorkspaceDefinition
43
- factors?: BenchFactor[]
44
- /** Repetitions per test × cell. Defaults to one. */
48
+ /**
49
+ * The variations to sweep. Every key is an axis and multiple keys
50
+ * multiply, so one key is the controlled single-variable experiment and
51
+ * more than one is a grid whose size is the author's to manage.
52
+ */
53
+ matrix?: BenchMatrix
54
+ /**
55
+ * Repetitions per test × cell. Defaults to one.
56
+ *
57
+ * Real models are stochastic: a single sample per cell is an anecdote,
58
+ * not a measurement.
59
+ */
45
60
  trials?: number
61
+ /**
62
+ * Runs after the workspace is copied and before the subject boots, once
63
+ * per iteration — the point at which the world exists but nothing has
64
+ * touched it yet (install dependencies, seed a database, snapshot a
65
+ * baseline).
66
+ */
67
+ setup?: () => Promise<void> | void
46
68
  /** Native Bun test globs. Defaults to benchmark files beneath tests/. */
47
69
  tests?: string[]
48
70
  measurements?: BenchMeasurementDefinition[]
@@ -1,5 +1,5 @@
1
1
  import type { BenchAggregate } from "./aggregate"
2
- import type { BenchResolvedFactor } from "./factor"
2
+ import type { BenchResolvedAxis } from "./matrix"
3
3
  import type { BenchRunResult } from "./result"
4
4
  import type { BenchHash } from "./value"
5
5
 
@@ -10,7 +10,7 @@ export type BenchCohortKey = {
10
10
  benchHash: BenchHash
11
11
  schemaHash: BenchHash
12
12
  caseSetPin: BenchHash
13
- controlledFactors: BenchResolvedFactor[]
13
+ controlledAxes: BenchResolvedAxis[]
14
14
  harnessCompatibility: string
15
15
  }
16
16
 
@@ -1,4 +1,4 @@
1
- import type { BenchCell } from "./factor"
1
+ import type { BenchCell } from "./matrix"
2
2
 
3
3
  export type BenchTestStatus = "passed" | "failed" | "skipped" | "todo"
4
4
 
@@ -10,18 +10,21 @@ export type {
10
10
  BenchWorkspaceFileState,
11
11
  BenchWorkspaceChange,
12
12
  BenchWorkspaceResult,
13
+ BenchWorkspaceHandle,
13
14
  } from "./workspace"
14
15
 
15
16
  export type {
16
- BenchFactorKind,
17
- BenchFactorRole,
18
- BenchFactorValue,
19
- BenchFactor,
20
- BenchFactorSelection,
17
+ BenchAxisName,
18
+ BenchAxisKey,
19
+ BenchAxisValue,
20
+ BenchAxis,
21
+ BenchAxisVariation,
22
+ BenchMatrix,
23
+ BenchAxisSelection,
21
24
  BenchCoordinate,
22
- BenchResolvedFactor,
25
+ BenchResolvedAxis,
23
26
  BenchCell,
24
- } from "./factor"
27
+ } from "./matrix"
25
28
 
26
29
  export type { BenchDimensionValue, BenchDimensionDefinition } from "./dimension"
27
30
 
@@ -82,7 +85,7 @@ export type { BenchProtocolVersions, BenchHarnessIdentity } from "./protocol"
82
85
  export type {
83
86
  BenchIdentity,
84
87
  BenchSchemaSnapshot,
85
- BenchFactorSnapshot,
88
+ BenchAxisSnapshot,
86
89
  BenchRunManifest,
87
90
  } from "./manifest"
88
91
 
@@ -1,7 +1,7 @@
1
1
  import type { BenchArtifactDefinition } from "./artifact"
2
2
  import type { BenchDimensionDefinition } from "./dimension"
3
3
  import type { BenchCaseRef, BenchTestRef } from "./execution"
4
- import type { BenchCell, BenchFactorKind, BenchFactorRole } from "./factor"
4
+ import type { BenchAxisKey, BenchCell } from "./matrix"
5
5
  import type { BenchMeasurementDefinition } from "./measurement"
6
6
  import type { BenchHarnessIdentity, BenchProtocolVersions } from "./protocol"
7
7
  import type { BenchHash } from "./value"
@@ -21,11 +21,11 @@ export type BenchSchemaSnapshot = {
21
21
  artifacts: BenchArtifactDefinition[]
22
22
  }
23
23
 
24
- export type BenchFactorSnapshot = {
25
- id: string
24
+ export type BenchAxisSnapshot = {
25
+ key: BenchAxisKey
26
26
  label: string
27
- kind: BenchFactorKind
28
- role: BenchFactorRole
27
+ /** Variation ids on this axis, in declared order. */
28
+ values: string[]
29
29
  }
30
30
 
31
31
  /** Layer-two reproducibility record. A result without this is not comparable. */
@@ -34,7 +34,7 @@ export type BenchRunManifest = {
34
34
  bench: BenchIdentity
35
35
  protocols: BenchProtocolVersions
36
36
  schema: BenchSchemaSnapshot
37
- factors: BenchFactorSnapshot[]
37
+ axes: BenchAxisSnapshot[]
38
38
  cells: BenchCell[]
39
39
  trials: number
40
40
  tests: BenchTestRef[]
@@ -0,0 +1,109 @@
1
+ import type { EngineRef } from "../engine"
2
+ import type { BenchValue } from "./value"
3
+
4
+ /**
5
+ * The named binding points a matrix axis can target.
6
+ *
7
+ * These are not a taxonomy of "kinds of thing" — they name WHERE in the
8
+ * assembled blueprint a variation lands:
9
+ *
10
+ * agent → which agent project is loaded at all
11
+ * cognet → the brain bundled into that agent before it boots
12
+ * model → config.engine
13
+ * env → the agent's environment variables
14
+ *
15
+ * Anything else is reachable by dotted path (see BenchAxisKey), so the named
16
+ * set stays small and ergonomic rather than growing a member per use case.
17
+ * An earlier design had eight kinds — dataset, toolset, judge, value among
18
+ * them — of which only three were ever wired, because the others were not
19
+ * binding points at all: a dataset is the population you measure OVER, and a
20
+ * judge is an assessor, not a property of the subject.
21
+ */
22
+ export type BenchAxisName = "agent" | "cognet" | "model" | "env"
23
+
24
+ /**
25
+ * A matrix axis: a named binding point, or a dotted path into the blueprint
26
+ * for anything without a name (`"config.engine.temperature"`).
27
+ *
28
+ * The template literal keeps `agent` and `model` autocompleting while still
29
+ * admitting arbitrary paths.
30
+ */
31
+ export type BenchAxisKey = BenchAxisName | `config.${string}` | `env.${string}`
32
+
33
+ /** What a variation is allowed to be, per named axis. */
34
+ export type BenchAxisValue = {
35
+ /** Path to a local agent project, or a registry ref. */
36
+ agent: string
37
+ /** Path to a local cognet, or a registry ref. */
38
+ cognet: string
39
+ model: EngineRef
40
+ env: Record<string, string>
41
+ }
42
+
43
+ /**
44
+ * One axis of the matrix: the variations to try at a single binding point.
45
+ *
46
+ * One value is a held constant — still pinned into the manifest, because a
47
+ * result is only comparable if the things that did NOT vary are recorded too.
48
+ * Two or more form an axis, and axes multiply.
49
+ */
50
+ export type BenchAxis<K extends BenchAxisKey = BenchAxisKey> = {
51
+ key: K
52
+ label?: string
53
+ description?: string
54
+ values: BenchAxisVariation[]
55
+ }
56
+
57
+ export type BenchAxisVariation = {
58
+ /** Stable within the axis; used in cell identities. */
59
+ id: string
60
+ label?: string
61
+ value: unknown
62
+ }
63
+
64
+ /**
65
+ * The authored matrix: every key is an axis, and multiple keys multiply.
66
+ *
67
+ * Deliberately a plain object rather than a list of factor descriptors — the
68
+ * key IS the binding point, so there is nothing to declare twice. A single
69
+ * key is the controlled single-variable experiment, which is the shape to
70
+ * reach for first; more keys is a grid, and the Cartesian growth is the
71
+ * author's to manage rather than the runtime's to hide.
72
+ *
73
+ * A bare value means a held constant: `agent: "@axon/coding-base"` and
74
+ * `agent: ["@axon/coding-base"]` are the same declaration.
75
+ */
76
+ export type BenchMatrix = {
77
+ [K in BenchAxisName]?: BenchAxisValue[K] | BenchAxisValue[K][]
78
+ } & {
79
+ [path: `config.${string}`]: unknown
80
+ } & {
81
+ [path: `env.${string}`]: unknown
82
+ }
83
+
84
+ /** A selected variation on one axis. */
85
+ export type BenchAxisSelection = {
86
+ key: BenchAxisKey
87
+ valueId: string
88
+ }
89
+
90
+ /** A raw Cartesian coordinate before values are resolved and pinned. */
91
+ export type BenchCoordinate = {
92
+ id: string
93
+ axes: BenchAxisSelection[]
94
+ }
95
+
96
+ /** Manifest-safe identity of a selected value. Secret values are never included. */
97
+ export type BenchResolvedAxis = BenchAxisSelection & {
98
+ label: string
99
+ /** Immutable registry version, content hash, or canonical value hash. */
100
+ pin: string
101
+ }
102
+
103
+ /** One fully resolved coordinate, including both varied and constant axes. */
104
+ export type BenchCell = {
105
+ id: string
106
+ axes: BenchResolvedAxis[]
107
+ }
108
+
109
+ export type { BenchValue }
@@ -8,9 +8,16 @@ export type BenchWorkspaceSource =
8
8
  export type BenchWorkspaceRetention = "never" | "failed" | "always"
9
9
 
10
10
  export type BenchWorkspaceDefinition = {
11
- /** Shorthand for source: { kind: "directory", path: template }. */
12
- template?: string
13
- source?: BenchWorkspaceSource
11
+ /**
12
+ * Directory holding the agent's world, copied fresh per iteration.
13
+ * Defaults to "./workspace".
14
+ *
15
+ * Named for what it IS rather than the copy that implements it: the
16
+ * directory is the working environment the agent sees, and nothing
17
+ * outside it is visible to the subject. `fixtures/` sits beside it for
18
+ * things only the bench author uses — setup, assertions, judge rubrics.
19
+ */
20
+ source?: string | BenchWorkspaceSource
14
21
  retain?: BenchWorkspaceRetention
15
22
  capture?: {
16
23
  changes?: boolean
@@ -74,3 +81,24 @@ export type BenchWorkspaceResult = {
74
81
  }
75
82
  }
76
83
 
84
+
85
+ /**
86
+ * What a scenario can ask about the agent's world after it has acted.
87
+ *
88
+ * `changed()` and `diff()` are only answerable by the harness: both need the
89
+ * world as it was before the subject booted, and by the time a test runs that
90
+ * state exists solely in the baseline snapshot.
91
+ */
92
+ export type BenchWorkspaceHandle = {
93
+ readonly path: string
94
+ toString(): string
95
+ read(relativePath: string): Promise<string>
96
+ exists(relativePath: string): Promise<boolean>
97
+ changed(): Promise<string[]>
98
+ changes(): Promise<BenchWorkspaceChange[]>
99
+ diff(): Promise<string>
100
+ tests: {
101
+ pass(opts?: { timeoutMs?: number }): Promise<boolean>
102
+ output(opts?: { timeoutMs?: number }): Promise<{ ok: boolean; text: string }>
103
+ }
104
+ }
package/src/config.ts CHANGED
@@ -70,6 +70,22 @@ export type AxonConfig<EventMap extends Record<string, unknown> = Record<string,
70
70
  */
71
71
  modules?: ModuleEntry[]
72
72
 
73
+ /**
74
+ * Prompt packages to load into this agent.
75
+ *
76
+ * Each entry is a registry name — `"@cody/eslint-scout"` — auto-installed
77
+ * at `axon prepare` / `axon dev` like a module. Every top-level .vue/.md
78
+ * in the package becomes an invokable prompt, namespaced by the package
79
+ * so an installed one can never shadow the agent's own:
80
+ *
81
+ * src/prompts/scout.vue → `axon run scout`
82
+ * @cody/eslint-scout:scout → `axon run @cody/eslint-scout:scout`
83
+ *
84
+ * A prompt is the smallest shareable unit of work — an instruction, not a
85
+ * capability. Modules bring tools; prompts bring tasks.
86
+ */
87
+ prompts?: string[]
88
+
73
89
  /**
74
90
  * Opt this agent into the repository workspace layer.
75
91
  * When true, Axon discovers the nearest .agents/ directory (walking up from cwd)
package/src/connect.ts ADDED
@@ -0,0 +1,55 @@
1
+ /**
2
+ * The connect-token contract — what a caller presents to a deployed agent's
3
+ * /_axon surface, and what that agent checks.
4
+ *
5
+ * Lives in types because it is genuinely shared: the backend mints against
6
+ * this shape and the runtime verifies against it. A drift between the two is
7
+ * an outage (every caller locked out) or a hole (a claim nobody checks), so
8
+ * there is one definition and both sides import it.
9
+ *
10
+ * The token is a CAPABILITY, not an identity. It says "the bearer may do
11
+ * these things, to this one agent, until this time" — it is not the caller's
12
+ * credential and cannot be replayed against another agent or the backend.
13
+ */
14
+
15
+ /**
16
+ * What a connect token may authorize. Deliberately about the AGENT's surface,
17
+ * not the backend's — `agents:connect` (an API-key scope) is permission to
18
+ * obtain one of these; these are what it lets you do once you have it.
19
+ *
20
+ * Additive only. A token in the wild carries the scopes it was minted with,
21
+ * so removing one silently breaks live callers; widening is safe.
22
+ */
23
+ export const CONNECT_SCOPES = ["request", "stream", "read"] as const
24
+
25
+ export type ConnectScope = (typeof CONNECT_SCOPES)[number]
26
+
27
+ export function isConnectScope(value: string): value is ConnectScope {
28
+ return (CONNECT_SCOPES as readonly string[]).includes(value)
29
+ }
30
+
31
+ /**
32
+ * Everything a token grants the caller who holds it, once verified.
33
+ *
34
+ * `agent` is the audience the token was minted for. The runtime checks it
35
+ * against its OWN id: a token addressed elsewhere is refused even though its
36
+ * signature is perfectly valid, which is what stops a token for agent A being
37
+ * replayed against agent B.
38
+ */
39
+ export type ConnectGrant = {
40
+ /** The user this token acts for. */
41
+ user: string
42
+ /** The one agent it is valid against. */
43
+ agent: string
44
+ scopes: ConnectScope[]
45
+ /** Expiry, epoch seconds — carried so a client can refresh ahead of it. */
46
+ expiresAt: number
47
+ }
48
+
49
+ /** What the backend's connect-token endpoint returns. */
50
+ export type ConnectTokenResponse = {
51
+ token: string
52
+ /** Seconds until expiry. A client refreshes on roughly half of this. */
53
+ expiresIn: number
54
+ scopes: ConnectScope[]
55
+ }
package/src/define.ts CHANGED
@@ -1,8 +1,11 @@
1
1
  import type { AxonConfig } from "./config"
2
2
  import type { BenchConfig, BenchDefinition } from "./bench"
3
3
  import type { ModuleConfig, ModuleEmitMap, ModuleOptionSchema } from "./module"
4
+ import type { EventHandler } from "h3"
5
+ import type { AxonMiddleware } from "./middleware"
4
6
  import type { AxonPlugin } from "./plugin"
5
7
  import type { AxonHandle } from "./handle"
8
+ import type { PromptConfig, PromptDefinition } from "./prompts"
6
9
 
7
10
  /** Return shape produced by `defineAgent()`. */
8
11
  export type AgentDefinition<EventMap extends Record<string, unknown> = Record<string, unknown>> = {
@@ -67,38 +70,68 @@ export function defineAgent<EventMap extends Record<string, unknown> = Record<st
67
70
  /**
68
71
  * Defines a benchmark configuration.
69
72
  *
70
- * Use this as the default export from `bench.config.ts`. Declares which
71
- * control axes the harness sweeps. Tasks remain ordinary Bun tests; this
72
- * file only declares the experiment applied to them.
73
+ * Use this as the default export from `bench.config.ts`. Declares what varies
74
+ * and how many times to repeat it; the scenarios stay ordinary Bun tests.
75
+ *
76
+ * The type parameter is the measurement schema. `axon bench prepare` extracts
77
+ * it into `.bench/schema.json` — property name becomes the id, the type becomes
78
+ * the kind, the doc comment becomes the description, and `@objective` supplies
79
+ * the one thing that cannot be inferred.
80
+ *
81
+ * Identity (name, version, description) lives in `package.json`, not here.
73
82
  *
74
83
  * ```ts
75
- * export default defineBench({
76
- * description: "Software engineering tasks",
77
- * factors: [{
78
- * id: "model",
79
- * label: "Model",
80
- * kind: "model",
81
- * role: "subject",
82
- * values: [sonnet, haiku],
83
- * }],
84
- * measurements: [{
85
- * id: "correct",
86
- * label: "Correct",
87
- * description: "Whether the answer is correct",
88
- * value: { kind: "boolean" },
89
- * aggregate: "rate",
90
- * }],
91
- * trials: 5,
92
- * tests: ["tests/<glob>.bench.ts"],
84
+ * type Schema = {
85
+ * /** Has the agent resolved the bug? *\/
86
+ * resolved: boolean
87
+ *
88
+ * /** Files edited beyond the target. @objective minimize *\/
89
+ * collateral: number
90
+ * }
91
+ *
92
+ * export default defineBench<Schema>({
93
+ * workspace: { source: "./workspace", retain: "failed" },
94
+ * matrix: {
95
+ * model: [sonnet, gpt5],
96
+ * },
97
+ * trials: 3,
93
98
  * })
94
99
  * ```
95
100
  *
96
101
  * @see https://axon.arclabs.it/docs/v2/bench/config
97
102
  */
98
- export function defineBench(config: BenchConfig): BenchDefinition {
103
+ export function defineBench<Schema extends Record<string, unknown> = Record<string, never>>(
104
+ config: BenchConfig,
105
+ ): BenchDefinition {
106
+ // Schema is a compile-time declaration only — it is read from the source by
107
+ // the extractor, never from this value, because a type cannot survive to
108
+ // runtime. Referencing it here keeps the parameter from being flagged as
109
+ // unused while making that asymmetry explicit.
110
+ void 0 as unknown as Schema
99
111
  return { _kind: "bench", config }
100
112
  }
101
113
 
114
+ /**
115
+ * Defines a prompt package. The default export of `prompt.config.ts`.
116
+ *
117
+ * A prompt package is the smallest publishable thing in Axon: one or more
118
+ * units of work, shareable without wrapping them in a module. Every
119
+ * top-level `.vue`/`.md` file in the folder is an invokable prompt;
120
+ * `components/` holds the fragments they compose and is never invokable.
121
+ *
122
+ * Identity only — a prompt has no build step, no dependencies, and no
123
+ * runtime surface of its own. It is text an agent is handed.
124
+ *
125
+ * ```ts
126
+ * export default definePrompt({
127
+ * description: "Scouts a codebase and files proposals",
128
+ * })
129
+ * ```
130
+ */
131
+ export function definePrompt(config: PromptConfig): PromptDefinition {
132
+ return { _kind: "prompt", config }
133
+ }
134
+
102
135
  /**
103
136
  * Defines a reusable Axon module. The default export of `module.config.ts`.
104
137
  *
@@ -193,6 +226,37 @@ export function defineAxonPlugin(fn: (axon: AxonHandle) => void | Promise<void>)
193
226
  return { name: fn.name || "plugin", fn }
194
227
  }
195
228
 
229
+ /**
230
+ * Registers server middleware.
231
+ *
232
+ * Use this as the default export from `server/middleware/*.ts`. The handler
233
+ * runs on EVERY request, before any route, in filename order — the same
234
+ * contract Nitro gives `server/middleware/`.
235
+ *
236
+ * ```ts
237
+ * export default defineMiddleware((event) => {
238
+ * if (!getHeader(event, "authorization")) {
239
+ * throw createError({ statusCode: 401, statusMessage: "unauthorized" })
240
+ * }
241
+ * })
242
+ * ```
243
+ *
244
+ * Returning nothing lets the request continue to the next middleware and then
245
+ * the route — that is the normal case, and what makes middleware composable.
246
+ * RETURNING A VALUE ends the request with that value as the response body, so
247
+ * a middleware that wants to short-circuit (a redirect, a cached response) can
248
+ * simply return it. To reject, throw `createError(...)`.
249
+ *
250
+ * Middleware runs ahead of `server/plugins/` and the reserved `/_axon/*`
251
+ * surface alike: it is the first thing any request meets, so an auth gate
252
+ * written here genuinely covers everything.
253
+ *
254
+ * @see https://axon.arclabs.it/docs/v2/agent/server
255
+ */
256
+ export function defineMiddleware(handler: EventHandler): AxonMiddleware {
257
+ return { name: handler.name || "middleware", handler }
258
+ }
259
+
196
260
  /** Handle returned by the test-runtime spawner `Axon()`. */
197
261
  export type AxonTestHandle = {
198
262
  axon: AxonHandle
package/src/index.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from "./blueprint"
2
2
  export * from "./config"
3
+ export * from "./connect"
3
4
  export * from "./define"
4
5
  export * from "./deploy"
5
6
  export * from "./engine"
package/src/prompts.ts CHANGED
@@ -22,4 +22,22 @@ export type AxonPrompt = {
22
22
  /** Whether the prop is required. */
23
23
  required?: boolean
24
24
  }>
25
- }
25
+ }
26
+
27
+ /**
28
+ * `prompt.config.ts` — a prompt package's identity.
29
+ *
30
+ * Deliberately thin. A prompt has no dependencies, no build output and no
31
+ * runtime surface: the folder's top-level .vue/.md files ARE the artifact,
32
+ * and this only carries what the registry needs to list it.
33
+ */
34
+ export type PromptConfig = {
35
+ /** One line, shown in the registry listing and `axon prompt list`. */
36
+ description?: string
37
+ }
38
+
39
+ /** Return shape produced by `definePrompt()`. */
40
+ export type PromptDefinition = {
41
+ _kind: "prompt"
42
+ config: PromptConfig
43
+ }
@@ -24,12 +24,29 @@
24
24
  export type AxonEventContext = {
25
25
  agentId: string
26
26
  sessionId: string
27
- /** One kernel request = one runId. The unit of "what the user asked for". */
27
+ /**
28
+ * One kernel request = one runId. The unit of "what the user asked for".
29
+ * This IS the trace id — there is no separate traceId field, because in
30
+ * this system the two would always be equal and a redundant field in a
31
+ * durable format is drift waiting to happen.
32
+ */
28
33
  runId?: string
29
- /** Tracing tree — minted per run, parented per phase/system. */
30
- traceId?: string
34
+ /**
35
+ * Correlates the events of ONE logical operation that may interleave
36
+ * with a concurrent sibling. Engine calls use it (start/input/retry/
37
+ * complete share a span); nothing else needs it yet.
38
+ *
39
+ * NOT a tree — there is deliberately no parentSpanId. Nesting is
40
+ * recovered by bracket-matching `:start`/`:complete` within a run: the
41
+ * session is one file with one serialized writer (disk order IS commit
42
+ * order, `time.seq` authoritative) and the scheduler admits one wake at
43
+ * a time, so within a run there is exactly one logical thread of
44
+ * execution. "What happened inside this span" is exactly "the events
45
+ * between its start and its end, in seq order" — not an approximation
46
+ * but an exact consequence of the single-writer design. A parent
47
+ * pointer would encode information the log already contains.
48
+ */
31
49
  spanId?: string
32
- parentSpanId?: string
33
50
  }
34
51
 
35
52
  /**
@@ -1,6 +1,6 @@
1
1
  import type { BenchArtifactRef } from "../../bench/artifact"
2
2
  import type { BenchFault, BenchPhysics, BenchResourceUsage, BenchSessionRef, BenchTestRef, BenchTestStatus } from "../../bench/execution"
3
- import type { BenchCell } from "../../bench/factor"
3
+ import type { BenchCell } from "../../bench/matrix"
4
4
  import type { BenchRunManifest } from "../../bench/manifest"
5
5
  import type { BenchObservationPayload } from "../../bench/observation"
6
6
  import type { BenchCoverage } from "../../bench/result"
@@ -24,11 +24,18 @@ export type BenchEventMap = {
24
24
  "bench:run:complete": { durationMs: number; coverage: BenchCoverage }
25
25
  "bench:run:failed": { error: AxonError }
26
26
 
27
+ // A cell or trial that throws mid-loop must still close its bracket.
28
+ // Without these the run's own :failed was the only record, leaving
29
+ // cell/trial :start events permanently open — and the projection, which
30
+ // reads :complete alone, silently dropped the crashed work rather than
31
+ // reporting it as incomplete.
27
32
  "bench:cell:start": { cell: BenchCell }
28
33
  "bench:cell:complete": { durationMs: number }
34
+ "bench:cell:failed": { durationMs: number; error: AxonError }
29
35
 
30
36
  "bench:trial:start": Record<string, never>
31
37
  "bench:trial:complete": { durationMs: number; physics: BenchPhysics }
38
+ "bench:trial:failed": { durationMs: number; error: AxonError }
32
39
 
33
40
  "bench:case:declare": { test: BenchTestRef }
34
41
  "bench:case:complete": { status: BenchTestStatus; durationMs: number; error?: AxonError }