owenloop 0.5.8 → 0.5.10
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 +69 -0
- package/README.md +81 -39
- package/bin/owenloop.mjs +16 -1
- package/dist/packages/work/src/agent/loop.d.ts +23 -8
- package/dist/packages/work/src/agent/loop.js +55 -6
- package/dist/packages/work/src/bundle/pull.d.ts +21 -0
- package/dist/packages/work/src/bundle/pull.js +118 -0
- package/dist/packages/work/src/consumed-verifier.js +6 -17
- package/dist/packages/work/src/exec/instructions.d.ts +4 -1
- package/dist/packages/work/src/exec/instructions.js +3 -0
- package/dist/packages/work/src/exec/loop.d.ts +2 -2
- package/dist/packages/work/src/exec/loop.js +273 -46
- 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/claude.js +116 -0
- package/dist/packages/work/src/harness/codex.d.ts +8 -0
- package/dist/packages/work/src/harness/codex.js +27 -1
- package/dist/packages/work/src/harness/contract.d.ts +9 -0
- 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 +84 -0
- package/dist/packages/work/src/main.js +1 -0
- package/dist/packages/work/src/roles/agent-run.js +57 -32
- package/dist/packages/work/src/roles/exec.js +27 -8
- package/dist/packages/work/src/roles/settings.js +2 -0
- 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 +84 -0
- package/dist/packages/work/src/settings/roster.js +364 -5
- 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 +14 -1
- package/dist/packages/work/src/settings/settings.js +14 -0
- package/dist/packages/work/src/shift/loop.d.ts +108 -5
- package/dist/packages/work/src/shift/loop.js +416 -54
- package/dist/packages/work/src/shift/protocol.d.ts +7 -5
- package/dist/packages/work/src/shift/runtime.d.ts +18 -0
- package/dist/packages/work/src/shift/runtime.js +104 -5
- package/dist/packages/work/src/shift/server.js +2 -0
- package/dist/packages/work/src/shift/spawn.d.ts +17 -2
- package/dist/packages/work/src/shift/spawn.js +16 -13
- 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/submit-proof.d.ts +11 -8
- package/dist/packages/work/src/submit-proof.js +11 -8
- package/dist/packages/work/src/usage.d.ts +1 -1
- package/dist/packages/work/src/usage.js +7 -1
- 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 +76 -6
- package/dist/src/capabilities.js +49 -6
- package/dist/src/capability-mapping-client.d.ts +29 -0
- package/dist/src/capability-mapping-client.js +160 -0
- package/dist/src/cli.d.ts +16 -3
- package/dist/src/cli.js +1925 -281
- package/dist/src/config-dir.d.ts +1 -1
- package/dist/src/config-dir.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 +2 -0
- package/dist/src/crypto/records.js +2 -0
- package/dist/src/defs.d.ts +38 -2
- package/dist/src/defs.js +593 -86
- package/dist/src/engine.d.ts +103 -25
- package/dist/src/engine.js +331 -79
- package/dist/src/hub.d.ts +77 -0
- package/dist/src/hub.js +162 -0
- package/dist/src/implements.d.ts +56 -0
- package/dist/src/implements.js +790 -0
- package/dist/src/index.d.ts +11 -9
- package/dist/src/index.js +6 -5
- package/dist/src/mcp/serve.d.ts +22 -0
- package/dist/src/mcp/serve.js +330 -41
- package/dist/src/mcp/server.d.ts +10 -7
- package/dist/src/mcp/server.js +53 -8
- package/dist/src/model.d.ts +48 -10
- package/dist/src/model.js +252 -99
- package/dist/src/order-resolver.d.ts +1 -0
- package/dist/src/order-resolver.js +8 -1
- package/dist/src/schemas/index.d.ts +11 -0
- package/dist/src/schemas/order.v1.schema.json +7 -1
- package/dist/src/store/def-source.d.ts +19 -0
- package/dist/src/store/def-source.js +87 -17
- package/dist/src/store/gc-recovery.d.ts +46 -0
- package/dist/src/store/gc-recovery.js +258 -0
- package/dist/src/store/gc.d.ts +94 -0
- package/dist/src/store/gc.js +562 -0
- package/dist/src/store/index.d.ts +3 -1
- package/dist/src/store/index.js +2 -0
- package/dist/src/store/install.d.ts +34 -5
- package/dist/src/store/install.js +73 -11
- package/dist/src/store/pre-commit-verifier.js +42 -2
- package/dist/src/store/snapshot-guard.d.ts +18 -0
- package/dist/src/store/snapshot-guard.js +94 -0
- package/dist/src/store.d.ts +69 -4
- package/dist/src/store.js +254 -16
- package/dist/src/types.d.ts +101 -20
- package/dist/src/util.js +4 -1
- package/docs/authoring.md +235 -10
- package/docs/bundles.md +45 -2
- package/docs/cli.md +437 -55
- package/docs/crypto.md +32 -10
- package/docs/design.md +177 -47
- package/docs/evals/mcp-charter-baseline.json +428 -0
- package/docs/mcp-charter-eval.md +124 -0
- package/docs/routing.md +189 -34
- package/docs/shift-logs.md +38 -9
- package/docs/wire-contracts.md +78 -14
- package/examples/workflows/compile-dev-playbook.yaml +1 -1
- package/examples/workflows/delivery.yaml +31 -14
- package/examples/workflows/ship.yaml +38 -4
- package/package.json +2 -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 +22 -0
- package/plugins/claude-code/plugin/skills/ephemeral/SKILL.md +95 -0
- package/plugins/claude-code/plugin/skills/graduate/SKILL.md +156 -0
- package/plugins/claude-code/plugin/skills/plan/SKILL.md +236 -0
- 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 +22 -0
- package/plugins/codex/plugins/owenloop/skills/ephemeral/SKILL.md +95 -0
- package/plugins/codex/plugins/owenloop/skills/graduate/SKILL.md +156 -0
- package/plugins/codex/plugins/owenloop/skills/plan/SKILL.md +236 -0
package/dist/src/config-dir.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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
7
|
* ladder, which made it too easy for each subsystem to resolve a different
|
package/dist/src/config-dir.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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
7
|
* ladder, which made it too easy for each subsystem to resolve a different
|
|
@@ -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,6 +288,7 @@ 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";
|
|
292
293
|
readonly reroutedFrom: "optional";
|
|
293
294
|
readonly escalated: "optional";
|
|
@@ -310,6 +311,7 @@ export declare const ORDER_REASON_FIELDS: {
|
|
|
310
311
|
readonly by: "required";
|
|
311
312
|
readonly text: "required";
|
|
312
313
|
readonly fromVersion: "optional";
|
|
314
|
+
readonly requested: "optional";
|
|
313
315
|
};
|
|
314
316
|
/** Bind every record definition in this package to a frozen DSSE media type. */
|
|
315
317
|
export declare const RECORD_PAYLOAD_TYPES: {
|
|
@@ -134,6 +134,7 @@ 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',
|
|
138
139
|
// Set only when a caller-supplied reroute rule replaced the composed offer,
|
|
139
140
|
// holding what the def actually asked for. Signed like the rest of the
|
|
@@ -175,6 +176,7 @@ export const ORDER_REASON_FIELDS = {
|
|
|
175
176
|
by: 'required',
|
|
176
177
|
text: 'required',
|
|
177
178
|
fromVersion: 'optional',
|
|
179
|
+
requested: 'optional',
|
|
178
180
|
};
|
|
179
181
|
/** Bind every record definition in this package to a frozen DSSE media type. */
|
|
180
182
|
export const RECORD_PAYLOAD_TYPES = {
|
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
|
/**
|
|
@@ -91,6 +96,22 @@ export declare function digestScopedCallsTargetKey(digest: string, target: strin
|
|
|
91
96
|
* spawns at runtime.
|
|
92
97
|
*/
|
|
93
98
|
export declare function resolveCallsTarget(defs: Map<string, WorkflowDef>, target: string, from: WorkflowDef): WorkflowDef | undefined;
|
|
99
|
+
/** A calls cycle and the resolved definition keys on its displayed path. */
|
|
100
|
+
export interface CallsCycleFinding {
|
|
101
|
+
message: string;
|
|
102
|
+
members: string[];
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Report calls cycles in a flat def map. This is the Mode 2 analogue of the
|
|
106
|
+
* Mode 1 include-cycle guard in expandIncludes; the two edge kinds stay
|
|
107
|
+
* deliberately separate. Findings use resolved map identity, not bare call
|
|
108
|
+
* text, so CAS bundle siblings cannot be accidentally fused. The first finding
|
|
109
|
+
* is strict loading's legacy DFS witness. Further findings add at most one
|
|
110
|
+
* deterministic witness for each still-unattributed cyclic member, keeping
|
|
111
|
+
* authoring attribution polynomial and every finding's members consistent with
|
|
112
|
+
* its displayed path without enumerating exponentially many simple cycles.
|
|
113
|
+
*/
|
|
114
|
+
export declare function reportCallsCycles(defs: Map<string, WorkflowDef>): CallsCycleFinding[];
|
|
94
115
|
/** Load and validate a single workflow definition from a YAML file. */
|
|
95
116
|
export declare function loadDefFile(file: string): WorkflowDef;
|
|
96
117
|
/**
|
|
@@ -125,7 +146,8 @@ export declare function loadDefsUnfinalized(dir: string): Map<string, WorkflowDe
|
|
|
125
146
|
* (each def possibly still carrying `_includes`), it: expands each def's
|
|
126
147
|
* includes; runs the cross-def `calls:` checks (target existence, `callsInputs`
|
|
127
148
|
* key validity, exactly-one child output); runs `validateDef` per expanded def;
|
|
128
|
-
* and finally
|
|
149
|
+
* and finally performs the bounded first-cycle DFS over the whole expanded map.
|
|
150
|
+
* `reportCallsCycles` exposes the wider per-member authoring report. Returns the
|
|
129
151
|
* expanded, validated map. Throws `DefError` on the first problem — the same
|
|
130
152
|
* messages, in the same order, the filesystem loader has always produced (this
|
|
131
153
|
* is a pure extraction of what used to live inline in `loadDefs`).
|
|
@@ -148,6 +170,12 @@ export interface FinalizeDefsOptions {
|
|
|
148
170
|
*/
|
|
149
171
|
allowUnresolvedCalls?: boolean;
|
|
150
172
|
}
|
|
173
|
+
/**
|
|
174
|
+
* Return every direct cross-definition `calls:` error for one expanded
|
|
175
|
+
* definition. Strict loading uses the first result to retain its historical
|
|
176
|
+
* throw behavior; tolerant authoring commands can present the complete list.
|
|
177
|
+
*/
|
|
178
|
+
export declare function validateCallsEdges(def: WorkflowDef, defs: Map<string, WorkflowDef>, options?: FinalizeDefsOptions): string[];
|
|
151
179
|
export declare function finalizeDefs(raw: Map<string, WorkflowDef>, options?: FinalizeDefsOptions): Map<string, WorkflowDef>;
|
|
152
180
|
/** One file that `loadDefsRaw` could not turn into a def (malformed YAML, bad shape, duplicate name). */
|
|
153
181
|
export interface DefLoadFailure {
|
|
@@ -163,4 +191,12 @@ export interface DefLoadFailure {
|
|
|
163
191
|
* Two-phase: Phase 1 collects all defs. Phase 2 expands includes best-effort
|
|
164
192
|
* (silently skips expansion failures so the lint caller sees un-expanded defs).
|
|
165
193
|
*/
|
|
194
|
+
export declare function scanDefsRaw(dir: string, failures?: DefLoadFailure[]): Map<string, WorkflowDef>;
|
|
195
|
+
/** Best-effort include expansion for a complete, already-merged raw map. */
|
|
196
|
+
export declare function expandDefsRaw(raw: Map<string, WorkflowDef>): Map<string, WorkflowDef>;
|
|
197
|
+
/**
|
|
198
|
+
* Compatibility wrapper for tolerant single-directory loading. Raw loading
|
|
199
|
+
* builds and expands includes best-effort; callers explicitly invoke shared
|
|
200
|
+
* calls validation and cycle reporting against the complete definition map.
|
|
201
|
+
*/
|
|
166
202
|
export declare function loadDefsRaw(dir: string, failures?: DefLoadFailure[]): Map<string, WorkflowDef>;
|