owenloop 0.5.7 → 0.5.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +7 -8
  3. package/dist/packages/work/src/agent/capability-model.d.ts +64 -82
  4. package/dist/packages/work/src/agent/capability-model.js +94 -91
  5. package/dist/packages/work/src/agent/loop.d.ts +55 -26
  6. package/dist/packages/work/src/agent/loop.js +144 -50
  7. package/dist/packages/work/src/bundle/types.d.ts +3 -3
  8. package/dist/packages/work/src/consumed-verifier.js +6 -17
  9. package/dist/packages/work/src/exec/loop.d.ts +1 -1
  10. package/dist/packages/work/src/exec/loop.js +206 -35
  11. package/dist/packages/work/src/exec/receipt.d.ts +7 -7
  12. package/dist/packages/work/src/exec/receipt.js +6 -6
  13. package/dist/packages/work/src/harness/child-env.js +4 -5
  14. package/dist/packages/work/src/harness/claude.js +100 -0
  15. package/dist/packages/work/src/harness/codex.js +3 -4
  16. package/dist/packages/work/src/harness/session-store.d.ts +63 -3
  17. package/dist/packages/work/src/harness/session-store.js +104 -9
  18. package/dist/packages/work/src/hub/client.d.ts +19 -4
  19. package/dist/packages/work/src/hub/client.js +7 -3
  20. package/dist/packages/work/src/hub/types.d.ts +87 -3
  21. package/dist/packages/work/src/main.js +1 -0
  22. package/dist/packages/work/src/roles/agent-run.js +46 -43
  23. package/dist/packages/work/src/roles/exec.js +2 -0
  24. package/dist/packages/work/src/roles/sessions.d.ts +3 -2
  25. package/dist/packages/work/src/roles/sessions.js +9 -2
  26. package/dist/packages/work/src/roles/settings.js +3 -1
  27. package/dist/packages/work/src/roles/shift.js +14 -2
  28. package/dist/packages/work/src/roles/util.d.ts +1 -0
  29. package/dist/packages/work/src/roles/util.js +10 -0
  30. package/dist/packages/work/src/settings/hub-roster-cache.d.ts +68 -0
  31. package/dist/packages/work/src/settings/hub-roster-cache.js +370 -0
  32. package/dist/packages/work/src/settings/roster.d.ts +105 -0
  33. package/dist/packages/work/src/settings/roster.js +439 -0
  34. package/dist/packages/work/src/settings/serving.d.ts +17 -0
  35. package/dist/packages/work/src/settings/serving.js +79 -0
  36. package/dist/packages/work/src/settings/settings.d.ts +25 -24
  37. package/dist/packages/work/src/settings/settings.js +29 -33
  38. package/dist/packages/work/src/shift/loop.d.ts +108 -5
  39. package/dist/packages/work/src/shift/loop.js +299 -51
  40. package/dist/packages/work/src/shift/protocol.d.ts +7 -5
  41. package/dist/packages/work/src/shift/runtime.d.ts +15 -0
  42. package/dist/packages/work/src/shift/runtime.js +95 -13
  43. package/dist/packages/work/src/shift/server.js +2 -0
  44. package/dist/packages/work/src/shift/spawn.d.ts +18 -50
  45. package/dist/packages/work/src/shift/spawn.js +30 -65
  46. package/dist/packages/work/src/shift/state.d.ts +29 -2
  47. package/dist/packages/work/src/shift/state.js +45 -15
  48. package/dist/packages/work/src/usage.d.ts +1 -1
  49. package/dist/packages/work/src/usage.js +10 -5
  50. package/dist/packages/work/src/util/modifier-init.d.ts +7 -0
  51. package/dist/packages/work/src/util/modifier-init.js +73 -0
  52. package/dist/src/bundle/tar.d.ts +9 -4
  53. package/dist/src/bundle/tar.js +9 -4
  54. package/dist/src/capabilities.d.ts +50 -0
  55. package/dist/src/capabilities.js +38 -0
  56. package/dist/src/cli.d.ts +15 -1
  57. package/dist/src/cli.js +1099 -32
  58. package/dist/src/config-dir.d.ts +14 -19
  59. package/dist/src/config-dir.js +16 -24
  60. package/dist/src/credentials.d.ts +1 -1
  61. package/dist/src/credentials.js +1 -1
  62. package/dist/src/crypto/index.d.ts +1 -1
  63. package/dist/src/crypto/index.js +1 -1
  64. package/dist/src/crypto/org-root.d.ts +30 -12
  65. package/dist/src/crypto/org-root.js +162 -14
  66. package/dist/src/crypto/records.d.ts +3 -0
  67. package/dist/src/crypto/records.js +8 -0
  68. package/dist/src/crypto/trust-roots.d.ts +2 -2
  69. package/dist/src/crypto/trust-roots.js +2 -2
  70. package/dist/src/defs.d.ts +6 -1
  71. package/dist/src/defs.js +203 -8
  72. package/dist/src/engine.d.ts +55 -6
  73. package/dist/src/engine.js +172 -22
  74. package/dist/src/global-config.d.ts +4 -7
  75. package/dist/src/global-config.js +4 -7
  76. package/dist/src/hub.d.ts +207 -5
  77. package/dist/src/hub.js +263 -3
  78. package/dist/src/index.d.ts +5 -5
  79. package/dist/src/index.js +3 -3
  80. package/dist/src/mcp/serve.d.ts +22 -0
  81. package/dist/src/mcp/serve.js +88 -8
  82. package/dist/src/model.d.ts +2 -0
  83. package/dist/src/model.js +32 -25
  84. package/dist/src/order-resolver.d.ts +1 -0
  85. package/dist/src/order-resolver.js +8 -1
  86. package/dist/src/schemas/index.d.ts +19 -0
  87. package/dist/src/schemas/order.v1.schema.json +13 -2
  88. package/dist/src/store/pre-commit-verifier.js +1 -1
  89. package/dist/src/store.d.ts +5 -0
  90. package/dist/src/store.js +43 -8
  91. package/dist/src/types.d.ts +64 -7
  92. package/dist/src/work-settings.d.ts +2 -4
  93. package/dist/src/work-settings.js +2 -4
  94. package/docs/agent-runner.md +2 -2
  95. package/docs/authoring.md +90 -2
  96. package/docs/bundles.md +29 -3
  97. package/docs/cli.md +456 -120
  98. package/docs/crypto.md +32 -16
  99. package/docs/design.md +70 -1
  100. package/docs/routing.md +762 -0
  101. package/docs/shift-logs.md +37 -10
  102. package/docs/wire-contracts.md +50 -7
  103. package/examples/workflows/delivery.yaml +31 -14
  104. package/examples/workflows/ship.yaml +10 -2
  105. package/package.json +1 -1
  106. package/plugins/claude-code/plugin/.claude-plugin/plugin.json +1 -1
  107. package/plugins/claude-code/plugin/.mcp.json +1 -1
  108. package/plugins/claude-code/plugin/skills/author/SKILL.md +1 -2
  109. package/plugins/codex/plugins/owenloop/.codex-plugin/plugin.json +1 -1
  110. package/plugins/codex/plugins/owenloop/.mcp.json +1 -1
  111. package/plugins/codex/plugins/owenloop/skills/author/SKILL.md +1 -2
@@ -13,7 +13,7 @@ import { elementPath, parseElement, parseWorkdirFrom, sealPath, } from "./paths.
13
13
  import { collectionStem, computeFingerprint, eligibleFirings, fingerprintMatches, groupBlockingWinner, isEscalated, isGreen, judgeNameOf, maintainDecisions, owedSchema, pendingOwed, plainConsumes, rejectionEpisode, requiredInputs, workflowStatus, } from "./model.js";
14
14
  import { summarizeIssues, validateValue } from "./schema.js";
15
15
  import { hashDef } from "./defs.js";
16
- import { claimMatches, composeCapabilities } from "./capabilities.js";
16
+ import { applyCapabilityRewrites, claimMatches, composeCapabilities } from "./capabilities.js";
17
17
  import { localMidnightMs, nowMs, randId } from "./util.js";
18
18
  import { createDefInstructionSource, OrderResolver } from "./order-resolver.js";
19
19
  const DEFAULT_REAP_TTL_MS = 2 * 60 * 60 * 1000; // 2h
@@ -28,6 +28,7 @@ const DEFAULT_REAP_TTL_MS = 2 * 60 * 60 * 1000; // 2h
28
28
  const DEFAULT_MAX_CALL_DEPTH = 64;
29
29
  /** The artifact-history `action` written when an escalation promotes an offer. */
30
30
  const ESCALATION_ACTION = 'escalated';
31
+ const BIND_ACTION = 'bound';
31
32
  /**
32
33
  * F2: a typed refusal for a produced-value/input-value schema mismatch, thrown
33
34
  * by `createInstance` (seed provide) and `provideInput`. Distinct from a bare
@@ -221,8 +222,9 @@ export class Engine {
221
222
  wfData.params = opts.params;
222
223
  // Validated against the SNAPSHOT being pinned on this same row, not
223
224
  // against a live re-resolution — the modifier and the vocabulary that
224
- // legitimizes it are stamped together and stay consistent for the life of
225
- // the instance, even if the def is republished with a different set.
225
+ // legitimizes it are stamped together. Later bound-artifact writes still
226
+ // validate against this pinned vocabulary, even if the def is republished
227
+ // with a different set.
226
228
  if (opts.modifier !== undefined) {
227
229
  const declared = def.modifiers ?? [];
228
230
  if (!declared.includes(opts.modifier)) {
@@ -986,7 +988,7 @@ export class Engine {
986
988
  tick(workflow, opts = {}) {
987
989
  // `capabilities` is passed through AS GIVEN — an omitted filter (undefined)
988
990
  // and an empty list are different claims. See `claimMatches`.
989
- return this.tickInternal(workflow, opts.now ?? nowMs(), opts.deep ?? true, opts.capabilities, new Set(), 0, undefined, opts.matchModes ?? {});
991
+ return this.tickInternal(workflow, opts.now ?? nowMs(), opts.deep ?? true, opts.capabilities, new Set(), 0, undefined, opts.matchModes ?? {}, opts.capabilityRewrites ?? {}, opts.crewStamps ?? {});
990
992
  }
991
993
  /**
992
994
  * The recursive tick worker. Runs this instance's own maintain → reap →
@@ -1027,7 +1029,7 @@ export class Engine {
1027
1029
  * edge it hangs from. The guard is silent (no debt/reasons/events), mirroring
1028
1030
  * the abort discipline of `publishCallsGreen`/`provisionCallsChild`.
1029
1031
  */
1030
- tickInternal(workflow, now, deep, capabilities, visited, depth, parentEdge, matchModes = {}) {
1032
+ tickInternal(workflow, now, deep, capabilities, visited, depth, parentEdge, matchModes = {}, capabilityRewrites = {}, crewStamps = {}) {
1031
1033
  if (depth > this.maxCallDepth) {
1032
1034
  throw new Error(`calls depth limit exceeded (maxCallDepth=${this.maxCallDepth}) ticking '${workflow}': `
1033
1035
  + `a calls: composition is deeper than the bound, which usually means a calls: cycle `
@@ -1076,11 +1078,11 @@ export class Engine {
1076
1078
  // Compute time facts for idle eligibility (clock-read boundary).
1077
1079
  const timeFacts = this.computeTimeFacts(def, workflow, arts, now);
1078
1080
  const firings = eligibleFirings(def, arts, timeFacts);
1079
- const { selected, deferred } = this.applySchedule(workflow, def, firings, now, arts, capabilities, modifier, matchModes);
1081
+ const { selected, deferred } = this.applySchedule(workflow, def, firings, now, arts, capabilities, modifier, matchModes, capabilityRewrites);
1080
1082
  const orders = [];
1081
1083
  const allDeferred = [...deferred];
1082
1084
  for (const f of selected) {
1083
- const claimed = this.claim(workflow, def, f, arts, now, modifier);
1085
+ const claimed = this.claim(workflow, def, f, arts, now, modifier, capabilityRewrites, crewStamps);
1084
1086
  if (claimed === 'in-flight') {
1085
1087
  const d = { step: f.step, key: f.key, inputs: f.inputs, outputs: f.outputs, reason: 'in-flight' };
1086
1088
  if (f.index !== undefined)
@@ -1115,7 +1117,7 @@ export class Engine {
1115
1117
  parentWf: workflow,
1116
1118
  step,
1117
1119
  callsStem: step.produces[0].stem,
1118
- }, matchModes);
1120
+ }, matchModes, capabilityRewrites, crewStamps);
1119
1121
  // orders: flatten; each Order already carries its own `workflow`.
1120
1122
  result.orders.push(...cr.orders);
1121
1123
  // deferred: stamp child-originated entries with the child id, preserving
@@ -1203,7 +1205,7 @@ export class Engine {
1203
1205
  * escalation authored every firing of a step composes identically, so this
1204
1206
  * behaves exactly as a per-step filter would.
1205
1207
  */
1206
- applySchedule(workflow, def, firings, now, arts, capabilities, modifier, matchModes) {
1208
+ applySchedule(workflow, def, firings, now, arts, capabilities, modifier, matchModes, capabilityRewrites) {
1207
1209
  const midnight = localMidnightMs(now);
1208
1210
  const selected = [];
1209
1211
  const deferred = [];
@@ -1220,10 +1222,13 @@ export class Engine {
1220
1222
  // A2: caller capability filter vs. this firing's COMPOSED offer. Composed
1221
1223
  // here, not authored, so a caller bound to `wise:deep` is judged against
1222
1224
  // what the order will actually carry — including when `deep` came from the
1223
- // escalation rule rather than the run.
1225
+ // escalation rule rather than the run, and including a reroute the caller
1226
+ // decided on. The filter and `buildOrder` apply the same two functions in
1227
+ // the same order, so what is matched is always what gets stamped.
1224
1228
  const stepFirings = [];
1225
1229
  for (const f of all) {
1226
- const offered = composeCapabilities(step.capabilities, this.routingFor(step, f, arts, modifier).modifier);
1230
+ const composed = composeCapabilities(step.capabilities, this.routingFor(step, f, arts, modifier).modifier);
1231
+ const { offered } = applyCapabilityRewrites(composed, capabilityRewrites);
1227
1232
  if (claimMatches(offered, capabilities, matchModes))
1228
1233
  stepFirings.push(f);
1229
1234
  else
@@ -1304,7 +1309,7 @@ export class Engine {
1304
1309
  return this.staleness(task, now, ttl, maxLease) === 'fresh';
1305
1310
  }
1306
1311
  /** Claim a firing's lease via CAS, snapshot the fingerprint, open a run. */
1307
- claim(workflow, def, f, arts, now, modifier) {
1312
+ claim(workflow, def, f, arts, now, modifier, capabilityRewrites = {}, crewStamps = {}) {
1308
1313
  const existing = this.store.getTask(workflow, f.step, f.key);
1309
1314
  if (existing && existing.status === 'claimed') {
1310
1315
  const run = existing.run ? this.store.getRun(existing.run) : undefined;
@@ -1332,7 +1337,7 @@ export class Engine {
1332
1337
  // `applySchedule` so the offer and the filter read the same function on the
1333
1338
  // same in-tx `arts` snapshot; nothing between them can move.
1334
1339
  const routing = this.routingFor(this.step(def, f.step), f, arts, modifier);
1335
- const order = this.buildOrder(def, workflow, runId, f, arts, fp, routing);
1340
+ const order = this.buildOrder(def, workflow, runId, f, arts, fp, routing, capabilityRewrites, crewStamps);
1336
1341
  if (typeof order === 'object' && 'deferred' in order)
1337
1342
  return order;
1338
1343
  // One history record per rejection episode. Written HERE, not in
@@ -1366,7 +1371,7 @@ export class Engine {
1366
1371
  * snapshot is registered under the digest (a side effect of `digestOf`),
1367
1372
  * so the order stays resolvable after the live definition map changes.
1368
1373
  */
1369
- buildOrder(def, workflow, runId, f, arts, consumedFingerprint, routing = {}) {
1374
+ buildOrder(def, workflow, runId, f, arts, consumedFingerprint, routing = {}, capabilityRewrites = {}, crewStamps = {}) {
1370
1375
  const step = this.step(def, f.step);
1371
1376
  const consumes = {};
1372
1377
  for (const p of f.inputs) {
@@ -1494,9 +1499,25 @@ export class Engine {
1494
1499
  // have to diff it against the run record. A claimed order is never
1495
1500
  // recomposed: composition happens per offer, and this record is what the
1496
1501
  // shift resolved against.
1497
- const offered = composeCapabilities(step.capabilities, routing.modifier);
1502
+ const { offered, reroutedFrom } = applyCapabilityRewrites(composeCapabilities(step.capabilities, routing.modifier), capabilityRewrites);
1498
1503
  if (offered.length > 0)
1499
1504
  order.capabilities = offered;
1505
+ const crews = [];
1506
+ for (const capability of offered) {
1507
+ if (!Object.prototype.hasOwnProperty.call(crewStamps, capability))
1508
+ continue;
1509
+ for (const crew of crewStamps[capability] ?? []) {
1510
+ if (!crews.includes(crew))
1511
+ crews.push(crew);
1512
+ }
1513
+ }
1514
+ if (crews.length > 0)
1515
+ order.crews = crews;
1516
+ // Only when a rewrite actually fired. `reroutedFrom` is absent on every
1517
+ // ordinary offer, so its presence alone tells a reader the order is not
1518
+ // running on the capability its def asked for.
1519
+ if (reroutedFrom !== undefined)
1520
+ order.reroutedFrom = reroutedFrom;
1500
1521
  if (routing.modifier !== undefined)
1501
1522
  order.modifier = routing.modifier;
1502
1523
  if (routing.escalation !== undefined)
@@ -1527,6 +1548,101 @@ export class Engine {
1527
1548
  resolveOrder(order) {
1528
1549
  return this.resolver.resolveOrder(order);
1529
1550
  }
1551
+ /** Return the binding declaration that owns this artifact path, if any. */
1552
+ artifactBind(def, art) {
1553
+ const step = def.steps.find((candidate) => candidate.name === art.producer);
1554
+ if (step === undefined)
1555
+ return undefined;
1556
+ const element = parseElement(art.path);
1557
+ if (element !== null) {
1558
+ return step.produces.find((produce) => produce.kind === 'map'
1559
+ && produce.stem === element.stem
1560
+ && produce.suffix === element.suffix)?.bind;
1561
+ }
1562
+ return step.produces.find((produce) => produce.kind === 'singleton' && produce.stem === art.path)?.bind;
1563
+ }
1564
+ /** Resolve a declared dot-path of object keys against an accepted artifact value. */
1565
+ boundValue(path, bind, acceptedValue) {
1566
+ let current = acceptedValue;
1567
+ for (const key of bind.from.split('.')) {
1568
+ if (current === null ||
1569
+ typeof current !== 'object' ||
1570
+ Array.isArray(current) ||
1571
+ !Object.prototype.hasOwnProperty.call(current, key)) {
1572
+ throw new Error(`artifact '${path}' bind.from '${bind.from}' cannot be resolved from its accepted value`);
1573
+ }
1574
+ current = current[key];
1575
+ }
1576
+ return current;
1577
+ }
1578
+ /**
1579
+ * The bind-time and reject-time modifier gate: membership in the def's
1580
+ * declared `modifiers` set, and nothing else — byte for byte the rule the
1581
+ * start path applies in `createInstanceInTx`. One value cannot be legal to
1582
+ * start a run with and illegal to bind.
1583
+ *
1584
+ * `def` here is the PINNED snapshot, so the vocabulary checked is the one
1585
+ * stamped on this run, not a later republish.
1586
+ *
1587
+ * The SHAPE of a name is constrained where a name is authored:
1588
+ * `parseModifiers` in `src/defs.ts` refuses an empty name, a name containing
1589
+ * whitespace, a name containing `MODIFIER_SEPARATOR`, and a duplicate.
1590
+ * Re-testing shape here is what split the vocabulary in the first place — a
1591
+ * value the parser admitted and `start_run` accepted, refused at bind.
1592
+ */
1593
+ assertBoundModifier(def, value) {
1594
+ const declared = def.modifiers ?? [];
1595
+ if (typeof value !== 'string' || !declared.includes(value)) {
1596
+ const rendered = typeof value === 'string' ? value : JSON.stringify(value) ?? String(value);
1597
+ throw new ModifierRefusalError(def.name, rendered, declared);
1598
+ }
1599
+ }
1600
+ /** Validate extraction before an acceptance branch changes an artifact. */
1601
+ validateArtifactBind(def, art, acceptedValue) {
1602
+ const bind = this.artifactBind(def, art);
1603
+ if (bind === undefined)
1604
+ return;
1605
+ const value = this.boundValue(art.path, bind, acceptedValue);
1606
+ if (bind.to === 'modifier')
1607
+ this.assertBoundModifier(def, value);
1608
+ }
1609
+ /**
1610
+ * Persist a declared instance-routing write and its single artifact-level
1611
+ * audit event. Call only from an already-accepted branch inside its tx.
1612
+ */
1613
+ applyArtifactBind(workflow, def, art, acceptedValue, now) {
1614
+ const bind = this.artifactBind(def, art);
1615
+ if (bind === undefined)
1616
+ return;
1617
+ const value = this.boundValue(art.path, bind, acceptedValue);
1618
+ const routing = this.store.getWorkflow(workflow);
1619
+ if (routing === undefined)
1620
+ throw new Error(`cannot bind routing for unknown workflow '${workflow}'`);
1621
+ let prior;
1622
+ if (bind.to === 'modifier') {
1623
+ this.assertBoundModifier(def, value);
1624
+ prior = routing.modifier;
1625
+ this.store.setWorkflowRouting(workflow, { modifier: value });
1626
+ }
1627
+ else {
1628
+ const key = bind.to.slice('meta.'.length);
1629
+ prior = routing.meta?.[key];
1630
+ this.store.setWorkflowRouting(workflow, { meta: { [key]: value } });
1631
+ }
1632
+ this.store.recordArtifactEvent({
1633
+ workflow,
1634
+ path: art.path,
1635
+ version: 0,
1636
+ action: BIND_ACTION,
1637
+ actor: 'engine',
1638
+ dedupe: `${BIND_ACTION}:${art.path}:v${art.version}`,
1639
+ timestamp: now,
1640
+ reason: `artifact '${art.path}' bound ${bind.to}`,
1641
+ // JSON has no undefined value, so null faithfully records an unbound
1642
+ // target while preserving both sides of every accepted routing write.
1643
+ metadata: { from: prior ?? null, to: value },
1644
+ });
1645
+ }
1530
1646
  // ---- producer commits ------------------------------------------------------
1531
1647
  /**
1532
1648
  * Commit a singleton/map output green — or born-reject it if an input moved.
@@ -1593,7 +1709,9 @@ export class Engine {
1593
1709
  const producer = def.steps.find((l) => l.name === art.producer);
1594
1710
  if (opts.terminal || producer?.terminal)
1595
1711
  next.terminal = true;
1712
+ this.validateArtifactBind(def, next, value);
1596
1713
  this.store.putArtifact(next, { action: 'green', actor: 'human', reason: 'human green' });
1714
+ this.applyArtifactBind(workflow, def, next, value, nowMs());
1597
1715
  this.settle(workflow, def);
1598
1716
  return { path, outcome: 'green' };
1599
1717
  });
@@ -1634,7 +1752,9 @@ export class Engine {
1634
1752
  const next = { ...art, acceptance: 'green', approvals };
1635
1753
  if (producer?.terminal)
1636
1754
  next.terminal = true;
1755
+ this.validateArtifactBind(def, next, art.value);
1637
1756
  this.store.putArtifact(next, { action: 'judge-approved', actor: jName, reason: 'all judges approved' });
1757
+ this.applyArtifactBind(workflow, def, next, art.value, nowMs());
1638
1758
  this.settle(workflow, def);
1639
1759
  return { path: judgedStem, outcome: 'green' };
1640
1760
  }
@@ -1689,6 +1809,20 @@ export class Engine {
1689
1809
  return { path, outcome: 'schema-rejected', reason: text, issues: check.issues };
1690
1810
  }
1691
1811
  }
1812
+ try {
1813
+ this.validateArtifactBind(def, art, value);
1814
+ }
1815
+ catch (e) {
1816
+ const text = `artifact bind validation failed: ${e instanceof Error ? e.message : String(e)}`;
1817
+ this.store.putArtifact({
1818
+ ...art,
1819
+ acceptance: 'rejected',
1820
+ schemaRejects: art.schemaRejects + 1,
1821
+ reasons: [...art.reasons, reason('schema-reject', 'validation', 'engine', text, art.version)],
1822
+ });
1823
+ this.settle(workflow, def);
1824
+ return { path, outcome: 'schema-rejected', reason: text };
1825
+ }
1692
1826
  // §24 §4.4/§4.8: when this produce declares judges, the commit lands
1693
1827
  // `submitted` (not `green`) and the version bumps here — CAS re-arms on
1694
1828
  // resubmission, not on judge-approve. `approvals` resets so a prior
@@ -1714,6 +1848,8 @@ export class Engine {
1714
1848
  actor: r.step,
1715
1849
  reason: hasJudges ? 'submitted for judgment' : 'producer green',
1716
1850
  });
1851
+ if (!hasJudges)
1852
+ this.applyArtifactBind(workflow, def, next, value, nowMs());
1717
1853
  this.settle(workflow, def);
1718
1854
  return { path, outcome: hasJudges ? 'submitted' : 'green' };
1719
1855
  });
@@ -1887,7 +2023,7 @@ export class Engine {
1887
2023
  * See `docs/design.md` §24.9 for the full writeup and operator mitigations
1888
2024
  * (`parallel: 1`, a generous `reapTtl:` on slow judge steps).
1889
2025
  */
1890
- reject(workflow, path, by, text) {
2026
+ reject(workflow, path, by, text, requested) {
1891
2027
  const def = this.defFor(workflow);
1892
2028
  this.assertAuthority(def, by, path, 'reject');
1893
2029
  // F4: a reject on an artifact produced by a `calls:` step is a verdict on
@@ -1898,7 +2034,14 @@ export class Engine {
1898
2034
  // verb-guard rule below that a verdict needs a built version).
1899
2035
  const producingStep = def.steps.find((s) => s.produces.some((p) => p.stem === path));
1900
2036
  if (producingStep?.calls) {
1901
- return this.rejectCallsArtifact(workflow, def, producingStep, path, by, text);
2037
+ const bind = producingStep.produces.find((p) => p.stem === path)?.bind;
2038
+ if (requested !== undefined) {
2039
+ if (bind?.to !== 'modifier') {
2040
+ throw new Error(`requested modifier is only valid when artifact '${path}' binds to modifier`);
2041
+ }
2042
+ this.assertBoundModifier(def, requested);
2043
+ }
2044
+ return this.rejectCallsArtifact(workflow, def, producingStep, path, by, text, requested);
1902
2045
  }
1903
2046
  const judgeStep = def.steps.find((s) => s.name === by);
1904
2047
  const judgedStem = judgeStep?.judges;
@@ -1907,6 +2050,13 @@ export class Engine {
1907
2050
  const art = this.store.getArtifact(workflow, path);
1908
2051
  if (!art)
1909
2052
  throw new Error(`cannot reject unknown artifact: ${path}`);
2053
+ if (requested !== undefined) {
2054
+ const bind = this.artifactBind(def, art);
2055
+ if (bind?.to !== 'modifier') {
2056
+ throw new Error(`requested modifier is only valid when artifact '${path}' binds to modifier`);
2057
+ }
2058
+ this.assertBoundModifier(def, requested);
2059
+ }
1910
2060
  if (judgedStem !== undefined) {
1911
2061
  // A judge's reject targets the judged stem, mirroring green()'s
1912
2062
  // judge-approve branch (§24.4): CAS-guard against a stale verdict
@@ -1950,7 +2100,7 @@ export class Engine {
1950
2100
  acceptance: 'rejected',
1951
2101
  judgmentRejects: art.judgmentRejects + 1,
1952
2102
  approvals: undefined,
1953
- reasons: [...art.reasons, reason('reject', 'judgment', by, text, art.version)],
2103
+ reasons: [...art.reasons, reason('reject', 'judgment', by, text, art.version, requested)],
1954
2104
  });
1955
2105
  this.settle(workflow, def);
1956
2106
  return { outcome: 'rejected' };
@@ -1981,7 +2131,7 @@ export class Engine {
1981
2131
  * reasons entry is `parent:<by>` to make the indirection visible in its
1982
2132
  * audit thread.
1983
2133
  */
1984
- rejectCallsArtifact(parentWf, def, producingStep, callsStem, by, text) {
2134
+ rejectCallsArtifact(parentWf, def, producingStep, callsStem, by, text, requested) {
1985
2135
  const child = this.store.findChildByParent(parentWf, callsStem);
1986
2136
  if (!child) {
1987
2137
  throw new Error(`cannot reject '${callsStem}': no child instance has been spawned yet (a verdict requires a built version)`);
@@ -2004,7 +2154,7 @@ export class Engine {
2004
2154
  acceptance: 'rejected',
2005
2155
  judgmentRejects: childArt.judgmentRejects + 1,
2006
2156
  approvals: undefined,
2007
- reasons: [...childArt.reasons, reason('reject', 'judgment', `parent:${by}`, text, childArt.version)],
2157
+ reasons: [...childArt.reasons, reason('reject', 'judgment', `parent:${by}`, text, childArt.version, requested)],
2008
2158
  });
2009
2159
  this.settle(child.id, childDef);
2010
2160
  // Parent calls artifact → reopened to owed (not left rejected), pinned
@@ -3015,8 +3165,8 @@ export class Engine {
3015
3165
  }
3016
3166
  }
3017
3167
  // ---- helpers -----------------------------------------------------------------
3018
- function reason(action, kind, by, text, fromVersion) {
3019
- return { at: nowMs(), action, kind, by, text, fromVersion };
3168
+ function reason(action, kind, by, text, fromVersion, requested) {
3169
+ return { at: nowMs(), action, kind, by, text, fromVersion, ...(requested !== undefined ? { requested } : {}) };
3020
3170
  }
3021
3171
  function nextIndex(arts, stem) {
3022
3172
  let max = -1;
@@ -12,8 +12,7 @@
12
12
  * real installs (macOS defaults to the keychain backend).
13
13
  *
14
14
  * This is deliberately a SEPARATE file from `src/work-settings.ts`'s
15
- * `~/.config/owenloop/settings.json` (or `$XDG_CONFIG_HOME/owenloop/settings.json`
16
- * when set). That file belongs to the EXECUTION plane: `owenloop setup` is its
15
+ * `~/.owenloop/settings.json`. That file belongs to the EXECUTION plane: `owenloop setup` is its
17
16
  * sole writer, and `owenloop work` role resolution and pre-commit verification
18
17
  * are its readers. This file belongs to the CONTROL plane: `owenloop login`
19
18
  * writes it, `owenloop mcp` reads it. Nothing reconciles the two if they
@@ -22,11 +21,9 @@
22
21
  * the two files answer different questions ("what hub does an agent shift run
23
22
  * against" vs. "what hub does the human's MCP session talk to") for two
24
23
  * independently-evolving call paths, and forcing one file to answer both would
25
- * couple them for no benefit. This file is also HOME-rooted, not XDG-aware,
26
- * unlike `settings.json`: `owenloop mcp` is a human-facing control-plane
27
- * process, and there is no separate "XDG vs. HOME" precedence to resolve here
28
- * — the caller supplies `home` directly (see `globalConfigPath`), mirroring
29
- * how `src/cli.ts`'s `workflowHome` resolves the same value.
24
+ * couple them for no benefit. Both files are HOME-rooted siblings in the same
25
+ * directory; their control-plane versus execution-plane responsibilities, not
26
+ * their location, keep them separate.
30
27
  *
31
28
  * Never holds a secret: `hub` is an origin URL, nothing else. A read failure
32
29
  * of any kind (file absent, invalid JSON, wrong shape, blank `hub`, or a
@@ -12,8 +12,7 @@
12
12
  * real installs (macOS defaults to the keychain backend).
13
13
  *
14
14
  * This is deliberately a SEPARATE file from `src/work-settings.ts`'s
15
- * `~/.config/owenloop/settings.json` (or `$XDG_CONFIG_HOME/owenloop/settings.json`
16
- * when set). That file belongs to the EXECUTION plane: `owenloop setup` is its
15
+ * `~/.owenloop/settings.json`. That file belongs to the EXECUTION plane: `owenloop setup` is its
17
16
  * sole writer, and `owenloop work` role resolution and pre-commit verification
18
17
  * are its readers. This file belongs to the CONTROL plane: `owenloop login`
19
18
  * writes it, `owenloop mcp` reads it. Nothing reconciles the two if they
@@ -22,11 +21,9 @@
22
21
  * the two files answer different questions ("what hub does an agent shift run
23
22
  * against" vs. "what hub does the human's MCP session talk to") for two
24
23
  * independently-evolving call paths, and forcing one file to answer both would
25
- * couple them for no benefit. This file is also HOME-rooted, not XDG-aware,
26
- * unlike `settings.json`: `owenloop mcp` is a human-facing control-plane
27
- * process, and there is no separate "XDG vs. HOME" precedence to resolve here
28
- * — the caller supplies `home` directly (see `globalConfigPath`), mirroring
29
- * how `src/cli.ts`'s `workflowHome` resolves the same value.
24
+ * couple them for no benefit. Both files are HOME-rooted siblings in the same
25
+ * directory; their control-plane versus execution-plane responsibilities, not
26
+ * their location, keep them separate.
30
27
  *
31
28
  * Never holds a secret: `hub` is an origin URL, nothing else. A read failure
32
29
  * of any kind (file absent, invalid JSON, wrong shape, blank `hub`, or a