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
package/docs/crypto.md CHANGED
@@ -70,7 +70,7 @@ child stderr is never interpolated into error text.
70
70
  | `machine` | the literal `"local"` |
71
71
  | `agent` | the agent identity id |
72
72
 
73
- `owenloop setup` step `[4/7] signing keys` ensures all three, in that order,
73
+ `owenloop setup` step `[4/8] signing keys` ensures all three, in that order,
74
74
  idempotently: a second run performs zero writes.
75
75
 
76
76
  **One backend is selected once and never error-fallback.** A fallback after a
@@ -523,16 +523,16 @@ sidecar is checked against the bundle digest and the local `allowed_signers`
523
523
  trust root. Origin verification is separate: `verifyOrigin` returns `absent`
524
524
  when the origin sidecar is missing, `verified` only after DSSE signature, schema,
525
525
  signer-key, and bundle-digest checks pass, and `unverifiable` or `invalid` for
526
- the corresponding failures. The trust-root path is `<config>/allowed_signers`, where `<config>` is
527
- `$OWENLOOP_CONFIG_DIR` when set to a non-blank absolute path, else
528
- `$XDG_CONFIG_HOME/owenloop` when `XDG_CONFIG_HOME` is non-blank, else
529
- `$HOME/.config/owenloop`. A missing or malformed trust root produces the distinct
526
+ the corresponding failures. The trust-root path is `<config>/allowed_signers`,
527
+ where `<config>` is `$HOME/.owenloop` by default or the absolute
528
+ `OWENLOOP_CONFIG_DIR` override. `XDG_CONFIG_HOME` is not consulted. A missing
529
+ or malformed trust root produces the distinct
530
530
  `unverifiable` verdict; a present signature that fails verification produces
531
531
  `invalid`.
532
532
 
533
533
  The execution and install policy is `defPolicy`, with built-in default `warn`.
534
- Set `defPolicy` in the JSON settings file at `<config>/settings.json` (same
535
- ladder as the trust root above), for example:
534
+ Set `defPolicy` in the JSON settings file at `$HOME/.owenloop/settings.json`,
535
+ for example:
536
536
 
537
537
  ```json
538
538
  {
@@ -711,24 +711,40 @@ whole organization.
711
711
 
712
712
  ### Local anchor and envelope files
713
713
 
714
- The optional filesystem loader derives paths from injected environment state:
715
- `OWENLOOP_CONFIG_DIR` wins over `XDG_CONFIG_HOME`, which wins over `HOME`;
716
- there is no ambient home-directory lookup.
717
- The local layout is:
714
+ The optional filesystem loader derives paths from the shared owenloop config
715
+ directory (`$HOME/.owenloop` by default, or the absolute
716
+ `OWENLOOP_CONFIG_DIR` override). `XDG_CONFIG_HOME` is not consulted. The local
717
+ layout is:
718
718
 
719
719
  ```text
720
- <config>/owenloop/org-root.pub # public anchor, 0644
721
- <config>/owenloop/org-root # private anchor, 0600
722
- <config>/owenloop/roster/<sha256hex(keyid)>.grant.dsse
723
- <config>/owenloop/revocations/<sha256hex(keyid)>.revocation.dsse
720
+ <config>/org-root.pub # public anchor, 0644
721
+ <config>/org-root # private anchor, 0600
722
+ <config>/grants/<sha256hex(keyid)>.grant.dsse
723
+ <config>/revocations/<sha256hex(keyid)>.revocation.dsse
724
724
  ```
725
725
 
726
726
  The root key is stored outside `PrincipalKeyManager` because the root is not a
727
727
  hub-scoped principal key. The containing directory is `0700`; the private root
728
- is never returned by the library or placed in an envelope. `loadRoster` and
728
+ is never returned by the library or placed in an envelope. `loadGrants` and
729
729
  `loadRevocations` return raw envelope bytes to the pure validator and refuse
730
730
  symlinked or non-regular files.
731
731
 
732
+ If `<config>/grants` has zero `*.grant.dsse` entries while the pre-rename
733
+ `<config>/roster` is a readable, non-symlink directory of regular files that
734
+ holds grants, owenloop refuses rather than treating the machine as unenrolled.
735
+ It never reads or moves that legacy directory. When `<config>/grants` is
736
+ absent, the shell-quoted remediation is structurally
737
+ `mv <config>/roster <config>/grants`; this whole-directory rename preserves
738
+ every accepted grant filename, including dot-prefixed names. When a grants path
739
+ already exists, the printed remediation is instead
740
+ `rmdir <config>/grants && mv <config>/roster <config>/grants`. It moves only if
741
+ that path is an empty real directory; otherwise `rmdir` fails without moving
742
+ anything, and the operator must inspect `<config>/grants` by hand before
743
+ retrying. In either case, restart running owenloop shift daemons after a
744
+ successful migration. If the legacy source is a file or symlink, cannot be
745
+ inspected, or contains a non-regular entry, owenloop prints no migration
746
+ command: repair the named source path by hand before retrying the migration.
747
+
732
748
  ## Admin-signed policy floors
733
749
 
734
750
  A policy floor is an org-wide minimum for local enforcement. An org admin signs
package/docs/design.md CHANGED
@@ -970,6 +970,13 @@ step's last owed submit is what closes it — so the reverse order made every
970
970
  reject from a single-owed-path step undeliverable. What follows the reject
971
971
  depends on the hub's own answer, in its `closed` field:
972
972
 
973
+ The payload reject's `text` starts with the script's reason. When the command
974
+ has a non-empty captured output tail, the worker appends a labeled
975
+ `--- command output (last N bytes) ---` section containing the last 4 KiB of
976
+ combined stdout-then-stderr output (lossy UTF-8, with trailing newlines
977
+ trimmed before counting bytes). An empty tail adds nothing, and the payload
978
+ marker line is retained. Judge rejects are not changed by this formatting.
979
+
973
980
  - `closed: true` — the rejected path was one of this firing's consumed inputs,
974
981
  so the hub closed the run `no_work`. The owed paths stay debts and the step
975
982
  re-fires against the rebuilt input. No receipt is submitted: an artifact
@@ -1682,7 +1689,7 @@ addressed by digest.
1682
1689
  record or throws the named refusal; `resolveOrder(order)` builds the
1683
1690
  `{defDigest, step, key}` ref from an order and additionally materializes the
1684
1691
  runtime placeholders in the resolved prompt — the same substitution
1685
- `${WORKFLOW}`/`${RUN}`/`${STEP}`/`${KEY}`/`${INDEX}`/`${MAX_ATTEMPTS}` that
1692
+ `${WORKFLOW}`/`${RUN}`/`${STEP}`/`${KEY}`/`${INDEX}`/`${MODIFIER}`/`${MAX_ATTEMPTS}` that
1686
1693
  `buildOrder` used to inline, moved whole to resolution time (unknown
1687
1694
  placeholders stay untouched; `MAX_ATTEMPTS` renders the `maxAttempts` metadata
1688
1695
  from the resolved instruction record). Substitution
@@ -1846,3 +1853,65 @@ path still requires a pre-commit verifier and remains fail-closed when that
1846
1853
  adapter is not provided. The ingestor and verifier are separate concerns:
1847
1854
  ingestion makes the bundle's verified object available, while the verifier
1848
1855
  decides whether the install may commit it.
1856
+
1857
+ ## §31 Cleanup on cancellation (`onCancel:`)
1858
+
1859
+ The engine's step grammar has a declarative cleanup marker:
1860
+
1861
+ ```yaml
1862
+ - name: deprovisioner
1863
+ consumes: [merge, workspace]
1864
+ onCancel:
1865
+ consumes: [workspace]
1866
+ ```
1867
+
1868
+ This is deliberately a new step key rather than another `on:` token.
1869
+
1870
+ | Existing key | What it means | Why it is not cleanup-on-cancel |
1871
+ |---|---|---|
1872
+ | `terminal: true` | A step's green is a destructive completion. | It says nothing about run lifecycle. |
1873
+ | `effect.onInvalidate` | Routes an already-green artifact after its inputs move. | Cancellation is not an input move. |
1874
+ | `on:` | Pure in-run firing vocabulary. | It has no lifecycle signal or per-trigger consume payload. |
1875
+ | `idleAfter:` | Duration sidecar for `on: [idle]`. | It is unrelated to cancellation. |
1876
+ | `x:` | Opaque extension map. | It cannot validate this declaration or catch typos. |
1877
+
1878
+ Finally, `on:` is evaluated by the clock-free, state-pure
1879
+ `eligibleFirings(ArtifactMap, TimeFacts)`; cancellation is neither artifact
1880
+ state nor a time fact, and `WorkflowData` has no instance status. It therefore
1881
+ cannot be a scheduler trigger in this package.
1882
+
1883
+ `onCancel:` is a mapping with exactly one required key, `consumes:`, a list of
1884
+ strings that may be empty. Every entry must be a unique stem from the owning
1885
+ step's own plain consumes. Map and reduce consumes have no key binding on a
1886
+ one-time cancellation firing and are refused. The key is refused on `calls:`
1887
+ steps by that grammar's smaller key allowlist. `allGreen` and `idle`
1888
+ evaluators may declare `onCancel:` only with an empty list because they cannot
1889
+ declare normal consumes. `terminal: true` together with `onCancel:` remains
1890
+ legal deliberately: the engine does not infer an author's cleanup policy.
1891
+
1892
+ `onCancel:` is inert in the standalone engine. It does not affect
1893
+ `eligibleFirings`, `modelCheck`, the forward cascade, or done-ness. A host
1894
+ with no cancellation concept loads a definition carrying it with no behavior
1895
+ change.
1896
+
1897
+ The control plane contract is:
1898
+
1899
+ > **`onCancel:` contract.** When the control plane cancels a run of instance `W`:
1900
+ >
1901
+ > 1. Resolve `W`'s def — `WorkflowData.defSnapshot` when pinned (§28), otherwise by name.
1902
+ > 2. Select the cleanup steps: `cancelCleanupSteps(def)` (exported from `owenloop`), i.e. every
1903
+ > step where `step.onCancel !== undefined`, in def order.
1904
+ > 3. For each such step `S`: if **every** stem in `S.onCancel.consumes` is green, dispatch an
1905
+ > order for `S` whose inputs are exactly those stems and their values. If any is not green,
1906
+ > `S` is not dispatchable — record that and do not block cancellation on it.
1907
+ > 4. `assertServableInstance` (`packages/hub-core/src/serving.ts`) must admit an order on a
1908
+ > `cancelled` instance **only** when that order is for a step selected in step 2. Every other
1909
+ > step stays refused, exactly as today.
1910
+ > 5. A step with no `onCancel:` is never dispatched after cancel — today's behaviour, unchanged.
1911
+ > 6. **Recommended, and the follow-on run's call to confirm:** hold the cancelled instance out of
1912
+ > its final closed state until each dispatched cleanup step's produces settle (green, or
1913
+ > exhausted per that step's `maxAttempts`). Closing immediately would reproduce the original
1914
+ > defect in a slower form — the order exists but nothing waits for it.
1915
+ > 7. `onCancel:` is inert in the standalone engine. `eligibleFirings`, `modelCheck`, the forward
1916
+ > cascade, and done-ness do not read it. A host with no cancellation concept loads and runs a
1917
+ > def carrying it with no behaviour change.