@you-agent-factory/factory-emulator 0.0.0 → 0.0.2

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.
Files changed (69) hide show
  1. package/LICENSE.md +19 -1
  2. package/README.md +305 -286
  3. package/dist/compatibility.d.ts +19 -0
  4. package/dist/compatibility.js +156 -0
  5. package/dist/event-sink.d.ts +29 -0
  6. package/dist/event-sink.js +58 -0
  7. package/dist/generated/scenario-schema.d.ts +268 -0
  8. package/dist/generated/scenario-schema.js +319 -0
  9. package/dist/index.d.ts +8 -0
  10. package/dist/index.js +8 -0
  11. package/dist/logical-move.d.ts +10 -0
  12. package/dist/logical-move.js +18 -0
  13. package/dist/recording-sink.d.ts +22 -0
  14. package/dist/recording-sink.js +122 -0
  15. package/dist/runtime-reference-conformance.d.ts +20 -0
  16. package/dist/runtime-reference-conformance.js +138 -0
  17. package/dist/runtime-reference-evidence.d.ts +9 -0
  18. package/dist/runtime-reference-evidence.js +193 -0
  19. package/dist/runtime-reference-fixtures.d.ts +7 -0
  20. package/dist/runtime-reference-fixtures.js +308 -0
  21. package/dist/runtime-reference.d.ts +48 -0
  22. package/dist/runtime-reference.js +143 -0
  23. package/dist/scenario-contracts.d.ts +81 -0
  24. package/dist/scenario-contracts.js +11 -0
  25. package/dist/scenario.d.ts +271 -0
  26. package/dist/scenario.js +333 -0
  27. package/dist/scheduler.d.ts +24 -0
  28. package/dist/scheduler.js +104 -0
  29. package/dist/session-contracts.d.ts +262 -0
  30. package/dist/session-contracts.js +74 -0
  31. package/dist/session.d.ts +4 -0
  32. package/dist/session.js +1490 -0
  33. package/dist/submission-replay.d.ts +14 -0
  34. package/dist/submission-replay.js +96 -0
  35. package/dist/submission-validation.d.ts +3 -0
  36. package/dist/submission-validation.js +113 -0
  37. package/examples/customer-support.scenario.v1.json +45 -0
  38. package/package.json +44 -22
  39. package/schema/scenario.schema.json +171 -0
  40. package/generated/factory-emulator-scenario.schema.json +0 -191
  41. package/generated/factory.schema.json +0 -2606
  42. package/src/contracts.ts +0 -41
  43. package/src/data-error.js +0 -21
  44. package/src/data-only.js +0 -208
  45. package/src/emulator.js +0 -195
  46. package/src/emulator.ts +0 -86
  47. package/src/examples.js +0 -86
  48. package/src/examples.ts +0 -11
  49. package/src/generated/factory-schema.d.ts +0 -3
  50. package/src/generated/factory-schema.js +0 -5
  51. package/src/generated/scenario-schema.d.ts +0 -4
  52. package/src/generated/scenario-schema.js +0 -6
  53. package/src/generated/scenario.ts +0 -103
  54. package/src/identity.js +0 -55
  55. package/src/index.js +0 -34
  56. package/src/index.ts +0 -102
  57. package/src/limits.js +0 -125
  58. package/src/parser.js +0 -113
  59. package/src/parser.ts +0 -56
  60. package/src/scheduler.js +0 -374
  61. package/src/semantics.js +0 -354
  62. package/src/semantics.ts +0 -38
  63. package/src/session.js +0 -1201
  64. package/src/session.ts +0 -324
  65. package/src/sinks.js +0 -118
  66. package/src/sinks.ts +0 -56
  67. package/src/support.js +0 -334
  68. package/src/support.ts +0 -15
  69. package/src/virtual-time.js +0 -36
@@ -0,0 +1,9 @@
1
+ import type { FactoryEvent } from "@you-agent-factory/client";
2
+ import type { FactoryEmulatorRuntimeReferenceProvenance, FactoryEmulatorRuntimeReferenceTick } from "./runtime-reference.js";
3
+ type FrozenEvidence = Readonly<{
4
+ provenance: FactoryEmulatorRuntimeReferenceProvenance;
5
+ ticks: readonly FactoryEmulatorRuntimeReferenceTick[];
6
+ orderedEventKinds: readonly FactoryEvent["type"][];
7
+ }>;
8
+ export declare const frozenRuntimeReferenceEvidence: Readonly<Record<string, FrozenEvidence>>;
9
+ export {};
@@ -0,0 +1,193 @@
1
+ const source = (anchor) => ({
2
+ kind: "public-documentation",
3
+ source: `docs/reference/${anchor} (pre-existing public runtime behavior documentation)`,
4
+ });
5
+ const semantics = (overrides = {}) => ({
6
+ dispatchChoices: [],
7
+ consumedWork: [],
8
+ outcomes: [],
9
+ routes: [],
10
+ terminalStates: [],
11
+ replayProjection: [],
12
+ ...overrides,
13
+ });
14
+ const tick = (logicalTick, eventKinds, values = {}) => ({
15
+ logicalTick,
16
+ eventKinds,
17
+ semantics: semantics(values),
18
+ });
19
+ const ordered = (ticks) => ticks.flatMap(({ eventKinds }) => eventKinds);
20
+ const bootstrap = () => tick(0, ["RUN_REQUEST", "INITIAL_STRUCTURE_REQUEST", "SESSION_STARTED"]);
21
+ const submitted = (projection, kinds = ["WORK_REQUEST"]) => tick(1, kinds, { replayProjection: projection });
22
+ const dispatch = (logicalTick, choices, projection, terminalStates = []) => tick(logicalTick, choices.map(() => "DISPATCH_REQUEST"), { dispatchChoices: choices, terminalStates, replayProjection: projection });
23
+ const response = (logicalTick, consumedWork, outcomes, routes, terminalStates, projection, kinds = []) => tick(logicalTick, kinds.length === 0
24
+ ? outcomes.map(() => "DISPATCH_RESPONSE")
25
+ : kinds, {
26
+ consumedWork,
27
+ outcomes,
28
+ routes,
29
+ terminalStates,
30
+ replayProjection: projection,
31
+ });
32
+ const input = ["input:task:ready"];
33
+ const parallel = ["first:task:ready", "second:task:ready"];
34
+ const contention = [
35
+ "first:task:ready",
36
+ "second:task:ready",
37
+ "third:task:ready",
38
+ ];
39
+ const dependencies = ["blocked:task:ready", "prerequisite:task:ready"];
40
+ // This is intentionally independent, literal expected evidence. Do not derive it from Factory or scenario inputs.
41
+ export const frozenRuntimeReferenceEvidence = {
42
+ "basic-execution": (() => {
43
+ const ticks = [
44
+ bootstrap(),
45
+ submitted(input),
46
+ dispatch(2, ["execute:input"], input),
47
+ response(3, ["input"], ["ACCEPTED"], ['task:done:"frozen input"'], ["task:done"], input),
48
+ ];
49
+ return {
50
+ provenance: source("workstations.md#agent_run-execution"),
51
+ ticks,
52
+ orderedEventKinds: ordered(ticks),
53
+ };
54
+ })(),
55
+ repeaters: (() => {
56
+ const ticks = [
57
+ bootstrap(),
58
+ submitted(input),
59
+ dispatch(2, ["execute:input"], input),
60
+ response(3, ["input"], ["CONTINUE"], ['task:ready:"frozen input"'], [], input),
61
+ dispatch(4, ["execute:input/execute/0"], input),
62
+ response(5, ["input"], ["ACCEPTED"], ['task:done:"frozen input"'], ["task:done"], input),
63
+ ];
64
+ return {
65
+ provenance: source("workstations.md#repeater-workstations"),
66
+ ticks,
67
+ orderedEventKinds: ordered(ticks),
68
+ };
69
+ })(),
70
+ routing: (() => {
71
+ const ticks = [
72
+ bootstrap(),
73
+ submitted(input),
74
+ dispatch(2, ["execute:input"], input),
75
+ response(3, ["input"], ["REJECTED"], ['task:failed:"frozen input"'], ["task:failed"], input),
76
+ ];
77
+ return {
78
+ provenance: source("workstations.md#topology-fields"),
79
+ ticks,
80
+ orderedEventKinds: ordered(ticks),
81
+ };
82
+ })(),
83
+ "logical-moves": (() => {
84
+ const ticks = [
85
+ bootstrap(),
86
+ submitted(input),
87
+ dispatch(2, ["execute:input"], input),
88
+ response(3, ["input"], ["ACCEPTED"], ['task:ready:"worker output"'], [], input),
89
+ response(4, ["input"], ["ACCEPTED"], ['task:done:"worker output"'], ["task:done"], input),
90
+ ];
91
+ return {
92
+ provenance: source("workstations.md#behavior-versus-type"),
93
+ ticks,
94
+ orderedEventKinds: ordered(ticks),
95
+ };
96
+ })(),
97
+ "multi-input-output": (() => {
98
+ const projection = ["input-two:task:ready", "input:task:ready"];
99
+ const ticks = [
100
+ bootstrap(),
101
+ submitted(projection),
102
+ dispatch(2, ["execute:input,input-two"], projection),
103
+ response(3, ["input", "input-two"], ["ACCEPTED"], ['task:done:"frozen input"', 'task:done:"frozen input"'], ["task:done", "task:done"], projection),
104
+ ];
105
+ return {
106
+ provenance: source("workstations.md#topology-fields"),
107
+ ticks,
108
+ orderedEventKinds: ordered(ticks),
109
+ };
110
+ })(),
111
+ propagation: (() => {
112
+ const ticks = [
113
+ bootstrap(),
114
+ submitted(input),
115
+ dispatch(2, ["execute:input"], input),
116
+ response(3, ["input"], ["ACCEPTED"], ['task:done:"frozen input"'], ["task:done"], input),
117
+ ];
118
+ return {
119
+ provenance: source("workstations.md#work-payload-propagation"),
120
+ ticks,
121
+ orderedEventKinds: ordered(ticks),
122
+ };
123
+ })(),
124
+ "parallel-dispatch": (() => {
125
+ const ticks = [
126
+ bootstrap(),
127
+ submitted(parallel),
128
+ dispatch(2, ["execute:first", "execute:second"], parallel),
129
+ response(3, ["first", "second"], ["ACCEPTED", "ACCEPTED"], ['task:done:"first frozen input"', 'task:done:"second frozen input"'], ["task:done", "task:done"], parallel),
130
+ ];
131
+ return {
132
+ provenance: source("workstations.md#agent_run-execution"),
133
+ ticks,
134
+ orderedEventKinds: ordered(ticks),
135
+ };
136
+ })(),
137
+ "simultaneous-completion": (() => {
138
+ const ticks = [
139
+ bootstrap(),
140
+ submitted(parallel),
141
+ dispatch(2, ["execute:first", "execute:second"], parallel),
142
+ response(3, ["first", "second"], ["ACCEPTED", "ACCEPTED"], ['task:done:"first frozen input"', 'task:done:"second frozen input"'], ["task:done", "task:done"], parallel),
143
+ ];
144
+ return {
145
+ provenance: source("workstations.md#agent_run-execution"),
146
+ ticks,
147
+ orderedEventKinds: ordered(ticks),
148
+ };
149
+ })(),
150
+ "resource-contention": (() => {
151
+ const ticks = [
152
+ bootstrap(),
153
+ submitted(contention),
154
+ dispatch(2, ["execute:first", "execute:third"], contention),
155
+ response(3, ["first", "third"], ["ACCEPTED", "ACCEPTED"], ['task:done:"first frozen input"', 'task:done:"third frozen input"'], ["task:done", "task:done"], contention),
156
+ dispatch(4, ["execute:second"], contention, ["task:done", "task:done"]),
157
+ response(5, ["second"], ["ACCEPTED"], ['task:done:"second frozen input"'], ["task:done", "task:done", "task:done"], contention),
158
+ ];
159
+ return {
160
+ provenance: source("workstations.md#current-contract"),
161
+ ticks,
162
+ orderedEventKinds: ordered(ticks),
163
+ };
164
+ })(),
165
+ "depends-on-release": (() => {
166
+ const ticks = [
167
+ bootstrap(),
168
+ submitted(dependencies, ["WORK_REQUEST", "RELATIONSHIP_CHANGE_REQUEST"]),
169
+ dispatch(2, ["execute:prerequisite"], dependencies),
170
+ response(3, ["prerequisite"], ["ACCEPTED"], ['task:done:"prerequisite"'], ["task:done"], dependencies),
171
+ dispatch(4, ["execute:blocked"], dependencies, ["task:done"]),
172
+ response(5, ["blocked"], ["ACCEPTED"], ['task:done:"blocked"'], ["task:done", "task:done"], dependencies),
173
+ ];
174
+ return {
175
+ provenance: source("relationships.md#depends_on"),
176
+ ticks,
177
+ orderedEventKinds: ordered(ticks),
178
+ };
179
+ })(),
180
+ "depends-on-terminal-failure": (() => {
181
+ const ticks = [
182
+ bootstrap(),
183
+ submitted(dependencies, ["WORK_REQUEST", "RELATIONSHIP_CHANGE_REQUEST"]),
184
+ dispatch(2, ["execute:prerequisite"], dependencies),
185
+ response(3, ["prerequisite"], ["FAILED"], ['task:failed:"prerequisite"'], ["task:failed", "task:failed"], dependencies, ["DISPATCH_RESPONSE", "WORK_STATE_CHANGE"]),
186
+ ];
187
+ return {
188
+ provenance: source("relationships.md#depends_on"),
189
+ ticks,
190
+ orderedEventKinds: ordered(ticks),
191
+ };
192
+ })(),
193
+ };
@@ -0,0 +1,7 @@
1
+ import type { FactoryEmulatorRuntimeReference } from "./runtime-reference.js";
2
+ /**
3
+ * Factories and scenarios are executable inputs; expected evidence lives in a
4
+ * separate immutable declaration so changing either input cannot recompute a
5
+ * passing expectation.
6
+ */
7
+ export declare const runtimeReferenceFixtures: readonly FactoryEmulatorRuntimeReference[];
@@ -0,0 +1,308 @@
1
+ import { frozenRuntimeReferenceEvidence } from "./runtime-reference-evidence.js";
2
+ function cloneFactory(factory) {
3
+ return JSON.parse(JSON.stringify(factory));
4
+ }
5
+ function firstWorkstation(factory) {
6
+ const workstation = factory.workstations?.[0];
7
+ if (workstation === undefined) {
8
+ throw new Error("Frozen runtime-reference Factory requires a workstation.");
9
+ }
10
+ return workstation;
11
+ }
12
+ function scenario(id, factoryName, workstation) {
13
+ return {
14
+ schemaVersion: "factory-emulator-scenario/v1",
15
+ id,
16
+ factory: { name: factoryName },
17
+ seed: `${id}-seed`,
18
+ startAt: "2026-07-18T16:00:00.000Z",
19
+ initialSubmissions: [
20
+ {
21
+ name: "input",
22
+ workType: "task",
23
+ state: "ready",
24
+ input: "frozen input",
25
+ },
26
+ ],
27
+ rules: [
28
+ {
29
+ id: "accepted",
30
+ selector: { workstation },
31
+ cursor: { scope: "lineage", input: "rootWorkId" },
32
+ outcomes: [{ result: "accepted", durationMs: 1 }],
33
+ exhaustion: "repeat-last",
34
+ },
35
+ ],
36
+ unmatched: { behavior: "error" },
37
+ };
38
+ }
39
+ function standardFactory(name, workstation = "execute") {
40
+ return {
41
+ name,
42
+ orchestrator: { kind: "PETRI" },
43
+ workTypes: [
44
+ {
45
+ name: "task",
46
+ states: [
47
+ { name: "ready", type: "INITIAL" },
48
+ { name: "done", type: "TERMINAL" },
49
+ { name: "failed", type: "FAILED" },
50
+ ],
51
+ },
52
+ ],
53
+ workers: [{ name: "worker", type: "AGENT_WORKER" }],
54
+ workstations: [
55
+ {
56
+ name: workstation,
57
+ type: "AGENT_RUN",
58
+ worker: "worker",
59
+ inputs: [{ workType: "task", state: "ready" }],
60
+ outputs: [{ workType: "task", state: "done" }],
61
+ onFailure: [{ workType: "task", state: "failed" }],
62
+ },
63
+ ],
64
+ };
65
+ }
66
+ function scenarioWithOutcome(id, factoryName, workstation, outcome) {
67
+ const base = scenario(id, factoryName, workstation);
68
+ const [rule] = base.rules;
69
+ if (rule === undefined)
70
+ throw new Error("Frozen reference needs a rule.");
71
+ return { ...base, rules: [{ ...rule, outcomes: [outcome] }] };
72
+ }
73
+ function concurrentScenario(id, factoryName, submissions) {
74
+ return {
75
+ ...scenario(id, factoryName, "execute"),
76
+ initialSubmissions: submissions.map((name) => ({
77
+ name,
78
+ workType: "task",
79
+ state: "ready",
80
+ input: `${name} frozen input`,
81
+ })),
82
+ };
83
+ }
84
+ function dependencyInput(id, title, prerequisiteOutcome) {
85
+ const factory = standardFactory(`runtime-reference-${id}`);
86
+ return {
87
+ id,
88
+ title,
89
+ factory,
90
+ scenario: {
91
+ ...scenario(id, factory.name, "execute"),
92
+ initialSubmissions: {
93
+ works: [
94
+ {
95
+ name: "blocked",
96
+ workType: "task",
97
+ state: "ready",
98
+ input: "blocked",
99
+ },
100
+ {
101
+ name: "prerequisite",
102
+ workType: "task",
103
+ state: "ready",
104
+ input: "prerequisite",
105
+ },
106
+ ],
107
+ relations: [
108
+ {
109
+ type: "DEPENDS_ON",
110
+ sourceWorkName: "blocked",
111
+ targetWorkName: "prerequisite",
112
+ requiredState: "done",
113
+ },
114
+ ],
115
+ },
116
+ rules: [
117
+ {
118
+ id: "prerequisite-outcome",
119
+ selector: { input: { name: "prerequisite" } },
120
+ cursor: { scope: "lineage", input: "rootWorkId" },
121
+ outcomes: [
122
+ prerequisiteOutcome === "accepted"
123
+ ? { result: "accepted", durationMs: 1 }
124
+ : {
125
+ result: "failed",
126
+ durationMs: 1,
127
+ error: "prerequisite failed",
128
+ },
129
+ ],
130
+ exhaustion: "repeat-last",
131
+ },
132
+ {
133
+ id: "blocked-outcome",
134
+ selector: { input: { name: "blocked" } },
135
+ cursor: { scope: "lineage", input: "rootWorkId" },
136
+ outcomes: [{ result: "accepted", durationMs: 1 }],
137
+ exhaustion: "repeat-last",
138
+ },
139
+ ],
140
+ },
141
+ };
142
+ }
143
+ const basic = standardFactory("runtime-reference-basic");
144
+ const repeater = cloneFactory(standardFactory("runtime-reference-repeater"));
145
+ firstWorkstation(repeater).behavior = "REPEATER";
146
+ firstWorkstation(repeater).onContinue = [{ workType: "task", state: "ready" }];
147
+ const repeaterScenario = scenario("repeaters", repeater.name, "execute");
148
+ const [repeaterRule] = repeaterScenario.rules;
149
+ if (repeaterRule === undefined) {
150
+ throw new Error("Frozen repeater reference needs a rule.");
151
+ }
152
+ const routing = cloneFactory(standardFactory("runtime-reference-routing"));
153
+ firstWorkstation(routing).onRejection = [{ workType: "task", state: "failed" }];
154
+ const propagation = cloneFactory(standardFactory("runtime-reference-propagation"));
155
+ firstWorkstation(propagation).workPropagation = { mode: "PRESERVE_INPUT" };
156
+ const multiInputOutput = cloneFactory(standardFactory("runtime-reference-multi-input-output"));
157
+ const multiInputOutputWorkstation = firstWorkstation(multiInputOutput);
158
+ multiInputOutputWorkstation.inputs.push({ workType: "task", state: "ready" });
159
+ if (multiInputOutputWorkstation.outputs === undefined) {
160
+ throw new Error("Frozen multi-output reference requires an output route.");
161
+ }
162
+ multiInputOutputWorkstation.outputs.push({ workType: "task", state: "done" });
163
+ const multiInputOutputScenario = scenario("multi-input-output", multiInputOutput.name, "execute");
164
+ if (!Array.isArray(multiInputOutputScenario.initialSubmissions)) {
165
+ throw new Error("Frozen multi-input reference requires direct submissions.");
166
+ }
167
+ multiInputOutputScenario.initialSubmissions.push({
168
+ name: "input-two",
169
+ workType: "task",
170
+ state: "ready",
171
+ input: "second frozen input",
172
+ });
173
+ const logicalMove = cloneFactory(standardFactory("runtime-reference-logical-move", "move"));
174
+ const logicalMoveWorkstations = logicalMove.workstations;
175
+ if (logicalMoveWorkstations === undefined) {
176
+ throw new Error("Frozen logical-move reference requires a workstation.");
177
+ }
178
+ logicalMoveWorkstations[0] = {
179
+ name: "execute",
180
+ type: "AGENT_RUN",
181
+ worker: "worker",
182
+ inputs: [{ workType: "task", state: "ready" }],
183
+ outputs: [{ workType: "task", state: "ready" }],
184
+ };
185
+ logicalMoveWorkstations.push({
186
+ name: "move",
187
+ type: "LOGICAL_MOVE",
188
+ worker: "",
189
+ inputs: [{ workType: "task", state: "ready" }],
190
+ outputs: [{ workType: "task", state: "done" }],
191
+ guards: [{ type: "VISIT_COUNT", workstation: "execute", maxVisits: 1 }],
192
+ workPropagation: { mode: "PRESERVE_INPUT" },
193
+ });
194
+ const parallel = cloneFactory(standardFactory("runtime-reference-parallel"));
195
+ const contention = cloneFactory(standardFactory("runtime-reference-resource-contention"));
196
+ contention.resources = [{ name: "agent-slot", capacity: 2 }];
197
+ firstWorkstation(contention).resources = [{ name: "agent-slot", capacity: 1 }];
198
+ const runtimeReferenceInputs = [
199
+ {
200
+ id: "basic-execution",
201
+ title: "Basic execution",
202
+ factory: basic,
203
+ scenario: scenario("basic-execution", basic.name, "execute"),
204
+ },
205
+ {
206
+ id: "repeaters",
207
+ title: "Repeater continuation",
208
+ factory: repeater,
209
+ scenario: {
210
+ ...repeaterScenario,
211
+ rules: [
212
+ {
213
+ ...repeaterRule,
214
+ outcomes: [
215
+ { result: "continued", durationMs: 1 },
216
+ { result: "accepted", durationMs: 1 },
217
+ ],
218
+ },
219
+ ],
220
+ },
221
+ },
222
+ {
223
+ id: "routing",
224
+ title: "Outcome routing",
225
+ factory: routing,
226
+ scenario: scenarioWithOutcome("routing", routing.name, "execute", {
227
+ result: "rejected",
228
+ durationMs: 1,
229
+ }),
230
+ },
231
+ {
232
+ id: "logical-moves",
233
+ title: "Logical move",
234
+ factory: logicalMove,
235
+ scenario: scenarioWithOutcome("logical-moves", logicalMove.name, "execute", {
236
+ result: "accepted",
237
+ durationMs: 1,
238
+ output: "worker output",
239
+ }),
240
+ },
241
+ {
242
+ id: "multi-input-output",
243
+ title: "Multi-input and multi-output",
244
+ factory: multiInputOutput,
245
+ scenario: multiInputOutputScenario,
246
+ },
247
+ {
248
+ id: "propagation",
249
+ title: "Work propagation",
250
+ factory: propagation,
251
+ scenario: scenarioWithOutcome("propagation", propagation.name, "execute", {
252
+ result: "accepted",
253
+ durationMs: 1,
254
+ output: "worker output",
255
+ }),
256
+ },
257
+ {
258
+ id: "parallel-dispatch",
259
+ title: "Parallel dispatch",
260
+ factory: parallel,
261
+ scenario: concurrentScenario("parallel-dispatch", parallel.name, [
262
+ "first",
263
+ "second",
264
+ ]),
265
+ },
266
+ {
267
+ id: "simultaneous-completion",
268
+ title: "Simultaneous completion",
269
+ factory: cloneFactory(parallel),
270
+ scenario: concurrentScenario("simultaneous-completion", parallel.name, [
271
+ "first",
272
+ "second",
273
+ ]),
274
+ },
275
+ {
276
+ id: "resource-contention",
277
+ title: "Resource contention",
278
+ factory: contention,
279
+ scenario: concurrentScenario("resource-contention", contention.name, [
280
+ "first",
281
+ "second",
282
+ "third",
283
+ ]),
284
+ },
285
+ dependencyInput("depends-on-release", "DEPENDS_ON prerequisite release", "accepted"),
286
+ dependencyInput("depends-on-terminal-failure", "DEPENDS_ON terminal failure cascade", "failed"),
287
+ ];
288
+ /**
289
+ * Factories and scenarios are executable inputs; expected evidence lives in a
290
+ * separate immutable declaration so changing either input cannot recompute a
291
+ * passing expectation.
292
+ */
293
+ export const runtimeReferenceFixtures = runtimeReferenceInputs.map(({ id, title, factory, scenario }) => {
294
+ const evidence = frozenRuntimeReferenceEvidence[id];
295
+ if (evidence === undefined) {
296
+ throw new Error(`Missing frozen runtime-reference evidence for ${id}.`);
297
+ }
298
+ return {
299
+ schemaVersion: "factory-emulator-runtime-reference/v1",
300
+ id,
301
+ title,
302
+ provenance: evidence.provenance,
303
+ factory,
304
+ scenario,
305
+ ticks: evidence.ticks,
306
+ orderedEventKinds: evidence.orderedEventKinds,
307
+ };
308
+ });
@@ -0,0 +1,48 @@
1
+ import type { FactoryDefinition, FactoryEvent } from "@you-agent-factory/client";
2
+ import { type FactoryEmulatorScenario } from "./scenario.js";
3
+ export declare const FACTORY_EMULATOR_RUNTIME_REFERENCE_SCHEMA_VERSION: "factory-emulator-runtime-reference/v1";
4
+ export interface FactoryEmulatorRuntimeReferenceProvenance {
5
+ readonly source: string;
6
+ readonly kind: "public-behavior" | "public-documentation" | "public-recording";
7
+ }
8
+ export interface FactoryEmulatorRuntimeReferenceTick {
9
+ readonly logicalTick: number;
10
+ readonly eventKinds: readonly FactoryEvent["type"][];
11
+ readonly semantics: FactoryEmulatorRuntimeReferenceSemantics;
12
+ }
13
+ /** Stable, identity- and time-normalized evidence observed after one logical tick. */
14
+ export interface FactoryEmulatorRuntimeReferenceSemantics {
15
+ readonly dispatchChoices: readonly string[];
16
+ readonly consumedWork: readonly string[];
17
+ readonly outcomes: readonly string[];
18
+ readonly routes: readonly string[];
19
+ readonly terminalStates: readonly string[];
20
+ readonly replayProjection: readonly string[];
21
+ }
22
+ export interface FactoryEmulatorRuntimeReference {
23
+ readonly schemaVersion: typeof FACTORY_EMULATOR_RUNTIME_REFERENCE_SCHEMA_VERSION;
24
+ readonly id: string;
25
+ readonly title: string;
26
+ readonly provenance: FactoryEmulatorRuntimeReferenceProvenance;
27
+ readonly factory: FactoryDefinition;
28
+ readonly scenario: FactoryEmulatorScenario;
29
+ readonly ticks: readonly FactoryEmulatorRuntimeReferenceTick[];
30
+ readonly orderedEventKinds: readonly FactoryEvent["type"][];
31
+ }
32
+ export type FactoryEmulatorRuntimeReferenceIssueCode = "invalid_factory" | "invalid_provenance" | "invalid_schema_version" | "invalid_tick_order" | "invalid_value" | "missing_required_data" | "missing_semantics" | "unexpected_event_kind";
33
+ export interface FactoryEmulatorRuntimeReferenceIssue {
34
+ readonly code: FactoryEmulatorRuntimeReferenceIssueCode;
35
+ readonly path: readonly (string | number)[];
36
+ readonly message: string;
37
+ }
38
+ export type SafeParseFactoryEmulatorRuntimeReferenceResult = {
39
+ readonly success: true;
40
+ readonly data: FactoryEmulatorRuntimeReference;
41
+ } | {
42
+ readonly success: false;
43
+ readonly issues: readonly FactoryEmulatorRuntimeReferenceIssue[];
44
+ };
45
+ /** Validates frozen, package-local evidence before a conformance comparison starts. */
46
+ export declare function safeParseFactoryEmulatorRuntimeReference(input: unknown): SafeParseFactoryEmulatorRuntimeReferenceResult;
47
+ /** Returns detached validated fixtures in their frozen package declaration order. */
48
+ export declare function loadFactoryEmulatorRuntimeReferences(): readonly FactoryEmulatorRuntimeReference[];