owenloop 0.5.7 → 0.5.9
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 +41 -0
- package/README.md +7 -8
- package/dist/packages/work/src/agent/capability-model.d.ts +64 -82
- package/dist/packages/work/src/agent/capability-model.js +94 -91
- package/dist/packages/work/src/agent/loop.d.ts +55 -26
- package/dist/packages/work/src/agent/loop.js +144 -50
- package/dist/packages/work/src/bundle/types.d.ts +3 -3
- package/dist/packages/work/src/consumed-verifier.js +6 -17
- package/dist/packages/work/src/exec/loop.d.ts +1 -1
- package/dist/packages/work/src/exec/loop.js +206 -35
- package/dist/packages/work/src/exec/receipt.d.ts +7 -7
- package/dist/packages/work/src/exec/receipt.js +6 -6
- package/dist/packages/work/src/harness/child-env.js +4 -5
- package/dist/packages/work/src/harness/claude.js +100 -0
- package/dist/packages/work/src/harness/codex.js +3 -4
- package/dist/packages/work/src/harness/session-store.d.ts +63 -3
- package/dist/packages/work/src/harness/session-store.js +104 -9
- package/dist/packages/work/src/hub/client.d.ts +19 -4
- package/dist/packages/work/src/hub/client.js +7 -3
- package/dist/packages/work/src/hub/types.d.ts +87 -3
- package/dist/packages/work/src/main.js +1 -0
- package/dist/packages/work/src/roles/agent-run.js +46 -43
- package/dist/packages/work/src/roles/exec.js +2 -0
- package/dist/packages/work/src/roles/sessions.d.ts +3 -2
- package/dist/packages/work/src/roles/sessions.js +9 -2
- package/dist/packages/work/src/roles/settings.js +3 -1
- package/dist/packages/work/src/roles/shift.js +14 -2
- package/dist/packages/work/src/roles/util.d.ts +1 -0
- package/dist/packages/work/src/roles/util.js +10 -0
- package/dist/packages/work/src/settings/hub-roster-cache.d.ts +68 -0
- package/dist/packages/work/src/settings/hub-roster-cache.js +370 -0
- package/dist/packages/work/src/settings/roster.d.ts +105 -0
- package/dist/packages/work/src/settings/roster.js +439 -0
- package/dist/packages/work/src/settings/serving.d.ts +17 -0
- package/dist/packages/work/src/settings/serving.js +79 -0
- package/dist/packages/work/src/settings/settings.d.ts +25 -24
- package/dist/packages/work/src/settings/settings.js +29 -33
- package/dist/packages/work/src/shift/loop.d.ts +108 -5
- package/dist/packages/work/src/shift/loop.js +299 -51
- package/dist/packages/work/src/shift/protocol.d.ts +7 -5
- package/dist/packages/work/src/shift/runtime.d.ts +15 -0
- package/dist/packages/work/src/shift/runtime.js +95 -13
- package/dist/packages/work/src/shift/server.js +2 -0
- package/dist/packages/work/src/shift/spawn.d.ts +18 -50
- package/dist/packages/work/src/shift/spawn.js +30 -65
- package/dist/packages/work/src/shift/state.d.ts +29 -2
- package/dist/packages/work/src/shift/state.js +45 -15
- package/dist/packages/work/src/usage.d.ts +1 -1
- package/dist/packages/work/src/usage.js +10 -5
- package/dist/packages/work/src/util/modifier-init.d.ts +7 -0
- package/dist/packages/work/src/util/modifier-init.js +73 -0
- package/dist/src/bundle/tar.d.ts +9 -4
- package/dist/src/bundle/tar.js +9 -4
- package/dist/src/capabilities.d.ts +50 -0
- package/dist/src/capabilities.js +38 -0
- package/dist/src/cli.d.ts +15 -1
- package/dist/src/cli.js +1099 -32
- package/dist/src/config-dir.d.ts +14 -19
- package/dist/src/config-dir.js +16 -24
- package/dist/src/credentials.d.ts +1 -1
- package/dist/src/credentials.js +1 -1
- package/dist/src/crypto/index.d.ts +1 -1
- package/dist/src/crypto/index.js +1 -1
- package/dist/src/crypto/org-root.d.ts +30 -12
- package/dist/src/crypto/org-root.js +162 -14
- package/dist/src/crypto/records.d.ts +3 -0
- package/dist/src/crypto/records.js +8 -0
- package/dist/src/crypto/trust-roots.d.ts +2 -2
- package/dist/src/crypto/trust-roots.js +2 -2
- package/dist/src/defs.d.ts +6 -1
- package/dist/src/defs.js +203 -8
- package/dist/src/engine.d.ts +55 -6
- package/dist/src/engine.js +172 -22
- package/dist/src/global-config.d.ts +4 -7
- package/dist/src/global-config.js +4 -7
- package/dist/src/hub.d.ts +207 -5
- package/dist/src/hub.js +263 -3
- package/dist/src/index.d.ts +5 -5
- package/dist/src/index.js +3 -3
- package/dist/src/mcp/serve.d.ts +22 -0
- package/dist/src/mcp/serve.js +88 -8
- package/dist/src/model.d.ts +2 -0
- package/dist/src/model.js +32 -25
- package/dist/src/order-resolver.d.ts +1 -0
- package/dist/src/order-resolver.js +8 -1
- package/dist/src/schemas/index.d.ts +19 -0
- package/dist/src/schemas/order.v1.schema.json +13 -2
- package/dist/src/store/pre-commit-verifier.js +1 -1
- package/dist/src/store.d.ts +5 -0
- package/dist/src/store.js +43 -8
- package/dist/src/types.d.ts +64 -7
- package/dist/src/work-settings.d.ts +2 -4
- package/dist/src/work-settings.js +2 -4
- package/docs/agent-runner.md +2 -2
- package/docs/authoring.md +90 -2
- package/docs/bundles.md +29 -3
- package/docs/cli.md +456 -120
- package/docs/crypto.md +32 -16
- package/docs/design.md +70 -1
- package/docs/routing.md +762 -0
- package/docs/shift-logs.md +37 -10
- package/docs/wire-contracts.md +50 -7
- package/examples/workflows/delivery.yaml +31 -14
- package/examples/workflows/ship.yaml +10 -2
- package/package.json +1 -1
- package/plugins/claude-code/plugin/.claude-plugin/plugin.json +1 -1
- package/plugins/claude-code/plugin/.mcp.json +1 -1
- package/plugins/claude-code/plugin/skills/author/SKILL.md +1 -2
- package/plugins/codex/plugins/owenloop/.codex-plugin/plugin.json +1 -1
- package/plugins/codex/plugins/owenloop/.mcp.json +1 -1
- package/plugins/codex/plugins/owenloop/skills/author/SKILL.md +1 -2
package/dist/src/config-dir.d.ts
CHANGED
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The ONE resolver for owenloop's own user-level config directory — the
|
|
3
3
|
* directory that directly holds `settings.json`, `credentials.json`,
|
|
4
|
-
* `allowed_signers`, `org-root.pub`, `
|
|
4
|
+
* `allowed_signers`, `org-root.pub`, `grants/`, and `revocations/`.
|
|
5
5
|
*
|
|
6
6
|
* WHY THIS MODULE EXISTS. Until now four call sites each re-derived the same
|
|
7
|
-
* ladder
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* also read, and `owenloop shift start` spreads its whole environment into
|
|
13
|
-
* every worker it dispatches (`shift/spawn.ts`), which in turn passes it to
|
|
14
|
-
* every command step's child process (`exec/` sets exactly three variables of
|
|
15
|
-
* its own on top). So an operator running two shifts with different
|
|
16
|
-
* `capabilityModels` had to set `XDG_CONFIG_HOME` per shift, and that silently
|
|
17
|
-
* relocated the config of every other tool the workflow's scripts shell out to.
|
|
7
|
+
* ladder, which made it too easy for each subsystem to resolve a different
|
|
8
|
+
* directory. Owenloop now owns exactly one default: `$HOME/.owenloop`.
|
|
9
|
+
* Operators who need isolation can set the explicit, owenloop-specific
|
|
10
|
+
* `OWENLOOP_CONFIG_DIR`, without changing the configuration roots of unrelated
|
|
11
|
+
* tools that a workflow may invoke.
|
|
18
12
|
*
|
|
19
13
|
* MEASURED, not theorized. On run `wf_8b2abe6b` the delivery line's `merge-gate`
|
|
20
14
|
* and `merger` steps both failed inside their `gh` probes, because `gh` looked
|
|
@@ -27,18 +21,19 @@
|
|
|
27
21
|
*
|
|
28
22
|
* THE FIX IS AN OWENLOOP-SPECIFIC VARIABLE. `OWENLOOP_CONFIG_DIR` names the
|
|
29
23
|
* owenloop config directory ITSELF — no `owenloop` path segment is appended to
|
|
30
|
-
* it — so
|
|
24
|
+
* it — so tests and throwaway experiments can scope owenloop's config while leaving
|
|
31
25
|
* `XDG_CONFIG_HOME` alone for everything else:
|
|
32
26
|
*
|
|
33
|
-
* OWENLOOP_CONFIG_DIR
|
|
34
|
-
* owenloop shift start utility …
|
|
27
|
+
* OWENLOOP_CONFIG_DIR=/tmp/owenloop-test owenloop work settings
|
|
35
28
|
*
|
|
36
29
|
* PRECEDENCE, highest first:
|
|
37
30
|
* 1. `OWENLOOP_CONFIG_DIR` → used verbatim
|
|
38
|
-
* 2. `
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
31
|
+
* 2. `HOME` → `<home>/.owenloop`
|
|
32
|
+
* Blank or whitespace-only values are treated as unset at every rung.
|
|
33
|
+
*
|
|
34
|
+
* `OWENLOOP_CONFIG_DIR` is no longer an operator-facing knob. It survives
|
|
35
|
+
* only for test and throwaway isolation; normal operation uses the HOME-rooted
|
|
36
|
+
* directory above.
|
|
42
37
|
*
|
|
43
38
|
* ABSOLUTE PATHS ONLY. A relative `OWENLOOP_CONFIG_DIR` would resolve against
|
|
44
39
|
* whatever the current working directory happens to be, and a worker's cwd
|
package/dist/src/config-dir.js
CHANGED
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The ONE resolver for owenloop's own user-level config directory — the
|
|
3
3
|
* directory that directly holds `settings.json`, `credentials.json`,
|
|
4
|
-
* `allowed_signers`, `org-root.pub`, `
|
|
4
|
+
* `allowed_signers`, `org-root.pub`, `grants/`, and `revocations/`.
|
|
5
5
|
*
|
|
6
6
|
* WHY THIS MODULE EXISTS. Until now four call sites each re-derived the same
|
|
7
|
-
* ladder
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* also read, and `owenloop shift start` spreads its whole environment into
|
|
13
|
-
* every worker it dispatches (`shift/spawn.ts`), which in turn passes it to
|
|
14
|
-
* every command step's child process (`exec/` sets exactly three variables of
|
|
15
|
-
* its own on top). So an operator running two shifts with different
|
|
16
|
-
* `capabilityModels` had to set `XDG_CONFIG_HOME` per shift, and that silently
|
|
17
|
-
* relocated the config of every other tool the workflow's scripts shell out to.
|
|
7
|
+
* ladder, which made it too easy for each subsystem to resolve a different
|
|
8
|
+
* directory. Owenloop now owns exactly one default: `$HOME/.owenloop`.
|
|
9
|
+
* Operators who need isolation can set the explicit, owenloop-specific
|
|
10
|
+
* `OWENLOOP_CONFIG_DIR`, without changing the configuration roots of unrelated
|
|
11
|
+
* tools that a workflow may invoke.
|
|
18
12
|
*
|
|
19
13
|
* MEASURED, not theorized. On run `wf_8b2abe6b` the delivery line's `merge-gate`
|
|
20
14
|
* and `merger` steps both failed inside their `gh` probes, because `gh` looked
|
|
@@ -27,18 +21,19 @@
|
|
|
27
21
|
*
|
|
28
22
|
* THE FIX IS AN OWENLOOP-SPECIFIC VARIABLE. `OWENLOOP_CONFIG_DIR` names the
|
|
29
23
|
* owenloop config directory ITSELF — no `owenloop` path segment is appended to
|
|
30
|
-
* it — so
|
|
24
|
+
* it — so tests and throwaway experiments can scope owenloop's config while leaving
|
|
31
25
|
* `XDG_CONFIG_HOME` alone for everything else:
|
|
32
26
|
*
|
|
33
|
-
* OWENLOOP_CONFIG_DIR
|
|
34
|
-
* owenloop shift start utility …
|
|
27
|
+
* OWENLOOP_CONFIG_DIR=/tmp/owenloop-test owenloop work settings
|
|
35
28
|
*
|
|
36
29
|
* PRECEDENCE, highest first:
|
|
37
30
|
* 1. `OWENLOOP_CONFIG_DIR` → used verbatim
|
|
38
|
-
* 2. `
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
31
|
+
* 2. `HOME` → `<home>/.owenloop`
|
|
32
|
+
* Blank or whitespace-only values are treated as unset at every rung.
|
|
33
|
+
*
|
|
34
|
+
* `OWENLOOP_CONFIG_DIR` is no longer an operator-facing knob. It survives
|
|
35
|
+
* only for test and throwaway isolation; normal operation uses the HOME-rooted
|
|
36
|
+
* directory above.
|
|
42
37
|
*
|
|
43
38
|
* ABSOLUTE PATHS ONLY. A relative `OWENLOOP_CONFIG_DIR` would resolve against
|
|
44
39
|
* whatever the current working directory happens to be, and a worker's cwd
|
|
@@ -73,13 +68,10 @@ export function owenloopConfigDir(env) {
|
|
|
73
68
|
}
|
|
74
69
|
return explicit;
|
|
75
70
|
}
|
|
76
|
-
const xdg = present(env.XDG_CONFIG_HOME);
|
|
77
|
-
if (xdg !== undefined)
|
|
78
|
-
return join(xdg, 'owenloop');
|
|
79
71
|
const home = present(env.HOME);
|
|
80
72
|
if (home !== undefined)
|
|
81
|
-
return join(home, '.
|
|
82
|
-
throw new Error('cannot locate a config directory: set OWENLOOP_CONFIG_DIR
|
|
73
|
+
return join(home, '.owenloop');
|
|
74
|
+
throw new Error('cannot locate a config directory: set OWENLOOP_CONFIG_DIR or HOME');
|
|
83
75
|
}
|
|
84
76
|
/** A file inside owenloop's config directory. */
|
|
85
77
|
export function owenloopConfigFile(env, ...segments) {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*
|
|
11
11
|
* **Concurrency safety (the reason this module exists):** the refresh-and-persist
|
|
12
12
|
* critical section is serialized by a lockfile next to the store
|
|
13
|
-
* (`~/.
|
|
13
|
+
* (`~/.owenloop/credentials.lock`, via `src/lock.ts`). Multiple long-lived
|
|
14
14
|
* processes sharing one slot (the `mcp` server case) would otherwise race a
|
|
15
15
|
* refresh — both read the old refresh token, both rotate it server-side, and the
|
|
16
16
|
* loser persists a now-dead token, causing a silent logout an hour later. The
|
package/dist/src/credentials.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*
|
|
11
11
|
* **Concurrency safety (the reason this module exists):** the refresh-and-persist
|
|
12
12
|
* critical section is serialized by a lockfile next to the store
|
|
13
|
-
* (`~/.
|
|
13
|
+
* (`~/.owenloop/credentials.lock`, via `src/lock.ts`). Multiple long-lived
|
|
14
14
|
* processes sharing one slot (the `mcp` server case) would otherwise race a
|
|
15
15
|
* refresh — both read the old refresh token, both rotate it server-side, and the
|
|
16
16
|
* loser persists a now-dead token, causing a silent logout an hour later. The
|
|
@@ -39,7 +39,7 @@ export { validateEnrollmentChain, validateProducer, revocationTemporalConsistenc
|
|
|
39
39
|
export type { ChainInput, ChainOptions, ChainVerdict } from './chain.ts';
|
|
40
40
|
export { attenuate, axisPermits, delegationPermits, ORG_ROOT_SCOPE, scopePermits, } from './scope.ts';
|
|
41
41
|
export type { ScopeAxis } from './scope.ts';
|
|
42
|
-
export {
|
|
42
|
+
export { loadGrants, loadRevocations, orgRootPrivateKeyPath, orgRootPublicKeyPath, resolveOrgRoot, revocationsDir, grantsDir, StrandedLegacyGrantsError, } from './org-root.ts';
|
|
43
43
|
export type { OrgRootAbsent, OrgRootPresent, OrgRootResolution } from './org-root.ts';
|
|
44
44
|
export { canonicalValueBytes, valueDigestHex } from './canonical.ts';
|
|
45
45
|
export { buildSubmissionRecord, signSubmission } from './submission.ts';
|
package/dist/src/crypto/index.js
CHANGED
|
@@ -36,7 +36,7 @@ export { DEFAULT_MACHINE_SCOPE, buildEnrollmentGrant, verifyRosterEntry, } from
|
|
|
36
36
|
// ---- enrollment chain ----
|
|
37
37
|
export { validateEnrollmentChain, validateProducer, revocationTemporalConsistency, } from "./chain.js";
|
|
38
38
|
export { attenuate, axisPermits, delegationPermits, ORG_ROOT_SCOPE, scopePermits, } from "./scope.js";
|
|
39
|
-
export {
|
|
39
|
+
export { loadGrants, loadRevocations, orgRootPrivateKeyPath, orgRootPublicKeyPath, resolveOrgRoot, revocationsDir, grantsDir, StrandedLegacyGrantsError, } from "./org-root.js";
|
|
40
40
|
// ---- WP-D2 signed submission records ----
|
|
41
41
|
export { canonicalValueBytes, valueDigestHex } from "./canonical.js";
|
|
42
42
|
export { buildSubmissionRecord, signSubmission } from "./submission.js";
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Local filesystem paths and loaders for an organization's enrollment anchor.
|
|
3
3
|
*
|
|
4
|
-
* The module derives every path from an injected environment
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* hub, or expose
|
|
4
|
+
* The module derives every path from an injected environment: an absolute
|
|
5
|
+
* OWENLOOP_CONFIG_DIR wins, otherwise paths live below $HOME/.owenloop;
|
|
6
|
+
* XDG_CONFIG_HOME is ignored. The loader only returns raw envelope bytes;
|
|
7
|
+
* chain.ts remains a pure verifier and does not know this layout. This module
|
|
8
|
+
* deliberately does not transport registrations, contact a hub, or expose
|
|
9
|
+
* private key bytes.
|
|
9
10
|
*/
|
|
10
11
|
export interface OrgRootPresent {
|
|
11
12
|
kind: 'present';
|
|
@@ -17,17 +18,34 @@ export interface OrgRootAbsent {
|
|
|
17
18
|
path: string;
|
|
18
19
|
}
|
|
19
20
|
export type OrgRootResolution = OrgRootPresent | OrgRootAbsent;
|
|
20
|
-
/** `<config>/
|
|
21
|
+
/** `<config>/org-root.pub`, the public local trust anchor. */
|
|
21
22
|
export declare function orgRootPublicKeyPath(env: Record<string, string | undefined>): string;
|
|
22
|
-
/** `<config>/
|
|
23
|
+
/** `<config>/org-root`, the private anchor path. */
|
|
23
24
|
export declare function orgRootPrivateKeyPath(env: Record<string, string | undefined>): string;
|
|
24
|
-
/** `<config>/
|
|
25
|
-
export declare function
|
|
26
|
-
|
|
25
|
+
/** `<config>/grants`, containing enrollment-grant envelopes. */
|
|
26
|
+
export declare function grantsDir(env: Record<string, string | undefined>): string;
|
|
27
|
+
interface GrantsDirectoryProblem {
|
|
28
|
+
path: string;
|
|
29
|
+
reason: string;
|
|
30
|
+
}
|
|
31
|
+
/** Thrown when legacy grants are stranded or cannot be safely inspected. */
|
|
32
|
+
export declare class StrandedLegacyGrantsError extends Error {
|
|
33
|
+
readonly name = "StrandedLegacyGrantsError";
|
|
34
|
+
readonly grantsPath: string;
|
|
35
|
+
readonly legacyPath: string;
|
|
36
|
+
readonly legacyCount: number;
|
|
37
|
+
readonly sourcePath: string | undefined;
|
|
38
|
+
readonly sourceReason: string | undefined;
|
|
39
|
+
constructor(grantsPath: string, legacyPath: string, legacyCount: number, sourceProblem?: GrantsDirectoryProblem | undefined, destinationIsAbsent?: boolean);
|
|
40
|
+
}
|
|
41
|
+
/** Refuse when legacy grants are stranded or cannot be safely inspected. */
|
|
42
|
+
export declare function assertNoStrandedLegacyGrants(env: Record<string, string | undefined>): void;
|
|
43
|
+
/** `<config>/revocations`, containing revocation envelopes. */
|
|
27
44
|
export declare function revocationsDir(env: Record<string, string | undefined>): string;
|
|
28
45
|
/** Resolve the public anchor without treating absence as a local-store error. */
|
|
29
46
|
export declare function resolveOrgRoot(env: Record<string, string | undefined>): OrgRootResolution;
|
|
30
|
-
/** Load sorted `.grant.dsse` bytes from the injected
|
|
31
|
-
export declare function
|
|
47
|
+
/** Load sorted `.grant.dsse` bytes from the injected grants directory. */
|
|
48
|
+
export declare function loadGrants(env: Record<string, string | undefined>): Uint8Array[];
|
|
32
49
|
/** Load sorted `.revocation.dsse` bytes from the injected revocation directory. */
|
|
33
50
|
export declare function loadRevocations(env: Record<string, string | undefined>): Uint8Array[];
|
|
51
|
+
export {};
|
|
@@ -1,33 +1,180 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Local filesystem paths and loaders for an organization's enrollment anchor.
|
|
3
3
|
*
|
|
4
|
-
* The module derives every path from an injected environment
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* hub, or expose
|
|
4
|
+
* The module derives every path from an injected environment: an absolute
|
|
5
|
+
* OWENLOOP_CONFIG_DIR wins, otherwise paths live below $HOME/.owenloop;
|
|
6
|
+
* XDG_CONFIG_HOME is ignored. The loader only returns raw envelope bytes;
|
|
7
|
+
* chain.ts remains a pure verifier and does not know this layout. This module
|
|
8
|
+
* deliberately does not transport registrations, contact a hub, or expose
|
|
9
|
+
* private key bytes.
|
|
9
10
|
*/
|
|
10
11
|
import { lstatSync, readdirSync, readFileSync } from 'node:fs';
|
|
11
12
|
import { dirname, join } from 'node:path';
|
|
12
13
|
import { allowedSignersPath } from "./trust-roots.js";
|
|
13
14
|
function orgRootDir(env) {
|
|
14
15
|
// allowedSignersPath is the established injected-env resolver. Its dirname
|
|
15
|
-
// is exactly <config
|
|
16
|
+
// is exactly <config>.
|
|
16
17
|
return dirname(allowedSignersPath(env));
|
|
17
18
|
}
|
|
18
|
-
/** `<config>/
|
|
19
|
+
/** `<config>/org-root.pub`, the public local trust anchor. */
|
|
19
20
|
export function orgRootPublicKeyPath(env) {
|
|
20
21
|
return join(orgRootDir(env), 'org-root.pub');
|
|
21
22
|
}
|
|
22
|
-
/** `<config>/
|
|
23
|
+
/** `<config>/org-root`, the private anchor path. */
|
|
23
24
|
export function orgRootPrivateKeyPath(env) {
|
|
24
25
|
return join(orgRootDir(env), 'org-root');
|
|
25
26
|
}
|
|
26
|
-
/** `<config>/
|
|
27
|
-
export function
|
|
27
|
+
/** `<config>/grants`, containing enrollment-grant envelopes. */
|
|
28
|
+
export function grantsDir(env) {
|
|
29
|
+
return join(orgRootDir(env), 'grants');
|
|
30
|
+
}
|
|
31
|
+
/** The pre-rename grants directory. Inspected only to refuse; never read. */
|
|
32
|
+
function legacyGrantsDir(env) {
|
|
28
33
|
return join(orgRootDir(env), 'roster');
|
|
29
34
|
}
|
|
30
|
-
/**
|
|
35
|
+
/** Count entries named `*.grant.dsse` without making the new path a loader. */
|
|
36
|
+
function countGrantFiles(dir) {
|
|
37
|
+
try {
|
|
38
|
+
return readdirSync(dir).filter((name) => name.endsWith('.grant.dsse')).length;
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return 0;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function inspectionError(path, action, error) {
|
|
45
|
+
return {
|
|
46
|
+
path,
|
|
47
|
+
reason: `${action}: ${error instanceof Error ? error.message : String(error)}`,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/** Encode one arbitrary path as a POSIX shell argument. */
|
|
51
|
+
function quotePosixShellArgument(value) {
|
|
52
|
+
return `'${value.replaceAll("'", "'\\''")}'`;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Inspect the legacy source without reading envelopes. A migration command is
|
|
56
|
+
* safe only when its source has the regular-file structure the old loader
|
|
57
|
+
* accepted; otherwise an operator must repair it by hand.
|
|
58
|
+
*/
|
|
59
|
+
function inspectLegacyGrantsSource(path) {
|
|
60
|
+
let stat;
|
|
61
|
+
try {
|
|
62
|
+
stat = lstatSync(path, { throwIfNoEntry: false });
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
return { grantCount: 0, problem: inspectionError(path, 'cannot inspect legacy grants source', error) };
|
|
66
|
+
}
|
|
67
|
+
if (stat === undefined)
|
|
68
|
+
return { grantCount: 0, problem: undefined };
|
|
69
|
+
if (stat.isSymbolicLink()) {
|
|
70
|
+
return { grantCount: 0, problem: { path, reason: 'legacy grants source is a symlink' } };
|
|
71
|
+
}
|
|
72
|
+
if (!stat.isDirectory()) {
|
|
73
|
+
return { grantCount: 0, problem: { path, reason: 'legacy grants source is not a directory' } };
|
|
74
|
+
}
|
|
75
|
+
let entries;
|
|
76
|
+
try {
|
|
77
|
+
entries = readdirSync(path);
|
|
78
|
+
}
|
|
79
|
+
catch (error) {
|
|
80
|
+
return { grantCount: 0, problem: inspectionError(path, 'cannot inspect legacy grants source', error) };
|
|
81
|
+
}
|
|
82
|
+
let grantCount = 0;
|
|
83
|
+
for (const name of entries) {
|
|
84
|
+
const entryPath = join(path, name);
|
|
85
|
+
let entry;
|
|
86
|
+
try {
|
|
87
|
+
entry = lstatSync(entryPath);
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
return { grantCount: 0, problem: inspectionError(entryPath, 'cannot inspect legacy grants source entry', error) };
|
|
91
|
+
}
|
|
92
|
+
if (entry.isSymbolicLink()) {
|
|
93
|
+
return { grantCount: 0, problem: { path: entryPath, reason: 'legacy grants source entry is a symlink' } };
|
|
94
|
+
}
|
|
95
|
+
if (!entry.isFile()) {
|
|
96
|
+
return { grantCount: 0, problem: { path: entryPath, reason: 'legacy grants source entry is not a regular file' } };
|
|
97
|
+
}
|
|
98
|
+
if (name.endsWith('.grant.dsse'))
|
|
99
|
+
grantCount += 1;
|
|
100
|
+
}
|
|
101
|
+
return { grantCount, problem: undefined };
|
|
102
|
+
}
|
|
103
|
+
/** Use lstat so a live or dangling symlink is never mistaken for absence. */
|
|
104
|
+
function grantsPathIsAbsent(path) {
|
|
105
|
+
let stat;
|
|
106
|
+
try {
|
|
107
|
+
stat = lstatSync(path, { throwIfNoEntry: false });
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
// The existing-path command begins with rmdir, which safely refuses when
|
|
111
|
+
// this probe cannot establish absence.
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
return stat === undefined;
|
|
115
|
+
}
|
|
116
|
+
function sourceManualRepairMessage(grantsPath, legacyPath, sourceProblem) {
|
|
117
|
+
return `enrollment grants cannot be safely inspected in the pre-rename directory '${legacyPath}': ` +
|
|
118
|
+
`${sourceProblem.reason}: '${sourceProblem.path}'. '${grantsPath}' holds no *.grant.dsse files. ` +
|
|
119
|
+
'Repair that path by hand before migrating; owenloop will not move your cryptographic material for you.';
|
|
120
|
+
}
|
|
121
|
+
function migrationMessage(grantsPath, legacyPath, legacyCount, quotedGrantsPath, quotedLegacyPath, destinationIsAbsent) {
|
|
122
|
+
// Renaming the whole inspected source directory preserves every accepted
|
|
123
|
+
// filename by construction, including all dot-prefixed names. If a grants
|
|
124
|
+
// path already exists, rmdir permits the rename only into an empty real
|
|
125
|
+
// directory, preventing mv from nesting roster beneath grants.
|
|
126
|
+
const command = destinationIsAbsent
|
|
127
|
+
? `mv ${quotedLegacyPath} ${quotedGrantsPath}`
|
|
128
|
+
: `rmdir ${quotedGrantsPath} && mv ${quotedLegacyPath} ${quotedGrantsPath}`;
|
|
129
|
+
return `enrollment grants are stranded in the pre-rename directory: '${grantsPath}' holds no *.grant.dsse files, ` +
|
|
130
|
+
`but '${legacyPath}' holds ${legacyCount}. owenloop reads only '${grantsPath}' and will not move your ` +
|
|
131
|
+
`cryptographic material for you. Run: ${command} ` +
|
|
132
|
+
'then restart every running owenloop shift daemon.' +
|
|
133
|
+
(destinationIsAbsent
|
|
134
|
+
? ''
|
|
135
|
+
: ` If rmdir refuses, inspect '${grantsPath}' by hand before migrating; owenloop will not move your cryptographic material for you.`);
|
|
136
|
+
}
|
|
137
|
+
/** Thrown when legacy grants are stranded or cannot be safely inspected. */
|
|
138
|
+
export class StrandedLegacyGrantsError extends Error {
|
|
139
|
+
name = 'StrandedLegacyGrantsError';
|
|
140
|
+
grantsPath;
|
|
141
|
+
legacyPath;
|
|
142
|
+
legacyCount;
|
|
143
|
+
sourcePath;
|
|
144
|
+
sourceReason;
|
|
145
|
+
constructor(grantsPath, legacyPath, legacyCount, sourceProblem = undefined, destinationIsAbsent = false) {
|
|
146
|
+
const quotedGrantsPath = quotePosixShellArgument(grantsPath);
|
|
147
|
+
const quotedLegacyPath = quotePosixShellArgument(legacyPath);
|
|
148
|
+
let message;
|
|
149
|
+
if (sourceProblem !== undefined) {
|
|
150
|
+
message = sourceManualRepairMessage(grantsPath, legacyPath, sourceProblem);
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
message = migrationMessage(grantsPath, legacyPath, legacyCount, quotedGrantsPath, quotedLegacyPath, destinationIsAbsent);
|
|
154
|
+
}
|
|
155
|
+
super(message);
|
|
156
|
+
this.grantsPath = grantsPath;
|
|
157
|
+
this.legacyPath = legacyPath;
|
|
158
|
+
this.legacyCount = legacyCount;
|
|
159
|
+
this.sourcePath = sourceProblem?.path;
|
|
160
|
+
this.sourceReason = sourceProblem?.reason;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
/** Refuse when legacy grants are stranded or cannot be safely inspected. */
|
|
164
|
+
export function assertNoStrandedLegacyGrants(env) {
|
|
165
|
+
const grants = grantsDir(env);
|
|
166
|
+
if (countGrantFiles(grants) > 0)
|
|
167
|
+
return;
|
|
168
|
+
const legacy = legacyGrantsDir(env);
|
|
169
|
+
const inspection = inspectLegacyGrantsSource(legacy);
|
|
170
|
+
if (inspection.problem !== undefined) {
|
|
171
|
+
throw new StrandedLegacyGrantsError(grants, legacy, inspection.grantCount, inspection.problem);
|
|
172
|
+
}
|
|
173
|
+
if (inspection.grantCount > 0) {
|
|
174
|
+
throw new StrandedLegacyGrantsError(grants, legacy, inspection.grantCount, undefined, grantsPathIsAbsent(grants));
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
/** `<config>/revocations`, containing revocation envelopes. */
|
|
31
178
|
export function revocationsDir(env) {
|
|
32
179
|
return join(orgRootDir(env), 'revocations');
|
|
33
180
|
}
|
|
@@ -68,9 +215,10 @@ function loadEnvelopeDirectory(path, suffix, label) {
|
|
|
68
215
|
}
|
|
69
216
|
return result;
|
|
70
217
|
}
|
|
71
|
-
/** Load sorted `.grant.dsse` bytes from the injected
|
|
72
|
-
export function
|
|
73
|
-
|
|
218
|
+
/** Load sorted `.grant.dsse` bytes from the injected grants directory. */
|
|
219
|
+
export function loadGrants(env) {
|
|
220
|
+
assertNoStrandedLegacyGrants(env);
|
|
221
|
+
return loadEnvelopeDirectory(grantsDir(env), '.grant.dsse', 'grants');
|
|
74
222
|
}
|
|
75
223
|
/** Load sorted `.revocation.dsse` bytes from the injected revocation directory. */
|
|
76
224
|
export function loadRevocations(env) {
|
|
@@ -288,7 +288,9 @@ export declare const ORDER_FIELDS: {
|
|
|
288
288
|
readonly consumesProof: "optional";
|
|
289
289
|
readonly cause: "optional";
|
|
290
290
|
readonly capabilities: "optional";
|
|
291
|
+
readonly crews: "optional";
|
|
291
292
|
readonly modifier: "optional";
|
|
293
|
+
readonly reroutedFrom: "optional";
|
|
292
294
|
readonly escalated: "optional";
|
|
293
295
|
};
|
|
294
296
|
/** Indexed access pins the already-emitted nested Order shape without cloning it. */
|
|
@@ -309,6 +311,7 @@ export declare const ORDER_REASON_FIELDS: {
|
|
|
309
311
|
readonly by: "required";
|
|
310
312
|
readonly text: "required";
|
|
311
313
|
readonly fromVersion: "optional";
|
|
314
|
+
readonly requested: "optional";
|
|
312
315
|
};
|
|
313
316
|
/** Bind every record definition in this package to a frozen DSSE media type. */
|
|
314
317
|
export declare const RECORD_PAYLOAD_TYPES: {
|
|
@@ -134,7 +134,14 @@ export const ORDER_FIELDS = {
|
|
|
134
134
|
// unmodified run on a capability-silent step carries neither, so every order
|
|
135
135
|
// emitted before this field existed still validates unchanged.
|
|
136
136
|
capabilities: 'optional',
|
|
137
|
+
crews: 'optional',
|
|
137
138
|
modifier: 'optional',
|
|
139
|
+
// Set only when a caller-supplied reroute rule replaced the composed offer,
|
|
140
|
+
// holding what the def actually asked for. Signed like the rest of the
|
|
141
|
+
// routing snapshot for the same reason `escalated` is: an order served on a
|
|
142
|
+
// substituted capability must not be replayable as one that was served on
|
|
143
|
+
// the capability it requested.
|
|
144
|
+
reroutedFrom: 'optional',
|
|
138
145
|
// Set only when `modifier` is the step's escalation target rather than the
|
|
139
146
|
// run's. Covered by the signature like every other routing field: a claim
|
|
140
147
|
// made on a recovery re-offer must not be replayable as an ordinary one.
|
|
@@ -169,6 +176,7 @@ export const ORDER_REASON_FIELDS = {
|
|
|
169
176
|
by: 'required',
|
|
170
177
|
text: 'required',
|
|
171
178
|
fromVersion: 'optional',
|
|
179
|
+
requested: 'optional',
|
|
172
180
|
};
|
|
173
181
|
/** Bind every record definition in this package to a frozen DSSE media type. */
|
|
174
182
|
export const RECORD_PAYLOAD_TYPES = {
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Resolution of the local SSHSIG trust root used for workflow publications.
|
|
3
3
|
*
|
|
4
4
|
* The path is derived only from injected environment state, through the shared
|
|
5
|
-
* `owenloopConfigDir` ladder (`OWENLOOP_CONFIG_DIR` > `
|
|
6
|
-
*
|
|
5
|
+
* `owenloopConfigDir` ladder (`OWENLOOP_CONFIG_DIR` > `HOME`); no ambient
|
|
6
|
+
* home directory lookup is allowed here. An absent file is
|
|
7
7
|
* a normal result so the
|
|
8
8
|
* publication verifier can classify it as `unverifiable` instead of confusing
|
|
9
9
|
* a missing trust root with an unsigned bundle.
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Resolution of the local SSHSIG trust root used for workflow publications.
|
|
3
3
|
*
|
|
4
4
|
* The path is derived only from injected environment state, through the shared
|
|
5
|
-
* `owenloopConfigDir` ladder (`OWENLOOP_CONFIG_DIR` > `
|
|
6
|
-
*
|
|
5
|
+
* `owenloopConfigDir` ladder (`OWENLOOP_CONFIG_DIR` > `HOME`); no ambient
|
|
6
|
+
* home directory lookup is allowed here. An absent file is
|
|
7
7
|
* a normal result so the
|
|
8
8
|
* publication verifier can classify it as `unverifiable` instead of confusing
|
|
9
9
|
* a missing trust root with an unsigned bundle.
|
package/dist/src/defs.d.ts
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* body: |
|
|
20
20
|
* Draft a plan for ${WORKFLOW}.
|
|
21
21
|
*/
|
|
22
|
-
import type { WorkflowDef } from './types.ts';
|
|
22
|
+
import type { StepDef, WorkflowDef } from './types.ts';
|
|
23
23
|
/**
|
|
24
24
|
* The engine-version contract (§27). A workflow definition may declare
|
|
25
25
|
* `engine: <n>`; it must be a positive integer no greater than this constant
|
|
@@ -81,6 +81,11 @@ export declare function lintDef(def: WorkflowDef): {
|
|
|
81
81
|
errors: string[];
|
|
82
82
|
warnings: string[];
|
|
83
83
|
};
|
|
84
|
+
/**
|
|
85
|
+
* The steps a def declares as cleanup-on-cancel, in definition order. The
|
|
86
|
+
* control plane calls this when it cancels a run.
|
|
87
|
+
*/
|
|
88
|
+
export declare function cancelCleanupSteps(def: WorkflowDef): StepDef[];
|
|
84
89
|
/** Stable private-map key for one installed coordinate at one verified digest. */
|
|
85
90
|
export declare function digestScopedCallsTargetKey(digest: string, target: string): string;
|
|
86
91
|
/**
|