@usine/core 0.1.0 → 0.3.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 (123) hide show
  1. package/README.md +32 -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/session.d.ts +139 -0
  15. package/dist/agent/session.d.ts.map +1 -0
  16. package/dist/agent/session.js +119 -0
  17. package/dist/agent/session.js.map +1 -0
  18. package/dist/attempt/attempt.d.ts +53 -0
  19. package/dist/attempt/attempt.d.ts.map +1 -0
  20. package/dist/attempt/attempt.js +47 -0
  21. package/dist/attempt/attempt.js.map +1 -0
  22. package/dist/attempt/channel.d.ts +194 -0
  23. package/dist/attempt/channel.d.ts.map +1 -0
  24. package/dist/attempt/channel.js +196 -0
  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 +0 -121
  80. package/dist/agent.d.ts.map +0 -1
  81. package/dist/agent.js +0 -105
  82. package/dist/agent.js.map +0 -1
  83. package/dist/attempt-channel.d.ts +0 -134
  84. package/dist/attempt-channel.d.ts.map +0 -1
  85. package/dist/attempt-channel.js +0 -138
  86. package/dist/attempt-channel.js.map +0 -1
  87. package/dist/index.d.ts +0 -24
  88. package/dist/index.d.ts.map +0 -1
  89. package/dist/index.js +0 -24
  90. package/dist/index.js.map +0 -1
  91. package/dist/lifecycle/attempt-failure.d.ts +0 -51
  92. package/dist/lifecycle/attempt-failure.d.ts.map +0 -1
  93. package/dist/lifecycle/attempt-failure.js +0 -45
  94. package/dist/lifecycle/attempt-failure.js.map +0 -1
  95. package/dist/lifecycle/attempt.d.ts +0 -61
  96. package/dist/lifecycle/attempt.d.ts.map +0 -1
  97. package/dist/lifecycle/attempt.js +0 -52
  98. package/dist/lifecycle/attempt.js.map +0 -1
  99. package/dist/lifecycle/event.d.ts.map +0 -1
  100. package/dist/lifecycle/event.js +0 -26
  101. package/dist/lifecycle/event.js.map +0 -1
  102. package/dist/lifecycle/item.d.ts +0 -11
  103. package/dist/lifecycle/item.d.ts.map +0 -1
  104. package/dist/lifecycle/item.js +0 -9
  105. package/dist/lifecycle/item.js.map +0 -1
  106. package/dist/lifecycle/loop.d.ts +0 -17
  107. package/dist/lifecycle/loop.d.ts.map +0 -1
  108. package/dist/lifecycle/loop.js +0 -15
  109. package/dist/lifecycle/loop.js.map +0 -1
  110. package/dist/lifecycle/run-state.d.ts +0 -133
  111. package/dist/lifecycle/run-state.d.ts.map +0 -1
  112. package/dist/lifecycle/run-state.js +0 -126
  113. package/dist/lifecycle/run-state.js.map +0 -1
  114. package/dist/lifecycle/run.d.ts +0 -22
  115. package/dist/lifecycle/run.d.ts.map +0 -1
  116. package/dist/lifecycle/run.js +0 -22
  117. package/dist/lifecycle/run.js.map +0 -1
  118. package/dist/lifecycle/step.d.ts +0 -23
  119. package/dist/lifecycle/step.d.ts.map +0 -1
  120. package/dist/lifecycle/step.js +0 -21
  121. package/dist/lifecycle/step.js.map +0 -1
  122. package/dist/step-result.d.ts.map +0 -1
  123. package/dist/step-result.js.map +0 -1
@@ -0,0 +1,38 @@
1
+ import { Schema } from "effect";
2
+ /** Maximum Runs one Loop may open for an Item between operator resets. */
3
+ export declare const CycleLimit: Schema.brand<Schema.Int, "CycleLimit">;
4
+ export type CycleLimit = typeof CycleLimit.Type;
5
+ /** Identifies one Item allowance between explicit operator resets. */
6
+ export declare const CycleGeneration: Schema.brand<Schema.Int, "CycleGeneration">;
7
+ export type CycleGeneration = typeof CycleGeneration.Type;
8
+ /** The safe default for unattended rounds on an Item. */
9
+ export declare const DEFAULT_CYCLE_LIMIT: number & import("effect/Brand").Brand<"CycleLimit">;
10
+ /** Number of admitted or completed rounds for one Loop on an Item. */
11
+ export declare const CycleCount: Schema.brand<Schema.Int, "CycleCount">;
12
+ export type CycleCount = typeof CycleCount.Type;
13
+ declare const LoopCycleCount_base: Schema.Class<LoopCycleCount, Schema.Struct<{
14
+ readonly loop: Schema.brand<Schema.NonEmptyString, "LoopName">;
15
+ readonly admitted: Schema.brand<Schema.Int, "CycleCount">;
16
+ readonly completed: Schema.brand<Schema.Int, "CycleCount">;
17
+ }>, {}>;
18
+ /** A Loop's charged Runs and settled Runs in the current cycle budget. */
19
+ export declare class LoopCycleCount extends LoopCycleCount_base {
20
+ }
21
+ /** Identifies the Event and budget generation that first exhausted an Item's allowance. */
22
+ export declare const CycleBudgetAskId: Schema.brand<Schema.brand<Schema.NonEmptyString, "EventId">, "CycleBudgetAskId">;
23
+ export type CycleBudgetAskId = typeof CycleBudgetAskId.Type;
24
+ declare const CycleBudgetAsk_base: Schema.Class<CycleBudgetAsk, Schema.Struct<{
25
+ readonly id: Schema.brand<Schema.brand<Schema.NonEmptyString, "EventId">, "CycleBudgetAskId">;
26
+ readonly itemKey: Schema.brand<Schema.NonEmptyString, "ItemKey">;
27
+ readonly repository: Schema.brand<Schema.String, "RepositoryName">;
28
+ readonly loop: Schema.brand<Schema.NonEmptyString, "LoopName">;
29
+ readonly limit: Schema.brand<Schema.Int, "CycleLimit">;
30
+ readonly counts: Schema.NonEmptyArray<typeof LoopCycleCount>;
31
+ }>, {}>;
32
+ /** An Item-level request for an operator reset before further Runs can open. */
33
+ export declare class CycleBudgetAsk extends CycleBudgetAsk_base {
34
+ /** The furthest completed round; each Loop participates at most once per round. */
35
+ get completedCycles(): CycleCount;
36
+ }
37
+ export {};
38
+ //# sourceMappingURL=cycle-budget.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cycle-budget.d.ts","sourceRoot":"","sources":["../src/cycle-budget.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,0EAA0E;AAC1E,eAAO,MAAM,UAAU,wCAEtB,CAAC;AACF,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC,IAAI,CAAC;AAEhD,sEAAsE;AACtE,eAAO,MAAM,eAAe,6CAE3B,CAAC;AACF,MAAM,MAAM,eAAe,GAAG,OAAO,eAAe,CAAC,IAAI,CAAC;AAE1D,yDAAyD;AACzD,eAAO,MAAM,mBAAmB,qDAAqB,CAAC;AAEtD,sEAAsE;AACtE,eAAO,MAAM,UAAU,wCAEtB,CAAC;AACF,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC,IAAI,CAAC;;;;;;AAEhD,0EAA0E;AAC1E,qBAAa,cAAe,SAAQ,mBAYnC;CAAG;AAEJ,2FAA2F;AAC3F,eAAO,MAAM,gBAAgB,kFAAiD,CAAC;AAC/E,MAAM,MAAM,gBAAgB,GAAG,OAAO,gBAAgB,CAAC,IAAI,CAAC;;;;;;;;;AAE5D,gFAAgF;AAChF,qBAAa,cAAe,SAAQ,mBAoBnC;IACC,mFAAmF;IACnF,IAAI,eAAe,IAAI,UAAU,CAEhC;CACF"}
@@ -0,0 +1,46 @@
1
+ import { EventId } from "./event.js";
2
+ import { ItemKey } from "./item.js";
3
+ import { LoopName } from "./loop.js";
4
+ import { RepositoryName } from "./repository.js";
5
+ import { Schema } from "effect";
6
+ /** Maximum Runs one Loop may open for an Item between operator resets. */
7
+ export const CycleLimit = Schema.Int.check(Schema.isGreaterThanOrEqualTo(1)).pipe(Schema.brand("CycleLimit"));
8
+ /** Identifies one Item allowance between explicit operator resets. */
9
+ export const CycleGeneration = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)).pipe(Schema.brand("CycleGeneration"));
10
+ /** The safe default for unattended rounds on an Item. */
11
+ export const DEFAULT_CYCLE_LIMIT = CycleLimit.make(3);
12
+ /** Number of admitted or completed rounds for one Loop on an Item. */
13
+ export const CycleCount = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)).pipe(Schema.brand("CycleCount"));
14
+ /** A Loop's charged Runs and settled Runs in the current cycle budget. */
15
+ export class LoopCycleCount extends Schema.Class("LoopCycleCount")(Schema.Struct({
16
+ loop: LoopName,
17
+ admitted: CycleCount,
18
+ completed: CycleCount,
19
+ })
20
+ .check(Schema.makeFilter(({ admitted, completed }) => completed <= admitted, {
21
+ message: "Completed Runs cannot exceed admitted Runs",
22
+ }))
23
+ .annotate({ parseOptions: { onExcessProperty: "error" } })) {
24
+ }
25
+ /** Identifies the Event and budget generation that first exhausted an Item's allowance. */
26
+ export const CycleBudgetAskId = EventId.pipe(Schema.brand("CycleBudgetAskId"));
27
+ /** An Item-level request for an operator reset before further Runs can open. */
28
+ export class CycleBudgetAsk extends Schema.Class("CycleBudgetAsk")(Schema.Struct({
29
+ id: CycleBudgetAskId,
30
+ itemKey: ItemKey,
31
+ repository: RepositoryName,
32
+ loop: LoopName,
33
+ limit: CycleLimit,
34
+ counts: Schema.NonEmptyArray(LoopCycleCount),
35
+ })
36
+ .check(Schema.makeFilter(({ loop, limit, counts }) => new Set(counts.map((count) => count.loop)).size === counts.length &&
37
+ counts.some((count) => count.loop === loop && count.admitted >= limit), {
38
+ message: "Expected unique participating Loops including the exhausted Loop at its limit",
39
+ }))
40
+ .annotate({ parseOptions: { onExcessProperty: "error" } })) {
41
+ /** The furthest completed round; each Loop participates at most once per round. */
42
+ get completedCycles() {
43
+ return CycleCount.make(Math.max(...this.counts.map(({ completed }) => completed)));
44
+ }
45
+ }
46
+ //# sourceMappingURL=cycle-budget.js.map
@@ -0,0 +1 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QACjB,OAAO,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IACrF,CAAC;CACF"}
@@ -1,13 +1,10 @@
1
1
  import { Schema } from "effect";
2
- /**
3
- * Value object (branded id): identity of one Event in the ledger.
4
- */
2
+ /** Identity of one recorded fact; repeated sightings are matched through its dedup key. */
5
3
  export declare const EventId: Schema.brand<Schema.NonEmptyString, "EventId">;
6
4
  export type EventId = typeof EventId.Type;
7
5
  /**
8
- * Value object: the engine-derived, never-expiring idempotency key — timestamps aside, the
9
- * same watched state is the same Event, forever. Derived per trigger type,
10
- * never authored in a loop file (ADR 0002).
6
+ * Idempotency key the engine derives from watched state, timestamps excluded.
7
+ * The same state is the same Event forever, so a loop file never sets it (ADR 0002).
11
8
  */
12
9
  export declare const DedupKey: Schema.brand<Schema.NonEmptyString, "DedupKey">;
13
10
  export type DedupKey = typeof DedupKey.Type;
@@ -18,11 +15,9 @@ declare const Event_base: Schema.Class<Event, Schema.Struct<{
18
15
  readonly receivedAt: Schema.DateTimeUtc;
19
16
  }>, {}>;
20
17
  /**
21
- * Entity — ledger row: one deduplicated fact the engine may react to — a trigger matching watched
22
- * state, or an operator approval. An Event owns at most one open Run, ever.
23
- *
24
- * The payload is the stream's payload slice — GitHub's own shapes, kept opaque
25
- * here; the expression and loop-file blocks range over it.
18
+ * One deduplicated fact the engine may react to: a trigger match or an operator
19
+ * approval. Trigger payloads retain the snapshot that selection expressions
20
+ * and prompt interpolation use; retries keep that recorded snapshot.
26
21
  */
27
22
  export declare class Event extends Event_base {
28
23
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../src/event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,2FAA2F;AAC3F,eAAO,MAAM,OAAO,gDAAsD,CAAC;AAE3E,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAC;AAE1C;;;GAGG;AACH,eAAO,MAAM,QAAQ,iDAAuD,CAAC;AAE7E,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC,IAAI,CAAC;;;;;;;AAE5C;;;;GAIG;AACH,qBAAa,KAAM,SAAQ,UAKzB;CAAG"}
package/dist/event.js ADDED
@@ -0,0 +1,21 @@
1
+ import { Schema } from "effect";
2
+ /** Identity of one recorded fact; repeated sightings are matched through its dedup key. */
3
+ export const EventId = Schema.NonEmptyString.pipe(Schema.brand("EventId"));
4
+ /**
5
+ * Idempotency key the engine derives from watched state, timestamps excluded.
6
+ * The same state is the same Event forever, so a loop file never sets it (ADR 0002).
7
+ */
8
+ export const DedupKey = Schema.NonEmptyString.pipe(Schema.brand("DedupKey"));
9
+ /**
10
+ * One deduplicated fact the engine may react to: a trigger match or an operator
11
+ * approval. Trigger payloads retain the snapshot that selection expressions
12
+ * and prompt interpolation use; retries keep that recorded snapshot.
13
+ */
14
+ export class Event extends Schema.Class("Event")({
15
+ id: EventId,
16
+ dedupKey: DedupKey,
17
+ payload: Schema.Json,
18
+ receivedAt: Schema.DateTimeUtc,
19
+ }) {
20
+ }
21
+ //# sourceMappingURL=event.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event.js","sourceRoot":"","sources":["../src/event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,2FAA2F;AAC3F,MAAM,CAAC,MAAM,OAAO,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;AAI3E;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;AAI7E;;;;GAIG;AACH,MAAM,OAAO,KAAM,SAAQ,MAAM,CAAC,KAAK,CAAQ,OAAO,CAAC,CAAC;IACtD,EAAE,EAAE,OAAO;IACX,QAAQ,EAAE,QAAQ;IAClB,OAAO,EAAE,MAAM,CAAC,IAAI;IACpB,UAAU,EAAE,MAAM,CAAC,WAAW;CAC/B,CAAC;CAAG"}
@@ -1,9 +1,5 @@
1
1
  import { Schema } from "effect";
2
- /**
3
- * Value object (branded path): absolute or caller-resolved path to the
4
- * instance folder (ADR 0001). Shared by every package that anchors itself to
5
- * the instance repo — the engine's database adapters and the config loader.
6
- */
7
- export declare const Directory: Schema.brand<Schema.NonEmptyString, "InstanceDirectory">;
8
- export type Directory = typeof Directory.Type;
2
+ /** Root folder containing the factory's `usine.yaml`, Loop files, and Agent roster; the caller resolves its location. */
3
+ export declare const InstanceDirectory: Schema.brand<Schema.NonEmptyString, "InstanceDirectory">;
4
+ export type InstanceDirectory = typeof InstanceDirectory.Type;
9
5
  //# sourceMappingURL=instance.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"instance.d.ts","sourceRoot":"","sources":["../src/instance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC;;;;GAIG;AACH,eAAO,MAAM,SAAS,0DAAgE,CAAC;AACvF,MAAM,MAAM,SAAS,GAAG,OAAO,SAAS,CAAC,IAAI,CAAC"}
1
+ {"version":3,"file":"instance.d.ts","sourceRoot":"","sources":["../src/instance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,yHAAyH;AACzH,eAAO,MAAM,iBAAiB,0DAAgE,CAAC;AAC/F,MAAM,MAAM,iBAAiB,GAAG,OAAO,iBAAiB,CAAC,IAAI,CAAC"}
package/dist/instance.js CHANGED
@@ -1,8 +1,4 @@
1
1
  import { Schema } from "effect";
2
- /**
3
- * Value object (branded path): absolute or caller-resolved path to the
4
- * instance folder (ADR 0001). Shared by every package that anchors itself to
5
- * the instance repo — the engine's database adapters and the config loader.
6
- */
7
- export const Directory = Schema.NonEmptyString.pipe(Schema.brand("InstanceDirectory"));
2
+ /** Root folder containing the factory's `usine.yaml`, Loop files, and Agent roster; the caller resolves its location. */
3
+ export const InstanceDirectory = Schema.NonEmptyString.pipe(Schema.brand("InstanceDirectory"));
8
4
  //# sourceMappingURL=instance.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"instance.js","sourceRoot":"","sources":["../src/instance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC;;;;GAIG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"instance.js","sourceRoot":"","sources":["../src/instance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,yHAAyH;AACzH,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC,CAAC"}
package/dist/item.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ import { Schema } from "effect";
2
+ /** Identity of the issue or pull request a loop acts on. Many content-distinct Events can concern one Item. */
3
+ export declare const ItemKey: Schema.brand<Schema.NonEmptyString, "ItemKey">;
4
+ export type ItemKey = typeof ItemKey.Type;
5
+ /** The issue or pull request number within its repository. */
6
+ export declare const ItemNumber: Schema.brand<Schema.Int, "ItemNumber">;
7
+ export type ItemNumber = typeof ItemNumber.Type;
8
+ //# sourceMappingURL=item.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"item.d.ts","sourceRoot":"","sources":["../src/item.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,+GAA+G;AAC/G,eAAO,MAAM,OAAO,gDAAsD,CAAC;AAE3E,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAC;AAE1C,8DAA8D;AAC9D,eAAO,MAAM,UAAU,wCAEtB,CAAC;AACF,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC,IAAI,CAAC"}
package/dist/item.js ADDED
@@ -0,0 +1,6 @@
1
+ import { Schema } from "effect";
2
+ /** Identity of the issue or pull request a loop acts on. Many content-distinct Events can concern one Item. */
3
+ export const ItemKey = Schema.NonEmptyString.pipe(Schema.brand("ItemKey"));
4
+ /** The issue or pull request number within its repository. */
5
+ export const ItemNumber = Schema.Int.check(Schema.isGreaterThanOrEqualTo(1)).pipe(Schema.brand("ItemNumber"));
6
+ //# sourceMappingURL=item.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"item.js","sourceRoot":"","sources":["../src/item.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,+GAA+G;AAC/G,MAAM,CAAC,MAAM,OAAO,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;AAI3E,8DAA8D;AAC9D,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAC/E,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,CAC3B,CAAC"}
package/dist/loop.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ import { Schema } from "effect";
2
+ /** The loop file's name. Renaming the file retires one loop and creates another (ADR 0001). */
3
+ export declare const LoopName: Schema.brand<Schema.NonEmptyString, "LoopName">;
4
+ export type LoopName = typeof LoopName.Type;
5
+ /** Whether a loop parks new runs until an approval Event arrives. The default is `none`. */
6
+ export declare const APPROVAL_REQUIREMENTS: readonly ["none", "required"];
7
+ export declare const ApprovalRequirement: Schema.Literals<readonly ["none", "required"]>;
8
+ export type ApprovalRequirement = typeof ApprovalRequirement.Type;
9
+ //# sourceMappingURL=loop.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loop.d.ts","sourceRoot":"","sources":["../src/loop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,+FAA+F;AAC/F,eAAO,MAAM,QAAQ,iDAAuD,CAAC;AAE7E,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC,IAAI,CAAC;AAE5C,4FAA4F;AAC5F,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"}
package/dist/loop.js ADDED
@@ -0,0 +1,7 @@
1
+ import { Schema } from "effect";
2
+ /** The loop file's name. Renaming the file retires one loop and creates another (ADR 0001). */
3
+ export const LoopName = Schema.NonEmptyString.pipe(Schema.brand("LoopName"));
4
+ /** Whether a loop parks new runs until an approval Event arrives. The default is `none`. */
5
+ export const APPROVAL_REQUIREMENTS = ["none", "required"];
6
+ export const ApprovalRequirement = Schema.Literals(APPROVAL_REQUIREMENTS);
7
+ //# sourceMappingURL=loop.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loop.js","sourceRoot":"","sources":["../src/loop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,+FAA+F;AAC/F,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;AAI7E,4FAA4F;AAC5F,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,26 +1,21 @@
1
1
  import { Schema } from "effect";
2
2
  /**
3
- * Value object: the stable `owner/name` identity shared by the registry and
4
- * every GitHub-facing block. The original casing is significant to display;
5
- * GitHub comparisons are handled separately at the adapter boundary.
3
+ * Full `owner/name` of a GitHub repository, in the casing the operator wrote.
4
+ * Compare through `canonicalRepositoryName`, since GitHub ignores case.
6
5
  */
7
- export declare const Name: Schema.brand<Schema.String, "RepoName">;
8
- export type Name = typeof Name.Type;
9
- /**
10
- * Value object: a git revision resolved when an Attempt workspace is created.
11
- * Revisions reach `git fetch` as bare arguments, so a leading `-` (which git
12
- * would parse as an option) and whitespace are unrepresentable by the brand.
13
- */
14
- export declare const Revision: Schema.brand<Schema.String, "RepositoryRevision">;
15
- export type Revision = typeof Revision.Type;
16
- /** Value object: a git object id harvested from an Attempt workspace. */
6
+ export declare const RepositoryName: Schema.brand<Schema.String, "RepositoryName">;
7
+ export type RepositoryName = typeof RepositoryName.Type;
8
+ /** The branch, tag, commit, or `HEAD` a Worker fetches when preparing an Attempt; named refs resolve at preparation time. */
9
+ export declare const RepositoryRevision: Schema.brand<Schema.String, "RepositoryRevision">;
10
+ export type RepositoryRevision = typeof RepositoryRevision.Type;
11
+ /** An exact Git commit recorded for a checkout or produced by an Attempt, unchanged when branch names move. */
17
12
  export declare const CommitSha: Schema.brand<Schema.String, "CommitSha">;
18
13
  export type CommitSha = typeof CommitSha.Type;
19
- /** The `owner` and `name` halves of a full repo name; the brand proves the separator exists. */
20
- export declare const parts: (repository: Name) => {
14
+ /** Splits a repository name into its `owner` and `name`. */
15
+ export declare const splitRepositoryName: (repository: RepositoryName) => {
21
16
  readonly owner: string;
22
17
  readonly name: string;
23
18
  };
24
- /** Case-insensitive comparison key: GitHub repo names differ only by display casing. */
25
- export declare const canonical: (repository: Name) => string;
19
+ /** Lowercases a repository name for comparison, since GitHub ignores case. */
20
+ export declare const canonicalRepositoryName: (repository: RepositoryName) => string;
26
21
  //# sourceMappingURL=repository.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../src/repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC;;;;GAIG;AACH,eAAO,MAAM,IAAI,yCAIe,CAAC;AACjC,MAAM,MAAM,IAAI,GAAG,OAAO,IAAI,CAAC,IAAI,CAAC;AAEpC;;;;GAIG;AACH,eAAO,MAAM,QAAQ,mDAIqB,CAAC;AAC3C,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC,IAAI,CAAC;AAE5C,yEAAyE;AACzE,eAAO,MAAM,SAAS,0CAIW,CAAC;AAClC,MAAM,MAAM,SAAS,GAAG,OAAO,SAAS,CAAC,IAAI,CAAC;AAE9C,gGAAgG;AAChG,eAAO,MAAM,KAAK,eAAgB,IAAI;aAGlC,KAAK;aACL,IAAI;CAEP,CAAC;AAEF,wFAAwF;AACxF,eAAO,MAAM,SAAS,eAAgB,IAAI,KAAG,MAAkC,CAAC"}
1
+ {"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../src/repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC;;;GAGG;AACH,eAAO,MAAM,cAAc,+CAIW,CAAC;AAEvC,MAAM,MAAM,cAAc,GAAG,OAAO,cAAc,CAAC,IAAI,CAAC;AAExD,6HAA6H;AAC7H,eAAO,MAAM,kBAAkB,mDAIW,CAAC;AAC3C,MAAM,MAAM,kBAAkB,GAAG,OAAO,kBAAkB,CAAC,IAAI,CAAC;AAEhE,+GAA+G;AAC/G,eAAO,MAAM,SAAS,0CAIW,CAAC;AAClC,MAAM,MAAM,SAAS,GAAG,OAAO,SAAS,CAAC,IAAI,CAAC;AAE9C,4DAA4D;AAC5D,eAAO,MAAM,mBAAmB,eAAgB,cAAc;aAG1D,KAAK;aACL,IAAI;CAEP,CAAC;AAEF,8EAA8E;AAC9E,eAAO,MAAM,uBAAuB,eAAgB,cAAc,KAAG,MAC3C,CAAC"}
@@ -1,32 +1,27 @@
1
1
  import { Schema } from "effect";
2
2
  /**
3
- * Value object: the stable `owner/name` identity shared by the registry and
4
- * every GitHub-facing block. The original casing is significant to display;
5
- * GitHub comparisons are handled separately at the adapter boundary.
3
+ * Full `owner/name` of a GitHub repository, in the casing the operator wrote.
4
+ * Compare through `canonicalRepositoryName`, since GitHub ignores case.
6
5
  */
7
- export const Name = Schema.String.check(Schema.isPattern(/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/u, {
6
+ export const RepositoryName = Schema.String.check(Schema.isPattern(/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/u, {
8
7
  message: "Expected a full GitHub repo name (owner/name)",
9
- })).pipe(Schema.brand("RepoName"));
10
- /**
11
- * Value object: a git revision resolved when an Attempt workspace is created.
12
- * Revisions reach `git fetch` as bare arguments, so a leading `-` (which git
13
- * would parse as an option) and whitespace are unrepresentable by the brand.
14
- */
15
- export const Revision = Schema.String.check(Schema.isPattern(/^[^\s-]\S*$/u, {
8
+ })).pipe(Schema.brand("RepositoryName"));
9
+ /** The branch, tag, commit, or `HEAD` a Worker fetches when preparing an Attempt; named refs resolve at preparation time. */
10
+ export const RepositoryRevision = Schema.String.check(Schema.isPattern(/^[^\s-]\S*$/u, {
16
11
  message: "Expected a git revision without whitespace or a leading dash",
17
12
  })).pipe(Schema.brand("RepositoryRevision"));
18
- /** Value object: a git object id harvested from an Attempt workspace. */
13
+ /** An exact Git commit recorded for a checkout or produced by an Attempt, unchanged when branch names move. */
19
14
  export const CommitSha = Schema.String.check(Schema.isPattern(/^[0-9a-f]{40}(?:[0-9a-f]{24})?$/u, {
20
15
  message: "Expected a 40- or 64-character lowercase git object id",
21
16
  })).pipe(Schema.brand("CommitSha"));
22
- /** The `owner` and `name` halves of a full repo name; the brand proves the separator exists. */
23
- export const parts = (repository) => {
17
+ /** Splits a repository name into its `owner` and `name`. */
18
+ export const splitRepositoryName = (repository) => {
24
19
  const separator = repository.indexOf("/");
25
20
  return {
26
21
  owner: repository.slice(0, separator),
27
22
  name: repository.slice(separator + 1),
28
23
  };
29
24
  };
30
- /** Case-insensitive comparison key: GitHub repo names differ only by display casing. */
31
- export const canonical = (repository) => repository.toLowerCase();
25
+ /** Lowercases a repository name for comparison, since GitHub ignores case. */
26
+ export const canonicalRepositoryName = (repository) => repository.toLowerCase();
32
27
  //# sourceMappingURL=repository.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"repository.js","sourceRoot":"","sources":["../src/repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC;;;;GAIG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CACrC,MAAM,CAAC,SAAS,CAAC,qCAAqC,EAAE;IACtD,OAAO,EAAE,+CAA+C;CACzD,CAAC,CACH,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;AAGjC;;;;GAIG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CACzC,MAAM,CAAC,SAAS,CAAC,cAAc,EAAE;IAC/B,OAAO,EAAE,8DAA8D;CACxE,CAAC,CACH,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC,CAAC;AAG3C,yEAAyE;AACzE,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAC1C,MAAM,CAAC,SAAS,CAAC,kCAAkC,EAAE;IACnD,OAAO,EAAE,wDAAwD;CAClE,CAAC,CACH,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,C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AAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC;AAGlC,4DAA4D;AAC5D,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,UAA0B,EAAE,EAAE;IAChE,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC1C,OAAO;QACL,KAAK,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC;QACrC,IAAI,EAAE,UAAU,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC;KAC7B,CAAC;AACb,CAAC,CAAC;AAEF,8EAA8E;AAC9E,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,UAA0B,EAAU,EAAE,CAC5E,UAAU,CAAC,WAAW,EAAE,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { Schema } from "effect";
2
+ /** Identity of the work owed to one Event, retained across retries of its Step. */
3
+ export declare const RunId: Schema.brand<Schema.NonEmptyString, "RunId">;
4
+ export type RunId = typeof RunId.Type;
5
+ declare const Run_base: Schema.Class<Run, Schema.Struct<{
6
+ readonly id: Schema.brand<Schema.NonEmptyString, "RunId">;
7
+ readonly eventId: Schema.brand<Schema.NonEmptyString, "EventId">;
8
+ readonly loop: Schema.brand<Schema.NonEmptyString, "LoopName">;
9
+ readonly state: Schema.Union<readonly [typeof import("./state.ts").Pending, typeof import("./state.ts").Waiting, typeof import("./state.ts").Queued, typeof import("./state.ts").Running, typeof import("./state.ts").Succeeded, typeof import("./state.ts").Failed, typeof import("./state.ts").Canceled]>;
10
+ readonly openedAt: Schema.DateTimeUtc;
11
+ }>, {}>;
12
+ /** The work a loop owes one Event. At most one open Run exists per dedup key; the engine's ledger enforces it (ADR 0002). */
13
+ export declare class Run extends Run_base {
14
+ }
15
+ export {};
16
+ //# sourceMappingURL=run.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/run/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAKhC,mFAAmF;AACnF,eAAO,MAAM,KAAK,8CAAoD,CAAC;AAEvE,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,IAAI,CAAC;;;;;;;;AAEtC,6HAA6H;AAC7H,qBAAa,GAAI,SAAQ,QAMvB;CAAG"}
@@ -0,0 +1,16 @@
1
+ import { Schema } from "effect";
2
+ import { EventId } from "../event.js";
3
+ import { LoopName } from "../loop.js";
4
+ import { RunState } from "./state.js";
5
+ /** Identity of the work owed to one Event, retained across retries of its Step. */
6
+ export const RunId = Schema.NonEmptyString.pipe(Schema.brand("RunId"));
7
+ /** The work a loop owes one Event. At most one open Run exists per dedup key; the engine's ledger enforces it (ADR 0002). */
8
+ export class Run extends Schema.Class("Run")({
9
+ id: RunId,
10
+ eventId: EventId,
11
+ loop: LoopName,
12
+ state: RunState,
13
+ openedAt: Schema.DateTimeUtc,
14
+ }) {
15
+ }
16
+ //# sourceMappingURL=run.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/run/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,mFAAmF;AACnF,MAAM,CAAC,MAAM,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;AAIvE,6HAA6H;AAC7H,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"}
@@ -0,0 +1,114 @@
1
+ import { Schema } from "effect";
2
+ import { EventId } from "../event.ts";
3
+ declare const OperatorCanceled_base: Schema.Class<OperatorCanceled, Schema.TaggedStruct<"OperatorCanceled", {}>, {}>;
4
+ /**
5
+ * The run state machine (ADR 0002):
6
+ *
7
+ * pending ─────────────────────────► running ──► succeeded
8
+ * │ ▲ │
9
+ * ▼ │ ▼
10
+ * waiting ──(approval)──► queued ────┘ failed ──► (retry: attempt N+1) ──► running
11
+ *
12
+ * pending | waiting | queued | running ──► canceled (operator cancel)
13
+ * pending | waiting | queued ──► canceled (supersede, revoke: a started
14
+ * attempt always finishes, ADR 0007)
15
+ *
16
+ * Each transition accepts only the states it is legal on, so an illegal
17
+ * transition fails to compile. Construct states through the transitions or by
18
+ * decoding a stored row with `RunState`.
19
+ */
20
+ /** The operator closed the run by hand. */
21
+ export declare class OperatorCanceled extends OperatorCanceled_base {
22
+ }
23
+ declare const Superseded_base: Schema.Class<Superseded, Schema.TaggedStruct<"Superseded", {
24
+ readonly by: Schema.brand<Schema.NonEmptyString, "EventId">;
25
+ }>, {}>;
26
+ /** A newer Event for the same Item took the run's place before any attempt started. */
27
+ export declare class Superseded extends Superseded_base {
28
+ }
29
+ declare const Revoked_base: Schema.Class<Revoked, Schema.TaggedStruct<"Revoked", {}>, {}>;
30
+ /** The run's Item stopped matching its loop's trigger before any attempt started. */
31
+ export declare class Revoked extends Revoked_base {
32
+ }
33
+ export declare const CancelReason: Schema.Union<readonly [typeof OperatorCanceled, typeof Superseded, typeof Revoked]>;
34
+ export type CancelReason = typeof CancelReason.Type;
35
+ declare const Pending_base: Schema.Class<Pending, Schema.TaggedStruct<"Pending", {}>, {}>;
36
+ /** Just created: no attempt started and no approval gate passed. */
37
+ export declare class Pending extends Pending_base {
38
+ }
39
+ declare const Waiting_base: Schema.Class<Waiting, Schema.TaggedStruct<"Waiting", {}>, {}>;
40
+ /** Parked on the loop's approval gate. The approval it waits for is an Event like any other fact. */
41
+ export declare class Waiting extends Waiting_base {
42
+ }
43
+ declare const Queued_base: Schema.Class<Queued, Schema.TaggedStruct<"Queued", {}>, {}>;
44
+ /** Approved and waiting for a worker slot. */
45
+ export declare class Queued extends Queued_base {
46
+ }
47
+ declare const Running_base: Schema.Class<Running, Schema.TaggedStruct<"Running", {}>, {}>;
48
+ /** An attempt is executing on a worker. */
49
+ export declare class Running extends Running_base {
50
+ }
51
+ declare const Succeeded_base: Schema.Class<Succeeded, Schema.TaggedStruct<"Succeeded", {}>, {}>;
52
+ /** The step finished and its result is stored. */
53
+ export declare class Succeeded extends Succeeded_base {
54
+ }
55
+ declare const Failed_base: Schema.Class<Failed, Schema.TaggedStruct<"Failed", {}>, {}>;
56
+ /** The last attempt failed and no auto-retry applies. The failure is on the Attempt, and `retry` reopens the run. */
57
+ export declare class Failed extends Failed_base {
58
+ }
59
+ declare const Canceled_base: Schema.Class<Canceled, Schema.TaggedStruct<"Canceled", {
60
+ readonly reason: Schema.Union<readonly [typeof OperatorCanceled, typeof Superseded, typeof Revoked]>;
61
+ }>, {}>;
62
+ /** Canceled, with the reason recorded. */
63
+ export declare class Canceled extends Canceled_base {
64
+ }
65
+ /** Runs that still owe work, including those waiting for approval or a Worker. */
66
+ export declare const Open: Schema.Union<readonly [typeof Pending, typeof Waiting, typeof Queued, typeof Running]>;
67
+ export type Open = typeof Open.Type;
68
+ /** A Run's progress from creation through approval and execution to a recorded outcome. */
69
+ export declare const RunState: Schema.Union<readonly [typeof Pending, typeof Waiting, typeof Queued, typeof Running, typeof Succeeded, typeof Failed, typeof Canceled]>;
70
+ export type RunState = typeof RunState.Type;
71
+ /** The states with no attempt started: what `supersede` and `revoke` accept. */
72
+ export declare const Unstarted: Schema.Union<readonly [typeof Pending, typeof Waiting, typeof Queued]>;
73
+ export type Unstarted = typeof Unstarted.Type;
74
+ /** The states an attempt can start from: the gate is passed or absent. */
75
+ export declare const Startable: Schema.Union<readonly [typeof Pending, typeof Queued]>;
76
+ export type Startable = typeof Startable.Type;
77
+ export declare const isOpen: <I>(input: I) => input is I & (Pending | Queued | Running | Waiting);
78
+ export declare const isUnstarted: <I>(input: I) => input is I & (Pending | Queued | Waiting);
79
+ export declare const isStartable: <I>(input: I) => input is I & (Pending | Queued);
80
+ /** The operator actions permitted by a Run's lifecycle state. Command handlers still apply the typed transitions. */
81
+ export declare const operatorActions: (state: RunState) => {
82
+ canApprove: boolean;
83
+ canRetry: boolean;
84
+ canCancel: boolean;
85
+ };
86
+ /** The open states as `_tag` literals, for queries that filter stored rows. */
87
+ export declare const OPEN_STATE_TAGS: readonly ["Pending", "Waiting", "Queued", "Running"];
88
+ /** Every state as a `_tag` literal, for read models that project stored rows. */
89
+ export declare const STATE_TAGS: readonly ["Pending", "Waiting", "Queued", "Running", "Succeeded", "Failed", "Canceled"];
90
+ /** The unstarted states as `_tag` literals, for queries that filter stored rows. */
91
+ export declare const UNSTARTED_STATE_TAGS: readonly ["Pending", "Waiting", "Queued"];
92
+ /** Parks a pending run on its loop's approval gate. */
93
+ export declare const awaitApproval: (_state: Pending) => Waiting;
94
+ /** Returns the approved state; the Run still waits for a Worker slot before execution. */
95
+ export declare const approve: (_state: Waiting) => Queued;
96
+ /** Returns the running state for a first Attempt after any required approval has been granted. */
97
+ export declare const start: (_state: Startable) => Running;
98
+ /** Closes the run after a successful attempt. */
99
+ export declare const succeed: (_state: Running) => Succeeded;
100
+ /** Closes the run after a failed attempt when no auto-retry applies; `shouldAutoRetry` decides that. */
101
+ export declare const fail: (_state: Running) => Failed;
102
+ /** Returns the reopened state for operator retry; attempt N+1 belongs to the same Run and Step. */
103
+ export declare const retry: (_state: Failed) => Running;
104
+ /** Cancels from any open state. */
105
+ export declare const cancelByOperator: (_state: Open) => Canceled;
106
+ /**
107
+ * Cancels an unstarted run because a newer Event for the same Item replaced it.
108
+ * A running attempt always finishes and the newer state is judged when it ends (ADR 0007).
109
+ */
110
+ export declare const supersede: (_state: Unstarted, by: EventId) => Canceled;
111
+ /** Cancels an unstarted run because its Item stopped matching the loop's trigger. */
112
+ export declare const revoke: (_state: Unstarted) => Canceled;
113
+ export {};
114
+ //# sourceMappingURL=state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/run/state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;;AAEtC;;;;;;;;;;;;;;;GAeG;AAEH,2CAA2C;AAC3C,qBAAa,gBAAiB,SAAQ,qBAEb;CAAG;;;;AAE5B,uFAAuF;AACvF,qBAAa,UAAW,SAAQ,eAG/B;CAAG;;AAEJ,qFAAqF;AACrF,qBAAa,OAAQ,SAAQ,YAAkE;CAAG;AAElG,eAAO,MAAM,YAAY,qFAAwD,CAAC;AAClF,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC,IAAI,CAAC;;AAEpD,oEAAoE;AACpE,qBAAa,OAAQ,SAAQ,YAA8D;CAAG;;AAE9F,qGAAqG;AACrG,qBAAa,OAAQ,SAAQ,YAA8D;CAAG;;AAE9F,8CAA8C;AAC9C,qBAAa,MAAO,SAAQ,WAA2D;CAAG;;AAE1F,2CAA2C;AAC3C,qBAAa,OAAQ,SAAQ,YAA8D;CAAG;;AAE9F,kDAAkD;AAClD,qBAAa,SAAU,SAAQ,cAG9B;CAAG;;AAEJ,qHAAqH;AACrH,qBAAa,MAAO,SAAQ,WAA2D;CAAG;;;;AAE1F,0CAA0C;AAC1C,qBAAa,QAAS,SAAQ,aAE5B;CAAG;AAEL,kFAAkF;AAClF,eAAO,MAAM,IAAI,wFAAoD,CAAC;AACtE,MAAM,MAAM,IAAI,GAAG,OAAO,IAAI,CAAC,IAAI,CAAC;AAEpC,2FAA2F;AAC3F,eAAO,MAAM,QAAQ,0IAA+D,CAAC;AACrF,MAAM,MAAM,QAAQ,GAAG,OAA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