owenloop 0.5.28 → 0.5.30

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,20 @@ 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.30](https://github.com/typicalday/owenloop/compare/v0.5.29...v0.5.30) (2026-09-05)
8
+
9
+
10
+ ### Features
11
+
12
+ * **engine:** send a refused path's previous value back with the re-offer ([#312](https://github.com/typicalday/owenloop/issues/312)) ([d697b6e](https://github.com/typicalday/owenloop/commit/d697b6ebb08538fa3a79f9eee0bd648fa13620a5))
13
+
14
+ ## [0.5.29](https://github.com/typicalday/owenloop/compare/v0.5.28...v0.5.29) (2026-09-05)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * **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))
20
+
7
21
  ## [0.5.28](https://github.com/typicalday/owenloop/compare/v0.5.27...v0.5.28) (2026-09-05)
8
22
 
9
23
 
@@ -471,6 +471,63 @@ export function renderRejection(spec) {
471
471
  ].join('\n\n');
472
472
  return { message, count, ...(newest !== undefined ? { deliveredReasonAt: newest } : {}) };
473
473
  }
474
+ /**
475
+ * Render what the refused submission actually SAID, for the paths the cold
476
+ * replay is about to show reasons for.
477
+ *
478
+ * WHY ONLY THE COLD PATH NEEDS THIS. A resumed session still holds its own
479
+ * prior submission, so `renderRejection` alone is enough there. A cold replay
480
+ * has no session: `renderReplayBrief`'s own contract is that without the
481
+ * reasons "the fresh agent repeats the rejected submission verbatim" -- but a
482
+ * fresh agent given only reasons cannot repeat it either. It has to rebuild the
483
+ * whole value from the brief to change the one part that was called out, and
484
+ * the rebuild quietly loses everything the reader did not object to. Sending
485
+ * the value back is what makes "keep everything you already have that was not
486
+ * called out above", which the rejection body already says, a thing the agent
487
+ * is able to do.
488
+ *
489
+ * SCOPE. Only paths that both carry a `previousValue` and have fresh reasons in
490
+ * this delta -- a value shown next to no reason is material with no correction
491
+ * attached, and the agent cannot tell what to do with it.
492
+ *
493
+ * HONESTY. The heading does not call this "the rejected value". After a schema
494
+ * reject nothing was committed, so what the hub sends is the last value that
495
+ * did commit, which may be older than the refusal or absent entirely. The
496
+ * wording says what the engine can actually promise.
497
+ */
498
+ function renderPreviousValues(spec) {
499
+ const since = spec.deliveredReasonAt;
500
+ const wanted = spec.paths === undefined ? undefined : new Set(spec.paths);
501
+ const sections = [];
502
+ for (const owed of spec.packet.owes) {
503
+ if (wanted !== undefined && !wanted.has(owed.path))
504
+ continue;
505
+ if (owed.previousValue === undefined)
506
+ continue;
507
+ const fresh = owed.reasons.filter((r) => since === undefined || r.at > since);
508
+ if (fresh.length === 0)
509
+ continue;
510
+ let body;
511
+ try {
512
+ body = JSON.stringify(owed.previousValue, null, 2) ?? String(owed.previousValue);
513
+ }
514
+ catch {
515
+ // A value that arrived as JSON cannot cycle, but a projecting layer is
516
+ // free to hand us anything. Dropping the section beats failing the replay.
517
+ continue;
518
+ }
519
+ sections.push(`The value \`${owed.path}\` currently holds:\n\n\`\`\`json\n${body}\n\`\`\``);
520
+ }
521
+ if (sections.length === 0)
522
+ return '';
523
+ return [
524
+ 'What is already on the owed paths, so you can revise it rather than rebuild it:',
525
+ ...sections,
526
+ 'This is what the path holds now, which is the value that was refused when the'
527
+ + ' refusal came from a reader. When it came from the schema check the value was'
528
+ + ' never committed, so what you see is the last one that was.',
529
+ ].join('\n\n');
530
+ }
474
531
  /**
475
532
  * Assemble a COLD-REPLAY brief: the ordinary rendered brief plus the same
476
533
  * rejection body as a trailing section.
@@ -497,15 +554,27 @@ export function renderReplayBrief(brief, spec) {
497
554
  const full = renderRejection(spec);
498
555
  if (full.message === '')
499
556
  return brief;
500
- const join = (body, dropped) => {
557
+ const join = (body, dropped, values) => {
501
558
  const note = dropped > 0
502
559
  ? `\n\n(${dropped} older rejection reason${dropped === 1 ? '' : 's'} omitted to fit the context budget.)`
503
560
  : '';
504
- return `${brief}\n\n---\n\n${body}${note}`;
561
+ const prior = values === '' ? '' : `${values}\n\n---\n\n`;
562
+ return `${brief}\n\n---\n\n${prior}${body}${note}`;
505
563
  };
506
- let assembled = join(full.message, 0);
564
+ const values = renderPreviousValues(spec);
565
+ let assembled = join(full.message, 0, values);
507
566
  if (estimateTokens(assembled) <= REPLAY_TOKEN_BUDGET)
508
567
  return assembled;
568
+ // First thing over budget: the previous values, whole. They are MATERIAL,
569
+ // and the reasons are the INSTRUCTION -- an agent holding the corrections
570
+ // can still rebuild the value, while one holding the value and no correction
571
+ // cannot know what to change. Same ordering principle as the brief itself,
572
+ // which is never trimmed: keep whatever the agent cannot work without.
573
+ if (values !== '') {
574
+ assembled = join(full.message, 0, '');
575
+ if (estimateTokens(assembled) <= REPLAY_TOKEN_BUDGET)
576
+ return assembled;
577
+ }
509
578
  // Over budget: re-render with progressively fewer reasons, oldest dropped
510
579
  // first. `ordered` is every candidate entry in ascending `at`, so slicing off
511
580
  // the FRONT drops the oldest and keeps whole entries.
@@ -529,7 +598,7 @@ export function renderReplayBrief(brief, spec) {
529
598
  });
530
599
  if (trimmed.message === '')
531
600
  break;
532
- assembled = join(trimmed.message, drop);
601
+ assembled = join(trimmed.message, drop, '');
533
602
  if (estimateTokens(assembled) <= REPLAY_TOKEN_BUDGET)
534
603
  return assembled;
535
604
  }
@@ -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;
@@ -269,6 +283,23 @@ export interface OrderPacket {
269
283
  judgmentRejects: number;
270
284
  schemaRejects: number;
271
285
  reasons: ReasonEntry[];
286
+ /**
287
+ * The value this path already holds, projected by a hub new enough to send
288
+ * it and ONLY on a re-offer whose reason thread is non-empty. Absent on a
289
+ * first offer, absent from an older hub, and absent when the refusal never
290
+ * committed a value.
291
+ *
292
+ * It is the REFUSED value only after a judgment or human reject, which
293
+ * follow a commit. A schema reject refuses the write, so after one this
294
+ * carries the last value that did commit, or nothing. Read `reasons` when
295
+ * the distinction matters; the engine's contract is on `Order.owes[]` in
296
+ * `src/types.ts`.
297
+ *
298
+ * Used on the COLD-REPLAY path only — see `renderReplayBrief`. A resumed
299
+ * session still holds its own prior submission, so sending it back there
300
+ * would spend tokens re-stating what the model already has.
301
+ */
302
+ previousValue?: unknown;
272
303
  /**
273
304
  * The JSON Schema the engine will enforce on this output at commit time,
274
305
  * projected off the owning produce entry by a schema-aware hub. Absent
@@ -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";
@@ -300,6 +301,7 @@ export declare const ORDER_OWED_FIELDS: {
300
301
  readonly judgmentRejects: "required";
301
302
  readonly schemaRejects: "required";
302
303
  readonly reasons: "required";
304
+ readonly previousValue: "optional";
303
305
  readonly schema: "optional";
304
306
  readonly schemaAppliesTo: "optional";
305
307
  readonly proof: "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
@@ -154,6 +155,17 @@ export const ORDER_OWED_FIELDS = {
154
155
  judgmentRejects: 'required',
155
156
  schemaRejects: 'required',
156
157
  reasons: 'required',
158
+ // The value the owed path already holds, sent back only on a re-offer whose
159
+ // reason thread is non-empty. Optional because most offers are first offers
160
+ // and carry no such thread, so every order emitted before this field existed
161
+ // still validates unchanged.
162
+ //
163
+ // Unlike `schema` below this is DYNAMIC, not derived: it is committed engine
164
+ // state read inside the claim transaction, exactly like `version`,
165
+ // `judgmentRejects` and `reasons`, all of which the signature already covers.
166
+ // Covering it too is what stops a re-offer from being replayed with a
167
+ // different prior value substituted under the same claim.
168
+ previousValue: 'optional',
157
169
  // The declared JSON Schema for this owed path and what it governs, projected
158
170
  // off the owning produce entry. Optional because most produces declare no
159
171
  // schema, so every order emitted before this field existed still validates
@@ -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
  }
@@ -1886,6 +1886,7 @@ export class Engine {
1886
1886
  const owes = f.outputs.map((p) => {
1887
1887
  const a = arts.get(p);
1888
1888
  const declared = owedSchema(step, p);
1889
+ const reasons = a?.reasons ?? [];
1889
1890
  return {
1890
1891
  path: p,
1891
1892
  ...(declared !== undefined
@@ -1909,7 +1910,18 @@ export class Engine {
1909
1910
  version: (a?.version ?? 0) + 1,
1910
1911
  judgmentRejects: a?.judgmentRejects ?? 0,
1911
1912
  schemaRejects: a?.schemaRejects ?? 0,
1912
- reasons: a?.reasons ?? [],
1913
+ reasons,
1914
+ // The value the path already holds, but ONLY on a re-offer that
1915
+ // follows a refusal. With an empty reason thread there is no feedback
1916
+ // for a previous value to be feedback ON, so projecting it would put
1917
+ // an artifact-sized payload on every ordinary first offer and buy
1918
+ // nothing. `undefined` is "no value" here, the same reading `consumes`
1919
+ // above gives it. See the field's contract in `types.ts` -- in
1920
+ // particular that this is the REFUSED value only after a judgment or
1921
+ // human reject, since a schema reject never committed one.
1922
+ ...(reasons.length > 0 && a?.value !== undefined
1923
+ ? { previousValue: a.value }
1924
+ : {}),
1913
1925
  };
1914
1926
  });
1915
1927
  const order = {
@@ -561,6 +561,9 @@ export declare const WIRE_SCHEMAS: {
561
561
  };
562
562
  };
563
563
  };
564
+ previousValue: {
565
+ description: string;
566
+ };
564
567
  schema: {
565
568
  description: string;
566
569
  oneOf: {
@@ -581,6 +584,29 @@ export declare const WIRE_SCHEMAS: {
581
584
  consumesProof: {
582
585
  type: string;
583
586
  };
587
+ consumesProofRelay: {
588
+ type: string;
589
+ description: string;
590
+ additionalProperties: {
591
+ type: string;
592
+ additionalProperties: boolean;
593
+ required: string[];
594
+ properties: {
595
+ childDefDigest: {
596
+ type: string;
597
+ minLength: number;
598
+ };
599
+ childVersion: {
600
+ type: string;
601
+ minimum: number;
602
+ };
603
+ childOutcome: {
604
+ type: string;
605
+ minLength: number;
606
+ };
607
+ };
608
+ };
609
+ };
584
610
  cause: {
585
611
  type: string;
586
612
  enum: string[];
@@ -97,6 +97,9 @@
97
97
  }
98
98
  }
99
99
  },
100
+ "previousValue": {
101
+ "description": "The value this owed path already holds, sent only on a re-offer whose reason thread is non-empty. Absent on a first offer, and absent when the refusal never committed a value. It is the REFUSED value only after a judgment or human reject, which follow a commit; a schema reject refuses the write, so after one this carries the last value that did commit. Any JSON, because it is a def author's artifact value and not a shape this wire contract controls."
102
+ },
100
103
  "schema": {
101
104
  "description": "The JSON Schema the engine will enforce on this owed path at commit time, copied verbatim off the owning produce entry. Absent when that produce declares none, which is the common case and means any JSON is accepted. A JSON Schema is either a keyword object or a bare boolean, so both forms are admitted here.",
102
105
  "oneOf": [{ "type": "object" }, { "type": "boolean" }]
@@ -111,6 +114,20 @@
111
114
  }
112
115
  },
113
116
  "consumesProof": { "type": "string" },
117
+ "consumesProofRelay": {
118
+ "type": "object",
119
+ "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.",
120
+ "additionalProperties": {
121
+ "type": "object",
122
+ "additionalProperties": false,
123
+ "required": ["childDefDigest", "childVersion", "childOutcome"],
124
+ "properties": {
125
+ "childDefDigest": { "type": "string", "minLength": 1 },
126
+ "childVersion": { "type": "integer", "minimum": 0 },
127
+ "childOutcome": { "type": "string", "minLength": 1 }
128
+ }
129
+ }
130
+ },
114
131
  "cause": { "type": "string", "enum": ["inputsGreen", "allGreen", "idle"] },
115
132
  "capabilities": {
116
133
  "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) {
@@ -281,6 +281,46 @@ export interface Order {
281
281
  judgmentRejects: number;
282
282
  schemaRejects: number;
283
283
  reasons: ReasonEntry[];
284
+ /**
285
+ * The value this owed path already holds, projected ONLY when the reason
286
+ * thread above is non-empty -- that is, only on a re-offer that follows a
287
+ * refusal.
288
+ *
289
+ * WHY IT IS ON THE ORDER. The same argument as `schema` below, for content
290
+ * instead of shape. `reasons` already tells a re-offered producer THAT its
291
+ * last submission was refused and why. It does not tell it WHAT it
292
+ * submitted. A producer reading "your plan was rejected because phase 3
293
+ * cites no artifact", with no sight of the plan it wrote, has to rebuild
294
+ * the whole value from memory to change one phase, and the rebuild
295
+ * silently drops the parts nobody objected to. That is the same rework
296
+ * `schema` exists to prevent, arriving through a different door: feedback
297
+ * is actionable only against the thing it is feedback ON.
298
+ *
299
+ * WHAT IT ACTUALLY HOLDS, which is NOT always the refused value:
300
+ *
301
+ * - After a judgment or human reject, it IS the refused value. Those
302
+ * rejects FOLLOW a commit -- `green()` had already written the artifact
303
+ * and bumped `version` -- so what stands here is what the judge read.
304
+ * - After a schema reject or an artifact-bind reject, it is NOT. Those
305
+ * refuse the write itself, so nothing was committed, and this carries
306
+ * the last value that DID commit, or is absent when none ever did.
307
+ *
308
+ * It is deliberately not named `rejectedValue`. Half the refusal kinds
309
+ * that put a reason on this thread never commit the value they refused,
310
+ * and a name asserting otherwise would be read as a guarantee the engine
311
+ * cannot make. A layer that needs the distinction reads `reasons`, which
312
+ * records each refusal's kind.
313
+ *
314
+ * Absent on a first firing, which has no artifact at all, and absent on
315
+ * any re-offer whose reason thread is empty. Gating on the thread is what
316
+ * keeps an artifact-sized payload off the ordinary offer and confines it
317
+ * to the rework path, the only path able to use it.
318
+ *
319
+ * It is a COPY taken at claim time, under the same contract as `schema`:
320
+ * `Store.restampOrderTarget`, the one post-claim writer of a persisted
321
+ * order, touches only `owes[].version`.
322
+ */
323
+ previousValue?: unknown;
284
324
  /**
285
325
  * The JSON Schema the engine will enforce on this output at commit time,
286
326
  * copied verbatim off the owning produce entry. Absent when that produce
@@ -325,6 +365,17 @@ export interface Order {
325
365
  /** Opaque proof/signature placeholder for future WP-A4-signed dynamic
326
366
  * consume values. Data-only today — same contract as `owes[].proof`. */
327
367
  consumesProof?: string;
368
+ /** Calls-boundary relay hints keyed by the parent artifact path: for a
369
+ * consumed path a `calls:` step produced, the child definition digest the
370
+ * parent pins, the pinned child outcome version, and the child outcome stem
371
+ * whose signed submission record `consumesProof` carries under the parent
372
+ * path. Data-only for the engine — a relay-aware hub projects it and the
373
+ * consuming worker verifies it against local definition bytes. */
374
+ consumesProofRelay?: Record<string, {
375
+ childDefDigest: string;
376
+ childVersion: number;
377
+ childOutcome: string;
378
+ }>;
328
379
  /** The trigger that woke this firing (§21). Absent = 'inputsGreen'. */
329
380
  cause?: FiringTrigger;
330
381
  }
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.30",
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.30",
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.30"
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.30",
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.30"
10
10
  },
11
11
  "env_vars": [
12
12
  "HOME",