@awebai/oats 0.23.2 → 0.24.0

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 (158) hide show
  1. package/README.md +7 -4
  2. package/bin/oats-pi-sdk-host.mjs +17 -0
  3. package/bin/oats.mjs +442 -51
  4. package/capabilities/oats-okf/bin/oats-okf-binding.mjs +14 -0
  5. package/capabilities/oats-okf/bin/oats-okf.mjs +79 -11
  6. package/capabilities/oats-okf/lib/binding-wire.mjs +268 -0
  7. package/capabilities/oats-okf/lib/captured-worker.mjs +101 -0
  8. package/capabilities/oats-okf/lib/config.mjs +2 -1
  9. package/capabilities/oats-okf/lib/inspection.mjs +16 -1
  10. package/capabilities/oats-okf/lib/invocation-context.mjs +111 -0
  11. package/capabilities/oats-okf/lib/invocation-shape.mjs +135 -0
  12. package/capabilities/oats-okf/lib/io.mjs +1 -1
  13. package/capabilities/oats-okf/lib/portable-binding.mjs +199 -0
  14. package/capabilities/oats-okf/lib/source-contract.mjs +46 -0
  15. package/capabilities/oats-okf/lib/sources.mjs +123 -3
  16. package/capabilities/oats-okf/lib/stores.mjs +104 -25
  17. package/capabilities/oats-okf/lib/worker.mjs +69 -10
  18. package/capabilities/oats-okf/oats.json +35 -7
  19. package/capabilities/oats-okf/schemas/okf-portable-declaration.schema.json +87 -0
  20. package/capabilities/oats-okf/schemas/okf-portable-payload.schema.json +113 -0
  21. package/capabilities/oats-okf/skills/memory-harvest/SKILL.md +23 -5
  22. package/capabilities/oats-okf/skills/okf/SKILL.md +42 -1
  23. package/docs/artifact-approvals.schema.json +7 -0
  24. package/docs/capability-manifest.schema.json +37 -66
  25. package/docs/captured-invocation-context.schema.json +7 -0
  26. package/docs/captured-resolution.schema.json +7 -0
  27. package/docs/design/2026-09-14-artifact-retention-contract.md +190 -0
  28. package/docs/design/2026-09-14-portable-souls-and-git-workspaces.md +708 -0
  29. package/docs/design/2026-09-14-portable-souls-contract-amendments.md +85 -0
  30. package/docs/design/2026-09-14-portable-souls-explainer.md +750 -0
  31. package/docs/design/2026-09-15-captured-dispatch.md +127 -0
  32. package/docs/design/2026-09-15-captured-resolution-records.md +143 -0
  33. package/docs/design/2026-09-15-package-preparation.md +100 -0
  34. package/docs/design/2026-09-15-portable-data-contract.md +121 -0
  35. package/docs/design/2026-09-15-portable-declarations.md +189 -0
  36. package/docs/design/2026-09-15-portable-souls-handoff.md +150 -0
  37. package/docs/design/2026-09-15-portable-souls-implementation.md +417 -0
  38. package/docs/design/2026-09-15-selection-lock-and-approval.md +122 -0
  39. package/docs/design/2026-09-15-source-observation.md +119 -0
  40. package/docs/design/2026-09-16-captured-admission.md +77 -0
  41. package/docs/design/2026-09-16-captured-helper-dispatch.md +105 -0
  42. package/docs/design/2026-09-16-captured-launch-inputs.md +42 -0
  43. package/docs/design/2026-09-16-command-profile-preparation.md +86 -0
  44. package/docs/design/2026-09-16-fresh-install-first-rollout.md +47 -0
  45. package/docs/design/2026-09-16-fresh-operator-walkthrough.md +277 -0
  46. package/docs/design/2026-09-16-knowledge-capability-contract.md +61 -0
  47. package/docs/design/2026-09-16-messaging-capability-contract.md +59 -0
  48. package/docs/design/2026-09-16-portable-migration-evidence.md +156 -0
  49. package/docs/design/2026-09-16-portable-onboarding.md +177 -0
  50. package/docs/design/2026-09-16-prepare-request-transport.md +26 -0
  51. package/docs/design/2026-09-16-provider-binding-codecs.md +98 -0
  52. package/docs/design/2026-09-16-provider-binding-wire.md +247 -0
  53. package/docs/design/2026-09-17-capability-helper-input-contract.md +95 -0
  54. package/docs/design/2026-09-17-captured-backend-parity.md +53 -0
  55. package/docs/design/2026-09-17-captured-native-start.md +58 -0
  56. package/docs/design/2026-09-17-portable-boundary-hookup.md +19 -0
  57. package/docs/design/2026-09-17-portable-boundary-resources.md +52 -0
  58. package/docs/design/2026-09-17-public-captured-start.md +108 -0
  59. package/docs/design/2026-09-17-public-prepare-request.md +90 -0
  60. package/docs/design/2026-09-18-captured-pi-host.md +205 -0
  61. package/docs/design/2026-09-18-first-cut-release-checklist.md +131 -0
  62. package/docs/design/2026-09-18-herdr-protocol-compatibility.md +60 -0
  63. package/docs/desktop-cli-api.md +5 -2
  64. package/docs/execution-capsule.schema.json +108 -0
  65. package/docs/execution-targets.md +20 -7
  66. package/docs/oats-lock-v3.schema.json +7 -0
  67. package/docs/oats-member.schema.json +38 -0
  68. package/docs/oats-workspace.schema.json +68 -0
  69. package/docs/portable.schema.json +2512 -0
  70. package/docs/provider-check-input.schema.json +7 -0
  71. package/docs/release-notes/v0.24.0.md +104 -0
  72. package/docs/schedules.md +126 -14
  73. package/docs/soul.schema.json +82 -0
  74. package/injects/oats-portable.md +17 -0
  75. package/injects/portable-instance-boundary.md +39 -0
  76. package/injects/portable-work-directory.md +29 -0
  77. package/lib/artifact-approvals.mjs +120 -0
  78. package/lib/artifact-tree.mjs +141 -0
  79. package/lib/capability-artifacts.mjs +179 -0
  80. package/lib/capability-execution.mjs +15 -0
  81. package/lib/capability-inputs.mjs +39 -0
  82. package/lib/capability-provenance.mjs +231 -0
  83. package/lib/captured-action-shape.mjs +21 -0
  84. package/lib/captured-admission-shape.mjs +20 -0
  85. package/lib/captured-binding-file.mjs +36 -0
  86. package/lib/captured-dispatch.mjs +66 -0
  87. package/lib/captured-instance-index.mjs +277 -0
  88. package/lib/captured-invocation-context.mjs +130 -0
  89. package/lib/captured-launch-request.mjs +46 -0
  90. package/lib/captured-operation-process.mjs +15 -0
  91. package/lib/captured-pi-custody.mjs +29 -0
  92. package/lib/captured-pi-host.mjs +167 -0
  93. package/lib/captured-pi-outcome.mjs +172 -0
  94. package/lib/captured-resolutions.mjs +275 -0
  95. package/lib/captured-scaffold.mjs +87 -0
  96. package/lib/captured-selector.mjs +28 -0
  97. package/lib/captured-session-backend.mjs +52 -0
  98. package/lib/captured-source-receipt-file.mjs +72 -0
  99. package/lib/config-data.mjs +104 -0
  100. package/lib/core.mjs +918 -562
  101. package/lib/errors.mjs +7 -0
  102. package/lib/helper-injection-policy.mjs +98 -0
  103. package/lib/herdr.mjs +18 -7
  104. package/lib/instruction-composition.mjs +31 -0
  105. package/lib/legacy-lock-codec.mjs +106 -0
  106. package/lib/manifest-settings.mjs +84 -0
  107. package/lib/package-closure.mjs +48 -0
  108. package/lib/package-materialization.mjs +83 -0
  109. package/lib/pi-sdk-host.mjs +229 -0
  110. package/lib/portable-artifacts.mjs +115 -0
  111. package/lib/portable-choices.mjs +82 -0
  112. package/lib/portable-composition.mjs +136 -0
  113. package/lib/portable-digest.mjs +105 -0
  114. package/lib/portable-files.mjs +26 -0
  115. package/lib/portable-identity.mjs +40 -0
  116. package/lib/portable-lock.mjs +117 -0
  117. package/lib/portable-migration-artifacts.mjs +135 -0
  118. package/lib/portable-migration-evidence.mjs +305 -0
  119. package/lib/portable-migration-store.mjs +199 -0
  120. package/lib/portable-migration.mjs +104 -0
  121. package/lib/portable-onboarding-acceptance.mjs +66 -0
  122. package/lib/portable-onboarding-request.mjs +49 -0
  123. package/lib/portable-onboarding.mjs +230 -0
  124. package/lib/portable-package-preparation.mjs +188 -0
  125. package/lib/portable-policy.mjs +44 -0
  126. package/lib/portable-shape.mjs +35 -0
  127. package/lib/portable-soul.mjs +38 -0
  128. package/lib/portable-state.mjs +80 -0
  129. package/lib/portable-values.mjs +181 -0
  130. package/lib/prepare-composition.mjs +151 -0
  131. package/lib/prepared-bindings.mjs +78 -0
  132. package/lib/prepared-resources.mjs +127 -0
  133. package/lib/provider-binding-broker.mjs +59 -0
  134. package/lib/provider-binding-wire.mjs +110 -0
  135. package/lib/provider-binding.mjs +22 -0
  136. package/lib/repository-observation.mjs +226 -0
  137. package/lib/resolution-shape.mjs +393 -0
  138. package/lib/schedule-capsule.mjs +206 -0
  139. package/lib/schedule.mjs +259 -38
  140. package/lib/servers.mjs +15 -0
  141. package/lib/soul-constraints.mjs +40 -0
  142. package/lib/source-projection.mjs +84 -0
  143. package/lib/source-spec.mjs +189 -0
  144. package/lib/workspace-definition.mjs +126 -0
  145. package/lib/workspace-discovery.mjs +146 -0
  146. package/package-catalog.json +1 -1
  147. package/package.json +3 -2
  148. package/packages/record/lib/capture-cc.mjs +14 -6
  149. package/packages/record/lib/formats.mjs +14 -3
  150. package/packages/record/lib/native-history.mjs +277 -7
  151. package/packages/record/lib/session-snapshot.mjs +25 -5
  152. package/packages/record/lib/sessions-for-home.mjs +30 -13
  153. package/skills/oats/SKILL.md +12 -7
  154. package/skills/oats-config/SKILL.md +12 -9
  155. package/skills/oats-packages/SKILL.md +12 -8
  156. package/skills/oats-portable/SKILL.md +116 -0
  157. package/skills/oats-portable-artifacts/SKILL.md +63 -0
  158. package/skills/oats-portable-setup/SKILL.md +69 -0
@@ -0,0 +1,190 @@
1
+ # Retained capability artifacts and captured resolutions
2
+
3
+ 14 September 2026. Portable Souls implementation foundation, task `aweb-abiu`.
4
+
5
+ Package updates currently replace `.agents/capabilities/installed/<id>`.
6
+ Instance metadata records commands and resource paths into that mutable store.
7
+ Keeping a command string does not keep the implementation that string invokes.
8
+
9
+ This first patch adds **retention primitives only**, in
10
+ `lib/capability-artifacts.mjs`. It does not change the installer, lock schema,
11
+ instance launch, scheduler or lifecycle dispatch. Existing instances are not
12
+ protected from package updates by this patch. The following integration contract
13
+ must be reviewed before those consumers change.
14
+
15
+ ## Responsibilities
16
+
17
+ - Acquisition resolves sources and materializes a package's declared resources.
18
+ - Retention publishes a verified capability tree under its exact integrity.
19
+ - Resolution selects one artifact per capability ID and records effective inputs.
20
+ - Approval authorizes the selected executable revision, independently of retention.
21
+ - Dispatch uses the captured resolution, including for retirement and queued work.
22
+
23
+ No soul, workspace, team or knowledge schema belongs in the storage primitive.
24
+ There is no new resolver or background service. The artifact includes materialized
25
+ runtime dependencies and its existing `.oats-installation.json` provenance.
26
+
27
+ ## Storage API implemented in this patch
28
+
29
+ ```text
30
+ <deployment>/.agents/capabilities/artifacts/
31
+ .gitignore # managed file containing *
32
+ <capability-id>/
33
+ sha256-<full digest>/ # one retained capability tree
34
+ ```
35
+
36
+ `retainCapabilityArtifact(scope, sourceDir, capabilityId, lock)` accepts a
37
+ materialized capability and its captured package/capability lock maps. It checks
38
+ the locked integrity and generated provenance before publication and verifies
39
+ the copied tree again before renaming it into place. It returns the capability
40
+ ID, integrity, canonical local directory and `retained` or `kept` status.
41
+
42
+ `verifyRetainedCapability(scope, capabilityId, lock)` verifies the exact stored
43
+ revision against the captured provenance. It does not consult the scope's current
44
+ lock, source checkout, catalog, network or approval state.
45
+
46
+ An absent scope, store or revision reports `artifact-not-found`. A present but
47
+ invalid tree/store or a digest/provenance mismatch is a different refusal. Callers
48
+ can therefore distinguish missing inputs from damaged retained state without
49
+ parsing filesystem error messages. A damaged entry is never silently repaired.
50
+
51
+ `retainedCapabilityDir(scope, capabilityId, integrity)` computes the lexical path
52
+ after checking the ID and full digest. Computing a path is not verification.
53
+
54
+ Both publication and verification reject broken or escaping symlinks. Absolute
55
+ symlinks back into the original source are rejected too: that source may later
56
+ disappear. Internal relative symlinks retain their spelling. The source directory
57
+ is copied with the package engine's catchable copy routine, not linked or moved.
58
+ File permissions are preserved; this uses the existing artifact digest format,
59
+ which hashes file bytes and symlink targets, not Unix mode bits.
60
+ At the consumer-migration boundary, introduce a versioned digest covering file
61
+ bytes, symlink targets and each regular file's executable flag, normalized from
62
+ the owner-execute bit (`(mode & 0o100) !== 0`). Apply the same digest rule to Git
63
+ and local-path sources. Group/other execute bits depend on the acquiring user's
64
+ umask and are not part of artifact identity. This models execution by the
65
+ deployment operator who owns the materialized files; it is not a guarantee for
66
+ arbitrary other operating-system principals.
67
+ Keep the old format explicitly verifiable for pre-migration evidence; never
68
+ reinterpret an old digest as covering modes. Other mode bits remain outside
69
+ identity. Do not rewrite modes during retention or infer executable entrypoints
70
+ by parsing free-form command/hook strings. This format change is not implemented
71
+ by the current primitive.
72
+
73
+ An existing revision is verified and reused. A damaged existing tree is an error,
74
+ never an invitation to overwrite it. Publishing another revision leaves the first
75
+ alone. Same-filesystem staging and rename avoid partially published trees; normal
76
+ errors remove staging. Concurrent publication of an already present valid revision
77
+ may reuse it after verification. A process crash can leave dot-prefixed staging
78
+ for later explicit cleanup; it is never a selectable artifact. This is not a
79
+ power-loss durability or hostile-host isolation guarantee.
80
+
81
+ Retention creates its managed ignore before any payload. It does not change the
82
+ scope's config, current lock, approval flags or authored capability directories.
83
+ Empty store directories/ignore metadata may remain after failure. No artifact
84
+ garbage collection is implemented: conservative retention is intentional.
85
+
86
+ ## Resolution and lock integration proposed next
87
+
88
+ Use a versioned per-instance resolution record, with a separate identifier from
89
+ runtime/session identity. It needs:
90
+
91
+ - Exact source soul reference and retained source revision.
92
+ - One selected artifact reference per capability ID, plus package provenance
93
+ sufficient to verify and, where possible, restore that artifact.
94
+ - Effective non-secret configuration, default/override provenance and binding
95
+ references, not secrets or a promise to freeze membership and credentials.
96
+ - Every managed helper, command/hook and runtime resource required for later
97
+ dispatch. Resource references resolve against retained artifact roots.
98
+
99
+ The following contract decisions incorporate the external expert's review:
100
+
101
+ - Imported and member-repository souls produce the same record shape: upstream
102
+ soul identity, exact retained source revision and adopter-local alias. Keep the
103
+ canonical repository and exported path in the source reference; the local alias
104
+ is not a global identity.
105
+ - Retain soul source artifacts separately from capability artifacts, under the
106
+ deployment, keyed by qualified source identity and content digest. Do not encode
107
+ a soul as a capability helper. A shared leaf module may implement the tree-copy,
108
+ digest and publication mechanics, with different provenance validation for each
109
+ kind. Retain all declared source resources needed after preparation, not just
110
+ `soul.yaml` or a symlink into the author's checkout.
111
+ Source retention inherits the same typed absence, invalid-shape and integrity
112
+ refusals, including never silently repairing a damaged retained tree.
113
+ - Store captured resolutions independently of instance homes so queued work can
114
+ retain a reference after its originating home is removed. Each instance and
115
+ independent execution references its exact resolution; conservative retention
116
+ applies to both source trees and resolution records.
117
+ - Record provenance per effective choice: a soul requirement/default, workspace
118
+ default, import-entry adoption default or explicit operator choice. Preserve the
119
+ hard constraints as well as the selected values.
120
+ - Record resolved non-secret provider bindings with separate credential references.
121
+ The default knowledge provider's payload includes store-qualified read nodes and
122
+ owned-node destinations. The kernel envelope does not require other knowledge
123
+ providers to implement OKF's owns/reads model.
124
+ - Record the responsible human/private-team key and chosen wider-team references
125
+ for messaging-enabled instances. These capture the choice, not immutable live
126
+ membership or permission to read earlier conversations.
127
+ - Existing-instance migration records `reconstructed`, `partial` or `unknown`
128
+ status with evidence and unresolved inputs. A partial or unknown record cannot
129
+ pass for a complete captured resolution in CLI or Desktop readiness.
130
+
131
+ The scope is an explicit deployment directory. A standalone repository or an
132
+ isolated user-data deployment uses the same store and APIs; no workspace Git
133
+ repository or parent-directory discovery is required by retention.
134
+
135
+ The deployment lock records current choices for new preparation. A captured
136
+ resolution is the authority for its instance or queued work; it must not look up
137
+ an older package row by ID in today's lock and accidentally acquire a new one.
138
+ The wire schema/version is not chosen by this retention patch. Current lock
139
+ objects are inputs for verification, not an implicit new persistent lock format.
140
+
141
+ Preparation publishes all needed artifacts, then commits the complete resolution
142
+ before launching anything. A failed preparation may leave unreferenced valid
143
+ artifacts; it must not leave a selectable partial resolution. Choosing or approving
144
+ a newer artifact is a separate operation. No artifact's presence grants approval.
145
+
146
+ Independent queued work retains the resolution it will execute, even after the
147
+ originating instance or source soul has been removed. Recurring schedules must
148
+ state whether they capture a composition or explicitly prepare a new one on a
149
+ future tick; an already queued execution cannot silently advance either way.
150
+ The proposed default is to capture the composition; re-preparation on later ticks
151
+ is an explicit policy. Messaging-disabled jobs do not acquire a private team.
152
+
153
+ ## Consumer migration
154
+
155
+ This is one coordinated change, not a permanent pair of resolution engines:
156
+
157
+ 1. Add the explicit lock/resolution schema and store migration. Verify the current
158
+ flat artifacts before retaining them. Do not re-fetch a moving source and
159
+ claim those bytes reconstruct an overwritten historical revision.
160
+ 2. Wire acquisition/preparation to retained artifacts. Ensure selected source
161
+ revisions are consistent across the transaction; preserve normal trust gates.
162
+ 3. Capture references for new instances and independent work. Route generated
163
+ commands, runtime packages, capability helpers, launch/retire hooks and recovery
164
+ through the captured resolution, including after source deletion.
165
+ 4. Migrate existing instance/queued-work records only where their exact managed
166
+ inputs can be established. Report unresolved historical inputs explicitly;
167
+ preserve running sessions and let their owners choose the restart boundary.
168
+ 5. Remove mutable-store lookups from captured consumers. Update diagnostics and
169
+ removal behavior to retain referenced revisions. Add collection only later if
170
+ actual storage use justifies it.
171
+
172
+ The compatibility boundary includes `core.mjs` acquisition, restoration, trust,
173
+ discovery, spawn, launch and retirement; package diagnostics and CLI paths; and
174
+ the scheduler/operation callers. Each is a consumer to check, not a reason to
175
+ create another config parser. Before wiring core consumers, extract the shared
176
+ artifact helpers into a narrow leaf module: `core.mjs` must not acquire a circular dependency on the retention module
177
+ that currently consumes its helpers. Keep policy and lifecycle logic out of the
178
+ shared leaf module.
179
+
180
+ ## Evidence and limits
181
+
182
+ The focused tests use the real package engine to install A, retain it, update to
183
+ B and retain B. Both execute their own test payload after removing the original
184
+ source, flat install and current lock. Further tests cover idempotent retention,
185
+ digest/provenance rejection, no silent repair, contained symlinks, and Git ignores.
186
+ No model harnesses or GUI processes are started.
187
+
188
+ This proves the storage prerequisite. It does **not** yet prove a running instance
189
+ or queued job dispatches A while new work uses B. That acceptance test belongs to
190
+ the consumer migration, with executable trust and recovery exercised end to end.