Skip to content

Speed up member case history and preserve pagination after erasure - #1202

Open
jatmn wants to merge 5 commits into
mainfrom
perf/member-case-history
Open

jatmn wants to merge 5 commits into
mainfrom
perf/member-case-history

Conversation

@jatmn

@jatmn jatmn commented Dec 6, 2026 •

Copy link
Copy Markdown
Owner

Member case history

On a local guild with 24,000 live cases, median latency for a member’s eight newest-first results fell from 21.476 ms to 0.168 ms (127.8×). Every timed read went through the scoped store, requested 25 rows with totals disabled and checked the exact ordered case IDs and cursor state. Each figure is the median of five trial medians, with 25 warm reads per trial and alternating revision order. The baseline is 87e1dfed74a0.

Local store query Before PR Speedup
Member history, current-thread Tokio 21.476 ms 0.168 ms 127.8×
Member history, multithread Tokio 20.618 ms 0.169 ms 122.3×
Unfiltered first page, current-thread Tokio 0.538 ms 0.214 ms 2.5×
Unfiltered first page, multithread Tokio 0.321 ms 0.214 ms 1.5×

Median trial p95 on the primary workload fell from 21.923 ms to 0.248 ms (88.5×). These measurements cover warm local-store reads. Guild schema 26 migrates the subject/date index, which added 1.88 MiB in the 24,000-row fixture. A scoped local read can reuse its blocking worker and promptly release a successfully rolled-back local handle. Case SQL templates can reuse a bounded read-validation result. Every read still checks membership, opens a transaction, binds parameters and reads its own snapshot.

Regression coverage

The attached ledger covers 399 historical candidate commits from 773 reachable commits. It maps at least one testable contract in 107 candidates, including 36 with newly added or extended properties and 71 with existing inspected properties. Another 12 concern documentation, dependencies, merge integration or retired functionality. The remaining 280 need semantic coverage. Three cgroup regressions were replayed against both the parent and the historical fix.

The checked-in SMT models cover pagination, exact-string read-template reuse and deadline accounting. They include two counterexamples, a redacted subject cursor rejected at zero and a write allowed beyond its deadline after resetting its budget. The fixtures, assumptions, trial data and historical ledger are described in the regression guide.

Using the same tracked source extensions as the baseline, the patch adds 192 net physical lines, including tests and the benchmark. The 50% reduction and repository-wide invariant proof remain open.

Verification

The full local suites passed 2,993 Rust workspace tests (11 skipped, including the two benchmark variants) and 644 WebUI tests. All six disposable libSQL checks passed. The retry and picker properties passed in isolation. The session-preservation property also passed all 70 status/reference combinations, and caught a word-boundary classifier that passed its predecessor. Formatting, Clippy across the touched Rust packages, check-selection and image-publication fixtures passed.

Summary by Sourcery

Speed up scoped case history reads and preserve complete, correctly paginated case listings when erasure redacts subject data.

New Features:

  • Add indexed, subject-filtered chronological case listing with cursor pagination that remains valid after subject erasure.

Bug Fixes:

  • Allow pagination cursors for redacted cases whose subject sort key is zero.

Enhancements:

  • Reduce local scoped case-read latency by using the subject/date index and improving pooled read execution and SQL-template reuse while preserving snapshot and membership checks.

Documentation:

  • Document guild schema 26, its migration requirements, and the historical regression and performance checks.

Tests:

  • Expand regression coverage across pagination after erasure and numerous historical behavior contracts, and add reproducible solver models and a local latency benchmark.

Chores:

  • Upgrade guild stores to schema 26 with a live-case subject/date index.

pullfrog[bot]
pullfrog Bot previously approved these changes Dec 6, 2026

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Approach — The scoped composite index lets chronological case pages seek within one subject, and accepting zero in subject-sort cursors lets moderators continue past erased cases.

Reviewed changes

  • Case listing. Checked subject-filtered date seeks, case ID tie-breaking, and continuation from an erased subject’s zero sort key.
  • Schema 26. Reviewed fresh installs, historical upgrades, index growth reservation, schema verification, and paired rollout metadata.
  • Scoped reads and stored data. Checked that reads still verify active membership in the same primary snapshot, and reviewed the shared case serializer, mention redaction, Discord reason handling, and integer conversion.
  • Regression coverage. Reviewed the generated paging and upgrade cases, session handling, and test fixture changes. An in-memory SQLite probe verified the new index, both seek directions, and paging from an erased subject key. A Node probe verified the production auth-loss classifier. The full local test harnesses could not start because the pinned Cargo Git dependency and react-dom were unavailable.

Pullfrog  | View workflow run | Using gpt-6.2-sol | 𝕏

pullfrog[bot]
pullfrog Bot previously approved these changes Dec 6, 2026

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

Reviewed c3ce9bf, 5526a1b, and 89a748b since the previous Pullfrog review at e83b317.

  • Reduced scoped-read overhead. Local reads can reuse their pooled blocking worker and release the transaction handle directly after a successful rollback. Placement and membership checks still share the data snapshot.
  • Cached case SQL validation. Case listing reuses successful validation for exact SQL strings in a bounded cache. It still prepares the statement and binds parameters for each read.
  • Expanded regression coverage. The new commits added a local case-history benchmark, a historical coverage ledger, bounded regression cases, and SMT models for pagination, template reuse, and write deadlines. The latest commit broadened the OAuth retry and member-picker error fixtures and traced 22 additional historical contracts.

Both SMT models returned the expected results. Rust formatting, script syntax, diff whitespace, and a direct probe of all 16 new Markdown cases passed. The local Rust and WebUI test harnesses could not start because the pinned libsql-sqlite3-parser Git source and react-dom were absent. PR CI was still running.

Pullfrog  | View workflow run | Using gpt-6.2-sol | 𝕏

@jatmn
jatmn marked this pull request as ready for review December 6, 2026 21:35
@jatmn jatmn self-assigned this Dec 6, 2026

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue

Sourcery assessment

Needs a human reviewer. 1 finding to address first, and if the revised mention scan matches the wrong text, an erasure can persist [removed] in case or history payloads that reverting the code will not restore. Recovery would require a backup or manual repair.

Blocking findings: scripts/frontend-state-test.mjs:9503


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread scripts/frontend-state-test.mjs Resolved

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

Reviewed 9f884de since the prior Pullfrog review.

  • Expanded session-preservation coverage. The WebUI test checks standalone, delimited, and embedded 401 references across seven other HTTP statuses, verifying that each error leaves the signed-in user intact.

All five focused WebUI tests passed. A Node VM probe confirmed that a word-boundary classifier passes the previous fixture and fails the expanded one. The frontend CI check was still running. Frontend CI

Pullfrog  | View workflow run | Using gpt-6.2-sol | 𝕏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant