Skip to content

perf(sessions): reduce turn completion database work - #168592

Merged
steipete merged 103 commits into
mainfrom
dbasync/actorb4
Oct 11, 2026
Merged

steipete merged 103 commits into
mainfrom
dbasync/actorb4

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Turn completion persisted related session bookkeeping through separate generic
patches: group intro, fallback notice, usage/context/billing, live-model cleanup,
activity, and final-delivery custody. Those independent prepare/commit cycles
repeated entry reads, side-table work, publication and transaction envelopes.

User Impact

No intended user-visible behavior change: the session owner performs less
duplicated database work while preserving completion, accounting and delivery
custody. No operator migration or configuration change is required.

Why This Change Was Made

Stacked on dbasync/actorb1. Route terminal work through its existing physical
session owner and completeTurn, without appending a second assistant message.
The shared pure bookkeeping reducers also serve the named native/SDK patch
adapter; the folded patch-fusion work suppresses unchanged entry/window/snapshot
writes and reuses authoritative postimages within the synchronous commit.

Restart delivery records deliveryPending before sending and deliverySettled
only after confirmed delivery or a proven no-send result. Pending-final settlement
retains exact intent/payload IDs, current harness authority, actual dispositions,
and recovery-wake decisions. Usage remains best-effort; live-model failure still
propagates. Captured model/auth fields prevent an older completion from clearing
a newer selection. Known commits survive fallible publication; unknown outcomes
follow B1's existing disclosure/reconciliation contract and are not replayed by B4.

The native-incognito adapter retains the already-open memory owner. Cancellation
rejects new actor admission/disclosure without revoking accepted phase work or
receipt installation. Maintenance consumes the same committed completion entry
and the existing reply-owner settlement; no new trigger or early intent clearing.

Deleted superseded internal persistSessionUsageUpdate and
consolidateLiveModelSwitchAfterRun writers. No schema, durability, retention,
permission, released SDK or foreign-commit freshness change is intended.

Queued/steering activity retains its own actor command because that branch has
no later durable point before returning. Ordinary terminal accounting is fused.

Measurements

Four alternating B1,B4 pairs on one admitted, task-owned AWS Crabbox lease.
Each run completed 13 successful turns, a second session, control, cron,
compaction and shutdown. Warmed all-thread statements fell 681.95 → 615.35
(−66.60, −9.77%); DB requests 168.5 → 163.9 and total worker requests
169.9 → 165.2. Explicit native commits fell 66.1 → 64.05.
The overall actor target is not reached by this lane; only the verified saving
is claimed. No savings are attributed to moving work between threads.

The shared census harness is unchanged. Task-local analysis corrects a
source-map-sensitive CPU classifier: recordProviderPrompt has the same
zero-SQL CPU contract in source and bundled stacks. This removes 16 wrongly
classified candidate DB requests across each full run, without changing total
worker requests, statements, frames, or transactions. Native attribution groups
by thread, operation and normalized SQL, not source-map-dependent filenames.

All phases: ALL + MAIN counters and durations

Pinned B1 cc65e9aacc50bfd2e86a8edc0eb89d561e571b3a and B4 ae04df5e0d58faf3d02afced834b10240928eefc; 4 alternating pairs. Cells are median [min–max]. Warmed values are the median of each run’s ten-turn mean, not pooled individual turns.

Native SQLite statements and explicit commits

Phase Statements all threads B1 / B4 Statements MAIN B1 / B4 Explicit commits all threads B1 / B4 Explicit commits MAIN B1 / B4
01.boot 2150 [2150–2152] / 2149 [2148–2150] 1925 [1925–1925] / 1925 [1925–1925] 35 [35–35] / 35 [35–35] 12 [12–12] / 12 [12–12]
01.connect 1024 [1022–1167] / 1133 [1113–1151] 94 [94–100] / 94 [94–94] 35 [35–36] / 33 [33–34] 4 [4–4] / 4 [4–4]
02.first-turn 1674 [1516–1675] / 1515 [1499–1535] 57 [57–60] / 63 [63–63] 110 [108–110] / 111 [110–111] 2 [2–2] / 2 [2–2]
03.warmed-per-turn 681.95 [678.1–683.4] / 615.35 [612.7–617.2] 11.2 [11.2–11.2] / 10 [9–10.3] 66.1 [65.7–66.2] / 64.05 [63.8–64.1] 0.4 [0.4–0.4] / 0.4 [0.3–0.4]
04.second-session 2713 [2701–2713] / 2631.5 [2615–2667] 106 [100–106] / 100 [97–113] 262 [261–262] / 258.5 [258–260] 3 [3–3] / 3 [3–4]
05.control-plane 18 [18–18] / 18 [18–18] 0 [0–0] / 0 [0–0] 3 [3–3] / 3 [3–3] 0 [0–0] / 0 [0–0]
06.cron 807 [807–809] / 783 [783–783] 26 [26–26] / 26 [26–26] 68 [68–68] / 68 [68–68] 0 [0–0] / 0 [0–0]
07.compaction 273 [271–273] / 260.5 [260–261] 24 [24–24] / 23.5 [23–24] 15 [15–15] / 15 [15–15] 1 [1–1] / 1 [1–1]
08.shutdown 114 [105–118] / 118 [114–124] 63.5 [62–65] / 62 [62–68] 9 [8–9] / 9 [9–10] 4 [4–4] / 4 [4–5]
done 0 [0–0] / 0 [0–0] 0 [0–0] / 0 [0–0] 0 [0–0] / 0 [0–0] 0 [0–0] / 0 [0–0]
total 15588.5 [15531–15607] / 14765 [14759–14772] 2409 [2406–2409] / 2395.5 [2393–2399] 1198 [1192–1198] / 1173 [1172–1174] 30 [30–30] / 30 [30–31]

DB requests and transfer frames

Phase DB requests all threads B1 / B4 DB requests MAIN B1 / B4 Transfer frames all threads B1 / B4 Transfer frames MAIN B1 / B4
01.boot 59 [59–59] / 59 [59–59] 59 [59–59] / 59 [59–59] 0 [0–0] / 0 [0–0] 0 [0–0] / 0 [0–0]
01.connect 51 [51–55] / 50 [50–51] 49 [49–53] / 48 [48–49] 12 [12–12] / 12 [12–12] 0 [0–0] / 0 [0–0]
02.first-turn 272 [267–273] / 276.5 [275–277] 265 [260–266] / 269.5 [268–270] 44 [44–44] / 44 [44–44] 2 [2–2] / 2 [2–2]
03.warmed-per-turn 168.5 [167.6–168.7] / 163.9 [162.7–164.4] 165.5 [164.6–165.7] / 160.9 [159.7–161.4] 18 [18–18] / 18 [18–18] 0 [0–0] / 0 [0–0]
04.second-session 613.5 [612–615] / 618 [614–629] 604.5 [603–606] / 609 [605–620] 55 [55–55] / 55 [55–55] 1 [1–1] / 1 [1–1]
05.control-plane 5 [5–5] / 5 [5–5] 5 [5–5] / 5 [5–5] 0 [0–0] / 0 [0–0] 0 [0–0] / 0 [0–0]
06.cron 160 [160–162] / 160 [160–160] 157 [157–159] / 157 [157–157] 18 [18–18] / 18 [18–18] 0 [0–0] / 0 [0–0]
07.compaction 74 [72–74] / 72 [72–72] 72 [70–72] / 70 [70–70] 14 [14–14] / 14 [14–14] 2 [2–2] / 2 [2–2]
08.shutdown 14 [14–16] / 16 [15–16] 14 [14–16] / 16 [15–16] 0 [0–0] / 0 [0–0] 0 [0–0] / 0 [0–0]
done 0 [0–0] / 0 [0–0] 0 [0–0] / 0 [0–0] 0 [0–0] / 0 [0–0] 0 [0–0] / 0 [0–0]
total 2934 [2924–2937] / 2895.5 [2894–2896] 2881 [2871–2884] / 2842.5 [2841–2843] 323 [323–323] / 323 [323–323] 5 [5–5] / 5 [5–5]

All logical worker requests (including CPU-only work)

Phase Worker requests all threads B1 / B4 Worker requests MAIN B1 / B4 CPU-only requests all threads B1 / B4
01.boot 59 [59–59] / 59 [59–59] 59 [59–59] / 59 [59–59] 0 [0–0] / 0 [0–0]
01.connect 51 [51–55] / 50 [50–51] 49 [49–53] / 48 [48–49] 0 [0–0] / 0 [0–0]
02.first-turn 274 [269–275] / 278.5 [277–279] 267 [262–268] / 271.5 [270–272] 2 [2–2] / 2 [2–2]
03.warmed-per-turn 169.9 [169–170.1] / 165.2 [164–165.8] 166.9 [166–167.1] / 162.2 [161–162.8] 1.4 [1.4–1.4] / 1.3 [1.3–1.4]
04.second-session 620.5 [619–622] / 625 [620–636] 611.5 [610–613] / 616 [611–627] 7 [7–7] / 7 [6–7]
05.control-plane 5 [5–5] / 5 [5–5] 5 [5–5] / 5 [5–5] 0 [0–0] / 0 [0–0]
06.cron 161 [161–163] / 161 [161–161] 158 [158–160] / 158 [158–158] 1 [1–1] / 1 [1–1]
07.compaction 74 [72–74] / 72 [72–72] 72 [70–72] / 70 [70–70] 0 [0–0] / 0 [0–0]
08.shutdown 14 [14–16] / 16 [15–16] 14 [14–16] / 16 [15–16] 0 [0–0] / 0 [0–0]
done 0 [0–0] / 0 [0–0] 0 [0–0] / 0 [0–0] 0 [0–0] / 0 [0–0]
total 2958 [2948–2961] / 2918.5 [2917–2919] 2905 [2895–2908] / 2865.5 [2864–2866] 24 [24–24] / 23 [23–23]

Actor commands

Phase Actor commands all threads B1 / B4 Actor commands MAIN B1 / B4 Actor reads all threads B1 / B4 Actor reads MAIN B1 / B4 Actor writes all threads B1 / B4 Actor writes MAIN B1 / B4
01.boot 0 [0–0] / 0 [0–0] 0 [0–0] / 0 [0–0] 0 [0–0] / 0 [0–0] 0 [0–0] / 0 [0–0] 0 [0–0] / 0 [0–0] 0 [0–0] / 0 [0–0]
01.connect 0 [0–0] / 0 [0–0] 0 [0–0] / 0 [0–0] 0 [0–0] / 0 [0–0] 0 [0–0] / 0 [0–0] 0 [0–0] / 0 [0–0] 0 [0–0] / 0 [0–0]
02.first-turn 0 [0–0] / 4 [4–4] 0 [0–0] / 0 [0–0] 0 [0–0] / 1 [1–1] 0 [0–0] / 0 [0–0] 0 [0–0] / 3 [3–3] 0 [0–0] / 0 [0–0]
03.warmed-per-turn 0 [0–0] / 4 [4–4] 0 [0–0] / 0 [0–0] 0 [0–0] / 1 [1–1] 0 [0–0] / 0 [0–0] 0 [0–0] / 3 [3–3] 0 [0–0] / 0 [0–0]
04.second-session 0 [0–0] / 8 [8–8] 0 [0–0] / 0 [0–0] 0 [0–0] / 2 [2–2] 0 [0–0] / 0 [0–0] 0 [0–0] / 6 [6–6] 0 [0–0] / 0 [0–0]
05.control-plane 0 [0–0] / 0 [0–0] 0 [0–0] / 0 [0–0] 0 [0–0] / 0 [0–0] 0 [0–0] / 0 [0–0] 0 [0–0] / 0 [0–0] 0 [0–0] / 0 [0–0]
06.cron 0 [0–0] / 0 [0–0] 0 [0–0] / 0 [0–0] 0 [0–0] / 0 [0–0] 0 [0–0] / 0 [0–0] 0 [0–0] / 0 [0–0] 0 [0–0] / 0 [0–0]
07.compaction 0 [0–0] / 0 [0–0] 0 [0–0] / 0 [0–0] 0 [0–0] / 0 [0–0] 0 [0–0] / 0 [0–0] 0 [0–0] / 0 [0–0] 0 [0–0] / 0 [0–0]
08.shutdown 0 [0–0] / 0 [0–0] 0 [0–0] / 0 [0–0] 0 [0–0] / 0 [0–0] 0 [0–0] / 0 [0–0] 0 [0–0] / 0 [0–0] 0 [0–0] / 0 [0–0]
done 0 [0–0] / 0 [0–0] 0 [0–0] / 0 [0–0] 0 [0–0] / 0 [0–0] 0 [0–0] / 0 [0–0] 0 [0–0] / 0 [0–0] 0 [0–0] / 0 [0–0]
total 0 [0–0] / 52 [52–52] 0 [0–0] / 0 [0–0] 0 [0–0] / 13 [13–13] 0 [0–0] / 0 [0–0] 0 [0–0] / 39 [39–39] 0 [0–0] / 0 [0–0]

Phase duration

Phase Seconds B1 / B4
01.boot 10.54 [10.52–10.6] / 9.16 [9.15–9.21]
01.connect 1.18 [1.18–1.18] / 1.15 [1.15–1.16]
02.first-turn 6.78 [6.58–6.84] / 6.17 [6.15–6.28]
03.warmed-per-turn 1.8 [1.79–1.81] / 1.71 [1.71–1.72]
04.second-session 7.2 [7.15–7.27] / 7.04 [7.02–7.06]
05.control-plane 1.08 [1.08–1.08] / 1.08 [1.07–1.08]
06.cron 5.47 [5.47–5.47] / 5.41 [5.4–5.41]
07.compaction 1.34 [1.34–1.35] / 1.32 [1.31–1.33]
08.shutdown 0.57 [0.54–0.58] / 0.47 [0.47–0.48]
done 0.01 [0.01–0.02] / 0.01 [0.01–0.01]
total 52.19 [52–52.23] / 48.96 [48.87–49.09]
Phase B4/B1 median duration ratio
01.boot 0.87
01.connect 0.98
02.first-turn 0.91
03.warmed-per-turn 0.95
04.second-session 0.98
05.control-plane 0.99
06.cron 0.99
07.compaction 0.98
08.shutdown 0.82
done 0.9
total 0.94

Explicit commits count observed native COMMIT/END statements, including read transactions; they do not infer autocommit transactions from statement totals. Actor command entry events, logical DB requests, and transfer frames remain distinct counters.

Attribution

The fixed warmed foreground replacement is 41 fewer statements and zero net
requests
: four generic patch requests disappear, replaced by one actor read,
one completion and two settlements. Shared no-op/postimage reuse removes another
two statements from lifecycle projection. The remaining 23.6 observed statements
and 4.6 DB requests per turn are workload/timing effects, not a claim that B4
deleted that many fixed calls. Per-family medians need not sum to a median total.

Warmed operation B1 / B4 requests per turn B1 / B4 statements per turn
Generic entry patch commits 11 / 7 133 / 78
Actor read 0 / 1 0 / 1
Actor completeTurn 0 / 1 0 / 6
Actor deliverySettled 0 / 2 0 / 7
Lifecycle projection 1 / 1 25 / 23

Combined-window and whole-run check

Window B1 statements per run B4 statements per run B1 / B4 median [min–max] B1 / B4 DB requests median [min–max]
boot+connect 3174, 3317, 3174, 3174 3301, 3267, 3296, 3262 3174 [3174–3317] / 3281.5 [3262–3301] 110 [110–114] / 109 [109–110]
boot+connect+first 4849, 4833, 4848, 4848 4801, 4797, 4795, 4797 4848 [4833–4849] / 4797 [4795–4801] 382 [381–383] / 385.5 [385–386]
whole run 15588, 15531, 15589, 15607 14772, 14759, 14769, 14761 15588.5 [15531–15607] / 14765 [14759–14772] 2934 [2924–2937] / 2895.5 [2894–2896]

Fixed warmed SQL families (generic patches, actor phases and lifecycle projection)

SQL family B1 / B4 statements per turn Delta
BEGIN 14 / 13 -1
COMMIT 14 / 13 -1
canonical-key reads 11 / 7 -4
entry upserts 12 / 11 -1
entry/postimage reads 30 / 22 -8
local generation reads 12 / 8 -4
other 2 / 2 0
participant reads 21 / 11 -10
snapshot writes 4 / 2 -2
transcript watermark reads 14 / 10 -4
window authority/postimage reads 12 / 8 -4
window upserts 12 / 8 -4
Per-operation attribution, DB requests and native statements

Unchanged operations are omitted. Fixed savings are the actor/patch/lifecycle rows above; the other rows are observed scheduling, background, or first-use attribution.

Warmed per turn

Operation Requests B1 / B4 Statements B1 / B4
session.entry.patch.commit 11 / 7 133 / 78
database.domain.execute 6.8 / 5.65 28.2 / 23.15
database.domain.bind 5.2 / 4.45 21.7 / 17.1
session-corpus-inventory 0.8 / 0.75 5.25 / 1.1
database.prepareWrite 0.1 / 0 3.2 / 0
session.lifecycle.project 1 / 1 25 / 23
pluginState.compareDelete 1.6 / 1.2 7.2 / 5.4
pluginState.compareUpdate 0.8 / 0.6 5.6 / 4.2
pluginState.observe 0.8 / 0.6 3.2 / 2.4
database.domain.close 5.2 / 4.45 3.2 / 2.45
session-exact-entries 8.5 / 8.1 22.5 / 22.1
session.entry.read 4.3 / 3.9 16.3 / 15.9
session-entry 0.4 / 0.35 2 / 1.75
session-tombstones 0.8 / 0.75 3.2 / 3
deliveryQueue.outbound 0.4 / 0.3 0.8 / 0.6
session-target-inventory 8 / 8 8.1 / 8
session-entry-read 2.95 / 3 2.95 / 3
acpSessions.metadata 2 / 2 0.2 / 0.3
sessionRows.sharedFacts 6.4 / 6.35 4.05 / 4.35
session.actor.read 0 / 1 0 / 1
session.actor.completeTurn 0 / 1 0 / 6
session.actor.deliverySettled 0 / 2 0 / 7

First turn

Operation Requests B1 / B4 Statements B1 / B4
database.domain.execute 11 / 10 219 / 89
session.entry.patch.commit 14 / 10 168 / 127
session-corpus-inventory 2 / 2 49 / 27
session.maintenance.read 3 / 3 32 / 16
session-tombstones 2 / 2 20 / 8
session-target-inventory 12 / 12 23 / 14
database.domain.bind 9 / 8 45 / 39
model-context 2 / 2 22 / 16
session-entry 2 / 2 19 / 13
transcript-stats 1 / 1 10 / 4
session.entries.replace 1 / 1 41 / 42
restartSentinel.admit 0 / 1 0 / 1
session.actor.read 0 / 1 0 / 1
sessionState.pendingNotices 0 / 1 0 / 1
session-exact-entries 14 / 15 48 / 51
restartSentinel.snapshot 0 / 1 0 / 4
session.actor.completeTurn 0 / 1 0 / 6
session.actor.deliverySettled 0 / 2 0 / 7
lifecycle-artifact-plan 0 / 1 0 / 8
sessionState.prune 0 / 1 0 / 8
history-page 2 / 2 20 / 36
database.prepareWrite 1 / 2 33 / 64.5

Whole run

Operation Requests B1 / B4 Statements B1 / B4
session.entry.patch.commit 168 / 116 2009 / 1280.5
session-corpus-inventory 13 / 13 116.5 / 53
database.domain.execute 121 / 111 662 / 619
database.domain.bind 91 / 85 416 / 379
session.lifecycle.project 13 / 13 320 / 298
pluginState.compareDelete 34 / 30 153 / 135
session.maintenance.read 20 / 20 104 / 88
pluginState.compareUpdate 17 / 15 119 / 105
session-tombstones 13 / 13 64 / 52
session.entries.replace 6 / 6 115 / 103
session-entry 10 / 9 59 / 48
session-target-inventory 132 / 132 140 / 130
catalog 1 / 1 14 / 5
lifecycle-artifact-plan 1 / 1 17 / 8
pluginState.observe 17 / 15 68 / 60
database.domain.close 91 / 85 63 / 57
model-context 18 / 18 127 / 121
transcript-stats 1 / 1 10 / 4
session-row-facts 89 / 88 436 / 431
session.entry.read 60.5 / 56.5 220.5 / 216.5
agentDatabaseRegistry.read 1 / 1 6 / 2
pluginState.entries 9 / 7 9 / 7
deliveryQueue.outbound 9 / 8 18 / 16
workers.placementProjection 98 / 97 97 / 96
session-exact-entries 147 / 145 402 / 401.5
database.prepareWrite 2 / 2 65 / 64.5
closeResource 355 / 356 0 / 0
acpSessions.metadata 27 / 27 3 / 4.5
session-entry-read 42.5 / 45 42.5 / 45
sessionRows.sharedFacts 97.5 / 95 63 / 66
audit.writer.prune 8 / 9 46 / 50
session.actor.read 0 / 13 0 / 13
history-page 19 / 19 180 / 196
prewarm 1 / 3 0 / 18
session.actor.completeTurn 0 / 13 0 / 78
session.actor.deliverySettled 0 / 26 0 / 91

The connect increase is deferred work: memory initialization's
database.domain.execute moves 130 statements / one request from first-turn
to connect, with the same SQL fingerprints; its accompanying bind also moves.
The unchanged startup scheduler additionally completes two transcript prewarms
(18 statements). Schema/admission SQL already present in baseline reader opens
shifts between first-use owners; history-page has +16 statements while inventory,
maintenance and other reader-open families fall. No per-call schema check was
added. Boot+connect+first is lower in every pair and by median (4,848 → 4,797).

First-turn DB requests rise 272 → 276.5. Five restart/lifecycle startup
requests move from connect into that window, and an existing prepare-write
request moves from warmed turn one into first-turn (whole-run count stays 2).
The extra whole-run pair required by RAW TURN INCREASE was completed: whole-run
statements 15,588.5 → 14,765, DB requests 2,934 → 2,895.5, total worker
requests 2,958 → 2,918.5. The operation table shows the affected families;
these are redistribution/background differences, not a new foreground loop.
Shutdown's +4 statements are the unchanged audit pruner (+1 call), within the
10-statement non-turn tolerance. Other non-turn phases do not increase.

The folded patch-fusion maintenance concern is specifically checked:
session.maintenance.read remains 20 / 20 requests per whole run
(104 / 88 statements), with no new scheduler trigger and no early intent clear.
All gated duration ratios are below 1.5. Historical patch-fusion results are
not used as B4 proof.

Evidence

The first real Gateway comparison exposed a B4 integration defect before any
savings were claimed: the model completed, but terminal accounting compared the
pre-run entry's writer with the writer claimed by execution. The repair carries
the existing native settlement's exact writer through the execution result,
including zero-compaction turns, into ordinary and queued completion. It adds
no reads, requests or handshake. A real-finalizer regression failed with
Terminal accounting session changed before repair and passed afterward
(3.77 s test time; 47.83 s Vitest, 148.49 s wrapper including worker compilation).
The failed run is not included in the measurement comparison.

On c2d7162cb57f3, core production types, touched-file lint, the
native-incognito suite (6/6; 15.52 s Vitest / 51.50 s wrapper), and T1 no-growth
against pinned B1 passed. Native completion retains the original memory
database, with no replacement worker owner or disk database. The broader
current-head owner selection then passed 80 tests across 13 files / five shards
(166.16 s wrapper) at c7198b99c8f2e. The preceding infra shard passed 124 tests
but found an obsolete two-command delivery assertion; the only intervening edit
updates that test to require one command and zero preparatory reads, preserving
all persisted-custody and replacement assertions. The corrected file passed.

Reusable prior-head behavioral evidence: 320 reply/Gateway tests, including
227 real reply-runner cases and public non-main session creation durability
(448.26 s wrapper); 151 dispatch/settlement tests (142.20 s Vitest / 155.72 s
wrapper); and all 24 restart-recovery tests (133.75 s Vitest / 151.16 s wrapper).
The restart regression requires exactly one deliveryPending command and no
preparatory read. Later changes in that owner only add lint-required braces.
Maintenance fixtures now publish lifecycle changes through their owning writer
and clear mock calls in cleanup; all three corrected cases passed on Linux
(36.98 s Vitest / 38.67 s wrapper). No foreign-commit polling was restored.

Canonical check:changed work was continued past individually recorded inherited
failures. It passed assertion safety, T1 no-growth, timeout/mock-export ratchets,
formatting, boundaries, dependency guards, all 27 core test-type graphs
(925.821 s at 223bc7a99fe3b), coercion/deprecated-API checks, script lint,
schema-version/storage/media/sidecar guards, webhook ordering and pairing guards.
Madge reports zero runtime import cycles. B4-owned type/lint/dead-export findings
were repaired without widening budgets or suppressing diagnostics. Final B1
integration only changed pure-reader reuse, unused callback removal, fixture
types and the relocated assertion baseline; production types and touched lint
were rerun on the final head.

Inherited checks, independently verified against main or B1's unchanged parent
files, remain recorded rather than described as passing:

  • Environment-name budget: 456/455, reproduced on main 696e8256e55f6.
  • UI type-root advisory: 722/720; same inventory/checker/config on main
    c4e70bc82a5f7. Actual UI type graphs passed.
  • Dead exports: Solid lint's default export, POST_ACTIVATION_INSPECTIONS_STEP,
    and two session-channel fixture stubs. B1 reproduced them independently;
    its obsolete pending-write export was removed before the final comparison.
  • Full Knip worker/UI/dependency findings reproduce on B1's parent 1d4f42e8f385
    with identical diagnostics and no B4-touched files.
  • Core lint's unused MockConfig in agents-mutate.test.ts is untouched here
    and appears in B1's independent core-lint result.

Final SQL/focused source pin: ae04df5e0d58; final pushed branch:
e3333d2f34379522f21be939ce6b1cc30beb12ab, stacked on
6e8a0034934cc2c914562f7bade42cf1d2c49a3e. The only later source delta is B1's
five-file replica simplification (23 additions / 64 deletions), merged without
conflicts. It removes duplicate in-memory validation and changes no SQL or
phase command; the paired measurements remain explicitly pinned to cc65/ae04.

On AWS Crabbox cbx_8eaa757bd06b, run
run_1016330a292060fc7cbeccac4021f7e4:

Check Result
Six focused files via node scripts/run-vitest.mjs … --maxWorkers=1 333 tests passed, including 227 real reply-runner E2E cases; 682.64 s wrapper (includes managed build)
pnpm check:madge-import-cycles Passed, zero runtime cycles; 18.45 s
pnpm check:database-worker-ratchet --base cc65… Passed, no T1 growth; 2.98 s
pnpm tsgo:core Passed; 16.82 s
pnpm plugin-sdk:api:diff --base cc65… --head ae04… Passed; 303.21 s; zero entrypoint/direct declaration changes, 148 reachable closures, digest dd27e91c
check:changed for the nine runtime-writer fix files Stops at the independently reproduced inherited environment budget 456/455; no blanket green claim
Changed test-type selector Stops before compilation at inherited UI roots 722/720; affected canonical graphs separately compiled below
pnpm deadcode:full Reproduces the recorded unrelated worker/UI/dependency/unused-export diagnostics; 60.32 s

The repeated inherited failures are not hidden or repaired outside this lane.
All 27 graphs and remaining changed-check stages had already run as described
above. Post-merge verification additionally passes the canonical messaging and
agents-sessions graphs (15.25 s / 15.07 s) and production types (16.52 s), plus
the replica/completion selection (58.74 s wrapper). The inherited UI inventory
guard remains failed; no guard/budget or fixture expectation is weakened.

Final integrated checks ran against e3333d2f3437 in
run_a8353feadca8a7b029629d189fbc0e24.
The parent-file typed lint passed (zero warnings/errors, 110.84 s including
SDK declaration preparation). Final SDK diff against B1 6e8a0034934c also
passed in 301.17 s; its public entrypoints and direct declarations remain
unchanged (148 reachable closures, digest dd27e91c).

Final nine-file typed lint and formatting passed in
run_fbd053946ee6e764fdbf4bcbbe1ca666:
zero warnings/errors, 9.9 s lint, 28.62 s remote command including preparation.

One final-head local E2E attempt stopped before test execution because the
managed-artifact fence could not prove separation. No guard was bypassed and no
managed Gateway was changed; the subsequent 227-case remote E2E pass supplies
that evidence.

Three Codex P2 review rounds completed under campaign convergence. The final
finding (newer auth selection consumed during refresh) was fixed by capturing
the concrete reducer at accounting; real-finalizer regression cases cover
auth-profile and source-only changes. No fourth review round.

Published-driver × candidate update cell: pending (lander).

Size and follow-ups

Chosen compromises

No B4-specific fencing token, generation ledger, recovery journal, or settlement
handshake is added. Completion uses B1's existing actor contract and the existing
delivery intent/payload identity. A proven version refusal retries once from its
returned postimage without an extra preparatory read. An unknown
commit is not blindly retried because this actor contract does not promise
idempotent phase replay; B4 does not add a second reconciliation mechanism.

Usage-only persistence remains best effort with a diagnostic on a proven failure.
Group-intro and fallback-notice bookkeeping keeps arrival-order semantics: a
later terminal update can replace an intervening internal metadata choice. No
per-field versioning is added for that recoverable edge. Model/auth selection
retains its existing targeted guard because changing the selected credentials or
model can affect paid work. Session/intent/payload checks prevent a reset or
delivery retry from attributing data or sending a reply to the wrong operation.
Maintenance reuses the settled completion rather than adding a scheduler trigger.

Against pinned B1 cc65e9aacc50b: production/tooling +1,999/−1,054 (net +945);
tests/support +2,111/−1,005 (net +1,106). Guard baselines count as production/tooling.
Growth is the full terminal cutover, additive phase
contracts, receipt/authority handling, shared postimage reuse and regression
coverage; obsolete writers and duplicated old tests are removed.

Structural extractions keep the query cache, snapshot readers and queued activity
operation with narrow leaf owners. The native-runtime ownership check only retries
a publication that preceded its synchronous hook; it never retries an ownership
change made inside that hook. Otherwise suppressed no-op writes could let a second
hook invocation adopt changed authority. The existing five-field hook regression
protects that boundary.

Remote capacity: a prior Testbox waited 15 minutes without a runner and was
stopped; the authorized AWS fallback reused one task-owned lease and one remote
slot. The lease is now stopped; its campaign slot is released. Raw/duplicate
measurement downloads and automatic evidence archives were removed from active
proof storage; compact summaries and cited logs remain for the lander.
Other earlier capacity waits are recorded in the lane notes. No local
Docker was used. This is a READY stacked PR against dbasync/actorb1;
retarget as the parent lands. Do not merge this lane as part of publication.

Integration corrections: entry-only callers retain fallback/group bookkeeping
through the shared pure reducers (no second durable writer). Native-memory
acquisition permits canonical keys in an explicitly selected incognito store;
the exact path, original owner/incarnation, and canonical agent-key checks stay
in place. Durable integration assertions now consume the published postimage,
not a superseded object alias. The usage suite uses the existing broker-capable
test shard; its earlier hostless-thread failures were fixed, not suppressed.

The maintenance fixture repair does not restore foreign-commit polling. It keeps
the lifecycle and logical-source admission checks meaningful under SINGLE OWNER:
the changed lifecycle is published by the same native writer as production.
Regression owners: agent-runner-result-accounting.persistence.test.ts covers
the real finalizer and no-send completion, successor model/auth selection, and
committed failures; session-accessor.sqlite-entry-writes.test.ts covers no-op
entry/window/snapshot suppression; model-setup.ownership.test.ts preserves
authority when a native hook changes any of the five ownership fields;
restart-recovery-receipt.test.ts and delivery-completion.test.ts cover exact
custody, wrong-source/tool refusal, post-preparation revocation and confirmation.

…odules

Merge current main while preserving shared physical admission, cancellation, reader validation birthtime, and live deletion authority. Split worker usage, pool construction, failure settlement, and schema owner types to keep the existing line caps.
Checkpoint the single-owner cutover, cache invalidation regressions, and request-owned read transactions. Keep explicit migration verification. Paired measurement and final validation are still in progress.
Route retained existing-state writer coverage through the host-owned worker project, preserve first-admission incompatibility refusal, and match the final deletion-authority contract. Keep the gateway test under its inherited line count by moving existing pure fixture helpers. Regenerate assertion allowances without adding production assertions.
Include the thirteen transitive admission modules required by the native wrapper import-closure proof. Carry the existing birthtime through the worker validation fixture to preserve its physical-file identity.
Merge current main and preserve its optional settlement-only receipt delivery through the extracted owner. Keep the worker refusal error with the leaf contract to stay within the existing admission line cap. End the marker-free read-only fixture transaction normally; dedicated rollback and explicit revocation coverage remains unchanged.
Preserve snapshot-local reuse without freshness queries, publish dedicated archive writes, and remove Workboard polling. Retain native authority and settlement boundaries. Checkpoint reviewed corrections and focused regression repairs; final integrated proof remains in progress.
Define inactive typed durable phases, versioned hot snapshots, complete commit receipts, pure bookkeeping reducers, and unknown-outcome fencing. Share lifetime and settlement vocabulary with the existing incognito actor without changing routing or persistence.
@clawsweeper clawsweeper Bot added merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Oct 11, 2026
Keep native-incognito delivery and restart receipts on their existing entry owner, and send only cloneable claim fields to the durable actor. Repair completion typing and fixture ownership exposed by CI.
@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. label Oct 11, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. and removed merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Oct 11, 2026
Preserve native incognito state-root identity and register dispatch mocks before consuming modules. Keep queue disposition bookkeeping in the existing reply operation state owner.
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Oct 11, 2026
@steipete
steipete merged commit 38ced6e into main Oct 11, 2026
176 of 181 checks passed
@steipete
steipete deleted the dbasync/actorb4 branch October 11, 2026 07:18
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 12, 2026
* perf(sqlite): checkpoint shared admission across workers (WIP)

* test(sqlite): align worker fixtures with shared admission

* perf(sqlite): avoid repeated quarantine reads in retained scopes

* docs(sqlite): define single-owner database freshness

* perf(sqlite): replace runtime probes with writer publications

Checkpoint the single-owner cutover, cache invalidation regressions, and request-owned read transactions. Keep explicit migration verification. Paired measurement and final validation are still in progress.

* test(sqlite): align first-admission coverage and deletion fixtures

Route retained existing-state writer coverage through the host-owned worker project, preserve first-admission incompatibility refusal, and match the final deletion-authority contract. Keep the gateway test under its inherited line count by moving existing pure fixture helpers. Regenerate assertion allowances without adding production assertions.

* build(sqlite): include shared admission in compiled wrappers

Include the thirteen transitive admission modules required by the native wrapper import-closure proof. Carry the existing birthtime through the worker validation fixture to preserve its physical-file identity.

* test(sqlite): use the canonical settlement owner in publication proof

* fix(sqlite): complete writer custody and snapshot cache lifetimes

Preserve snapshot-local reuse without freshness queries, publish dedicated archive writes, and remove Workboard polling. Retain native authority and settlement boundaries. Checkpoint reviewed corrections and focused regression repairs; final integrated proof remains in progress.

* fix(sqlite): retain integrity and worker admission through cleanup

* test(sqlite): preserve reader coverage in existing fixture owners

* fix(sqlite): preserve cache receipts across sibling writers and temp DDL

* fix(workboard): type the replacement card-list promise

* fix(sessions): integrate receipt-based list revision reads

* perf(sessions): reuse committed entry facts across ordered reads

* refactor(sessions): identify fused query as worker-only

* fix(sessions): preserve receipt facts across read phases

* docs(sessions): clarify retained listing and alias guards

* refactor(sessions): define shared session actor contract

Define inactive typed durable phases, versioned hot snapshots, complete commit receipts, pure bookkeeping reducers, and unknown-outcome fencing. Share lifetime and settlement vocabulary with the existing incognito actor without changing routing or persistence.

* refactor(sessions): update actor cutover contract

* refactor(sessions): prepare usage facts for actor completion

* refactor(sessions): add inactive phase actor backend

* fix(sessions): preserve actor projection readiness and held facts

* refactor(sessions): share terminal receipt reducers

* perf(sessions): reuse retained transcript initialization facts

* test(sessions): split admitted cohort lifecycle coverage

* test(sessions): service actor fixture admission synchronously

* perf(sessions): fuse terminal accounting and delivery custody in actor

* test: capture native incognito completion regression

Keep the B4 cutover blocked until actor acquisition can preserve the existing native in-memory owner. The regression expects normal usage completion with no second memory owner or durable fallback; it is not an expected-failure allowance.

* refactor(sessions): use shared string validation for entry facts

* feat(sessions): contract update 2 for existing incognito owners

* fix(sessions): preserve query builder method binding

* fix(sessions): acquire existing native incognito completion owner

* fix(sessions): separate actor admission from accepted settlement

* fix(sessions): reacquire incognito projection claims after actor commits

* test(sessions): distinguish model metadata from context messages

* refactor(sessions): separate actor contracts and share mutation executors

* docs(sessions): explain actor assertion invariants

* fix(sessions): reject ownership changes inside native hooks

* fix(sessions): use internal completion authority and fresh test versions

* refactor(sessions): share native transcript presence query

* test(sessions): run usage accounting with host admission

* fix(sessions): preserve transient completion and native store keys

* chore(sessions): document closed projection assertions

* test(sessions): explain actor eviction mock isolation

* test(sessions): publish maintenance lifecycle fixture mutations

* chore(sessions): place snapshot safety invariant at assertion

* refactor(sessions): make snapshot projection assertion explicit

* test(sessions): align actor fixtures with typed owner contracts

* test(sessions): use real live-model reducer preparation

* fix(sessions): preserve actor callback bindings and audit inactive APIs

* test(sessions): retire removed mock exceptions

* fix(sessions): keep host config out of worker transport bundles

* feat(sessions): contract update 3 for scoped receipts and command preimages

* fix(sessions): reject mutations during actor authority admission

* test(reply): project compound session patch fixtures

* fix(sessions): retain actor state across unrelated pending writes

* fix(sessions): pass a record to canonical postimage projection

* fix(sessions): preserve incognito transaction settlement contract

* test(reply): retain record-shaped fixture projections

* test(sessions): keep scoped receipt fixtures within storage contracts

* test(sessions): use the extracted history owner in reset proof

* refactor(sessions): separate receipt and transcript helper responsibilities

* fix(sessions): use scoped entry receipt for the adopted window

* test(sessions): type native receipt fixtures against storage contracts

* fix(sessions): complete integrated actor reader references

* test(sessions): follow extracted entry presence reader

* refactor(sessions): keep patch step reducer private

* fix(sessions): finish actor validation cleanup

* refactor(sessions): satisfy completion owner lint contracts

* chore(sessions): shrink moved assertion baseline

* test(sessions): assert command-local delivery admission

* fix(sessions): complete against the settled runtime writer

* refactor(sessions): simplify actor replica validation

* fix(sessions): preserve native completion ownership after actor cutover

Keep native-incognito delivery and restart receipts on their existing entry owner, and send only cloneable claim fields to the durable actor. Repair completion typing and fixture ownership exposed by CI.

* fix(sessions): reuse native delivery settlement owner

* test(sessions): run delivery actor fixtures with host broker

* fix(sessions): align incognito and dispatch fixtures

Preserve native incognito state-root identity and register dispatch mocks before consuming modules. Keep queue disposition bookkeeping in the existing reply operation state owner.

* fix(reply): keep queue disposition types acyclic
steipete added a commit that referenced this pull request Oct 14, 2026
Share completion projection and settlement, reuse existing command gates and
session-source preparation, and remove duplicate response/receipt mirrors.
Keep private-source authority, approvals, FIFO, transcript durability, bounded
retry behavior, and write-capable shutdown settlement at their existing owners.

Best-effort tradeoffs accepted:
- Idle source/config changes may retain unused capacity until expiry; allocation
  and private-source transfer still authorize use (#143372, #143410).
- Mid-read model configuration and native availability may keep prepared display
  facts for that read; catalog/account authority remains (#169253).
- Cosmetic health topology and clock rollback use normal refresh or an explicit
  probe; live lifecycle mismatch checks remain (#128222, #128503).
- Bootstrap enrollment overlapping shutdown/reload may fail and retry rather than
  reject every post-await close interleaving (#133037).
- Late internal completion reducers are not persisted; completion stays idempotent
  and final-intent receipt validation remains (#168592).
- An in-flight plugin UI catalog may finish against its selected registry;
  HTTP asset disclosure still checks current authority (#134943, #169449).

These removed guards have speculative/synthetic provenance, not cited human
actual-use incidents. Keep the human-reported memory-flush retry bound (#85645).
The Phase E standalone session memory backend and its tests are untouched.
steipete added a commit that referenced this pull request Oct 14, 2026
* refactor(gateway): consolidate reply and worker preparation paths

Share completion projection and settlement, reuse existing command gates and
session-source preparation, and remove duplicate response/receipt mirrors.
Keep private-source authority, approvals, FIFO, transcript durability, bounded
retry behavior, and write-capable shutdown settlement at their existing owners.

Best-effort tradeoffs accepted:
- Idle source/config changes may retain unused capacity until expiry; allocation
  and private-source transfer still authorize use (#143372, #143410).
- Mid-read model configuration and native availability may keep prepared display
  facts for that read; catalog/account authority remains (#169253).
- Cosmetic health topology and clock rollback use normal refresh or an explicit
  probe; live lifecycle mismatch checks remain (#128222, #128503).
- Bootstrap enrollment overlapping shutdown/reload may fail and retry rather than
  reject every post-await close interleaving (#133037).
- Late internal completion reducers are not persisted; completion stays idempotent
  and final-intent receipt validation remains (#168592).
- An in-flight plugin UI catalog may finish against its selected registry;
  HTTP asset disclosure still checks current authority (#134943, #169449).

These removed guards have speculative/synthetic provenance, not cited human
actual-use incidents. Keep the human-reported memory-flush retry bound (#85645).
The Phase E standalone session memory backend and its tests are untouched.

* refactor(gateway): consolidate dispatch and trusted result projections

* refactor(workers): trust admitted preparation facts
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 15, 2026
…2342)

* refactor(gateway): consolidate reply and worker preparation paths

Share completion projection and settlement, reuse existing command gates and
session-source preparation, and remove duplicate response/receipt mirrors.
Keep private-source authority, approvals, FIFO, transcript durability, bounded
retry behavior, and write-capable shutdown settlement at their existing owners.

Best-effort tradeoffs accepted:
- Idle source/config changes may retain unused capacity until expiry; allocation
  and private-source transfer still authorize use (openclaw#143372, openclaw#143410).
- Mid-read model configuration and native availability may keep prepared display
  facts for that read; catalog/account authority remains (openclaw#169253).
- Cosmetic health topology and clock rollback use normal refresh or an explicit
  probe; live lifecycle mismatch checks remain (openclaw#128222, openclaw#128503).
- Bootstrap enrollment overlapping shutdown/reload may fail and retry rather than
  reject every post-await close interleaving (openclaw#133037).
- Late internal completion reducers are not persisted; completion stays idempotent
  and final-intent receipt validation remains (openclaw#168592).
- An in-flight plugin UI catalog may finish against its selected registry;
  HTTP asset disclosure still checks current authority (openclaw#134943, openclaw#169449).

These removed guards have speculative/synthetic provenance, not cited human
actual-use incidents. Keep the human-reported memory-flush retry bound (openclaw#85645).
The Phase E standalone session memory backend and its tests are untouched.

* refactor(gateway): consolidate dispatch and trusted result projections

* refactor(workers): trust admitted preparation facts
scribe-dandelion-cult added a commit to karmaterminal/openclaw that referenced this pull request Oct 16, 2026
Absorbs fp#1318-1442 (125 first-parent commits), ending just before
openclaw#168592 (fp#1443), which starts the next conflict cluster.

Conflicts (2, generated/budget only):
- plugin-sdk-surface-report: upstream re-based its own budgets (3661
  exports / 2127 callable) on the async inspection/authorization
  replacements; ours stays upstream + the continuation contracts
  (+11 / +4). Measured on the merged tree: 3672 / 2131.
- worker-access-inventory.md: regenerated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Jhynq2GVpzuVQQieebEubg
scribe-dandelion-cult added a commit to karmaterminal/openclaw that referenced this pull request Oct 16, 2026
…step 30)

openclaw#168592 wraps terminal turn accounting in one retained session-actor
completion owner (withAgentTurnCompletion): usage, group-intro,
fallback-notice and live-model bookkeeping are staged as reducers and
commit with pending-final custody through completion.complete().

Continuation reconciliation:
- Arm continuation only after the terminal completion commits.
  accountFollowupTurn now returns scheduleContinuation, which
  followup-runner calls after turnCompletion.complete();
  completeReplyAgentRun settles the completion before
  scheduleReplyContinuation on every return path (silent continuation,
  signal-only, and final). A wake is never visible for a turn whose
  bookkeeping or final custody failed to settle. New followup-runner
  tests pin the order and the failed-settle case (both red with the
  order reversed).
- After the continuation chain reset, re-read through the completion
  owner instead of the caller's pre-turn entry, which discarded the
  owner's projection (upstream fallback-notice tests caught it).
- Recipient-authority advance on visibility narrowing runs before the
  committed revision is read, so upstream's no-op-write fast path never
  mistakes an advance for a no-op.
- Owner path reads the exact-row cache from upstream's new
  session-accessor.sqlite-entry-query module; sqlite-entry-read is now
  byte-identical to upstream.
- Test fixtures: continuation work-span tests seed the real session row
  the completion actor commits to; followup-runner accounting mocks carry
  scheduleContinuation; reduceSessionEntryPatch mocks follow upstream's
  move to projectSessionEntryPatch; persist-usage provenance tests follow
  upstream's removal.

Premaps: 🕯 Emeric (source map) and 🌊 Ronan (ordering risk).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Jhynq2GVpzuVQQieebEubg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling commands Command implementations gateway Gateway runtime merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant