@usine/orchestrator 0.1.0 → 0.2.1

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 (122) hide show
  1. package/README.md +46 -21
  2. package/dist/board/items.d.ts +18 -0
  3. package/dist/board/items.d.ts.map +1 -0
  4. package/dist/board/items.js +46 -0
  5. package/dist/board/items.js.map +1 -0
  6. package/dist/board/projection.d.ts +6 -5
  7. package/dist/board/projection.d.ts.map +1 -1
  8. package/dist/board/projection.js +25 -65
  9. package/dist/board/projection.js.map +1 -1
  10. package/dist/board/tasks.d.ts +8 -0
  11. package/dist/board/tasks.d.ts.map +1 -0
  12. package/dist/board/tasks.js +86 -0
  13. package/dist/board/tasks.js.map +1 -0
  14. package/dist/credentials.d.ts +6 -6
  15. package/dist/credentials.d.ts.map +1 -1
  16. package/dist/credentials.js +6 -6
  17. package/dist/credentials.js.map +1 -1
  18. package/dist/exe-dev.d.ts +5 -4
  19. package/dist/exe-dev.d.ts.map +1 -1
  20. package/dist/exe-dev.js +5 -4
  21. package/dist/exe-dev.js.map +1 -1
  22. package/dist/idle-triggers.d.ts +1 -1
  23. package/dist/idle-triggers.d.ts.map +1 -1
  24. package/dist/idle-triggers.js +3 -1
  25. package/dist/idle-triggers.js.map +1 -1
  26. package/dist/label-reconciler.d.ts +30 -0
  27. package/dist/label-reconciler.d.ts.map +1 -0
  28. package/dist/label-reconciler.js +119 -0
  29. package/dist/label-reconciler.js.map +1 -0
  30. package/dist/local.d.ts +17 -12
  31. package/dist/local.d.ts.map +1 -1
  32. package/dist/local.js +20 -13
  33. package/dist/local.js.map +1 -1
  34. package/dist/operator/attempt.d.ts +69 -0
  35. package/dist/operator/attempt.d.ts.map +1 -0
  36. package/dist/operator/attempt.js +62 -0
  37. package/dist/operator/attempt.js.map +1 -0
  38. package/dist/operator/board.d.ts +119 -0
  39. package/dist/operator/board.d.ts.map +1 -0
  40. package/dist/operator/board.js +101 -0
  41. package/dist/operator/board.js.map +1 -0
  42. package/dist/operator/http.d.ts +180 -0
  43. package/dist/operator/http.d.ts.map +1 -0
  44. package/dist/operator/http.js +150 -0
  45. package/dist/operator/http.js.map +1 -0
  46. package/dist/operator/need.d.ts +66 -0
  47. package/dist/operator/need.d.ts.map +1 -0
  48. package/dist/operator/need.js +70 -0
  49. package/dist/operator/need.js.map +1 -0
  50. package/dist/operator/operator.d.ts +68 -0
  51. package/dist/operator/operator.d.ts.map +1 -0
  52. package/dist/operator/operator.js +402 -0
  53. package/dist/operator/operator.js.map +1 -0
  54. package/dist/operator/overview.d.ts +51 -0
  55. package/dist/operator/overview.d.ts.map +1 -0
  56. package/dist/operator/overview.js +48 -0
  57. package/dist/operator/overview.js.map +1 -0
  58. package/dist/operator/projection.d.ts +12 -9
  59. package/dist/operator/projection.d.ts.map +1 -1
  60. package/dist/operator/projection.js +44 -17
  61. package/dist/operator/projection.js.map +1 -1
  62. package/dist/operator/run.d.ts +62 -0
  63. package/dist/operator/run.d.ts.map +1 -0
  64. package/dist/operator/run.js +61 -0
  65. package/dist/operator/run.js.map +1 -0
  66. package/dist/operator/transcript.d.ts +59 -0
  67. package/dist/operator/transcript.d.ts.map +1 -0
  68. package/dist/operator/transcript.js +66 -0
  69. package/dist/operator/transcript.js.map +1 -0
  70. package/dist/orchestrator.d.ts +3 -2
  71. package/dist/orchestrator.d.ts.map +1 -1
  72. package/dist/orchestrator.js +1 -1
  73. package/dist/orchestrator.js.map +1 -1
  74. package/dist/polling/cycle.d.ts +51 -0
  75. package/dist/polling/cycle.d.ts.map +1 -0
  76. package/dist/polling/cycle.js +44 -0
  77. package/dist/polling/cycle.js.map +1 -0
  78. package/dist/polling/hints.d.ts +20 -0
  79. package/dist/polling/hints.d.ts.map +1 -0
  80. package/dist/polling/hints.js +54 -0
  81. package/dist/polling/hints.js.map +1 -0
  82. package/dist/polling/loop-evaluation.d.ts +21 -0
  83. package/dist/polling/loop-evaluation.d.ts.map +1 -0
  84. package/dist/polling/loop-evaluation.js +131 -0
  85. package/dist/polling/loop-evaluation.js.map +1 -0
  86. package/dist/polling/polling.d.ts +36 -0
  87. package/dist/polling/polling.d.ts.map +1 -0
  88. package/dist/polling/polling.js +296 -0
  89. package/dist/polling/polling.js.map +1 -0
  90. package/dist/polling/repository-sync.d.ts +45 -0
  91. package/dist/polling/repository-sync.d.ts.map +1 -0
  92. package/dist/polling/repository-sync.js +169 -0
  93. package/dist/polling/repository-sync.js.map +1 -0
  94. package/dist/polling-triggers.d.ts +3 -39
  95. package/dist/polling-triggers.d.ts.map +1 -1
  96. package/dist/polling-triggers.js +3 -393
  97. package/dist/polling-triggers.js.map +1 -1
  98. package/dist/schedule-triggers.d.ts +17 -15
  99. package/dist/schedule-triggers.d.ts.map +1 -1
  100. package/dist/schedule-triggers.js +53 -43
  101. package/dist/schedule-triggers.js.map +1 -1
  102. package/dist/scheduler.d.ts +5 -5
  103. package/dist/scheduler.d.ts.map +1 -1
  104. package/dist/scheduler.js +30 -44
  105. package/dist/scheduler.js.map +1 -1
  106. package/dist/trigger-submission.d.ts +33 -24
  107. package/dist/trigger-submission.d.ts.map +1 -1
  108. package/dist/trigger-submission.js +30 -37
  109. package/dist/trigger-submission.js.map +1 -1
  110. package/package.json +50 -14
  111. package/dist/index.d.ts +0 -11
  112. package/dist/index.d.ts.map +0 -1
  113. package/dist/index.js +0 -11
  114. package/dist/index.js.map +0 -1
  115. package/dist/operator/model.d.ts +0 -280
  116. package/dist/operator/model.d.ts.map +0 -1
  117. package/dist/operator/model.js +0 -242
  118. package/dist/operator/model.js.map +0 -1
  119. package/dist/operator/service.d.ts +0 -36
  120. package/dist/operator/service.d.ts.map +0 -1
  121. package/dist/operator/service.js +0 -248
  122. package/dist/operator/service.js.map +0 -1
package/dist/exe-dev.js CHANGED
@@ -1,16 +1,17 @@
1
1
  import { NodeServices } from "@effect/platform-node";
2
- import { CredentialGrantMinutes, layer as exeDevExecutorLayer, } from "@usine/executor/exe-dev";
2
+ import { layer as exeDevExecutorLayer } from "@usine/executor/exe-dev";
3
+ import { CredentialGrantMinutes } from "@usine/executor/exe-dev";
3
4
  import { layer as localEngineLayer } from "@usine/engine/local-sqlite";
4
5
  import { Layer } from "effect";
5
6
  import { stepExecutorLayer } from "./scheduler.js";
6
- /** Complete local-orchestrator / exe.dev-Worker engine composition. */
7
- export const layer = (instanceDirectory, config, options) => {
7
+ /** The full engine composition for a local orchestrator driving exe.dev Workers; brains are the instance roster checked at startup. */
8
+ export const layer = (instanceDirectory, config, brains, options) => {
8
9
  const executor = exeDevExecutorLayer({
9
10
  ...options,
10
11
  credentialGrantMinutes: options.credentialGrantMinutes ??
11
12
  CredentialGrantMinutes.make(config.settings.maxAttemptMinutes + 5),
12
13
  }).pipe(Layer.provide(NodeServices.layer));
13
- const stepExecutor = stepExecutorLayer(config).pipe(Layer.provide(executor));
14
+ const stepExecutor = stepExecutorLayer(config, brains).pipe(Layer.provide(executor));
14
15
  return localEngineLayer(instanceDirectory).pipe(Layer.provide(stepExecutor));
15
16
  };
16
17
  //# sourceMappingURL=exe-dev.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"exe-dev.js","sourceRoot":"","sources":["../src/exe-dev.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAGrD,OAAO,EACL,sBAAsB,EACtB,KAAK,IAAI,mBAAmB,GAE7B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,KAAK,IAAI,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,uEAAuE;AACvE,MAAM,CAAC,MAAM,KAAK,GAAG,CACnB,iBAAqC,EACrC,MAAmB,EACnB,OAA8B,EAC9B,EAAE;IACF,MAAM,QAAQ,GAAG,mBAAmB,CAAC;QACnC,GAAG,OAAO;QACV,sBAAsB,EACpB,OAAO,CAAC,sB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IAC3C,MAAM,YAAY,GAAG,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;IACrF,OAAO,gBAAgB,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC;AAC/E,CAAC,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { Layer } from "effect";
2
2
  import { PollingTriggers } from "./polling-triggers.ts";
3
3
  import { ScheduleTriggers } from "./schedule-triggers.ts";
4
- /** Trigger services for needs-setup observation; no stream performs work. */
4
+ /** Trigger services that never poll or tick, for observing an instance that still needs setup. */
5
5
  export declare const idleTriggersLayer: Layer.Layer<PollingTriggers | ScheduleTriggers, never, never>;
6
6
  //# sourceMappingURL=idle-triggers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"idle-triggers.d.ts","sourceRoot":"","sources":["../src/idle-triggers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,EAAU,MAAM,QAAQ,CAAC;AAC/C,OAAO,EAAa,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAiB,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAEzE,6EAA6E;AAC7E,eAAO,MAAM,iBAAiB,+DAgC7B,CAAC"}
1
+ {"version":3,"file":"idle-triggers.d.ts","sourceRoot":"","sources":["../src/idle-triggers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,EAAU,MAAM,QAAQ,CAAC;AAC/C,OAAO,EAAa,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAiB,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAEzE,kGAAkG;AAClG,eAAO,MAAM,iBAAiB,+DAkC7B,CAAC"}
@@ -1,8 +1,9 @@
1
1
  import { Effect, Layer, Option } from "effect";
2
2
  import { PollCycle, PollingTriggers } from "./polling-triggers.js";
3
3
  import { ScheduleCycle, ScheduleTriggers } from "./schedule-triggers.js";
4
- /** Trigger services for needs-setup observation; no stream performs work. */
4
+ /** Trigger services that never poll or tick, for observing an instance that still needs setup. */
5
5
  export const idleTriggersLayer = Layer.mergeAll(Layer.succeed(PollingTriggers)({
6
+ hint: () => Effect.void,
6
7
  latest: Effect.succeed(Option.none()),
7
8
  poll: () => Effect.succeed(new PollCycle({
8
9
  repositories: 0,
@@ -10,6 +11,7 @@ export const idleTriggersLayer = Layer.mergeAll(Layer.succeed(PollingTriggers)({
10
11
  submissions: [],
11
12
  revokedRuns: 0,
12
13
  failures: [],
14
+ preflightFindings: [],
13
15
  nextPollAt: Option.none(),
14
16
  })),
15
17
  run: () => Effect.never,
@@ -1 +1 @@
1
- {"version":3,"file":"idle-triggers.js","sourceRoot":"","sources":["../src/idle-triggers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAEzE,6EAA6E;AAC7E,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,CAAC,QAAQ,CAC7C,KAAK,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IACrC,IAAI,EAAE,GAAG,EAAE,CACT,MAAM,CAAC,OAAO,CACZ,IAAI,SAAS,CAAC;QACZ,YAAY,EAAE,CAAC;QACf,YAAY,EAAE,CAAC;QACf,WAAW,EAAE,EAAE;QACf,WAAW,EAAE,CAAC;QACd,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,MAAM,CAAC,IAAI,EAAE;KAC1B,CAAC,CACH;IACH,GAAG,EAAE,GAAG,EAAE,CAAC,MA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BAAiB,EAAE,EAAE;QACrB,UAAU,EAAE,MAAM,CAAC,IAAI,EAAE;KAC1B,CAAC,CACH;IACH,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK;CACxB,CAAC,EACF,KAAK,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IACrC,IAAI,EAAE,GAAG,EAAE,CACT,MAAM,CAAC,OAAO,CACZ,IAAI,aAAa,CAAC;QAChB,KAAK,EAAE,CAAC;QACR,MAAM,EAAE,CAAC;QACT,WAAW,EAAE,EAAE;QACf,OAAO,EAAE,CAAC;QACV,YAAY,EAAE,CAAC;QACf,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,MAAM,CAAC,IAAI,EAAE;KAC1B,CAAC,CACH;IACH,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK;CACxB,CAAC,CACH,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { type DeclaredLabel } from "@usine/config/label";
2
+ import { RepositoryName } from "@usine/core/repository";
3
+ import { RepositoryLabel as StoredRepositoryLabel } from "@usine/engine/repository-label-projection";
4
+ import { GitHubLabelWriter } from "@usine/github/label-writer";
5
+ import { Context, DateTime, Effect, Layer, Option, Schema } from "effect";
6
+ declare const LabelPreflightFinding_base: Schema.Class<LabelPreflightFinding, Schema.Struct<{
7
+ readonly repository: Schema.brand<Schema.String, "RepositoryName">;
8
+ readonly label: Schema.brand<Schema.String, "GitHubLabelName">;
9
+ readonly errorTag: Schema.NonEmptyString;
10
+ readonly message: Schema.NonEmptyString;
11
+ }>, {}>;
12
+ export declare class LabelPreflightFinding extends LabelPreflightFinding_base {
13
+ }
14
+ export interface LabelReconciliation {
15
+ readonly labels: ReadonlyArray<StoredRepositoryLabel>;
16
+ readonly findings: ReadonlyArray<LabelPreflightFinding>;
17
+ /** True when a label was created, so the poll cursor must drop its catalog ETag. */
18
+ readonly catalogChanged: boolean;
19
+ /** When a creation rate limit asks the next cycle to wait; this cycle's triggers still run. */
20
+ readonly nextPollAt: Option.Option<DateTime.Utc>;
21
+ }
22
+ declare const LabelReconciler_base: Context.ServiceClass<LabelReconciler, "@usine/orchestrator/LabelReconciler", {
23
+ readonly reconcile: (repository: RepositoryName, declared: ReadonlyArray<DeclaredLabel>, existing: ReadonlyArray<StoredRepositoryLabel>) => Effect.Effect<LabelReconciliation>;
24
+ }>;
25
+ /** Creates the labels a factory declares that one repository's stored catalog lacks. */
26
+ export declare class LabelReconciler extends LabelReconciler_base {
27
+ static readonly layer: Layer.Layer<LabelReconciler, never, GitHubLabelWriter>;
28
+ }
29
+ export {};
30
+ //# sourceMappingURL=label-reconciler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"label-reconciler.d.ts","sourceRoot":"","sources":["../src/label-reconciler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,aAAa,EAAmB,MAAM,qBAAqB,CAAC;AAC9F,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,eAAe,IAAI,qBAAqB,EAAE,MAAM,2CAA2C,CAAC;AACrG,OAAO,EAAE,iBAAiB,EAAsB,MAAM,4BAA4B,CAAC;AAEnF,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAC;;;;;;;AAElF,qBAAa,qBAAsB,SAAQ,0BAOzC;CAAG;AAEL,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,qBAAqB,CAAC,CAAC;IACtD,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC,qBAAqB,CAAC,CAAC;IACxD,oFAAoF;IACpF,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IACjC,+FAA+F;IAC/F,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;CAClD;;wBA2CuB,CAClB,UAAU,EAAE,cAAc,EAC1B,QAAQ,EAAE,aAAa,CAAC,aAAa,CAAC,EACtC,QAAQ,EAAE,aAAa,CAAC,qBAAqB,CAAC,KAC3C,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC;;AAR3C,wFAAwF;AACxF,qBAAa,eAAgB,SAAQ,oBASK;IACxC,MAAM,CAAC,QAAQ,CAAC,KAAK,yDAkGnB;CACH"}
@@ -0,0 +1,119 @@
1
+ import { canonicalLabelName, GitHubLabelName } from "@usine/config/label";
2
+ import { RepositoryName } from "@usine/core/repository";
3
+ import { RepositoryLabel as StoredRepositoryLabel } from "@usine/engine/repository-label-projection";
4
+ import { GitHubLabelWriter, NewRepositoryLabel } from "@usine/github/label-writer";
5
+ import { RepositoryLabelColor, RepositoryLabelName } from "@usine/github/polling";
6
+ import { Context, DateTime, Effect, Layer, Option, Result, Schema } from "effect";
7
+ export class LabelPreflightFinding extends Schema.Class("@usine/orchestrator/LabelPreflightFinding")({
8
+ repository: RepositoryName,
9
+ label: GitHubLabelName,
10
+ errorTag: Schema.NonEmptyString,
11
+ message: Schema.NonEmptyString,
12
+ }) {
13
+ }
14
+ const driftFields = (declared, existing) => {
15
+ const drift = [];
16
+ if (Option.isSome(declared.color)) {
17
+ const expected = declared.color.value.toLowerCase();
18
+ if (Option.match(existing.color, {
19
+ onNone: () => true,
20
+ onSome: (color) => color.toLowerCase() !== expected,
21
+ })) {
22
+ drift.push("color");
23
+ }
24
+ }
25
+ if (Option.isSome(declared.description)) {
26
+ const expected = declared.description.value;
27
+ if (Option.match(existing.description, {
28
+ onNone: () => true,
29
+ onSome: (description) => description !== expected,
30
+ })) {
31
+ drift.push("description");
32
+ }
33
+ }
34
+ return drift;
35
+ };
36
+ const createInput = (label) => new NewRepositoryLabel({
37
+ name: RepositoryLabelName.make(label.name),
38
+ color: Option.map(label.color, RepositoryLabelColor.make),
39
+ description: label.description,
40
+ });
41
+ /** Creates the labels a factory declares that one repository's stored catalog lacks. */
42
+ export class LabelReconciler extends Context.Service()("@usine/orchestrator/LabelReconciler") {
43
+ static layer = Layer.effect(LabelReconciler, Effect.gen(function* () {
44
+ const github = yield* GitHubLabelWriter;
45
+ return {
46
+ reconcile: Effect.fn("LabelReconciler.reconcile")(function* (repository, declared, existing) {
47
+ yield* Effect.annotateCurrentSpan({ repository });
48
+ const labels = [...existing];
49
+ const byName = new Map(existing.map((label) => [canonicalLabelName(label.name), label]));
50
+ const findings = [];
51
+ let catalogChanged = false;
52
+ let nextPollAt = Option.none();
53
+ for (const declaration of declared) {
54
+ const current = byName.get(canonicalLabelName(declaration.name));
55
+ if (current !== undefined) {
56
+ const drift = driftFields(declaration, current);
57
+ if (drift.length > 0) {
58
+ yield* Effect.logWarning("Declared GitHub label differs from the existing repository label; left unchanged", {
59
+ repository,
60
+ label: declaration.name,
61
+ drift: drift.join(", "),
62
+ });
63
+ }
64
+ else {
65
+ yield* Effect.logDebug("Declared GitHub label already exists", {
66
+ repository,
67
+ label: declaration.name,
68
+ });
69
+ }
70
+ continue;
71
+ }
72
+ const created = yield* Effect.result(github.create(repository, createInput(declaration)));
73
+ if (Result.isFailure(created)) {
74
+ const error = created.failure;
75
+ findings.push(new LabelPreflightFinding({
76
+ repository,
77
+ label: declaration.name,
78
+ errorTag: error._tag,
79
+ message: error.message,
80
+ }));
81
+ if (error._tag === "GitHubRateLimitError") {
82
+ nextPollAt = Option.some(error.retryAt);
83
+ yield* Effect.logWarning("Label creation rate-limited; remaining declarations deferred and trigger evaluation continues", {
84
+ repository,
85
+ label: declaration.name,
86
+ errorTag: error._tag,
87
+ message: error.message,
88
+ retryAt: DateTime.formatIso(error.retryAt),
89
+ });
90
+ break;
91
+ }
92
+ yield* Effect.logError("Declared GitHub label could not be created; trigger evaluation continues", {
93
+ repository,
94
+ label: declaration.name,
95
+ errorTag: error._tag,
96
+ message: error.message,
97
+ });
98
+ continue;
99
+ }
100
+ const label = new StoredRepositoryLabel({
101
+ name: created.success.name,
102
+ color: Option.some(created.success.color),
103
+ description: created.success.description,
104
+ });
105
+ labels.push(label);
106
+ byName.set(canonicalLabelName(label.name), label);
107
+ catalogChanged = true;
108
+ yield* Effect.logInfo("Created declared GitHub label", {
109
+ repository,
110
+ label: label.name,
111
+ });
112
+ }
113
+ labels.sort((left, right) => left.name.localeCompare(right.name));
114
+ return { labels, findings, catalogChanged, nextPollAt };
115
+ }),
116
+ };
117
+ }));
118
+ }
119
+ //# sourceMappingURL=label-reconciler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"label-reconciler.js","sourceRoot":"","sources":["../src/label-reconciler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAsB,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC9F,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,eAAe,IAAI,qBAAqB,EAAE,MAAM,2CAA2C,CAAC;AACrG,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACnF,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAClF,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAElF,MAAM,OAAO,qBAAsB,SAAQ,MAAM,CAAC,KAAK,CACrD,2CAA2C,CAC5C,CAAC;IACA,UAAU,EAAE,cAAc;IAC1B,KAAK,EAAE,eAAe;IACtB,QAAQ,EAAE,MAAM,CAAC,cAAc;IAC/B,OAAO,EAAE,MAAM,CAAC,cAAc;CAC/B,CAAC;CAAG;AAWL,MAAM,WAAW,GAAG,CAClB,QAAuB,EACvB,QAA+B,EACS,EAAE;IAC1C,MAAM,KAAK,GAAmC,EAAE,CAAC;IACjD,IAAI,MAAM,CAAC,MA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AE,KAAK,CAAC,IAAI;4BACpB,OAAO,EAAE,KAAK,CAAC,OAAO;yBACvB,CACF,CAAC;wBACF,SAAS;oBACX,CAAC;oBAED,MAAM,KAAK,GAAG,IAAI,qBAAqB,CAAC;wBACtC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,IAAI;wBAC1B,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC;wBACzC,WAAW,EAAE,OAAO,CAAC,OAAO,CAAC,WAAW;qBACzC,CAAC,CAAC;oBACH,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;oBACnB,MAAM,CAAC,GAAG,CAAC,kBAAkB,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC;oBAClD,cAAc,GAAG,IAAI,CAAC;oBACtB,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,+BAA+B,EAAE;wBACrD,UAAU;wBACV,KAAK,EAAE,KAAK,CAAC,IAAI;qBAClB,CAAC,CAAC;gBACL,CAAC;gBAED,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;gBAClE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,UAAU,EAAgC,CAAC;YACxF,CAAC,CAAC;SACH,CAAC;IACJ,CAAC,CAAC,CACH,CAAC;CACH"}
package/dist/local.d.ts CHANGED
@@ -1,20 +1,25 @@
1
- import { ConfigParser, type LoadedInstance, type UsineConfig } from "@usine/config";
2
- import type { Instance } from "@usine/core";
1
+ import { BrainSpec } from "@usine/core/agent/brain";
2
+ import type { LoadedInstance } from "@usine/config/instance";
3
+ import type { UsineConfig } from "@usine/config/factory";
4
+ import { ConfigParser } from "@usine/config/parser";
5
+ import type { InstanceDirectory } from "@usine/core/instance";
3
6
  import { type LocalExecutorOptions } from "@usine/executor/local";
4
- import { GitHubItemWriter, GitHubPolling } from "@usine/github";
7
+ import { GitHubItemWriter } from "@usine/github/item-writer";
8
+ import { GitHubPolling } from "@usine/github/polling";
5
9
  import { Layer } from "effect";
6
- import { Operator, OperatorObservation } from "./operator/service.ts";
10
+ import { LabelReconciler } from "./label-reconciler.ts";
11
+ import { Operator, OperatorObservation } from "./operator/operator.ts";
7
12
  import { Orchestrator } from "./orchestrator.ts";
8
13
  import { PollingTriggers } from "./polling-triggers.ts";
9
14
  import { ScheduleTriggers } from "./schedule-triggers.ts";
10
- /** Complete local-worker engine composition. Credential sourcing stays caller-owned. */
11
- export declare const layer: (instanceDirectory: Instance.Directory, config: UsineConfig, options: Omit<LocalExecutorOptions, "instanceDirectory" | "runHost"> & Partial<Pick<LocalExecutorOptions, "runHost">>) => Layer.Layer<import("@usine/engine").CursorStore | import("@usine/engine").ItemProjectionReader | import("@usine/engine").ItemProjectionWriter | import("@usine/engine").LoopControl | import("@usine/engine").RepositoryLabelProjectionReader | import("@usine/engine").RepositoryLabelProjectionWriter | import("@usine/engine").RunEngine | import("@usine/engine").RunReader, import("@usine/engine").AttemptCancellationError | import("@usine/executor").CredentialUnavailableError | import("@usine/engine").EnginePersistenceError | import("@usine/executor").ExecutorOperationError | import("@usine/engine").RunNotFoundError | import("@usine/engine").RunOperationRejectedError | import("./scheduler.ts").UnsupportedWorkerError | import("@usine/executor").WorkerCapabilityError, import("@usine/executor").CredentialProvider>;
12
- /** Read-only local operator composition used while trigger credentials are unavailable. */
13
- export declare const operatorObservationLayer: (instanceDirectory: Instance.Directory) => Layer.Layer<OperatorObservation, import("@usine/engine").AttemptCancellationError | import("@usine/engine").EnginePersistenceError | import("@usine/engine").RunNotFoundError | import("@usine/engine").RunOperationRejectedError, never>;
15
+ /** The full engine composition for local Workers. Supply the roster’s brains for startup preflight and provide the credential provider. */
16
+ export declare const layer: (instanceDirectory: InstanceDirectory, config: UsineConfig, brains: ReadonlyArray<BrainSpec>, options: Omit<LocalExecutorOptions, "instanceDirectory" | "runHost"> & Partial<Pick<LocalExecutorOptions, "runHost">>) => Layer.Layer<import("@usine/engine/cursor").CursorStore | import("@usine/engine/cycle-budget").CycleBudgets | import("@usine/engine/item-projection").ItemProjectionReader | import("@usine/engine/item-projection").ItemProjectionWriter | import("@usine/engine/loop-control").LoopControl | import("@usine/engine/repository-label-projection").RepositoryLabelProjectionReader | import("@usine/engine/repository-label-projection").RepositoryLabelProjectionWriter | import("@usine/engine/engine").RunEngine | import("@usine/engine/run-reader").RunReader, import("@usine/engine/engine").AttemptCancellationError | import("@usine/executor").CredentialUnavailableError | import("@usine/engine/engine").EnginePersistenceError | import("@usine/executor").ExecutorOperationError | import("@usine/engine/engine").RunInterventionRejectedError | import("@usine/engine/engine").RunNotFoundError | import("@usine/engine/engine").RunOperationRejectedError | import("./scheduler.ts").UnsupportedWorkerError | import("@usine/executor").WorkerCapabilityError, import("@usine/executor").CredentialProvider>;
17
+ /** A read-only operator composition for when trigger credentials are not available yet. */
18
+ export declare const operatorObservationLayer: (instanceDirectory: InstanceDirectory) => Layer.Layer<OperatorObservation, import("@usine/engine/engine").AttemptCancellationError | import("@usine/engine/engine").EnginePersistenceError | import("@usine/engine/engine").RunInterventionRejectedError | import("@usine/engine/engine").RunNotFoundError | import("@usine/engine/engine").RunOperationRejectedError, never>;
14
19
  /**
15
- * Complete Node composition for one loaded local factory. The caller still
16
- * owns GitHub credential sourcing; everything else — both trigger streams,
17
- * durable engine, worker execution, and operator surface — is included.
20
+ * The full Node composition for one loaded local factory: both trigger
21
+ * streams, the durable engine, worker execution, and the operator surface.
22
+ * The caller supplies the GitHub credentials.
18
23
  */
19
- export declare const runtimeLayer: (instanceDirectory: Instance.Directory, instance: LoadedInstance, options: Omit<LocalExecutorOptions, "instanceDirectory" | "runHost"> & Partial<Pick<LocalExecutorOptions, "runHost">>) => Layer.Layer<ConfigParser | import("@usine/engine").CursorStore | import("@usine/expression").ExpressionEngine | GitHubItemWriter | GitHubPolling | import("@usine/engine").ItemProjectionReader | import("@usine/engine").ItemProjectionWriter | import("@usine/engine").LoopControl | Operator | Orchestrator | PollingTriggers | import("@usine/engine").RepositoryLabelProjectionReader | import("@usine/engine").RepositoryLabelProjectionWriter | import("@usine/engine").RunEngine | import("@usine/engine").RunReader | ScheduleTriggers, import("@usine/github").AppAuthenticationError | import("@usine/engine").AttemptCancellationError | import("@usine/executor").CredentialUnavailableError | import("@usine/engine").EnginePersistenceError | import("@usine/executor").ExecutorOperationError | import("@usine/engine").RunNotFoundError | import("@usine/engine").RunOperationRejectedError | import("./scheduler.ts").UnsupportedWorkerError | import("@usine/executor").WorkerCapabilityError, import("@usine/github").GitHubCredentials>;
24
+ export declare const runtimeLayer: (instanceDirectory: InstanceDirectory, instance: LoadedInstance, options: Omit<LocalExecutorOptions, "instanceDirectory" | "runHost"> & Partial<Pick<LocalExecutorOptions, "runHost">>) => Layer.Layer<ConfigParser | import("@usine/engine/cursor").CursorStore | import("@usine/engine/cycle-budget").CycleBudgets | import("@usine/expression/expression-engine").ExpressionEngine | GitHubItemWriter | GitHubPolling | import("@usine/engine/item-projection").ItemProjectionReader | import("@usine/engine/item-projection").ItemProjectionWriter | LabelReconciler | import("@usine/engine/loop-control").LoopControl | Operator | Orchestrator | PollingTriggers | import("@usine/engine/repository-label-projection").RepositoryLabelProjectionReader | import("@usine/engine/repository-label-projection").RepositoryLabelProjectionWriter | import("@usine/engine/engine").RunEngine | import("@usine/engine/run-reader").RunReader | ScheduleTriggers, import("@usine/github/github-app").AppAuthenticationError | import("@usine/engine/engine").AttemptCancellationError | import("@usine/executor").CredentialUnavailableError | import("@usine/engine/engine").EnginePersistenceError | import("@usine/executor").ExecutorOperationError | import("@usine/engine/engine").RunInterventionRejectedError | import("@usine/engine/engine").RunNotFoundError | import("@usine/engine/engine").RunOperationRejectedError | import("./scheduler.ts").UnsupportedWorkerError | import("@usine/executor").WorkerCapabilityError, import("@usine/github/github-app").GitHubCredentials>;
20
25
  //# sourceMappingURL=local.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"local.d.ts","sourceRoot":"","sources":["../src/local.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,KAAK,cAAc,EAAE,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AACpF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAA+B,KAAK,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAM/F,OAAO,EAAa,gBAAgB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE3E,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAI/B,OAAO,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG1D,wFAAwF;AACxF,eAAO,MAAM,KAAK,sBACG,QAAQ,CAAC,SAAS,UAC7B,WAAW,WACV,IAAI,CAAC,oBAAoB,EAAE,mBAAmB,GAAG,SAAS,CAAC,GAClE,OAAO,CAAC,IAAI,CAAC,oBAAoB,EAAE,SAAS,CAAC,CAAC,mzBASjD,CAAC;AAEF,2FAA2F;AAC3F,eAAO,MAAM,wBAAwB,sBAAuB,QAAQ,CAAC,SAAS,8OAG3E,CAAC;AAEJ;;;;GAIG;AACH,eAAO,MAAM,YAAY,sBACJ,QAAQ,CAAC,SAAS,YAC3B,cAAc,WACf,IAAI,CAAC,oBAAoB,EAAE,mBAAmB,GAAG,SAAS,CAAC,GAClE,OAAO,CAAC,IAAI,CAAC,oBAAoB,EAAE,SAAS,CAAC,CAAC,igCA4BjD,CAAC"}
1
+ {"version":3,"file":"local.d.ts","sourceRoot":"","sources":["../src/local.ts"],"names":[],"mappings":"AAAA,OAAO,EAA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,CAAC,CAAC,u0CA2CjD,CAAC"}
package/dist/local.js CHANGED
@@ -1,44 +1,51 @@
1
+ import { BrainSpec } from "@usine/core/agent/brain";
1
2
  import { NodeServices } from "@effect/platform-node";
2
- import { ConfigParser } from "@usine/config";
3
+ import { ConfigParser } from "@usine/config/parser";
3
4
  import { layer as localExecutorLayer } from "@usine/executor/local";
4
5
  import { layer as localEngineLayer, observationLayer as localObservationLayer, } from "@usine/engine/local-sqlite";
5
- import { MarcbachmannCelLayer } from "@usine/expression";
6
- import { GitHubApp, GitHubItemWriter, GitHubPolling } from "@usine/github";
6
+ import { MarcbachmannCelLayer } from "@usine/expression/marcbachmann-cel";
7
+ import { GitHubApp } from "@usine/github/github-app";
8
+ import { GitHubItemWriter } from "@usine/github/item-writer";
9
+ import { GitHubLabelWriter } from "@usine/github/label-writer";
10
+ import { GitHubPolling } from "@usine/github/polling";
7
11
  import { executableCommand } from "@usine/run-host/executable";
8
12
  import { Layer } from "effect";
9
13
  import { FetchHttpClient } from "effect/unstable/http";
10
14
  import { gitHubCredentialLayer } from "./credentials.js";
11
15
  import { idleTriggersLayer } from "./idle-triggers.js";
12
- import { Operator, OperatorObservation } from "./operator/service.js";
16
+ import { LabelReconciler } from "./label-reconciler.js";
17
+ import { Operator, OperatorObservation } from "./operator/operator.js";
13
18
  import { Orchestrator } from "./orchestrator.js";
14
19
  import { PollingTriggers } from "./polling-triggers.js";
15
20
  import { ScheduleTriggers } from "./schedule-triggers.js";
16
21
  import { stepExecutorLayer } from "./scheduler.js";
17
- /** Complete local-worker engine composition. Credential sourcing stays caller-owned. */
18
- export const layer = (instanceDirectory, config, options) => {
22
+ /** The full engine composition for local Workers. Supply the roster’s brains for startup preflight and provide the credential provider. */
23
+ export const layer = (instanceDirectory, config, brains, options) => {
19
24
  const executor = localExecutorLayer({
20
25
  runHost: options.runHost ?? executableCommand(),
21
26
  ...options,
22
27
  instanceDirectory,
23
28
  }).pipe(Layer.provide(NodeServices.layer));
24
- const stepExecutor = stepExecutorLayer(config).pipe(Layer.provide(executor));
29
+ const stepExecutor = stepExecutorLayer(config, brains).pipe(Layer.provide(executor));
25
30
  return localEngineLayer(instanceDirectory).pipe(Layer.provide(stepExecutor));
26
31
  };
27
- /** Read-only local operator composition used while trigger credentials are unavailable. */
32
+ /** A read-only operator composition for when trigger credentials are not available yet. */
28
33
  export const operatorObservationLayer = (instanceDirectory) => OperatorObservation.layer.pipe(Layer.provide(Layer.mergeAll(localObservationLayer(instanceDirectory), idleTriggersLayer)));
29
34
  /**
30
- * Complete Node composition for one loaded local factory. The caller still
31
- * owns GitHub credential sourcing; everything else — both trigger streams,
32
- * durable engine, worker execution, and operator surface — is included.
35
+ * The full Node composition for one loaded local factory: both trigger
36
+ * streams, the durable engine, worker execution, and the operator surface.
37
+ * The caller supplies the GitHub credentials.
33
38
  */
34
39
  export const runtimeLayer = (instanceDirectory, instance, options) => {
35
40
  const app = GitHubApp.layer.pipe(Layer.provide(FetchHttpClient.layer), Layer.provide(NodeServices.layer));
36
41
  const credentials = gitHubCredentialLayer(instance.config).pipe(Layer.provide(app));
37
- const engine = layer(instanceDirectory, instance.config, options).pipe(Layer.provide(credentials));
42
+ const engine = layer(instanceDirectory, instance.config, instance.agents.map(({ harness, model, effort }) => new BrainSpec({ harness, model, effort })), options).pipe(Layer.provide(credentials));
38
43
  const polling = GitHubPolling.layer.pipe(Layer.provide(app), Layer.provide(FetchHttpClient.layer), Layer.provide(NodeServices.layer));
39
44
  const itemWriter = GitHubItemWriter.layer.pipe(Layer.provide(app), Layer.provide(FetchHttpClient.layer));
45
+ const labelWriter = GitHubLabelWriter.layer.pipe(Layer.provide(app), Layer.provide(FetchHttpClient.layer));
46
+ const labelReconciler = LabelReconciler.layer.pipe(Layer.provide(labelWriter));
40
47
  const parser = ConfigParser.layer.pipe(Layer.provide(MarcbachmannCelLayer));
41
- const dependencies = Layer.mergeAll(engine, itemWriter, MarcbachmannCelLayer, parser, polling);
48
+ const dependencies = Layer.mergeAll(engine, itemWriter, labelReconciler, MarcbachmannCelLayer, parser, polling);
42
49
  const triggers = Layer.mergeAll(PollingTriggers.layer, ScheduleTriggers.layer).pipe(Layer.provide(dependencies));
43
50
  const services = Layer.mergeAll(Operator.layer, Orchestrator.layer).pipe(Layer.provide(Layer.mergeAll(dependencies, triggers)));
44
51
  return Layer.mergeAll(dependencies, triggers, services);
package/dist/local.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"local.js","sourceRoot":"","sources":["../src/local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAyC,MAAM,eAAe,CAAC;AAEpF,OAAO,EAAE,KAAK,IAAI,kBAAkB,EAA6B,MAAM,uBAAuB,CAAC;AAC/F,OAAO,EACL,KAAK,IAAI,gBAAgB,EACzB,gBAAgB,IAAI,qBAAqB,GAC1C,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,g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AAO,CACR,CAAC;IACF,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,eAAe,CAAC,KAAK,EAAE,gBAAgB,CAAC,KAAK,CAAC,CAAC,IAAI,CACjF,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,CAC5B,CAAC;IACF,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC,IAAI,CACtE,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC,CACtD,CAAC;IACF,OAAO,KAAK,CAAC,QAAQ,CAAC,YAAY,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAC1D,CAAC,CAAC"}
@@ -0,0 +1,69 @@
1
+ import { BrainSpec } from "@usine/core/agent/brain";
2
+ import { Schema } from "effect";
3
+ declare const InfraFailureView_base: Schema.Class<InfraFailureView, Schema.TaggedStruct<"InfraFailure", {
4
+ readonly message: Schema.String;
5
+ }>, {}>;
6
+ /** An infra failure as the operator sees it; the defect cause stays behind this boundary. */
7
+ export declare class InfraFailureView extends InfraFailureView_base {
8
+ }
9
+ declare const DefectFailureView_base: Schema.Class<DefectFailureView, Schema.TaggedStruct<"DefectFailure", {
10
+ readonly message: Schema.String;
11
+ }>, {}>;
12
+ /** A captured programmer defect requiring operator intervention; the original cause stays behind this boundary. */
13
+ export declare class DefectFailureView extends DefectFailureView_base {
14
+ }
15
+ declare const AgentFailureView_base: Schema.Class<AgentFailureView, Schema.TaggedStruct<"AgentFailure", {
16
+ readonly message: Schema.String;
17
+ }>, {}>;
18
+ /** An agent failure message safe to display to the operator. */
19
+ export declare class AgentFailureView extends AgentFailureView_base {
20
+ }
21
+ declare const RunawayFailureView_base: Schema.Class<RunawayFailureView, Schema.TaggedStruct<"RunawayFailure", {
22
+ readonly ceiling: Schema.Literals<readonly ["wall-clock", "tokens"]>;
23
+ }>, {}>;
24
+ /** The wall-clock or token ceiling that stopped an Attempt. */
25
+ export declare class RunawayFailureView extends RunawayFailureView_base {
26
+ }
27
+ declare const ChildSessionBudgetFailureView_base: Schema.Class<ChildSessionBudgetFailureView, Schema.TaggedStruct<"ChildSessionBudgetFailure", {
28
+ readonly maxChildren: Schema.brand<Schema.Int, "ChildSessionBudget">;
29
+ readonly attemptedChildren: Schema.brand<Schema.Int, "ChildSessionCount">;
30
+ }>, {}>;
31
+ /** The configured child-session budget and the spawn count that exceeded it. */
32
+ export declare class ChildSessionBudgetFailureView extends ChildSessionBudgetFailureView_base {
33
+ }
34
+ /** An Attempt failure with only the details the operator can inspect. */
35
+ export declare const FailureView: Schema.Union<readonly [typeof InfraFailureView, typeof DefectFailureView, typeof AgentFailureView, typeof RunawayFailureView, typeof ChildSessionBudgetFailureView]>;
36
+ export type FailureView = typeof FailureView.Type;
37
+ declare const SucceededAttemptView_base: Schema.Class<SucceededAttemptView, Schema.TaggedStruct<"Succeeded", {}>, {}>;
38
+ /** An Attempt that completed successfully. */
39
+ export declare class SucceededAttemptView extends SucceededAttemptView_base {
40
+ }
41
+ declare const FailedAttemptView_base: Schema.Class<FailedAttemptView, Schema.TaggedStruct<"Failed", {
42
+ readonly failure: Schema.Union<readonly [typeof InfraFailureView, typeof DefectFailureView, typeof AgentFailureView, typeof RunawayFailureView, typeof ChildSessionBudgetFailureView]>;
43
+ }>, {}>;
44
+ /** An Attempt that ended with a failure the operator can inspect. */
45
+ export declare class FailedAttemptView extends FailedAttemptView_base {
46
+ }
47
+ declare const CanceledAttemptView_base: Schema.Class<CanceledAttemptView, Schema.TaggedStruct<"Canceled", {}>, {}>;
48
+ /** An Attempt that ended after cancellation. */
49
+ export declare class CanceledAttemptView extends CanceledAttemptView_base {
50
+ }
51
+ /** The terminal outcome displayed for an Attempt; a live Attempt has no outcome. */
52
+ export declare const AttemptOutcomeView: Schema.Union<readonly [typeof SucceededAttemptView, typeof FailedAttemptView, typeof CanceledAttemptView]>;
53
+ export type AttemptOutcomeView = typeof AttemptOutcomeView.Type;
54
+ declare const AttemptView_base: Schema.Class<AttemptView, Schema.Struct<{
55
+ readonly id: Schema.brand<Schema.NonEmptyString, "AttemptId">;
56
+ readonly number: Schema.brand<Schema.Int, "AttemptNumber">;
57
+ readonly worker: Schema.brand<Schema.String, "WorkerName">;
58
+ readonly brain: typeof BrainSpec;
59
+ readonly task: Schema.brand<Schema.String, "AttemptTask">;
60
+ readonly agent: Schema.brand<Schema.String, "AgentName">;
61
+ readonly operatorIntervened: Schema.Boolean;
62
+ readonly startedAt: Schema.String;
63
+ readonly outcome: Schema.NullOr<Schema.Union<readonly [typeof SucceededAttemptView, typeof FailedAttemptView, typeof CanceledAttemptView]>>;
64
+ }>, {}>;
65
+ /** One Attempt's identity, Worker, effective brain, start time, and optional terminal outcome. */
66
+ export declare class AttemptView extends AttemptView_base {
67
+ }
68
+ export {};
69
+ //# sourceMappingURL=attempt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attempt.d.ts","sourceRoot":"","sources":["../../src/operator/attempt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAMpD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;;;;AAEhC,6FAA6F;AAC7F,qBAAa,gBAAiB,SAAQ,qBAEO;CAAG;;;;AAEhD,mHAAmH;AACnH,qBAAa,iBAAkB,SAAQ,sBAEO;CAAG;;;;AAEjD,gEAAgE;AAChE,qBAAa,gBAAiB,SAAQ,qBAEO;CAAG;;;;AAEhD,+DAA+D;AAC/D,qBAAa,kBAAmB,SAAQ,uBAEQ;CAAG;;;;;AAEnD,gFAAgF;AAChF,qBAAa,6BAA8B,SAAQ,kCAKjD;CAAG;AAEL,yEAAyE;AACzE,eAAO,MAAM,WAAW,sKAMtB,CAAC;AACH,MAAM,MAAM,WAAW,GAAG,OAAO,WAAW,CAAC,IAAI,CAAC;;AAElD,8CAA8C;AAC9C,qBAAa,oBAAqB,SAAQ,yBAExB;CAAG;;;;AAErB,qEAAqE;AACrE,qBAAa,iBAAkB,SAAQ,sBAEF;CAAG;;AAExC,gDAAgD;AAChD,qBAAa,mBAAoB,SAAQ,wBAExB;CAAG;AAEpB,oFAAoF;AACpF,eAAO,MAAM,kBAAkB,4GAI7B,CAAC;AACH,MAAM,MAAM,kBAAkB,GAAG,OAAO,kBAAkB,CAAC,IAAI,CAAC;;;;;;;;;;;;AAEhE,kGAAkG;AAClG,qBAAa,WAAY,SAAQ,gBAU/B;CAAG"}
@@ -0,0 +1,62 @@
1
+ import { BrainSpec } from "@usine/core/agent/brain";
2
+ import { ChildSessionBudget, ChildSessionCount } from "@usine/core/agent/session";
3
+ import { AttemptNumber, AttemptId, AttemptTask } from "@usine/core/attempt";
4
+ import { AgentName } from "@usine/core/agent";
5
+ import { RunawayCeiling } from "@usine/core/attempt/failure";
6
+ import { WorkerName } from "@usine/core/worker";
7
+ import { Schema } from "effect";
8
+ /** An infra failure as the operator sees it; the defect cause stays behind this boundary. */
9
+ export class InfraFailureView extends Schema.TaggedClass("@usine/orchestrator/InfraFailureView")("InfraFailure", { message: Schema.String }) {
10
+ }
11
+ /** A captured programmer defect requiring operator intervention; the original cause stays behind this boundary. */
12
+ export class DefectFailureView extends Schema.TaggedClass("@usine/orchestrator/DefectFailureView")("DefectFailure", { message: Schema.String }) {
13
+ }
14
+ /** An agent failure message safe to display to the operator. */
15
+ export class AgentFailureView extends Schema.TaggedClass("@usine/orchestrator/AgentFailureView")("AgentFailure", { message: Schema.String }) {
16
+ }
17
+ /** The wall-clock or token ceiling that stopped an Attempt. */
18
+ export class RunawayFailureView extends Schema.TaggedClass("@usine/orchestrator/RunawayFailureView")("RunawayFailure", { ceiling: RunawayCeiling }) {
19
+ }
20
+ /** The configured child-session budget and the spawn count that exceeded it. */
21
+ export class ChildSessionBudgetFailureView extends Schema.TaggedClass("@usine/orchestrator/ChildSessionBudgetFailureView")("ChildSessionBudgetFailure", {
22
+ maxChildren: ChildSessionBudget,
23
+ attemptedChildren: ChildSessionCount,
24
+ }) {
25
+ }
26
+ /** An Attempt failure with only the details the operator can inspect. */
27
+ export const FailureView = Schema.Union([
28
+ InfraFailureView,
29
+ DefectFailureView,
30
+ AgentFailureView,
31
+ RunawayFailureView,
32
+ ChildSessionBudgetFailureView,
33
+ ]);
34
+ /** An Attempt that completed successfully. */
35
+ export class SucceededAttemptView extends Schema.TaggedClass("@usine/orchestrator/SucceededAttemptView")("Succeeded", {}) {
36
+ }
37
+ /** An Attempt that ended with a failure the operator can inspect. */
38
+ export class FailedAttemptView extends Schema.TaggedClass("@usine/orchestrator/FailedAttemptView")("Failed", { failure: FailureView }) {
39
+ }
40
+ /** An Attempt that ended after cancellation. */
41
+ export class CanceledAttemptView extends Schema.TaggedClass("@usine/orchestrator/CanceledAttemptView")("Canceled", {}) {
42
+ }
43
+ /** The terminal outcome displayed for an Attempt; a live Attempt has no outcome. */
44
+ export const AttemptOutcomeView = Schema.Union([
45
+ SucceededAttemptView,
46
+ FailedAttemptView,
47
+ CanceledAttemptView,
48
+ ]);
49
+ /** One Attempt's identity, Worker, effective brain, start time, and optional terminal outcome. */
50
+ export class AttemptView extends Schema.Class("@usine/orchestrator/AttemptView")({
51
+ id: AttemptId,
52
+ number: AttemptNumber,
53
+ worker: WorkerName,
54
+ brain: BrainSpec,
55
+ task: AttemptTask,
56
+ agent: AgentName,
57
+ operatorIntervened: Schema.Boolean,
58
+ startedAt: Schema.String,
59
+ outcome: Schema.NullOr(AttemptOutcomeView),
60
+ }) {
61
+ }
62
+ //# sourceMappingURL=attempt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attempt.js","sourceRoot":"","sources":["../../src/operator/attempt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAClF,OAAO,EAAE,aAAa,EAAE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