owenloop 0.5.27 → 0.5.29
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 +21 -0
- package/dist/packages/work/src/agent/brief.d.ts +10 -0
- package/dist/packages/work/src/agent/brief.js +38 -0
- package/dist/packages/work/src/agent/loop.js +4 -0
- package/dist/packages/work/src/consumed-verifier.d.ts +22 -2
- package/dist/packages/work/src/consumed-verifier.js +131 -12
- package/dist/packages/work/src/contained-path.d.ts +18 -0
- package/dist/packages/work/src/contained-path.js +42 -0
- package/dist/packages/work/src/exec/instructions.js +43 -3
- package/dist/packages/work/src/harness/claude.js +21 -0
- package/dist/packages/work/src/harness/codex.js +29 -0
- package/dist/packages/work/src/harness/contract.d.ts +26 -0
- package/dist/packages/work/src/hold/mcp.d.ts +3 -40
- package/dist/packages/work/src/hold/mcp.js +121 -2
- package/dist/packages/work/src/hub/client.d.ts +10 -1
- package/dist/packages/work/src/hub/client.js +23 -0
- package/dist/packages/work/src/hub/types.d.ts +45 -0
- package/dist/packages/work/src/roles/shift.js +7 -1
- package/dist/packages/work/src/settings/settings.d.ts +12 -1
- package/dist/packages/work/src/settings/settings.js +7 -0
- package/dist/packages/work/src/shift/disk-floor.d.ts +107 -0
- package/dist/packages/work/src/shift/disk-floor.js +148 -0
- package/dist/packages/work/src/shift/host-preflight.d.ts +85 -0
- package/dist/packages/work/src/shift/host-preflight.js +112 -0
- package/dist/packages/work/src/shift/loop.d.ts +18 -0
- package/dist/packages/work/src/shift/loop.js +179 -7
- package/dist/packages/work/src/shift/protocol.d.ts +62 -1
- package/dist/packages/work/src/shift/runtime.d.ts +2 -0
- package/dist/packages/work/src/shift/runtime.js +17 -0
- package/dist/packages/work/src/submit-file.d.ts +3 -2
- package/dist/packages/work/src/submit-file.js +6 -22
- package/dist/src/crypto/records.d.ts +1 -0
- package/dist/src/crypto/records.js +1 -0
- package/dist/src/crypto/verify-consumed.d.ts +16 -1
- package/dist/src/crypto/verify-consumed.js +21 -6
- package/dist/src/schemas/index.d.ts +23 -0
- package/dist/src/schemas/order.v1.schema.json +14 -0
- package/dist/src/store/index.d.ts +1 -1
- package/dist/src/store/instruction-source.d.ts +15 -0
- package/dist/src/store/instruction-source.js +64 -4
- package/dist/src/store/types.d.ts +6 -2
- package/dist/src/store/types.js +5 -1
- package/dist/src/types.d.ts +11 -0
- package/docs/bundles.md +5 -1
- package/docs/cli.md +8 -5
- package/docs/crypto.md +46 -0
- package/docs/shift-logs.md +64 -7
- package/docs/wire-contracts.md +15 -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/codex/plugins/owenloop/.codex-plugin/plugin.json +1 -1
- package/plugins/codex/plugins/owenloop/.mcp.json +1 -1
|
@@ -1,36 +1,20 @@
|
|
|
1
|
-
import { readFile
|
|
2
|
-
import {
|
|
3
|
-
import { isInside } from "./harness/gatekeeper.js";
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { resolveContainedPath } from "./contained-path.js";
|
|
4
3
|
function errorMessage(error) {
|
|
5
4
|
return error instanceof Error ? error.message : String(error);
|
|
6
5
|
}
|
|
7
6
|
/**
|
|
8
7
|
* Read a submit value from a JSON document contained in a run worktree.
|
|
9
8
|
*
|
|
10
|
-
*
|
|
11
|
-
* canonical check
|
|
9
|
+
* Containment is `resolveContainedPath`'s job — lexical traversal check first,
|
|
10
|
+
* then a canonical symlink check. This function owns only what is specific to
|
|
11
|
+
* a submit value: the argument shape and the JSON decode.
|
|
12
12
|
*/
|
|
13
13
|
export async function readSubmitValueFile(workdir, valueFile) {
|
|
14
14
|
if (typeof valueFile !== 'string' || valueFile.trim() === '') {
|
|
15
15
|
throw new Error(`submit-value-file-invalid: valueFile must be a non-empty string: ${String(valueFile)}`);
|
|
16
16
|
}
|
|
17
|
-
const
|
|
18
|
-
if (!isInside(workdir, candidate)) {
|
|
19
|
-
throw new Error(`submit-value-file-outside-workdir: ${valueFile} is outside the run workdir`);
|
|
20
|
-
}
|
|
21
|
-
let canonicalCandidate;
|
|
22
|
-
try {
|
|
23
|
-
const canonicalWorkdir = await realpath(workdir);
|
|
24
|
-
canonicalCandidate = await realpath(candidate);
|
|
25
|
-
if (!isInside(canonicalWorkdir, canonicalCandidate)) {
|
|
26
|
-
throw new Error(`submit-value-file-outside-workdir: ${valueFile} is outside the run workdir`);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
catch (error) {
|
|
30
|
-
if (error instanceof Error && error.message.startsWith('submit-value-file-outside-workdir:'))
|
|
31
|
-
throw error;
|
|
32
|
-
throw new Error(`submit-value-file-read-failed: could not read ${valueFile}: ${errorMessage(error)}`);
|
|
33
|
-
}
|
|
17
|
+
const canonicalCandidate = await resolveContainedPath(workdir, valueFile, 'submit-value-file');
|
|
34
18
|
let text;
|
|
35
19
|
try {
|
|
36
20
|
text = await readFile(canonicalCandidate, 'utf8');
|
|
@@ -286,6 +286,7 @@ export declare const ORDER_FIELDS: {
|
|
|
286
286
|
readonly consumedFingerprint: "optional";
|
|
287
287
|
readonly owes: "required";
|
|
288
288
|
readonly consumesProof: "optional";
|
|
289
|
+
readonly consumesProofRelay: "optional";
|
|
289
290
|
readonly cause: "optional";
|
|
290
291
|
readonly capabilities: "optional";
|
|
291
292
|
readonly crews: "optional";
|
|
@@ -127,6 +127,7 @@ export const ORDER_FIELDS = {
|
|
|
127
127
|
consumedFingerprint: 'optional',
|
|
128
128
|
owes: 'required',
|
|
129
129
|
consumesProof: 'optional',
|
|
130
|
+
consumesProofRelay: 'optional',
|
|
130
131
|
cause: 'optional',
|
|
131
132
|
// Routing snapshot of the offer this order was claimed from. `capabilities`
|
|
132
133
|
// is the COMPOSED list (authored capability + `:<modifier>` where a modifier
|
|
@@ -23,6 +23,17 @@ export type ConsumedVerdict = {
|
|
|
23
23
|
kind: 'invalid';
|
|
24
24
|
reason: string;
|
|
25
25
|
};
|
|
26
|
+
/** The calls-boundary facts a relayed child submission record is checked
|
|
27
|
+
* against. Both values come from the consumer's verified local definition
|
|
28
|
+
* bytes — the parent's pinned child digest and the child's outcome stem —
|
|
29
|
+
* never from the order that carried the record. */
|
|
30
|
+
export interface CallsRelayExpectation {
|
|
31
|
+
/** Exact definition digest the verified parent pins its `calls:` child at. */
|
|
32
|
+
childDefDigest: string;
|
|
33
|
+
/** The child definition's single outcome stem (`outputs[0]`), the artifact
|
|
34
|
+
* the child's record must cover; the engine folds it into `path`. */
|
|
35
|
+
childOutcome: string;
|
|
36
|
+
}
|
|
26
37
|
export interface VerifyConsumedInput {
|
|
27
38
|
/** Artifact path being consumed. */
|
|
28
39
|
path: string;
|
|
@@ -30,8 +41,12 @@ export interface VerifyConsumedInput {
|
|
|
30
41
|
value: unknown;
|
|
31
42
|
/** Serialized DSSE submission envelope for this artifact. */
|
|
32
43
|
proof?: string;
|
|
33
|
-
/** Consumer claim-time version, when available.
|
|
44
|
+
/** Consumer claim-time version, when available. For a relayed record this
|
|
45
|
+
* is the pinned CHILD outcome version, not the parent path's counter. */
|
|
34
46
|
expectedVersion?: number;
|
|
47
|
+
/** Present when `path` was produced by a `calls:` step and `proof` is the
|
|
48
|
+
* child's own relayed submission record rather than one for `path`. */
|
|
49
|
+
relay?: CallsRelayExpectation;
|
|
35
50
|
/** Local organization-root public key anchor. */
|
|
36
51
|
orgRootPublicKey: string;
|
|
37
52
|
/** Raw enrollment-grant envelope bytes. */
|
|
@@ -209,9 +209,24 @@ export async function verifyConsumed(input, options = {}) {
|
|
|
209
209
|
finally {
|
|
210
210
|
signer.dispose?.();
|
|
211
211
|
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
212
|
+
// Calls boundary: a relayed record was signed by the CHILD for its own
|
|
213
|
+
// outcome. It is admitted for the parent path only when it was signed for
|
|
214
|
+
// exactly the child definition the verified parent pins, and only under the
|
|
215
|
+
// child's outcome stem. Both expectations are the consumer's own bytes.
|
|
216
|
+
const relay = input.relay;
|
|
217
|
+
if (relay !== undefined && record.defDigest !== relay.childDefDigest) {
|
|
218
|
+
return invalid(`calls: relayed submission record for artifact '${input.path}' was signed for definition digest '${record.defDigest}', but the verified parent definition pins its calls child at '${relay.childDefDigest}'`);
|
|
219
|
+
}
|
|
220
|
+
const coveredArtifact = relay === undefined ? input.path : relay.childOutcome;
|
|
221
|
+
const produced = record.produced.find((entry) => entry.artifact === coveredArtifact);
|
|
222
|
+
if (produced === undefined) {
|
|
223
|
+
return relay === undefined
|
|
224
|
+
? invalid(`signature: signed submission record does not cover artifact '${input.path}'`)
|
|
225
|
+
: invalid(`calls: relayed submission record does not cover child outcome '${relay.childOutcome}', which the calls boundary folds into artifact '${input.path}'`);
|
|
226
|
+
}
|
|
227
|
+
const boundary = relay === undefined
|
|
228
|
+
? ''
|
|
229
|
+
: ` (relayed across the calls boundary from child outcome '${relay.childOutcome}' of definition '${relay.childDefDigest}')`;
|
|
215
230
|
let deliveredDigest;
|
|
216
231
|
try {
|
|
217
232
|
deliveredDigest = valueDigestHex(input.value);
|
|
@@ -220,10 +235,10 @@ export async function verifyConsumed(input, options = {}) {
|
|
|
220
235
|
return invalid(`value-digest: delivered artifact '${input.path}' cannot be canonically represented: ${error instanceof Error ? error.message : String(error)}`);
|
|
221
236
|
}
|
|
222
237
|
if (deliveredDigest !== produced.valueDigest) {
|
|
223
|
-
return invalid(`value-digest: delivered artifact '${input.path}' has digest '${deliveredDigest}', signed digest is '${produced.valueDigest}'`);
|
|
238
|
+
return invalid(`value-digest: delivered artifact '${input.path}' has digest '${deliveredDigest}', signed digest is '${produced.valueDigest}'${boundary}`);
|
|
224
239
|
}
|
|
225
240
|
if (input.expectedVersion !== undefined && produced.version !== input.expectedVersion) {
|
|
226
|
-
return invalid(`version: artifact '${input.path}' has signed version ${produced.version}, expected version ${input.expectedVersion}`);
|
|
241
|
+
return invalid(`version: artifact '${input.path}' has signed version ${produced.version}, expected version ${input.expectedVersion}${boundary}`);
|
|
227
242
|
}
|
|
228
243
|
if (record.timestamp > input.at) {
|
|
229
244
|
options.warn?.(`producer-claimed timestamp for artifact '${input.path}' is ${record.timestamp - input.at} ms ahead of local clock; timestamp is not used for revocation`);
|
|
@@ -251,7 +266,7 @@ export async function verifyConsumed(input, options = {}) {
|
|
|
251
266
|
return invalid(`${link}: ${chain.reason}`);
|
|
252
267
|
}
|
|
253
268
|
if (input.expectedVersion === undefined) {
|
|
254
|
-
return unverifiable(`version: artifact '${input.path}' has a valid historical proof, but the claim omitted its authoritative expected version`);
|
|
269
|
+
return unverifiable(`version: artifact '${input.path}' has a valid historical proof, but the claim omitted its authoritative expected version${boundary}`);
|
|
255
270
|
}
|
|
256
271
|
return { kind: 'verified', producerKeyId: verifiedKeyId, principal: chain.principal, version: produced.version };
|
|
257
272
|
}
|
|
@@ -581,6 +581,29 @@ export declare const WIRE_SCHEMAS: {
|
|
|
581
581
|
consumesProof: {
|
|
582
582
|
type: string;
|
|
583
583
|
};
|
|
584
|
+
consumesProofRelay: {
|
|
585
|
+
type: string;
|
|
586
|
+
description: string;
|
|
587
|
+
additionalProperties: {
|
|
588
|
+
type: string;
|
|
589
|
+
additionalProperties: boolean;
|
|
590
|
+
required: string[];
|
|
591
|
+
properties: {
|
|
592
|
+
childDefDigest: {
|
|
593
|
+
type: string;
|
|
594
|
+
minLength: number;
|
|
595
|
+
};
|
|
596
|
+
childVersion: {
|
|
597
|
+
type: string;
|
|
598
|
+
minimum: number;
|
|
599
|
+
};
|
|
600
|
+
childOutcome: {
|
|
601
|
+
type: string;
|
|
602
|
+
minLength: number;
|
|
603
|
+
};
|
|
604
|
+
};
|
|
605
|
+
};
|
|
606
|
+
};
|
|
584
607
|
cause: {
|
|
585
608
|
type: string;
|
|
586
609
|
enum: string[];
|
|
@@ -111,6 +111,20 @@
|
|
|
111
111
|
}
|
|
112
112
|
},
|
|
113
113
|
"consumesProof": { "type": "string" },
|
|
114
|
+
"consumesProofRelay": {
|
|
115
|
+
"type": "object",
|
|
116
|
+
"description": "Calls-boundary relay hints keyed by the parent artifact path. For a consumed path a 'calls:' step produced, the entry names the child definition digest the parent pins, the pinned child outcome version, and the child outcome stem whose signed submission record 'consumesProof' carries under the parent path.",
|
|
117
|
+
"additionalProperties": {
|
|
118
|
+
"type": "object",
|
|
119
|
+
"additionalProperties": false,
|
|
120
|
+
"required": ["childDefDigest", "childVersion", "childOutcome"],
|
|
121
|
+
"properties": {
|
|
122
|
+
"childDefDigest": { "type": "string", "minLength": 1 },
|
|
123
|
+
"childVersion": { "type": "integer", "minimum": 0 },
|
|
124
|
+
"childOutcome": { "type": "string", "minLength": 1 }
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
},
|
|
114
128
|
"cause": { "type": "string", "enum": ["inputsGreen", "allGreen", "idle"] },
|
|
115
129
|
"capabilities": {
|
|
116
130
|
"type": "array",
|
|
@@ -23,7 +23,7 @@ export { collectWorkflowStoreGarbage, planWorkflowStoreGc } from './gc.ts';
|
|
|
23
23
|
export type { CollectWorkflowStoreGcArgs, PlanWorkflowStoreGcArgs, WorkflowStoreGcObject, WorkflowStoreGcPlan, WorkflowStoreGcReport, } from './gc.ts';
|
|
24
24
|
export { originEvidencePath, persistOriginEvidence, readOriginEvidence, } from './origin-evidence.ts';
|
|
25
25
|
export { createStoreInstructionSource, isResolvableOrderDigest, StoreInstructionSourceError, } from './instruction-source.ts';
|
|
26
|
-
export type { MissingObjectHandler, StoreInstructionSource, StoreInstructionSourceArgs, } from './instruction-source.ts';
|
|
26
|
+
export type { MissingObjectHandler, StoreInstructionSource, StoreInstructionSourceArgs, VerifiedCallsChild, } from './instruction-source.ts';
|
|
27
27
|
export type { BundleInstallResult, BundleIngestor, BundleSource, BundleVerificationEvidence, InstallWorkflowBundleArgs, PreCommitVerifier, RecoverWorkflowStoreArgs, } from './install.ts';
|
|
28
28
|
export { createExecutionDefinitionVerifier, createExecutionOriginVerifier, createPreCommitVerifier, createProductionPreCommitVerifier, resolveArtifactPolicy, resolveDefPolicy, resolveOriginPolicy, resolveOriginRules, } from './pre-commit-verifier.ts';
|
|
29
29
|
export type { ExecutionDefinitionVerifierInput, ExecutionOriginVerifierInput, PreCommitVerifierOptions, } from './pre-commit-verifier.ts';
|
|
@@ -30,6 +30,15 @@ export declare class StoreInstructionSourceError extends Error {
|
|
|
30
30
|
readonly code: 'digest-of-unavailable';
|
|
31
31
|
constructor(message: string);
|
|
32
32
|
}
|
|
33
|
+
/** A verified `calls:` child: the finalized child definition and the exact
|
|
34
|
+
* bundle digest the parent's verified bytes pin it at. Validation context
|
|
35
|
+
* only — a child is never an instruction lookup target of its own. */
|
|
36
|
+
export interface VerifiedCallsChild {
|
|
37
|
+
definition: WorkflowDef;
|
|
38
|
+
bundleDigest: DefDigest;
|
|
39
|
+
/** The `calls:` target as authored on the parent step. */
|
|
40
|
+
target: string;
|
|
41
|
+
}
|
|
33
42
|
/** A synchronous lookup source backed by verified local workflow-store objects. */
|
|
34
43
|
export interface StoreInstructionSource extends OrderInstructionSource {
|
|
35
44
|
/** Load and verify the bundle that corresponds to an order or bundle digest. */
|
|
@@ -43,6 +52,12 @@ export interface StoreInstructionSource extends OrderInstructionSource {
|
|
|
43
52
|
bundleDigest: DefDigest;
|
|
44
53
|
objectPath: string;
|
|
45
54
|
} | undefined;
|
|
55
|
+
/** Return the verified `calls:` child that step `callsStep` of the definition
|
|
56
|
+
* serving `step` invokes, resolved in the same finalized closure the
|
|
57
|
+
* definition was verified in. Optional so a source without a dependency
|
|
58
|
+
* closure still type-checks; a consumer treats its absence as "no
|
|
59
|
+
* calls-boundary context", never as permission. */
|
|
60
|
+
getVerifiedCallsChild?(defDigest: string, step: string, callsStep: string): VerifiedCallsChild | undefined;
|
|
46
61
|
}
|
|
47
62
|
export declare function createStoreInstructionSource(args: StoreInstructionSourceArgs): StoreInstructionSource;
|
|
48
63
|
/** A small helper for callers that receive a raw order digest before priming. */
|
|
@@ -11,7 +11,7 @@ import { join } from 'node:path';
|
|
|
11
11
|
import { readFileSync } from 'node:fs';
|
|
12
12
|
import { isVersionedReference, parseManifestBytes } from "../bundle/manifest.js";
|
|
13
13
|
import { defInstructionDigest } from "../order-resolver.js";
|
|
14
|
-
import { digestScopedCallsTargetKey, finalizeDefs, loadDefFile } from "../defs.js";
|
|
14
|
+
import { digestScopedCallsTargetKey, finalizeDefs, loadDefFile, resolveCallsTarget } from "../defs.js";
|
|
15
15
|
import { readWorkflowStoreIndex } from "./index-file.js";
|
|
16
16
|
import { StoreIntegrityError, compareStoreText, defDigest, objectDirForDigest, parseWorkflowCoordinate, } from "./types.js";
|
|
17
17
|
import { coordinateDigestRead, projectStoreRoot, probeObjectDir, probeStoreRoot, storeIndexPath, } from "./resolve.js";
|
|
@@ -194,6 +194,9 @@ export function createStoreInstructionSource(args) {
|
|
|
194
194
|
catch (error) {
|
|
195
195
|
if (error instanceof StoreIntegrityError && error.code === 'object-missing')
|
|
196
196
|
continue;
|
|
197
|
+
// A child whose own lock target is missing names THAT digest; keep it.
|
|
198
|
+
if (error instanceof StoreIntegrityError && error.code === 'dependency-missing')
|
|
199
|
+
throw error;
|
|
197
200
|
const verified = error instanceof StoreIntegrityError
|
|
198
201
|
&& error.message.includes('object failed verification');
|
|
199
202
|
throw new StoreIntegrityError('object-corrupt', childDigest, `locked calls target '${target}' digest ${childDigest} at ${candidate.level}-level root '${candidate.root}' ` +
|
|
@@ -201,7 +204,10 @@ export function createStoreInstructionSource(args) {
|
|
|
201
204
|
}
|
|
202
205
|
}
|
|
203
206
|
if (child === undefined) {
|
|
204
|
-
|
|
207
|
+
// Not corruption: the parent verified, it merely pins a child this
|
|
208
|
+
// store never received. `prime` hands the CHILD digest to recovery.
|
|
209
|
+
throw new StoreIntegrityError('dependency-missing', childDigest, `locked calls target '${target}' digest ${childDigest} pinned by parent bundle ${object.bundleDigest} ` +
|
|
210
|
+
'is absent from every configured workflow store root');
|
|
205
211
|
}
|
|
206
212
|
const selected = selectLockedTarget(target, childDigest, child);
|
|
207
213
|
// An alias is the only qualified path a parent calls: edge may take.
|
|
@@ -218,6 +224,26 @@ export function createStoreInstructionSource(args) {
|
|
|
218
224
|
const finalized = finalizeDefs(validation);
|
|
219
225
|
const parentDefinitions = [...parent.defs.keys()].map((name) => finalized.get(name));
|
|
220
226
|
const cachedSupport = [...support.values()];
|
|
227
|
+
// The same scope-aware rule finalizeDefs validated and the engine runs:
|
|
228
|
+
// a qualified target resolves through the parent's lock, a bare one to
|
|
229
|
+
// the sibling inside the parent's own bundle. Recorded per calls step so
|
|
230
|
+
// a consumer can corroborate a relayed child proof from verified bytes.
|
|
231
|
+
const callsChildrenOf = (def) => {
|
|
232
|
+
const children = new Map();
|
|
233
|
+
for (const step of def.steps) {
|
|
234
|
+
if (step.calls === undefined)
|
|
235
|
+
continue;
|
|
236
|
+
const child = resolveCallsTarget(finalized, step.calls, def);
|
|
237
|
+
const rawDigest = child?.bundleDigest;
|
|
238
|
+
if (child === undefined || rawDigest === undefined)
|
|
239
|
+
continue;
|
|
240
|
+
const childDigest = asDefDigest(rawDigest);
|
|
241
|
+
if (childDigest === undefined)
|
|
242
|
+
continue;
|
|
243
|
+
children.set(step.name, { definition: child, bundleDigest: childDigest, target: step.calls });
|
|
244
|
+
}
|
|
245
|
+
return children;
|
|
246
|
+
};
|
|
221
247
|
// Hub-backed orders use the immutable bundle digest as their execution
|
|
222
248
|
// identity. Dependencies are validation-only: never cache or publish them
|
|
223
249
|
// under the parent digest, even when a child step name is globally unique.
|
|
@@ -227,6 +253,7 @@ export function createStoreInstructionSource(args) {
|
|
|
227
253
|
bundleDigest,
|
|
228
254
|
objectPath: parent.objectPath,
|
|
229
255
|
support: cachedSupport,
|
|
256
|
+
callsChildren: callsChildrenOf(def),
|
|
230
257
|
})));
|
|
231
258
|
return true;
|
|
232
259
|
}
|
|
@@ -239,6 +266,7 @@ export function createStoreInstructionSource(args) {
|
|
|
239
266
|
bundleDigest,
|
|
240
267
|
objectPath: parent.objectPath,
|
|
241
268
|
support: cachedSupport,
|
|
269
|
+
callsChildren: callsChildrenOf(def),
|
|
242
270
|
}]);
|
|
243
271
|
return true;
|
|
244
272
|
}
|
|
@@ -373,16 +401,44 @@ export function createStoreInstructionSource(args) {
|
|
|
373
401
|
}
|
|
374
402
|
return 'unknown-digest';
|
|
375
403
|
};
|
|
404
|
+
/**
|
|
405
|
+
* Prime one digest, recovering a lock-pinned child that the verified
|
|
406
|
+
* closure needs but no configured store root holds. A worker that pulled
|
|
407
|
+
* the parent alone has exactly this shape, so recovery is asked for the
|
|
408
|
+
* CHILD digest (never the requested one) and the parent is re-resolved once
|
|
409
|
+
* the pull supplies it. Each missing child is requested at most once per
|
|
410
|
+
* prime; a child recovery cannot supply surfaces as the named
|
|
411
|
+
* `dependency-missing` error, not as `unknown-digest` (that would re-offer
|
|
412
|
+
* the order forever) and not as corruption.
|
|
413
|
+
*/
|
|
414
|
+
const primeRecoveringDependencies = async (requestedDigest) => {
|
|
415
|
+
const requestedChildren = new Set();
|
|
416
|
+
for (;;) {
|
|
417
|
+
try {
|
|
418
|
+
return await primeOnce(requestedDigest);
|
|
419
|
+
}
|
|
420
|
+
catch (error) {
|
|
421
|
+
if (!(error instanceof StoreIntegrityError) || error.code !== 'dependency-missing')
|
|
422
|
+
throw error;
|
|
423
|
+
if (args.onMissing === undefined || requestedChildren.has(error.digest))
|
|
424
|
+
throw error;
|
|
425
|
+
requestedChildren.add(error.digest);
|
|
426
|
+
const action = await args.onMissing.onMissing(error.digest);
|
|
427
|
+
if (action !== 'retry')
|
|
428
|
+
throw error;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
};
|
|
376
432
|
const prime = (requestedDigest) => {
|
|
377
433
|
const existing = inFlight.get(requestedDigest);
|
|
378
434
|
if (existing !== undefined)
|
|
379
435
|
return existing;
|
|
380
436
|
const operation = (async () => {
|
|
381
|
-
let result = await
|
|
437
|
+
let result = await primeRecoveringDependencies(requestedDigest);
|
|
382
438
|
if (result === 'unknown-digest' && args.onMissing !== undefined) {
|
|
383
439
|
const action = await args.onMissing.onMissing(requestedDigest);
|
|
384
440
|
if (action === 'retry')
|
|
385
|
-
result = await
|
|
441
|
+
result = await primeRecoveringDependencies(requestedDigest);
|
|
386
442
|
}
|
|
387
443
|
return result;
|
|
388
444
|
})();
|
|
@@ -438,6 +494,10 @@ export function createStoreInstructionSource(args) {
|
|
|
438
494
|
const cached = cache.get(requestedDigest)?.[0];
|
|
439
495
|
return cached === undefined ? undefined : { bundleDigest: cached.bundleDigest, objectPath: cached.objectPath };
|
|
440
496
|
},
|
|
497
|
+
getVerifiedCallsChild: (requestedDigest, stepName, callsStep) => {
|
|
498
|
+
const cached = cache.get(requestedDigest)?.filter((entry) => entry.def.steps.some((step) => step.name === stepName));
|
|
499
|
+
return cached?.length === 1 ? cached[0].callsChildren.get(callsStep) : undefined;
|
|
500
|
+
},
|
|
441
501
|
};
|
|
442
502
|
}
|
|
443
503
|
/** A small helper for callers that receive a raw order digest before priming. */
|
|
@@ -92,10 +92,14 @@ export declare class StoreNotFoundError extends WorkflowStoreError {
|
|
|
92
92
|
readonly coordinate: WorkflowCoordinate;
|
|
93
93
|
constructor(coordinate: WorkflowCoordinate);
|
|
94
94
|
}
|
|
95
|
-
/**
|
|
95
|
+
/**
|
|
96
|
+
* An index entry names a digest whose object is missing or failed verification,
|
|
97
|
+
* or a verified object pins a lock target (`dependency-missing`, carrying the
|
|
98
|
+
* CHILD digest) that no configured store root holds.
|
|
99
|
+
*/
|
|
96
100
|
export declare class StoreIntegrityError extends WorkflowStoreError {
|
|
97
101
|
readonly digest: string;
|
|
98
|
-
constructor(code: 'object-missing' | 'object-corrupt', digest: string, detail: string);
|
|
102
|
+
constructor(code: 'object-missing' | 'object-corrupt' | 'dependency-missing', digest: string, detail: string);
|
|
99
103
|
}
|
|
100
104
|
/** Installing a coordinate the index already records at a DIFFERENT digest. */
|
|
101
105
|
export declare class StoreConflictError extends WorkflowStoreError {
|
package/dist/src/store/types.js
CHANGED
|
@@ -106,7 +106,11 @@ export class StoreNotFoundError extends WorkflowStoreError {
|
|
|
106
106
|
this.coordinate = coordinate;
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
|
-
/**
|
|
109
|
+
/**
|
|
110
|
+
* An index entry names a digest whose object is missing or failed verification,
|
|
111
|
+
* or a verified object pins a lock target (`dependency-missing`, carrying the
|
|
112
|
+
* CHILD digest) that no configured store root holds.
|
|
113
|
+
*/
|
|
110
114
|
export class StoreIntegrityError extends WorkflowStoreError {
|
|
111
115
|
digest;
|
|
112
116
|
constructor(code, digest, detail) {
|
package/dist/src/types.d.ts
CHANGED
|
@@ -325,6 +325,17 @@ export interface Order {
|
|
|
325
325
|
/** Opaque proof/signature placeholder for future WP-A4-signed dynamic
|
|
326
326
|
* consume values. Data-only today — same contract as `owes[].proof`. */
|
|
327
327
|
consumesProof?: string;
|
|
328
|
+
/** Calls-boundary relay hints keyed by the parent artifact path: for a
|
|
329
|
+
* consumed path a `calls:` step produced, the child definition digest the
|
|
330
|
+
* parent pins, the pinned child outcome version, and the child outcome stem
|
|
331
|
+
* whose signed submission record `consumesProof` carries under the parent
|
|
332
|
+
* path. Data-only for the engine — a relay-aware hub projects it and the
|
|
333
|
+
* consuming worker verifies it against local definition bytes. */
|
|
334
|
+
consumesProofRelay?: Record<string, {
|
|
335
|
+
childDefDigest: string;
|
|
336
|
+
childVersion: number;
|
|
337
|
+
childOutcome: string;
|
|
338
|
+
}>;
|
|
328
339
|
/** The trigger that woke this firing (§21). Absent = 'inputsGreen'. */
|
|
329
340
|
cause?: FiringTrigger;
|
|
330
341
|
}
|
package/docs/bundles.md
CHANGED
|
@@ -172,7 +172,11 @@ Using that worker's scoped bearer, it reads raw canonical bytes from
|
|
|
172
172
|
`GET /api/publications/<digest>`, and optional origin evidence from
|
|
173
173
|
`GET /api/origins/<digest>`, then installs only into the global store. The
|
|
174
174
|
original store lookup is retried once after a successful install; a store hit
|
|
175
|
-
does no hub I/O.
|
|
175
|
+
does no hub I/O. The same recovery serves a lock-pinned `calls:` child that a
|
|
176
|
+
verified parent needs but neither store holds: the worker asks the hub for the
|
|
177
|
+
CHILD's digest, installs it, and re-resolves the parent, and a child the hub
|
|
178
|
+
cannot supply is the named `dependency-missing` store refusal, not a
|
|
179
|
+
corrupt-object verdict.
|
|
176
180
|
|
|
177
181
|
Recovery is fail-closed. The installer compares the ingested canonical digest
|
|
178
182
|
with the order digest before any object or index mutation, and the required
|
package/docs/cli.md
CHANGED
|
@@ -305,6 +305,7 @@ holds `credentials.json`, `allowed_signers`, `org-root.pub`, `grants/`, and
|
|
|
305
305
|
```text
|
|
306
306
|
owenloop shift start <crew...> [--all] [--origin <url>] [--as <account>] [--name <n>]
|
|
307
307
|
[--cap <n>] [--max-agents <n>] [--exec-reserve <n>] [--local-queue-hold <ms>] [--poll-interval <ms>] [--once]
|
|
308
|
+
[--disk-floor <bytes>]
|
|
308
309
|
[--cache-dir <p>] [--state-dir <p>] [--log-dir <p>] [--log-max-age <ms>]
|
|
309
310
|
[--work-root <dir>]...
|
|
310
311
|
```
|
|
@@ -323,6 +324,7 @@ one loop sweep and exits instead of keeping the foreground daemon running.
|
|
|
323
324
|
| `--cap <n>` | dispatch capacity; precedence is flag, then `settings.dispatchCap`, then `3` |
|
|
324
325
|
| `--max-agents <n>` | concurrent agent limit; precedence is flag, then `settings.maxConcurrentAgents`, then `4` |
|
|
325
326
|
| `--exec-reserve <n>` | slots inside `--cap` that `agent-run` children may never occupy, so an exec/command order always has room; precedence is flag, then `settings.execReserve`, then `1`. Clamped to `cap - 1`, so a `--cap 1` shift gets no reserve. `0` disables the reserve and lets agents fill the whole cap. This does not raise the total child ceiling — `--cap` still bounds every child. |
|
|
327
|
+
| `--disk-floor <bytes>` | free space the shift requires on the volume holding its work root before it will START another order; precedence is flag, then `settings.diskFloorBytes`, then `1073741824` (1 GiB). A shift below the floor keeps polling and declines new work, writing one `low-disk` record per episode, and resumes by itself when space returns; children already running are left alone. `0` disables the check. This is a floor for starting work, not a promise that a particular step will fit. |
|
|
326
328
|
| `--local-queue-hold <ms>` | how long to retain a claim this shift cannot dispatch before returning it to the hub; precedence is flag, then `settings.localQueueHoldMs`, then `0`. The value is clamped to 90 seconds. `0` means the shift never holds an undispatchable claim locally, so another daemon can be offered it immediately. |
|
|
327
329
|
| `--poll-interval <ms>` | loop polling interval; defaults to `5000` milliseconds |
|
|
328
330
|
| `--once` | run one loop sweep and exit; without it, keep the daemon in the foreground |
|
|
@@ -587,16 +589,17 @@ either `exec` or `agent-run`:
|
|
|
587
589
|
- `bundle-miss`: `{ "type": "bundle-miss", "workflow": "...", "def": "..." }` — a legacy order named a def with no cached bundle, so it was left for hub pickup
|
|
588
590
|
- `order-dropped`: `{ "type": "order-dropped", "workflow": "...", "run": "...", "step": "...", "reason": "unsupported-worker", "message": "..." }` — the shift refused one order. Match on `reason` (`malformed-digest`, `malformed-worker`, `unsupported-worker`, `verification-failed`, `metadata-unavailable`, `agent-lane-closed`, `dispatch-cap-full`, `agent-cap-full`, `claim-expired`); display `message`. The capacity, expiry, and `agent-lane-closed` reasons return the claim to the hub; malformed and unsupported reasons leave it for the pickup window.
|
|
589
591
|
- `ended`: `{ "type": "ended" }`, delivered to a parked `next` when `shift end` explicitly shuts down the daemon
|
|
592
|
+
- `wedged`: `{ "type": "wedged", "faults": [{ "kind": "missing", "role": "temp-dir", "path": "...", "message": "..." }], "streak": 3 }` — the shift stopped because the MACHINE it runs on is broken, and the process exits non-zero straight after. `faults` is never empty; display each `message`, which names the path and the operator fix. `streak` is how many consecutive hub calls failed before the check ran, and is `0` for the check a shift makes at start. A shift that cannot reach the hub does NOT produce this — a hub outage or a rate-limit ban recovers on its own, and the shift keeps polling through it. This record means a human must change something on the host.
|
|
590
593
|
|
|
591
594
|
Every event above is also appended to `<log-dir>/shift.log` as JSON Lines, which
|
|
592
|
-
is how they survive the daemon. **
|
|
595
|
+
is how they survive the daemon. **Five further record types exist in
|
|
593
596
|
`shift.log` and are never delivered over the socket** — `parked`, `capacity`,
|
|
594
|
-
`hub-error`,
|
|
597
|
+
`hub-error`, `event-queue-overflow`, and `low-disk`.
|
|
595
598
|
|
|
596
599
|
An idle `shift next` must block until there is work to report, and each of those
|
|
597
|
-
|
|
598
|
-
that the shift is full, a failed call to the hub,
|
|
599
|
-
queue itself. `parked` and `capacity` are also redundant on the wire — the
|
|
600
|
+
five would satisfy it with news that no work moved: a startup record, a report
|
|
601
|
+
that the shift is full, a failed call to the hub, a record about the socket
|
|
602
|
+
queue itself, or a report that the disk is too full to start anything. `parked` and `capacity` are also redundant on the wire — the
|
|
600
603
|
response above already carries live `cap`, `free`, and `running`, which is
|
|
601
604
|
exactly what a `capacity` record restates. `hub-error` is level-triggered at the
|
|
602
605
|
poll interval, so an unreachable hub would otherwise fill the 1000-slot socket
|
package/docs/crypto.md
CHANGED
|
@@ -843,6 +843,52 @@ scope-checked signer. The gate runs before the floor-derived policy value is
|
|
|
843
843
|
read and fails closed regardless of local policy, including `off`, and
|
|
844
844
|
regardless of any floor. A floor cannot relax this rule.
|
|
845
845
|
|
|
846
|
+
### Calls boundary
|
|
847
|
+
|
|
848
|
+
An artifact a `calls:` step produces has no submission record of its own: the
|
|
849
|
+
engine folds the child workflow's outcome into the parent path without a
|
|
850
|
+
`submit`, so the parent path is `absent` by construction and a command consumer
|
|
851
|
+
of it could never run. A relay-aware hub places the CHILD's own signed
|
|
852
|
+
submission record under the parent path in `consumesProof` and names the child
|
|
853
|
+
in `consumesProofRelay` (keyed by the parent path: `childDefDigest`,
|
|
854
|
+
`childVersion`, `childOutcome`). The command worker admits that record only when
|
|
855
|
+
every hint is corroborated by bytes it verified itself:
|
|
856
|
+
|
|
857
|
+
- **Corroborated from local bytes.** The verified parent definition — selected
|
|
858
|
+
by the order's `defDigest` from the local workflow store, never hub-supplied
|
|
859
|
+
step text — must produce the path through a `calls:` step. The child that step
|
|
860
|
+
resolves to in the same verified closure (the bundle lock for a qualified
|
|
861
|
+
target, the sibling inside the parent's own bundle for a bare one) must carry
|
|
862
|
+
exactly the relayed `childDefDigest`, and its declared outcome (`outputs[0]`)
|
|
863
|
+
must equal the relayed `childOutcome`.
|
|
864
|
+
- **Verified on the record.** The record's signed `defDigest` must equal that
|
|
865
|
+
child digest and the record must cover the child outcome stem. The consumed
|
|
866
|
+
value's digest, the expected version, the producer's enrollment chain, and the
|
|
867
|
+
scope demand are then checked exactly as for a directly produced artifact.
|
|
868
|
+
The expected version is the relayed `childVersion`, the pinned child outcome
|
|
869
|
+
version; the parent's `consumedFingerprint` entry counts the parent artifact
|
|
870
|
+
and is a different number, so a coincidental match is never relied on. Like
|
|
871
|
+
`consumedFingerprint`, the pin is hub data; the trust anchor stays the
|
|
872
|
+
signature plus the verified definition bytes.
|
|
873
|
+
|
|
874
|
+
Any mismatch is `invalid` under the `calls` link and refuses under the hard
|
|
875
|
+
rule. The boundary is exclusive in both directions: a path the verified
|
|
876
|
+
definition produces through a `calls:` step accepts only the relay contract, so
|
|
877
|
+
an order carrying no `consumesProofRelay` entry for it is `invalid` under the
|
|
878
|
+
`calls` link and never falls through to ordinary verification (which does not
|
|
879
|
+
check a record's signed definition digest, so any trusted record covering the
|
|
880
|
+
parent path with a matching value and version could otherwise stand in for the
|
|
881
|
+
child's outcome). A relay offered for a path the verified definition does not
|
|
882
|
+
produce through a `calls:` step is likewise `invalid`, record or no record.
|
|
883
|
+
Hints without a record on a calls-produced path leave it `absent`. A relay
|
|
884
|
+
reaching a consumer that holds no verified definition (an agent worker) is
|
|
885
|
+
`unverifiable` and follows the configured artifact policy like any other
|
|
886
|
+
non-verified verdict.
|
|
887
|
+
Nothing in the relay relaxes the hard rule for a non-calls path, and no policy,
|
|
888
|
+
floor, or environment variable can. Unchanged residual: a relayed record, like
|
|
889
|
+
every submission record, is bound to the producing run and artifact version,
|
|
890
|
+
not to the consuming order.
|
|
891
|
+
|
|
846
892
|
## Out of scope (future work)
|
|
847
893
|
|
|
848
894
|
Publish-time author-side DSSE signing is implemented by `owenloop publish`.
|