owenloop 0.5.8 → 0.5.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/README.md +81 -39
  3. package/bin/owenloop.mjs +16 -1
  4. package/dist/packages/work/src/agent/loop.d.ts +23 -8
  5. package/dist/packages/work/src/agent/loop.js +55 -6
  6. package/dist/packages/work/src/bundle/pull.d.ts +21 -0
  7. package/dist/packages/work/src/bundle/pull.js +118 -0
  8. package/dist/packages/work/src/consumed-verifier.js +6 -17
  9. package/dist/packages/work/src/exec/instructions.d.ts +4 -1
  10. package/dist/packages/work/src/exec/instructions.js +3 -0
  11. package/dist/packages/work/src/exec/loop.d.ts +2 -2
  12. package/dist/packages/work/src/exec/loop.js +273 -46
  13. package/dist/packages/work/src/exec/receipt.d.ts +7 -7
  14. package/dist/packages/work/src/exec/receipt.js +6 -6
  15. package/dist/packages/work/src/harness/claude.js +116 -0
  16. package/dist/packages/work/src/harness/codex.d.ts +8 -0
  17. package/dist/packages/work/src/harness/codex.js +27 -1
  18. package/dist/packages/work/src/harness/contract.d.ts +9 -0
  19. package/dist/packages/work/src/hub/client.d.ts +19 -4
  20. package/dist/packages/work/src/hub/client.js +7 -3
  21. package/dist/packages/work/src/hub/types.d.ts +84 -0
  22. package/dist/packages/work/src/main.js +1 -0
  23. package/dist/packages/work/src/roles/agent-run.js +57 -32
  24. package/dist/packages/work/src/roles/exec.js +27 -8
  25. package/dist/packages/work/src/roles/settings.js +2 -0
  26. package/dist/packages/work/src/roles/shift.js +14 -2
  27. package/dist/packages/work/src/roles/util.d.ts +1 -0
  28. package/dist/packages/work/src/roles/util.js +10 -0
  29. package/dist/packages/work/src/settings/hub-roster-cache.d.ts +68 -0
  30. package/dist/packages/work/src/settings/hub-roster-cache.js +370 -0
  31. package/dist/packages/work/src/settings/roster.d.ts +84 -0
  32. package/dist/packages/work/src/settings/roster.js +364 -5
  33. package/dist/packages/work/src/settings/serving.d.ts +17 -0
  34. package/dist/packages/work/src/settings/serving.js +79 -0
  35. package/dist/packages/work/src/settings/settings.d.ts +14 -1
  36. package/dist/packages/work/src/settings/settings.js +14 -0
  37. package/dist/packages/work/src/shift/loop.d.ts +108 -5
  38. package/dist/packages/work/src/shift/loop.js +416 -54
  39. package/dist/packages/work/src/shift/protocol.d.ts +7 -5
  40. package/dist/packages/work/src/shift/runtime.d.ts +18 -0
  41. package/dist/packages/work/src/shift/runtime.js +104 -5
  42. package/dist/packages/work/src/shift/server.js +2 -0
  43. package/dist/packages/work/src/shift/spawn.d.ts +17 -2
  44. package/dist/packages/work/src/shift/spawn.js +16 -13
  45. package/dist/packages/work/src/shift/state.d.ts +29 -2
  46. package/dist/packages/work/src/shift/state.js +45 -15
  47. package/dist/packages/work/src/submit-proof.d.ts +11 -8
  48. package/dist/packages/work/src/submit-proof.js +11 -8
  49. package/dist/packages/work/src/usage.d.ts +1 -1
  50. package/dist/packages/work/src/usage.js +7 -1
  51. package/dist/packages/work/src/util/modifier-init.d.ts +7 -0
  52. package/dist/packages/work/src/util/modifier-init.js +73 -0
  53. package/dist/src/bundle/tar.d.ts +9 -4
  54. package/dist/src/bundle/tar.js +9 -4
  55. package/dist/src/capabilities.d.ts +76 -6
  56. package/dist/src/capabilities.js +49 -6
  57. package/dist/src/capability-mapping-client.d.ts +29 -0
  58. package/dist/src/capability-mapping-client.js +160 -0
  59. package/dist/src/cli.d.ts +16 -3
  60. package/dist/src/cli.js +1925 -281
  61. package/dist/src/config-dir.d.ts +1 -1
  62. package/dist/src/config-dir.js +1 -1
  63. package/dist/src/crypto/index.d.ts +1 -1
  64. package/dist/src/crypto/index.js +1 -1
  65. package/dist/src/crypto/org-root.d.ts +30 -12
  66. package/dist/src/crypto/org-root.js +162 -14
  67. package/dist/src/crypto/records.d.ts +2 -0
  68. package/dist/src/crypto/records.js +2 -0
  69. package/dist/src/defs.d.ts +38 -2
  70. package/dist/src/defs.js +593 -86
  71. package/dist/src/engine.d.ts +103 -25
  72. package/dist/src/engine.js +331 -79
  73. package/dist/src/hub.d.ts +77 -0
  74. package/dist/src/hub.js +162 -0
  75. package/dist/src/implements.d.ts +56 -0
  76. package/dist/src/implements.js +790 -0
  77. package/dist/src/index.d.ts +11 -9
  78. package/dist/src/index.js +6 -5
  79. package/dist/src/mcp/serve.d.ts +22 -0
  80. package/dist/src/mcp/serve.js +330 -41
  81. package/dist/src/mcp/server.d.ts +10 -7
  82. package/dist/src/mcp/server.js +53 -8
  83. package/dist/src/model.d.ts +48 -10
  84. package/dist/src/model.js +252 -99
  85. package/dist/src/order-resolver.d.ts +1 -0
  86. package/dist/src/order-resolver.js +8 -1
  87. package/dist/src/schemas/index.d.ts +11 -0
  88. package/dist/src/schemas/order.v1.schema.json +7 -1
  89. package/dist/src/store/def-source.d.ts +19 -0
  90. package/dist/src/store/def-source.js +87 -17
  91. package/dist/src/store/gc-recovery.d.ts +46 -0
  92. package/dist/src/store/gc-recovery.js +258 -0
  93. package/dist/src/store/gc.d.ts +94 -0
  94. package/dist/src/store/gc.js +562 -0
  95. package/dist/src/store/index.d.ts +3 -1
  96. package/dist/src/store/index.js +2 -0
  97. package/dist/src/store/install.d.ts +34 -5
  98. package/dist/src/store/install.js +73 -11
  99. package/dist/src/store/pre-commit-verifier.js +42 -2
  100. package/dist/src/store/snapshot-guard.d.ts +18 -0
  101. package/dist/src/store/snapshot-guard.js +94 -0
  102. package/dist/src/store.d.ts +69 -4
  103. package/dist/src/store.js +254 -16
  104. package/dist/src/types.d.ts +101 -20
  105. package/dist/src/util.js +4 -1
  106. package/docs/authoring.md +235 -10
  107. package/docs/bundles.md +45 -2
  108. package/docs/cli.md +437 -55
  109. package/docs/crypto.md +32 -10
  110. package/docs/design.md +177 -47
  111. package/docs/evals/mcp-charter-baseline.json +428 -0
  112. package/docs/mcp-charter-eval.md +124 -0
  113. package/docs/routing.md +189 -34
  114. package/docs/shift-logs.md +38 -9
  115. package/docs/wire-contracts.md +78 -14
  116. package/examples/workflows/compile-dev-playbook.yaml +1 -1
  117. package/examples/workflows/delivery.yaml +31 -14
  118. package/examples/workflows/ship.yaml +38 -4
  119. package/package.json +2 -1
  120. package/plugins/claude-code/plugin/.claude-plugin/plugin.json +1 -1
  121. package/plugins/claude-code/plugin/.mcp.json +1 -1
  122. package/plugins/claude-code/plugin/skills/author/SKILL.md +22 -0
  123. package/plugins/claude-code/plugin/skills/ephemeral/SKILL.md +95 -0
  124. package/plugins/claude-code/plugin/skills/graduate/SKILL.md +156 -0
  125. package/plugins/claude-code/plugin/skills/plan/SKILL.md +236 -0
  126. package/plugins/codex/plugins/owenloop/.codex-plugin/plugin.json +1 -1
  127. package/plugins/codex/plugins/owenloop/.mcp.json +1 -1
  128. package/plugins/codex/plugins/owenloop/skills/author/SKILL.md +22 -0
  129. package/plugins/codex/plugins/owenloop/skills/ephemeral/SKILL.md +95 -0
  130. package/plugins/codex/plugins/owenloop/skills/graduate/SKILL.md +156 -0
  131. package/plugins/codex/plugins/owenloop/skills/plan/SKILL.md +236 -0
@@ -11,7 +11,7 @@
11
11
  */
12
12
  import type { WorkflowStatus } from './model.ts';
13
13
  import type { SchemaIssue } from './schema.ts';
14
- import type { CapabilityRewrites } from './capabilities.ts';
14
+ import type { CapabilityMappings, CapabilityRewrites, CrewStamps } from './capabilities.ts';
15
15
  import type { MatchMode } from './capabilities.ts';
16
16
  import type { Store } from './store.ts';
17
17
  import type { Author, Fingerprint, Order, WorkflowDef } from './types.ts';
@@ -160,14 +160,16 @@ export interface CreateOpts {
160
160
  parentPath: string;
161
161
  };
162
162
  /**
163
- * The ONE routing modifier this instance carries for its whole life. Must be
164
- * a member of the def's declared `modifiers` set — `createInstance` throws
163
+ * The ONE routing modifier this instance carries at a time. Must be a member
164
+ * of the def's declared `modifiers` set — `createInstance` throws
165
165
  * {@link ModifierRefusalError} otherwise, rather than starting a run that
166
- * would compose capabilities no crew was ever bound to.
166
+ * would compose capabilities no crew was ever bound to. After creation, the
167
+ * engine may replace it only through a def-declared artifact bind during
168
+ * acceptance.
167
169
  *
168
170
  * Absent = an unmodified run: every step is offered on bare capabilities.
169
- * Never mutated after creation; an escalated re-offer carries its own target
170
- * modifier per-offer without rewriting this.
171
+ * An escalated re-offer carries its own target modifier per-offer without
172
+ * rewriting this stored value.
171
173
  */
172
174
  modifier?: string;
173
175
  }
@@ -225,7 +227,7 @@ export type EngineEvent = {
225
227
  type: 'closed';
226
228
  workflow: string;
227
229
  run: string;
228
- outcome: 'ok' | 'no_work' | 'failed' | 'skipped';
230
+ outcome: 'ok' | 'no_work' | 'released' | 'failed' | 'skipped';
229
231
  } | {
230
232
  type: 'settled';
231
233
  workflow: string;
@@ -381,11 +383,11 @@ export declare class Engine {
381
383
  */
382
384
  private static readonly CHILD_OUTCOME_PIN_KEY;
383
385
  /**
384
- * F4: the single place that computes "what child-outcome version is this
385
- * calls: artifact currently resting on" — used both when machine-greening
386
- * (STEP 6) and when stamping the pin at verdict time (reject propagation,
387
- * human skip). Returns undefined if no child has ever been spawned (nothing
388
- * to pin to).
386
+ * F4: the single verdict-time helper that computes "what child-outcome
387
+ * version is this calls: artifact currently resting on" for reject
388
+ * propagation and human skip. STEP 6 publication reads and stamps the version
389
+ * from its authoritative in-transaction snapshot instead. Returns undefined
390
+ * if no child has ever been spawned (nothing to pin to).
389
391
  */
390
392
  private childOutcomePin;
391
393
  /**
@@ -473,7 +475,8 @@ export declare class Engine {
473
475
  * Called at the top of tick (outside any tx) and as cascade-up prompt.
474
476
  * For each calls: step: spawn the child if gate is ready and no child exists;
475
477
  * re-attach if it exists; re-provide if parent inputs moved; machine-green
476
- * the parent artifact when the child's declared output is green.
478
+ * the parent artifact when the child's declared output is green and the
479
+ * whole child workflow is done.
477
480
  */
478
481
  private maintainCalls;
479
482
  /**
@@ -503,11 +506,12 @@ export declare class Engine {
503
506
  /**
504
507
  * STEP 6 re-arm as the mirror-image atomic guard. maintainCalls' optimistic
505
508
  * pre-read decides only WHETHER to call this; the parent artifact AND the
506
- * child outcome are re-read inside the write lock, and the re-arm happens only
507
- * if the parent is still green AND the child outcome is still NOT green in-tx.
508
- * If the child went green between the optimistic read and the tx, this does
509
- * nothing (returns false) and the next maintainCalls pass publishes normally.
510
- * Returns true only when it wrote.
509
+ * child definition/artifacts are re-read inside the write lock, and the
510
+ * re-arm happens only if the parent is still green AND either the child
511
+ * outcome is non-green or the whole child is unfinished in-tx. If the outcome
512
+ * is green and the child is done by then, this does nothing (returns false)
513
+ * and the next maintainCalls pass publishes normally. Returns true only when
514
+ * it wrote.
511
515
  */
512
516
  private rearmCallsGreen;
513
517
  /**
@@ -546,6 +550,23 @@ export declare class Engine {
546
550
  * decides a mode, it only enforces the one it is handed.
547
551
  */
548
552
  matchModes?: Record<string, MatchMode>;
553
+ /**
554
+ * Per-AUTHORED-capability substitution, applied BEFORE the offer composes
555
+ * with the modifier, so one entry covers every grade a step can be
556
+ * offered at. Supplied by the same caller that supplies `matchModes` and
557
+ * for the same reason — deciding what an authored name means in this org
558
+ * requires reading an install-scoped table the pure engine cannot see.
559
+ * Substitution is a single hop and the value is never validated; the
560
+ * caller resolves any chain first. See `applyCapabilityMappings`.
561
+ *
562
+ * Absent or empty is exact identity: the offer is composed from the
563
+ * authored list itself, byte for byte, as before this input existed.
564
+ *
565
+ * Distinct from `capabilityRewrites` below, which is keyed by the
566
+ * COMPOSED string and applied AFTER composition. Both may apply in one
567
+ * tick, in that order.
568
+ */
569
+ capabilityMappings?: CapabilityMappings;
549
570
  /**
550
571
  * Per-offered-capability reroute, keyed by the COMPOSED capability the
551
572
  * offer would otherwise carry. Supplied by the same caller that supplies
@@ -559,6 +580,12 @@ export declare class Engine {
559
580
  * record still shows the grade of service that was requested.
560
581
  */
561
582
  capabilityRewrites?: CapabilityRewrites;
583
+ /**
584
+ * Per-offered-capability crews matched by the caller that owns routing
585
+ * bindings. The pure engine cannot compute this; it stamps the supplied
586
+ * match result onto the order that is actually served.
587
+ */
588
+ crewStamps?: CrewStamps;
562
589
  }): TickResult;
563
590
  /**
564
591
  * The recursive tick worker. Runs this instance's own maintain → reap →
@@ -633,9 +660,11 @@ export declare class Engine {
633
660
  * Per-step cadence + daily budget + parallel cap over the eligible firings.
634
661
  *
635
662
  * A2: `capabilities` is the tick caller's claim filter, matched against the
636
- * step's OFFERED capabilities — the authored list composed with the modifier
637
- * this firing will actually be offered under (`wise` + `deep` → `wise:deep`),
638
- * which is the same list the order will carry. `claimMatches` owns the rule;
663
+ * step's OFFERED capabilities — the authored list mapped onto the caller's
664
+ * own capability names, composed with the modifier this firing will actually
665
+ * be offered under (`wise` + `deep` → `wise:deep`), then rewritten by any
666
+ * reroute the caller decided on, which is the same list the order will carry.
667
+ * `claimMatches` owns the rule;
639
668
  * see it for the four cases (no filter presented, capability-silent step,
640
669
  * empty caller list, both non-empty) and for what `matchModes` changes.
641
670
  * A firing this caller may not claim is deferred as `'capability-mismatch'`.
@@ -708,6 +737,33 @@ export declare class Engine {
708
737
  * the order's digest — before any caller can execute a prompt or command.
709
738
  */
710
739
  resolveOrder(order: Order): ResolvedInstructions;
740
+ /** Return the binding declaration that owns this artifact path, if any. */
741
+ private artifactBind;
742
+ /** Resolve a declared dot-path of object keys against an accepted artifact value. */
743
+ private boundValue;
744
+ /**
745
+ * The bind-time and reject-time modifier gate: membership in the def's
746
+ * declared `modifiers` set, and nothing else — byte for byte the rule the
747
+ * start path applies in `createInstanceInTx`. One value cannot be legal to
748
+ * start a run with and illegal to bind.
749
+ *
750
+ * `def` here is the PINNED snapshot, so the vocabulary checked is the one
751
+ * stamped on this run, not a later republish.
752
+ *
753
+ * The SHAPE of a name is constrained where a name is authored:
754
+ * `parseModifiers` in `src/defs.ts` refuses an empty name, a name containing
755
+ * whitespace, a name containing `MODIFIER_SEPARATOR`, and a duplicate.
756
+ * Re-testing shape here is what split the vocabulary in the first place — a
757
+ * value the parser admitted and `start_run` accepted, refused at bind.
758
+ */
759
+ private assertBoundModifier;
760
+ /** Validate extraction before an acceptance branch changes an artifact. */
761
+ private validateArtifactBind;
762
+ /**
763
+ * Persist a declared instance-routing write and its single artifact-level
764
+ * audit event. Call only from an already-accepted branch inside its tx.
765
+ */
766
+ private applyArtifactBind;
711
767
  /**
712
768
  * Commit a singleton/map output green — or born-reject it if an input moved.
713
769
  *
@@ -769,7 +825,7 @@ export declare class Engine {
769
825
  * See `docs/design.md` §24.9 for the full writeup and operator mitigations
770
826
  * (`parallel: 1`, a generous `reapTtl:` on slow judge steps).
771
827
  */
772
- reject(workflow: string, path: string, by: Author, text: string): {
828
+ reject(workflow: string, path: string, by: Author, text: string, requested?: string): {
773
829
  outcome: 'rejected' | 'born-rejected';
774
830
  reason?: string;
775
831
  };
@@ -845,7 +901,7 @@ export declare class Engine {
845
901
  */
846
902
  retry(workflow: string, path: string, by?: Author, text?: string): void;
847
903
  /** Close a run (audit/budget) and release its lease so the task can re-arm. */
848
- close(workflow: string, run: string, outcome?: 'ok' | 'no_work' | 'failed' | 'skipped', summary?: string): void;
904
+ close(workflow: string, run: string, outcome?: 'ok' | 'no_work' | 'released' | 'failed' | 'skipped', summary?: string): void;
849
905
  /**
850
906
  * Touch the liveness timestamp on an open run's task. A run that periodically
851
907
  * calls heartbeat() will never be falsely reaped as long as beats arrive within
@@ -926,10 +982,32 @@ export declare class Engine {
926
982
  private settle;
927
983
  private applyOp;
928
984
  /**
929
- * §12.2 born-reject lease release: close the run (`no_work`) and re-arm its
985
+ * Re-stamp the owed version target for `path` on any OPEN claim that owes it.
986
+ *
987
+ * The target frozen at claim issue is `committed + 1`. That stays correct for
988
+ * every refusal that leaves the run open WITHOUT bumping the artifact (the
989
+ * schema reject and the artifact-bind reject in `green()`). It goes stale for
990
+ * a judgment/human reject, which is preceded by a commit that already bumped
991
+ * the artifact and which leaves the SAME claim live to retry: the next commit
992
+ * lands `committed + 1` from the new committed version, while the producer is
993
+ * still signing the old number into its proof's `produced[].version`. The
994
+ * proof row is then stored under a key the envelope does not name, and the
995
+ * consumer's version check refuses the artifact.
996
+ *
997
+ * Matching is by owed path, not by task key, so it is correct for map
998
+ * elements without re-deriving the binding key. Runs inside the caller's open
999
+ * tx (plain store writes, no nested tx).
1000
+ */
1001
+ private restampOwedTarget;
1002
+ /**
1003
+ * §12.2 born-reject lease release: close the run (`released`) and re-arm its
930
1004
  * task to `idle` so the firing is immediately re-claimable next tick. Runs
931
1005
  * inside the caller's open tx (plain store write, no nested tx). Unlike reap()
932
- * it does NOT bump attempts — a CAS-stale born-reject is not lease churn. The
1006
+ * it does NOT bump attempts — a CAS-stale born-reject is not lease churn. For
1007
+ * the same reason the outcome is `released` and not `no_work`: the step never
1008
+ * ran, so the run must not spend the daily budget or restart the cadence
1009
+ * clock either. `no_work` is reserved for a step that DID run and had nothing
1010
+ * to produce, which is a firing and does spend both. The
933
1011
  * `closed` event is fired by the caller AFTER the tx commits (post-commit
934
1012
  * ordering), matching public close().
935
1013
  */