Skip to content

improve: avoid unnecessary transcript compression projections - #188655

Merged
steipete merged 2 commits into
mainfrom
dbasync/regress51
Oct 30, 2026
Merged

steipete merged 2 commits into
mainfrom
dbasync/regress51

Conversation

@steipete

@steipete steipete commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Transcript appends and persisted model-selection rewrites perform a native metadata SELECT even when the compressed frame and required metadata cannot meet the existing storage savings threshold. This removes avoidable preparation introduced with #185730 and #184702, plus the same redundant work for assistant payloads.

User Impact

Transcript and provider bytes, submitted model selection, restart delivery, and storage format stay unchanged. Payloads that already end in identity storage skip a metadata SELECT. No migration or configuration change is required.

Why This Change Was Made

Reject impossible-fit compression candidates before the SELECT using the already-prepared report and a conservative envelope lower bound. The envelope shape is shared with the native encoder, so its minimum is derived rather than hardcoded. Canonical entries retain type/id and any serialized parentId in all three native projections. Candidates that might fit still use those projections and the original final byte check.

No cache, generation, schema, transaction, admission, writer-claim, recovery, or security-effect check changes. PostgreSQL's existing early identity return is unchanged. The independent #186046 request remains a required floor: it computes the first off-thread fingerprint of newly sealed assistant output, then reuses it on later observations.

Production delta: +44 lines; test delta: 0. The shared envelope and lower-bound calculation are the necessary growth. A CI correction makes the three calculated minima a readonly tuple; it does not alter their values or runtime behavior.

Evidence

Acceptance rule (published before candidate measurement)

Use frozen v3.1.5 on the exact parent and candidate on the same Mac: 14 synthetic real-WebSocket Gateway turns, child/cron/compaction, idle, shutdown and restart. Count-only pair, one sample per head. Warm turns must remove the attributed initial and rewritten-payload SELECTs, preserve worker requests and active MAIN=0, and all flows must pass. Report phase and per-operation counts; cold and warm stay separate. The 48 synthetic stored/reconstructed variants must have byte-identical final outputs while redundant metadata SELECTs disappear. No latency or CPU-speed claim from the loaded host; per-thread profiles are attribution evidence only.

Observed counts

Frozen v3.1.5 (37/37 hashes verified), exact parent 7d9677ce36db versus measured candidate d3c3d5bea831. Command: python3 <frozen-v3.1.5>/measure.py --repo <lane> --sha <head> --repetitions 1 --scratch-root <isolated-internal-temp> --idle-seconds 60. Final head changes only the type-safe construction of the same minima; the repeated byte-equivalence and owner tests pass. No second full pair was run for that equivalent correction.

Count Parent Candidate
Ordinary warm turn SQL / requests / MAIN 48 / 13 / 0 45 / 13 / 0
Ten warm causal phases: SQL median; p95 [min–max] 48; 54 [48–54] 45; 48 [45–48]
Ten warm causal phases: requests median; p95 [min–max] 13; 15 [13–15] 13; 14 [13–14]
Ten warm causal phases: MAIN median; p95 [min–max] 0; 0 [0–0] 0; 0 [0–0]
Whole workload SQL / requests / MAIN 2,883 / 778 / 98 2,872 / 778 / 98
Cold boot SQL / requests / MAIN 320 / 97 / 51 317 / 97 / 51
Connected idle (60 seconds) SQL / requests / MAIN 92 / 29 / 0 92 / 29 / 0

Ten warm phases are observations inside one workload per head, not independent timing samples. Each ordinary warm turn removes three SELECTs: initial payload 12→11 SQL, model-selection rewrite 11→10, assistant payload 10→9. Requests stay 1 / 1 / 1 for those operations. Across ten warm phases, payload preparation is 220→200 SQL / 20→20 requests; rewrite preparation is 110→100 / 10→10. Across the full workload these owners save 41 statements (payload 428→400; rewrite 175→162), with unchanged 44 and 16 requests and zero MAIN SQL. The frozen mapper calls the candidate payload operation batch instead of prepareTranscriptPayload because the removed query changes its observed stack; counts above group the same captured source owner, not the label.

Cold/background counts are disclosed separately: restart-connect rises 42→71 SQL because unchanged installStatusTracking contributes 30 statements there; first-turn rises 429→430, idle-settle 98→99, restart-boot 313→314, and restart-first-turn 138→139. These are scheduling/background attribution differences outside the changed owner. Full phase/operation evidence confirms no added SQL or requests from the changed owners. Active MAIN remains zero, and all 14 turns, child/cron/compaction, shutdown and restart pass. This is operation-count evidence; latency, memory and CPU speed are unmeasured. Per-thread profiles were captured (200 parent, 226 candidate profiles) for attribution only.

The 48 synthetic variants produce byte-identical final outputs; native SELECTs fall 48→6 (12 initial, 13 rewritten, 17 assistant cases skipped). The final tuple correction repeats the same result. The work-count regression is red on the exact parent and green on the candidate. All 13 payload boundary tests and 14 prompt-prefix stability tests pass; existing UTF-8 readback, malformed/duplicate-key, predicate rollback, and read-only coverage remains.

Two full isolated Codex P0–P2 reviews are scoped-clean. One allowed delta-only review of the CI TS18048 correction is also scoped-clean. Local changed-file typed lint, formatting, source guards, Madge (0 cycles), worker/T1 (168→168), and dialect ratchets (design 9→8; mechanical 1→1) pass. Local type checks hit the documented internal-store declaration-custody restriction; exact-head CI owns that verdict. Three unchanged production Knip findings match scheduled-main run 41107007551, job 124239589390: recordNodeWorkerDescendantsReaped, recordNodeWorkerLineageSettled, and prepareAgentDatabaseStartupIntegrity; full-tree scan has zero findings. No new Knip finding.

The initial CI run caught TS18048 in the new minimum array and was corrected before landing. Final-head validation runs in CI 41119337522; all three PostgreSQL shards must complete successfully before merge. PostgreSQL source approval covers final head d0c9b036a82ab3b94c704027ef928d75cd89fda6. No SDK, update, migration, service lifecycle, or plugin-loading surface is touched.

Open-PR overlap: the shared index returns no open main-target PR touching either changed file; no new merge conflicts.

@clawsweeper

clawsweeper Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review ended

ClawSweeper stopped reviewing this revision because the pull request closed.

View the workflow run.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-30T19:58:37.908410Z d0c9b03 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 30, 2026
@steipete
steipete merged commit b906fc7 into main Oct 30, 2026
133 of 136 checks passed
@steipete
steipete deleted the dbasync/regress51 branch October 30, 2026 20:25
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 31, 2026
…aw#188655)

Skip the native transcript metadata SELECT when the compressed frame, prepared report, and encoder-derived minimum cannot satisfy the existing savings threshold. Preserve byte-identical transcript/provider data, model-selection facts, restart delivery, and PostgreSQL behavior.

Addresses the redundant payload work from openclaw#185730 and openclaw#184702. Synthetic Gateway proof reduces ordinary warm turns from 48 to 45 SQL statements, with 13 worker requests and zero MAIN SQL unchanged; all fourteen turns and restart flows pass. The first sealed-history fingerprint from openclaw#186046 remains required.

Validated with payload and prompt-prefix tests, 48 byte-equivalent variants, two isolated code reviews plus a type-correction delta review, and exact-head CI/PostgreSQL conformance.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant