@usine/core 0.1.0 → 0.2.0

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 (120) hide show
  1. package/README.md +28 -22
  2. package/dist/agent/agent.d.ts +27 -0
  3. package/dist/agent/agent.d.ts.map +1 -0
  4. package/dist/agent/agent.js +26 -0
  5. package/dist/agent/agent.js.map +1 -0
  6. package/dist/agent/brain.d.ts +24 -0
  7. package/dist/agent/brain.d.ts.map +1 -0
  8. package/dist/agent/brain.js +19 -0
  9. package/dist/agent/brain.js.map +1 -0
  10. package/dist/agent/capability.d.ts +23 -0
  11. package/dist/agent/capability.d.ts.map +1 -0
  12. package/dist/agent/capability.js +19 -0
  13. package/dist/agent/capability.js.map +1 -0
  14. package/dist/{agent.d.ts → agent/session.d.ts} +34 -50
  15. package/dist/agent/session.d.ts.map +1 -0
  16. package/dist/agent/session.js +93 -0
  17. package/dist/agent/session.js.map +1 -0
  18. package/dist/attempt/attempt.d.ts +41 -0
  19. package/dist/attempt/attempt.d.ts.map +1 -0
  20. package/dist/attempt/attempt.js +36 -0
  21. package/dist/attempt/attempt.js.map +1 -0
  22. package/dist/{attempt-channel.d.ts → attempt/channel.d.ts} +28 -32
  23. package/dist/attempt/channel.d.ts.map +1 -0
  24. package/dist/{attempt-channel.js → attempt/channel.js} +25 -26
  25. package/dist/attempt/channel.js.map +1 -0
  26. package/dist/attempt/failure.d.ts +52 -0
  27. package/dist/attempt/failure.d.ts.map +1 -0
  28. package/dist/attempt/failure.js +48 -0
  29. package/dist/attempt/failure.js.map +1 -0
  30. package/dist/attempt/outcome.d.ts +20 -0
  31. package/dist/attempt/outcome.d.ts.map +1 -0
  32. package/dist/attempt/outcome.js +16 -0
  33. package/dist/attempt/outcome.js.map +1 -0
  34. package/dist/cycle-budget.d.ts +38 -0
  35. package/dist/cycle-budget.d.ts.map +1 -0
  36. package/dist/cycle-budget.js +46 -0
  37. package/dist/cycle-budget.js.map +1 -0
  38. package/dist/{lifecycle/event.d.ts → event.d.ts} +6 -11
  39. package/dist/event.d.ts.map +1 -0
  40. package/dist/event.js +21 -0
  41. package/dist/event.js.map +1 -0
  42. package/dist/instance.d.ts +3 -7
  43. package/dist/instance.d.ts.map +1 -1
  44. package/dist/instance.js +2 -6
  45. package/dist/instance.js.map +1 -1
  46. package/dist/item.d.ts +8 -0
  47. package/dist/item.d.ts.map +1 -0
  48. package/dist/item.js +6 -0
  49. package/dist/item.js.map +1 -0
  50. package/dist/loop.d.ts +9 -0
  51. package/dist/loop.d.ts.map +1 -0
  52. package/dist/loop.js +7 -0
  53. package/dist/loop.js.map +1 -0
  54. package/dist/repository.d.ts +12 -17
  55. package/dist/repository.d.ts.map +1 -1
  56. package/dist/repository.js +11 -16
  57. package/dist/repository.js.map +1 -1
  58. package/dist/run/run.d.ts +16 -0
  59. package/dist/run/run.d.ts.map +1 -0
  60. package/dist/run/run.js +16 -0
  61. package/dist/run/run.js.map +1 -0
  62. package/dist/run/state.d.ts +114 -0
  63. package/dist/run/state.d.ts.map +1 -0
  64. package/dist/run/state.js +102 -0
  65. package/dist/run/state.js.map +1 -0
  66. package/dist/{step-result.d.ts → step/result.d.ts} +7 -9
  67. package/dist/step/result.d.ts.map +1 -0
  68. package/dist/{step-result.js → step/result.js} +8 -10
  69. package/dist/step/result.js.map +1 -0
  70. package/dist/step/step.d.ts +21 -0
  71. package/dist/step/step.d.ts.map +1 -0
  72. package/dist/step/step.js +19 -0
  73. package/dist/step/step.js.map +1 -0
  74. package/dist/worker.d.ts +7 -7
  75. package/dist/worker.d.ts.map +1 -1
  76. package/dist/worker.js +5 -5
  77. package/dist/worker.js.map +1 -1
  78. package/package.json +76 -4
  79. package/dist/agent.d.ts.map +0 -1
  80. package/dist/agent.js +0 -105
  81. package/dist/agent.js.map +0 -1
  82. package/dist/attempt-channel.d.ts.map +0 -1
  83. package/dist/attempt-channel.js.map +0 -1
  84. package/dist/index.d.ts +0 -24
  85. package/dist/index.d.ts.map +0 -1
  86. package/dist/index.js +0 -24
  87. package/dist/index.js.map +0 -1
  88. package/dist/lifecycle/attempt-failure.d.ts +0 -51
  89. package/dist/lifecycle/attempt-failure.d.ts.map +0 -1
  90. package/dist/lifecycle/attempt-failure.js +0 -45
  91. package/dist/lifecycle/attempt-failure.js.map +0 -1
  92. package/dist/lifecycle/attempt.d.ts +0 -61
  93. package/dist/lifecycle/attempt.d.ts.map +0 -1
  94. package/dist/lifecycle/attempt.js +0 -52
  95. package/dist/lifecycle/attempt.js.map +0 -1
  96. package/dist/lifecycle/event.d.ts.map +0 -1
  97. package/dist/lifecycle/event.js +0 -26
  98. package/dist/lifecycle/event.js.map +0 -1
  99. package/dist/lifecycle/item.d.ts +0 -11
  100. package/dist/lifecycle/item.d.ts.map +0 -1
  101. package/dist/lifecycle/item.js +0 -9
  102. package/dist/lifecycle/item.js.map +0 -1
  103. package/dist/lifecycle/loop.d.ts +0 -17
  104. package/dist/lifecycle/loop.d.ts.map +0 -1
  105. package/dist/lifecycle/loop.js +0 -15
  106. package/dist/lifecycle/loop.js.map +0 -1
  107. package/dist/lifecycle/run-state.d.ts +0 -133
  108. package/dist/lifecycle/run-state.d.ts.map +0 -1
  109. package/dist/lifecycle/run-state.js +0 -126
  110. package/dist/lifecycle/run-state.js.map +0 -1
  111. package/dist/lifecycle/run.d.ts +0 -22
  112. package/dist/lifecycle/run.d.ts.map +0 -1
  113. package/dist/lifecycle/run.js +0 -22
  114. package/dist/lifecycle/run.js.map +0 -1
  115. package/dist/lifecycle/step.d.ts +0 -23
  116. package/dist/lifecycle/step.d.ts.map +0 -1
  117. package/dist/lifecycle/step.js +0 -21
  118. package/dist/lifecycle/step.js.map +0 -1
  119. package/dist/step-result.d.ts.map +0 -1
  120. package/dist/step-result.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"loop.d.ts","sourceRoot":"","sources":["../../src/lifecycle/loop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC;;;;GAIG;AACH,eAAO,MAAM,QAAQ,iDAAuD,CAAC;AAC7E,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC,IAAI,CAAC;AAE5C;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,YAAI,MAAM,EAAE,UAAU,CAAU,CAAC;AACnE,eAAO,MAAM,mBAAmB,gDAAyC,CAAC;AAC1E,MAAM,MAAM,mBAAmB,GAAG,OAAO,mBAAmB,CAAC,IAAI,CAAC"}
@@ -1,15 +0,0 @@
1
- import { Schema } from "effect";
2
- /**
3
- * Value object (branded id): loop identity — the loop file's name in the instance repo. Filename is
4
- * identity — renaming the file retires one loop and creates another
5
- * (ADR 0001).
6
- */
7
- export const LoopName = Schema.NonEmptyString.pipe(Schema.brand("LoopName"));
8
- /**
9
- * Value object: whether a loop parks new runs until an approval Event arrives
10
- * (ADR 0004's `approval:` field, default none). One owner for the literal set
11
- * the config parser accepts and the engine routes on.
12
- */
13
- export const APPROVAL_REQUIREMENTS = ["none", "required"];
14
- export const ApprovalRequirement = Schema.Literals(APPROVAL_REQUIREMENTS);
15
- //# sourceMappingURL=loop.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"loop.js","sourceRoot":"","sources":["../../src/lifecycle/loop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC;;;;GAIG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;AAG7E;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,MAAM,EAAE,UAAU,CAAU,CAAC;AACnE,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC,QAAQ,CAAC,qBAAqB,CAAC,CAAC"}
@@ -1,133 +0,0 @@
1
- /**
2
- * The run state machine (ADR 0002):
3
- *
4
- * pending ──────────────► running ──► succeeded
5
- * │ ▲ │
6
- * ▼ │ ▼
7
- * waiting ────────────────┘ failed ──► (retry: attempt N+1) ──► running
8
- *
9
- * pending | waiting | running ──► canceled (operator cancel)
10
- * pending | waiting ──► canceled (supersede, revoke — a started
11
- * attempt always finishes, ADR 0007)
12
- *
13
- * States are value objects (a discriminated union, each state carrying exactly
14
- * its own data). Transitions are typestate derivers: each function accepts
15
- * only the states it is legal on, so an illegal transition is a compile
16
- * error. Construct states through these transitions (or by parsing a stored
17
- * row via the `RunState` union) — they are the state machine.
18
- */
19
- import { Schema } from "effect";
20
- import { EventId } from "./event.ts";
21
- declare const OperatorCanceled_base: Schema.Class<OperatorCanceled, Schema.TaggedStruct<"OperatorCanceled", {}>, {}>;
22
- /** Cancel reason — value object: the operator closed the run by hand. */
23
- export declare class OperatorCanceled extends OperatorCanceled_base {
24
- }
25
- declare const Superseded_base: Schema.Class<Superseded, Schema.TaggedStruct<"Superseded", {
26
- readonly by: Schema.brand<Schema.NonEmptyString, "EventId">;
27
- }>, {}>;
28
- /**
29
- * Cancel reason — value object: a newer Event for the same Item took the
30
- * run's place before any attempt started.
31
- */
32
- export declare class Superseded extends Superseded_base {
33
- }
34
- declare const Revoked_base: Schema.Class<Revoked, Schema.TaggedStruct<"Revoked", {}>, {}>;
35
- /**
36
- * Cancel reason — value object: the run's Item stopped matching its loop's
37
- * trigger before any attempt started. Distinct from operator cancel and from
38
- * supersede.
39
- */
40
- export declare class Revoked extends Revoked_base {
41
- }
42
- export declare const CancelReason: Schema.Union<readonly [typeof OperatorCanceled, typeof Superseded, typeof Revoked]>;
43
- export type CancelReason = typeof CancelReason.Type;
44
- declare const Pending_base: Schema.Class<Pending, Schema.TaggedStruct<"Pending", {}>, {}>;
45
- /** Open: just created; no attempt started, no approval gate passed. */
46
- export declare class Pending extends Pending_base {
47
- }
48
- declare const Waiting_base: Schema.Class<Waiting, Schema.TaggedStruct<"Waiting", {}>, {}>;
49
- /**
50
- * Open: parked on its loop's approval gate — v1's only waiting reason. The
51
- * approval it consumes is an Event like every other fact.
52
- */
53
- export declare class Waiting extends Waiting_base {
54
- }
55
- declare const Running_base: Schema.Class<Running, Schema.TaggedStruct<"Running", {}>, {}>;
56
- /** Open: an attempt is executing on a worker. */
57
- export declare class Running extends Running_base {
58
- }
59
- declare const Succeeded_base: Schema.Class<Succeeded, Schema.TaggedStruct<"Succeeded", {}>, {}>;
60
- /** Closed: the step finished and its result is stored. */
61
- export declare class Succeeded extends Succeeded_base {
62
- }
63
- declare const Failed_base: Schema.Class<Failed, Schema.TaggedStruct<"Failed", {}>, {}>;
64
- /**
65
- * Closed, but reopenable: the last attempt failed and no auto-retry applies.
66
- * The failure itself lives on the Attempt.
67
- */
68
- export declare class Failed extends Failed_base {
69
- }
70
- declare const Canceled_base: Schema.Class<Canceled, Schema.TaggedStruct<"Canceled", {
71
- readonly reason: Schema.Union<readonly [typeof OperatorCanceled, typeof Superseded, typeof Revoked]>;
72
- }>, {}>;
73
- /** Closed: canceled, with the reason recorded. */
74
- export declare class Canceled extends Canceled_base {
75
- }
76
- /**
77
- * The open half of the machine — the single statement of the open/closed
78
- * partition; the alias, the guard, and the full union all derive from it.
79
- */
80
- export declare const Open: Schema.Union<readonly [typeof Pending, typeof Waiting, typeof Running]>;
81
- export type Open = typeof Open.Type;
82
- export declare const RunState: Schema.Union<readonly [typeof Pending, typeof Waiting, typeof Running, typeof Succeeded, typeof Failed, typeof Canceled]>;
83
- export type RunState = typeof RunState.Type;
84
- export declare const isOpen: <I>(input: I) => input is I & (Pending | Running | Waiting);
85
- /** The open partition as `_tag` literals, for queries that filter stored rows by state. */
86
- export declare const OPEN_STATE_TAGS: readonly ["Pending", "Waiting", "Running"];
87
- /** Every state as `_tag` literals, for read models that project stored rows by state. */
88
- export declare const STATE_TAGS: readonly ["Pending", "Waiting", "Running", "Succeeded", "Failed", "Canceled"];
89
- /**
90
- * The states with no started attempt, as `_tag` literals — the precondition
91
- * of `supersede` and `revoke`, for queries that filter stored rows by state.
92
- */
93
- export declare const UNSTARTED_STATE_TAGS: readonly ["Pending", "Waiting"];
94
- /** pending → waiting: park the run on its loop's approval gate. */
95
- export declare const awaitApproval: (_state: Pending) => Waiting;
96
- /**
97
- * pending | waiting → running: the first attempt starts. From waiting, the
98
- * engine consumes the approval Event that opens the gate.
99
- */
100
- export declare const start: (_state: Pending | Waiting) => Running;
101
- /** running → succeeded: the attempt finished and the step result is stored. */
102
- export declare const succeed: (_state: Running) => Succeeded;
103
- /**
104
- * running → failed: the attempt failed and no auto-retry applies — the engine
105
- * discharges that precondition with `Attempt.shouldAutoRetry`, the one owner
106
- * of the auto-retry law.
107
- */
108
- export declare const fail: (_state: Running) => Failed;
109
- /**
110
- * failed → running: operator retry. The next try is a new Attempt (N+1) under
111
- * the same Step, never a new run.
112
- */
113
- export declare const retry: (_state: Failed) => Running;
114
- /**
115
- * open → canceled: the operator's act, reachable from every open state —
116
- * named by cause like its siblings; supersede and revoke are the other two
117
- * roads into Canceled.
118
- */
119
- export declare const cancelByOperator: (_state: Open) => Canceled;
120
- /**
121
- * pending | waiting → canceled: a newer Event for the same Item takes this
122
- * run's place. Only runs with no started attempt can be superseded — a running
123
- * attempt always finishes, and the newer state is judged again when it ends
124
- * (ADR 0007).
125
- */
126
- export declare const supersede: (_state: Pending | Waiting, by: EventId) => Canceled;
127
- /**
128
- * pending | waiting → canceled: the run's Item stopped matching its loop's
129
- * trigger. Never touches a running attempt.
130
- */
131
- export declare const revoke: (_state: Pending | Waiting) => Canceled;
132
- export {};
133
- //# sourceMappingURL=run-state.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"run-state.d.ts","sourceRoot":"","sources":["../../src/lifecycle/run-state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;;AAErC,yEAAyE;AACzE,qBAAa,gBAAi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E;;;;GAIG;AACH,eAAO,MAAM,IAAI,WAAY,OAAO,KAAG,MAAsB,CAAC;AAE9D;;;GAGG;AACH,eAAO,MAAM,KAAK,WAAY,MAAM,KAAG,OAAwB,CAAC;AAEhE;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,WAAY,IAAI,KAAG,QACE,CAAC;AAEnD;;;;;GAKG;AACH,eAAO,MAAM,SAAS,WAAY,OAAO,GAAG,OAAO,MAAM,OAAO,KAAG,QACjB,CAAC;AAEnD;;;GAGG;AACH,eAAO,MAAM,MAAM,WAAY,OAAO,GAAG,OAAO,KAAG,QACV,CAAC"}
@@ -1,126 +0,0 @@
1
- /**
2
- * The run state machine (ADR 0002):
3
- *
4
- * pending ──────────────► running ──► succeeded
5
- * │ ▲ │
6
- * ▼ │ ▼
7
- * waiting ────────────────┘ failed ──► (retry: attempt N+1) ──► running
8
- *
9
- * pending | waiting | running ──► canceled (operator cancel)
10
- * pending | waiting ──► canceled (supersede, revoke — a started
11
- * attempt always finishes, ADR 0007)
12
- *
13
- * States are value objects (a discriminated union, each state carrying exactly
14
- * its own data). Transitions are typestate derivers: each function accepts
15
- * only the states it is legal on, so an illegal transition is a compile
16
- * error. Construct states through these transitions (or by parsing a stored
17
- * row via the `RunState` union) — they are the state machine.
18
- */
19
- import { Schema } from "effect";
20
- import { EventId } from "./event.js";
21
- /** Cancel reason — value object: the operator closed the run by hand. */
22
- export class OperatorCanceled extends Schema.TaggedClass("CancelReason/OperatorCanceled")("OperatorCanceled", {}) {
23
- }
24
- /**
25
- * Cancel reason — value object: a newer Event for the same Item took the
26
- * run's place before any attempt started.
27
- */
28
- export class Superseded extends Schema.TaggedClass("CancelReason/Superseded")("Superseded", { by: EventId }) {
29
- }
30
- /**
31
- * Cancel reason — value object: the run's Item stopped matching its loop's
32
- * trigger before any attempt started. Distinct from operator cancel and from
33
- * supersede.
34
- */
35
- export class Revoked extends Schema.TaggedClass("CancelReason/Revoked")("Revoked", {}) {
36
- }
37
- export const CancelReason = Schema.Union([OperatorCanceled, Superseded, Revoked]);
38
- /** Open: just created; no attempt started, no approval gate passed. */
39
- export class Pending extends Schema.TaggedClass("RunState/Pending")("Pending", {}) {
40
- }
41
- /**
42
- * Open: parked on its loop's approval gate — v1's only waiting reason. The
43
- * approval it consumes is an Event like every other fact.
44
- */
45
- export class Waiting extends Schema.TaggedClass("RunState/Waiting")("Waiting", {}) {
46
- }
47
- /** Open: an attempt is executing on a worker. */
48
- export class Running extends Schema.TaggedClass("RunState/Running")("Running", {}) {
49
- }
50
- /** Closed: the step finished and its result is stored. */
51
- export class Succeeded extends Schema.TaggedClass("RunState/Succeeded")("Succeeded", {}) {
52
- }
53
- /**
54
- * Closed, but reopenable: the last attempt failed and no auto-retry applies.
55
- * The failure itself lives on the Attempt.
56
- */
57
- export class Failed extends Schema.TaggedClass("RunState/Failed")("Failed", {}) {
58
- }
59
- /** Closed: canceled, with the reason recorded. */
60
- export class Canceled extends Schema.TaggedClass("RunState/Canceled")("Canceled", {
61
- reason: CancelReason,
62
- }) {
63
- }
64
- /**
65
- * The open half of the machine — the single statement of the open/closed
66
- * partition; the alias, the guard, and the full union all derive from it.
67
- */
68
- export const Open = Schema.Union([Pending, Waiting, Running]);
69
- export const RunState = Schema.Union([...Open.members, Succeeded, Failed, Canceled]);
70
- export const isOpen = Schema.is(Open);
71
- /**
72
- * Compile-checked tag tuple over a state partition: the argument list must
73
- * name every `_tag` of `State` and nothing else. A foreign tag fails the
74
- * `Tags` constraint; a missing tag collapses the parameters to `[never]`, so
75
- * the call stops compiling. This keeps the unions above the single owner of
76
- * each partition while read-side SQL gets a value-level tag list.
77
- */
78
- const tagsOf = () => (...tags) => tags;
79
- /** The open partition as `_tag` literals, for queries that filter stored rows by state. */
80
- export const OPEN_STATE_TAGS = tagsOf()("Pending", "Waiting", "Running");
81
- /** Every state as `_tag` literals, for read models that project stored rows by state. */
82
- export const STATE_TAGS = tagsOf()("Pending", "Waiting", "Running", "Succeeded", "Failed", "Canceled");
83
- /**
84
- * The states with no started attempt, as `_tag` literals — the precondition
85
- * of `supersede` and `revoke`, for queries that filter stored rows by state.
86
- */
87
- export const UNSTARTED_STATE_TAGS = tagsOf()("Pending", "Waiting");
88
- /** pending → waiting: park the run on its loop's approval gate. */
89
- export const awaitApproval = (_state) => new Waiting();
90
- /**
91
- * pending | waiting → running: the first attempt starts. From waiting, the
92
- * engine consumes the approval Event that opens the gate.
93
- */
94
- export const start = (_state) => new Running();
95
- /** running → succeeded: the attempt finished and the step result is stored. */
96
- export const succeed = (_state) => new Succeeded();
97
- /**
98
- * running → failed: the attempt failed and no auto-retry applies — the engine
99
- * discharges that precondition with `Attempt.shouldAutoRetry`, the one owner
100
- * of the auto-retry law.
101
- */
102
- export const fail = (_state) => new Failed();
103
- /**
104
- * failed → running: operator retry. The next try is a new Attempt (N+1) under
105
- * the same Step, never a new run.
106
- */
107
- export const retry = (_state) => new Running();
108
- /**
109
- * open → canceled: the operator's act, reachable from every open state —
110
- * named by cause like its siblings; supersede and revoke are the other two
111
- * roads into Canceled.
112
- */
113
- export const cancelByOperator = (_state) => new Canceled({ reason: new OperatorCanceled() });
114
- /**
115
- * pending | waiting → canceled: a newer Event for the same Item takes this
116
- * run's place. Only runs with no started attempt can be superseded — a running
117
- * attempt always finishes, and the newer state is judged again when it ends
118
- * (ADR 0007).
119
- */
120
- export const supersede = (_state, by) => new Canceled({ reason: new Superseded({ by }) });
121
- /**
122
- * pending | waiting → canceled: the run's Item stopped matching its loop's
123
- * trigger. Never touches a running attempt.
124
- */
125
- export const revoke = (_state) => new Canceled({ reason: new Revoked() });
126
- //# sourceMappingURL=run-state.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"run-state.js","sourceRoot":"","sources":["../../src/lifecycle/run-state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AA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EAAU,EAAE,CAAC,IAAI,MAAM,EAAE,CAAC;AAE9D;;;GAGG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,MAAc,EAAW,EAAE,CAAC,IAAI,OAAO,EAAE,CAAC;AAEhE;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,MAAY,EAAY,EAAE,CACzD,IAAI,QAAQ,CAAC,EAAE,MAAM,EAAE,IAAI,gBAAgB,EAAE,EAAE,CAAC,CAAC;AAEnD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,MAAyB,EAAE,EAAW,EAAY,EAAE,CAC5E,IAAI,QAAQ,CAAC,EAAE,MAAM,EAAE,IAAI,UAAU,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;AAEnD;;;GAGG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,MAAyB,EAAY,EAAE,CAC5D,IAAI,QAAQ,CAAC,EAAE,MAAM,EAAE,IAAI,OAAO,EAAE,EAAE,CAAC,CAAC"}
@@ -1,22 +0,0 @@
1
- import { Schema } from "effect";
2
- /**
3
- * Value object (branded id): identity of one Run.
4
- */
5
- export declare const RunId: Schema.brand<Schema.NonEmptyString, "RunId">;
6
- export type RunId = typeof RunId.Type;
7
- declare const Run_base: Schema.Class<Run, Schema.Struct<{
8
- readonly id: Schema.brand<Schema.NonEmptyString, "RunId">;
9
- readonly eventId: Schema.brand<Schema.NonEmptyString, "EventId">;
10
- readonly loop: Schema.brand<Schema.NonEmptyString, "LoopName">;
11
- readonly state: Schema.Union<readonly [typeof import("./run-state.ts").Pending, typeof import("./run-state.ts").Waiting, typeof import("./run-state.ts").Running, typeof import("./run-state.ts").Succeeded, typeof import("./run-state.ts").Failed, typeof import("./run-state.ts").Canceled]>;
12
- readonly openedAt: Schema.DateTimeUtc;
13
- }>, {}>;
14
- /**
15
- * Entity — ledger row: the work a loop owes one Event. At most one open run
16
- * exists per dedup key, ever — the Event owns the key; the engine's ledger
17
- * enforces the invariant (ADR 0002).
18
- */
19
- export declare class Run extends Run_base {
20
- }
21
- export {};
22
- //# sourceMappingURL=run.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/lifecycle/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAKhC;;GAEG;AACH,eAAO,MAAM,KAAK,8CAAoD,CAAC;AACvE,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,IAAI,CAAC;;;;;;;;AAEtC;;;;GAIG;AACH,qBAAa,GAAI,SAAQ,QAMvB;CAAG"}
@@ -1,22 +0,0 @@
1
- import { Schema } from "effect";
2
- import { EventId } from "./event.js";
3
- import { LoopName } from "./loop.js";
4
- import { RunState } from "./run-state.js";
5
- /**
6
- * Value object (branded id): identity of one Run.
7
- */
8
- export const RunId = Schema.NonEmptyString.pipe(Schema.brand("RunId"));
9
- /**
10
- * Entity — ledger row: the work a loop owes one Event. At most one open run
11
- * exists per dedup key, ever — the Event owns the key; the engine's ledger
12
- * enforces the invariant (ADR 0002).
13
- */
14
- export class Run extends Schema.Class("Run")({
15
- id: RunId,
16
- eventId: EventId,
17
- loop: LoopName,
18
- state: RunState,
19
- openedAt: Schema.DateTimeUtc,
20
- }) {
21
- }
22
- //# sourceMappingURL=run.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/lifecycle/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C;;GAEG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;AAGvE;;;;GAIG;AACH,MAAM,OAAO,GAAI,SAAQ,MAAM,CAAC,KAAK,CAAM,KAAK,CAAC,CAAC;IAChD,EAAE,EAAE,KAAK;IACT,OAAO,EAAE,OAAO;IAChB,IAAI,EAAE,QAAQ;IACd,KAAK,EAAE,QAAQ;IACf,QAAQ,EAAE,MAAM,CAAC,WAAW;CAC7B,CAAC;CAAG"}
@@ -1,23 +0,0 @@
1
- import { Schema } from "effect";
2
- import { StepResult } from "../step-result.ts";
3
- /**
4
- * Value object (branded id): step identity within its run — the loop-authored name (ADR 0002). Renaming a
5
- * step in the loop file retires it — prior results stay under the old name.
6
- * There is deliberately no synthetic step id.
7
- */
8
- export declare const StepName: Schema.brand<Schema.NonEmptyString, "StepName">;
9
- export type StepName = typeof StepName.Type;
10
- declare const Step_base: Schema.Class<Step, Schema.Struct<{
11
- readonly runId: Schema.brand<Schema.NonEmptyString, "RunId">;
12
- readonly name: Schema.brand<Schema.NonEmptyString, "StepName">;
13
- readonly result: Schema.Option<typeof StepResult>;
14
- }>, {}>;
15
- /**
16
- * Entity — ledger row: a named unit of work inside a run, its stored result addressable by name;
17
- * exactly one per run in v1 (the agent action). The result is the run host's
18
- * final message, stored when an attempt succeeds — none until then.
19
- */
20
- export declare class Step extends Step_base {
21
- }
22
- export {};
23
- //# sourceMappingURL=step.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"step.d.ts","sourceRoot":"","sources":["../../src/lifecycle/step.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/C;;;;GAIG;AACH,eAAO,MAAM,QAAQ,iDAAuD,CAAC;AAC7E,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC,IAAI,CAAC;;;;;;AAE5C;;;;GAIG;AACH,qBAAa,IAAK,SAAQ,SAIxB;CAAG"}
@@ -1,21 +0,0 @@
1
- import { Schema } from "effect";
2
- import { StepResult } from "../step-result.js";
3
- import { RunId } from "./run.js";
4
- /**
5
- * Value object (branded id): step identity within its run — the loop-authored name (ADR 0002). Renaming a
6
- * step in the loop file retires it — prior results stay under the old name.
7
- * There is deliberately no synthetic step id.
8
- */
9
- export const StepName = Schema.NonEmptyString.pipe(Schema.brand("StepName"));
10
- /**
11
- * Entity — ledger row: a named unit of work inside a run, its stored result addressable by name;
12
- * exactly one per run in v1 (the agent action). The result is the run host's
13
- * final message, stored when an attempt succeeds — none until then.
14
- */
15
- export class Step extends Schema.Class("Step")({
16
- runId: RunId,
17
- name: StepName,
18
- result: Schema.Option(StepResult),
19
- }) {
20
- }
21
- //# sourceMappingURL=step.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"step.js","sourceRoot":"","sources":["../../src/lifecycle/step.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC;;;;GAIG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;AAG7E;;;;GAIG;AACH,MAAM,OAAO,IAAK,SAAQ,MAAM,CAAC,KAAK,CAAO,MAAM,CAAC,CAAC;IACnD,KAAK,EAAE,KAAK;IACZ,IAAI,EAAE,QAAQ;IACd,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC;CAClC,CAAC;CAAG"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"step-result.d.ts","sourceRoot":"","sources":["../src/step-result.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;;;;;AAGhC,6EAA6E;AA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