owenloop 0.4.1 → 0.5.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.
- package/CHANGELOG.md +71 -0
- package/README.md +182 -53
- package/bin/owenloop.mjs +50 -2
- package/dist/packages/work/src/agent/brief.d.ts +176 -0
- package/dist/packages/work/src/agent/brief.js +197 -0
- package/dist/packages/work/src/agent/loop.d.ts +141 -0
- package/dist/packages/work/src/agent/loop.js +669 -0
- package/dist/packages/work/src/agent/model-policy.d.ts +49 -0
- package/dist/packages/work/src/agent/model-policy.js +138 -0
- package/dist/packages/work/src/agent/workdir.d.ts +210 -0
- package/dist/packages/work/src/agent/workdir.js +319 -0
- package/dist/packages/work/src/bundle/cache.d.ts +92 -0
- package/dist/packages/work/src/bundle/cache.js +338 -0
- package/dist/packages/work/src/bundle/fetch.d.ts +87 -0
- package/dist/packages/work/src/bundle/fetch.js +345 -0
- package/dist/packages/work/src/bundle/types.d.ts +164 -0
- package/dist/packages/work/src/bundle/types.js +1 -0
- package/dist/packages/work/src/consumed-verifier.d.ts +45 -0
- package/dist/packages/work/src/consumed-verifier.js +205 -0
- package/dist/packages/work/src/credentials/owenloop.d.ts +11 -0
- package/dist/packages/work/src/credentials/owenloop.js +28 -0
- package/dist/packages/work/src/credentials/reader.d.ts +36 -0
- package/dist/packages/work/src/credentials/reader.js +32 -0
- package/dist/packages/work/src/credentials/resolve.d.ts +19 -0
- package/dist/packages/work/src/credentials/resolve.js +56 -0
- package/dist/packages/work/src/exec/instructions.d.ts +99 -0
- package/dist/packages/work/src/exec/instructions.js +323 -0
- package/dist/packages/work/src/exec/loop.d.ts +40 -0
- package/dist/packages/work/src/exec/loop.js +332 -0
- package/dist/packages/work/src/exec/payload.d.ts +29 -0
- package/dist/packages/work/src/exec/payload.js +54 -0
- package/dist/packages/work/src/exec/receipt.d.ts +41 -0
- package/dist/packages/work/src/exec/receipt.js +32 -0
- package/dist/packages/work/src/exec/runner.d.ts +71 -0
- package/dist/packages/work/src/exec/runner.js +256 -0
- package/dist/packages/work/src/harness/child-env.d.ts +100 -0
- package/dist/packages/work/src/harness/child-env.js +134 -0
- package/dist/packages/work/src/harness/claude.d.ts +140 -0
- package/dist/packages/work/src/harness/claude.js +837 -0
- package/dist/packages/work/src/harness/codex.d.ts +111 -0
- package/dist/packages/work/src/harness/codex.js +1024 -0
- package/dist/packages/work/src/harness/contract.d.ts +308 -0
- package/dist/packages/work/src/harness/contract.js +32 -0
- package/dist/packages/work/src/harness/fake.d.ts +59 -0
- package/dist/packages/work/src/harness/fake.js +91 -0
- package/dist/packages/work/src/harness/jsonrpc-stdio.d.ts +108 -0
- package/dist/packages/work/src/harness/jsonrpc-stdio.js +351 -0
- package/dist/packages/work/src/harness/permissions.d.ts +75 -0
- package/dist/packages/work/src/harness/permissions.js +182 -0
- package/dist/packages/work/src/harness/registry.d.ts +47 -0
- package/dist/packages/work/src/harness/registry.js +45 -0
- package/dist/packages/work/src/harness/session-store.d.ts +181 -0
- package/dist/packages/work/src/harness/session-store.js +523 -0
- package/dist/packages/work/src/harness/types.d.ts +29 -0
- package/dist/packages/work/src/harness/types.js +14 -0
- package/dist/packages/work/src/harnesses.d.ts +38 -0
- package/dist/packages/work/src/harnesses.js +38 -0
- package/dist/packages/work/src/hold/loop.d.ts +36 -0
- package/dist/packages/work/src/hold/loop.js +23 -0
- package/dist/packages/work/src/hold/mcp.d.ts +75 -0
- package/dist/packages/work/src/hold/mcp.js +264 -0
- package/dist/packages/work/src/hub/client.d.ts +23 -0
- package/dist/packages/work/src/hub/client.js +91 -0
- package/dist/packages/work/src/hub/types.d.ts +326 -0
- package/dist/packages/work/src/hub/types.js +26 -0
- package/dist/packages/work/src/lease/loop.d.ts +94 -0
- package/dist/packages/work/src/lease/loop.js +277 -0
- package/dist/packages/work/src/main.d.ts +1 -0
- package/dist/packages/work/src/main.js +48 -0
- package/dist/packages/work/src/mcp/server.d.ts +125 -0
- package/dist/packages/work/src/mcp/server.js +320 -0
- package/dist/packages/work/src/owenloop-bin.d.ts +1 -0
- package/dist/packages/work/src/owenloop-bin.js +18 -0
- package/dist/packages/work/src/roles/agent-run.d.ts +124 -0
- package/dist/packages/work/src/roles/agent-run.js +529 -0
- package/dist/packages/work/src/roles/exec.d.ts +48 -0
- package/dist/packages/work/src/roles/exec.js +228 -0
- package/dist/packages/work/src/roles/hold.d.ts +72 -0
- package/dist/packages/work/src/roles/hold.js +363 -0
- package/dist/packages/work/src/roles/join.d.ts +18 -0
- package/dist/packages/work/src/roles/join.js +204 -0
- package/dist/packages/work/src/roles/lint.d.ts +58 -0
- package/dist/packages/work/src/roles/lint.js +234 -0
- package/dist/packages/work/src/roles/prepare.d.ts +1 -0
- package/dist/packages/work/src/roles/prepare.js +249 -0
- package/dist/packages/work/src/roles/release.d.ts +48 -0
- package/dist/packages/work/src/roles/release.js +137 -0
- package/dist/packages/work/src/roles/sessions.d.ts +61 -0
- package/dist/packages/work/src/roles/sessions.js +180 -0
- package/dist/packages/work/src/roles/settings.d.ts +6 -0
- package/dist/packages/work/src/roles/settings.js +71 -0
- package/dist/packages/work/src/roles/shift.d.ts +13 -0
- package/dist/packages/work/src/roles/shift.js +250 -0
- package/dist/packages/work/src/roles/signals.d.ts +55 -0
- package/dist/packages/work/src/roles/signals.js +62 -0
- package/dist/packages/work/src/settings/provision.d.ts +21 -0
- package/dist/packages/work/src/settings/provision.js +47 -0
- package/dist/packages/work/src/settings/settings.d.ts +136 -0
- package/dist/packages/work/src/settings/settings.js +155 -0
- package/dist/packages/work/src/shift/client.d.ts +24 -0
- package/dist/packages/work/src/shift/client.js +124 -0
- package/dist/packages/work/src/shift/loop.d.ts +131 -0
- package/dist/packages/work/src/shift/loop.js +751 -0
- package/dist/packages/work/src/shift/protocol.d.ts +95 -0
- package/dist/packages/work/src/shift/protocol.js +24 -0
- package/dist/packages/work/src/shift/routing.d.ts +35 -0
- package/dist/packages/work/src/shift/routing.js +50 -0
- package/dist/packages/work/src/shift/runtime.d.ts +45 -0
- package/dist/packages/work/src/shift/runtime.js +337 -0
- package/dist/packages/work/src/shift/server.d.ts +23 -0
- package/dist/packages/work/src/shift/server.js +716 -0
- package/dist/packages/work/src/shift/spawn.d.ts +109 -0
- package/dist/packages/work/src/shift/spawn.js +158 -0
- package/dist/packages/work/src/shift/state.d.ts +79 -0
- package/dist/packages/work/src/shift/state.js +385 -0
- package/dist/packages/work/src/submit-proof.d.ts +36 -0
- package/dist/packages/work/src/submit-proof.js +93 -0
- package/dist/packages/work/src/usage.d.ts +6 -0
- package/dist/packages/work/src/usage.js +175 -0
- package/dist/src/add.d.ts +189 -0
- package/dist/src/add.js +300 -0
- package/dist/src/archive.d.ts +97 -0
- package/dist/src/archive.js +591 -0
- package/dist/src/bundle/index.d.ts +64 -0
- package/dist/src/bundle/index.js +508 -0
- package/dist/src/bundle/manifest.d.ts +50 -0
- package/dist/src/bundle/manifest.js +435 -0
- package/dist/src/bundle/runtime.d.ts +26 -0
- package/dist/src/bundle/runtime.js +64 -0
- package/dist/src/bundle/tar.d.ts +62 -0
- package/dist/src/bundle/tar.js +238 -0
- package/dist/src/bundle/types.d.ts +105 -0
- package/dist/src/bundle/types.js +21 -0
- package/dist/{cli.d.ts → src/cli.d.ts} +92 -7
- package/dist/src/cli.js +5968 -0
- package/dist/{credentials.d.ts → src/credentials.d.ts} +22 -15
- package/dist/{credentials.js → src/credentials.js} +35 -31
- package/dist/src/crypto/allowed-signers.d.ts +68 -0
- package/dist/src/crypto/allowed-signers.js +307 -0
- package/dist/src/crypto/canonical.d.ts +8 -0
- package/dist/src/crypto/canonical.js +92 -0
- package/dist/src/crypto/chain.d.ts +65 -0
- package/dist/src/crypto/chain.js +377 -0
- package/dist/src/crypto/dsse.d.ts +209 -0
- package/dist/src/crypto/dsse.js +282 -0
- package/dist/src/crypto/enrollment.d.ts +78 -0
- package/dist/src/crypto/enrollment.js +186 -0
- package/dist/src/crypto/index.d.ts +48 -0
- package/dist/src/crypto/index.js +44 -0
- package/dist/src/crypto/keys.d.ts +258 -0
- package/dist/src/crypto/keys.js +908 -0
- package/dist/src/crypto/org-root.d.ts +33 -0
- package/dist/src/crypto/org-root.js +78 -0
- package/dist/src/crypto/origin-rules.d.ts +56 -0
- package/dist/src/crypto/origin-rules.js +143 -0
- package/dist/src/crypto/policy-floor.d.ts +98 -0
- package/dist/src/crypto/policy-floor.js +353 -0
- package/dist/src/crypto/records.d.ts +316 -0
- package/dist/src/crypto/records.js +157 -0
- package/dist/src/crypto/scope.d.ts +49 -0
- package/dist/src/crypto/scope.js +83 -0
- package/dist/src/crypto/ssh.d.ts +171 -0
- package/dist/src/crypto/ssh.js +396 -0
- package/dist/src/crypto/submission.d.ts +33 -0
- package/dist/src/crypto/submission.js +47 -0
- package/dist/src/crypto/trust-roots.d.ts +29 -0
- package/dist/src/crypto/trust-roots.js +39 -0
- package/dist/src/crypto/verify-consumed.d.ts +67 -0
- package/dist/src/crypto/verify-consumed.js +259 -0
- package/dist/src/crypto/verify-origin.d.ts +50 -0
- package/dist/src/crypto/verify-origin.js +151 -0
- package/dist/src/crypto/verify-publication.d.ts +60 -0
- package/dist/src/crypto/verify-publication.js +150 -0
- package/dist/{defs.d.ts → src/defs.d.ts} +24 -1
- package/dist/{defs.js → src/defs.js} +181 -61
- package/dist/{engine.d.ts → src/engine.d.ts} +105 -9
- package/dist/{engine.js → src/engine.js} +251 -47
- package/dist/{factory.d.ts → src/factory.d.ts} +16 -0
- package/dist/{factory.js → src/factory.js} +16 -4
- package/dist/src/global-config.d.ts +59 -0
- package/dist/src/global-config.js +84 -0
- package/dist/{hub.d.ts → src/hub.d.ts} +280 -31
- package/dist/{hub.js → src/hub.js} +493 -52
- package/dist/src/index.d.ts +47 -0
- package/dist/src/index.js +41 -0
- package/dist/src/install.d.ts +538 -0
- package/dist/src/install.js +1981 -0
- package/dist/src/lock.d.ts +38 -0
- package/dist/src/lock.js +325 -0
- package/dist/src/mcp/serve.d.ts +109 -0
- package/dist/{mcp → src/mcp}/serve.js +335 -75
- package/dist/{mcp → src/mcp}/server.d.ts +6 -9
- package/dist/{mcp → src/mcp}/server.js +18 -10
- package/dist/{model.d.ts → src/model.d.ts} +15 -0
- package/dist/{model.js → src/model.js} +112 -2
- package/dist/src/order-resolver.d.ts +184 -0
- package/dist/src/order-resolver.js +252 -0
- package/dist/src/package-version.d.ts +10 -0
- package/dist/src/package-version.js +42 -0
- package/dist/{paths.d.ts → src/paths.d.ts} +14 -1
- package/dist/{paths.js → src/paths.js} +18 -0
- package/dist/src/schemas/enrollment-grant.v1.schema.json +90 -0
- package/dist/src/schemas/index.d.ts +1416 -0
- package/dist/src/schemas/index.js +31 -0
- package/dist/src/schemas/order.v1.schema.json +106 -0
- package/dist/src/schemas/origin.v1.schema.json +68 -0
- package/dist/src/schemas/policy-floor.v1.schema.json +29 -0
- package/dist/src/schemas/publication.v1.schema.json +31 -0
- package/dist/src/schemas/revocation.v1.schema.json +39 -0
- package/dist/src/schemas/submission.v1.schema.json +61 -0
- package/dist/src/store/def-source.d.ts +52 -0
- package/dist/src/store/def-source.js +335 -0
- package/dist/src/store/index-file.d.ts +69 -0
- package/dist/src/store/index-file.js +151 -0
- package/dist/src/store/index.d.ts +27 -0
- package/dist/src/store/index.js +22 -0
- package/dist/src/store/ingestor.d.ts +43 -0
- package/dist/src/store/ingestor.js +211 -0
- package/dist/src/store/install.d.ts +228 -0
- package/dist/src/store/install.js +555 -0
- package/dist/src/store/instruction-source.d.ts +49 -0
- package/dist/src/store/instruction-source.js +298 -0
- package/dist/src/store/origin-evidence.d.ts +21 -0
- package/dist/src/store/origin-evidence.js +66 -0
- package/dist/src/store/pre-commit-verifier.d.ts +68 -0
- package/dist/src/store/pre-commit-verifier.js +418 -0
- package/dist/src/store/resolve.d.ts +138 -0
- package/dist/src/store/resolve.js +363 -0
- package/dist/src/store/types.d.ts +288 -0
- package/dist/src/store/types.js +356 -0
- package/dist/{types.d.ts → src/types.d.ts} +58 -24
- package/dist/{untar.d.ts → src/untar.d.ts} +8 -23
- package/dist/src/untar.js +38 -0
- package/dist/{util.d.ts → src/util.d.ts} +3 -2
- package/dist/{util.js → src/util.js} +3 -2
- package/dist/{owenwork.d.ts → src/work-settings.d.ts} +22 -22
- package/dist/{owenwork.js → src/work-settings.js} +27 -27
- package/docs/agent-runner.md +86 -0
- package/docs/authoring.md +150 -59
- package/docs/bundles.md +250 -0
- package/docs/cli.md +1758 -163
- package/docs/crypto.md +816 -0
- package/docs/design.md +374 -52
- package/docs/embedding.md +135 -27
- package/docs/wire-contracts.md +380 -0
- package/examples/workflows/{command-worker.yaml → command-executor.yaml} +15 -15
- package/examples/workflows/compile-dev-playbook.yaml +338 -0
- package/examples/workflows/judges/gate-sharpness.md +39 -0
- package/examples/workflows/judges/security.md +34 -0
- package/package.json +22 -8
- package/plugins/claude-code/.claude-plugin/marketplace.json +14 -0
- package/plugins/claude-code/plugin/.claude-plugin/plugin.json +8 -0
- package/plugins/claude-code/plugin/.mcp.json +14 -0
- package/plugins/claude-code/plugin/hooks/hooks.json +26 -0
- package/plugins/claude-code/plugin/hooks/session-end.sh +40 -0
- package/plugins/claude-code/plugin/hooks/session-start.sh +52 -0
- package/plugins/claude-code/plugin/skills/author/SKILL.md +181 -0
- package/plugins/claude-code/plugin/skills/conduct/SKILL.md +106 -0
- package/plugins/claude-code/plugin/skills/shift/SKILL.md +105 -0
- package/plugins/codex/.agents/plugins/marketplace.json +21 -0
- package/plugins/codex/plugins/owenloop/.codex-plugin/plugin.json +7 -0
- package/plugins/codex/plugins/owenloop/.mcp.json +20 -0
- package/plugins/codex/plugins/owenloop/hooks/hooks.json +26 -0
- package/plugins/codex/plugins/owenloop/hooks/session-end.sh +40 -0
- package/plugins/codex/plugins/owenloop/hooks/session-start.sh +52 -0
- package/plugins/codex/plugins/owenloop/skills/author/SKILL.md +181 -0
- package/plugins/codex/plugins/owenloop/skills/conduct/SKILL.md +106 -0
- package/plugins/codex/plugins/owenloop/skills/shift/SKILL.md +105 -0
- package/dist/add.d.ts +0 -384
- package/dist/add.js +0 -834
- package/dist/cli.js +0 -3270
- package/dist/index.d.ts +0 -32
- package/dist/index.js +0 -23
- package/dist/lock.d.ts +0 -80
- package/dist/lock.js +0 -217
- package/dist/mcp/serve.d.ts +0 -84
- package/dist/untar.js +0 -164
- /package/dist/{schema.d.ts → src/schema.d.ts} +0 -0
- /package/dist/{schema.js → src/schema.js} +0 -0
- /package/dist/{store.d.ts → src/store.d.ts} +0 -0
- /package/dist/{store.js → src/store.js} +0 -0
- /package/dist/{types.js → src/types.js} +0 -0
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The content-addressed workflow store's value types, constructors, and named
|
|
3
|
+
* error classes.
|
|
4
|
+
*
|
|
5
|
+
* TWO DISTINCT "STORES" live in this package — do not conflate them:
|
|
6
|
+
* - `src/store.ts` — the SQLite RUNTIME store (`Store`/`openStore`): engine
|
|
7
|
+
* execution state (workflows, runs, artifacts).
|
|
8
|
+
* - `src/store/` (this directory) — the content-addressed WORKFLOW store:
|
|
9
|
+
* immutable, digest-addressed workflow-definition objects plus a
|
|
10
|
+
* coordinate→digest index, installed from `.wnlp` bundles. This module is
|
|
11
|
+
* its type surface.
|
|
12
|
+
*
|
|
13
|
+
* On-disk layout, at EACH of two levels (project = the resolved defs dir;
|
|
14
|
+
* global = `~/.owenloop/workflows`):
|
|
15
|
+
*
|
|
16
|
+
* <root>/index.json coordinate → digest (+ pinned) index
|
|
17
|
+
* <root>/objects/sha256/<64-hex>/ one immutable object per digest
|
|
18
|
+
*
|
|
19
|
+
* Identity rules: a digest is a lowercase 64-char SHA-256 hex value owned by
|
|
20
|
+
* the bundle format module — this module only VALIDATES the
|
|
21
|
+
* shape (rejecting uppercase/noncanonical input rather than normalizing
|
|
22
|
+
* attacker-controlled data); it never recomputes bundle digests itself. A
|
|
23
|
+
* coordinate is `namespace/name@version` (the FULL coordinate — this module
|
|
24
|
+
* never derives one from a filename or URL). Object paths derive ONLY from
|
|
25
|
+
* validated digests; a coordinate or source URL is never joined into a
|
|
26
|
+
* filesystem path.
|
|
27
|
+
*/
|
|
28
|
+
import { createRequire } from 'node:module';
|
|
29
|
+
import { join } from 'node:path';
|
|
30
|
+
import { isCanonicalSemver } from "../bundle/runtime.js";
|
|
31
|
+
const semver = createRequire(import.meta.url)('semver');
|
|
32
|
+
/** A lowercase 64-char SHA-256 hex digest — the store's only object identity. */
|
|
33
|
+
export const DIGEST_RE = /^[0-9a-f]{64}$/;
|
|
34
|
+
/**
|
|
35
|
+
* One coordinate component (`namespace`, `name`, or `version`). The grammar is
|
|
36
|
+
* deliberately broad: a component is a non-empty string free of control
|
|
37
|
+
* characters and path-significant characters. This module deliberately does
|
|
38
|
+
* NOT impose a semver grammar on `version` — the bundle format module owns
|
|
39
|
+
* version content; this module only keeps components filesystem-safe and
|
|
40
|
+
* unambiguous.
|
|
41
|
+
*/
|
|
42
|
+
// eslint-disable-next-line no-control-regex -- the control-character exclusion IS the point: components must be filesystem-safe, so the range is deliberate.
|
|
43
|
+
export const COORDINATE_COMPONENT_RE = /^[^\x00-\x1f\x7f\\/:%#?]+$/;
|
|
44
|
+
/**
|
|
45
|
+
* A named store error: every fail-closed refusal the store produces carries a
|
|
46
|
+
* stable machine-readable `code` alongside the human message, so callers
|
|
47
|
+
* (CLI dispatch, resolution callers, tests) can branch on `instanceof` +
|
|
48
|
+
* `code` instead of matching message text. `path`/`entry`/`coordinate` are
|
|
49
|
+
* present only in messages, never trusted for control flow.
|
|
50
|
+
*/
|
|
51
|
+
export class WorkflowStoreError extends Error {
|
|
52
|
+
code;
|
|
53
|
+
constructor(code, message) {
|
|
54
|
+
super(message);
|
|
55
|
+
this.name = 'WorkflowStoreError';
|
|
56
|
+
this.code = code;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/** The index file failed to parse or failed fail-closed validation. */
|
|
60
|
+
export class StoreIndexError extends WorkflowStoreError {
|
|
61
|
+
constructor(message) {
|
|
62
|
+
super('index-invalid', message);
|
|
63
|
+
this.name = 'StoreIndexError';
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/** A digest string failed validation (wrong length/case/charset). */
|
|
67
|
+
export class StoreDigestError extends WorkflowStoreError {
|
|
68
|
+
constructor(message) {
|
|
69
|
+
super('digest-invalid', message);
|
|
70
|
+
this.name = 'StoreDigestError';
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/** A coordinate string failed construction/parsing validation. */
|
|
74
|
+
export class StoreCoordinateError extends WorkflowStoreError {
|
|
75
|
+
constructor(message) {
|
|
76
|
+
super('coordinate-invalid', message);
|
|
77
|
+
this.name = 'StoreCoordinateError';
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* @deprecated Coordinate resolution is project-first and no longer throws this
|
|
82
|
+
* error when project and global indexes name different digests. The export and
|
|
83
|
+
* constructor remain for compatibility with older callers that import or
|
|
84
|
+
* instantiate the error class.
|
|
85
|
+
*/
|
|
86
|
+
export class StoreAmbiguityError extends WorkflowStoreError {
|
|
87
|
+
coordinate;
|
|
88
|
+
projectDigest;
|
|
89
|
+
globalDigest;
|
|
90
|
+
constructor(coordinate, projectDigest, globalDigest) {
|
|
91
|
+
super('coordinate-ambiguous', `coordinate '${coordinate}' resolves to different digests in the project store ` +
|
|
92
|
+
`(${projectDigest}) and the global store (${globalDigest}) — ` +
|
|
93
|
+
`resolve the ambiguity explicitly instead of guessing`);
|
|
94
|
+
this.name = 'StoreAmbiguityError';
|
|
95
|
+
this.coordinate = coordinate;
|
|
96
|
+
this.projectDigest = projectDigest;
|
|
97
|
+
this.globalDigest = globalDigest;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/** The coordinate was not found in any consulted level's index. */
|
|
101
|
+
export class StoreNotFoundError extends WorkflowStoreError {
|
|
102
|
+
coordinate;
|
|
103
|
+
constructor(coordinate) {
|
|
104
|
+
super('coordinate-not-found', `coordinate '${coordinate}' is not in the workflow store index`);
|
|
105
|
+
this.name = 'StoreNotFoundError';
|
|
106
|
+
this.coordinate = coordinate;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/** An index entry names a digest whose object is missing or failed verification. */
|
|
110
|
+
export class StoreIntegrityError extends WorkflowStoreError {
|
|
111
|
+
digest;
|
|
112
|
+
constructor(code, digest, detail) {
|
|
113
|
+
super(code, `object ${digest}: ${detail}`);
|
|
114
|
+
this.name = 'StoreIntegrityError';
|
|
115
|
+
this.digest = digest;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/** Installing a coordinate the index already records at a DIFFERENT digest. */
|
|
119
|
+
export class StoreConflictError extends WorkflowStoreError {
|
|
120
|
+
coordinate;
|
|
121
|
+
existingDigest;
|
|
122
|
+
constructor(coordinate, existingDigest) {
|
|
123
|
+
super('coordinate-conflict', `coordinate '${coordinate}' is already recorded at digest ${existingDigest} — ` +
|
|
124
|
+
`an existing coordinate is never silently retargeted to a different digest ` +
|
|
125
|
+
`(use an explicit pin/update)`);
|
|
126
|
+
this.name = 'StoreConflictError';
|
|
127
|
+
this.coordinate = coordinate;
|
|
128
|
+
this.existingDigest = existingDigest;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/** The required bundle ingestion adapter was not supplied. Fail-closed. */
|
|
132
|
+
export class BundleIngestorUnavailableError extends WorkflowStoreError {
|
|
133
|
+
constructor() {
|
|
134
|
+
super('bundle-ingestor-unavailable', 'bundle ingestion is unavailable: no BundleIngestor adapter is bound — ' +
|
|
135
|
+
'nothing was staged or committed');
|
|
136
|
+
this.name = 'BundleIngestorUnavailableError';
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/** The required pre-commit signature/policy verifier was not supplied. Fail-closed. */
|
|
140
|
+
export class PreCommitVerifierUnavailableError extends WorkflowStoreError {
|
|
141
|
+
constructor() {
|
|
142
|
+
super('pre-commit-verifier-unavailable', 'pre-commit verification is unavailable: no PreCommitVerifier adapter is bound — ' +
|
|
143
|
+
'nothing was staged or committed');
|
|
144
|
+
this.name = 'PreCommitVerifierUnavailableError';
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/** A publication signature verdict was refused by the configured definition policy. */
|
|
148
|
+
export class StoreDefinitionVerificationError extends WorkflowStoreError {
|
|
149
|
+
verdict;
|
|
150
|
+
policy;
|
|
151
|
+
coordinate;
|
|
152
|
+
constructor(verdict, policy, coordinate, reason) {
|
|
153
|
+
super('definition-verification-refused', `definition '${coordinate}' was refused by defPolicy=${policy}: ${verdict} — ${reason}`);
|
|
154
|
+
this.name = 'StoreDefinitionVerificationError';
|
|
155
|
+
this.verdict = verdict;
|
|
156
|
+
this.policy = policy;
|
|
157
|
+
this.coordinate = coordinate;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/** A provenance rule refused a workflow definition before execution or install. */
|
|
161
|
+
export class StoreOriginPolicyError extends WorkflowStoreError {
|
|
162
|
+
coordinate;
|
|
163
|
+
namespace;
|
|
164
|
+
rule;
|
|
165
|
+
verdict;
|
|
166
|
+
constructor(coordinate, namespace, rule, verdict, detail) {
|
|
167
|
+
super('origin-policy-refused', `definition '${coordinate}' was refused by originRules=${rule} for namespace '${namespace}': ${verdict} — ${detail}`);
|
|
168
|
+
this.name = 'StoreOriginPolicyError';
|
|
169
|
+
this.coordinate = coordinate;
|
|
170
|
+
this.namespace = namespace;
|
|
171
|
+
this.rule = rule;
|
|
172
|
+
this.verdict = verdict;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
/** A store root, objects dir, index file, or state path failed a type/symlink guard. */
|
|
176
|
+
export class StorePathError extends WorkflowStoreError {
|
|
177
|
+
constructor(message) {
|
|
178
|
+
super('path-refused', message);
|
|
179
|
+
this.name = 'StorePathError';
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
/** Validate a raw string as a {@link DefDigest}; throw {@link StoreDigestError} otherwise. */
|
|
183
|
+
export function defDigest(raw) {
|
|
184
|
+
if (!DIGEST_RE.test(raw)) {
|
|
185
|
+
throw new StoreDigestError(`invalid def digest ${JSON.stringify(raw)} — expected a lowercase 64-char sha256 hex value`);
|
|
186
|
+
}
|
|
187
|
+
return raw;
|
|
188
|
+
}
|
|
189
|
+
/** True when `raw` is a well-formed digest (lowercase 64-hex). */
|
|
190
|
+
export function isDefDigest(raw) {
|
|
191
|
+
return DIGEST_RE.test(raw);
|
|
192
|
+
}
|
|
193
|
+
function validateCoordinateComponent(kind, value) {
|
|
194
|
+
if (value === '') {
|
|
195
|
+
throw new StoreCoordinateError(`invalid coordinate: ${kind} is empty`);
|
|
196
|
+
}
|
|
197
|
+
if (!COORDINATE_COMPONENT_RE.test(value)) {
|
|
198
|
+
throw new StoreCoordinateError(`invalid coordinate: ${kind} ${JSON.stringify(value)} contains a control or path-significant character`);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Construct a validated {@link WorkflowCoordinate} from its three parts.
|
|
203
|
+
* Each part must be non-empty and free of control/path-significant characters;
|
|
204
|
+
* a violation throws {@link StoreCoordinateError}. The full text
|
|
205
|
+
* `namespace/name@version` is returned branded — the ONLY string shape the
|
|
206
|
+
* store accepts as a coordinate key.
|
|
207
|
+
*/
|
|
208
|
+
export function workflowCoordinate(parts) {
|
|
209
|
+
validateCoordinateComponent('namespace', parts.namespace);
|
|
210
|
+
validateCoordinateComponent('name', parts.name);
|
|
211
|
+
validateCoordinateComponent('version', parts.version);
|
|
212
|
+
return `${parts.namespace}/${parts.name}@${parts.version}`;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Parse a full `namespace/name@version` coordinate text into its parts. The
|
|
216
|
+
* version is split at the FINAL `@` and the name at the FIRST `/` before it
|
|
217
|
+
* (a namespace/name itself never contains a slash); every component is
|
|
218
|
+
* validated exactly as {@link workflowCoordinate} validates it. A malformed
|
|
219
|
+
* shape throws {@link StoreCoordinateError}. Never used on untrusted input
|
|
220
|
+
* that then bypasses validation — the returned parts are only as safe as this
|
|
221
|
+
* function's checks.
|
|
222
|
+
*/
|
|
223
|
+
export function parseWorkflowCoordinate(text) {
|
|
224
|
+
const at = text.lastIndexOf('@');
|
|
225
|
+
if (at <= 0 || at === text.length - 1) {
|
|
226
|
+
throw new StoreCoordinateError(`invalid coordinate ${JSON.stringify(text)} — expected 'namespace/name@version'`);
|
|
227
|
+
}
|
|
228
|
+
const namespaceAndName = text.slice(0, at);
|
|
229
|
+
const version = text.slice(at + 1);
|
|
230
|
+
const slash = namespaceAndName.indexOf('/');
|
|
231
|
+
if (slash <= 0 || slash === namespaceAndName.length - 1) {
|
|
232
|
+
throw new StoreCoordinateError(`invalid coordinate ${JSON.stringify(text)} — expected 'namespace/name@version'`);
|
|
233
|
+
}
|
|
234
|
+
const namespace = namespaceAndName.slice(0, slash);
|
|
235
|
+
const name = namespaceAndName.slice(slash + 1);
|
|
236
|
+
if (name.includes('/')) {
|
|
237
|
+
throw new StoreCoordinateError(`invalid coordinate ${JSON.stringify(text)} — expected exactly one '/' before the version`);
|
|
238
|
+
}
|
|
239
|
+
const coordinate = workflowCoordinate({ namespace, name, version });
|
|
240
|
+
// Defensive round-trip: the reconstructed full text must equal the input —
|
|
241
|
+
// a coordinate is only ever stored/compared in its exact input form.
|
|
242
|
+
if (coordinate !== text) {
|
|
243
|
+
throw new StoreCoordinateError(`invalid coordinate ${JSON.stringify(text)} — non-canonical form`);
|
|
244
|
+
}
|
|
245
|
+
return { namespace, name, version };
|
|
246
|
+
}
|
|
247
|
+
// ---- deterministic ordering and version selection -----------------------------
|
|
248
|
+
/**
|
|
249
|
+
* A total, LOCALE-INDEPENDENT order on store text (coordinates, digests,
|
|
250
|
+
* qualified names). `String.prototype.localeCompare` is deliberately avoided
|
|
251
|
+
* throughout the store: without an explicit locale its result depends on the
|
|
252
|
+
* host's ICU data, so two machines walking the same index could disagree on
|
|
253
|
+
* order.
|
|
254
|
+
*
|
|
255
|
+
* This is UTF-16 code-unit order (JS `<` on strings), which differs from true
|
|
256
|
+
* codepoint order for astral characters. That difference does not matter here:
|
|
257
|
+
* the requirement is a total order identical on every host, not one that
|
|
258
|
+
* matches any particular alphabet.
|
|
259
|
+
*
|
|
260
|
+
* This orders ENUMERATION only. It never decides which version of a package is
|
|
261
|
+
* the current one — {@link selectLatestVersion} owns that and is the store's
|
|
262
|
+
* only version-selection rule.
|
|
263
|
+
*/
|
|
264
|
+
export function compareStoreText(a, b) {
|
|
265
|
+
if (a < b)
|
|
266
|
+
return -1;
|
|
267
|
+
if (a > b)
|
|
268
|
+
return 1;
|
|
269
|
+
return 0;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Rank two same-level candidates, BEST FIRST.
|
|
273
|
+
*
|
|
274
|
+
* 1. A canonical SemVer version outranks a non-SemVer one. A version the store
|
|
275
|
+
* cannot order never displaces one it can.
|
|
276
|
+
* 2. Between two canonical SemVer versions, higher SemVer precedence wins
|
|
277
|
+
* (SemVer §11 — so `0.1.10` beats `0.1.2`, and `1.0.0` beats `1.0.0-rc.1`).
|
|
278
|
+
* 3. Otherwise the two are indistinguishable by precedence: either they differ
|
|
279
|
+
* only in build metadata, or neither is SemVer at all. Fall through to raw
|
|
280
|
+
* text, then to the digest, purely so the answer is STABLE. Neither of those
|
|
281
|
+
* last two steps claims to say which version is newer; they exist so the
|
|
282
|
+
* result never depends on index insertion, filesystem, or install order.
|
|
283
|
+
*/
|
|
284
|
+
function compareVersionCandidates(a, b) {
|
|
285
|
+
const aOrderable = isCanonicalSemver(a.version);
|
|
286
|
+
const bOrderable = isCanonicalSemver(b.version);
|
|
287
|
+
if (aOrderable !== bOrderable)
|
|
288
|
+
return aOrderable ? -1 : 1;
|
|
289
|
+
if (aOrderable && bOrderable) {
|
|
290
|
+
const byPrecedence = semver.compare(b.version, a.version);
|
|
291
|
+
if (byPrecedence !== 0)
|
|
292
|
+
return byPrecedence;
|
|
293
|
+
}
|
|
294
|
+
const byText = compareStoreText(b.version, a.version);
|
|
295
|
+
if (byText !== 0)
|
|
296
|
+
return byText;
|
|
297
|
+
return compareStoreText(a.digest, b.digest);
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Choose the ONE candidate that holds an unqualified `package/workflow` name.
|
|
301
|
+
*
|
|
302
|
+
* Two rules apply in order, and neither consults arrival order:
|
|
303
|
+
*
|
|
304
|
+
* 1. LEVEL FIRST. If any candidate is named by the project index, only project
|
|
305
|
+
* candidates compete. This mirrors `resolveWorkflowCoordinate`, where the
|
|
306
|
+
* project index is the deterministic override: a project install of
|
|
307
|
+
* `pkg@0.1.0` beats a global install of `pkg@0.9.9`, because the project
|
|
308
|
+
* store is how an operator pins a workspace to a specific definition.
|
|
309
|
+
* 2. VERSION SECOND, by {@link compareVersionCandidates}, among the candidates
|
|
310
|
+
* at that one level.
|
|
311
|
+
*
|
|
312
|
+
* When the surviving group holds more than one candidate and none carries a
|
|
313
|
+
* canonical SemVer version, the result is `unorderable` and the unqualified name
|
|
314
|
+
* goes unregistered. A SINGLE non-SemVer candidate still wins its name — there
|
|
315
|
+
* is nothing to order, so refusing it would break `pkg@nightly` installs for no
|
|
316
|
+
* determinism gain.
|
|
317
|
+
*/
|
|
318
|
+
export function selectLatestVersion(candidates) {
|
|
319
|
+
if (candidates.length === 0)
|
|
320
|
+
return { kind: 'unorderable', shadowed: [], competing: [] };
|
|
321
|
+
const hasProject = candidates.some((candidate) => candidate.level === 'project');
|
|
322
|
+
const competing = hasProject
|
|
323
|
+
? candidates.filter((candidate) => candidate.level === 'project')
|
|
324
|
+
: [...candidates];
|
|
325
|
+
const outranked = hasProject
|
|
326
|
+
? candidates.filter((candidate) => candidate.level !== 'project')
|
|
327
|
+
: [];
|
|
328
|
+
const ranked = [...competing].sort(compareVersionCandidates);
|
|
329
|
+
const best = ranked[0];
|
|
330
|
+
// Rule 1 sorts every orderable candidate ahead of every unorderable one, so a
|
|
331
|
+
// non-SemVer `best` proves the whole competing group is unorderable.
|
|
332
|
+
if (!isCanonicalSemver(best.version) && ranked.length > 1) {
|
|
333
|
+
return { kind: 'unorderable', shadowed: [...ranked, ...outranked], competing: ranked };
|
|
334
|
+
}
|
|
335
|
+
return { kind: 'selected', winner: best, shadowed: [...ranked.slice(1), ...outranked] };
|
|
336
|
+
}
|
|
337
|
+
/** The index filename at a store root. */
|
|
338
|
+
export const WORKFLOW_STORE_INDEX_FILENAME = 'index.json';
|
|
339
|
+
/** The objects subtree at a store root: `objects/sha256/<digest>/`. */
|
|
340
|
+
export const WORKFLOW_OBJECTS_DIRNAME = 'objects';
|
|
341
|
+
/** The digest algorithm directory under `objects/` (sha256 is the only one). */
|
|
342
|
+
export const WORKFLOW_OBJECTS_ALGO = 'sha256';
|
|
343
|
+
/**
|
|
344
|
+
* Derive the object directory for a validated digest under `root`. Digests are
|
|
345
|
+
* validated BEFORE this joins anything: a coordinate or URL must never reach a
|
|
346
|
+
* filesystem path. The digest is a single path segment by construction (64 hex
|
|
347
|
+
* chars), so the join cannot escape `root`.
|
|
348
|
+
*/
|
|
349
|
+
export function objectDirForDigest(root, digest) {
|
|
350
|
+
// Re-assert the shape at the derivation site (belt-and-braces; the brand is
|
|
351
|
+
// compile-time only).
|
|
352
|
+
if (!DIGEST_RE.test(digest)) {
|
|
353
|
+
throw new StoreDigestError(`refusing to derive an object path from ${JSON.stringify(digest)}`);
|
|
354
|
+
}
|
|
355
|
+
return join(root, WORKFLOW_OBJECTS_DIRNAME, WORKFLOW_OBJECTS_ALGO, digest);
|
|
356
|
+
}
|
|
@@ -123,42 +123,70 @@ export interface TaskData {
|
|
|
123
123
|
alarmAt?: number;
|
|
124
124
|
}
|
|
125
125
|
/** A run node — audit/budget trail, and the holder of a claim's fingerprint. */
|
|
126
|
-
/**
|
|
126
|
+
/**
|
|
127
|
+
* A reference-mode unit of work emitted by a tick (WP-B1). The order is a
|
|
128
|
+
* REFERENCE packet: `defDigest` identifies the pinned definition snapshot
|
|
129
|
+
* that emitted it, and the authored static instruction bytes (prompt,
|
|
130
|
+
* command, acceptance) ride the resolver boundary instead — see
|
|
131
|
+
* `OrderResolver` in order-resolver.ts. An order NEVER carries authored
|
|
132
|
+
* prompt or command text, nor `owes[].acceptance` (the artifact lifecycle
|
|
133
|
+
* state is dynamic engine state, not channel-1 instructions). It does carry
|
|
134
|
+
* the routing/reference fields, the dynamic consumed input values, and the
|
|
135
|
+
* dynamic rejection feedback. One shape serves both local (`owenloop tick`)
|
|
136
|
+
* and embedded/library callers — there is no verify-mode or legacy branch.
|
|
137
|
+
*/
|
|
127
138
|
export interface Order {
|
|
128
139
|
run: string;
|
|
129
140
|
workflow: string;
|
|
130
141
|
step: string;
|
|
131
142
|
key: string;
|
|
132
143
|
index?: number;
|
|
144
|
+
/** The digest of the definition snapshot this order was emitted against.
|
|
145
|
+
* Resolves static instructions through the `(defDigest, step, key)`
|
|
146
|
+
* boundary; an unknown digest is a named refusal (UnknownDefDigestError). */
|
|
147
|
+
defDigest: string;
|
|
133
148
|
inputs: string[];
|
|
134
149
|
outputs: string[];
|
|
135
150
|
workdir?: string;
|
|
136
151
|
model?: string;
|
|
137
|
-
/** Declares which kind of
|
|
152
|
+
/** Declares which kind of worker this order is for. Absent = 'agent'
|
|
138
153
|
* (today's behavior). Opaque to the engine; carried through verbatim from
|
|
139
|
-
* the step
|
|
154
|
+
* the authored step's `executor:` field (the YAML grammar is unchanged),
|
|
155
|
+
* same pass-through contract as `model`/`x`. */
|
|
140
156
|
worker?: string;
|
|
141
|
-
/** The
|
|
142
|
-
|
|
143
|
-
command?: string;
|
|
157
|
+
/** The artifact stem this order's judge step is verdicting, when present. */
|
|
158
|
+
judge?: string;
|
|
144
159
|
/** Opaque config object for a non-agent/non-command worker type (or
|
|
145
|
-
* alongside
|
|
160
|
+
* alongside a command). Carried through untouched, contents never read. */
|
|
146
161
|
spec?: Record<string, unknown>;
|
|
147
162
|
/** §27.3: the step's opaque `x:` extension map, carried through untouched
|
|
148
163
|
* (same pass-through contract as `model`). The engine never reads it —
|
|
149
164
|
* it exists for the external runner/tooling consuming this order. */
|
|
150
165
|
x?: Record<string, unknown>;
|
|
151
|
-
prompt: string;
|
|
152
166
|
/** captured handles of the green inputs this run builds on */
|
|
153
167
|
consumes: Record<string, unknown>;
|
|
168
|
+
/**
|
|
169
|
+
* The versions of the consumed inputs captured at claim time. Drivers cover
|
|
170
|
+
* this map in a submission signature instead of recomputing it from values.
|
|
171
|
+
*/
|
|
172
|
+
consumedFingerprint?: Fingerprint;
|
|
154
173
|
/** the owed outputs and their accumulated reason threads (the feedback channel) */
|
|
155
174
|
owes: Array<{
|
|
156
175
|
path: string;
|
|
157
|
-
|
|
176
|
+
/** Current committed artifact version captured by the engine at claim time. */
|
|
177
|
+
version?: number;
|
|
158
178
|
judgmentRejects: number;
|
|
159
179
|
schemaRejects: number;
|
|
160
180
|
reasons: ReasonEntry[];
|
|
181
|
+
/** Opaque proof/signature placeholder for future WP-A4-signed reason
|
|
182
|
+
* threads. Data-only today: no cryptographic code attaches or verifies
|
|
183
|
+
* it — the slot exists so signed dynamic data can land without changing
|
|
184
|
+
* the reference-mode wire shape. */
|
|
185
|
+
proof?: string;
|
|
161
186
|
}>;
|
|
187
|
+
/** Opaque proof/signature placeholder for future WP-A4-signed dynamic
|
|
188
|
+
* consume values. Data-only today — same contract as `owes[].proof`. */
|
|
189
|
+
consumesProof?: string;
|
|
162
190
|
/** The trigger that woke this firing (§21). Absent = 'inputsGreen'. */
|
|
163
191
|
cause?: FiringTrigger;
|
|
164
192
|
}
|
|
@@ -256,13 +284,13 @@ export interface ProducePattern {
|
|
|
256
284
|
cadence?: string;
|
|
257
285
|
maxRunsPerDay?: number;
|
|
258
286
|
/** Declares which kind of executor this judge's synthesized order is for.
|
|
259
|
-
* Same opaque-passthrough contract as StepDef.
|
|
287
|
+
* Same opaque-passthrough contract as StepDef.executor — default 'agent'
|
|
260
288
|
* when omitted. */
|
|
261
|
-
|
|
262
|
-
/** Required when
|
|
289
|
+
executor?: string;
|
|
290
|
+
/** Required when executor is 'command'; the command string for that executor
|
|
263
291
|
* to run. Opaque to the engine — never parsed, never shelled out. */
|
|
264
292
|
command?: string;
|
|
265
|
-
/** Optional opaque config object for a non-agent/non-command
|
|
293
|
+
/** Optional opaque config object for a non-agent/non-command executor type
|
|
266
294
|
* (or additionally alongside `command`). Shape-checked as a plain map
|
|
267
295
|
* only (mirrors `x:`'s asExtension contract) — contents never read. */
|
|
268
296
|
spec?: Record<string, unknown>;
|
|
@@ -325,16 +353,22 @@ export interface StepDef {
|
|
|
325
353
|
* unchanged). Opaque to the engine beyond the shape rules validateDef
|
|
326
354
|
* enforces; carried through verbatim on the Order, same contract as
|
|
327
355
|
* `model`. */
|
|
328
|
-
|
|
329
|
-
/** Required when
|
|
356
|
+
executor?: string;
|
|
357
|
+
/** Required when executor is 'command'; the command string for that executor
|
|
330
358
|
* to run. Opaque to the engine — never parsed, never shelled out. */
|
|
331
359
|
command?: string;
|
|
332
|
-
/** Optional opaque config object for a non-agent/non-command
|
|
360
|
+
/** Optional opaque config object for a non-agent/non-command executor type
|
|
333
361
|
* (or additionally alongside `command`). Shape-checked as a plain map
|
|
334
362
|
* only (mirrors `x:`'s asExtension contract) — contents never read. */
|
|
335
363
|
spec?: Record<string, unknown>;
|
|
336
364
|
/** opaque location hint passed through on the order; no default — absent unless the def sets it */
|
|
337
365
|
workdir?: string;
|
|
366
|
+
/**
|
|
367
|
+
* Resolve the order's workdir from `<consumedStem>.<dotted.path>` in a consumed
|
|
368
|
+
* artifact value. Mutually exclusive with workdir; the stem must be a plain
|
|
369
|
+
* consume so the value passes the engine's consume-side verification gate.
|
|
370
|
+
*/
|
|
371
|
+
workdirFrom?: string;
|
|
338
372
|
/** the step's output is a destructive completion (e.g. a merge): green is terminal (§15.2) */
|
|
339
373
|
terminal?: boolean;
|
|
340
374
|
/** Step-level effect contract (§6.5). Only consulted for non-terminal greens whose inputs move. */
|
|
@@ -347,11 +381,11 @@ export interface StepDef {
|
|
|
347
381
|
idleAfterMs?: number;
|
|
348
382
|
/** Per-step reap TTL override in milliseconds. Falls back to the engine's DEFAULT_REAP_TTL_MS. */
|
|
349
383
|
reapTtlMs?: number;
|
|
350
|
-
/** A2: opaque routing
|
|
351
|
-
* caller passing a
|
|
384
|
+
/** A2: opaque routing capabilities for peer-orchestrator claim filtering. A tick
|
|
385
|
+
* caller passing a capability filter only claims steps whose capabilities intersect it;
|
|
352
386
|
* absent (or empty, normalized to absent at parse) = claimable by any caller.
|
|
353
|
-
* Distinct from `
|
|
354
|
-
|
|
387
|
+
* Distinct from `executor`/`executors` (executor-kind), which this never touches. */
|
|
388
|
+
capabilities?: string[];
|
|
355
389
|
/** A3 (REL-8): per-step OPT-IN max total lease lifetime override in
|
|
356
390
|
* milliseconds — the cap on `claimedAt + maxLease` past which renewals can no
|
|
357
391
|
* longer keep a lease fresh. Overrides the engine `maxLeaseMs`; when both are
|
|
@@ -399,10 +433,10 @@ export interface WorkflowDef {
|
|
|
399
433
|
/** §27.3: opaque workflow-level extension map (`x:`). Validated as a plain
|
|
400
434
|
* map at load time, never interpreted by the engine. */
|
|
401
435
|
x?: Record<string, unknown>;
|
|
402
|
-
/** Optional allow-list of
|
|
403
|
-
* on any step/judge whose `
|
|
404
|
-
* Absent = any
|
|
405
|
-
|
|
436
|
+
/** Optional allow-list of executor values; when present, validateDef errors
|
|
437
|
+
* on any step/judge whose `executor` is not in this list (typo guard).
|
|
438
|
+
* Absent = any executor string accepted. */
|
|
439
|
+
executors?: string[];
|
|
406
440
|
}
|
|
407
441
|
export interface InputDef {
|
|
408
442
|
name: string;
|
|
@@ -9,30 +9,15 @@
|
|
|
9
9
|
* it would be silently skipped (unrepresentable, not corrupt).
|
|
10
10
|
*
|
|
11
11
|
* This is intentionally narrow: just enough tar to unpack a GitHub tarball,
|
|
12
|
-
* not a general-purpose tar library.
|
|
12
|
+
* not a general-purpose tar library. The parsing, resource limits, and path
|
|
13
|
+
* policy live in `src/archive.ts` (the ONE shared archive boundary, also
|
|
14
|
+
* used by `src/bundle/` and `src/add.ts`); this module keeps the historical
|
|
15
|
+
* `extractTarGz` API and compatible reading behavior.
|
|
13
16
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
*
|
|
19
|
-
* - `maxCompressedBytes` (256 MiB): the buffered tarball download itself.
|
|
20
|
-
* - `maxExpandedBytes` (1 GiB): total inflated size — kills gzip bombs at
|
|
21
|
-
* inflate time. GitHub's own recommended repo size sits comfortably below.
|
|
22
|
-
* - `maxFileCount` (50k): number of regular files kept.
|
|
23
|
-
* - `maxFileBytes` (100 MiB): GitHub blocks pushing files larger than this,
|
|
24
|
-
* and LFS content is never in the tarball, so no legit entry exceeds it.
|
|
25
|
-
* - `maxPathLength` (1024): guards against absurdly long entry paths (pax or
|
|
26
|
-
* USTAR prefix-composed) before they are ever used as a filesystem path.
|
|
27
|
-
*/
|
|
28
|
-
export interface TarLimits {
|
|
29
|
-
maxCompressedBytes: number;
|
|
30
|
-
maxExpandedBytes: number;
|
|
31
|
-
maxFileCount: number;
|
|
32
|
-
maxFileBytes: number;
|
|
33
|
-
maxPathLength: number;
|
|
34
|
-
}
|
|
35
|
-
export declare const DEFAULT_TAR_LIMITS: TarLimits;
|
|
17
|
+
import { DEFAULT_TAR_LIMITS } from './archive.ts';
|
|
18
|
+
import type { TarLimits } from './archive.ts';
|
|
19
|
+
export type { TarLimits };
|
|
20
|
+
export { DEFAULT_TAR_LIMITS };
|
|
36
21
|
/**
|
|
37
22
|
* Extract a gzipped tar archive into a flat map of in-archive path → file
|
|
38
23
|
* bytes. Directory entries are dropped; only regular files are kept. Pax
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal, dependency-free `.tar.gz` reader for GitHub codeload tarballs.
|
|
3
|
+
*
|
|
4
|
+
* GitHub's tarball endpoint (`/repos/:owner/:repo/tarball/:ref`) emits a
|
|
5
|
+
* gzipped USTAR/pax stream: short ASCII paths as plain USTAR headers, and
|
|
6
|
+
* paths over 100 chars as a pax extended header (typeflag `'x'`) followed by
|
|
7
|
+
* the real entry. GitHub does NOT emit GNU longname (`'L'`) entries — this
|
|
8
|
+
* reader does not implement that typeflag; a repo path that happens to need
|
|
9
|
+
* it would be silently skipped (unrepresentable, not corrupt).
|
|
10
|
+
*
|
|
11
|
+
* This is intentionally narrow: just enough tar to unpack a GitHub tarball,
|
|
12
|
+
* not a general-purpose tar library. The parsing, resource limits, and path
|
|
13
|
+
* policy live in `src/archive.ts` (the ONE shared archive boundary, also
|
|
14
|
+
* used by `src/bundle/` and `src/add.ts`); this module keeps the historical
|
|
15
|
+
* `extractTarGz` API and compatible reading behavior.
|
|
16
|
+
*/
|
|
17
|
+
import { DEFAULT_TAR_LIMITS, inflateArchive, parseTar } from "./archive.js";
|
|
18
|
+
export { DEFAULT_TAR_LIMITS };
|
|
19
|
+
/**
|
|
20
|
+
* Extract a gzipped tar archive into a flat map of in-archive path → file
|
|
21
|
+
* bytes. Directory entries are dropped; only regular files are kept. Pax
|
|
22
|
+
* extended headers (typeflag 'x') are honored for long paths; pax global
|
|
23
|
+
* headers (typeflag 'g') are skipped. Any other typeflag is skipped (its
|
|
24
|
+
* data block(s) consumed and discarded so the stream stays in sync).
|
|
25
|
+
*
|
|
26
|
+
* Returns keys as the raw in-archive paths, including the leading
|
|
27
|
+
* `<owner>-<repo>-<sha>/` root-dir component GitHub tarballs always have —
|
|
28
|
+
* callers strip that themselves.
|
|
29
|
+
*/
|
|
30
|
+
export function extractTarGz(bytes, limits = {}) {
|
|
31
|
+
const lim = { ...DEFAULT_TAR_LIMITS, ...limits };
|
|
32
|
+
const tar = inflateArchive(bytes, lim);
|
|
33
|
+
const entries = parseTar(tar, lim, { policy: 'compatible' });
|
|
34
|
+
const out = new Map();
|
|
35
|
+
for (const e of entries)
|
|
36
|
+
out.set(e.path, e.data);
|
|
37
|
+
return out;
|
|
38
|
+
}
|
|
@@ -14,8 +14,9 @@
|
|
|
14
14
|
* (consumed by both entry-point catches in `cli.ts`). It defaults to `1`, so
|
|
15
15
|
* every existing `new CliError(msg)` — and `RateLimitError extends CliError`,
|
|
16
16
|
* which inherits this constructor — keeps its byte-for-byte exit-1 behavior. The
|
|
17
|
-
* non-default codes today are
|
|
18
|
-
*
|
|
17
|
+
* non-default codes today are exit 2 (hub unresolvable) and exit 3 (human
|
|
18
|
+
* credential absent/irrecoverable), used by `agent new`, `binding
|
|
19
|
+
* new|rm|list`, and `crew`'s five subcommands.
|
|
19
20
|
*/
|
|
20
21
|
export declare class CliError extends Error {
|
|
21
22
|
readonly exitCode: number;
|
|
@@ -16,8 +16,9 @@ import { lstatSync, mkdirSync } from 'node:fs';
|
|
|
16
16
|
* (consumed by both entry-point catches in `cli.ts`). It defaults to `1`, so
|
|
17
17
|
* every existing `new CliError(msg)` — and `RateLimitError extends CliError`,
|
|
18
18
|
* which inherits this constructor — keeps its byte-for-byte exit-1 behavior. The
|
|
19
|
-
* non-default codes today are
|
|
20
|
-
*
|
|
19
|
+
* non-default codes today are exit 2 (hub unresolvable) and exit 3 (human
|
|
20
|
+
* credential absent/irrecoverable), used by `agent new`, `binding
|
|
21
|
+
* new|rm|list`, and `crew`'s five subcommands.
|
|
21
22
|
*/
|
|
22
23
|
export class CliError extends Error {
|
|
23
24
|
exitCode;
|