OverviewFilesCommitsIssuesDocsReleasesPeers

keet-daemon commits / 3cd545b

CPP-PORT-DESIGN: R4c-4d E0 correction — frontier scopes + foreign outer queue
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3cd545bafb921f8aa111e7eee2ec626be8d3ceb0
by plankatron <fleeky@gmail.com> · 2026-10-07T22:13:07.000Z

Changed files (1) +22 -0

docs/CPP-PORT-DESIGN.md +22 -0
……@@ -4311,6 +4311,28 @@ injected per layer:
43114311 numbering. Only `tools/l2-ops` and l2's own gates stay on l2 until R4c-4e.
43124312 - **E6. The core gate's `hops` mode and the R4c-4b concurrency scripts,** compared line for line with Bare at
43134313 pool = 1. Any difference is a finding, fixed in core.
4314 - **E0 CORRECTION (2026-10-07, found before any code; decided by the user: an outer queue for hooks).** A
4315 frontier scope around a whole core op also captures the microtasks that core's hooks queue in code OUTSIDE
4316 core. For example, `core->verify` (replicator.cpp:732) reaches the replicator's `inOndata_` request
4317 resolutions (replicator.cpp:145, 156) through `onappend` / `onupgrade`. The scope would drain those
4318 microtasks before `_handleData`'s remaining steps; today, and in JS's single queue, they run after. R4c-4c-3's
4319 scopes never hit this, because they wrapped pure storage calls. So E0 as written was NOT a no-op. The fix, as
4320 migration scaffold deleted at R4i together with `Sync` (same lint):
4321 - **rt:** a scope can be a FRONTIER scope. `rt::queueMicrotaskForeign(fn)` queues onto the queue that was
4322 current when the OUTERMOST open frontier scope began: the root, or a non-frontier scope around it. With no
4323 frontier open it is `queueMicrotask`. Storage-level `Sync` scopes nested inside a frontier are unaffected.
4324 - **scaffold:** `Frontier` is a `Sync` (same `wait`, same drain to quiescence) that pushes a frontier scope.
4325 E0's frontier sites use `Frontier`; core's internal storage scopes stay `Sync`.
4326 - **Foreign producers use `queueMicrotaskForeign`:** the replicator's two `inOndata_` deferrals, blobs'
4327 callback deferrals (blobs.cpp:194, 253, 296, 321, 501), autobee-wakeup's `Promise.resolve(false)`
4328 (autobee_wakeup.cpp:59), and protomux's deferrals (protomux.cpp:44, 136, 143, 147, 148, 153, 204). Their
4329 microtasks keep today's position whether or not a core op is on the stack. core/streams.cpp:56 is core's
4330 own, and stays.
4331 - **Gate:** r4c_scaffold gains cases for this: a foreign microtask queued inside a frontier runs after it, in
4332 FIFO with the root's; nested frontiers target the OUTERMOST frontier's parent; a `Sync` inside a frontier
4333 captures as before. E0's gates (ctest, m4b / m4c / m4d / m3c / m5* / r3c) must be identical, which shows
4334 the frontier is atomic and no foreign microtask moved. A drill: a producer back on `queueMicrotask` must go
4335 red in a pipe gate.
43144336 - **Rules carried from the hazards:**
43154337 - **Timer-resumed continuations open their own `Sync`.** `waitForRecovery`'s tail holds the state mutex, and
43164338 a timer callback is a frontier entry (D4).