owenloop 0.5.28 → 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 CHANGED
@@ -4,6 +4,13 @@ All notable changes to this project are documented here. The format is based on
4
4
  [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project
5
5
  adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [0.5.29](https://github.com/typicalday/owenloop/compare/v0.5.28...v0.5.29) (2026-09-05)
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * **work:** accept a relayed child proof for a calls-produced consumed artifact ([#310](https://github.com/typicalday/owenloop/issues/310)) ([7a185f6](https://github.com/typicalday/owenloop/commit/7a185f6cc42ba712db675d6c14f1d9ef1fdd9e8a))
13
+
7
14
  ## [0.5.28](https://github.com/typicalday/owenloop/compare/v0.5.27...v0.5.28) (2026-09-05)
8
15
 
9
16
 
@@ -37,9 +37,29 @@ export interface CreateConsumedVerifierArgs {
37
37
  /** Optional warning sink; the returned warnings remain authoritative for callers. */
38
38
  warn?: (line: string) => void;
39
39
  }
40
- export type ConsumedVerifier = (order: OrderPacket, opts: {
40
+ /** The calls-boundary facts for one consumed path, read by the caller from
41
+ * its VERIFIED local definition bytes: the parent's `calls:` step that
42
+ * produces the path, the exact child definition digest the parent pins, and
43
+ * the child's outcome stem. Never derived from the order. */
44
+ export interface VerifiedCallsProducer {
45
+ /** The parent step whose `calls:` produces the consumed path. */
46
+ step: string;
47
+ /** The `calls:` target as authored on that step. */
48
+ target: string;
49
+ /** Exact definition digest the verified parent pins the child at. */
50
+ childDefDigest: string;
51
+ /** The verified child definition's single outcome stem (`outputs[0]`). */
52
+ childOutcome: string;
53
+ }
54
+ export interface ConsumedVerifierOptions {
41
55
  hardRule: boolean;
42
- }) => Promise<ConsumedGateResult | ConsumedGateRefusal>;
56
+ /** Calls-boundary context keyed by consumed path. Present only when the
57
+ * caller holds the verified definition (the command resolver). Without it
58
+ * a relayed record is `unverifiable`, never admitted: the hub's hints alone
59
+ * cannot say which child a parent pins. */
60
+ callsProducers?: Readonly<Record<string, VerifiedCallsProducer>>;
61
+ }
62
+ export type ConsumedVerifier = (order: OrderPacket, opts: ConsumedVerifierOptions) => Promise<ConsumedGateResult | ConsumedGateRefusal>;
43
63
  /** Create a verifier bound to one injected local environment and clock. */
44
64
  export declare function createConsumedVerifier(args: CreateConsumedVerifierArgs): ConsumedVerifier;
45
65
  export declare function resetConsumedVerifierWarningsForTests(): void;
@@ -17,7 +17,7 @@ function errorText(error) {
17
17
  return error instanceof Error ? error.message : String(error);
18
18
  }
19
19
  function linkFor(verdict) {
20
- const match = verdict.reason.match(/^(no-proof|signature|value-digest|version|chain|scope|prerequisite):/);
20
+ const match = verdict.reason.match(/^(no-proof|signature|value-digest|version|chain|scope|prerequisite|calls):/);
21
21
  if (match !== null)
22
22
  return match[1];
23
23
  return verdict.kind === 'invalid' ? 'signature' : 'prerequisite';
@@ -81,6 +81,88 @@ function parseProofMap(order) {
81
81
  }
82
82
  return { kind: 'ok', proofs };
83
83
  }
84
+ function parseRelayMap(order) {
85
+ const raw = order.consumesProofRelay;
86
+ if (raw === undefined)
87
+ return { kind: 'ok', relays: {} };
88
+ if (typeof raw !== 'object' || raw === null || Array.isArray(raw)) {
89
+ return { kind: 'unverifiable', reason: 'prerequisite: consumesProofRelay is not a JSON object' };
90
+ }
91
+ const relays = {};
92
+ for (const [path, value] of Object.entries(raw)) {
93
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) {
94
+ return { kind: 'unverifiable', reason: `prerequisite: consumesProofRelay entry for artifact '${path}' is not an object` };
95
+ }
96
+ const entry = value;
97
+ if (typeof entry.childDefDigest !== 'string' || entry.childDefDigest === '') {
98
+ return { kind: 'unverifiable', reason: `prerequisite: consumesProofRelay entry for artifact '${path}' has no non-empty string 'childDefDigest'` };
99
+ }
100
+ if (typeof entry.childVersion !== 'number' || !Number.isInteger(entry.childVersion) || entry.childVersion < 0) {
101
+ return { kind: 'unverifiable', reason: `prerequisite: consumesProofRelay entry for artifact '${path}' has no non-negative integer 'childVersion'` };
102
+ }
103
+ if (typeof entry.childOutcome !== 'string' || entry.childOutcome === '') {
104
+ return { kind: 'unverifiable', reason: `prerequisite: consumesProofRelay entry for artifact '${path}' has no non-empty string 'childOutcome'` };
105
+ }
106
+ relays[path] = { childDefDigest: entry.childDefDigest, childVersion: entry.childVersion, childOutcome: entry.childOutcome };
107
+ }
108
+ return { kind: 'ok', relays };
109
+ }
110
+ function callsBoundary(path, relay, producers) {
111
+ if (producers === undefined) {
112
+ // A consumer with no verified definition (an agent worker) can neither
113
+ // confirm nor deny that the path is calls-produced: without a relay the
114
+ // path is an ordinary one to it, and with one it cannot corroborate.
115
+ if (relay === undefined)
116
+ return { kind: 'ordinary' };
117
+ return {
118
+ kind: 'uncorroborated',
119
+ verdict: {
120
+ kind: 'unverifiable',
121
+ reason: `prerequisite: artifact '${path}' carries a calls-boundary relay, but this consumer holds no verified definition to corroborate the calls child against`,
122
+ },
123
+ };
124
+ }
125
+ const producer = producers[path];
126
+ if (producer === undefined) {
127
+ if (relay === undefined)
128
+ return { kind: 'ordinary' };
129
+ return {
130
+ kind: 'refused',
131
+ verdict: {
132
+ kind: 'invalid',
133
+ reason: `calls: artifact '${path}' carries a calls-boundary relay, but the verified definition does not produce it through a calls: step`,
134
+ },
135
+ };
136
+ }
137
+ if (relay === undefined) {
138
+ return {
139
+ kind: 'refused',
140
+ verdict: {
141
+ kind: 'invalid',
142
+ reason: `calls: artifact '${path}' is produced by calls: step '${producer.step}' (${producer.target}), so only a relayed child proof can prove it, but the order carries no consumesProofRelay entry for it`,
143
+ },
144
+ };
145
+ }
146
+ if (relay.childDefDigest !== producer.childDefDigest) {
147
+ return {
148
+ kind: 'refused',
149
+ verdict: {
150
+ kind: 'invalid',
151
+ reason: `calls: relay for artifact '${path}' names child definition digest '${relay.childDefDigest}', but the verified definition pins calls: step '${producer.step}' (${producer.target}) at '${producer.childDefDigest}'`,
152
+ },
153
+ };
154
+ }
155
+ if (relay.childOutcome !== producer.childOutcome) {
156
+ return {
157
+ kind: 'refused',
158
+ verdict: {
159
+ kind: 'invalid',
160
+ reason: `calls: relay for artifact '${path}' names child outcome '${relay.childOutcome}', but the verified child definition for calls: step '${producer.step}' declares outcome '${producer.childOutcome}'`,
161
+ },
162
+ };
163
+ }
164
+ return { kind: 'relay', relay, producer };
165
+ }
84
166
  /** Create a verifier bound to one injected local environment and clock. */
85
167
  export function createConsumedVerifier(args) {
86
168
  const policy = mergePolicyFloorWithLocal('off', args.policyFloor, 'off', resolveArtifactPolicy(args.env, args.artifactPolicy)).artifactPolicy;
@@ -111,6 +193,7 @@ export function createConsumedVerifier(args) {
111
193
  : undefined;
112
194
  const rootPublicKey = root.kind === 'present' ? root.publicKey : '';
113
195
  const proofs = parseProofMap(order);
196
+ const relays = parseRelayMap(order);
114
197
  const warnings = [];
115
198
  const chainCache = new Map();
116
199
  const chainValidator = (input, options) => {
@@ -139,18 +222,54 @@ export function createConsumedVerifier(args) {
139
222
  else if (proofs.kind === 'unverifiable') {
140
223
  verdict = { kind: 'unverifiable', reason: proofs.reason };
141
224
  }
225
+ else if (relays.kind === 'unverifiable') {
226
+ verdict = { kind: 'unverifiable', reason: relays.reason };
227
+ }
142
228
  else {
143
- verdict = await verifyConsumed({
144
- path,
145
- value,
146
- ...(proofs.proofs[path] === undefined ? {} : { proof: proofs.proofs[path] }),
147
- ...(order.consumedFingerprint?.[path] === undefined ? {} : { expectedVersion: order.consumedFingerprint[path] }),
148
- orgRootPublicKey: rootPublicKey,
149
- grants,
150
- revocations,
151
- at,
152
- demand: args.demand ?? {},
153
- }, verifierOptions);
229
+ // The calls boundary is settled before any record is consulted: a
230
+ // calls-produced path without a relay, or a relay on a non-calls
231
+ // path, is refused here and never reaches ordinary verification.
232
+ const boundary = callsBoundary(path, relays.relays[path], opts.callsProducers);
233
+ if (boundary.kind === 'refused') {
234
+ verdict = boundary.verdict;
235
+ }
236
+ else if (boundary.kind !== 'ordinary' && proofs.proofs[path] === undefined) {
237
+ // Hints without a record prove nothing: the path stays unproven.
238
+ verdict = { kind: 'absent' };
239
+ }
240
+ else if (boundary.kind === 'uncorroborated') {
241
+ verdict = boundary.verdict;
242
+ }
243
+ else if (boundary.kind === 'relay') {
244
+ verdict = await verifyConsumed({
245
+ path,
246
+ value,
247
+ proof: proofs.proofs[path],
248
+ // The pinned CHILD outcome version. The parent's
249
+ // consumedFingerprint[path] counts the parent artifact and is a
250
+ // different number; a coincidental match must never be relied on.
251
+ expectedVersion: boundary.relay.childVersion,
252
+ relay: { childDefDigest: boundary.producer.childDefDigest, childOutcome: boundary.producer.childOutcome },
253
+ orgRootPublicKey: rootPublicKey,
254
+ grants,
255
+ revocations,
256
+ at,
257
+ demand: args.demand ?? {},
258
+ }, verifierOptions);
259
+ }
260
+ else {
261
+ verdict = await verifyConsumed({
262
+ path,
263
+ value,
264
+ ...(proofs.proofs[path] === undefined ? {} : { proof: proofs.proofs[path] }),
265
+ ...(order.consumedFingerprint?.[path] === undefined ? {} : { expectedVersion: order.consumedFingerprint[path] }),
266
+ orgRootPublicKey: rootPublicKey,
267
+ grants,
268
+ revocations,
269
+ at,
270
+ demand: args.demand ?? {},
271
+ }, verifierOptions);
272
+ }
154
273
  }
155
274
  const result = policyOutcome(order, opts.hardRule, policy, path, verdict, warnings);
156
275
  if (result !== undefined)
@@ -222,14 +222,54 @@ export function createStoreInstructionResolver(options) {
222
222
  reasons: [],
223
223
  })),
224
224
  });
225
- const gateConsumed = async (order, hardRule) => {
225
+ /**
226
+ * Calls boundary. For every consumed path the VERIFIED definition produces
227
+ * through a `calls:` step, read the facts a relayed child record is checked
228
+ * against — the pinned child definition digest and the child's outcome stem
229
+ * — from the same verified store closure the definition came from. Nothing
230
+ * here consults hub-supplied step text. A source without a dependency
231
+ * closure yields no context, and the verifier then treats any relay as
232
+ * unverifiable rather than guessing.
233
+ */
234
+ const verifiedCallsProducers = (order, resolved) => {
235
+ if (source.getVerifiedCallsChild === undefined)
236
+ return { ok: true, producers: undefined };
237
+ const producers = {};
238
+ for (const path of Object.keys(order.consumes)) {
239
+ const callsStep = resolved.definition.steps.find((step) => step.calls !== undefined && step.produces.some((produce) => produce.stem === path));
240
+ if (callsStep?.calls === undefined)
241
+ continue;
242
+ const relayed = order.consumesProofRelay?.[path] !== undefined;
243
+ const child = source.getVerifiedCallsChild(order.defDigest, order.step, callsStep.name);
244
+ if (child === undefined) {
245
+ if (!relayed)
246
+ continue;
247
+ return refusal('integrity', order, `the verified definition produces artifact '${path}' through calls: step '${callsStep.name}' (${callsStep.calls}), but its child definition could not be resolved from the verified store closure`);
248
+ }
249
+ const childOutcome = child.definition.outputs?.[0];
250
+ if (childOutcome === undefined) {
251
+ if (!relayed)
252
+ continue;
253
+ return refusal('integrity', order, `the verified definition produces artifact '${path}' through calls: step '${callsStep.name}' (${callsStep.calls}), but the verified child definition '${child.definition.name}' declares no outcome`);
254
+ }
255
+ producers[path] = { step: callsStep.name, target: callsStep.calls, childDefDigest: child.bundleDigest, childOutcome };
256
+ }
257
+ return { ok: true, producers };
258
+ };
259
+ const gateConsumed = async (order, hardRule, resolved) => {
226
260
  if (!hasConsumedData(order))
227
261
  return undefined;
228
262
  if (options.consumedVerifier === undefined) {
229
263
  return refusal('unverified-consumed', order, 'consume-side verifier is not configured; dynamic values cannot be admitted to a command worker');
230
264
  }
265
+ const callsContext = verifiedCallsProducers(order, resolved);
266
+ if (!callsContext.ok)
267
+ return callsContext;
231
268
  try {
232
- const checked = await options.consumedVerifier(commandConsumedOrder(order), { hardRule });
269
+ const checked = await options.consumedVerifier(commandConsumedOrder(order), {
270
+ hardRule,
271
+ ...(callsContext.producers === undefined ? {} : { callsProducers: callsContext.producers }),
272
+ });
233
273
  if (!checked.ok)
234
274
  return refusal('unverified-consumed', order, checked.reason);
235
275
  for (const warning of checked.warnings)
@@ -276,7 +316,7 @@ export function createStoreInstructionResolver(options) {
276
316
  // absent, unverifiable, or invalid dynamic evidence under
277
317
  // artifactPolicy=off; otherwise a future command interpolation could
278
318
  // carry an unverified value into `/bin/sh -c`.
279
- const consumedRefusal = await gateConsumed(order, true);
319
+ const consumedRefusal = await gateConsumed(order, true, resolved);
280
320
  if (consumedRefusal !== undefined)
281
321
  return consumedRefusal;
282
322
  const originRefusal = await checkOrigin(order, resolved);
@@ -257,6 +257,20 @@ export interface OrderPacket {
257
257
  * proof-aware hub. Absent from any hub that does not store submit proofs;
258
258
  * consume-side verification then reports the artifact as unproven. */
259
259
  consumesProof?: string;
260
+ /** Calls-boundary relay hints, keyed by the PARENT artifact path. When a
261
+ * consumed path was produced by a `calls:` step, no submission record can
262
+ * exist for the parent path: the engine folds the child's outcome into it
263
+ * without a `submit`. A relay-aware hub places the CHILD's own signed
264
+ * submission record under the parent path in `consumesProof` and names
265
+ * here the child it came from: the child definition digest the parent pins,
266
+ * the pinned child outcome version, and the child outcome stem. A worker
267
+ * corroborates every hint against its verified local definition bytes
268
+ * before trusting the record; the hints never admit a proof-less path. */
269
+ consumesProofRelay?: Record<string, {
270
+ childDefDigest: string;
271
+ childVersion: number;
272
+ childOutcome: string;
273
+ }>;
260
274
  /** The owed outputs and their reason threads. */
261
275
  owes: Array<{
262
276
  path: string;
@@ -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
- const produced = record.produced.find((entry) => entry.artifact === input.path);
213
- if (produced === undefined)
214
- return invalid(`signature: signed submission record does not cover artifact '${input.path}'`);
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
- throw new StoreIntegrityError('object-corrupt', childDigest, `locked calls target '${target}' digest ${childDigest} is absent from every configured workflow store root`);
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 primeOnce(requestedDigest);
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 primeOnce(requestedDigest);
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
- /** An index entry names a digest whose object is missing or failed verification. */
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 {
@@ -106,7 +106,11 @@ export class StoreNotFoundError extends WorkflowStoreError {
106
106
  this.coordinate = coordinate;
107
107
  }
108
108
  }
109
- /** An index entry names a digest whose object is missing or failed verification. */
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) {
@@ -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/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`.
@@ -303,8 +303,8 @@ Required fields are `run`, `workflow`, `step`, `key`, `defDigest`, `inputs`,
303
303
  `outputs`, `consumes`, and `owes`.
304
304
 
305
305
  Optional fields are `index`, `workdir`, `model`, `worker`, `judge`, `spec`, `x`,
306
- `consumedFingerprint`, `consumesProof`, `cause`, `capabilities`, `crews`,
307
- `reroutedFrom`, `modifier`, and `escalated`. `workdir` may be authored as a
306
+ `consumedFingerprint`, `consumesProof`, `consumesProofRelay`, `cause`,
307
+ `capabilities`, `crews`, `reroutedFrom`, `modifier`, and `escalated`. `workdir` may be authored as a
308
308
  literal `workdir:` or resolved by the engine from a step's `workdirFrom:`, whose
309
309
  stem names either a consumed artifact or a declared input; the Order wire shape
310
310
  remains unchanged. No proof field covers `workdir` in any case.
@@ -354,6 +354,19 @@ projection. A consuming driver treats a missing entry as the `absent` verdict
354
354
  and applies the configured artifact policy rather than stripping that artifact
355
355
  from the order.
356
356
 
357
+ `consumesProofRelay` is a plain (not serialized) map from a consumed artifact
358
+ path to `{ childDefDigest, childVersion, childOutcome }`. It is present only
359
+ for a path a `calls:` step produced: the engine folds the child workflow's
360
+ outcome into that path without a `submit`, so no submission record exists for
361
+ the path itself, and a relay-aware hub places the CHILD's own signed record
362
+ under the parent path in `consumesProof` while this map names the child it came
363
+ from — the child definition digest the parent pins, the pinned child outcome
364
+ version (the parent artifact's `__child_outcome_version__` fingerprint), and the
365
+ child outcome stem. The hints are corroborated by the consumer against its own
366
+ verified definition bytes before the record is examined; they never admit a path
367
+ that carries no record, and a driver that does not understand the field ignores
368
+ it. Details in `docs/crypto.md` under "Calls boundary".
369
+
357
370
  `owes[].proof`, when present, uses the same serialized DSSE envelope format. The
358
371
  signed `submission.v1` record contains one `produced[]` entry for the owed path;
359
372
  its `valueDigest` covers the complete `owes[].reasons` array at signing time.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "owenloop",
3
- "version": "0.5.28",
3
+ "version": "0.5.29",
4
4
  "description": "Deterministic rails for agentic workflows. Declare steps and dependencies; the engine guarantees order, redoes what changes invalidate, and stops what keeps failing — instead of hoping the agent follows through.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "typicalday",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "owenloop",
3
- "version": "0.5.28",
3
+ "version": "0.5.29",
4
4
  "description": "Claude Code driver for owenloop — cross-harness shift and conduct skills driven by the owenloop CLI, plus one hub control-plane MCP server backing an author skill and a fallback worker, for conducting and authoring workflows against your hosted owenloop server.",
5
5
  "author": {
6
6
  "name": "Typical Day"
@@ -7,7 +7,7 @@
7
7
  "mcp"
8
8
  ],
9
9
  "env": {
10
- "OWENLOOP_PLUGIN_VERSION": "0.5.28"
10
+ "OWENLOOP_PLUGIN_VERSION": "0.5.29"
11
11
  }
12
12
  }
13
13
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "owenloop",
3
- "version": "0.5.28",
3
+ "version": "0.5.29",
4
4
  "description": "Codex plugin for the owenloop workflow engine.",
5
5
  "skills": "./skills/",
6
6
  "mcpServers": "./.mcp.json"
@@ -6,7 +6,7 @@
6
6
  "mcp"
7
7
  ],
8
8
  "env": {
9
- "OWENLOOP_PLUGIN_VERSION": "0.5.28"
9
+ "OWENLOOP_PLUGIN_VERSION": "0.5.29"
10
10
  },
11
11
  "env_vars": [
12
12
  "HOME",