Skip to content

improve: reduce repeated Skill Workshop history reads - #158757

Merged
steipete merged 1 commit into
mainfrom
codex/sql-workshop-pending-reads
Sep 26, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/sql-workshop-pending-reads

Conversation

@steipete

@steipete steipete commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Skill Workshop repeatedly decodes and transfers the entire retained proposal history while listing proposals, even when most proposals no longer need reconciliation.

User Impact

Listing a large proposal history does less work while returning the same complete history. Pending recovery, agent scoping, ordering, and the final fresh read are preserved. No schema migration, new index, configuration change, or operator action is required.

Why This Change Was Made

Apply the existing proposal status in SQLite so the three reconciliation enumerations return only pending proposals; the final enumeration still returns all proposals. For valid stable records this reduces materialized records from 4N to N + 3P, where N is all proposals and P is pending proposals. This saves JSON decoding and worker transfer; without a status index, it does not claim fewer SQLite rows scanned.

Evidence

  • Extended an existing real-worker service test: three terminal proposals previously materialized 12 records across list operations; the candidate materializes at most 3 and returns all three. The negative control failed on the original production code for that exact reason.
  • Focused service, persisted-record validation, and scope-retention proof: 58 passed, 14 intentionally unselected. Existing recovery and cross-agent cases passed. Command wall time was 237.99 seconds across two Vitest shards; the extended case took 374 ms (442 ms for the failing negative control).
  • Warm service benchmark through the actual SQLite worker: 1,000 synthetic terminal proposals, each with 8 KiB of evidence, two warmups and 12 timed samples per variant. Median wall time fell from 348.03 ms to 163.73 ms; median process CPU including workers fell from 623.14 ms to 241.76 ms. Returned manifests had identical SHA-256 hashes. Node 26.9.0, SQLite 3.53.4, macOS; excludes fixture creation and cold startup. No wire-byte measurement is claimed.
  • Targeted type-aware lint, formatting, diff checks, and independent scoped review passed. Hosted CI succeeded on the published head; the extended regression took 127 ms in checks-node-changed-compact-small-9. ClawSweeper also completed a clean review in run 36229931514. Native merge and all required gates completed successfully.

Focused proof command:

pnpm test src/skills/workshop/service.test.ts src/skills/workshop/store-record.test.ts src/skills/workshop/store.test.ts --maxWorkers=1 -t 'skill workshop proposals|Skill Workshop persisted record validation|retains the requested agent scope'

@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 08:27
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. 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, 5:40 AM ET / 09:40 UTC (Revision 2).

ClawSweeper review

What this changes

The branch filters Skill Workshop reconciliation reads to pending SQLite proposals, retains a final full-history read, and extends a service test that counts worker-returned records.

Merge readiness

✅ Ready for maintainer review

Current main still materializes completed proposals during reconciliation reads. This PR makes a distinct, well-supported optimization, and the reviewed head has no identified blocking defect.

Priority: P2
Reviewed head: 34bb377dbc93962a49c5af8823f0141887bc36b3

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) The narrow patch has direct worker-boundary regression coverage, a reported before-and-after benchmark, and no identified correctness or security blocker.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR reports exercising the changed SQLite-worker listing path on macOS with 1,000 terminal proposals: median wall time fell from 348.03 to 163.73 ms and returned manifest hashes matched. The real-worker service test also checks retained history; no stored-data contract changes.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR reports exercising the changed SQLite-worker listing path on macOS with 1,000 terminal proposals: median wall time fell from 348.03 to 163.73 ms and returned manifest hashes matched. The real-worker service test also checks retained history; no stored-data contract changes.
Evidence reviewed 7 items Current main retains repeated full reads: The current-main manifest helper lists all scoped proposals before and after pending reconciliation; the listing service calls that helper twice.
Introduced query filter: The pinned merge-base-to-head diff adds a SQLite status predicate and uses pending-only reads for reconciliation while leaving the final manifest read unfiltered.
Status consistency: Proposal writes derive both the JSON record and indexed status from the same record; row parsing rejects a status mismatch.
Findings None None.
Security None None.

How this fits together

Skill Workshop stores proposal records in SQLite and serves proposal listings to the Gateway, CLI, and agent tools. Listing reconciles pending work before returning the selected agent’s proposal history.

flowchart LR
A[Gateway, CLI, and tools] --> B[Proposal listing]
B --> C[Agent-scoped pending query]
C --> D[Pending recovery]
D --> E[Full-history query]
E --> F[Proposal history]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +1, Tests +16. Total +17 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 3 29 28 +1
Tests 1 22 6 +16
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 51 34 +17

Review metrics

Metric Value Why it matters
Warm listing wall time 348.03 ms → 163.73 ms median The contributor’s real-worker benchmark reports about 53% less listing time for a history dominated by completed proposals.
Materialized proposal records 4N → N + 3P The stated bound shows how work scales with all proposals N and pending proposals P; it does not claim fewer SQLite rows scanned.

Technical review

Best possible solution:

Keep status filtering in the Workshop store while preserving pending recovery and the complete agent-scoped history returned to callers.

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

Yes, from source: current main performs unfiltered proposal reads during both manifest calls, and each manifest call lists records twice. This read-only review did not run a benchmark.

Is this the best way to solve the issue?

Yes. Filtering at the existing SQLite query avoids decoding and transferring completed rows during reconciliation while retaining the final full-history response.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded performance improvement to proposal listing with no reported loss of functionality.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR reports exercising the changed SQLite-worker listing path on macOS with 1,000 terminal proposals: median wall time fell from 348.03 to 163.73 ms and returned manifest hashes matched. The real-worker service test also checks retained history; no stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR reports exercising the changed SQLite-worker listing path on macOS with 1,000 terminal proposals: median wall time fell from 348.03 to 163.73 ms and returned manifest hashes matched. The real-worker service test also checks retained history; no stored-data contract changes.

Evidence

What I checked:

  • Current main retains repeated full reads: The current-main manifest helper lists all scoped proposals before and after pending reconciliation; the listing service calls that helper twice. (src/skills/workshop/store.ts:399, 2919fa6bdc4f)
  • Introduced query filter: The pinned merge-base-to-head diff adds a SQLite status predicate and uses pending-only reads for reconciliation while leaving the final manifest read unfiltered. (src/skills/workshop/store-proposal.kernel.ts:132, 34bb377dbc93)
  • Status consistency: Proposal writes derive both the JSON record and indexed status from the same record; row parsing rejects a status mismatch. (src/skills/workshop/store-sqlite-record.ts:65, 34bb377dbc93)
  • Service regression coverage: The extended service test exercises listing through the real worker, caps materialized terminal rows at three, and checks that rejected, applied, and quarantined proposals remain in the result. (src/skills/workshop/service.test.ts:914, 34bb377dbc93)
  • Published history contract: The Skill Workshop reference defines the proposals array as both proposal history and the pending queue. Public docs: docs/tools/skill-workshop/reference.md. (docs/tools/skill-workshop/reference.md:31, 2919fa6bdc4f)
  • Reported real-worker benchmark: The captured PR body reports a macOS SQLite-worker listing benchmark with 1,000 terminal proposals and 8 KiB evidence each: median wall time 348.03 ms before and 163.73 ms after, with identical returned manifest hashes. These measurements were reported by the contributor, not rerun in this read-only review. (34bb377dbc93)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Ayaan Zaidi: 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-26T08:56:19.638Z sha 34bb377 :: needs maintainer review before merge. :: none

@steipete
steipete merged commit c4a7654 into main Sep 26, 2026
273 of 274 checks passed
@steipete
steipete deleted the codex/sql-workshop-pending-reads branch September 26, 2026 15:57
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor 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