Skip to content

improve: reduce database work when updating Goals - #149740

Closed
steipete wants to merge 2 commits into
mainfrom
codex/goal-mutation-reuse-entry
Closed

steipete wants to merge 2 commits into
mainfrom
codex/goal-mutation-reuse-entry

Conversation

@steipete

@steipete steipete commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Superseded by #149765, merged as b80fe68. This draft was not merged.

Goal management decoded full session rows to compare identities even though it only changes the Goal. The merged implementation removes those redundant identity snapshots and reuses the authoritative entry already read inside write admission. Stored-row certification, cache invalidation, Goal receipts, and the existing transaction remain owned by the shared writer. I compared both production implementations; their remaining difference is comment placement. The superseding PR's CI has 120 successful and 17 skipped checks, with no failed or pending CI checks.

The refreshed branch at 6ac0019 remains available as additional regression evidence. Against main e2d3d80, the synthetic 64 KiB prompt case dropped from 3 session-row reads / 132,942 returned text bytes to 2 reads / 66,771 bytes. All 23 focused persistence and registered Gateway RPC tests passed, along with production/test types, targeted typed lint, formatting, and independent P0–P2 review.

This branch also preserves Vincent Koc's distinct Matrix room-key regression from #149722, with his verified co-author credit. That additional case and this branch's tighter read/byte budgets have not landed; closing this duplicate does not claim otherwise. The merged PR has its own identity, certification, returned-entry, and Goal behavior coverage.

These are isolated database-read measurements, not production latency or CPU results. No schema, configuration, retention, durability, or permission change is involved. Update behavior is unchanged.

Related: #149537, #149388, #149697, #149722, #149726, #149765.

@steipete steipete self-assigned this Sep 16, 2026
@clawsweeper

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

@clawsweeper

clawsweeper Bot commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 16, 2026, 1:36 AM ET / 05:36 UTC.

ClawSweeper review

What this changes

Goal management reuses the session entry already read inside its transaction, removes redundant identity snapshots, and strengthens database-read and identity-preservation regression checks.

Merge readiness

⛔ Blocked before merge - 2 items remain

Keep open: this is a focused, useful optimization that remains absent from the pinned main revision. No introduced correctness defect was found, and the protected draft explicitly coordinates with an active related repair.

Priority: P2
Reviewed head: e65b7bab5f77dd3deee041133ba4505c73e7ebb2

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused simplification with meaningful regression coverage and no identified correctness defect; draft coordination does not reduce patch quality.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer-authored internal optimization is exempt from the external-contributor proof gate; its reported SQLite measurements exercise the changed Goal owner, with owner/RPC tests as supplemental validation.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-authored internal optimization is exempt from the external-contributor proof gate; its reported SQLite measurements exercise the changed Goal owner, with owner/RPC tests as supplemental validation.
Evidence reviewed 8 items Verified introduced scope: The merge-base-to-head diff contains only the Goal mutation implementation and its existing persistence regression. It removes identity snapshots and publication without moving authorization, transaction, or receipt boundaries.
Identity remains unchanged: The selected reader accepts only the exact requested row; the Goal-only merge retains the existing session ID. Identity publication emits only create, delete, move, or replacement events, so the removed comparison is inert for this operation.
Shared writer safeguards remain: The shared writer accepts a canonical entry revalidated inside the transaction, preserves creation provenance and same-generation ownership, certifies stored metadata, and publishes cache invalidation independently of identity events.
Findings None None.
Security None None.

How this fits together

The Gateway sends Goal edits and status changes to the session persistence owner, which commits the updated Goal and its retry receipt together. The shared writer maintains cache freshness, while the Gateway separately announces Goal changes.

flowchart TD
  A[Goal management request] --> B[Gateway authorization]
  B --> C[Queued transaction and current checks]
  C --> D[Read existing session]
  D --> E[Write Goal and retry receipt]
  E --> F[Shared cache publication]
  E --> G[Gateway Goal notification]
Loading

Before merge

  • Resolve merge risk (P1) - The final combined implementation and preserved Matrix-room regression have not yet been validated together after the stated reconciliation with the active repair.
  • Complete next step (P2) - Complete the stated reconciliation with fix(sessions): reuse Goal identities and chat reply state #149722, retain and validate its mixed-case Matrix regression, and mark the draft ready when that integration is complete.
Agent review details

Security

None.

PR surface

Source -18, Tests +12. Total -6 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 3 21 -18
Tests 1 16 4 +12
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 19 25 -6

Review metrics

Metric Value Why it matters
Reported Goal edit database work Session-row SELECTs 4 → 2; returned text 199,114 → 66,771 bytes The synthetic 64 KiB prompt measurement supports reduced database work without claiming production latency improvement.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Retain one Goal mutation path that reuses its fresh canonical entry while preserving atomic receipts, identity invariants, cache publication, and mixed-case session-key coverage.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Retain one Goal mutation path that reuses its fresh canonical entry while preserving atomic receipts, identity invariants, cache publication, and mixed-case session-key coverage.

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

Yes, source inspection identifies both redundant full-entry snapshots on pinned main, and the existing SQLite regression provides a focused measurement path; no tests were executed during this read-only review.

Is this the best way to solve the issue?

Yes, reusing the exact entry already read inside the synchronous transaction is narrower than retaining unnecessary identity comparisons and preserves the existing writer owner.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This bounded persistence optimization reduces repeated prompt-data reads during Goal management.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.

Label justifications:

  • P2: This bounded persistence optimization reduces repeated prompt-data reads during Goal management.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.

Evidence

What I checked:

Likely related people:

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

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Preserve the related repair's mixed-case Matrix regression and validate it with the final reconciled Goal implementation.

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.

Refresh against the canonical pre-write reuse from #149697 and retain
Vincent Koc's case-distinct Matrix sibling identity regression from #149722.
Management-only Goal mutations still preserve identity without taking
identity snapshots; shared writer certification and receipt atomicity stay.

The current-main64KiB fixture drops3 session-row SELECTs/132942bytes to
2 SELECTs/66771bytes. All23 focused owner/Gateway tests, scoped types,
typed lint, formatting and independent P2 review pass. These are local
database-read measurements, not production CPU or latency claims.

Co-authored-by: Vincent Koc <[email protected]>
@steipete steipete closed this Sep 16, 2026
@RomneyDa
RomneyDa deleted the codex/goal-mutation-reuse-entry branch October 22, 2026 00:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant