@kici-dev/engine 0.1.27 → 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 (148) hide show
  1. package/dist/approval/types.d.ts +8 -1
  2. package/dist/approval/types.js +8 -1
  3. package/dist/artifacts/name.d.ts +60 -0
  4. package/dist/artifacts/name.js +71 -0
  5. package/dist/audit/access-log-policy.d.ts +1 -1
  6. package/dist/audit/access-log-policy.js +8 -0
  7. package/dist/audit/activity.d.ts +12 -12
  8. package/dist/audit/retention-policy.js +16 -0
  9. package/dist/billing/plan-type.d.ts +53 -0
  10. package/dist/billing/plan-type.js +70 -0
  11. package/dist/bundler/rolldown-config.d.ts +3 -3
  12. package/dist/check-mode.d.ts +1 -1
  13. package/dist/context/concurrency-strategy.d.ts +34 -0
  14. package/dist/context/concurrency-strategy.js +35 -0
  15. package/dist/context/held-run-job-id.d.ts +45 -0
  16. package/dist/context/held-run-job-id.js +56 -0
  17. package/dist/context/held-run-status.d.ts +33 -0
  18. package/dist/context/held-run-status.js +37 -0
  19. package/dist/context/hold-expiry.d.ts +20 -0
  20. package/dist/context/hold-expiry.js +25 -0
  21. package/dist/context/hold-reason.d.ts +33 -0
  22. package/dist/context/hold-reason.js +23 -0
  23. package/dist/context/hold-type.d.ts +40 -0
  24. package/dist/context/hold-type.js +61 -0
  25. package/dist/context/index.d.ts +9 -1
  26. package/dist/context/index.js +9 -2
  27. package/dist/context/multi-context.d.ts +3 -3
  28. package/dist/context/scope-name.d.ts +29 -0
  29. package/dist/context/scope-name.js +49 -0
  30. package/dist/context/scope-resolver.d.ts +33 -0
  31. package/dist/context/scope-resolver.js +45 -15
  32. package/dist/context/types.d.ts +8 -5
  33. package/dist/dev-ops/operations.d.ts +8 -0
  34. package/dist/dev-ops/operations.js +36 -19
  35. package/dist/diagnostics/infra-alert.d.ts +71 -0
  36. package/dist/diagnostics/infra-alert.js +60 -0
  37. package/dist/env/environment-allowlist.d.ts +4 -4
  38. package/dist/fanout/materialize.d.ts +16 -0
  39. package/dist/fanout/materialize.js +32 -3
  40. package/dist/index.d.ts +15 -6
  41. package/dist/index.js +34 -19
  42. package/dist/inputs/descriptor.d.ts +9 -9
  43. package/dist/inventory.d.ts +4 -4
  44. package/dist/labels.d.ts +82 -2
  45. package/dist/labels.js +119 -1
  46. package/dist/matrix/expand.d.ts +49 -2
  47. package/dist/matrix/expand.js +102 -13
  48. package/dist/matrix/format.d.ts +6 -1
  49. package/dist/matrix/format.js +6 -1
  50. package/dist/mcp/held-run-resolve.d.ts +7 -10
  51. package/dist/mcp/held-run-resolve.js +33 -7
  52. package/dist/metrics/catalog-policy.js +4 -4
  53. package/dist/metrics/metric-catalog.generated.d.ts +954 -739
  54. package/dist/metrics/metric-catalog.generated.js +278 -20
  55. package/dist/metrics/metric-kind-compat.d.ts +26 -0
  56. package/dist/metrics/metric-kind-compat.js +33 -0
  57. package/dist/protocol/analytics-events.d.ts +6 -6
  58. package/dist/protocol/dashboard-api-errors.d.ts +1 -0
  59. package/dist/protocol/dashboard-api-errors.js +5 -1
  60. package/dist/protocol/dashboard-write-operations.d.ts +143 -86
  61. package/dist/protocol/dashboard-write-operations.js +91 -17
  62. package/dist/protocol/messages/access-log.d.ts +437 -392
  63. package/dist/protocol/messages/access-log.js +11 -2
  64. package/dist/protocol/messages/actor.d.ts +2 -2
  65. package/dist/protocol/messages/agent-dev-ops.d.ts +4 -2
  66. package/dist/protocol/messages/agent-dev-ops.js +2 -5
  67. package/dist/protocol/messages/agent-run-result.d.ts +72 -62
  68. package/dist/protocol/messages/auth.d.ts +35 -23
  69. package/dist/protocol/messages/browser.d.ts +81 -5
  70. package/dist/protocol/messages/browser.js +53 -2
  71. package/dist/protocol/messages/capabilities.d.ts +106 -31
  72. package/dist/protocol/messages/capabilities.js +94 -10
  73. package/dist/protocol/messages/common.d.ts +45 -2
  74. package/dist/protocol/messages/common.js +64 -3
  75. package/dist/protocol/messages/dashboard-sealed-write.d.ts +52 -0
  76. package/dist/protocol/messages/dashboard-sealed-write.js +57 -0
  77. package/dist/protocol/messages/dashboard.d.ts +1022 -498
  78. package/dist/protocol/messages/dashboard.js +198 -31
  79. package/dist/protocol/messages/deployment-identity.d.ts +37 -10
  80. package/dist/protocol/messages/deployment-identity.js +30 -3
  81. package/dist/protocol/messages/event-log.d.ts +5 -5
  82. package/dist/protocol/messages/execution-status.d.ts +189 -53
  83. package/dist/protocol/messages/execution-status.js +108 -40
  84. package/dist/protocol/messages/heartbeat-health.d.ts +83 -0
  85. package/dist/protocol/messages/heartbeat-health.js +87 -0
  86. package/dist/protocol/messages/log-stream.d.ts +18 -0
  87. package/dist/protocol/messages/log-stream.js +19 -0
  88. package/dist/protocol/messages/oidc-mint.d.ts +7 -0
  89. package/dist/protocol/messages/oidc-mint.js +7 -0
  90. package/dist/protocol/messages/orchestrator-agent.d.ts +264 -67
  91. package/dist/protocol/messages/orchestrator-agent.js +170 -5
  92. package/dist/protocol/messages/pat-kind.d.ts +1 -1
  93. package/dist/protocol/messages/peer.d.ts +122 -58
  94. package/dist/protocol/messages/peer.js +37 -2
  95. package/dist/protocol/messages/platform-orchestrator.d.ts +561 -217
  96. package/dist/protocol/messages/platform-orchestrator.js +131 -21
  97. package/dist/protocol/messages/run-events.d.ts +5 -5
  98. package/dist/protocol/messages/scaler-event.d.ts +3 -3
  99. package/dist/protocol/messages/source-registration.d.ts +56 -13
  100. package/dist/protocol/messages/source-registration.js +49 -6
  101. package/dist/protocol/source-origin.d.ts +1 -1
  102. package/dist/provenance/attestation-origin.d.ts +1 -1
  103. package/dist/provenance/schema.d.ts +11 -11
  104. package/dist/provenance/verify.js +2 -1
  105. package/dist/provider/changed-files-fetcher.d.ts +21 -2
  106. package/dist/provider/check-run-conclusion.d.ts +2 -2
  107. package/dist/provider/check-status-poster.d.ts +23 -0
  108. package/dist/provider/index.d.ts +2 -2
  109. package/dist/registration/registerable-trigger-type.d.ts +14 -13
  110. package/dist/registration/registerable-trigger-type.js +1 -0
  111. package/dist/sandbox/capabilities.d.ts +6 -0
  112. package/dist/sandbox/capabilities.js +57 -0
  113. package/dist/scaler/scaler-backend-type.d.ts +1 -1
  114. package/dist/status/presentation.d.ts +89 -0
  115. package/dist/status/presentation.js +163 -0
  116. package/dist/trigger/compiled-matchers.d.ts +13 -0
  117. package/dist/trigger/compiled-matchers.js +44 -0
  118. package/dist/trigger/event-buckets.d.ts +44 -0
  119. package/dist/trigger/event-buckets.js +93 -0
  120. package/dist/trigger/matcher.d.ts +7 -3
  121. package/dist/trigger/matcher.js +53 -15
  122. package/dist/trigger/schedule-key.d.ts +14 -0
  123. package/dist/trigger/schedule-key.js +21 -0
  124. package/dist/trigger/trigger-event-type.d.ts +1 -1
  125. package/dist/trigger/trigger-event-type.js +2 -0
  126. package/dist/trigger/types.d.ts +173 -43
  127. package/dist/trigger/types.js +82 -25
  128. package/dist/webhook/event-types.d.ts +56 -0
  129. package/dist/webhook/event-types.js +59 -0
  130. package/dist/ws/ws-like.d.ts +13 -0
  131. package/package.json +12 -4
  132. package/sbom.spdx.json +10 -10
  133. package/dist/environment/host-match.d.ts +0 -25
  134. package/dist/environment/index.d.ts +0 -6
  135. package/dist/environment/multi-env.d.ts +0 -30
  136. package/dist/environment/scope-resolver.d.ts +0 -46
  137. package/dist/environment/scope-template.d.ts +0 -18
  138. package/dist/environment/types.d.ts +0 -119
  139. package/dist/package-manager.d.ts +0 -20
  140. package/dist/protocol/messages/observe.d.ts +0 -76
  141. package/dist/protocol/messages/saas-orchestrator.d.ts +0 -2179
  142. package/dist/protocol/messages/test-run.d.ts +0 -59
  143. package/dist/state-machine/index.d.ts +0 -2
  144. package/dist/state-machine/index.js +0 -3
  145. package/dist/state-machine/machine.d.ts +0 -34
  146. package/dist/state-machine/machine.js +0 -103
  147. package/dist/state-machine/types.d.ts +0 -34
  148. package/dist/state-machine/types.js +0 -15
@@ -15,10 +15,10 @@ export type { ProviderType } from './types.js';
15
15
  export type { WebhookNormalizer, AccessCacheInvalidation } from './webhook-normalizer.js';
16
16
  export type { LockFileFetcher } from './lock-file-fetcher.js';
17
17
  export { LockFileParseError } from './lock-file-parse-error.js';
18
- export type { ChangedFilesFetcher } from './changed-files-fetcher.js';
18
+ export type { ChangedFilesFetcher, ChangedFilesResult } from './changed-files-fetcher.js';
19
19
  export type { CloneTokenProvider, ProviderGitAuth } from './clone-token-provider.js';
20
20
  export type { RepoUrlBuilder } from './repo-url-builder.js';
21
21
  export type { ContributorResolver, ContributorInfo, ContributorPermission, } from './contributor-resolver.js';
22
- export type { CheckStatusPoster, CheckStatus } from './check-status-poster.js';
22
+ export type { CheckStatusPoster, CheckStatus, WorkflowModificationInfo, } from './check-status-poster.js';
23
23
  export * from './check-run-conclusion.js';
24
24
  //# sourceMappingURL=index.d.ts.map
@@ -25,28 +25,29 @@ import { z } from 'zod';
25
25
  * Access values: RegisterableTriggerType.enum.kici_event, etc.
26
26
  */
27
27
  export declare const RegisterableTriggerType: z.ZodEnum<{
28
+ comment: "comment";
29
+ create: "create";
30
+ delete: "delete";
28
31
  dispatch: "dispatch";
29
- push: "push";
30
- status: "status";
32
+ fork: "fork";
31
33
  generic_webhook: "generic_webhook";
34
+ job_complete: "job_complete";
35
+ kici_event: "kici_event";
36
+ lifecycle: "lifecycle";
32
37
  pr: "pr";
33
- tag: "tag";
34
- comment: "comment";
38
+ push: "push";
39
+ release: "release";
35
40
  review: "review";
36
41
  review_comment: "review_comment";
37
- release: "release";
38
- create: "create";
39
- delete: "delete";
40
- workflow_run: "workflow_run";
41
- fork: "fork";
42
+ schedule: "schedule";
42
43
  star: "star";
44
+ status: "status";
45
+ tag: "tag";
43
46
  watch: "watch";
44
47
  webhook: "webhook";
45
- kici_event: "kici_event";
46
48
  workflow_complete: "workflow_complete";
47
- job_complete: "job_complete";
48
- schedule: "schedule";
49
- lifecycle: "lifecycle";
49
+ workflow_run: "workflow_run";
50
+ workflows_failed_batch: "workflows_failed_batch";
50
51
  }>;
51
52
  export type RegisterableTriggerType = z.infer<typeof RegisterableTriggerType>;
52
53
  //# sourceMappingURL=registerable-trigger-type.d.ts.map
@@ -29,6 +29,7 @@ import { z } from "zod";
29
29
  const RegisterableTriggerType = z.enum([
30
30
  "kici_event",
31
31
  "workflow_complete",
32
+ "workflows_failed_batch",
32
33
  "job_complete",
33
34
  "generic_webhook",
34
35
  "schedule",
@@ -0,0 +1,6 @@
1
+ export declare const KNOWN_LINUX_CAPABILITIES: ReadonlySet<string>;
2
+ /** Normalize a capability name to the bare uppercase form used by CapAdd and the allow-list. */
3
+ export declare function canonicalizeCapability(raw: string): string;
4
+ /** True when `raw` (in either CAP_-prefixed or bare form) is a real Linux capability. */
5
+ export declare function isKnownCapability(raw: string): boolean;
6
+ //# sourceMappingURL=capabilities.d.ts.map
@@ -0,0 +1,57 @@
1
+ import "../rolldown-runtime-ClRpJifh.js";
2
+ //#region src/sandbox/capabilities.ts
3
+ const KNOWN_LINUX_CAPABILITIES = /* @__PURE__ */ new Set([
4
+ "CHOWN",
5
+ "DAC_OVERRIDE",
6
+ "DAC_READ_SEARCH",
7
+ "FOWNER",
8
+ "FSETID",
9
+ "KILL",
10
+ "SETGID",
11
+ "SETUID",
12
+ "SETPCAP",
13
+ "LINUX_IMMUTABLE",
14
+ "NET_BIND_SERVICE",
15
+ "NET_BROADCAST",
16
+ "NET_ADMIN",
17
+ "NET_RAW",
18
+ "IPC_LOCK",
19
+ "IPC_OWNER",
20
+ "SYS_MODULE",
21
+ "SYS_RAWIO",
22
+ "SYS_CHROOT",
23
+ "SYS_PTRACE",
24
+ "SYS_PACCT",
25
+ "SYS_ADMIN",
26
+ "SYS_BOOT",
27
+ "SYS_NICE",
28
+ "SYS_RESOURCE",
29
+ "SYS_TIME",
30
+ "SYS_TTY_CONFIG",
31
+ "MKNOD",
32
+ "LEASE",
33
+ "AUDIT_WRITE",
34
+ "AUDIT_CONTROL",
35
+ "SETFCAP",
36
+ "MAC_OVERRIDE",
37
+ "MAC_ADMIN",
38
+ "SYSLOG",
39
+ "WAKE_ALARM",
40
+ "BLOCK_SUSPEND",
41
+ "AUDIT_READ",
42
+ "PERFMON",
43
+ "BPF",
44
+ "CHECKPOINT_RESTORE"
45
+ ]);
46
+ /** Normalize a capability name to the bare uppercase form used by CapAdd and the allow-list. */
47
+ function canonicalizeCapability(raw) {
48
+ return raw.trim().toUpperCase().replace(/^CAP_/, "");
49
+ }
50
+ /** True when `raw` (in either CAP_-prefixed or bare form) is a real Linux capability. */
51
+ function isKnownCapability(raw) {
52
+ return KNOWN_LINUX_CAPABILITIES.has(canonicalizeCapability(raw));
53
+ }
54
+ //#endregion
55
+ export { KNOWN_LINUX_CAPABILITIES, canonicalizeCapability, isKnownCapability };
56
+
57
+ //# sourceMappingURL=capabilities.js.map
@@ -7,8 +7,8 @@ import { z } from 'zod';
7
7
  * Access values: ScalerBackendType.enum.container, ScalerBackendType.enum.firecracker, etc.
8
8
  */
9
9
  export declare const ScalerBackendType: z.ZodEnum<{
10
- container: "container";
11
10
  "bare-metal": "bare-metal";
11
+ container: "container";
12
12
  firecracker: "firecracker";
13
13
  kubernetes: "kubernetes";
14
14
  }>;
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Shared execution-status presentation vocabulary: the canonical status union,
3
+ * a total precedence order for roll-up aggregates, legacy-spelling resolution,
4
+ * and a per-status failure classification.
5
+ *
6
+ * Pure Zod (browser-safe): the engine barrel re-exports this module and the
7
+ * dashboard imports the barrel, so no Node built-in may appear here.
8
+ *
9
+ * Consumers keep their own presentation tables (badge colour, terminal colour,
10
+ * emoji, webhook event type) — those are medium-specific. What lives here is
11
+ * the vocabulary itself and the two questions every consumer asks about it:
12
+ * "which of these statuses wins?" and "is this status a failure?".
13
+ */
14
+ import { z } from 'zod';
15
+ import { ExecutionJobStatus, ExecutionRunStatus } from '../protocol/messages/execution-status.js';
16
+ /**
17
+ * Every status a run or a job can hold. `ExecutionStepStatus` is a strict
18
+ * subset (running / success / failed / skipped / pending / cancelled), so a
19
+ * table keyed by this union also covers step surfaces.
20
+ */
21
+ export type CanonicalStatus = ExecutionRunStatus | ExecutionJobStatus;
22
+ /** Every canonical status, derived from the engine enums so it cannot drift. */
23
+ export declare const CANONICAL_STATUSES: readonly CanonicalStatus[];
24
+ /** Canonical statuses ordered worst-first. Derived from `STATUS_RANK`. */
25
+ export declare const STATUS_PRECEDENCE: readonly CanonicalStatus[];
26
+ /**
27
+ * Legacy status spellings that map onto a canonical status. An alias always
28
+ * resolves like the status it aliases, so a consumer never needs a second
29
+ * hand-written copy of the mapping.
30
+ */
31
+ export declare const LEGACY_STATUS_ALIASES: Readonly<Record<string, CanonicalStatus>>;
32
+ /**
33
+ * Resolve a status string onto its canonical status, or `undefined` when it is
34
+ * neither canonical nor a known legacy alias. Callers that accept mixed case
35
+ * lowercase their input first.
36
+ *
37
+ * `Object.hasOwn`, not a bare index: an object literal inherits
38
+ * `Object.prototype`, so indexing it with `toString` / `constructor` /
39
+ * `valueOf` would yield a function rather than `undefined` and the caller's
40
+ * fallback would never fire.
41
+ */
42
+ export declare function toCanonicalStatus(status: string): CanonicalStatus | undefined;
43
+ /**
44
+ * The winning status for a group of children, by `STATUS_RANK` precedence.
45
+ *
46
+ * Returns `undefined` when no input resolves, so the caller decides what to
47
+ * show rather than being handed a fabricated status. A roll-up must never
48
+ * invent "queued" or "success" for a child it did not recognise.
49
+ *
50
+ * An unrecognised child in an OTHERWISE resolvable group is skipped, so the
51
+ * aggregate reports the worst status this build understands. That is a
52
+ * deliberate trade: the alternative — refusing to aggregate at all — would blank
53
+ * the group header for one unknown child. It does mean an older bundle talking
54
+ * to a newer orchestrator can report a group as `success` when an unrecognised
55
+ * sibling was in fact a failure; the per-child badges still render each unknown
56
+ * status on its own terms, which is where the discrepancy is visible.
57
+ */
58
+ export declare function worstStatus(statuses: readonly string[]): CanonicalStatus | undefined;
59
+ /**
60
+ * How a status counts when deciding whether something failed.
61
+ *
62
+ * - `failure` — the workflow did not do what it declared. Drives the run
63
+ * roll-up and the `on-failure` needs-edge expansion.
64
+ * - `cancelled` — deliberately stopped; its own outcome, not a failure.
65
+ * - `neutral` — terminal but never ran (skipped).
66
+ * - `success` — passed.
67
+ * - `in-flight` — not terminal yet.
68
+ */
69
+ export declare const StatusFailureClass: z.ZodEnum<{
70
+ cancelled: "cancelled";
71
+ failure: "failure";
72
+ "in-flight": "in-flight";
73
+ neutral: "neutral";
74
+ success: "success";
75
+ }>;
76
+ export type StatusFailureClass = z.infer<typeof StatusFailureClass>;
77
+ /**
78
+ * Failure classification for every canonical status. Exhaustive by type, for
79
+ * the same reason as `STATUS_RANK`.
80
+ *
81
+ * `drift_dropped` is a `failure`: the job was dropped by determinism drift on
82
+ * the executing agent, so a job the workflow declared did not run. The run
83
+ * roll-up and the `on-failure` needs-edge both read this one table, which is
84
+ * what stops them from disagreeing.
85
+ */
86
+ export declare const STATUS_FAILURE_CLASS: Readonly<Record<CanonicalStatus, StatusFailureClass>>;
87
+ /** True when a status means the workflow did not do what it declared. */
88
+ export declare function isFailureStatus(status: string): boolean;
89
+ //# sourceMappingURL=presentation.d.ts.map
@@ -0,0 +1,163 @@
1
+ import "../rolldown-runtime-ClRpJifh.js";
2
+ import { ExecutionJobStatus, ExecutionRunStatus } from "../protocol/messages/execution-status.js";
3
+ import { z } from "zod";
4
+ //#region src/status/presentation.ts
5
+ /**
6
+ * Shared execution-status presentation vocabulary: the canonical status union,
7
+ * a total precedence order for roll-up aggregates, legacy-spelling resolution,
8
+ * and a per-status failure classification.
9
+ *
10
+ * Pure Zod (browser-safe): the engine barrel re-exports this module and the
11
+ * dashboard imports the barrel, so no Node built-in may appear here.
12
+ *
13
+ * Consumers keep their own presentation tables (badge colour, terminal colour,
14
+ * emoji, webhook event type) — those are medium-specific. What lives here is
15
+ * the vocabulary itself and the two questions every consumer asks about it:
16
+ * "which of these statuses wins?" and "is this status a failure?".
17
+ */
18
+ /** Every canonical status, derived from the engine enums so it cannot drift. */
19
+ const CANONICAL_STATUSES = Object.freeze([.../* @__PURE__ */ new Set([...ExecutionRunStatus.options, ...ExecutionJobStatus.options])]);
20
+ const CANONICAL_SET = new Set(CANONICAL_STATUSES);
21
+ /**
22
+ * Precedence rank for roll-up aggregates — LOWER wins.
23
+ *
24
+ * Exhaustive by type: adding a value to either engine enum breaks this file's
25
+ * typecheck. That is the whole point — `STATUS_PRECEDENCE` below is a plain
26
+ * array, and an array literal missing a member would compile silently, so the
27
+ * ordered list is derived from this record rather than written by hand.
28
+ *
29
+ * - Failures outrank in-flight states, so one failed shard reddens a matrix
30
+ * group immediately rather than waiting for its siblings to settle.
31
+ * - `cancelling` sits above `recovering` and `running`: an in-flight cancel
32
+ * must stay visible on the group header.
33
+ * - `unroutable` sits beside the other "declared but never ran" failures: a
34
+ * job whose `runsOn` matched no agent must redden its group, since the
35
+ * workflow did not do what it declared.
36
+ * - `cancelled` sits below the actively-executing states (`running`,
37
+ * `recovering`, `cancelling`) but ABOVE the not-yet-started ones (`held`,
38
+ * `queued`, `pending`). A band with a live child is still running whatever
39
+ * happened to its cancelled sibling; a band whose only news is that a child
40
+ * was cancelled reads "Cancelled" rather than "Queued", because the
41
+ * cancellation is the thing an operator needs to see.
42
+ * - `success` outranks `skipped`, so a matrix where three shards were narrowed
43
+ * out and one passed reads green. Only a group with no successful child
44
+ * reads "Skipped".
45
+ */
46
+ const STATUS_RANK = Object.freeze({
47
+ [ExecutionJobStatus.enum.failed]: 0,
48
+ [ExecutionJobStatus.enum.timed_out_stale]: 1,
49
+ [ExecutionJobStatus.enum.drift_dropped]: 2,
50
+ [ExecutionJobStatus.enum.unroutable]: 3,
51
+ [ExecutionJobStatus.enum.cancelling]: 4,
52
+ [ExecutionJobStatus.enum.recovering]: 5,
53
+ [ExecutionJobStatus.enum.running]: 6,
54
+ [ExecutionJobStatus.enum.cancelled]: 7,
55
+ [ExecutionRunStatus.enum.held]: 8,
56
+ [ExecutionJobStatus.enum.queued]: 9,
57
+ [ExecutionJobStatus.enum.pending]: 10,
58
+ [ExecutionJobStatus.enum.success]: 11,
59
+ [ExecutionJobStatus.enum.skipped]: 12
60
+ });
61
+ /** Canonical statuses ordered worst-first. Derived from `STATUS_RANK`. */
62
+ const STATUS_PRECEDENCE = Object.freeze([...CANONICAL_STATUSES].sort((a, b) => STATUS_RANK[a] - STATUS_RANK[b]));
63
+ /**
64
+ * Legacy status spellings that map onto a canonical status. An alias always
65
+ * resolves like the status it aliases, so a consumer never needs a second
66
+ * hand-written copy of the mapping.
67
+ */
68
+ const LEGACY_STATUS_ALIASES = Object.freeze({
69
+ passed: ExecutionRunStatus.enum.success,
70
+ completed: ExecutionRunStatus.enum.success,
71
+ in_progress: ExecutionRunStatus.enum.running,
72
+ error: ExecutionRunStatus.enum.failed,
73
+ canceled: ExecutionRunStatus.enum.cancelled,
74
+ waiting: ExecutionRunStatus.enum.pending
75
+ });
76
+ /**
77
+ * Resolve a status string onto its canonical status, or `undefined` when it is
78
+ * neither canonical nor a known legacy alias. Callers that accept mixed case
79
+ * lowercase their input first.
80
+ *
81
+ * `Object.hasOwn`, not a bare index: an object literal inherits
82
+ * `Object.prototype`, so indexing it with `toString` / `constructor` /
83
+ * `valueOf` would yield a function rather than `undefined` and the caller's
84
+ * fallback would never fire.
85
+ */
86
+ function toCanonicalStatus(status) {
87
+ if (Object.hasOwn(LEGACY_STATUS_ALIASES, status)) return LEGACY_STATUS_ALIASES[status];
88
+ return CANONICAL_SET.has(status) ? status : void 0;
89
+ }
90
+ /**
91
+ * The winning status for a group of children, by `STATUS_RANK` precedence.
92
+ *
93
+ * Returns `undefined` when no input resolves, so the caller decides what to
94
+ * show rather than being handed a fabricated status. A roll-up must never
95
+ * invent "queued" or "success" for a child it did not recognise.
96
+ *
97
+ * An unrecognised child in an OTHERWISE resolvable group is skipped, so the
98
+ * aggregate reports the worst status this build understands. That is a
99
+ * deliberate trade: the alternative — refusing to aggregate at all — would blank
100
+ * the group header for one unknown child. It does mean an older bundle talking
101
+ * to a newer orchestrator can report a group as `success` when an unrecognised
102
+ * sibling was in fact a failure; the per-child badges still render each unknown
103
+ * status on its own terms, which is where the discrepancy is visible.
104
+ */
105
+ function worstStatus(statuses) {
106
+ let best;
107
+ for (const raw of statuses) {
108
+ const canonical = toCanonicalStatus(raw);
109
+ if (canonical === void 0) continue;
110
+ if (best === void 0 || STATUS_RANK[canonical] < STATUS_RANK[best]) best = canonical;
111
+ }
112
+ return best;
113
+ }
114
+ /**
115
+ * How a status counts when deciding whether something failed.
116
+ *
117
+ * - `failure` — the workflow did not do what it declared. Drives the run
118
+ * roll-up and the `on-failure` needs-edge expansion.
119
+ * - `cancelled` — deliberately stopped; its own outcome, not a failure.
120
+ * - `neutral` — terminal but never ran (skipped).
121
+ * - `success` — passed.
122
+ * - `in-flight` — not terminal yet.
123
+ */
124
+ const StatusFailureClass = z.enum([
125
+ "failure",
126
+ "cancelled",
127
+ "neutral",
128
+ "success",
129
+ "in-flight"
130
+ ]);
131
+ /**
132
+ * Failure classification for every canonical status. Exhaustive by type, for
133
+ * the same reason as `STATUS_RANK`.
134
+ *
135
+ * `drift_dropped` is a `failure`: the job was dropped by determinism drift on
136
+ * the executing agent, so a job the workflow declared did not run. The run
137
+ * roll-up and the `on-failure` needs-edge both read this one table, which is
138
+ * what stops them from disagreeing.
139
+ */
140
+ const STATUS_FAILURE_CLASS = Object.freeze({
141
+ [ExecutionJobStatus.enum.failed]: StatusFailureClass.enum.failure,
142
+ [ExecutionJobStatus.enum.timed_out_stale]: StatusFailureClass.enum.failure,
143
+ [ExecutionJobStatus.enum.drift_dropped]: StatusFailureClass.enum.failure,
144
+ [ExecutionJobStatus.enum.unroutable]: StatusFailureClass.enum.failure,
145
+ [ExecutionJobStatus.enum.cancelled]: StatusFailureClass.enum.cancelled,
146
+ [ExecutionJobStatus.enum.skipped]: StatusFailureClass.enum.neutral,
147
+ [ExecutionJobStatus.enum.success]: StatusFailureClass.enum.success,
148
+ [ExecutionJobStatus.enum.pending]: StatusFailureClass.enum["in-flight"],
149
+ [ExecutionJobStatus.enum.queued]: StatusFailureClass.enum["in-flight"],
150
+ [ExecutionJobStatus.enum.running]: StatusFailureClass.enum["in-flight"],
151
+ [ExecutionJobStatus.enum.recovering]: StatusFailureClass.enum["in-flight"],
152
+ [ExecutionJobStatus.enum.cancelling]: StatusFailureClass.enum["in-flight"],
153
+ [ExecutionRunStatus.enum.held]: StatusFailureClass.enum["in-flight"]
154
+ });
155
+ /** True when a status means the workflow did not do what it declared. */
156
+ function isFailureStatus(status) {
157
+ const canonical = toCanonicalStatus(status.toLowerCase());
158
+ return canonical !== void 0 && STATUS_FAILURE_CLASS[canonical] === StatusFailureClass.enum.failure;
159
+ }
160
+ //#endregion
161
+ export { CANONICAL_STATUSES, LEGACY_STATUS_ALIASES, STATUS_FAILURE_CLASS, STATUS_PRECEDENCE, StatusFailureClass, isFailureStatus, toCanonicalStatus, worstStatus };
162
+
163
+ //# sourceMappingURL=presentation.js.map
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Return a memoized RegExp for the given pattern + flags. The key encodes the
3
+ * flags first with a space separator; regex flags are restricted to
4
+ * `[gimsuydv]`, so the separator can never collide with a pattern that starts
5
+ * with a space.
6
+ */
7
+ export declare function getCompiledRegex(pattern: string, flags?: string): RegExp;
8
+ /**
9
+ * Return a memoized picomatch matcher function for the given glob pattern.
10
+ * `getGlobMatcher(pattern)(str)` is equivalent to `picomatch.isMatch(str, pattern)`.
11
+ */
12
+ export declare function getGlobMatcher(pattern: string): (s: string) => boolean;
13
+ //# sourceMappingURL=compiled-matchers.d.ts.map
@@ -0,0 +1,44 @@
1
+ import "../rolldown-runtime-ClRpJifh.js";
2
+ import picomatch from "picomatch";
3
+ //#region src/trigger/compiled-matchers.ts
4
+ /**
5
+ * Bounded memo for compiled trigger matchers. Regex and glob compilation is
6
+ * pure and deterministic per pattern string, so we compile each distinct
7
+ * pattern once and reuse it across every match call. Insertion-ordered Map
8
+ * with oldest-eviction keeps the memo bounded without a new dependency, and
9
+ * keeps the engine barrel browser-safe (no node:* imports).
10
+ */
11
+ const MAX_COMPILED = 5e3;
12
+ function boundedGet(cache, key, make) {
13
+ const existing = cache.get(key);
14
+ if (existing !== void 0) return existing;
15
+ const value = make();
16
+ cache.set(key, value);
17
+ if (cache.size > MAX_COMPILED) {
18
+ const oldest = cache.keys().next().value;
19
+ if (oldest !== void 0) cache.delete(oldest);
20
+ }
21
+ return value;
22
+ }
23
+ const regexCache = /* @__PURE__ */ new Map();
24
+ const globCache = /* @__PURE__ */ new Map();
25
+ /**
26
+ * Return a memoized RegExp for the given pattern + flags. The key encodes the
27
+ * flags first with a space separator; regex flags are restricted to
28
+ * `[gimsuydv]`, so the separator can never collide with a pattern that starts
29
+ * with a space.
30
+ */
31
+ function getCompiledRegex(pattern, flags) {
32
+ return boundedGet(regexCache, `${flags ?? ""} ${pattern}`, () => new RegExp(pattern, flags));
33
+ }
34
+ /**
35
+ * Return a memoized picomatch matcher function for the given glob pattern.
36
+ * `getGlobMatcher(pattern)(str)` is equivalent to `picomatch.isMatch(str, pattern)`.
37
+ */
38
+ function getGlobMatcher(pattern) {
39
+ return boundedGet(globCache, pattern, () => picomatch(pattern));
40
+ }
41
+ //#endregion
42
+ export { getCompiledRegex, getGlobMatcher };
43
+
44
+ //# sourceMappingURL=compiled-matchers.js.map
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Event-type bucketing for trigger matching. Walking every workflow per
3
+ * webhook is O(all-workflows) even though most reject on the event-type guard.
4
+ * We index workflows by the SimulatedEvent.type(s) they can match once per
5
+ * lockfile (memoized on the workflows-array identity) and, on the hot dispatch
6
+ * path, evaluate only the candidates for the incoming event type.
7
+ *
8
+ * Pure module — no node:* imports — so the engine barrel stays browser-safe.
9
+ */
10
+ import type { LockWorkflow, SimulatedEvent } from './types.js';
11
+ import type { WorkflowDecision } from './decision-trace.js';
12
+ import type { TriggerEventType } from './trigger-event-type.js';
13
+ /**
14
+ * Static inverse of the `event.type !== X` guards in matcher.ts. Every trigger
15
+ * `_type` maps to the set of SimulatedEvent.type values whose guard it passes.
16
+ *
17
+ * Two triggers are multi-type:
18
+ * - `webhook` is NOT in this map — its event types are per-instance
19
+ * (`trigger.events`), resolved in prepareEventBuckets.
20
+ * - `workflows_failed_batch` matches TWO event types: a failed
21
+ * `workflow_complete` (accumulation input) and the synthetic
22
+ * `workflows_failed_batch` (dispatch), so it maps to both.
23
+ *
24
+ * Guarded against drift by event-buckets.test.ts (the equivalence + guard
25
+ * tests would fail if a guard changed without this map).
26
+ */
27
+ export declare const TRIGGER_TYPE_TO_EVENT_TYPES: Record<string, readonly TriggerEventType[]>;
28
+ /**
29
+ * Index workflows by every SimulatedEvent.type any of their triggers can match.
30
+ * Memoized on the workflows-array identity: LockFileCache returns the same
31
+ * LockFile (hence the same workflows array) on a cache hit, so buckets are
32
+ * built once per cached lockfile and GC'd with it.
33
+ */
34
+ export declare function prepareEventBuckets(workflows: readonly LockWorkflow[]): Map<string, LockWorkflow[]>;
35
+ /**
36
+ * Match only the workflows subscribed to the incoming event type. Returns
37
+ * candidate decisions (a superset of matched); callers filter `.matched`.
38
+ * The candidate set is a superset of every workflow matchAllWorkflows would
39
+ * mark matched — a workflow matches only if some trigger's guard passes for
40
+ * event.type, which means that trigger indexed the workflow under event.type —
41
+ * so the matched result is identical.
42
+ */
43
+ export declare function matchWorkflowsForEvent(workflows: readonly LockWorkflow[], event: SimulatedEvent): WorkflowDecision[];
44
+ //# sourceMappingURL=event-buckets.d.ts.map
@@ -0,0 +1,93 @@
1
+ import "../rolldown-runtime-ClRpJifh.js";
2
+ import { matchWorkflowTriggers } from "./matcher.js";
3
+ //#region src/trigger/event-buckets.ts
4
+ /**
5
+ * Static inverse of the `event.type !== X` guards in matcher.ts. Every trigger
6
+ * `_type` maps to the set of SimulatedEvent.type values whose guard it passes.
7
+ *
8
+ * Two triggers are multi-type:
9
+ * - `webhook` is NOT in this map — its event types are per-instance
10
+ * (`trigger.events`), resolved in prepareEventBuckets.
11
+ * - `workflows_failed_batch` matches TWO event types: a failed
12
+ * `workflow_complete` (accumulation input) and the synthetic
13
+ * `workflows_failed_batch` (dispatch), so it maps to both.
14
+ *
15
+ * Guarded against drift by event-buckets.test.ts (the equivalence + guard
16
+ * tests would fail if a guard changed without this map).
17
+ */
18
+ const TRIGGER_TYPE_TO_EVENT_TYPES = {
19
+ pr: ["pull_request"],
20
+ push: ["push"],
21
+ tag: ["tag"],
22
+ comment: ["comment"],
23
+ review: ["review"],
24
+ review_comment: ["review_comment"],
25
+ release: ["release"],
26
+ dispatch: ["dispatch"],
27
+ create: ["create"],
28
+ delete: ["delete"],
29
+ status: ["status"],
30
+ workflow_run: ["workflow_run"],
31
+ fork: ["fork"],
32
+ star: ["star"],
33
+ watch: ["watch"],
34
+ kici_event: ["kici_event"],
35
+ workflow_complete: ["workflow_complete"],
36
+ workflows_failed_batch: ["workflow_complete", "workflows_failed_batch"],
37
+ job_complete: ["job_complete"],
38
+ generic_webhook: ["generic_webhook"],
39
+ schedule: ["schedule"],
40
+ lifecycle: ["lifecycle"]
41
+ };
42
+ const WEBHOOK_TRIGGER_TYPE = "webhook";
43
+ const bucketMemo = /* @__PURE__ */ new WeakMap();
44
+ /**
45
+ * Index workflows by every SimulatedEvent.type any of their triggers can match.
46
+ * Memoized on the workflows-array identity: LockFileCache returns the same
47
+ * LockFile (hence the same workflows array) on a cache hit, so buckets are
48
+ * built once per cached lockfile and GC'd with it.
49
+ */
50
+ function prepareEventBuckets(workflows) {
51
+ const cached = bucketMemo.get(workflows);
52
+ if (cached) return cached;
53
+ const buckets = /* @__PURE__ */ new Map();
54
+ const add = (eventType, w, seen) => {
55
+ if (seen.has(eventType)) return;
56
+ seen.add(eventType);
57
+ let arr = buckets.get(eventType);
58
+ if (!arr) {
59
+ arr = [];
60
+ buckets.set(eventType, arr);
61
+ }
62
+ arr.push(w);
63
+ };
64
+ for (const w of workflows) {
65
+ const seen = /* @__PURE__ */ new Set();
66
+ for (const trigger of w.triggers) {
67
+ if (trigger == null) continue;
68
+ if (trigger._type === WEBHOOK_TRIGGER_TYPE) {
69
+ for (const evt of trigger.events) add(evt, w, seen);
70
+ continue;
71
+ }
72
+ const eventTypes = TRIGGER_TYPE_TO_EVENT_TYPES[trigger._type];
73
+ if (eventTypes) for (const evt of eventTypes) add(evt, w, seen);
74
+ }
75
+ }
76
+ bucketMemo.set(workflows, buckets);
77
+ return buckets;
78
+ }
79
+ /**
80
+ * Match only the workflows subscribed to the incoming event type. Returns
81
+ * candidate decisions (a superset of matched); callers filter `.matched`.
82
+ * The candidate set is a superset of every workflow matchAllWorkflows would
83
+ * mark matched — a workflow matches only if some trigger's guard passes for
84
+ * event.type, which means that trigger indexed the workflow under event.type —
85
+ * so the matched result is identical.
86
+ */
87
+ function matchWorkflowsForEvent(workflows, event) {
88
+ return (prepareEventBuckets(workflows).get(event.type) ?? []).map((w) => matchWorkflowTriggers(w, event));
89
+ }
90
+ //#endregion
91
+ export { TRIGGER_TYPE_TO_EVENT_TYPES, matchWorkflowsForEvent, prepareEventBuckets };
92
+
93
+ //# sourceMappingURL=event-buckets.js.map
@@ -1,5 +1,5 @@
1
- import type { LockWorkflow, LockBranchPattern, SimulatedEvent } from './types.js';
2
- import { type WorkflowDecision } from './decision-trace.js';
1
+ import type { LockTrigger, LockWorkflow, LockBranchPattern, SimulatedEvent, ChangedFilesStatus } from './types.js';
2
+ import { type TraceEntry, type WorkflowDecision } from './decision-trace.js';
3
3
  /**
4
4
  * Match a branch pattern against a branch name.
5
5
  */
@@ -9,7 +9,7 @@ export declare function matchBranchPattern(pattern: LockBranchPattern, branch: s
9
9
  * Patterns prefixed with ! are exclusions. Remaining patterns are inclusions.
10
10
  * An all-negation array has implicit match-all semantics for non-excluded files.
11
11
  */
12
- export declare function matchPathPatterns(paths: readonly string[], changedFiles: string[]): boolean;
12
+ export declare function matchPathPatterns(paths: readonly string[], changedFiles: string[], status?: ChangedFilesStatus): boolean;
13
13
  /**
14
14
  * Match repo patterns against a source repository identifier.
15
15
  * Patterns with ! prefix in the pattern string are exclusions.
@@ -17,6 +17,10 @@ export declare function matchPathPatterns(paths: readonly string[], changedFiles
17
17
  * Empty array = no filtering (matches all repos).
18
18
  */
19
19
  export declare function matchRepoPatterns(repos: readonly LockBranchPattern[], sourceRepo: string): boolean;
20
+ /**
21
+ * Match a trigger against a simulated event.
22
+ */
23
+ export declare function matchTrigger(trigger: LockTrigger, event: SimulatedEvent, traces: TraceEntry[]): boolean;
20
24
  /**
21
25
  * Match all triggers for a workflow against an event.
22
26
  * Returns WorkflowDecision with full trace.