Skip to content

improve(team-reports): reduce activity aggregation queries - #159148

Merged
steipete merged 3 commits into
mainfrom
codex/sqlite-report-activity-0926
Sep 26, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/sqlite-report-activity-0926

Conversation

@steipete

@steipete steipete commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Team Reports aggregation repeatedly fetches small metadata pages even though it must retain all of that metadata before sorting activity.

User Impact

Aggregation performs fewer SQLite queries while producing the same reports. Payload reads remain limited to 100 rows, and no migration or configuration change is required.

Why This Change Was Made

Read compact activity metadata once per source, preserving its initial key order and the existing JavaScript collation. Keep comment/message payloads in their existing bounded batches. This removes redundant pagination without changing the worker owner or retaining additional payloads.

Evidence

  • All 272 Team Reports tests passed. A new regression verifies newest-comment deduplication across 201 inputs, at most 5 reads, and at most 100 payload rows per read. It fails on the original implementation with 8 reads.
  • The final query-budget test passes on both Node 24.19.0 and Node 26.8.2; its original-source negative control also fails on Node 24. Observing the shared query executor covers both native iterate() and all() paths. Scoped lint and extension test typechecking pass.
  • Measured test cost for the single-file runs: 125 ms test / 4.37 s wrapper on Node 24; 56 ms test / 2.40 s wrapper on Node 26. Selected repository checks passed, including storage guards and import-cycle checks.
  • Actual SQLite backend benchmark with 10,000 synthetic GitHub activities and 2 KiB bodies: 202 → 102 queries, unchanged 20,000 returned rows, and maximum payload batch unchanged at 100. Median aggregation time 67.27 → 64.25 ms (4.5% faster) across 31 alternating paired samples after 5 warmup pairs on Node 26.8.2/WSL. Instrumentation was removed before timing; worker startup, network, and model calls were excluded.
  • The existing complete worker report benchmark exercised 3,000 GitHub activities and 1,500 Discord messages. Before/after daily and monthly report JSON and Markdown hashes match exactly. Overall benchmark timing was noisy; no end-to-end speedup is claimed.
  • Fresh direct source review covered connection ownership, stable ordering, empty sources, duplicate handling, and payload bounds.

@clawsweeper

clawsweeper Bot commented Sep 26, 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.

@steipete
steipete marked this pull request as ready for review September 26, 2026 19:53
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 26, 2026
@clawsweeper

clawsweeper Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 26, 2026, 4:24 PM ET / 20:24 UTC (Revision 2).

ClawSweeper review

What this changes

The Team Reports plugin now reads activity metadata once per source during aggregation, retains 100-row payload batches, and adds a SQLite query-budget regression test.

Merge readiness

✅ Ready for maintainer review

Current main still makes repeated metadata queries, so this PR remains useful. The revised test addresses the previous review finding, and I found no introduced defect that warrants another repair cycle.

Priority: P2
Reviewed head: f533e782de298ea99fb17ea89bb6c8b6ff87c9b3

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused patch has meaningful backend and report-parity evidence, and the previous cross-version test defect has been addressed.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The author reports exercising the changed Team Reports SQLite aggregation path with 10,000 activities, observing 202 to 102 queries and unchanged 100-row payload batches; a complete worker benchmark reports matching daily and monthly outputs. The change alters a SELECT over connection-local scratch activity, not a stored-data contract.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The author reports exercising the changed Team Reports SQLite aggregation path with 10,000 activities, observing 202 to 102 queries and unchanged 100-row payload batches; a complete worker benchmark reports matching daily and monthly outputs. The change alters a SELECT over connection-local scratch activity, not a stored-data contract.
Evidence reviewed 8 items Introduced query change: The PR replaces repeated 100-row metadata pages with one ordered read while retaining the existing JavaScript sort and 100-key payload batches.
Current main remains unoptimized: The inspected main revision still pages compact metadata in groups of 100. A later live-main revision has the same worker-file blob, so the central optimization is not already on main.
Live-main identity check: Live main at f72bb2c has worker blob fd0a34b44528f4f5b537017a6731a97b39b762f4, identical to the inspected main blob.
Findings None None.
Security None None.

How this fits together

Team Reports collects GitHub and optional Discord activity into a worker-owned SQLite scratch table. The worker orders that activity and supplies bounded payload batches to daily report generation.

flowchart LR
  A[GitHub and Discord activity] --> B[Worker collection]
  B --> C[SQLite scratch table]
  C --> D[Metadata ordering]
  D --> E[Payload batches]
  E --> F[Daily report]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -9, Tests +72. Total +63 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 6 15 -9
Tests 1 72 0 +72
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 78 15 +63

Review metrics

Metric Value Why it matters
Reported SQLite queries 202 → 102 for 10,000 activities The author reports this reduction from the changed aggregation path with the payload batch bound unchanged.

Technical review

Best possible solution:

Keep the single metadata read in the existing Team Reports SQLite worker while preserving its ordering and bounded payload decoding.

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

Yes. Current-main source shows repeated metadata pages, and the PR body gives a concrete SQLite-backend benchmark for the same aggregation path; this review did not execute it.

Is this the best way to solve the issue?

Yes. The change removes redundant reads within the existing worker while retaining the sorting and payload limits already used by reports.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against fb3d7c33a716.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The author reports exercising the changed Team Reports SQLite aggregation path with 10,000 activities, observing 202 to 102 queries and unchanged 100-row payload batches; a complete worker benchmark reports matching daily and monthly outputs. The change alters a SELECT over connection-local scratch activity, not a stored-data contract.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove merge-risk: 🚨 automation: Current PR review selected no merge-risk labels.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This is a bounded performance improvement to an optional reporting plugin.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The author reports exercising the changed Team Reports SQLite aggregation path with 10,000 activities, observing 202 to 102 queries and unchanged 100-row payload batches; a complete worker benchmark reports matching daily and monthly outputs. The change alters a SELECT over connection-local scratch activity, not a stored-data contract.
  • proof: sufficient: Contributor real behavior proof is sufficient. The author reports exercising the changed Team Reports SQLite aggregation path with 10,000 activities, observing 202 to 102 queries and unchanged 100-row payload batches; a complete worker benchmark reports matching daily and monthly outputs. The change alters a SELECT over connection-local scratch activity, not a stored-data contract.

Evidence

What I checked:

  • Introduced query change: The PR replaces repeated 100-row metadata pages with one ordered read while retaining the existing JavaScript sort and 100-key payload batches. (extensions/team-reports/src/store.worker.ts:176, f533e782de29)
  • Current main remains unoptimized: The inspected main revision still pages compact metadata in groups of 100. A later live-main revision has the same worker-file blob, so the central optimization is not already on main. (extensions/team-reports/src/store.worker.ts:176, fb3d7c33a716)
  • Live-main identity check: Live main at f72bb2c has worker blob fd0a34b44528f4f5b537017a6731a97b39b762f4, identical to the inspected main blob. (extensions/team-reports/src/store.worker.ts:176, f72bb2cca2d9)
  • Previous finding addressed: The prior review found that a native all() spy missed supported Node versions using iterate(). The current test observes the shared query helper and asserts both the read count and payload-row bound; the PR body reports passing runs on Node 24.19.0 and 26.8.2. (extensions/team-reports/src/store-read-budget.test.ts:42, f533e782de29)
  • SQLite execution paths: The shared helper uses iterate() before Node 24.20 or 26.6 and all() on later supported versions, explaining the prior test failure and why observing the helper covers both paths. (src/infra/kysely-sync.ts:103, f533e782de29)
  • Reported real behavior proof: The captured PR body reports an actual SQLite-backend benchmark over 10,000 synthetic GitHub activities: 202 to 102 queries, unchanged returned rows, and a maximum payload batch of 100. It also reports matching before/after daily and monthly JSON and Markdown hashes from a complete worker benchmark. These measurements were reported by the author, not rerun in this read-only review.

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vincent Koc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-26T20:08:48.660Z sha c11aaca :: blocked before merge. :: [P2] Observe SQLite reads on both supported Node paths

@steipete
steipete enabled auto-merge (squash) September 26, 2026 20:18
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 26, 2026
@steipete
steipete merged commit 5acde61 into main Sep 26, 2026
111 of 113 checks passed
@steipete
steipete deleted the codex/sqlite-report-activity-0926 branch September 26, 2026 20:25
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash auto-merge.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 27, 2026
…159148)

* improve(team-reports): reduce activity aggregation queries

* test(team-reports): observe native statement reads directly

* test(team-reports): count reads across SQLite execution paths
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. plugin: team-reports proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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