@h1r-ai/croche 0.0.0-stage → 0.5.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 (86) hide show
  1. package/LICENSE +32 -0
  2. package/README.md +1176 -2
  3. package/THIRD-PARTY-NOTICES +5824 -0
  4. package/dist/archive.d.ts +47 -0
  5. package/dist/archive.js +217 -0
  6. package/dist/atomic-replace.d.ts +18 -0
  7. package/dist/atomic-replace.js +39 -0
  8. package/dist/commands.d.ts +56 -0
  9. package/dist/commands.js +1 -0
  10. package/dist/control.d.ts +62 -0
  11. package/dist/control.js +269 -0
  12. package/dist/core-abi.d.ts +110 -0
  13. package/dist/core-abi.js +1 -0
  14. package/dist/core-bindgen.d.ts +413 -0
  15. package/dist/core-bindgen.js +1533 -0
  16. package/dist/core-runtime.d.ts +214 -0
  17. package/dist/core-runtime.js +837 -0
  18. package/dist/core-wasm-bytes.d.ts +4 -0
  19. package/dist/core-wasm-bytes.js +5 -0
  20. package/dist/core-wasm.d.ts +16 -0
  21. package/dist/core-wasm.js +63 -0
  22. package/dist/debug.d.ts +26 -0
  23. package/dist/debug.js +171 -0
  24. package/dist/file-lock.d.ts +46 -0
  25. package/dist/file-lock.js +300 -0
  26. package/dist/images.d.ts +53 -0
  27. package/dist/images.js +179 -0
  28. package/dist/index.d.ts +14 -0
  29. package/dist/index.js +9 -0
  30. package/dist/markers.d.ts +1 -0
  31. package/dist/markers.js +1 -0
  32. package/dist/node.d.ts +46 -0
  33. package/dist/node.js +281 -0
  34. package/dist/project-core.d.ts +79 -0
  35. package/dist/project-core.js +261 -0
  36. package/dist/project-session.d.ts +44 -0
  37. package/dist/project-session.js +143 -0
  38. package/dist/project-types.d.ts +97 -0
  39. package/dist/project-types.js +1 -0
  40. package/dist/project-wire.d.ts +19 -0
  41. package/dist/project-wire.js +39 -0
  42. package/dist/sse.d.ts +19 -0
  43. package/dist/sse.js +53 -0
  44. package/dist/storage.d.ts +24 -0
  45. package/dist/storage.js +32 -0
  46. package/dist/stream-branch.d.ts +47 -0
  47. package/dist/stream-branch.js +107 -0
  48. package/dist/stream-hub.d.ts +207 -0
  49. package/dist/stream-hub.js +210 -0
  50. package/dist/stream.d.ts +3 -0
  51. package/dist/stream.js +5 -0
  52. package/dist/types.d.ts +930 -0
  53. package/dist/types.js +8 -0
  54. package/dist/wiki.d.ts +15 -0
  55. package/dist/wiki.js +25 -0
  56. package/docs/CODING-AGENT.md +92 -0
  57. package/docs/DEBUGGER.md +230 -0
  58. package/docs/S2-IMPLEMENTATION.md +585 -0
  59. package/docs/SKILL.md +295 -0
  60. package/package.json +52 -4
  61. package/src/archive.ts +188 -0
  62. package/src/atomic-replace.ts +43 -0
  63. package/src/commands.ts +62 -0
  64. package/src/control.ts +179 -0
  65. package/src/core-abi.ts +52 -0
  66. package/src/core-bindgen.ts +1557 -0
  67. package/src/core-runtime.ts +750 -0
  68. package/src/core-wasm-bytes.ts +5 -0
  69. package/src/core-wasm.ts +57 -0
  70. package/src/debug.ts +160 -0
  71. package/src/file-lock.ts +269 -0
  72. package/src/images.ts +174 -0
  73. package/src/index.ts +15 -0
  74. package/src/markers.ts +1 -0
  75. package/src/node.ts +194 -0
  76. package/src/project-core.ts +231 -0
  77. package/src/project-session.ts +118 -0
  78. package/src/project-types.ts +77 -0
  79. package/src/project-wire.ts +39 -0
  80. package/src/sse.ts +57 -0
  81. package/src/storage.ts +30 -0
  82. package/src/stream-branch.ts +112 -0
  83. package/src/stream-hub.ts +249 -0
  84. package/src/stream.ts +7 -0
  85. package/src/types.ts +840 -0
  86. package/src/wiki.ts +25 -0
@@ -0,0 +1,585 @@
1
+ # S2 implementation ledger
2
+
3
+ 2026-10-08. Draft #357, initially based on S1 #354 `45fa37d`; current parent is
4
+ `66c5136f`. Design: rev 4 §18, including the later rulings below; Atlas design YES
5
+ #264 comment 6064535190 covers the earlier kernel. Later sections override earlier ones.
6
+
7
+ S2 changes **no persisted bytes**. The v12 old-reader barrier is unchanged. No fake Core is included in production code. The new modules are internal and **not yet bound to CrocheRuntime's public API**.
8
+
9
+ ## Current split
10
+
11
+ `stream-hub.ts` owns one canonical observation attachment, request waiters, and the isolated app branch. `stream-branch.ts` schedules app callbacks serially off the canonical callback stack and bounds retained delivery work at 256 events / 1 MiB serialized UTF-8, including the in-flight event. Its `ended` promise exposes replacement, close, handler failure or overflow independently of a hung callback.
12
+
13
+ Core owns row projection, window/history selection, captured-H ordering, delta fences, and durability. `CoreStreamPort` is a proposed internal adapter boundary awaiting agreement with rook/Keel, **not an approved Rust ABI or a second protocol**. `select`/`history` project from the same Core attachment; they must not allocate another canonical subscriber. The adapter must feed canonical observations before projected app delivery.
14
+
15
+ The scoped `readOutcome` read's `captured` callback runs at its ordered capture point and reports H, floor, current input disposition and Core's agent-wide `idle` boolean. Its result carries matching ends through H plus actual read-gap evidence (including pruning during the read). Live bookkeeping continues synchronously while it reads; matching ends merge by id + seq. A prior completion observed before the receipt reaches JS is retained, rather than lost to later unrelated work. A UI window miss is not a gap.
16
+
17
+ Captured completion consumes Core's `idle` boolean (§18.20.5/7): no running unit, nothing
18
+ queued, no late invocation and no result_queued invocation. Live completion consumes the
19
+ canonical stream's `state.status` under the same Core guarantee (rook 6064971358, Keel
20
+ 6064993833). No additional live boolean wire field is invented. The SDK never computes
21
+ the predicate from queued counts or from the debugger's narrower runtime.state.
22
+
23
+ Keel's kernel review (6064961707) is implemented before any real binding: receipt-bearing
24
+ wait errors subclass `CrocheError`; closed subscribe/request use typed `closed`; an
25
+ already-aborted signal rejects typed `aborted` without sending or attaching a receipt.
26
+ Abort after acceptance still stops only the wait, with its receipt. `readOutcome` is an
27
+ internal rename, not a bound Rust name. Captured-terminal/pending-result and live-working
28
+ gates go red if captured idle is removed or an empty queued count is mistaken for idle.
29
+ The review-follow-up focused subset is 32 tests (six branch, 26 fake hub); the full local
30
+ suite passes 933 tests with four skips. Core/ABI binding evidence remains owed.
31
+
32
+ ## Executed versus owed
33
+
34
+ ### Parity and request policy follow-up
35
+
36
+ Keel 6070283323: invalid `initialMessages` emits only an unsequenced
37
+ `invalid_configuration` event, not a synchronous throw; finite maintenance
38
+ intervals below 1000 clamp to 1000. TS `setTools` stays synchronous. `state.typing`
39
+ is Core-owned, and `snapshot.streaming.firstSeq` is preserved. Tests cover the
40
+ error-only subscription including a hung callback, captured snapshot forwarding,
41
+ and **real embedded Core open** with the clamped open option. They do not prove
42
+ Core's production typing producer or snapshot projection.
43
+
44
+ Keel's newer 6070475698 (§18.24) supersedes the two-status parity wording:
45
+ state status is `running | waiting | idle`, with `queued` and `typing`.
46
+ No execution-unit glossary rename has been performed.
47
+
48
+ `requestComplete` is now the single completion predicate for captured and live
49
+ observations. `wait: 'idle'` is accepted. **The internal default still waits for
50
+ idle** until S1 commit 8 supplies consuming-unit end evidence. Atlas design YES
51
+ is recorded by Keel 6071897955; implementation, not design, is now pending.
52
+ Terminal disposition and cost-bearing `turn` events cannot substitute for that
53
+ evidence. Default consuming-unit completion, the confirmed `pending` name,
54
+ and internal `unit.end` remain unbound/unexecuted. This kernel is not yet the
55
+ final public request contract. It never calls `sendForResult`.
56
+
57
+ The Node draft is [apps/web-backend/S2.md](../../../apps/web-backend/S2.md), with
58
+ an injected-interface HTTP adapter and fake-Runtime local HTTP tests. It does not
59
+ replace the existing backend/browser or introduce a second Core subscription.
60
+ The readonly `logId` property is represented in the injected interface, not
61
+ bound to real Core. SSE Last-Event-ID includes log identity and sequence.
62
+ Normal body completion does not abort a request; actual
63
+ response-socket loss aborts only its wait. Browser/recovery/real-Core tests remain
64
+ owed; draft interface tests do not constitute those gates. Keel's Node shape
65
+ review 6070623457 corrects the earlier draft: `logId` is a readonly property;
66
+ SSE IDs carry `logId:seq`, increasing only, with gaps advancing `throughSeq`;
67
+ no-cursor connections select the latest-row window. Core cursor_reset is
68
+ ordinary SSE data followed by stream end, not an HTTP 409. The previous
69
+ metadata endpoint and logId query parameter have been removed. HTTP fake-Runtime
70
+ tests cover these relay rules, not real Core reset/replay or browser reconnection.
71
+
72
+ | Requirement | Evidence now | Still owed |
73
+ | --- | --- | --- |
74
+ | App callbacks are serial, off the canonical stack, bounded including in-flight work | Six focused branch tests; cap and UTF-8 mutants red | Bound real Core adapter and transport ordering |
75
+ | Ordinary, multi-message, late continuation, batched, unrelated/scheduled, failed/no_reply/cancelled request outcomes | Fake-Core tests; premature completion and unfiltered causes mutants red | Real Core Node/WASM request gates |
76
+ | Receipt-bearing observation loss and caller abort; healthy busy continues waiting | Fake-Core tests, including pending receipt delivery | Poison/close/reopen and durable at-most-once controls |
77
+ | Throwing/hung app handler, replacement/old close, concurrent requests | Fake-Core tests, one canonical observe count | Actual Core subscription lifetime and adapter generation gates |
78
+ | Hidden input status reaches request but not app | Fake Core emits canonical status with projection withheld | Actual Core window/loaded-row filtering |
79
+ | Same-id request outside 50 rows, other request active, continuation during read | Fake captured read plus live merge; dropping retained ends mutant red | Actual scoped retained-ends read and continuation race |
80
+ | Completed retry, seq order/dedupe, genuine gap, legacy status | Fake-Core tests; false gap mutant red | Core retention/clear/reopen through all placements |
81
+ | Every named gate has a red mutant | Selected mutants measured as above | Remaining per-gate sensitivity checks; do not call this complete |
82
+ | Receipt-returning public send; cancel/logId/history/tool app events | Not changed yet | Bind rook's commit-4/7 APIs, migrate §18.1 callers |
83
+ | UniFFI/WASM exposure and parity | Not changed yet | Agree Rust signatures before builds, Atlas ABI review |
84
+ | Plain app with no cursor/offset/epoch logic | Not run | Real Node and browser/WASM E2E |
85
+ | v12 reader barrier | Unmodified by S2 | Rerun unchanged when real binding lands |
86
+
87
+ Fake-Core assertions are **SDK algorithm checks**, not evidence of durable acceptance, real retention, provider behavior, or crash recovery. A question asked is not a case run.
88
+
89
+ Local gate for the first two S2 commits: **929 passed, 4 skipped** (124 test files passed,
90
+ one skipped); six Runtime/protocol/CLI/Cloud/debugger/Studio typechecks, SDK build, Studio
91
+ production build, plugin freshness and diff checks pass. The Studio bundle retains its
92
+ existing >500 KiB warning. The new focused subset is 28 tests (six branch, 22 fake hub).
93
+ Core/UniFFI were not rebuilt for this internal TS cut; real binding and barrier evidence
94
+ remain owed as listed above. No installation, paid-provider request, release or deployment.
95
+
96
+ The request-id mutation regression failed on the first kernel: changing the caller's input
97
+ object after acceptance made live matching follow the new id and hang. The fixed kernel
98
+ pins the submitted id at invocation. This is a defect found in S2 itself, not an S1 finding.
99
+
100
+ The four request mutants measured here remove retained ends, resolve without later idle,
101
+ include unrelated causes, and turn a window miss into a gap. Each fails its focused gate.
102
+ Branch mutants change 256 to 257 and count UTF-16 units instead of serialized UTF-8 bytes.
103
+ No claim is made that these six mutations cover every named design gate.
104
+
105
+ ## Remaining order
106
+
107
+ 1. Agree the internal capture/projection boundary against S1 commit-4/7 signatures; extend sensitivity and lifecycle tests.
108
+ 2. Bind real Core WASM/UniFFI APIs. Do not replace missing Core semantics with SDK projection or shipped fake behavior.
109
+ 3. Migrate backend, story example, control, and tests to receipt send plus subscription/request; remove per-send/runtime-wide onEvent.
110
+ 4. Execute the real-Core and plain-app gates above, keeping SDK fake checks separate from actual storage/browser evidence.
111
+
112
+ ## Latest local gate — parity/Node draft
113
+
114
+ Combined S1 parent `0cc665b` plus S2: **955 passed, four skipped** (127 test
115
+ files passed, one skipped). Focused subset: **52 passed**, consisting of 34 fake
116
+ hub tests, six branch tests, five real-Core maintenance-open tests and seven
117
+ Node draft HTTP/encoding tests. Seven typechecks (the previous six plus
118
+ web-backend), SDK build, Studio build, plugin freshness and diff checks pass.
119
+ The existing 532.5 KiB Studio bundle warning remains. All four S2 commits rebase
120
+ with identical range-diff on this S1 parent before this evidence-only addition.
121
+
122
+ Two additional sensitivity checks went red: removing the 1000-ms clamp fails
123
+ all three finite-low-interval gates, and assigning an SSE id to unsequenced
124
+ live events fails the encoding gate. Both mutants were restored before the
125
+ immutable full-suite run. These are not a claim of complete mutation coverage.
126
+ No provider call, installation, release or deployment was used. Core/UniFFI and
127
+ the v12 barrier were not rebuilt; the adapter remains unbound as listed above.
128
+
129
+ ## Node relay review delta — 6070623457
130
+
131
+ Executed after the three shape corrections: **959 passed, four skipped** (127
132
+ files passed, one skipped), **56 focused** including 11 Node draft tests. Seven
133
+ typechecks, SDK/Studio builds, plugin freshness and diff checks pass; the same
134
+ Studio bundle warning remains. Request completion source is unchanged.
135
+
136
+ Four new red controls: allow decreasing SSE IDs; ignore gap `throughSeq`; start
137
+ without a cursor at sequence zero instead of the latest window; return HTTP 409
138
+ for a mismatched log. Each fails its named relay gate. All were restored before
139
+ the full-suite run. The HTTP tests use real local sockets and a fake Runtime;
140
+ Core cursor validation/durable replay and an actual EventSource reconnect remain
141
+ owed, rather than inferred from these adapter checks. No release or deployment.
142
+
143
+ ## Founder terminology / subscription-end rulings — 2026-10-09
144
+
145
+ 6071179153 / 6071345646 / 6071419228 applied to the kernel. S1 parent `80d3757`
146
+ already carries debug `running | waiting | idle | closed`, `summary` terminology
147
+ and the existing TS `storageKey` option. S2 corrects the prepare-purpose comment;
148
+ the usage purpose remains open to future strings rather than rejecting them.
149
+ Internal message/page types use `MessageEvent` and `page.messages`, distinguish
150
+ user messages from event inputs, and have no public `turnId`. Snapshot streaming
151
+ uses `messageId`. Tool/usage/debug and transitional API unit IDs are not stripped.
152
+
153
+ Each SDK-side end attempts exactly one final callback: replaced, handler_failed,
154
+ subscriber_overflow, runtime closed. Queued normal events are dropped. The final
155
+ notification bypasses a stuck normal callback; it may overlap it, never waits
156
+ for it, and a terminal callback failure is ignored. App subscription.close is
157
+ silent. Core live errors seal the queue on arrival, drain preceding events and
158
+ deliver that error once; durable errors are ordinary. No second SDK terminal is
159
+ synthesized for a Core-delivered end. Normal delivery remains serial and bounded,
160
+ including the in-flight event; the one final control notification bypasses caps.
161
+ Explicit app close also suppresses a final notification queued before that call.
162
+ An ordered fake poison gate exposed another SDK race: projection-before-on_end
163
+ does not itself deliver the app callback. Observation end now preserves an already
164
+ draining Core terminal error, including poisoned:true; explicit Runtime close still
165
+ drops that backlog and reports closed. The dropping/draining controls both execute.
166
+
167
+ The hub target now exposes receipt-only send and Runtime-level history routing.
168
+ History without an attached live generation throws invalid_configuration, both
169
+ with and without before. Late pages remain captured to the asking generation.
170
+ Rook's #368 `14ca307` generator and JSON are unchanged; all 20 shared scenarios
171
+ execute with no skips. The TS runner uses actual hub.history, not a fabricated
172
+ no-stream error. These are fake-Core algorithm/parity checks only.
173
+
174
+ **[pending S1 7b]**, per Keel 6071731052: public CrocheRuntime.send still uses
175
+ sendForResult / TurnResult and per-send onEvent; public history still returns
176
+ inspection messages. Public subscribe/request/logId and page-history binding,
177
+ dependent backend/story/control callers and their tests wait for real
178
+ select/history/read_outcome. No shim. #357 must not merge until those public
179
+ calls are migrated together. S2 still changes no persisted bytes.
180
+
181
+ Latest frozen local gate: **987 passed, four skipped** (128 files passed, one
182
+ skipped). Focused: **84 passed**, including the 20 shared parity scenarios plus
183
+ their census check, 41 hub checks, six branch checks, five maintenance-open checks
184
+ and 11 Node draft checks. Seven typechecks, SDK/Studio builds, plugin freshness
185
+ and diff checks pass; existing Studio size warning remains. JSON/generator diff
186
+ against rook's #368 is empty; crates/protocol/Cloud diff against S1 is empty.
187
+
188
+ Eight end/generation mutants went red: omit replaced, omit subscriber_overflow,
189
+ omit handler_failed, omit runtime closed, omit projected terminal endAfter, leak
190
+ old projection into the new generation, notify explicit subscription close,
191
+ and discard a draining Core terminal on observation end. The explicit-close
192
+ microtask race and Core poison race were each red on the earlier kernel before
193
+ their fixes. Mutants were restored before the final full gate.
194
+
195
+ Still owed at real binding: Core/ABI durability, unchanged v12 reader gate,
196
+ browser/WASM plain-app and transport recovery, and history settlement at actual
197
+ app-handler delivery (rather than just the Core listener), with the cursor-form
198
+ before/limit rules. The window cap was pending at this gate; founder 01:24Z
199
+ confirmed it in 6072371963, as recorded below. No installs, paid
200
+ provider request, release or deployment.
201
+
202
+ ## Delta review and founder 01:24Z — 2026-10-09
203
+
204
+ Keel 6071925557: every SDK-side terminal error now carries a nonblank `message`;
205
+ replacement keeps its own event. Core errors, including `message` and `poisoned`,
206
+ pass through without synthesizing or replacing fields. Both history entry points
207
+ return rejected promises, including calls on invalid, closed or replaced
208
+ subscriptions. `.catch()` sees `invalid_configuration`; an invalid initial
209
+ window can no longer return silent-success history.
210
+
211
+ Founder routing 6072371963 confirms `initialMessages` 0..256 (zero remains valid)
212
+ and history `limit` 1..256. Nonintegers, NaN and infinity reject. These checks
213
+ precede the Core page call. Internal `StreamTurnEvent` requires
214
+ `purpose: 'model' | 'summary'`; it is not yet the public binding.
215
+
216
+ **[pending S1]**, as confirmed by Keel 6072413877 and assigned to S1 in #354
217
+ 6072370693: remove `turnId` from ToolContext, MemoryItem and its history, and
218
+ replace RuntimeUsageEvent.turnId with causedBy; ordinary call purpose becomes
219
+ `model` in debug, usage and every public turn event. S2 takes the producer/type
220
+ change together when S1 lands it. No SDK stripping or invented causedBy/join.
221
+ Public TurnEvent must carry the purpose union when bound; it cannot stay internal.
222
+ The confirmed `pending` name and consuming-unit request cut bind at S1 commit 8.
223
+
224
+ Focused gate: **96 passed**, including all **21 shared scenarios** plus census.
225
+ Fixture JSON/generator are unchanged from rook #368 `a88db641`; the added Core
226
+ end operation exercises three queued deltas followed by the poisoned error.
227
+ Five red controls: omit SDK error message; synchronously throw Runtime history;
228
+ synchronously throw subscription history; make invalid-window history a no-op;
229
+ ignore page bounds. Each fails its focused gate. All restored before the full run.
230
+
231
+ Final frozen full local gate: **999 passed, four skipped** (128 files passed,
232
+ one skipped). Seven typechecks, SDK/Studio builds, plugin freshness and diff
233
+ checks pass; the existing 532.51 KiB Studio bundle warning remains. No changes
234
+ to crates/protocol/Cloud against S1 `80d3757`. Real binding, public migration,
235
+ Core/UniFFI/v12 barrier and actual browser/native gates remain owed. No paid
236
+ provider calls, installs, release or deployment.
237
+
238
+ ## Fixture ownership correction — Keel 6072441232 / 6072444138
239
+
240
+ The entire shared fixture triplet (`s3-parity.json`, `s3-parity.gen.mjs` and
241
+ `S3-PARITY.md`) is now byte-identical to rook #368 `7cbca748`. The regenerated
242
+ turn examples carry `purpose: 'model'`. The shared documentation retains rook's
243
+ `end` operation row and Swift/Kotlin scenario-21 results unchanged; those are
244
+ rook's measurements, not new native executions by S2.
245
+
246
+ TS follow-up, moved here from the shared fixture documentation: all 21 scenarios
247
+ execute, including `a_poisoned_core_end_drains_the_queue_then_delivers_its_error_last`.
248
+ The runner handles Core's `end` operation and catches history rejections through
249
+ the returned promise. Message-bearing SDK terminal errors have separate focused
250
+ checks: canonical gate-9 normalization intentionally omits error message text.
251
+
252
+ Executed after this fixture-only delta: **999 passed, four skipped** (128 files
253
+ passed, one skipped), and **96 focused checks**. Seven typechecks, SDK/Studio
254
+ builds, plugin freshness, generator/JSON comparison and diff checks pass. All
255
+ three shared file blob hashes match `7cbca748`; production source and the runner
256
+ are unchanged from `c4c73db`. The existing Studio bundle warning remains. No
257
+ new Core/native/browser evidence, install, paid call, release or deployment.
258
+
259
+ ## Stacked sends / croche-chat #93 — 6074213027, 6074271952, 6074298264
260
+
261
+ The single TS `SendInput` form accepts `images`; the stack form forbids top-level
262
+ images. Both forms prepare standard images through the same codec and admission
263
+ ordering before sending. URL, high-resolution and codec-less Node images pass
264
+ unchanged. The SDK preserves the single form: its conversion into a one-part
265
+ stack belongs to Core, and is not simulated here. Hub send/request preserve the
266
+ stack, context and one input id unchanged.
267
+
268
+ Browsers attach `visibilitychange` only while automatic upkeep is enabled.
269
+ Visible returns call non-forced maintain, coalesce inside maintenanceIntervalMs
270
+ and never overlap another foreground call. Close removes the listener. Node has
271
+ no listener. Per 6074298264, backgroundSync false disables both automatic timer
272
+ and foreground hook; explicit maintain remains available. Core owns due/backoff
273
+ and durable work. The lifecycle test uses a synthetic Document EventTarget with
274
+ the real embedded Core and fixture Cloud, not a Chrome/Safari lifecycle run.
275
+
276
+ The storage check pins the existing derived store path for a fixed configuration,
277
+ rather than computing an expected key from the implementation under test. It
278
+ also passed with the previous adapter at eac7ce6 temporarily restored. Default
279
+ and explicitly equivalent storageKey reopen the same persisted conversation.
280
+ This is existing-path/reopen evidence, not the S1-8 unsettled legacy input's
281
+ eventual stream status or a v12 migration/barrier rerun.
282
+
283
+ Prepared only, as ruled in 6074298264: internal StreamToolContext adds
284
+ causedBy: string[] and origin: 'app' | 'agent'; CoreStreamPort/StreamHub cancel
285
+ accept an optional id and return Promise<void>. The hub forwards that choice,
286
+ waits for the Core promise and propagates failures. The fake checks delegation,
287
+ not cancellation durability or which inputs stop. Public ToolContext and
288
+ CrocheRuntime.cancel await the producer and async durable Core API; there is no
289
+ Promise wrapper pretending today's synchronous cancelTurn is durable.
290
+
291
+ Focused checks: **107 passed**. Five red controls were restored before the full
292
+ gate: skip single-image preparation; ignore foreground opt-out; ignore interval
293
+ coalescing; retain the listener on close; drift the default storage path. Shared
294
+ fixture triplet remains unchanged from rook #368 7cbca748.
295
+
296
+ Final frozen local gate: **1010 passed, four skipped** (129 files passed, one
297
+ skipped). Seven typechecks, SDK/Studio builds, plugin freshness, fixture generator
298
+ and diff checks pass; existing Studio bundle warning remains. Parent is S1
299
+ 66c5136f; no crate/protocol/Cloud changes. Single-input Core normalization,
300
+ durable no-id cancel, tool-context provenance, real browser lifecycle and the
301
+ remaining real binding/legacy-stream gates are not claimed by these SDK checks.
302
+ No install, paid-provider call, release or deployment.
303
+
304
+ ## Project → Agent v2 staging — 2026-10-09
305
+
306
+ Founder decisions 6074456269, 6074529332 and 6074548271 supersede the
307
+ previous compatibility/storage-path requirement. The old-path check is deleted.
308
+ New typed open options use config, handlers and optional user, without a host
309
+ installationId or storageKey override. The internal ProjectSession coordinates
310
+ default-agent caching, overrides, close/reopen and read-only registration ids
311
+ through a typed factory. It is not a root export or a real Core binding.
312
+
313
+ Core owns the five-layer merge, hashes, registration identities, remote config
314
+ selection and override-path reporting. The coordinator passes overrides intact;
315
+ its equality comparison only detects a conflicting second open. Both directions
316
+ of declaration/handler completeness are checked across bundled agent/language
317
+ entries, per Keel 6074968852.
318
+
319
+ Ten fake-factory tests pass. Three red controls caught undeclared handlers,
320
+ silently reused different overrides and omitted project cleanup. Full local
321
+ gate: **1019 passed, four skipped**; seven typechecks, SDK/Studio builds, plugin
322
+ freshness and diff checks pass. The existing bundle-size warning remains.
323
+
324
+ Public CrocheRuntime callers and RN have not migrated yet. Their old APIs will
325
+ be removed with caller migration, without aliases. The legacy receipt branch
326
+ awaits rook's regenerated fixture, as Keel directed. Removing setTools also
327
+ removes the story-companion demo's live permission toggle; that feature-deletion
328
+ finding was reported on #339 before changing it. This slice proves neither real
329
+ Core resolution nor shared identity/budget behavior. No release or deployment.
330
+
331
+ ### Founder follow-up: tool controls and shared RN types
332
+
333
+ Keel 6075169212 / 6075172504 supersede the preceding setTools deletion plan:
334
+ keep names-only async setTools, add async setMode and read-only mode/visibleTools.
335
+ Declarations still belong in config. Added shared types for modes/toolGuide,
336
+ schedule and heartbeat, and included mode declarations in handler-completeness
337
+ checks. A mode-only tool with a handler opens; a nested mode without one refuses.
338
+ Skipping the mode walk makes both cases red. No TS overlay or visibility state
339
+ is synthesized: actual selection, withdrawal and cache invalidation await Core.
340
+
341
+ RN's staged project options consume the same TS declarations and handler/context
342
+ types, with attestation/android/backgroundDelivery as host capabilities. Compile
343
+ checks reject old declaration-valued setTools and host-set store/install identity.
344
+ This is not a working RN project binding or native execution. The shared types
345
+ are exported from TS; no open alias or compatibility wrapper was added.
346
+
347
+ The Studio draft-editor work in the separate worktree is parked, uncommitted,
348
+ per 6075191284. Release/list/applied UI remains secondary to TS then RN; its
349
+ synthetic tests are not live Cloud delivery evidence. The first browser exercise
350
+ failed because its synthetic Overview response was malformed; no browser pass
351
+ is claimed. Public migration, actual Core binding and old fixture retirement
352
+ remain open. No release/deployment.
353
+
354
+ Final frozen gate for this follow-up: **1021 passed, four skipped** (131 files
355
+ passed, one skipped). Eight typechecks including RN, SDK/Studio builds, plugin
356
+ freshness and diff checks pass. The existing Studio bundle warning remains.
357
+ Twelve focused checks pass; the mode-walk mutant failed two and was restored
358
+ before this run. No real Core/native binding or browser success is claimed.
359
+
360
+ ### Consent deletion and toolGuide — founder 05:58Z
361
+
362
+ Per #357 6075283666 / #339 6075281274: toolGuide is the single per-agent field;
363
+ toolPolicy is deleted without an alias. RuntimeCommand no longer declares
364
+ confirm. SendInput no longer claims that app/person inputs authorize held
365
+ commands. Compile checks reject both removed declaration fields. Five
366
+ consent-only SDK cases are deleted; streamed/non-streamed tool-batch bounds,
367
+ held sends and cancellation coverage remain. RN's unknown-option fixture now
368
+ uses a neutral unknown field instead of teaching toolPolicy.
369
+
370
+ The one-sided debug-event deletion was executed: **1015 passed, one failed,
371
+ four skipped**. The failure is exact Core emission parity, because S1 still
372
+ emits consent.held/stated/used. Per Keel 6075324251 those three names are
373
+ **kept for parity until the Core consent removal (#339 6075281274)**, and then
374
+ deleted in that Core PR or immediately after. The parity test is unchanged:
375
+ no excluded events, skip or relaxed assertion. Core rejection of a JSON
376
+ declaration containing confirm is still producer work, not a passed SDK gate.
377
+ Keel owns the public docs/approval example; no Core or canonical-doc edit here.
378
+
379
+ Final frozen rerun with producer/consumer debug names aligned: **1016 passed,
380
+ four skipped** (131 files passed, one skipped), eight typechecks including RN,
381
+ SDK/Studio builds, plugin freshness and diff checks pass. Five fewer tests are
382
+ the explicitly retired consent cases, not new skips. The existing Studio bundle
383
+ warning remains. No install, paid-provider call, release or deployment.
384
+
385
+ ### Image preparation fixture / CI merge-tree check — 2026-10-09
386
+
387
+ CI run 37892102385 fails the four image cases on both the normal and +35-day
388
+ jobs, not only the latter. No catalog-expiry cause was established. The fixture
389
+ did not deliver image_models. It now declares the fake gateway's image capability
390
+ explicitly and executes every image mode at day 0 and a JavaScript Date shift
391
+ of +35 days. Production code is unchanged; afterEach restores the clock.
392
+
393
+ Local branch WASM is 5fc1c90b. The fetched PR merge tree b79f5d3 (S1 parent
394
+ 8e5dc01) carries 81818524. The original fixture reproduced four failures on
395
+ that merge tree's normal clock; it passed on the older branch Core, even after
396
+ injected-clock and JS-Date shifts. The fixed file passes all 12 cases on both
397
+ trees. On the merge tree, omitting only image_models makes eight cases fail;
398
+ restoring it returns 12 passes. Test-file hashes match across the two trees.
399
+
400
+ Full suites on both trees: **1020 passed, four skipped**, 131 files passed and
401
+ one skipped. Branch eight typechecks, SDK/Studio builds, plugin freshness and
402
+ diff checks pass; existing bundle warning remains. Merge-tree verification uses
403
+ an isolated detached worktree and reused dependency cache, not a new install.
404
+
405
+ **Not executed:** a local libfaketime run. Neither faketime nor its library is
406
+ installed here; Leo was asked for an approved tool path or installation approval.
407
+ The JS-Date cases are not reported as libfaketime evidence. CI's actual +35-day
408
+ job must pass before merge. No release, deployment or paid-provider call.
409
+
410
+ ### Provider image delivery assertion — 2026-10-09, Leo 06:46Z
411
+
412
+ The 12 cases at aca00e7 asserted preparation/forwarding, not provider delivery.
413
+ The eight image cases now inspect the fake gateway's actual model request and
414
+ require exactly the expected image_url: the URL for URL mode, or the exact
415
+ PNG data URL with independently expected resized/original bytes for the other
416
+ modes. The four foreground cases remain unchanged.
417
+
418
+ Executed control: older branch Core 5fc1c90b fails all eight image cases because
419
+ the provider image list is empty. Merge Core 81818524 passes all 12. Rebased
420
+ onto S1 1a46557b7e943d57641e6b6746840819ee6c44e7, current Core 0d89db56
421
+ also passes all 12. No conflicts or hand resolution; all 17 replayed patches
422
+ are identical in range-diff. No producer/generated-Core file changed in this lane.
423
+
424
+ Final rebased gate: **1020 passed, four skipped**, 131 files passed and one
425
+ skipped. Eight typechecks, SDK/Studio builds, plugin freshness and diff checks
426
+ pass; existing bundle warning remains. This proves delivery to the fixture's
427
+ provider request, not a paid provider or native/RN execution.
428
+
429
+ Leo closed the local faketime tool question at 06:33Z/06:36Z: do not install;
430
+ CI supplies the actual shifted-clock gate. The earlier request above is historical,
431
+ not an outstanding installation request. New-head CI still must pass before merge.
432
+
433
+ ### Project open retention option — Keel 6076089026
434
+
435
+ The staged OpenOptions now has retentionBytes?: number, inherited by RN's shared
436
+ options. It is host-only, never a configuration property. The SDK forwards it
437
+ unchanged and omits the key when absent; it performs no defaulting or validation.
438
+ The fake-factory test checks omission and unchanged explicit values, including
439
+ below-minimum and non-integer values. It does not claim real Core acceptance or
440
+ rejection. The real Project open gates for absent, 1048576 and invalid 524287
441
+ remain owed until the Project/Agent adapter is available.
442
+
443
+ Keel 6078348447 follow-up, executed 2026-10-09:
444
+
445
+ - SDK default mutant (`retentionBytes ?? 4194304`): red on the absent-key assertion.
446
+ - SDK clamp mutant (`Math.max(1048576, value)`): red because 524287 became 1048576.
447
+ - SDK round mutant (`Math.floor(value)`): red because 0.5 became 0.
448
+ - RN compile-only contract now calls CrocheRuntime.create with retentionBytes
449
+ under @ts-expect-error. Temporarily adding retentionBytes to legacy RuntimeOptions
450
+ and rebuilding the SDK makes RN tsc fail with TS2578 (unused directive).
451
+ - An initial RN typecheck used stale dist from the other branch and failed on
452
+ missing staged fields; that is not the type mutant evidence. The measured
453
+ mutant above rebuilds the SDK first, as does the restored full gate.
454
+
455
+ All temporary source mutants are removed. No SDK validation/defaulting was
456
+ introduced; real Project-open/Core validation remains owed.
457
+
458
+ ### Accepted factory consumer alignment — 2026-10-09
459
+
460
+ Names read from #377 6078466532, with Keel Q1–Q4 6078489328,
461
+ retention placement 6078660666 and browser detection 6078675928.
462
+ The staged consumer passes explicit language unchanged; absent browser language
463
+ uses navigator.language only when document exists. Node passes no language even
464
+ with navigator present. The navigator-only mutant fails the Node omission gate.
465
+ Core owns tag validation and exact/primary/default selection; no F9 in TS.
466
+
467
+ Delete no longer manufactures agent default or requires a declared id. Omission
468
+ means Core's all-declared-agent transaction; an explicit removed agent is passed
469
+ through. Fake tests do not prove locking, deletion, or record retention.
470
+
471
+ The internal project-wire encoder separates host/runtime/config/handlers and
472
+ puts retentionBytes in host, omitted when absent and unchanged when present.
473
+ Callbacks/adapters remain local; no SDK config resolution or identity synthesis.
474
+ These encoding tests are not real factory tests. The first #381 head bd3e2911
475
+ still lacks crocheUserId/deleteStore/tool controls and accepted Q1–Q4 changes;
476
+ binding and real-open tests await the producer delta. #379 remains draft.
477
+
478
+ Restored alignment gate: 1083 passed, four existing skips; eight typechecks,
479
+ SDK/Studio builds, plugin freshness and diff check pass. Sixteen focused fake
480
+ lifecycle/encoding cases pass. No real Project factory execution is claimed.
481
+
482
+ ### Real Project factory binding — 2026-10-09
483
+
484
+ The paragraph above describes the earlier alignment head, not this binding.
485
+ `Croche.open`, `croche.agent`, `close`, `user`, `installationId`, `crocheUserId`
486
+ and `agentIds` now call the actual `WasmProject` exports from #381. The SDK's
487
+ agent map preserves JS object identity only: every agent call reaches Core to
488
+ validate the override and lifecycle. Duplicate returned WASM clones are freed.
489
+ Core owns config layers, census, record selection, ids and store hashes.
490
+
491
+ The new agent uses Core receipt send and its one canonical observer plus app
492
+ projection. It offers send/subscribe/history/logId/close and sync; no per-send
493
+ event callback or turn result. PAL, image preparation, handler isolation, storage,
494
+ transport and foreground scheduling reuse the existing host. A host is created
495
+ whenever the factory requests one; closed agents do not reuse a timer owner.
496
+ Core's userId in tool context is renamed crocheUserId, while app user comes from
497
+ the project getter; cause/origin/agentId come unchanged from Core.
498
+
499
+ Twelve real-WASM gates (only transport fake) cover persisted/shared identity,
500
+ agent overrides and close/reopen, first registration's live user id, server id
501
+ absence, closing all agents, pre-write validation, actual language-specific
502
+ provider requests, handler execution/provenance, receipt/projection/history,
503
+ receipt-before-model completion, PAL time zone and retention open validation.
504
+ SDK mutants: navigator-only selection fails the actual provider-persona gate;
505
+ installationId always null fails the device identity gate; crocheUserId always
506
+ null fails the post-registration gate; putting timeZone in hostFields fails
507
+ the real-WASM time-zone gate. All reverted before the final gate.
508
+ Fixture corrections, not Core fixes: server keys require csk_ plus 64 hex digits;
509
+ the default language lives in the base, not languages[defaultLanguage]; receipt
510
+ status may already be seen when its promise resolves, not always queued.
511
+
512
+ **Still owed, not test coverage:** public request's consuming-unit completion
513
+ binding, async cancel, deleteStore, name/tool-visibility controls and public legacy
514
+ API removal. This is the factory slice, not complete S2. At the first 1e59d294
515
+ binding, retentionBytes/timeZone in the posted prose did not match HOST_FIELDS;
516
+ reported to rook and settled below. debugVisibility does exist in that allowlist
517
+ and is forwarded. The factory still lacks sync-to-record config delivery; owned
518
+ by rook, not synthesized by this adapter. Paid providers/native devices are not
519
+ part of these gates.
520
+
521
+ Factory follow-up consumed through d2e4df1b: host.retentionBytes now exists.
522
+ Real default and 1 MiB agent opens succeed; 524287 and 0.5 are refused by Core
523
+ at agent open with no agent-store writes (the project record may already exist).
524
+ This is not an SDK logical-pruning test; Core's own pruning gates are separate.
525
+ Keel 6079291889 settled timeZone as PAL-only, never on the JSON wire; the real
526
+ PAL returns 540 for Asia/Seoul and the real provider request's time channel shows
527
+ UTC+09:00. No host-side config field was invented to solve the prose discrepancy.
528
+
529
+ Initial full combined gate exposed an SDK raw-Core type leak through an internal
530
+ PAL factory attached to the public class. The helper is now module-local to the
531
+ package implementation; constructors also take no raw-Core arguments. The
532
+ existing exhaustive public-type walker passes without weakening it. The same
533
+ run had a missing fake-indexeddb cache target, fixed by relinking this worktree's
534
+ owned dependency link to an existing locked-version 6.2.5 cache (no install).
535
+ An initial ABI comparison used the stale main native library; rebuilding native
536
+ Core returned 129 identical transitions. Neither failed run is called green.
537
+
538
+ Final restored combined gate: 1110 passed, four existing skips (140 files pass,
539
+ one skipped); eight typechecks, SDK/Studio builds, plugin/source freshness and
540
+ format/diff checks pass. Current-source native/committed-WASM comparison gives
541
+ 129 identical transitions, zero provider calls. No final CI or device-matrix
542
+ claim. Parent integration merged the S2 main tree with factory d2e4df1b rather
543
+ than rebasing S2 onto its older S1-only parent; #380 bindings were replayed with
544
+ generated files resolved only by regeneration. No factory Rust edits by Milo.
545
+
546
+ ### Factory tool/mode bindings — 2026-10-09
547
+
548
+ Rebased onto #381 `6ab80a5f`. The older S2 squash was already present in the
549
+ factory's newer ancestry and disappeared from the replay. Four conflicting S3
550
+ fixture files retain the upstream versions unchanged. Stream ABI source patches
551
+ and SDK patches replay unchanged; conflicting generated glue/bytes retain the
552
+ base temporarily and are then regenerated from the combined Core source.
553
+ There is no handwritten factory Rust conflict resolution.
554
+
555
+ `CrocheAgent` now implements the accepted `AgentToolControls`: async
556
+ `setTools(names | null)` and `setMode(name | null)`, plus Core-backed `mode` and
557
+ `visibleTools` getters. Null restores the Core default. Tool names are encoded
558
+ as a JSON array for WASM, not reinterpreted as declarations. Core alone validates
559
+ the current tool list and per-agent mode registry, retains filters across mode
560
+ switches, and emits the change/unmatched events. Agent `id` and `name` getters
561
+ also read the actual Core exports. The public config field is `reasoning` with
562
+ the five accepted levels; there is no `reasoningEffort` alias in `AgentConfig`.
563
+
564
+ Two additional real-Core tests cover empty visibility, restore, invalid names,
565
+ fresh getter arrays, reopened defaults, per-agent mode refusal, the surviving
566
+ filter, actual hidden provider tools and Core `tools.changed`/`tools.unmatched`
567
+ events. Both SDK forwarding mutants fail their intended gate: drop names →
568
+ visibility is null instead of garden; drop mode → mode is null instead of
569
+ gardening. Both were reverted before the final full gate. The standing founder
570
+ test still proves language-resolved system text, agent tools replacing project
571
+ tools and provider `max_tokens` of 777 / 555 / 333 through public open/agent/send.
572
+
573
+ Final unchanged-source full run: 1205 passed, five existing upstream skips
574
+ (141 files passed, one skipped); eight typechecks, SDK/Studio builds,
575
+ plugin/Core freshness and format/diff checks pass. Native/committed-WASM ABI
576
+ comparison: 129 identical transitions, zero paid-provider calls. An earlier full
577
+ run failed the existing H2 elapsed-time assertion (3750 ms versus <3400 ms)
578
+ while native compilation ran concurrently. That run is not called green. The
579
+ unchanged test passed in isolation, then the full suite passed with the compiler
580
+ idle; no test was weakened or excluded.
581
+
582
+ Still owed: public request completion, async cancel, deleteStore, legacy public
583
+ API removal and RN factory migration. The canonical profile table at this base
584
+ is empty; no valid app-selected model provider-delivery test is claimed here.
585
+ No release, deploy, paid-provider, device-matrix or CI evidence is claimed.