Skip to content

perf: reduce collaboration and workshop SQLite bookkeeping - #169033

Merged
steipete merged 4 commits into
mainfrom
dbasync/t1configrest
Oct 11, 2026
Merged

steipete merged 4 commits into
mainfrom
dbasync/t1configrest

Conversation

@steipete

@steipete steipete commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Ordinary collaboration and progress-card operations reread rows or repeat internal source checks even when the existing writer already owns the mutation. Workshop recording also repeats schema DDL on each append.

Why This Change Was Made

Use conditional mutations with RETURNING for progress cards, membership removal, and suggestion finalization; derive reaction removal results from transaction-local rows; prepare category keys and read each current entry only in the writer. Reuse admitted workshop schema facts. Keep caller authorization and live host authority checks at real effects.

User Impact

No user action, schema migration, or public API change. Category updates preserve current unrelated entry fields and skip entries already reassigned by another in-process write.

Main-thread inventory

Owned T1 call sites: 79 → 69, across 33 → 30 files. Three primitive call sites are deleted; seven are classification corrections (five already-worker-only workshop sites and two CLI-only hook sites). This does not claim ten newly migrated runtime calls. All-tier primitive sites: 385 → 382.

The remaining 69 T1 sites require the synchronous SDK, incognito/session, or config-owner cutover. They include config health and plugin metadata, native collaboration/pending-input helpers, pairing allowlists, skill selection, ambient watches, upstream links, progress-card reset, and the cron approval-generation reader. Shared kernels remain classified T1 instead of hiding their synchronous callers. No schema, stored format, retention, permission, dependency, or SDK contract changes.

Removed checks and accepted edges

  • Progress-card metadata rereads become SQL revision increments and conditional updates; an accepted write completes against its originally captured store if config changes while queued.
  • Membership/suggestion read-before-write uses the existing grant/token predicates in the mutation; a stale grant or claim changes no row.
  • Reaction removal uses rows read inside its transaction; concurrent mutations serialize at the existing writer.
  • Category preparation no longer snapshots whole entries or compares their later bytes; current unrelated fields survive, and entries moved to another category are skipped.
  • The duplicate category-destination check at commit is removed; the existing check immediately before effects remains, accepting a recoverable catalog change after that check.
  • Goal mutation drops its post-mutation source check; the transaction's initial source check owns the bookkeeping.
  • Workshop list/capture drops redundant host admission checks; a read already accepted by its captured store may finish after the host changes state.
  • Workshop append reuses admitted schema facts instead of CREATE TABLE/INDEX per append; migration/repair owners remain responsible for publishing schema changes.

Measurement

Three alternating pairs, M,C,M,C,M,C, using the unchanged shared synthetic workload. Base 53eb3f4f0c9455debc5ac58283916d7ea85f402b; candidate 95501b6c643ceeef86579832f00f2d22ab9e079d. Same Linux host, dependencies and harness; source hashes verified, MAIN/worker native observer calibration passed, and request-to-statement conservation is exact.

Metric Base median [min–max] Candidate median [min–max]
Warmed all-thread statements/turn 456.6 [456.4–456.7] 456.0 [450.8–456.4]
Warmed logical requests/turn 90.8 [90.5–90.8] 90.8 [90.1–90.8]
Warmed MAIN statements/turn 4.1 [4.1–4.1] 4.1 [4.1–4.1]
First-turn statements 1317 [1317–1321] 1315 [1160–1317]
First-turn requests 194 [193–199] 190 [185–193]
Startup-through-shutdown statements 11790 [11787–11799] 11786 [11713–11786]
Startup-through-shutdown requests 1744 [1741–1747] 1744 [1733–1746]

Warm duration ratio is 1.0001; all phase ratios are below 1.5. First/warmed medians do not rise; no other phase's statement median rises. Second-session requests vary by +2, with unchanged SQL and unchanged owners. The only changed warmed request-family median is the untouched sessionRows.sharedFacts (4.2 → 4.1 requests/turn).

Attribution limit: the shared ordinary-chat workload does not exercise these optional mutation operations: their direct SQL call-site counts are zero on both revisions. The raw −0.6 warmed statement delta is background variation, not a claimed saving from this patch. The baseline itself is already below 500 on this fixed workload; this is not evidence that every production turn is below 500. MAIN remains 4.1, and this PR does not complete the T1-zero mission.

The owner-level removals below are source-counted ordinary-path deltas, with focused behavior regressions; they are not substituted for the shared-harness results above. Logical worker requests for these operations are unchanged.

Operation Removed SQL work per operation
Card upsert / successful clear 1 metadata SELECT
Membership removal 1 SELECT; existing predicates stay in DELETE RETURNING
Suggestion finalization 1 SELECT; existing predicates stay in UPDATE RETURNING
Reaction removal 1 post-write SELECT
Category move 1 preparatory entry-read pass (point reads or batched reads); duplicate destination check removed
Goal mutation 1 duplicate source-validation pass
Workshop append after admission 2 DDL statements (CREATE TABLE/INDEX)

Validation

All 150 focused tests in 12 owner test files pass on pre-integration head 95501b6c643c (pnpm test <focused files> --maxWorkers=1 runner equivalent: 171.74s wall time / CI worker-seconds). Full remote check:changed passes at 92c39b5c31ab, before the final receipt predicate correction; type-aware lint, export-collision scan, Knip and both ratchets pass on that head. Madge passes. Codex autoreview: two rounds, scoped-clean (production P0–P2; obsolete-test removal P0–P1). The final receipt correction fixes the category regression exposed by the focused run. No update cell or SDK diff is applicable: no update, Doctor, migration/schema, plugin loading, service lifecycle, or SDK surface changes.

LOC after integration: production +108/-193 (net −85), tests +137/-69, docs/tooling +36/-0. Total: +281/-262 across 21 files.

Integration: merged ce5b795128e359ebebd9df80bdcfaf0258659a5a into the branch at 2f1b30688ed14d8d7fed8b57ac39a65d35f90a2f. The sole conflict was the upstream worker; the final file exactly matches main, which had already landed the same simplification and removed the redundant commit admission. That file and its kernel no longer appear in this PR. Exact integrated-head CI run 38128283864 passes, including source contracts, guards, architecture, build, and changed-test shards.

Post-integration sanity pair, ce5b795128e3 → 2f1b30688ed1, with source hashes and native calibration verified:

Metric Integrated main Candidate
Warmed statements/turn 406.3 405.0
Warmed requests/turn 92.0 92.4
Warmed MAIN statements/turn 4.1 4.1
First-turn statements 1071 1075
Whole-workload statements 10875 10867
Whole-workload requests 1744 1745

The warm duration ratio is 1.0068. The +4 first-turn statements (+0.37%) are entirely in untouched transcript request families: entry-list +14/−7 across caller buckets, exact entries −1, store projection −1, target inventory −1. The +0.4 warmed requests (+0.43%) are likewise untouched transcript/resource/shared-fact work: closes +0.1, entry-read −0.1, exact-entry buckets +0.3/−0.1, target inventory +0.1, shared facts +0.1. No changed owner executes SQL in this workload. Whole-workload statements decrease by 8. This passes the attributed 0.5% turn noise floor; no PR-attributable increase or extra pair is indicated. The three-pair evidence above is retained; this single pair checks the conflict-only integration and is not presented as a three-run median.

Use conditional writes and committed rows for cards, membership, suggestions, reactions, and category edits. Check internal sources once inside their transaction and reuse admitted workshop schema facts. Preserve released synchronous adapters and native incognito ownership.
@clawsweeper

clawsweeper Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime scripts Repository scripts size: L labels Oct 11, 2026
# Conflicts:
#	src/sessions/session-upstream-links.worker.ts
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 11, 2026
@clawsweeper

clawsweeper Bot commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR removes redundant SQLite reads and schema work from collaboration, progress-card, Goal, and Workshop operations.

Example: A progress card at revision 2 is replaced with markdown "Second".

  • Before: The writer selects existing metadata before updating the card.
  • After: One upsert increments the stored revision to 3 and returns it, preserving the creation timestamp.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful simplification with meaningful owner-boundary coverage and no actionable defect found; supplied runtime measurements do not establish the changed operations.
Proof confidence 🦐 gold shrimp (3/6) The maintainer-authored ordinary-proof exemption applies; reported focused tests exercise production owners, while the supplied chat measurements explicitly omit the optional mutation paths.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Optional collaboration and progress operations perform avoidable database bookkeeping.
Reason: The maintainer-directed change reduces work within existing owners without adding configuration, public APIs, or storage formats.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it provides useful, maintainer-directed SQLite simplification, and review found no discrete introduced bug.

Priority: P2
Reviewed head: 2f1b30688ed14d8d7fed8b57ac39a65d35f90a2f

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: No supplied shipped-entry-point capture exercises the changed optional mutations, and base-fail/head-pass regression runs are not demonstrated.
Agent review details

How this fits together

Gateway and collaboration callers submit mutations to existing database owners, which validate authority, execute synchronous SQLite transactions, and publish committed results to session projections.

flowchart TD
A[Gateway and collaboration callers] --> B[Captured store and caller authority]
B --> C[Existing writer admission]
C --> D[Transactional storage kernels]
D --> E[Agent and shared state SQLite]
E --> F[Commit receipts]
F --> G[Session projections and responses]
Loading

Technical review

Best possible solution:

Retain the existing storage owners and merge the focused simplification through the normal required gates.

Do we have a high-confidence way to reproduce the issue?

Current-main source establishes the redundant metadata reads, preparatory entry pass, and repeated Workshop DDL; no target code or tests were executed during this read-only review.

Is this the best way to solve the issue?

The patch removes work at existing transactional owners, preserves conditional mutation predicates and live authority, and documents its intentional bookkeeping tradeoffs.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against f442662cabd8.

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Pinned production change: The introduced diff replaces progress-card metadata reads with conditional updates and upserts; revision predicates, creation timestamps, and revision tombstones remain owned by the existing store. (src/session-cards/progress-card-store.ts:28, 2f1b30688ed1)
  • Membership authority preserved: Removal retains session-instance and ownership validation, puts expected grant fields directly in DELETE predicates, and publishes membership changes only when a row is returned. (src/config/sessions/session-sharing-store.native.ts:146, 2f1b30688ed1)
  • Category changes preserve current state: The writer reads current entries inside its transaction, preserves unrelated fields, and skips reassigned categories; receipt validation still requires prepared-key coverage and exact publication facts. (src/config/sessions/session-group-categories.kernel.ts:26, 2f1b30688ed1)
  • Schema compatibility: Workshop reuses the existing schema ensurer with the same canonical table and index definitions; the patch introduces no schema, serialized-format, retention, or migration change. (src/skills/workshop/changes.kernel.ts:38, 2f1b30688ed1)
  • Accepted tradeoffs and measurement limits: The maintainer-authored body explicitly accepts captured-store completion and recoverable category-catalog changes, while preserving live caller authority; it also states that the chat benchmark does not exercise the optional mutations and attributes no warmed-turn saving to them. (2f1b30688ed1)
  • Current-main ownership: Feature history includes progress-card introduction, worker persistence, schema reuse, collaboration snapshots, and Workshop recording; the corresponding current-main implementations retain the redundant work changed here. (src/session-cards/progress-card-store.ts:156, f442662cabd8)

PR surface

Source -85, Tests +68, Docs +23, Other +13. Total +19 across 21 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 12 108 193 -85
Tests 7 137 69 +68
Docs 1 23 0 +23
Config 0 0 0 0
Generated 0 0 0 0
Other 1 13 0 +13
Total 21 281 262 +19

Review metrics

Metric Value Why it matters
Production versus test changes Production +108/-193; tests +137/-69 Production shrinks while tests strengthen stale-grant, current-entry, persisted-result, and schema-rollback contracts.

Labels

Label changes:

  • add P2: Useful bounded database-work reduction without evidence of an urgent user-facing failure.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: Useful bounded database-work reduction without evidence of an urgent user-facing failure.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only; repair and merge need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

Reviewed October 11, 2026, 5:31 AM ET / 09:31 UTC.

@steipete
steipete merged commit 6a7bd30 into main Oct 11, 2026
134 of 136 checks passed
@steipete
steipete deleted the dbasync/t1configrest branch October 11, 2026 09:57
@steipete

Copy link
Copy Markdown
Contributor Author

Landed after exact-head CI passed. The native route twice confirmed a pre-dispatch refusal for UNSTABLE; both required openclaw/ci-gate checks were successful and the only failing checks were non-required PR context and evidence. The authorized fallback squashed the reviewed head 2f1b30688ed14d8d7fed8b57ac39a65d35f90a2f.

Follow-up from review: add optional card/collaboration/workshop mutation scenarios to the shared SQL harness. Current focused owner tests cover their behavior, while the ordinary-chat measurements do not establish their runtime savings. The remaining 69 T1 sites still need their documented SDK/session/config owner cutovers. No concrete correctness or security finding remained.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 12, 2026
…169033)

* perf: reduce collaboration and workshop SQLite bookkeeping

Use conditional writes and committed rows for cards, membership, suggestions, reactions, and category edits. Check internal sources once inside their transaction and reuse admitted workshop schema facts. Preserve released synchronous adapters and native incognito ownership.

* test: remove obsolete progress card decode expectation

* fix: accept unchanged category keys in collaboration receipts
scribe-dandelion-cult added a commit to karmaterminal/openclaw that referenced this pull request Oct 18, 2026
First-parent upstream fd0fc62..f4f4868 (8 commits: openclaw#169033
collaboration/workshop SQLite bookkeeping, 952c102, openclaw#155464 active
turns during worker dispatch, openclaw#168995 approval/placement queries,
openclaw#154286 telegram polling workers, 194a08e, openclaw#169045 code-mode catalog
bytes, openclaw#159697 talk voice permissions).

Conflicts:
- session-sharing-store.native.ts: upstream folded the member lookup and
  delete into one DELETE ... RETURNING with a no-row early return; our
  recipient-authority advance now follows that return, so only an actual
  removal revokes access (same order as before the merge).
- worker-access inventory: took upstream, regenerated (632 files, 2442
  calls).

sharing-store receipt/worker auto-merged: upstream's category plan
(keys only) is disjoint from our authority.capture command.

Refs #1475

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

Labels

docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant