owenloop 0.5.0 → 0.5.1

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 (211) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/README.md +137 -35
  3. package/bin/owenloop.mjs +49 -1
  4. package/dist/packages/work/src/agent/brief.d.ts +8 -4
  5. package/dist/packages/work/src/agent/brief.js +7 -3
  6. package/dist/packages/work/src/agent/loop.d.ts +13 -7
  7. package/dist/packages/work/src/agent/loop.js +136 -9
  8. package/dist/packages/work/src/agent/model-policy.d.ts +49 -0
  9. package/dist/packages/work/src/agent/model-policy.js +138 -0
  10. package/dist/packages/work/src/bundle/cache.d.ts +7 -5
  11. package/dist/packages/work/src/bundle/cache.js +20 -6
  12. package/dist/packages/work/src/bundle/fetch.d.ts +7 -5
  13. package/dist/packages/work/src/bundle/fetch.js +27 -7
  14. package/dist/packages/work/src/bundle/types.d.ts +8 -4
  15. package/dist/packages/work/src/consumed-verifier.d.ts +45 -0
  16. package/dist/packages/work/src/consumed-verifier.js +205 -0
  17. package/dist/packages/work/src/exec/instructions.d.ts +99 -0
  18. package/dist/packages/work/src/exec/instructions.js +323 -0
  19. package/dist/packages/work/src/exec/loop.d.ts +12 -1
  20. package/dist/packages/work/src/exec/loop.js +137 -20
  21. package/dist/packages/work/src/exec/payload.d.ts +29 -0
  22. package/dist/packages/work/src/exec/payload.js +54 -0
  23. package/dist/packages/work/src/exec/receipt.d.ts +9 -6
  24. package/dist/packages/work/src/exec/receipt.js +12 -1
  25. package/dist/packages/work/src/exec/runner.d.ts +7 -1
  26. package/dist/packages/work/src/exec/runner.js +74 -3
  27. package/dist/packages/work/src/harness/child-env.js +7 -0
  28. package/dist/packages/work/src/harness/claude.d.ts +20 -8
  29. package/dist/packages/work/src/harness/claude.js +260 -58
  30. package/dist/packages/work/src/harness/codex.d.ts +5 -4
  31. package/dist/packages/work/src/harness/codex.js +169 -41
  32. package/dist/packages/work/src/harness/contract.d.ts +36 -11
  33. package/dist/packages/work/src/harness/fake.js +1 -0
  34. package/dist/packages/work/src/harness/jsonrpc-stdio.js +7 -0
  35. package/dist/packages/work/src/harness/permissions.d.ts +16 -3
  36. package/dist/packages/work/src/harness/permissions.js +102 -13
  37. package/dist/packages/work/src/harness/session-store.d.ts +27 -9
  38. package/dist/packages/work/src/harness/session-store.js +271 -67
  39. package/dist/packages/work/src/hold/mcp.d.ts +25 -5
  40. package/dist/packages/work/src/hold/mcp.js +126 -11
  41. package/dist/packages/work/src/hub/client.d.ts +2 -1
  42. package/dist/packages/work/src/hub/client.js +14 -1
  43. package/dist/packages/work/src/hub/types.d.ts +69 -33
  44. package/dist/packages/work/src/hub/types.js +8 -10
  45. package/dist/packages/work/src/mcp/server.js +1 -1
  46. package/dist/packages/work/src/owenloop-bin.d.ts +1 -0
  47. package/dist/packages/work/src/owenloop-bin.js +18 -0
  48. package/dist/packages/work/src/roles/agent-run.d.ts +12 -6
  49. package/dist/packages/work/src/roles/agent-run.js +116 -34
  50. package/dist/packages/work/src/roles/exec.d.ts +8 -0
  51. package/dist/packages/work/src/roles/exec.js +27 -2
  52. package/dist/packages/work/src/roles/hold.d.ts +4 -0
  53. package/dist/packages/work/src/roles/hold.js +44 -5
  54. package/dist/packages/work/src/roles/lint.d.ts +3 -4
  55. package/dist/packages/work/src/roles/lint.js +41 -7
  56. package/dist/packages/work/src/roles/settings.js +5 -0
  57. package/dist/packages/work/src/roles/shift.d.ts +1 -0
  58. package/dist/packages/work/src/roles/shift.js +23 -1
  59. package/dist/packages/work/src/settings/settings.d.ts +17 -1
  60. package/dist/packages/work/src/settings/settings.js +39 -0
  61. package/dist/packages/work/src/shift/loop.d.ts +14 -3
  62. package/dist/packages/work/src/shift/loop.js +447 -164
  63. package/dist/packages/work/src/shift/protocol.d.ts +4 -0
  64. package/dist/packages/work/src/shift/runtime.d.ts +2 -0
  65. package/dist/packages/work/src/shift/runtime.js +66 -3
  66. package/dist/packages/work/src/shift/spawn.d.ts +41 -18
  67. package/dist/packages/work/src/shift/spawn.js +89 -31
  68. package/dist/packages/work/src/shift/state.d.ts +53 -51
  69. package/dist/packages/work/src/shift/state.js +325 -102
  70. package/dist/packages/work/src/submit-proof.d.ts +36 -0
  71. package/dist/packages/work/src/submit-proof.js +93 -0
  72. package/dist/src/add.d.ts +64 -259
  73. package/dist/src/add.js +81 -615
  74. package/dist/src/archive.d.ts +97 -0
  75. package/dist/src/archive.js +591 -0
  76. package/dist/src/bundle/index.d.ts +64 -0
  77. package/dist/src/bundle/index.js +508 -0
  78. package/dist/src/bundle/manifest.d.ts +50 -0
  79. package/dist/src/bundle/manifest.js +435 -0
  80. package/dist/src/bundle/runtime.d.ts +26 -0
  81. package/dist/src/bundle/runtime.js +64 -0
  82. package/dist/src/bundle/tar.d.ts +62 -0
  83. package/dist/src/bundle/tar.js +238 -0
  84. package/dist/src/bundle/types.d.ts +105 -0
  85. package/dist/src/bundle/types.js +21 -0
  86. package/dist/src/cli.d.ts +90 -20
  87. package/dist/src/cli.js +2407 -365
  88. package/dist/src/credentials.d.ts +4 -3
  89. package/dist/src/credentials.js +21 -19
  90. package/dist/src/crypto/allowed-signers.d.ts +68 -0
  91. package/dist/src/crypto/allowed-signers.js +307 -0
  92. package/dist/src/crypto/canonical.d.ts +8 -0
  93. package/dist/src/crypto/canonical.js +92 -0
  94. package/dist/src/crypto/chain.d.ts +65 -0
  95. package/dist/src/crypto/chain.js +377 -0
  96. package/dist/src/crypto/dsse.d.ts +209 -0
  97. package/dist/src/crypto/dsse.js +282 -0
  98. package/dist/src/crypto/enrollment.d.ts +78 -0
  99. package/dist/src/crypto/enrollment.js +186 -0
  100. package/dist/src/crypto/index.d.ts +48 -0
  101. package/dist/src/crypto/index.js +44 -0
  102. package/dist/src/crypto/keys.d.ts +258 -0
  103. package/dist/src/crypto/keys.js +908 -0
  104. package/dist/src/crypto/org-root.d.ts +33 -0
  105. package/dist/src/crypto/org-root.js +78 -0
  106. package/dist/src/crypto/origin-rules.d.ts +56 -0
  107. package/dist/src/crypto/origin-rules.js +143 -0
  108. package/dist/src/crypto/policy-floor.d.ts +98 -0
  109. package/dist/src/crypto/policy-floor.js +353 -0
  110. package/dist/src/crypto/records.d.ts +316 -0
  111. package/dist/src/crypto/records.js +157 -0
  112. package/dist/src/crypto/scope.d.ts +49 -0
  113. package/dist/src/crypto/scope.js +83 -0
  114. package/dist/src/crypto/ssh.d.ts +171 -0
  115. package/dist/src/crypto/ssh.js +396 -0
  116. package/dist/src/crypto/submission.d.ts +33 -0
  117. package/dist/src/crypto/submission.js +47 -0
  118. package/dist/src/crypto/trust-roots.d.ts +29 -0
  119. package/dist/src/crypto/trust-roots.js +39 -0
  120. package/dist/src/crypto/verify-consumed.d.ts +67 -0
  121. package/dist/src/crypto/verify-consumed.js +259 -0
  122. package/dist/src/crypto/verify-origin.d.ts +50 -0
  123. package/dist/src/crypto/verify-origin.js +151 -0
  124. package/dist/src/crypto/verify-publication.d.ts +60 -0
  125. package/dist/src/crypto/verify-publication.js +150 -0
  126. package/dist/src/defs.d.ts +24 -1
  127. package/dist/src/defs.js +145 -25
  128. package/dist/src/engine.d.ts +99 -3
  129. package/dist/src/engine.js +238 -34
  130. package/dist/src/factory.d.ts +16 -0
  131. package/dist/src/factory.js +16 -4
  132. package/dist/src/global-config.d.ts +59 -0
  133. package/dist/src/global-config.js +84 -0
  134. package/dist/src/hub.d.ts +75 -21
  135. package/dist/src/hub.js +123 -40
  136. package/dist/src/index.d.ts +17 -2
  137. package/dist/src/index.js +20 -2
  138. package/dist/src/install.d.ts +538 -0
  139. package/dist/src/install.js +1981 -0
  140. package/dist/src/lock.d.ts +15 -57
  141. package/dist/src/lock.js +251 -143
  142. package/dist/src/mcp/serve.d.ts +46 -22
  143. package/dist/src/mcp/serve.js +167 -44
  144. package/dist/src/mcp/server.js +12 -1
  145. package/dist/src/model.d.ts +15 -0
  146. package/dist/src/model.js +111 -1
  147. package/dist/src/order-resolver.d.ts +184 -0
  148. package/dist/src/order-resolver.js +252 -0
  149. package/dist/src/package-version.d.ts +10 -0
  150. package/dist/src/package-version.js +42 -0
  151. package/dist/src/paths.d.ts +14 -1
  152. package/dist/src/paths.js +18 -0
  153. package/dist/src/schemas/enrollment-grant.v1.schema.json +90 -0
  154. package/dist/src/schemas/index.d.ts +1416 -0
  155. package/dist/src/schemas/index.js +31 -0
  156. package/dist/src/schemas/order.v1.schema.json +106 -0
  157. package/dist/src/schemas/origin.v1.schema.json +68 -0
  158. package/dist/src/schemas/policy-floor.v1.schema.json +29 -0
  159. package/dist/src/schemas/publication.v1.schema.json +31 -0
  160. package/dist/src/schemas/revocation.v1.schema.json +39 -0
  161. package/dist/src/schemas/submission.v1.schema.json +61 -0
  162. package/dist/src/store/def-source.d.ts +52 -0
  163. package/dist/src/store/def-source.js +335 -0
  164. package/dist/src/store/index-file.d.ts +69 -0
  165. package/dist/src/store/index-file.js +151 -0
  166. package/dist/src/store/index.d.ts +27 -0
  167. package/dist/src/store/index.js +22 -0
  168. package/dist/src/store/ingestor.d.ts +43 -0
  169. package/dist/src/store/ingestor.js +211 -0
  170. package/dist/src/store/install.d.ts +228 -0
  171. package/dist/src/store/install.js +555 -0
  172. package/dist/src/store/instruction-source.d.ts +49 -0
  173. package/dist/src/store/instruction-source.js +298 -0
  174. package/dist/src/store/origin-evidence.d.ts +21 -0
  175. package/dist/src/store/origin-evidence.js +66 -0
  176. package/dist/src/store/pre-commit-verifier.d.ts +68 -0
  177. package/dist/src/store/pre-commit-verifier.js +418 -0
  178. package/dist/src/store/resolve.d.ts +138 -0
  179. package/dist/src/store/resolve.js +363 -0
  180. package/dist/src/store/types.d.ts +288 -0
  181. package/dist/src/store/types.js +356 -0
  182. package/dist/src/types.d.ts +45 -11
  183. package/dist/src/untar.d.ts +8 -23
  184. package/dist/src/untar.js +10 -136
  185. package/docs/agent-runner.md +86 -0
  186. package/docs/authoring.md +57 -6
  187. package/docs/bundles.md +250 -0
  188. package/docs/cli.md +1171 -97
  189. package/docs/crypto.md +816 -0
  190. package/docs/design.md +342 -20
  191. package/docs/embedding.md +132 -25
  192. package/docs/wire-contracts.md +380 -0
  193. package/package.json +6 -1
  194. package/plugins/claude-code/.claude-plugin/marketplace.json +14 -0
  195. package/plugins/claude-code/plugin/.claude-plugin/plugin.json +8 -0
  196. package/plugins/claude-code/plugin/.mcp.json +14 -0
  197. package/plugins/claude-code/plugin/hooks/hooks.json +26 -0
  198. package/plugins/claude-code/plugin/hooks/session-end.sh +40 -0
  199. package/plugins/claude-code/plugin/hooks/session-start.sh +52 -0
  200. package/plugins/claude-code/plugin/skills/author/SKILL.md +181 -0
  201. package/plugins/claude-code/plugin/skills/conduct/SKILL.md +106 -0
  202. package/plugins/claude-code/plugin/skills/shift/SKILL.md +105 -0
  203. package/plugins/codex/.agents/plugins/marketplace.json +21 -0
  204. package/plugins/codex/plugins/owenloop/.codex-plugin/plugin.json +7 -0
  205. package/plugins/codex/plugins/owenloop/.mcp.json +20 -0
  206. package/plugins/codex/plugins/owenloop/hooks/hooks.json +26 -0
  207. package/plugins/codex/plugins/owenloop/hooks/session-end.sh +40 -0
  208. package/plugins/codex/plugins/owenloop/hooks/session-start.sh +52 -0
  209. package/plugins/codex/plugins/owenloop/skills/author/SKILL.md +181 -0
  210. package/plugins/codex/plugins/owenloop/skills/conduct/SKILL.md +106 -0
  211. package/plugins/codex/plugins/owenloop/skills/shift/SKILL.md +105 -0
@@ -0,0 +1,335 @@
1
+ /**
2
+ * WS-6: the content-addressed workflow store → `WorkflowDef` bridge.
3
+ *
4
+ * Executable discovery is strict: an indexed coordinate is an integrity
5
+ * boundary, so a corrupt index or object aborts discovery rather than
6
+ * disappearing and allowing another store level to win. A valid multi-workflow
7
+ * bundle without a default remains explicit-workflow-only and gets no coordinate
8
+ * alias. Read-only callers that deliberately accept partial data must use
9
+ * {@link inspectCasDefs}; its result carries `complete: false` whenever data was
10
+ * skipped and must never be used to build an executable `DefResolver`.
11
+ */
12
+ import { readFileSync } from 'node:fs';
13
+ import { join } from 'node:path';
14
+ import { parseManifestBytes } from "../bundle/manifest.js";
15
+ import { digestScopedCallsTargetKey, loadDefFile } from "../defs.js";
16
+ import { readWorkflowStoreIndex } from "./index-file.js";
17
+ import { verifyWorkflowObjectSync } from "./ingestor.js";
18
+ import { coordinateDigestReadSync, probeObjectDir, probeStoreRoot, projectStoreRoot, storeIndexPath, } from "./resolve.js";
19
+ import { compareStoreText, defDigest, objectDirForDigest, parseWorkflowCoordinate, selectLatestVersion, StoreIntegrityError, } from "./types.js";
20
+ class CasObjectAbsentDuringCoordinatedRead extends Error {
21
+ }
22
+ /** Runtime incompatibility is a listing warning, unlike store corruption. */
23
+ class CasRuntimeIncompatibleError extends Error {
24
+ }
25
+ function isRuntimeIncompatible(error) {
26
+ return error instanceof Error
27
+ && error.message.includes('incompatible with this Owenloop runtime');
28
+ }
29
+ function failureMessage(error) {
30
+ return error instanceof Error ? error.message : String(error);
31
+ }
32
+ /** Read one root's coordinate-preserving index. */
33
+ function readIndexedCoordinates(root, level, tolerant, warn) {
34
+ try {
35
+ if (probeStoreRoot(root) !== 'dir')
36
+ return { entries: [], complete: true };
37
+ const index = readWorkflowStoreIndex(storeIndexPath(root));
38
+ const entries = Object.entries(index.entries)
39
+ .sort(([a], [b]) => compareStoreText(a, b))
40
+ .map(([coordinate, entry]) => ({
41
+ coordinate: coordinate,
42
+ entry,
43
+ root,
44
+ level,
45
+ }));
46
+ return { entries, complete: true };
47
+ }
48
+ catch (error) {
49
+ if (!tolerant)
50
+ throw error;
51
+ warn(`warning: incomplete ${level} workflow store at ${root}: ${failureMessage(error)}`);
52
+ return { entries: [], complete: false };
53
+ }
54
+ }
55
+ /** Load and verify every definition in one immutable object. */
56
+ function loadObjectDefs(objectDir, bundleDigest, level) {
57
+ try {
58
+ verifyWorkflowObjectSync(objectDir, bundleDigest, { coordinateRepair: false });
59
+ const manifest = parseManifestBytes(readFileSync(join(objectDir, 'bundle.yaml')));
60
+ const defs = new Map();
61
+ // Sorted, not YAML key order. `defs` is handed to callers as a Map, whose
62
+ // iteration order is this insertion order; nothing downstream currently
63
+ // depends on it (`selectWorkflowRegistrations` re-sorts by qualified name,
64
+ // and `coordinateTarget` reads `keys()` only when there is exactly one), so
65
+ // this is defensive: it keeps a public iteration order from tracking how the
66
+ // manifest author happened to write the file.
67
+ const manifestWorkflows = Object.entries(manifest.workflows)
68
+ .sort(([a], [b]) => compareStoreText(a, b));
69
+ for (const [workflowName, workflowPath] of manifestWorkflows) {
70
+ const def = loadDefFile(join(objectDir, workflowPath));
71
+ if (def.name !== workflowName) {
72
+ throw new Error(`workflow '${workflowPath}' has definition name '${def.name}', expected '${workflowName}'`);
73
+ }
74
+ def.bundlePackage = manifest.package.name;
75
+ def.bundleDigest = bundleDigest;
76
+ def.bundleLock = { ...manifest.lock };
77
+ defs.set(def.name, def);
78
+ }
79
+ return { bundleDigest, manifest, defs, level };
80
+ }
81
+ catch (error) {
82
+ if (isRuntimeIncompatible(error)) {
83
+ throw new CasRuntimeIncompatibleError(failureMessage(error));
84
+ }
85
+ if (error instanceof StoreIntegrityError)
86
+ throw error;
87
+ throw new StoreIntegrityError('object-corrupt', bundleDigest, failureMessage(error));
88
+ }
89
+ }
90
+ function loadObjectIfPresent(root, digest, level) {
91
+ const objectDir = objectDirForDigest(root, digest);
92
+ try {
93
+ return coordinateDigestReadSync(root, digest, () => {
94
+ if (probeObjectDir(objectDir, digest, level) !== 'dir') {
95
+ throw new CasObjectAbsentDuringCoordinatedRead();
96
+ }
97
+ return loadObjectDefs(objectDir, digest, level);
98
+ });
99
+ }
100
+ catch (error) {
101
+ if (error instanceof CasObjectAbsentDuringCoordinatedRead)
102
+ return undefined;
103
+ if (error instanceof CasRuntimeIncompatibleError || error instanceof StoreIntegrityError)
104
+ throw error;
105
+ throw new StoreIntegrityError('object-corrupt', digest, failureMessage(error));
106
+ }
107
+ }
108
+ function resolveObject(indexed, globalRoot, globalDigests) {
109
+ const digest = defDigest(indexed.entry.digest);
110
+ const primary = loadObjectIfPresent(indexed.root, digest, indexed.level);
111
+ if (primary !== undefined)
112
+ return primary;
113
+ // An indexed project object may fall through only to the exact same digest,
114
+ // and only when that digest is also indexed globally. A different global
115
+ // digest for the coordinate is never considered.
116
+ if (indexed.level === 'project' && globalDigests.has(digest)) {
117
+ const fallback = loadObjectIfPresent(globalRoot, digest, 'global');
118
+ if (fallback !== undefined)
119
+ return fallback;
120
+ }
121
+ throw new StoreIntegrityError('object-missing', digest, `indexed by ${indexed.level} coordinate '${indexed.coordinate}', but no verified object directory exists`);
122
+ }
123
+ /** Verify coordinate identity and select the one workflow the coordinate calls. */
124
+ function coordinateTarget(indexed, loaded) {
125
+ const parsed = parseWorkflowCoordinate(indexed.coordinate);
126
+ if (parsed.name !== loaded.manifest.package.name
127
+ || parsed.version !== loaded.manifest.package.version) {
128
+ throw new StoreIntegrityError('object-corrupt', loaded.bundleDigest, `coordinate '${indexed.coordinate}' does not match manifest package ` +
129
+ `'${loaded.manifest.package.name}@${loaded.manifest.package.version}'`);
130
+ }
131
+ const workflowName = loaded.manifest.default
132
+ ?? (loaded.defs.size === 1 ? loaded.defs.keys().next().value : undefined);
133
+ if (workflowName === undefined)
134
+ return undefined;
135
+ const target = loaded.defs.get(workflowName);
136
+ if (target === undefined) {
137
+ throw new StoreIntegrityError('object-corrupt', loaded.bundleDigest, `coordinate '${indexed.coordinate}' selects missing workflow '${workflowName}'`);
138
+ }
139
+ return target;
140
+ }
141
+ function candidateRegistration(candidate, key) {
142
+ return {
143
+ key,
144
+ qualified: candidate.qualified,
145
+ bare: candidate.def.name,
146
+ def: candidate.def,
147
+ bundleDigest: candidate.digest,
148
+ bundlePackage: candidate.packageName,
149
+ level: candidate.byteLevel,
150
+ kind: 'workflow',
151
+ };
152
+ }
153
+ /** `<digest>/<workflow>` — where a version that did not win its name stays reachable. */
154
+ function shadowedWorkflowKey(candidate) {
155
+ return `${candidate.digest}/${candidate.def.name}`;
156
+ }
157
+ /**
158
+ * Register every workflow of every verified object, choosing ONE holder per
159
+ * unqualified `package/workflow` name with {@link selectLatestVersion}.
160
+ *
161
+ * This runs AFTER the coordinate walk, not inside it, precisely so the choice
162
+ * cannot depend on which coordinate the walk reached first. Two versions of the
163
+ * same package are competitors to be ranked, never a first-claim and a
164
+ * latecomer.
165
+ *
166
+ * Exact coordinate aliases and digest-scoped aliases are registered by the walk
167
+ * itself and are deliberately NOT affected by anything decided here: a pinned
168
+ * parent and an explicit `pkg/name@version` call keep resolving to their own
169
+ * object whichever version currently holds the unqualified name.
170
+ *
171
+ * Precedence runs on `indexedLevel` — which index named the object — so a
172
+ * project pin still outranks a higher global version even when the project's
173
+ * own object bytes were missing and had to be read from the global store.
174
+ */
175
+ function selectWorkflowRegistrations(objects, warn) {
176
+ const byQualified = new Map();
177
+ const ordered = [...objects].sort((a, b) => compareStoreText(a.loaded.bundleDigest, b.loaded.bundleDigest));
178
+ for (const { loaded, indexedLevel } of ordered) {
179
+ for (const def of loaded.defs.values()) {
180
+ const qualified = `${loaded.manifest.package.name}/${def.name}`;
181
+ const candidate = {
182
+ qualified,
183
+ def,
184
+ packageName: loaded.manifest.package.name,
185
+ version: loaded.manifest.package.version,
186
+ level: indexedLevel,
187
+ byteLevel: loaded.level,
188
+ digest: loaded.bundleDigest,
189
+ };
190
+ const existing = byQualified.get(qualified);
191
+ if (existing === undefined)
192
+ byQualified.set(qualified, [candidate]);
193
+ else
194
+ existing.push(candidate);
195
+ }
196
+ }
197
+ const registrations = [];
198
+ for (const qualified of [...byQualified.keys()].sort(compareStoreText)) {
199
+ const candidates = byQualified.get(qualified);
200
+ const selection = selectLatestVersion(candidates);
201
+ if (selection.kind === 'unorderable') {
202
+ // ONLY the competing versions may be described as non-SemVer. Anything
203
+ // else in `shadowed` lost on level and was never judged on its version —
204
+ // saying otherwise sends the operator to inspect a version string that is
205
+ // perfectly valid.
206
+ const versions = selection.competing.map((candidate) => candidate.version).join(', ');
207
+ const outrankedCount = selection.shadowed.length - selection.competing.length;
208
+ const outrankedNote = outrankedCount === 0
209
+ ? ''
210
+ : ` (${outrankedCount} further global-indexed version${outrankedCount === 1 ? '' : 's'} ` +
211
+ `never competed, because a project-indexed version takes precedence)`;
212
+ warn(`warning: workflow '${qualified}' has no selectable version — none of the competing ` +
213
+ `versions (${versions}) is canonical SemVer, so the unqualified name is refused rather ` +
214
+ `than resolved by install order${outrankedNote}; call an exact ` +
215
+ `'namespace/name@version' coordinate instead`);
216
+ for (const candidate of selection.shadowed) {
217
+ registrations.push(candidateRegistration(candidate, shadowedWorkflowKey(candidate)));
218
+ }
219
+ continue;
220
+ }
221
+ registrations.push(candidateRegistration(selection.winner, qualified));
222
+ for (const candidate of selection.shadowed) {
223
+ const key = shadowedWorkflowKey(candidate);
224
+ // `-indexed`, because this sentence is about PRECEDENCE, which keys on the
225
+ // index that named the object. The registration's own `level` field
226
+ // reports the different question of which store the bytes came from, and
227
+ // the two legitimately disagree under exact-digest fallback.
228
+ warn(`warning: workflow '${qualified}' from ${candidate.level}-indexed bundle ${candidate.digest} ` +
229
+ `(version ${candidate.version}) does not hold that name — ${selection.winner.level}-indexed ` +
230
+ `bundle ${selection.winner.digest} (version ${selection.winner.version}) is the selected ` +
231
+ `version; this copy stays reachable as '${key}'`);
232
+ registrations.push(candidateRegistration(candidate, key));
233
+ }
234
+ }
235
+ return registrations;
236
+ }
237
+ function discoverCasDefs(args, tolerant) {
238
+ const projectRoot = args.projectRoot === undefined ? undefined : projectStoreRoot(args.projectRoot);
239
+ const globalRoot = projectStoreRoot(args.globalRoot);
240
+ const sameRoot = projectRoot === undefined || projectRoot === globalRoot;
241
+ const project = sameRoot
242
+ ? { entries: [], complete: true }
243
+ : readIndexedCoordinates(projectRoot, 'project', tolerant, args.warn);
244
+ const global = readIndexedCoordinates(globalRoot, 'global', tolerant, args.warn);
245
+ let complete = project.complete && global.complete;
246
+ const projectCoordinates = new Set(project.entries.map((item) => item.coordinate));
247
+ const selected = [
248
+ ...project.entries.map((item) => ({ ...item, registerAlias: true })),
249
+ ...global.entries
250
+ .filter((item) => !projectCoordinates.has(item.coordinate))
251
+ .map((item) => ({ ...item, registerAlias: true })),
252
+ // A shadowed global coordinate never receives the direct precedence alias, but
253
+ // its workflows and callable coordinate remain digest-scoped for pinned runs.
254
+ ...global.entries
255
+ .filter((item) => projectCoordinates.has(item.coordinate))
256
+ .map((item) => ({ ...item, registerAlias: false })),
257
+ ];
258
+ const globalDigests = new Set();
259
+ for (const item of global.entries)
260
+ globalDigests.add(defDigest(item.entry.digest));
261
+ const registrations = [];
262
+ const loadedByDigest = new Map();
263
+ const registeredObjects = new Map();
264
+ const registeredCoordinateKeys = new Set();
265
+ for (const indexed of selected) {
266
+ try {
267
+ const digest = defDigest(indexed.entry.digest);
268
+ let loaded = loadedByDigest.get(digest);
269
+ if (loaded === undefined) {
270
+ loaded = resolveObject(indexed, globalRoot, globalDigests);
271
+ loadedByDigest.set(digest, loaded);
272
+ }
273
+ const target = coordinateTarget(indexed, loaded);
274
+ // `indexed.level`, not `loaded.level`: the index that NAMED the object
275
+ // decides precedence, while `loaded.level` only records which store the
276
+ // verified bytes came from. Project wins the merge when both indexes
277
+ // name the same object.
278
+ const alreadyRegistered = registeredObjects.get(loaded.bundleDigest);
279
+ if (alreadyRegistered?.indexedLevel !== 'project') {
280
+ registeredObjects.set(loaded.bundleDigest, { loaded, indexedLevel: indexed.level });
281
+ }
282
+ if (target === undefined) {
283
+ if (indexed.registerAlias) {
284
+ args.warn(`warning: coordinate '${indexed.coordinate}' is not callable because the bundle exports ` +
285
+ `multiple workflows and has no default; use an explicit package/workflow target`);
286
+ }
287
+ continue;
288
+ }
289
+ // Every callable coordinate gets a digest-scoped alias, including a
290
+ // shadowed global coordinate. A running parent can therefore follow its
291
+ // lock digest without changing the direct project's precedence alias.
292
+ const coordinateKeys = [
293
+ digestScopedCallsTargetKey(digest, indexed.coordinate),
294
+ ...(indexed.registerAlias ? [indexed.coordinate] : []),
295
+ ];
296
+ for (const key of coordinateKeys) {
297
+ if (registeredCoordinateKeys.has(key))
298
+ continue;
299
+ registeredCoordinateKeys.add(key);
300
+ registrations.push({
301
+ key,
302
+ qualified: `${loaded.manifest.package.name}/${target.name}`,
303
+ bare: target.name,
304
+ def: target,
305
+ bundleDigest: digest,
306
+ bundlePackage: loaded.manifest.package.name,
307
+ level: loaded.level,
308
+ kind: 'coordinate',
309
+ coordinate: indexed.coordinate,
310
+ });
311
+ }
312
+ }
313
+ catch (error) {
314
+ if (error instanceof CasRuntimeIncompatibleError) {
315
+ complete = false;
316
+ args.warn(`warning: skipping ${indexed.level} workflow object ${indexed.entry.digest}: ${error.message}`);
317
+ continue;
318
+ }
319
+ if (!tolerant)
320
+ throw error;
321
+ complete = false;
322
+ args.warn(`warning: incomplete ${indexed.level} workflow coordinate '${indexed.coordinate}': ${failureMessage(error)}`);
323
+ }
324
+ }
325
+ registrations.push(...selectWorkflowRegistrations([...registeredObjects.values()], args.warn));
326
+ return { registrations, complete };
327
+ }
328
+ /** Strict executable discovery. Any indexed integrity failure aborts. */
329
+ export function loadCasDefs(args) {
330
+ return discoverCasDefs(args, false).registrations;
331
+ }
332
+ /** Tolerant read-only inspection. Never use this result for execution. */
333
+ export function inspectCasDefs(args) {
334
+ return discoverCasDefs(args, true);
335
+ }
@@ -0,0 +1,69 @@
1
+ /**
2
+ * `index.json` — the workflow-store coordinate index, one per store root.
3
+ * Strict fail-closed parsing, canonical serialization, and atomic writes.
4
+ *
5
+ * The index is attacker-influenceable disk input (a project index is ordinary
6
+ * repo content; a global index lives next to user data): every byte read from
7
+ * it passes {@link parseWorkflowStoreIndex} before any consumer acts on it. A
8
+ * malformed index is a hard, named error — never silently reset to empty
9
+ * (which would erase pins) and never normalized (an uppercase digest stays
10
+ * invalid rather than being lowercased into apparent validity).
11
+ */
12
+ import type { WorkflowStoreIndex } from './types.ts';
13
+ /** The current (and only) index schema version. */
14
+ export declare const WORKFLOW_STORE_INDEX_VERSION = 1;
15
+ /** The empty index (what a root with no index file logically holds). */
16
+ export declare function emptyWorkflowStoreIndex(): WorkflowStoreIndex;
17
+ /**
18
+ * Structurally validate a parsed `index.json`, fail-closed — the trust
19
+ * boundary for the workflow-store index (same discipline as the GitHub
20
+ * route's `validateLockfile`). EVERY entry is validated, not just one being
21
+ * installed: the writer re-serializes the whole index on success, so acting
22
+ * while carrying a poisoned sibling entry would re-persist it.
23
+ *
24
+ * Enforced: `version === 1`; `entries` a plain object; each key a full
25
+ * `namespace/name@version` coordinate (validated by
26
+ * `parseWorkflowCoordinate`); each entry `{ digest, pinned }` with digest a
27
+ * LOWERCASE 64-hex value (uppercase/noncanonical is rejected, never
28
+ * normalized) and pinned a boolean. When present, `workflows` is a unique,
29
+ * valid, UTF-8-sorted workflow-name array. Unknown extra keys are tolerated
30
+ * for forward compatibility; required fields are enforced. `path` appears
31
+ * only in error messages. Throws {@link StoreIndexError} on any violation.
32
+ */
33
+ export declare function parseWorkflowStoreIndex(parsed: unknown, path: string): WorkflowStoreIndex;
34
+ /**
35
+ * Read `index.json` at a store root; a MISSING file is an empty index, not an
36
+ * error (a root that has never installed anything). A present-but-unparseable
37
+ * file is a hard {@link StoreIndexError}; a parseable-but-invalid file is a
38
+ * hard {@link StoreIndexError} via {@link parseWorkflowStoreIndex}. Never
39
+ * silently resets to empty, never trusts content for filesystem paths.
40
+ *
41
+ * Symlink/type guard: `lstat` (never `stat`) refuses a symlink squatting at
42
+ * the index path — a symlinked index would make reads and the atomic write's
43
+ * rename act through the link, outside the root (SEC-3). A non-regular file
44
+ * (a directory) is refused for the same reason.
45
+ */
46
+ export declare function readWorkflowStoreIndex(path: string): WorkflowStoreIndex;
47
+ /**
48
+ * Serialize an index CANONICALLY (`JSON.stringify(..., null, 2) + '\n'`) and
49
+ * write it atomically (sibling temp file + rename — the shared
50
+ * `writeJsonAtomic` discipline: a crash or concurrent reader never sees a
51
+ * half-written index; a failed rename cleans up its temp and surfaces the
52
+ * original error). Canonical bytes matter twice over: they are what the
53
+ * crash-recovery journal's `metadataHash` commits to, and they make the index
54
+ * diff-stable in git review.
55
+ */
56
+ export declare function serializeWorkflowStoreIndex(index: WorkflowStoreIndex): string;
57
+ /**
58
+ * Atomically write `index` to `path` (canonical serialization). Callers hold
59
+ * the root's install lock; the write itself is rename-atomic within the
60
+ * directory. `rm` is injectable for the same double-fault test seam the
61
+ * lockfile writer exposes.
62
+ */
63
+ export declare function writeWorkflowStoreIndex(path: string, index: WorkflowStoreIndex, opts?: {
64
+ rm?: (path: string, opts: {
65
+ force: true;
66
+ }) => void;
67
+ }): void;
68
+ /** Remove a stray temp sibling (best-effort; absence is fine). */
69
+ export declare function removeIndexTempSibling(path: string): void;
@@ -0,0 +1,151 @@
1
+ /**
2
+ * `index.json` — the workflow-store coordinate index, one per store root.
3
+ * Strict fail-closed parsing, canonical serialization, and atomic writes.
4
+ *
5
+ * The index is attacker-influenceable disk input (a project index is ordinary
6
+ * repo content; a global index lives next to user data): every byte read from
7
+ * it passes {@link parseWorkflowStoreIndex} before any consumer acts on it. A
8
+ * malformed index is a hard, named error — never silently reset to empty
9
+ * (which would erase pins) and never normalized (an uppercase digest stays
10
+ * invalid rather than being lowercased into apparent validity).
11
+ */
12
+ import { lstatSync, rmSync } from 'node:fs';
13
+ import { dirname } from 'node:path';
14
+ import { WORKFLOW_NAME_RE } from "../bundle/manifest.js";
15
+ import { DIGEST_RE, StoreIndexError, parseWorkflowCoordinate } from "./types.js";
16
+ import { readRegularFileNoFollow, writeJsonAtomic } from "../install.js";
17
+ /** The current (and only) index schema version. */
18
+ export const WORKFLOW_STORE_INDEX_VERSION = 1;
19
+ /** The empty index (what a root with no index file logically holds). */
20
+ export function emptyWorkflowStoreIndex() {
21
+ return { version: 1, entries: {} };
22
+ }
23
+ function isPlainObject(value) {
24
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
25
+ }
26
+ /**
27
+ * Structurally validate a parsed `index.json`, fail-closed — the trust
28
+ * boundary for the workflow-store index (same discipline as the GitHub
29
+ * route's `validateLockfile`). EVERY entry is validated, not just one being
30
+ * installed: the writer re-serializes the whole index on success, so acting
31
+ * while carrying a poisoned sibling entry would re-persist it.
32
+ *
33
+ * Enforced: `version === 1`; `entries` a plain object; each key a full
34
+ * `namespace/name@version` coordinate (validated by
35
+ * `parseWorkflowCoordinate`); each entry `{ digest, pinned }` with digest a
36
+ * LOWERCASE 64-hex value (uppercase/noncanonical is rejected, never
37
+ * normalized) and pinned a boolean. When present, `workflows` is a unique,
38
+ * valid, UTF-8-sorted workflow-name array. Unknown extra keys are tolerated
39
+ * for forward compatibility; required fields are enforced. `path` appears
40
+ * only in error messages. Throws {@link StoreIndexError} on any violation.
41
+ */
42
+ export function parseWorkflowStoreIndex(parsed, path) {
43
+ const fail = (detail) => {
44
+ throw new StoreIndexError(`invalid workflow store index at ${path}: ${detail} — fix or remove it manually`);
45
+ };
46
+ if (!isPlainObject(parsed))
47
+ return fail('top-level value is not an object');
48
+ if (parsed.version !== WORKFLOW_STORE_INDEX_VERSION) {
49
+ return fail(`unsupported index version ${JSON.stringify(parsed.version)} (expected 1)`);
50
+ }
51
+ if (!isPlainObject(parsed.entries))
52
+ return fail("'entries' is not an object");
53
+ for (const [key, entry] of Object.entries(parsed.entries)) {
54
+ const at = (field) => `entries[${JSON.stringify(key)}].${field}`;
55
+ try {
56
+ parseWorkflowCoordinate(key);
57
+ }
58
+ catch (e) {
59
+ return fail(`key ${JSON.stringify(key)} is not a valid coordinate: ${e.message}`);
60
+ }
61
+ if (!isPlainObject(entry))
62
+ return fail(`entries[${JSON.stringify(key)}] is not an object`);
63
+ if (typeof entry.digest !== 'string' || !DIGEST_RE.test(entry.digest)) {
64
+ return fail(`${at('digest')} is not a lowercase 64-char sha256 hex digest`);
65
+ }
66
+ if (typeof entry.pinned !== 'boolean')
67
+ return fail(`${at('pinned')} is not a boolean`);
68
+ if (entry.workflows !== undefined) {
69
+ if (!Array.isArray(entry.workflows) || entry.workflows.some((name) => typeof name !== 'string')) {
70
+ return fail(`${at('workflows')} is not an array of workflow names`);
71
+ }
72
+ for (const [index, name] of entry.workflows.entries()) {
73
+ if (!WORKFLOW_NAME_RE.test(name)) {
74
+ return fail(`${at(`workflows[${index}]`)} is not a valid workflow name`);
75
+ }
76
+ }
77
+ if (new Set(entry.workflows).size !== entry.workflows.length) {
78
+ return fail(`${at('workflows')} contains duplicate workflow names`);
79
+ }
80
+ const sorted = [...entry.workflows].sort((a, b) => Buffer.compare(Buffer.from(a, 'utf8'), Buffer.from(b, 'utf8')));
81
+ if (entry.workflows.some((name, index) => name !== sorted[index])) {
82
+ return fail(`${at('workflows')} must be sorted by UTF-8 bytes`);
83
+ }
84
+ }
85
+ }
86
+ return parsed;
87
+ }
88
+ /**
89
+ * Read `index.json` at a store root; a MISSING file is an empty index, not an
90
+ * error (a root that has never installed anything). A present-but-unparseable
91
+ * file is a hard {@link StoreIndexError}; a parseable-but-invalid file is a
92
+ * hard {@link StoreIndexError} via {@link parseWorkflowStoreIndex}. Never
93
+ * silently resets to empty, never trusts content for filesystem paths.
94
+ *
95
+ * Symlink/type guard: `lstat` (never `stat`) refuses a symlink squatting at
96
+ * the index path — a symlinked index would make reads and the atomic write's
97
+ * rename act through the link, outside the root (SEC-3). A non-regular file
98
+ * (a directory) is refused for the same reason.
99
+ */
100
+ export function readWorkflowStoreIndex(path) {
101
+ let rawBytes;
102
+ try {
103
+ rawBytes = readRegularFileNoFollow(path, 'workflow store index');
104
+ }
105
+ catch (e) {
106
+ throw new StoreIndexError(`refusing workflow store index at ${path}: ${e.message}`);
107
+ }
108
+ if (rawBytes === undefined)
109
+ return emptyWorkflowStoreIndex();
110
+ const raw = new TextDecoder().decode(rawBytes);
111
+ let parsed;
112
+ try {
113
+ parsed = JSON.parse(raw);
114
+ }
115
+ catch (e) {
116
+ throw new StoreIndexError(`corrupt workflow store index at ${path}: ${e.message} — fix or remove it manually`);
117
+ }
118
+ return parseWorkflowStoreIndex(parsed, path);
119
+ }
120
+ /**
121
+ * Serialize an index CANONICALLY (`JSON.stringify(..., null, 2) + '\n'`) and
122
+ * write it atomically (sibling temp file + rename — the shared
123
+ * `writeJsonAtomic` discipline: a crash or concurrent reader never sees a
124
+ * half-written index; a failed rename cleans up its temp and surfaces the
125
+ * original error). Canonical bytes matter twice over: they are what the
126
+ * crash-recovery journal's `metadataHash` commits to, and they make the index
127
+ * diff-stable in git review.
128
+ */
129
+ export function serializeWorkflowStoreIndex(index) {
130
+ return `${JSON.stringify(index, null, 2)}\n`;
131
+ }
132
+ /**
133
+ * Atomically write `index` to `path` (canonical serialization). Callers hold
134
+ * the root's install lock; the write itself is rename-atomic within the
135
+ * directory. `rm` is injectable for the same double-fault test seam the
136
+ * lockfile writer exposes.
137
+ */
138
+ export function writeWorkflowStoreIndex(path, index, opts = {}) {
139
+ // The parent directory must exist and be a real directory — a symlinked
140
+ // parent would redirect the atomic rename outside the root.
141
+ const parent = dirname(path);
142
+ const parentSt = lstatSync(parent, { throwIfNoEntry: false });
143
+ if (parentSt?.isSymbolicLink()) {
144
+ throw new StoreIndexError(`refusing to write workflow store index: parent '${parent}' is a symlink`);
145
+ }
146
+ writeJsonAtomic(path, index, opts);
147
+ }
148
+ /** Remove a stray temp sibling (best-effort; absence is fine). */
149
+ export function removeIndexTempSibling(path) {
150
+ rmSync(path, { force: true });
151
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * The public surface of the content-addressed WORKFLOW store (this `store/`
3
+ * package). Distinct from `src/store.ts` — the SQLite RUNTIME store
4
+ * (`Store`/`openStore`): this package holds immutable, digest-addressed
5
+ * workflow-definition objects installed from `.wnlp` bundles, plus the
6
+ * coordinate→digest index at two levels (project = the resolved defs dir;
7
+ * global = `~/.owenloop/workflows`).
8
+ *
9
+ * Names here are deliberately `Workflow*`-qualified so nothing can collide
10
+ * with the runtime store's `Store`.
11
+ */
12
+ export { COORDINATE_COMPONENT_RE, compareStoreText, DIGEST_RE, defDigest, selectLatestVersion, isDefDigest, objectDirForDigest, parseWorkflowCoordinate, workflowCoordinate, WORKFLOW_OBJECTS_ALGO, WORKFLOW_OBJECTS_DIRNAME, WORKFLOW_STORE_INDEX_FILENAME, WorkflowStoreError, StoreIndexError, StoreDigestError, StoreCoordinateError, StoreAmbiguityError, StoreNotFoundError, StoreIntegrityError, StoreConflictError, StoreDefinitionVerificationError, StoreOriginPolicyError, StorePathError, BundleIngestorUnavailableError, PreCommitVerifierUnavailableError, } from './types.ts';
13
+ export type { DefDigest, LatestVersionSelection, ResolutionLevel, StoreLevel, VersionSelectionCandidate, WorkflowCoordinate, WorkflowStoreIndex, WorkflowStoreIndexEntry, } from './types.ts';
14
+ export { emptyWorkflowStoreIndex, parseWorkflowStoreIndex, readWorkflowStoreIndex, serializeWorkflowStoreIndex, WORKFLOW_STORE_INDEX_VERSION, writeWorkflowStoreIndex, } from './index-file.ts';
15
+ export { globalStoreRoot, projectStoreRoot, probeObjectDir, probeStoreRoot, resolveWorkflowCoordinate, resolveWorkflowDigest, storeIndexPath, waitForDigestRepair, waitForDigestRepairSync, workflowStoreStatePaths, } from './resolve.ts';
16
+ export type { ResolvedWorkflowObject, ResolveWorkflowCoordinateArgs, ResolveWorkflowDigestArgs, WorkflowStoreStatePaths, } from './resolve.ts';
17
+ export { hardenObjectModes, installWorkflowBundle, objectDestRelPath, recoverWorkflowStore, workflowStoreReplacementRecovery, } from './install.ts';
18
+ export { createBundleIngestor, verifyHardenedWorkflowObjectModesSync, verifyWorkflowObjectSync, } from './ingestor.ts';
19
+ export type { BundleIngestorOptions } from './ingestor.ts';
20
+ export { inspectCasDefs, loadCasDefs } from './def-source.ts';
21
+ export type { CasDefInspectionResult, CasDefRegistration, LoadCasDefsArgs, } from './def-source.ts';
22
+ export { originEvidencePath, persistOriginEvidence, readOriginEvidence, } from './origin-evidence.ts';
23
+ export { createStoreInstructionSource, isResolvableOrderDigest, StoreInstructionSourceError, } from './instruction-source.ts';
24
+ export type { MissingObjectHandler, StoreInstructionSource, StoreInstructionSourceArgs, } from './instruction-source.ts';
25
+ export type { BundleInstallResult, BundleIngestor, BundleSource, InstallWorkflowBundleArgs, PreCommitVerifier, RecoverWorkflowStoreArgs, } from './install.ts';
26
+ export { createExecutionDefinitionVerifier, createExecutionOriginVerifier, createPreCommitVerifier, createProductionPreCommitVerifier, resolveArtifactPolicy, resolveDefPolicy, resolveOriginPolicy, resolveOriginRules, } from './pre-commit-verifier.ts';
27
+ export type { ExecutionDefinitionVerifierInput, ExecutionOriginVerifierInput, PreCommitVerifierOptions, } from './pre-commit-verifier.ts';
@@ -0,0 +1,22 @@
1
+ /**
2
+ * The public surface of the content-addressed WORKFLOW store (this `store/`
3
+ * package). Distinct from `src/store.ts` — the SQLite RUNTIME store
4
+ * (`Store`/`openStore`): this package holds immutable, digest-addressed
5
+ * workflow-definition objects installed from `.wnlp` bundles, plus the
6
+ * coordinate→digest index at two levels (project = the resolved defs dir;
7
+ * global = `~/.owenloop/workflows`).
8
+ *
9
+ * Names here are deliberately `Workflow*`-qualified so nothing can collide
10
+ * with the runtime store's `Store`.
11
+ */
12
+ export { COORDINATE_COMPONENT_RE, compareStoreText, DIGEST_RE, defDigest, selectLatestVersion, isDefDigest, objectDirForDigest, parseWorkflowCoordinate, workflowCoordinate, WORKFLOW_OBJECTS_ALGO, WORKFLOW_OBJECTS_DIRNAME, WORKFLOW_STORE_INDEX_FILENAME, WorkflowStoreError, StoreIndexError, StoreDigestError, StoreCoordinateError, StoreAmbiguityError, StoreNotFoundError, StoreIntegrityError, StoreConflictError, StoreDefinitionVerificationError, StoreOriginPolicyError, StorePathError, BundleIngestorUnavailableError, PreCommitVerifierUnavailableError, } from "./types.js";
13
+ export { emptyWorkflowStoreIndex, parseWorkflowStoreIndex, readWorkflowStoreIndex, serializeWorkflowStoreIndex, WORKFLOW_STORE_INDEX_VERSION, writeWorkflowStoreIndex, } from "./index-file.js";
14
+ export { globalStoreRoot, projectStoreRoot, probeObjectDir, probeStoreRoot, resolveWorkflowCoordinate, resolveWorkflowDigest, storeIndexPath, waitForDigestRepair, waitForDigestRepairSync, workflowStoreStatePaths, } from "./resolve.js";
15
+ export { hardenObjectModes, installWorkflowBundle, objectDestRelPath, recoverWorkflowStore, workflowStoreReplacementRecovery, } from "./install.js";
16
+ export { createBundleIngestor, verifyHardenedWorkflowObjectModesSync, verifyWorkflowObjectSync, } from "./ingestor.js";
17
+ // ---- WS-6 CAS -> calls: def bridge ----
18
+ export { inspectCasDefs, loadCasDefs } from "./def-source.js";
19
+ // ---- WP-E2a origin execution policy ----
20
+ export { originEvidencePath, persistOriginEvidence, readOriginEvidence, } from "./origin-evidence.js";
21
+ export { createStoreInstructionSource, isResolvableOrderDigest, StoreInstructionSourceError, } from "./instruction-source.js";
22
+ export { createExecutionDefinitionVerifier, createExecutionOriginVerifier, createPreCommitVerifier, createProductionPreCommitVerifier, resolveArtifactPolicy, resolveDefPolicy, resolveOriginPolicy, resolveOriginRules, } from "./pre-commit-verifier.js";
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Concrete `.wnlp` bundle ingestion and on-read object verification.
3
+ *
4
+ * The bundle format owns archive validation and the canonical content digest;
5
+ * this adapter connects that byte-oriented API to the workflow store's staged
6
+ * object contract. Installed objects are verified from their manifest integrity
7
+ * map every time instruction content is resolved.
8
+ */
9
+ import type { BundleIngestor } from './install.ts';
10
+ import type { DefDigest } from './types.ts';
11
+ export interface BundleIngestorOptions {
12
+ /** Explicit namespace override for the package-derived store coordinate. */
13
+ namespace?: string;
14
+ }
15
+ /**
16
+ * Re-check one unpacked object against its strict package manifest.
17
+ * `bundle.yaml` is intentionally absent from `integrity.files` because its
18
+ * content participates in the canonical bundle digest and self-hashing would
19
+ * be recursive.
20
+ *
21
+ * SYNCHRONOUS by construction: every filesystem call in the body is a `*Sync`
22
+ * call, and it awaits nothing. The `BundleIngestor.verifyInstalledObject` port
23
+ * stays `Promise`-returning (an adapter may legitimately need I/O concurrency),
24
+ * but this default adapter's implementation does not, so WS-6's def loader —
25
+ * which must run inside the synchronous `openCtx`/`dispatch` path — calls this
26
+ * function directly instead of forcing `openCtx` to become `async`. Exported
27
+ * for exactly that caller; the async port remains the public contract.
28
+ */
29
+ export interface VerifyWorkflowObjectOptions {
30
+ /** Optional directory-entry source used by tests to control filesystem order. */
31
+ readDir?: (directory: string) => string[];
32
+ /** Optional visit trace used by tests to assert recursive traversal order. */
33
+ onVisit?: (relativePath: string) => void;
34
+ /** False only when an async caller already waited on the matching repair journal. */
35
+ coordinateRepair?: boolean;
36
+ /** False only for staged pre-swap content; installed objects require exact hardened modes. */
37
+ requireHardenedModes?: boolean;
38
+ }
39
+ /** Verify exact immutable store modes independently from canonical identity. */
40
+ export declare function verifyHardenedWorkflowObjectModesSync(objectDir: string): void;
41
+ export declare function verifyWorkflowObjectSync(objectDir: string, digest: DefDigest, options?: VerifyWorkflowObjectOptions): void;
42
+ /** Create the real store adapter used by the default CLI and driver paths. */
43
+ export declare function createBundleIngestor(options?: BundleIngestorOptions): BundleIngestor;