@usine/engine 0.0.1 → 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 (142) hide show
  1. package/README.md +91 -2
  2. package/dist/cursor/cursor.d.ts +20 -0
  3. package/dist/cursor/cursor.d.ts.map +1 -0
  4. package/dist/cursor/cursor.js +55 -0
  5. package/dist/cursor/cursor.js.map +1 -0
  6. package/dist/cycle-budget/cycle-budget.d.ts +25 -0
  7. package/dist/cycle-budget/cycle-budget.d.ts.map +1 -0
  8. package/dist/cycle-budget/cycle-budget.js +117 -0
  9. package/dist/cycle-budget/cycle-budget.js.map +1 -0
  10. package/dist/cycle-budget/model.d.ts +26 -0
  11. package/dist/cycle-budget/model.d.ts.map +1 -0
  12. package/dist/cycle-budget/model.js +20 -0
  13. package/dist/cycle-budget/model.js.map +1 -0
  14. package/dist/cycle-budget/queries.d.ts +27 -0
  15. package/dist/cycle-budget/queries.d.ts.map +1 -0
  16. package/dist/cycle-budget/queries.js +175 -0
  17. package/dist/cycle-budget/queries.js.map +1 -0
  18. package/dist/database/database.d.ts +15 -0
  19. package/dist/database/database.d.ts.map +1 -0
  20. package/dist/database/database.js +5 -0
  21. package/dist/database/database.js.map +1 -0
  22. package/dist/database/local-sqlite.d.ts +37 -0
  23. package/dist/database/local-sqlite.d.ts.map +1 -0
  24. package/dist/database/local-sqlite.js +144 -0
  25. package/dist/database/local-sqlite.js.map +1 -0
  26. package/dist/database/schema.d.ts +1341 -0
  27. package/dist/database/schema.d.ts.map +1 -0
  28. package/dist/database/schema.js +224 -0
  29. package/dist/database/schema.js.map +1 -0
  30. package/dist/engine/engine.d.ts +55 -0
  31. package/dist/engine/engine.d.ts.map +1 -0
  32. package/dist/engine/engine.js +193 -0
  33. package/dist/engine/engine.js.map +1 -0
  34. package/dist/engine/error.d.ts +37 -0
  35. package/dist/engine/error.d.ts.map +1 -0
  36. package/dist/engine/error.js +41 -0
  37. package/dist/engine/error.js.map +1 -0
  38. package/dist/engine/lifecycle.d.ts +112 -0
  39. package/dist/engine/lifecycle.d.ts.map +1 -0
  40. package/dist/engine/lifecycle.js +132 -0
  41. package/dist/engine/lifecycle.js.map +1 -0
  42. package/dist/engine/shutdown.d.ts +12 -0
  43. package/dist/engine/shutdown.d.ts.map +1 -0
  44. package/dist/engine/shutdown.js +10 -0
  45. package/dist/engine/shutdown.js.map +1 -0
  46. package/dist/engine/submission.d.ts +58 -0
  47. package/dist/engine/submission.d.ts.map +1 -0
  48. package/dist/engine/submission.js +54 -0
  49. package/dist/engine/submission.js.map +1 -0
  50. package/dist/item-projection/item-projection.d.ts +25 -0
  51. package/dist/item-projection/item-projection.d.ts.map +1 -0
  52. package/dist/item-projection/item-projection.js +100 -0
  53. package/dist/item-projection/item-projection.js.map +1 -0
  54. package/dist/item-projection/model.d.ts +18 -0
  55. package/dist/item-projection/model.d.ts.map +1 -0
  56. package/dist/item-projection/model.js +16 -0
  57. package/dist/item-projection/model.js.map +1 -0
  58. package/dist/loop-control/loop-control.d.ts +21 -0
  59. package/dist/loop-control/loop-control.d.ts.map +1 -0
  60. package/dist/loop-control/loop-control.js +71 -0
  61. package/dist/loop-control/loop-control.js.map +1 -0
  62. package/dist/loop-control/model.d.ts +10 -0
  63. package/dist/loop-control/model.d.ts.map +1 -0
  64. package/dist/loop-control/model.js +9 -0
  65. package/dist/loop-control/model.js.map +1 -0
  66. package/dist/repository-label-projection/model.d.ts +19 -0
  67. package/dist/repository-label-projection/model.d.ts.map +1 -0
  68. package/dist/repository-label-projection/model.js +20 -0
  69. package/dist/repository-label-projection/model.js.map +1 -0
  70. package/dist/repository-label-projection/repository-label-projection.d.ts +20 -0
  71. package/dist/repository-label-projection/repository-label-projection.d.ts.map +1 -0
  72. package/dist/repository-label-projection/repository-label-projection.js +83 -0
  73. package/dist/repository-label-projection/repository-label-projection.js.map +1 -0
  74. package/dist/run-reader/model.d.ts +46 -0
  75. package/dist/run-reader/model.d.ts.map +1 -0
  76. package/dist/run-reader/model.js +44 -0
  77. package/dist/run-reader/model.js.map +1 -0
  78. package/dist/run-reader/run-reader.d.ts +29 -0
  79. package/dist/run-reader/run-reader.d.ts.map +1 -0
  80. package/dist/run-reader/run-reader.js +44 -0
  81. package/dist/run-reader/run-reader.js.map +1 -0
  82. package/dist/step-executor.d.ts +43 -0
  83. package/dist/step-executor.d.ts.map +1 -0
  84. package/dist/step-executor.js +25 -0
  85. package/dist/step-executor.js.map +1 -0
  86. package/dist/store/codec.d.ts +495 -0
  87. package/dist/store/codec.d.ts.map +1 -0
  88. package/dist/store/codec.js +162 -0
  89. package/dist/store/codec.js.map +1 -0
  90. package/dist/store/queries.d.ts +107 -0
  91. package/dist/store/queries.d.ts.map +1 -0
  92. package/dist/store/queries.js +543 -0
  93. package/dist/store/queries.js.map +1 -0
  94. package/dist/store/store.d.ts +101 -0
  95. package/dist/store/store.d.ts.map +1 -0
  96. package/dist/store/store.js +432 -0
  97. package/dist/store/store.js.map +1 -0
  98. package/dist/transcript.d.ts +64 -0
  99. package/dist/transcript.d.ts.map +1 -0
  100. package/dist/transcript.js +59 -0
  101. package/dist/transcript.js.map +1 -0
  102. package/dist/workflow/admission.d.ts +13 -0
  103. package/dist/workflow/admission.d.ts.map +1 -0
  104. package/dist/workflow/admission.js +55 -0
  105. package/dist/workflow/admission.js.map +1 -0
  106. package/dist/workflow/command.d.ts +13 -0
  107. package/dist/workflow/command.d.ts.map +1 -0
  108. package/dist/workflow/command.js +17 -0
  109. package/dist/workflow/command.js.map +1 -0
  110. package/dist/workflow/workflow.d.ts +18 -0
  111. package/dist/workflow/workflow.d.ts.map +1 -0
  112. package/dist/workflow/workflow.js +108 -0
  113. package/dist/workflow/workflow.js.map +1 -0
  114. package/drizzle/20260825055549_initial_runtime/migration.sql +73 -0
  115. package/drizzle/20260825055549_initial_runtime/snapshot.json +592 -0
  116. package/drizzle/20260830191125_polling_cursors/migration.sql +5 -0
  117. package/drizzle/20260830191125_polling_cursors/snapshot.json +629 -0
  118. package/drizzle/20260831073158_attempt_channel/migration.sql +36 -0
  119. package/drizzle/20260831073158_attempt_channel/snapshot.json +845 -0
  120. package/drizzle/20260831133534_agent_context/migration.sql +49 -0
  121. package/drizzle/20260831133534_agent_context/snapshot.json +897 -0
  122. package/drizzle/20260831134612_attempt_brain/migration.sql +26 -0
  123. package/drizzle/20260831134612_attempt_brain/snapshot.json +923 -0
  124. package/drizzle/20260831194605_loop_runtime/migration.sql +4 -0
  125. package/drizzle/20260831194605_loop_runtime/snapshot.json +954 -0
  126. package/drizzle/20260901073233_projection_revision/migration.sql +55 -0
  127. package/drizzle/20260901073233_projection_revision/snapshot.json +991 -0
  128. package/drizzle/20260901180433_item_projections/migration.sql +22 -0
  129. package/drizzle/20260901180433_item_projections/snapshot.json +1110 -0
  130. package/drizzle/20260901185146_repository_label_projections/migration.sql +17 -0
  131. package/drizzle/20260901185146_repository_label_projections/snapshot.json +1147 -0
  132. package/drizzle/20260903091940_queued_approved_runs/migration.sql +3 -0
  133. package/drizzle/20260903091940_queued_approved_runs/snapshot.json +1147 -0
  134. package/drizzle/20260905150403_item_cycle_budgets/migration.sql +58 -0
  135. package/drizzle/20260905150403_item_cycle_budgets/snapshot.json +1417 -0
  136. package/drizzle/20260905174009_item_run_history/migration.sql +1 -0
  137. package/drizzle/20260905174009_item_run_history/snapshot.json +1431 -0
  138. package/package.json +60 -6
  139. package/dist/index.d.ts +0 -8
  140. package/dist/index.d.ts.map +0 -1
  141. package/dist/index.js +0 -8
  142. package/dist/index.js.map +0 -1
@@ -0,0 +1,71 @@
1
+ import { LoopName } from "@usine/core/loop";
2
+ import { asc, eq } from "drizzle-orm";
3
+ import { Context, Effect, Layer } from "effect";
4
+ import { RunDatabase } from "../database/database.js";
5
+ import { loopRuntime } from "../database/schema.js";
6
+ import { EnginePersistenceError } from "../engine/error.js";
7
+ import { LoopRuntimeState } from "./model.js";
8
+ const persistence = (operation) => (effect) => effect.pipe(Effect.mapError((cause) => new EnginePersistenceError({ operation, cause })));
9
+ const makeLoopControl = Effect.gen(function* () {
10
+ const database = yield* RunDatabase;
11
+ const stateFor = Effect.fn("LoopControl.stateFor")(function* (loop) {
12
+ yield* Effect.annotateCurrentSpan({ loop });
13
+ const rows = yield* database
14
+ .select({ loop: loopRuntime.loopName, paused: loopRuntime.paused })
15
+ .from(loopRuntime)
16
+ .where(eq(loopRuntime.loopName, loop))
17
+ .limit(1)
18
+ .execute();
19
+ const stored = rows[0];
20
+ return stored === undefined
21
+ ? new LoopRuntimeState({ loop, paused: false })
22
+ : new LoopRuntimeState(stored);
23
+ }, persistence("read Loop runtime state"));
24
+ const states = Effect.fn("LoopControl.states")(function* () {
25
+ const rows = yield* database
26
+ .select({ loop: loopRuntime.loopName, paused: loopRuntime.paused })
27
+ .from(loopRuntime)
28
+ .orderBy(asc(loopRuntime.loopName))
29
+ .execute();
30
+ return rows.map((row) => new LoopRuntimeState(row));
31
+ }, persistence("list Loop runtime states"));
32
+ const write = Effect.fn("LoopControl.write")(function* (next) {
33
+ yield* Effect.annotateCurrentSpan({ loop: next.loop });
34
+ const current = yield* stateFor(next.loop);
35
+ if (current.paused === next.paused) {
36
+ yield* Effect.logDebug("Loop runtime state was already set", {
37
+ loop: next.loop,
38
+ paused: next.paused,
39
+ });
40
+ return current;
41
+ }
42
+ yield* database
43
+ .insert(loopRuntime)
44
+ .values({ loopName: next.loop, paused: next.paused })
45
+ .onConflictDoUpdate({
46
+ target: loopRuntime.loopName,
47
+ set: { paused: next.paused },
48
+ })
49
+ .execute()
50
+ .pipe(persistence("write Loop runtime state"));
51
+ yield* Effect.logInfo(next.paused ? "Loop paused" : "Loop unpaused", {
52
+ loop: next.loop,
53
+ paused: next.paused,
54
+ });
55
+ return next;
56
+ });
57
+ return {
58
+ isPaused: Effect.fn("LoopControl.isPaused")(function* (loop) {
59
+ return (yield* stateFor(loop)).paused;
60
+ }),
61
+ pause: Effect.fn("LoopControl.pause")((loop) => write(new LoopRuntimeState({ loop, paused: true }))),
62
+ states: states(),
63
+ unpause: Effect.fn("LoopControl.unpause")((loop) => write(new LoopRuntimeState({ loop, paused: false }))),
64
+ };
65
+ });
66
+ /** Records whether triggers may open new Runs for each Loop; existing Runs and authored files stay unchanged. */
67
+ export class LoopControl extends Context.Service()("@usine/engine/LoopControl") {
68
+ static layer = Layer.effect(LoopControl, makeLoopControl);
69
+ }
70
+ export { LoopRuntimeState } from "./model.js";
71
+ //# sourceMappingURL=loop-control.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loop-control.js","sourceRoot":"","sources":["../../src/loop-control/loop-control.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9C,MAAM,WAAW,GACf,CAAC,SAAiB,EAAE,EAAE,CACtB,CAAU,MAA8B,EAA+C,EAAE,CACvF,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,sBAAsB,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;AAE9F,MAAM,eAAe,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAC1C,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,WAAW,CAAC;IAEpC,MAAM,QAAQ,GAAG,MAAM,CAAC,EAAE,CAAC,sBAAsB,CAAC,CAAC,QAAQ,CAAC,EAAE,IAAc;QAC1E,KAAK,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AC,KAAK,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC;QACxC,CAAC,CAAC;QACF,KAAK,EAAE,MAAM,CAAC,EAAE,CAAC,mBAAmB,CAAC,CAAC,CAAC,IAAc,EAAE,EAAE,CACvD,KAAK,CAAC,IAAI,gBAAgB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CACpD;QACD,MAAM,EAAE,MAAM,EAAE;QAChB,OAAO,EAAE,MAAM,CAAC,EAAE,CAAC,qBAAqB,CAAC,CAAC,CAAC,IAAc,EAAE,EAAE,CAC3D,KAAK,CAAC,IAAI,gBAAgB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,CACrD;KACO,CAAC;AACb,CAAC,CAAC,CAAC;AAEH,iHAAiH;AACjH,MAAM,OAAO,WAAY,SAAQ,OAAO,CAAC,OAAO,EAY7C,CAAC,2BAA2B,CAAC;IAC9B,MAAM,CAAU,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC;CACpE;AAED,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { Schema } from "effect";
2
+ declare const LoopRuntimeState_base: Schema.Class<LoopRuntimeState, Schema.Struct<{
3
+ readonly loop: Schema.brand<Schema.NonEmptyString, "LoopName">;
4
+ readonly paused: Schema.Boolean;
5
+ }>, {}>;
6
+ /** Runtime state for one Loop. Authored loop files never carry this toggle. */
7
+ export declare class LoopRuntimeState extends LoopRuntimeState_base {
8
+ }
9
+ export {};
10
+ //# sourceMappingURL=model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/loop-control/model.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;;;;;AAEhC,+EAA+E;AAC/E,qBAAa,gBAAiB,SAAQ,qBAKpC;CAAG"}
@@ -0,0 +1,9 @@
1
+ import { LoopName } from "@usine/core/loop";
2
+ import { Schema } from "effect";
3
+ /** Runtime state for one Loop. Authored loop files never carry this toggle. */
4
+ export class LoopRuntimeState extends Schema.Class("@usine/engine/LoopRuntimeState")({
5
+ loop: LoopName,
6
+ paused: Schema.Boolean,
7
+ }) {
8
+ }
9
+ //# sourceMappingURL=model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/loop-control/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,+EAA+E;AAC/E,MAAM,OAAO,gBAAiB,SAAQ,MAAM,CAAC,KAAK,CAChD,gCAAgC,CACjC,CAAC;IACA,IAAI,EAAE,QAAQ;IACd,MAAM,EAAE,MAAM,CAAC,OAAO;CACvB,CAAC;CAAG"}
@@ -0,0 +1,19 @@
1
+ import { Schema } from "effect";
2
+ /** Six hex digits, as GitHub stores label colors. Absent for catalogs stored before colors were kept. */
3
+ export declare const RepositoryLabelColor: Schema.String;
4
+ declare const RepositoryLabel_base: Schema.Class<RepositoryLabel, Schema.Struct<{
5
+ readonly name: Schema.String;
6
+ readonly color: Schema.OptionFromNullOr<Schema.String>;
7
+ readonly description: Schema.OptionFromNullOr<Schema.String>;
8
+ }>, {}>;
9
+ export declare class RepositoryLabel extends RepositoryLabel_base {
10
+ }
11
+ declare const RepositoryLabelProjection_base: Schema.Class<RepositoryLabelProjection, Schema.Struct<{
12
+ readonly repository: Schema.brand<Schema.String, "RepositoryName">;
13
+ readonly labels: Schema.$Array<typeof RepositoryLabel>;
14
+ }>, {}>;
15
+ /** The latest complete label catalog polling observed for one repository. */
16
+ export declare class RepositoryLabelProjection extends RepositoryLabelProjection_base {
17
+ }
18
+ export {};
19
+ //# sourceMappingURL=model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/repository-label-projection/model.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAMhC,yGAAyG;AACzG,eAAO,MAAM,oBAAoB,eAEhC,CAAC;;;;;;AAEF,qBAAa,eAAgB,SAAQ,oBAMpC;CAAG;;;;;AAQJ,6EAA6E;AAC7E,qBAAa,yBAA0B,SAAQ,8BAK7C;CAAG"}
@@ -0,0 +1,20 @@
1
+ import { RepositoryName } from "@usine/core/repository";
2
+ import { Schema } from "effect";
3
+ const RepositoryLabelName = Schema.String.check(Schema.isPattern(/\S/u, { message: "Expected a non-blank repository label" }));
4
+ /** Six hex digits, as GitHub stores label colors. Absent for catalogs stored before colors were kept. */
5
+ export const RepositoryLabelColor = Schema.String.check(Schema.isPattern(/^[0-9a-fA-F]{6}$/u, { message: "Expected a six-digit hex label color" }));
6
+ export class RepositoryLabel extends Schema.Class("@usine/engine/RepositoryLabel")({
7
+ name: RepositoryLabelName,
8
+ color: Schema.OptionFromNullOr(RepositoryLabelColor),
9
+ description: Schema.OptionFromNullOr(Schema.String),
10
+ }) {
11
+ }
12
+ const uniqueLabelNames = Schema.makeFilter((labels) => new Set(labels.map(({ name }) => name)).size === labels.length, { message: "Expected unique label names" });
13
+ const RepositoryLabels = Schema.Array(RepositoryLabel).check(uniqueLabelNames);
14
+ /** The latest complete label catalog polling observed for one repository. */
15
+ export class RepositoryLabelProjection extends Schema.Class("@usine/engine/RepositoryLabelProjection")({
16
+ repository: RepositoryName,
17
+ labels: RepositoryLabels,
18
+ }) {
19
+ }
20
+ //# sourceMappingURL=model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/repository-label-projection/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAC7C,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,uCAAuC,EAAE,CAAC,CAC9E,CAAC;AAEF,yGAAyG;AACzG,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CACrD,MAAM,CAAC,SAAS,CAAC,mBAAmB,EAAE,EAAE,OAAO,EAAE,sCAAsC,EAAE,CAAC,CAC3F,CAAC;AAEF,MAAM,OAAO,eAAgB,SAAQ,MAAM,CAAC,KAAK,CAAkB,+BAA+B,CAAC,CACjG;IACE,IAAI,EAAE,mBAAmB;IACzB,KAAK,EAAE,MAAM,CAAC,gBAAgB,CAAC,oBAAoB,CAAC;IACpD,WAAW,EAAE,MAAM,CAAC,gBAAgB,CAAC,MAAM,CAAC,MAAM,CAAC;CACpD,CACF;CAAG;AAEJ,MAAM,gBAAgB,GAAG,MAAM,CAAC,UAAU,CACxC,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,MAAM,EAC1E,EAAE,OAAO,EAAE,6BAA6B,EAAE,CAC3C,CAAC;AACF,MAAM,gBAAgB,GAAG,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;AAE/E,6EAA6E;AAC7E,MAAM,OAAO,yBAA0B,SAAQ,MAAM,CAAC,KAAK,CACzD,yCAAyC,CAC1C,CAAC;IACA,UAAU,EAAE,cAAc;IAC1B,MAAM,EAAE,gBAAgB;CACzB,CAAC;CAAG"}
@@ -0,0 +1,20 @@
1
+ import { RepositoryName } from "@usine/core/repository";
2
+ import { Context, Effect, Layer, Option } from "effect";
3
+ import { RunDatabase } from "../database/database.ts";
4
+ import { EnginePersistenceError } from "../engine/error.ts";
5
+ import { RepositoryLabelProjection } from "./model.ts";
6
+ declare const RepositoryLabelProjectionReader_base: Context.ServiceClass<RepositoryLabelProjectionReader, "@usine/engine/RepositoryLabelProjectionReader", {
7
+ readonly get: (repository: RepositoryName) => Effect.Effect<Option.Option<RepositoryLabelProjection>, EnginePersistenceError>;
8
+ }>;
9
+ export declare class RepositoryLabelProjectionReader extends RepositoryLabelProjectionReader_base {
10
+ static readonly layer: Layer.Layer<RepositoryLabelProjectionReader, never, RunDatabase>;
11
+ }
12
+ declare const RepositoryLabelProjectionWriter_base: Context.ServiceClass<RepositoryLabelProjectionWriter, "@usine/engine/RepositoryLabelProjectionWriter", {
13
+ /** `true` means the durable projection changed. */
14
+ readonly replace: (projection: RepositoryLabelProjection) => Effect.Effect<boolean, EnginePersistenceError>;
15
+ }>;
16
+ export declare class RepositoryLabelProjectionWriter extends RepositoryLabelProjectionWriter_base {
17
+ static readonly layer: Layer.Layer<RepositoryLabelProjectionWriter, never, RunDatabase>;
18
+ }
19
+ export { RepositoryLabel, RepositoryLabelColor, RepositoryLabelProjection } from "./model.ts";
20
+ //# sourceMappingURL=repository-label-projection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repository-label-projection.d.ts","sourceRoot":"","sources":["../../src/repository-label-projection/repository-label-projection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAmB,yBAAyB,EAAE,MAAM,YAAY,CAAC;;kBA0FtD,CACZ,UAAU,EAAE,cAAc,KACvB,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,yBAAyB,CAAC,EAAE,sBAAsB,CAAC;;AALxF,qBAAa,+BAAgC,SAAQ,oCAOD;IAClD,MAAM,CAAC,QAAQ,CAAC,KAAK,mEAA6D;CACnF;;IAKG,mDAAmD;sBACjC,CAChB,UAAU,EAAE,yBAAyB,KAClC,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,sBAAsB,CAAC;;AANvD,qBAAa,+BAAgC,SAAQ,oCAQD;IAClD,MAAM,CAAC,QAAQ,CAAC,KAAK,mEAA6D;CACnF;AAED,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,83 @@
1
+ import { RepositoryName } from "@usine/core/repository";
2
+ import { eq, ne } from "drizzle-orm";
3
+ import { Context, Effect, Layer, Option, Schema } from "effect";
4
+ import { RunDatabase } from "../database/database.js";
5
+ import { repositoryLabelProjections } from "../database/schema.js";
6
+ import { EnginePersistenceError } from "../engine/error.js";
7
+ import { RepositoryLabel, RepositoryLabelProjection } from "./model.js";
8
+ /** Rows written before colors were kept are bare names and read as colorless labels. */
9
+ const LegacyLabelNames = Schema.Array(Schema.String);
10
+ const isLegacyLabelNames = Schema.is(LegacyLabelNames);
11
+ const RepositoryLabelProjectionRow = Schema.Struct({
12
+ repository: RepositoryName,
13
+ labels: Schema.Union([RepositoryLabelProjection.fields.labels, LegacyLabelNames]),
14
+ });
15
+ const storedLabels = (labels) => isLegacyLabelNames(labels)
16
+ ? labels.map((name) => new RepositoryLabel({ name, color: Option.none(), description: Option.none() }))
17
+ : labels;
18
+ const decodeRows = Schema.decodeUnknownEffect(Schema.Array(RepositoryLabelProjectionRow));
19
+ const encodeLabels = Schema.encodeSync(RepositoryLabelProjection.fields.labels);
20
+ const persistence = (operation) => (effect) => Effect.mapError(effect, (cause) => new EnginePersistenceError({ operation, cause }));
21
+ const makeReader = Effect.gen(function* () {
22
+ const database = yield* RunDatabase;
23
+ return {
24
+ get: Effect.fn("RepositoryLabelProjectionReader.get")(function* (repository) {
25
+ const rows = yield* database
26
+ .select({
27
+ repository: repositoryLabelProjections.repository,
28
+ labels: repositoryLabelProjections.labelsJson,
29
+ })
30
+ .from(repositoryLabelProjections)
31
+ .where(eq(repositoryLabelProjections.repository, repository))
32
+ .limit(1)
33
+ .execute();
34
+ const decoded = yield* decodeRows(rows, { onExcessProperty: "error" });
35
+ const row = decoded[0];
36
+ return row === undefined
37
+ ? Option.none()
38
+ : Option.some(new RepositoryLabelProjection({
39
+ repository: row.repository,
40
+ labels: storedLabels(row.labels),
41
+ }));
42
+ }, persistence("read repository label projection")),
43
+ };
44
+ });
45
+ const makeWriter = Effect.gen(function* () {
46
+ const database = yield* RunDatabase;
47
+ return {
48
+ replace: Effect.fn("RepositoryLabelProjectionWriter.replace")(function* (projection) {
49
+ yield* Effect.annotateCurrentSpan({ repository: projection.repository });
50
+ const labelsJson = encodeLabels(projection.labels);
51
+ const changed = yield* database
52
+ .insert(repositoryLabelProjections)
53
+ .values({ repository: projection.repository, labelsJson })
54
+ .onConflictDoUpdate({
55
+ target: repositoryLabelProjections.repository,
56
+ set: { labelsJson },
57
+ setWhere: ne(repositoryLabelProjections.labelsJson, labelsJson),
58
+ })
59
+ .returning({ repository: repositoryLabelProjections.repository })
60
+ .execute();
61
+ if (changed.length === 0) {
62
+ yield* Effect.logDebug("Repository label projection already matched GitHub", {
63
+ repository: projection.repository,
64
+ labels: projection.labels.length,
65
+ });
66
+ return false;
67
+ }
68
+ yield* Effect.logDebug("Repository label projection updated from trigger polling", {
69
+ repository: projection.repository,
70
+ labels: projection.labels.length,
71
+ });
72
+ return true;
73
+ }, persistence("write repository label projection")),
74
+ };
75
+ });
76
+ export class RepositoryLabelProjectionReader extends Context.Service()("@usine/engine/RepositoryLabelProjectionReader") {
77
+ static layer = Layer.effect(RepositoryLabelProjectionReader, makeReader);
78
+ }
79
+ export class RepositoryLabelProjectionWriter extends Context.Service()("@usine/engine/RepositoryLabelProjectionWriter") {
80
+ static layer = Layer.effect(RepositoryLabelProjectionWriter, makeWriter);
81
+ }
82
+ export { RepositoryLabel, RepositoryLabelColor, RepositoryLabelProjection } from "./model.js";
83
+ //# sourceMappingURL=repository-label-projection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repository-label-projection.js","sourceRoot":"","sources":["../../src/repository-label-projection/repository-label-projection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAExE,wFAAwF;AACxF,MAAM,gBAAgB,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AACrD,MAAM,kBAAkB,GAAG,MAAM,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC;AACvD,MAAM,4BAA4B,GAAG,MAAM,CAAC,MAAM,CAAC;IACjD,UAAU,EAAE,cAAc;IAC1B,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,yBAAyB,CAAC,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;CAClF,CAAC,CAAC;AACH,MAAM,YAAY,GAAG,CACnB,MAA4D,EAC5B,EAAE,CAClC,kBAAkB,CAAC,MAAM,CAAC;IACxB,CAAC,CAAC,MAAM,CAAC,GAAG,CACR,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,eAAe,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,MA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zB,KAAK,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,oDAAoD,EAAE;oBAC3E,UAAU,EAAE,UAAU,CAAC,UAAU;oBACjC,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,MAAM;iBACjC,CAAC,CAAC;gBACH,OAAO,KAAK,CAAC;YACf,CAAC;YACD,KAAK,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,0DAA0D,EAAE;gBACjF,UAAU,EAAE,UAAU,CAAC,UAAU;gBACjC,MAAM,EAAE,UAAU,CAAC,MAAM,CAAC,MAAM;aACjC,CAAC,CAAC;YACH,OAAO,IAAI,CAAC;QACd,CAAC,EAAE,WAAW,CAAC,mCAAmC,CAAC,CAAC;KAC5C,CAAC;AACb,CAAC,CAAC,CAAC;AAEH,MAAM,OAAO,+BAAgC,SAAQ,OAAO,CAAC,OAAO,EAOjE,CAAC,+CAA+C,CAAC;IAClD,MAAM,CAAU,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,+BAA+B,EAAE,UAAU,CAAC,CAAC;CACnF;AAED,MAAM,OAAO,+BAAgC,SAAQ,OAAO,CAAC,OAAO,EAQjE,CAAC,+CAA+C,CAAC;IAClD,MAAM,CAAU,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,+BAA+B,EAAE,UAAU,CAAC,CAAC;CACnF;AAED,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,46 @@
1
+ import { Agent } from "@usine/core/agent";
2
+ import { Attempt } from "@usine/core/attempt";
3
+ import { Event } from "@usine/core/event";
4
+ import { Run } from "@usine/core/run";
5
+ import { Step } from "@usine/core/step";
6
+ import { Schema } from "effect";
7
+ import { TranscriptEntry } from "../transcript.ts";
8
+ declare const RunSnapshot_base: Schema.Class<RunSnapshot, Schema.Struct<{
9
+ readonly event: typeof Event;
10
+ readonly itemKey: Schema.brand<Schema.NonEmptyString, "ItemKey">;
11
+ readonly run: typeof Run;
12
+ readonly step: typeof Step;
13
+ readonly attempts: Schema.$Array<typeof Attempt>;
14
+ readonly repository: Schema.brand<Schema.String, "RepositoryName">;
15
+ readonly revision: Schema.brand<Schema.String, "RepositoryRevision">;
16
+ readonly task: Schema.brand<Schema.String, "AttemptTask">;
17
+ readonly agent: typeof Agent;
18
+ readonly parentModel: Schema.Option<Schema.brand<Schema.String, "ModelId">>;
19
+ }>, {}>;
20
+ /** The full durable view of one Run. */
21
+ export declare class RunSnapshot extends RunSnapshot_base {
22
+ }
23
+ declare const RunEvidence_base: Schema.Class<RunEvidence, Schema.Struct<{
24
+ readonly snapshot: typeof RunSnapshot;
25
+ readonly transcript: Schema.$Array<typeof TranscriptEntry>;
26
+ }>, {}>;
27
+ /** A Run snapshot and all its saved transcript entries from the same database transaction. */
28
+ export declare class RunEvidence extends RunEvidence_base {
29
+ }
30
+ declare const RunSummary_base: Schema.Class<RunSummary, Schema.Struct<{
31
+ readonly itemKey: Schema.brand<Schema.NonEmptyString, "ItemKey">;
32
+ readonly run: typeof Run;
33
+ readonly step: typeof Step;
34
+ readonly attempts: Schema.$Array<typeof Attempt>;
35
+ readonly repository: Schema.brand<Schema.String, "RepositoryName">;
36
+ readonly task: Schema.brand<Schema.String, "AttemptTask">;
37
+ readonly agent: typeof Agent;
38
+ }>, {}>;
39
+ /** The lighter view used when listing Runs for operators. */
40
+ export declare class RunSummary extends RunSummary_base {
41
+ }
42
+ /** Monotonic version of the operator projection. */
43
+ export declare const ProjectionRevision: Schema.brand<Schema.Int, "ProjectionRevision">;
44
+ export type ProjectionRevision = typeof ProjectionRevision.Type;
45
+ export {};
46
+ //# sourceMappingURL=model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/run-reader/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1C,OAAO,EAAE,OAAO,EAAe,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAG1C,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;;;;;;;;;;;;;AAEnD,wCAAwC;AACxC,qBAAa,WAAY,SAAQ,gBAW/B;CAAG;;;;;AAEL,8FAA8F;AAC9F,qBAAa,WAAY,SAAQ,gBAG/B;CAAG;;;;;;;;;;AAEL,6DAA6D;AAC7D,qBAAa,UAAW,SAAQ,eAQ9B;CAAG;AAEL,oDAAoD;AACpD,eAAO,MAAM,kBAAkB,gDAE9B,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,OAAO,kBAAkB,CAAC,IAAI,CAAC"}
@@ -0,0 +1,44 @@
1
+ import { Agent } from "@usine/core/agent";
2
+ import { ModelId } from "@usine/core/agent/brain";
3
+ import { Attempt, AttemptTask } from "@usine/core/attempt";
4
+ import { Event } from "@usine/core/event";
5
+ import { ItemKey } from "@usine/core/item";
6
+ import { RepositoryName, RepositoryRevision } from "@usine/core/repository";
7
+ import { Run } from "@usine/core/run";
8
+ import { Step } from "@usine/core/step";
9
+ import { Schema } from "effect";
10
+ import { TranscriptEntry } from "../transcript.js";
11
+ /** The full durable view of one Run. */
12
+ export class RunSnapshot extends Schema.Class("@usine/engine/RunSnapshot")({
13
+ event: Event,
14
+ itemKey: ItemKey,
15
+ run: Run,
16
+ step: Step,
17
+ attempts: Schema.Array(Attempt),
18
+ repository: RepositoryName,
19
+ revision: RepositoryRevision,
20
+ task: AttemptTask,
21
+ agent: Agent,
22
+ parentModel: Schema.Option(ModelId),
23
+ }) {
24
+ }
25
+ /** A Run snapshot and all its saved transcript entries from the same database transaction. */
26
+ export class RunEvidence extends Schema.Class("@usine/engine/RunEvidence")({
27
+ snapshot: RunSnapshot,
28
+ transcript: Schema.Array(TranscriptEntry),
29
+ }) {
30
+ }
31
+ /** The lighter view used when listing Runs for operators. */
32
+ export class RunSummary extends Schema.Class("@usine/engine/RunSummary")({
33
+ itemKey: ItemKey,
34
+ run: Run,
35
+ step: Step,
36
+ attempts: Schema.Array(Attempt),
37
+ repository: RepositoryName,
38
+ task: AttemptTask,
39
+ agent: Agent,
40
+ }) {
41
+ }
42
+ /** Monotonic version of the operator projection. */
43
+ export const ProjectionRevision = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)).pipe(Schema.brand("ProjectionRevision"));
44
+ //# sourceMappingURL=model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/run-reader/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,wCAAwC;AACxC,MAAM,OAAO,WAAY,SAAQ,MAAM,CAAC,KAAK,CAAc,2BAA2B,CAAC,CAAC;IACtF,KAAK,EAAE,KAAK;IACZ,OAAO,EAAE,OAAO;IAChB,GAAG,EAAE,GAAG;IACR,IAAI,EAAE,IAAI;IACV,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC;IAC/B,UAAU,EAAE,cAAc;IAC1B,QAAQ,EAAE,kBAAkB;IAC5B,IAAI,EAAE,WAAW;IACjB,KAAK,EAAE,KAAK;IACZ,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;CACpC,CAAC;CAAG;AAEL,8FAA8F;AAC9F,MAAM,OAAO,WAAY,SAAQ,MAAM,CAAC,KAAK,CAAc,2BAA2B,CAAC,CAAC;IACtF,QAAQ,EAAE,WAAW;IACrB,UAAU,EAAE,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC;CAC1C,CAAC;CAAG;AAEL,6DAA6D;AAC7D,MAAM,OAAO,UAAW,SAAQ,MAAM,CAAC,KAAK,CAAa,0BAA0B,CAAC,CAAC;IACnF,OAAO,EAAE,OAAO;IAChB,GAAG,EAAE,GAAG;IACR,IAAI,EAAE,IAAI;IACV,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC;IAC/B,UAAU,EAAE,cAAc;IAC1B,IAAI,EAAE,WAAW;IACjB,KAAK,EAAE,KAAK;CACb,CAAC;CAAG;AAEL,oDAAoD;AACpD,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CACvF,MAAM,CAAC,KAAK,CAAC,oBAAoB,CAAC,CACnC,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { Context, Effect, Layer, Option } from "effect";
2
+ import { RunId } from "@usine/core/run";
3
+ import { ItemKey } from "@usine/core/item";
4
+ import { RunDatabase } from "../database/database.ts";
5
+ import { ProjectionRevision, RunEvidence, RunSnapshot, RunSummary } from "./model.ts";
6
+ import { TranscriptEntry, TranscriptQuery } from "../transcript.ts";
7
+ import type { RunStoreError } from "../engine/error.ts";
8
+ declare const RunReader_base: Context.ServiceClass<RunReader, "@usine/engine/RunReader", {
9
+ /** Reads a Run's current state, effective task and Agent, Step result, and Attempt history. */
10
+ readonly inspect: (runId: RunId) => Effect.Effect<RunSnapshot, RunStoreError>;
11
+ /** Reads one consistent Run snapshot and every saved transcript entry, in append order without a page limit. */
12
+ readonly evidence: (runId: RunId) => Effect.Effect<RunEvidence, RunStoreError>;
13
+ /** Every open Run plus the newest `closedLimit` settled ones, newest first. */
14
+ readonly list: (options: {
15
+ readonly closedLimit: number;
16
+ }) => Effect.Effect<ReadonlyArray<RunSummary>, RunStoreError>;
17
+ /** Every saved Run for the supplied Items, newest first, including all their Attempts. */
18
+ readonly forItems: (itemKeys: ReadonlyArray<ItemKey>) => Effect.Effect<ReadonlyArray<RunSummary>, RunStoreError>;
19
+ /** `None` means the invalidation row is absent: treat every cached projection as stale. */
20
+ readonly revision: () => Effect.Effect<Option.Option<ProjectionRevision>, RunStoreError>;
21
+ /** Reads the requested portion of one Attempt's saved transcript in append order. */
22
+ readonly transcript: (query: TranscriptQuery) => Effect.Effect<ReadonlyArray<TranscriptEntry>, RunStoreError>;
23
+ }>;
24
+ /** Reads saved Run state and transcripts without starting or recovering execution. */
25
+ export declare class RunReader extends RunReader_base {
26
+ static readonly layer: Layer.Layer<RunReader, never, RunDatabase>;
27
+ }
28
+ export { RunEvidence, RunSnapshot, RunSummary, ProjectionRevision } from "./model.ts";
29
+ //# sourceMappingURL=run-reader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-reader.d.ts","sourceRoot":"","sources":["../../src/run-reader/run-reader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACtF,OAAO,EAAsB,eAAe,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;;IAuDpD,+FAA+F;sBAC7E,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,aAAa,CAAC;IAC7E,gHAAgH;uBAC7F,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,aAAa,CAAC;IAC9E,+EAA+E;mBAChE,CAAC,OAAO,EAAE;QACvB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;KAC9B,KAAK,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC,EAAE,aAAa,CAAC;IAC7D,0FAA0F;uBACvE,CACjB,QAAQ,EAAE,aAAa,CAAC,OAAO,CAAC,KAC7B,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC,EAAE,aAAa,CAAC;IAC5D,2FAA2F;uBACxE,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,EAAE,aAAa,CAAC;IACxF,qFAAqF;yBAChE,CACnB,KAAK,EAAE,eAAe,KACnB,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,eAAe,CAAC,EAAE,aAAa,CAAC;;AArBrE,sFAAsF;AACtF,qBAAa,SAAU,SAAQ,cAsBD;IAC5B,MAAM,CAAC,QAAQ,CAAC,KAAK,6CAA0C;CAChE;AAED,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,44 @@
1
+ import { Context, Effect, Layer, Option } from "effect";
2
+ import { RunId } from "@usine/core/run";
3
+ import { ItemKey } from "@usine/core/item";
4
+ import { RunDatabase } from "../database/database.js";
5
+ import { ProjectionRevision, RunEvidence, RunSnapshot, RunSummary } from "./model.js";
6
+ import { TranscriptAllQuery, TranscriptEntry, TranscriptQuery } from "../transcript.js";
7
+ import { persistence } from "../store/codec.js";
8
+ import { queriesFor } from "../store/queries.js";
9
+ const makeRunReader = Effect.gen(function* () {
10
+ const database = yield* RunDatabase;
11
+ const queries = queriesFor(database);
12
+ const inspect = Effect.fn("RunReader.inspect")((runId) => queries.snapshot(runId).pipe(persistence("read run")));
13
+ const evidence = Effect.fn("RunReader.evidence")(function* (runId) {
14
+ yield* Effect.annotateCurrentSpan({ runId });
15
+ const evidence = yield* database
16
+ .transaction((transaction) => Effect.gen(function* () {
17
+ const queries = queriesFor(transaction);
18
+ const snapshot = yield* queries.snapshot(runId);
19
+ const transcripts = yield* Effect.forEach(snapshot.attempts, ({ id }) => queries.transcript(new TranscriptAllQuery({ attemptId: id })));
20
+ return new RunEvidence({
21
+ snapshot,
22
+ transcript: transcripts.flat().sort((left, right) => left.sequence - right.sequence),
23
+ });
24
+ }))
25
+ .pipe(persistence("read Run evidence"));
26
+ yield* Effect.logDebug("Run evidence read", {
27
+ runId,
28
+ attempts: evidence.snapshot.attempts.length,
29
+ transcriptRows: evidence.transcript.length,
30
+ });
31
+ return evidence;
32
+ });
33
+ const list = Effect.fn("RunReader.list")((options) => queries.runSummaries(options.closedLimit).pipe(persistence("list runs")));
34
+ const revision = Effect.fn("RunReader.revision")(() => queries.revision().pipe(persistence("read projection revision")));
35
+ const forItems = Effect.fn("RunReader.forItems")((itemKeys) => queries.itemRunSummaries(itemKeys).pipe(persistence("read Item Run histories")));
36
+ const transcript = Effect.fn("RunReader.transcript")((query) => queries.transcript(query).pipe(persistence("read Attempt transcript")));
37
+ return { inspect, evidence, list, forItems, revision, transcript };
38
+ });
39
+ /** Reads saved Run state and transcripts without starting or recovering execution. */
40
+ export class RunReader extends Context.Service()("@usine/engine/RunReader") {
41
+ static layer = Layer.effect(RunReader, makeRunReader);
42
+ }
43
+ export { RunEvidence, RunSnapshot, RunSummary, ProjectionRevision } from "./model.js";
44
+ //# sourceMappingURL=run-reader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-reader.js","sourceRoot":"","sources":["../../src/run-reader/run-reader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACtF,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAExF,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IACxC,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,WAAW,CAAC;IACpC,MAAM,OAAO,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;IAErC,MAAM,OAAO,GAAG,MAAM,CAAC,EAAE,CAAC,mBAAmB,CAAC,CAAC,CAAC,KAAY,EAAE,EAAE,CAC9D,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,CACtD,CAAC;IACF,MAAM,QAAQ,GAAG,MAAM,CAAC,EAAE,CAAC,oBAAoB,CAAC,CAAC,QAAQ,CAAC,EAAE,KAAY;QACtE,KAAK,CAAC,CAAC,MAAM,CAAC,mBAAmB,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QAC7C,MAAM,QAAQ,GAAG,KAAK,CAA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AAC;IACF,MAAM,QAAQ,GAAG,MAAM,CAAC,EAAE,CAAC,oBAAoB,CAAC,CAAC,GAAG,EAAE,CACpD,OAAO,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,0BAA0B,CAAC,CAAC,CACjE,CAAC;IACF,MAAM,QAAQ,GAAG,MAAM,CAAC,EAAE,CAAC,oBAAoB,CAAC,CAAC,CAAC,QAAgC,EAAE,EAAE,CACpF,OAAO,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,yBAAyB,CAAC,CAAC,CAChF,CAAC;IACF,MAAM,UAAU,GAAG,MAAM,CAAC,EAAE,CAAC,sBAAsB,CAAC,CAAC,CAAC,KAAsB,EAAE,EAAE,CAC9E,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,yBAAyB,CAAC,CAAC,CACvE,CAAC;IAEF,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAW,CAAC;AAC9E,CAAC,CAAC,CAAC;AAEH,sFAAsF;AACtF,MAAM,OAAO,SAAU,SAAQ,OAAO,CAAC,OAAO,EAsB3C,CAAC,yBAAyB,CAAC;IAC5B,MAAM,CAAU,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;CAChE;AAED,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,43 @@
1
+ import { Agent } from "@usine/core/agent";
2
+ import { Attempt, type AttemptId } from "@usine/core/attempt";
3
+ import { Event } from "@usine/core/event";
4
+ import { Run } from "@usine/core/run";
5
+ import { Step } from "@usine/core/step";
6
+ import { Schema, Context, Effect } from "effect";
7
+ import type * as AttemptChannel from "@usine/core/attempt/channel";
8
+ import type { AttemptFailure } from "@usine/core/attempt/failure";
9
+ import type { WorkerName } from "@usine/core/worker";
10
+ import type { StepResult } from "@usine/core/step/result";
11
+ import type { Submission } from "./engine/submission.ts";
12
+ declare const StepExecution_base: Schema.Class<StepExecution, Schema.Struct<{
13
+ readonly attempt: typeof Attempt;
14
+ readonly event: typeof Event;
15
+ readonly run: typeof Run;
16
+ readonly step: typeof Step;
17
+ readonly repository: Schema.brand<Schema.String, "RepositoryName">;
18
+ readonly revision: Schema.brand<Schema.String, "RepositoryRevision">;
19
+ readonly task: Schema.brand<Schema.String, "AttemptTask">;
20
+ readonly agent: typeof Agent;
21
+ readonly parentModel: Schema.Option<Schema.brand<Schema.String, "ModelId">>;
22
+ }>, {}>;
23
+ /** The saved Event, effective task and Agent, and Step being tried in one Attempt. */
24
+ export declare class StepExecution extends StepExecution_base {
25
+ }
26
+ /** A reservation of one Worker's capacity for the length of an Attempt. Call `release` when the Attempt ends. */
27
+ export interface WorkerLease {
28
+ readonly worker: WorkerName;
29
+ readonly release: Effect.Effect<void>;
30
+ }
31
+ declare const StepExecutor_base: Context.ServiceClass<StepExecutor, "@usine/engine/StepExecutor", {
32
+ /** Requests that the identified Attempt stop its current work. */
33
+ readonly interrupt: (attemptId: AttemptId) => Effect.Effect<void, AttemptFailure>;
34
+ /** Waits for Worker capacity; the returned lease must be released after execution or cancellation. */
35
+ readonly reserve: (submission: Submission) => Effect.Effect<WorkerLease, AttemptFailure>;
36
+ /** Runs the reserved Attempt, recording channel activity through `io`, and waits for its result. */
37
+ readonly execute: (execution: StepExecution, io: AttemptChannel.Sink) => Effect.Effect<StepResult, AttemptFailure>;
38
+ }>;
39
+ /** Runs one Attempt on a Worker: reserve capacity, execute the step, interrupt on cancel. */
40
+ export declare class StepExecutor extends StepExecutor_base {
41
+ }
42
+ export {};
43
+ //# sourceMappingURL=step-executor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"step-executor.d.ts","sourceRoot":"","sources":["../src/step-executor.ts"],"names":[],"mappings":"AAAA,OAAO,EAA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;CAAG"}
@@ -0,0 +1,25 @@
1
+ import { Agent } from "@usine/core/agent";
2
+ import { ModelId } from "@usine/core/agent/brain";
3
+ import { Attempt, AttemptTask } from "@usine/core/attempt";
4
+ import { Event } from "@usine/core/event";
5
+ import { RepositoryName, RepositoryRevision } from "@usine/core/repository";
6
+ import { Run } from "@usine/core/run";
7
+ import { Step } from "@usine/core/step";
8
+ import { Schema, Context, Effect } from "effect";
9
+ /** The saved Event, effective task and Agent, and Step being tried in one Attempt. */
10
+ export class StepExecution extends Schema.Class("@usine/engine/StepExecution")({
11
+ attempt: Attempt,
12
+ event: Event,
13
+ run: Run,
14
+ step: Step,
15
+ repository: RepositoryName,
16
+ revision: RepositoryRevision,
17
+ task: AttemptTask,
18
+ agent: Agent,
19
+ parentModel: Schema.Option(ModelId),
20
+ }) {
21
+ }
22
+ /** Runs one Attempt on a Worker: reserve capacity, execute the step, interrupt on cancel. */
23
+ export class StepExecutor extends Context.Service()("@usine/engine/StepExecutor") {
24
+ }
25
+ //# sourceMappingURL=step-executor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"step-executor.js","sourceRoot":"","sources":["../src/step-executor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,WAAW,EAAkB,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAOjD,sFAAsF;AACtF,MAAM,OAAO,aAAc,SAAQ,MAAM,CAAC,KAAK,CAAgB,6BAA6B,CAAC,CAAC;IAC5F,OAAO,EAAE,OAAO;IAChB,KAAK,EAAE,KAAK;IACZ,GAAG,EAAE,GAAG;IACR,IAAI,EAAE,IAAI;IACV,UAAU,EAAE,cAAc;IAC1B,QAAQ,EAAE,kBAAkB;IAC5B,IAAI,EAAE,WAAW;IACjB,KAAK,EAAE,KAAK;IACZ,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;CACpC,CAAC;CAAG;AAQL,6FAA6F;AAC7F,MAAM,OAAO,YAAa,SAAQ,OAAO,CAAC,OAAO,EAa9C,CAAC,4BAA4B,CAAC;CAAG"}