@usine/core 0.2.0 → 0.4.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 (102) hide show
  1. package/README.md +43 -16
  2. package/dist/agent/agent.d.ts +12 -8
  3. package/dist/agent/agent.d.ts.map +1 -1
  4. package/dist/agent/agent.js +14 -10
  5. package/dist/agent/agent.js.map +1 -1
  6. package/dist/agent/brain.d.ts +2 -6
  7. package/dist/agent/brain.d.ts.map +1 -1
  8. package/dist/agent/brain.js +3 -7
  9. package/dist/agent/brain.js.map +1 -1
  10. package/dist/agent/capability.d.ts +4 -4
  11. package/dist/agent/capability.d.ts.map +1 -1
  12. package/dist/agent/capability.js +4 -4
  13. package/dist/agent/capability.js.map +1 -1
  14. package/dist/agent/session.d.ts +95 -21
  15. package/dist/agent/session.d.ts.map +1 -1
  16. package/dist/agent/session.js +100 -21
  17. package/dist/agent/session.js.map +1 -1
  18. package/dist/attempt/attempt.d.ts +63 -11
  19. package/dist/attempt/attempt.d.ts.map +1 -1
  20. package/dist/attempt/attempt.js +81 -11
  21. package/dist/attempt/attempt.js.map +1 -1
  22. package/dist/attempt/channel.d.ts +142 -44
  23. package/dist/attempt/channel.d.ts.map +1 -1
  24. package/dist/attempt/channel.js +124 -36
  25. package/dist/attempt/channel.js.map +1 -1
  26. package/dist/attempt/failure.d.ts +27 -14
  27. package/dist/attempt/failure.d.ts.map +1 -1
  28. package/dist/attempt/failure.js +27 -14
  29. package/dist/attempt/failure.js.map +1 -1
  30. package/dist/attempt/outcome.d.ts +3 -5
  31. package/dist/attempt/outcome.d.ts.map +1 -1
  32. package/dist/attempt/outcome.js +2 -4
  33. package/dist/attempt/outcome.js.map +1 -1
  34. package/dist/attempt/salvage.d.ts +50 -0
  35. package/dist/attempt/salvage.d.ts.map +1 -0
  36. package/dist/attempt/salvage.js +21 -0
  37. package/dist/attempt/salvage.js.map +1 -0
  38. package/dist/attempt/start.d.ts +35 -0
  39. package/dist/attempt/start.d.ts.map +1 -0
  40. package/dist/attempt/start.js +30 -0
  41. package/dist/attempt/start.js.map +1 -0
  42. package/dist/cycle-budget.d.ts +7 -8
  43. package/dist/cycle-budget.d.ts.map +1 -1
  44. package/dist/cycle-budget.js +9 -10
  45. package/dist/cycle-budget.js.map +1 -1
  46. package/dist/event.d.ts +4 -8
  47. package/dist/event.d.ts.map +1 -1
  48. package/dist/event.js +4 -8
  49. package/dist/event.js.map +1 -1
  50. package/dist/instance.d.ts +1 -1
  51. package/dist/instance.d.ts.map +1 -1
  52. package/dist/instance.js +1 -1
  53. package/dist/instance.js.map +1 -1
  54. package/dist/item.d.ts +1 -2
  55. package/dist/item.d.ts.map +1 -1
  56. package/dist/item.js +1 -2
  57. package/dist/item.js.map +1 -1
  58. package/dist/loop.d.ts +10 -2
  59. package/dist/loop.d.ts.map +1 -1
  60. package/dist/loop.js +9 -2
  61. package/dist/loop.js.map +1 -1
  62. package/dist/operator.d.ts +8 -0
  63. package/dist/operator.d.ts.map +1 -0
  64. package/dist/operator.js +9 -0
  65. package/dist/operator.js.map +1 -0
  66. package/dist/repository.d.ts +6 -8
  67. package/dist/repository.d.ts.map +1 -1
  68. package/dist/repository.js +8 -10
  69. package/dist/repository.js.map +1 -1
  70. package/dist/run/again.d.ts +13 -0
  71. package/dist/run/again.d.ts.map +1 -0
  72. package/dist/run/again.js +13 -0
  73. package/dist/run/again.js.map +1 -0
  74. package/dist/run/approval.d.ts +27 -0
  75. package/dist/run/approval.d.ts.map +1 -0
  76. package/dist/run/approval.js +26 -0
  77. package/dist/run/approval.js.map +1 -0
  78. package/dist/run/run.d.ts +2 -2
  79. package/dist/run/run.d.ts.map +1 -1
  80. package/dist/run/run.js +2 -2
  81. package/dist/run/run.js.map +1 -1
  82. package/dist/run/state.d.ts +22 -31
  83. package/dist/run/state.d.ts.map +1 -1
  84. package/dist/run/state.js +23 -36
  85. package/dist/run/state.js.map +1 -1
  86. package/dist/step/harvest.d.ts +44 -0
  87. package/dist/step/harvest.d.ts.map +1 -0
  88. package/dist/step/harvest.js +368 -0
  89. package/dist/step/harvest.js.map +1 -0
  90. package/dist/step/result.d.ts +15 -4
  91. package/dist/step/result.d.ts.map +1 -1
  92. package/dist/step/result.js +14 -4
  93. package/dist/step/result.js.map +1 -1
  94. package/dist/step/step.d.ts +2 -8
  95. package/dist/step/step.d.ts.map +1 -1
  96. package/dist/step/step.js +2 -8
  97. package/dist/step/step.js.map +1 -1
  98. package/dist/worker.d.ts +48 -4
  99. package/dist/worker.d.ts.map +1 -1
  100. package/dist/worker.js +47 -4
  101. package/dist/worker.js.map +1 -1
  102. package/package.json +27 -2
package/dist/item.d.ts CHANGED
@@ -1,8 +1,7 @@
1
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. */
2
+ /** The ID of an issue or pull request; several Events can have the same Item. */
3
3
  export declare const ItemKey: Schema.brand<Schema.NonEmptyString, "ItemKey">;
4
4
  export type ItemKey = typeof ItemKey.Type;
5
- /** The issue or pull request number within its repository. */
6
5
  export declare const ItemNumber: Schema.brand<Schema.Int, "ItemNumber">;
7
6
  export type ItemNumber = typeof ItemNumber.Type;
8
7
  //# sourceMappingURL=item.d.ts.map
@@ -1 +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"}
1
+ {"version":3,"file":"item.d.ts","sourceRoot":"","sources":["../src/item.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,iFAAiF;AACjF,eAAO,MAAM,OAAO,gDAAsD,CAAC;AAE3E,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAC;AAE1C,eAAO,MAAM,UAAU,wCAEtB,CAAC;AACF,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC,IAAI,CAAC"}
package/dist/item.js CHANGED
@@ -1,6 +1,5 @@
1
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. */
2
+ /** The ID of an issue or pull request; several Events can have the same Item. */
3
3
  export const ItemKey = Schema.NonEmptyString.pipe(Schema.brand("ItemKey"));
4
- /** The issue or pull request number within its repository. */
5
4
  export const ItemNumber = Schema.Int.check(Schema.isGreaterThanOrEqualTo(1)).pipe(Schema.brand("ItemNumber"));
6
5
  //# sourceMappingURL=item.js.map
package/dist/item.js.map CHANGED
@@ -1 +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"}
1
+ {"version":3,"file":"item.js","sourceRoot":"","sources":["../src/item.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,iFAAiF;AACjF,MAAM,CAAC,MAAM,OAAO,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;AAI3E,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 CHANGED
@@ -1,9 +1,17 @@
1
1
  import { Schema } from "effect";
2
- /** The loop file's name. Renaming the file retires one loop and creates another (ADR 0001). */
2
+ /** The Loop file name. Renaming the file creates a new Loop and retires the old one (ADR 0001). */
3
3
  export declare const LoopName: Schema.brand<Schema.NonEmptyString, "LoopName">;
4
4
  export type LoopName = typeof LoopName.Type;
5
- /** Whether a loop parks new runs until an approval Event arrives. The default is `none`. */
5
+ /** The approval modes; with `required`, new Runs wait for an approval Event. */
6
6
  export declare const APPROVAL_REQUIREMENTS: readonly ["none", "required"];
7
7
  export declare const ApprovalRequirement: Schema.Literals<readonly ["none", "required"]>;
8
8
  export type ApprovalRequirement = typeof ApprovalRequirement.Type;
9
+ /**
10
+ * The repository access modes. With `write`, Attempts can push and merge. With `read`, they can
11
+ * read code and post reviews and comments but can't push; a Worker kind that can't issue such a
12
+ * token rejects the Attempt (ADR 0011).
13
+ */
14
+ export declare const LOOP_PERMISSIONS: readonly ["write", "read"];
15
+ export declare const LoopPermissions: Schema.Literals<readonly ["write", "read"]>;
16
+ export type LoopPermissions = typeof LoopPermissions.Type;
9
17
  //# sourceMappingURL=loop.d.ts.map
@@ -1 +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"}
1
+ {"version":3,"file":"loop.d.ts","sourceRoot":"","sources":["../src/loop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,mGAAmG;AACnG,eAAO,MAAM,QAAQ,iDAAuD,CAAC;AAE7E,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC,IAAI,CAAC;AAE5C,gFAAgF;AAChF,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;AAElE;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,YAAI,OAAO,EAAE,MAAM,CAAU,CAAC;AAC3D,eAAO,MAAM,eAAe,6CAAoC,CAAC;AACjE,MAAM,MAAM,eAAe,GAAG,OAAO,eAAe,CAAC,IAAI,CAAC"}
package/dist/loop.js CHANGED
@@ -1,7 +1,14 @@
1
1
  import { Schema } from "effect";
2
- /** The loop file's name. Renaming the file retires one loop and creates another (ADR 0001). */
2
+ /** The Loop file name. Renaming the file creates a new Loop and retires the old one (ADR 0001). */
3
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`. */
4
+ /** The approval modes; with `required`, new Runs wait for an approval Event. */
5
5
  export const APPROVAL_REQUIREMENTS = ["none", "required"];
6
6
  export const ApprovalRequirement = Schema.Literals(APPROVAL_REQUIREMENTS);
7
+ /**
8
+ * The repository access modes. With `write`, Attempts can push and merge. With `read`, they can
9
+ * read code and post reviews and comments but can't push; a Worker kind that can't issue such a
10
+ * token rejects the Attempt (ADR 0011).
11
+ */
12
+ export const LOOP_PERMISSIONS = ["write", "read"];
13
+ export const LoopPermissions = Schema.Literals(LOOP_PERMISSIONS);
7
14
  //# sourceMappingURL=loop.js.map
package/dist/loop.js.map CHANGED
@@ -1 +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
+ {"version":3,"file":"loop.js","sourceRoot":"","sources":["../src/loop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,mGAAmG;AACnG,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;AAI7E,gFAAgF;AAChF,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,MAAM,EAAE,UAAU,CAAU,CAAC;AACnE,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC,QAAQ,CAAC,qBAAqB,CAAC,CAAC;AAG1E;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,OAAO,EAAE,MAAM,CAAU,CAAC;AAC3D,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { Schema } from "effect";
2
+ /**
3
+ * The operator's GitHub login from `usine.yaml`. The web UI acts as this login, and only this
4
+ * login can answer an Ask (ADR 0017).
5
+ */
6
+ export declare const OperatorLogin: Schema.brand<Schema.String, "OperatorLogin">;
7
+ export type OperatorLogin = typeof OperatorLogin.Type;
8
+ //# sourceMappingURL=operator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operator.d.ts","sourceRoot":"","sources":["../src/operator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC;;;GAGG;AACH,eAAO,MAAM,aAAa,8CAIW,CAAC;AAEtC,MAAM,MAAM,aAAa,GAAG,OAAO,aAAa,CAAC,IAAI,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { Schema } from "effect";
2
+ /**
3
+ * The operator's GitHub login from `usine.yaml`. The web UI acts as this login, and only this
4
+ * login can answer an Ask (ADR 0017).
5
+ */
6
+ export const OperatorLogin = Schema.String.check(Schema.isPattern(/^[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?$/u, {
7
+ message: "Expected a GitHub login",
8
+ })).pipe(Schema.brand("OperatorLogin"));
9
+ //# sourceMappingURL=operator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operator.js","sourceRoot":"","sources":["../src/operator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAC9C,MAAM,CAAC,SAAS,CAAC,kDAAkD,EAAE;IACnE,OAAO,EAAE,yBAAyB;CACnC,CAAC,CACH,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC"}
@@ -1,21 +1,19 @@
1
1
  import { Schema } from "effect";
2
- /**
3
- * Full `owner/name` of a GitHub repository, in the casing the operator wrote.
4
- * Compare through `canonicalRepositoryName`, since GitHub ignores case.
5
- */
2
+ /** A GitHub `owner/name` in the casing from config; compare with `canonicalRepositoryName`. */
6
3
  export declare const RepositoryName: Schema.brand<Schema.String, "RepositoryName">;
7
4
  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. */
5
+ /** The branch, tag, commit, or `HEAD` to check out for an Attempt, resolved when the Attempt is prepared. */
9
6
  export declare const RepositoryRevision: Schema.brand<Schema.String, "RepositoryRevision">;
10
7
  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. */
8
+ /** A full SHA-1 or SHA-256 commit ID in lowercase hex. */
12
9
  export declare const CommitSha: Schema.brand<Schema.String, "CommitSha">;
13
10
  export type CommitSha = typeof CommitSha.Type;
14
- /** Splits a repository name into its `owner` and `name`. */
11
+ /** Returns `value` with every character outside `[A-Za-z0-9_.-]` replaced by `_`, for a path or ref segment. */
12
+ export declare const safeSegment: (value: string) => string;
15
13
  export declare const splitRepositoryName: (repository: RepositoryName) => {
16
14
  readonly owner: string;
17
15
  readonly name: string;
18
16
  };
19
- /** Lowercases a repository name for comparison, since GitHub ignores case. */
17
+ /** Returns the comparison key for a repository name; GitHub names are case-insensitive. */
20
18
  export declare const canonicalRepositoryName: (repository: RepositoryName) => string;
21
19
  //# 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;;;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
+ {"version":3,"file":"repository.d.ts","sourceRoot":"","sources":["../src/repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,+FAA+F;AAC/F,eAAO,MAAM,cAAc,+CAIW,CAAC;AAEvC,MAAM,MAAM,cAAc,GAAG,OAAO,cAAc,CAAC,IAAI,CAAC;AAExD,6GAA6G;AAC7G,eAAO,MAAM,kBAAkB,mDAIW,CAAC;AAC3C,MAAM,MAAM,kBAAkB,GAAG,OAAO,kBAAkB,CAAC,IAAI,CAAC;AAEhE,0DAA0D;AAC1D,eAAO,MAAM,SAAS,0CAIW,CAAC;AAClC,MAAM,MAAM,SAAS,GAAG,OAAO,SAAS,CAAC,IAAI,CAAC;AAE9C,gHAAgH;AAChH,eAAO,MAAM,WAAW,UAAW,MAAM,KAAG,MAAoD,CAAC;AAEjG,eAAO,MAAM,mBAAmB,eAAgB,cAAc;aAG1D,KAAK;aACL,IAAI;CAEP,CAAC;AAEF,2FAA2F;AAC3F,eAAO,MAAM,uBAAuB,eAAgB,cAAc,KAAG,MAC3C,CAAC"}
@@ -1,20 +1,18 @@
1
1
  import { Schema } from "effect";
2
- /**
3
- * Full `owner/name` of a GitHub repository, in the casing the operator wrote.
4
- * Compare through `canonicalRepositoryName`, since GitHub ignores case.
5
- */
2
+ /** A GitHub `owner/name` in the casing from config; compare with `canonicalRepositoryName`. */
6
3
  export const RepositoryName = Schema.String.check(Schema.isPattern(/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/u, {
7
4
  message: "Expected a full GitHub repo name (owner/name)",
8
5
  })).pipe(Schema.brand("RepositoryName"));
9
- /** The branch, tag, commit, or `HEAD` a Worker fetches when preparing an Attempt; named refs resolve at preparation time. */
6
+ /** The branch, tag, commit, or `HEAD` to check out for an Attempt, resolved when the Attempt is prepared. */
10
7
  export const RepositoryRevision = Schema.String.check(Schema.isPattern(/^[^\s-]\S*$/u, {
11
- message: "Expected a git revision without whitespace or a leading dash",
8
+ message: "Expected a Git revision without whitespace or a leading dash",
12
9
  })).pipe(Schema.brand("RepositoryRevision"));
13
- /** An exact Git commit recorded for a checkout or produced by an Attempt, unchanged when branch names move. */
10
+ /** A full SHA-1 or SHA-256 commit ID in lowercase hex. */
14
11
  export const CommitSha = Schema.String.check(Schema.isPattern(/^[0-9a-f]{40}(?:[0-9a-f]{24})?$/u, {
15
- message: "Expected a 40- or 64-character lowercase git object id",
12
+ message: "Expected a 40- or 64-character lowercase Git object ID",
16
13
  })).pipe(Schema.brand("CommitSha"));
17
- /** Splits a repository name into its `owner` and `name`. */
14
+ /** Returns `value` with every character outside `[A-Za-z0-9_.-]` replaced by `_`, for a path or ref segment. */
15
+ export const safeSegment = (value) => value.replaceAll(/[^A-Za-z0-9_.-]/gu, "_");
18
16
  export const splitRepositoryName = (repository) => {
19
17
  const separator = repository.indexOf("/");
20
18
  return {
@@ -22,6 +20,6 @@ export const splitRepositoryName = (repository) => {
22
20
  name: repository.slice(separator + 1),
23
21
  };
24
22
  };
25
- /** Lowercases a repository name for comparison, since GitHub ignores case. */
23
+ /** Returns the comparison key for a repository name; GitHub names are case-insensitive. */
26
24
  export const canonicalRepositoryName = (repository) => repository.toLowerCase();
27
25
  //# 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;A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C,MAAM,uBAAuB,GAAG,CAAC,UAA0B,EAAU,EAAE,CAC5E,UAAU,CAAC,WAAW,EAAE,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { Schema } from "effect";
2
+ declare const RunAgain_base: Schema.Class<RunAgain, Schema.Struct<{
3
+ readonly from: Schema.brand<Schema.NonEmptyString, "RunId">;
4
+ readonly requestedBy: Schema.OptionFromNullOr<Schema.brand<Schema.String, "OperatorLogin">>;
5
+ }>, {}>;
6
+ /**
7
+ * The origin of a Run created by running a succeeded or canceled Run again (ADR 0002).
8
+ * `requestedBy` is the operator login from `usine.yaml`, or `None` if none is configured.
9
+ */
10
+ export declare class RunAgain extends RunAgain_base {
11
+ }
12
+ export {};
13
+ //# sourceMappingURL=again.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"again.d.ts","sourceRoot":"","sources":["../../src/run/again.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;;;;;AAIhC;;;GAGG;AACH,qBAAa,QAAS,SAAQ,aAK7B;CAAG"}
@@ -0,0 +1,13 @@
1
+ import { Schema } from "effect";
2
+ import { OperatorLogin } from "../operator.js";
3
+ import { RunId } from "./run.js";
4
+ /**
5
+ * The origin of a Run created by running a succeeded or canceled Run again (ADR 0002).
6
+ * `requestedBy` is the operator login from `usine.yaml`, or `None` if none is configured.
7
+ */
8
+ export class RunAgain extends Schema.Class("RunAgain")(Schema.Struct({
9
+ from: RunId,
10
+ requestedBy: Schema.OptionFromNullOr(OperatorLogin),
11
+ }).annotate({ parseOptions: { onExcessProperty: "error" } })) {
12
+ }
13
+ //# sourceMappingURL=again.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"again.js","sourceRoot":"","sources":["../../src/run/again.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC;;;GAGG;AACH,MAAM,OAAO,QAAS,SAAQ,MAAM,CAAC,KAAK,CAAW,UAAU,CAAC,CAC9D,MAAM,CAAC,MAAM,CAAC;IACZ,IAAI,EAAE,KAAK;IACX,WAAW,EAAE,MAAM,CAAC,gBAAgB,CAAC,aAAa,CAAC;CACpD,CAAC,CAAC,QAAQ,CAAC,EAAE,YAAY,EAAE,EAAE,gBAAgB,EAAE,OAAO,EAAE,EAAE,CAAC,CAC7D;CAAG"}
@@ -0,0 +1,27 @@
1
+ import { Schema } from "effect";
2
+ /** The approval channels: `ui` for the web UI's Approve action and `github-ask` for a 👍 on the GitHub Ask (ADR 0017). */
3
+ export declare const APPROVAL_CHANNELS: readonly ["ui", "github-ask"];
4
+ export declare const ApprovalChannel: Schema.Literals<readonly ["ui", "github-ask"]>;
5
+ export type ApprovalChannel = typeof ApprovalChannel.Type;
6
+ declare const ApprovalSource_base: Schema.Class<ApprovalSource, Schema.Struct<{
7
+ readonly channel: Schema.Literals<readonly ["ui", "github-ask"]>;
8
+ readonly approver: Schema.OptionFromNullOr<Schema.brand<Schema.String, "OperatorLogin">>;
9
+ }>, {}>;
10
+ /**
11
+ * The approver and channel, recorded when the approval takes effect. A `ui` approval has no
12
+ * `approver` if `usine.yaml` sets no operator login; a `github-ask` approval always has one.
13
+ */
14
+ export declare class ApprovalSource extends ApprovalSource_base {
15
+ }
16
+ declare const RunApproval_base: Schema.Class<RunApproval, Schema.Struct<{
17
+ readonly approvedAt: Schema.DateTimeUtc;
18
+ readonly source: Schema.Option<typeof ApprovalSource>;
19
+ }>, {}>;
20
+ /**
21
+ * A Run's approval. `approvedAt` is when the approval Event arrived, and `source` is `None` for
22
+ * older records.
23
+ */
24
+ export declare class RunApproval extends RunApproval_base {
25
+ }
26
+ export {};
27
+ //# sourceMappingURL=approval.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"approval.d.ts","sourceRoot":"","sources":["../../src/run/approval.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGxC,0HAA0H;AAC1H,eAAO,MAAM,iBAAiB,YAAI,IAAI,EAAE,YAAY,CAAU,CAAC;AAC/D,eAAO,MAAM,eAAe,gDAAqC,CAAC;AAClE,MAAM,MAAM,eAAe,GAAG,OAAO,eAAe,CAAC,IAAI,CAAC;;;;;AAE1D;;;GAGG;AACH,qBAAa,cAAe,SAAQ,mBAYnC;CAAG;;;;;AAEJ;;;GAGG;AACH,qBAAa,WAAY,SAAQ,gBAG/B;CAAG"}
@@ -0,0 +1,26 @@
1
+ import { Option, Schema } from "effect";
2
+ import { OperatorLogin } from "../operator.js";
3
+ /** The approval channels: `ui` for the web UI's Approve action and `github-ask` for a 👍 on the GitHub Ask (ADR 0017). */
4
+ export const APPROVAL_CHANNELS = ["ui", "github-ask"];
5
+ export const ApprovalChannel = Schema.Literals(APPROVAL_CHANNELS);
6
+ /**
7
+ * The approver and channel, recorded when the approval takes effect. A `ui` approval has no
8
+ * `approver` if `usine.yaml` sets no operator login; a `github-ask` approval always has one.
9
+ */
10
+ export class ApprovalSource extends Schema.Class("ApprovalSource")(Schema.Struct({
11
+ channel: ApprovalChannel,
12
+ approver: Schema.OptionFromNullOr(OperatorLogin),
13
+ })
14
+ .check(Schema.makeFilter(({ channel, approver }) => channel !== "github-ask" || Option.isSome(approver), { message: "Expected an approver for a GitHub ask approval" }))
15
+ .annotate({ parseOptions: { onExcessProperty: "error" } })) {
16
+ }
17
+ /**
18
+ * A Run's approval. `approvedAt` is when the approval Event arrived, and `source` is `None` for
19
+ * older records.
20
+ */
21
+ export class RunApproval extends Schema.Class("RunApproval")({
22
+ approvedAt: Schema.DateTimeUtc,
23
+ source: Schema.Option(ApprovalSource),
24
+ }) {
25
+ }
26
+ //# sourceMappingURL=approval.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"approval.js","sourceRoot":"","sources":["../../src/run/approval.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,0HAA0H;AAC1H,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,IAAI,EAAE,YAAY,CAAU,CAAC;AAC/D,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC;AAGlE;;;GAGG;AACH,MAAM,OAAO,cAAe,SAAQ,MAAM,CAAC,KAAK,CAAiB,gBAAgB,CAAC,CAChF,MAAM,CAAC,MAAM,CAAC;IACZ,OAAO,EAAE,eAAe;IACxB,QAAQ,EAAE,MAAM,CAAC,gBAAgB,CAAC,aAAa,CAAC;CACjD,CAAC;KACC,KAAK,CACJ,MAAM,CAAC,UAAU,CACf,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,OAAO,KAAK,YAAY,IAAI,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,EAC9E,EAAE,OAAO,EAAE,gDAAgD,EAAE,CAC9D,CACF;KACA,QAAQ,CAAC,EAAE,YAAY,EAAE,EAAE,gBAAgB,EAAE,OAAO,EAAE,EAAE,CAAC,CAC7D;CAAG;AAEJ;;;GAGG;AACH,MAAM,OAAO,WAAY,SAAQ,MAAM,CAAC,KAAK,CAAc,aAAa,CAAC,CAAC;IACxE,UAAU,EAAE,MAAM,CAAC,WAAW;IAC9B,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC;CACtC,CAAC;CAAG"}
package/dist/run/run.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Schema } from "effect";
2
- /** Identity of the work owed to one Event, retained across retries of its Step. */
2
+ /** The ID of a Run, unchanged across retries of its Step. */
3
3
  export declare const RunId: Schema.brand<Schema.NonEmptyString, "RunId">;
4
4
  export type RunId = typeof RunId.Type;
5
5
  declare const Run_base: Schema.Class<Run, Schema.Struct<{
@@ -9,7 +9,7 @@ declare const Run_base: Schema.Class<Run, Schema.Struct<{
9
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
10
  readonly openedAt: Schema.DateTimeUtc;
11
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). */
12
+ /** The work a Loop does for one Event. The engine allows at most one open Run per dedup key (ADR 0002). */
13
13
  export declare class Run extends Run_base {
14
14
  }
15
15
  export {};
@@ -1 +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"}
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/run/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAKhC,6DAA6D;AAC7D,eAAO,MAAM,KAAK,8CAAoD,CAAC;AAEvE,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,IAAI,CAAC;;;;;;;;AAEtC,2GAA2G;AAC3G,qBAAa,GAAI,SAAQ,QAMvB;CAAG"}
package/dist/run/run.js CHANGED
@@ -2,9 +2,9 @@ import { Schema } from "effect";
2
2
  import { EventId } from "../event.js";
3
3
  import { LoopName } from "../loop.js";
4
4
  import { RunState } from "./state.js";
5
- /** Identity of the work owed to one Event, retained across retries of its Step. */
5
+ /** The ID of a Run, unchanged across retries of its Step. */
6
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). */
7
+ /** The work a Loop does for one Event. The engine allows at most one open Run per dedup key (ADR 0002). */
8
8
  export class Run extends Schema.Class("Run")({
9
9
  id: RunId,
10
10
  eventId: EventId,
@@ -1 +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"}
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,6DAA6D;AAC7D,MAAM,CAAC,MAAM,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;AAIvE,2GAA2G;AAC3G,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"}
@@ -13,102 +13,93 @@ declare const OperatorCanceled_base: Schema.Class<OperatorCanceled, Schema.Tagge
13
13
  * pending | waiting | queued ──► canceled (supersede, revoke: a started
14
14
  * attempt always finishes, ADR 0007)
15
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`.
16
+ * Each transition accepts only its legal source states, so an illegal transition is a type
17
+ * error. States come from the transitions or from decoding a stored row with `RunState`.
19
18
  */
20
- /** The operator closed the run by hand. */
21
19
  export declare class OperatorCanceled extends OperatorCanceled_base {
22
20
  }
23
21
  declare const Superseded_base: Schema.Class<Superseded, Schema.TaggedStruct<"Superseded", {
24
22
  readonly by: Schema.brand<Schema.NonEmptyString, "EventId">;
25
23
  }>, {}>;
26
- /** A newer Event for the same Item took the run's place before any attempt started. */
24
+ /** Cancellation because a newer Event for the same Item arrived before any Attempt started. */
27
25
  export declare class Superseded extends Superseded_base {
28
26
  }
29
27
  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. */
28
+ /** Cancellation because the Item stopped matching the Loop's trigger before any Attempt started. */
31
29
  export declare class Revoked extends Revoked_base {
32
30
  }
33
31
  export declare const CancelReason: Schema.Union<readonly [typeof OperatorCanceled, typeof Superseded, typeof Revoked]>;
34
32
  export type CancelReason = typeof CancelReason.Type;
35
33
  declare const Pending_base: Schema.Class<Pending, Schema.TaggedStruct<"Pending", {}>, {}>;
36
- /** Just created: no attempt started and no approval gate passed. */
34
+ /** A new Run with no Attempt started and no approval gate passed. */
37
35
  export declare class Pending extends Pending_base {
38
36
  }
39
37
  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. */
38
+ /** A Run waiting for its Loop's approval Event. */
41
39
  export declare class Waiting extends Waiting_base {
42
40
  }
43
41
  declare const Queued_base: Schema.Class<Queued, Schema.TaggedStruct<"Queued", {}>, {}>;
44
- /** Approved and waiting for a worker slot. */
42
+ /** An approved Run waiting for a Worker slot. */
45
43
  export declare class Queued extends Queued_base {
46
44
  }
47
45
  declare const Running_base: Schema.Class<Running, Schema.TaggedStruct<"Running", {}>, {}>;
48
- /** An attempt is executing on a worker. */
46
+ /** A Run with an Attempt running on a Worker. */
49
47
  export declare class Running extends Running_base {
50
48
  }
51
49
  declare const Succeeded_base: Schema.Class<Succeeded, Schema.TaggedStruct<"Succeeded", {}>, {}>;
52
- /** The step finished and its result is stored. */
50
+ /** A Run whose Step finished with a stored result. */
53
51
  export declare class Succeeded extends Succeeded_base {
54
52
  }
55
53
  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. */
54
+ /** A Run whose last Attempt failed without an auto-retry; the failure is stored on the Attempt. */
57
55
  export declare class Failed extends Failed_base {
58
56
  }
59
57
  declare const Canceled_base: Schema.Class<Canceled, Schema.TaggedStruct<"Canceled", {
60
58
  readonly reason: Schema.Union<readonly [typeof OperatorCanceled, typeof Superseded, typeof Revoked]>;
61
59
  }>, {}>;
62
- /** Canceled, with the reason recorded. */
63
60
  export declare class Canceled extends Canceled_base {
64
61
  }
65
- /** Runs that still owe work, including those waiting for approval or a Worker. */
62
+ /** The states of a Run that isn't closed. */
66
63
  export declare const Open: Schema.Union<readonly [typeof Pending, typeof Waiting, typeof Queued, typeof Running]>;
67
64
  export type Open = typeof Open.Type;
68
- /** A Run's progress from creation through approval and execution to a recorded outcome. */
69
65
  export declare const RunState: Schema.Union<readonly [typeof Pending, typeof Waiting, typeof Queued, typeof Running, typeof Succeeded, typeof Failed, typeof Canceled]>;
70
66
  export type RunState = typeof RunState.Type;
71
- /** The states with no attempt started: what `supersede` and `revoke` accept. */
67
+ /** The states before any Attempt starts, accepted by `supersede` and `revoke`. */
72
68
  export declare const Unstarted: Schema.Union<readonly [typeof Pending, typeof Waiting, typeof Queued]>;
73
69
  export type Unstarted = typeof Unstarted.Type;
74
- /** The states an attempt can start from: the gate is passed or absent. */
70
+ /** The states from which an Attempt can start. */
75
71
  export declare const Startable: Schema.Union<readonly [typeof Pending, typeof Queued]>;
76
72
  export type Startable = typeof Startable.Type;
77
73
  export declare const isOpen: <I>(input: I) => input is I & (Pending | Queued | Running | Waiting);
78
74
  export declare const isUnstarted: <I>(input: I) => input is I & (Pending | Queued | Waiting);
79
75
  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. */
76
+ /** Returns the operator actions allowed in `state`. */
81
77
  export declare const operatorActions: (state: RunState) => {
82
78
  canApprove: boolean;
83
79
  canRetry: boolean;
80
+ canResolveFailure: boolean;
84
81
  canCancel: boolean;
82
+ canRunAgain: boolean;
85
83
  };
86
- /** The open states as `_tag` literals, for queries that filter stored rows. */
84
+ /** The `_tag` values of `Open`, for SQL filters. */
87
85
  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. */
86
+ /** The `_tag` values of `RunState`. */
89
87
  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. */
88
+ /** The `_tag` values of `Unstarted`, for SQL filters. */
91
89
  export declare const UNSTARTED_STATE_TAGS: readonly ["Pending", "Waiting", "Queued"];
92
- /** Parks a pending run on its loop's approval gate. */
93
90
  export declare const awaitApproval: (_state: Pending) => Waiting;
94
- /** Returns the approved state; the Run still waits for a Worker slot before execution. */
95
91
  export declare const approve: (_state: Waiting) => Queued;
96
- /** Returns the running state for a first Attempt after any required approval has been granted. */
97
92
  export declare const start: (_state: Startable) => Running;
98
- /** Closes the run after a successful attempt. */
99
93
  export declare const succeed: (_state: Running) => Succeeded;
100
- /** Closes the run after a failed attempt when no auto-retry applies; `shouldAutoRetry` decides that. */
94
+ /** Returns `Failed`. Callers use it only if `shouldAutoRetry` returns `false`. */
101
95
  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
96
  export declare const retry: (_state: Failed) => Running;
104
- /** Cancels from any open state. */
105
97
  export declare const cancelByOperator: (_state: Open) => Canceled;
106
98
  /**
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).
99
+ * Returns `Canceled` for a Run replaced by the newer Event `by`. A running Run isn't
100
+ * superseded; the engine evaluates the newer Event after its Attempt ends (ADR 0007).
109
101
  */
110
102
  export declare const supersede: (_state: Unstarted, by: EventId) => Canceled;
111
- /** Cancels an unstarted run because its Item stopped matching the loop's trigger. */
112
103
  export declare const revoke: (_state: Unstarted) => Canceled;
113
104
  export {};
114
105
  //# sourceMappingURL=state.d.ts.map
@@ -1 +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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