Repository navigation
perf(gateway): reduce repeated turn preparation work - #134673
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 31, 2026, 10:59 PM ET / September 1, 2026, 02:59 UTC. ClawSweeper reviewWhat this changesThis PR removes redundant plugin-policy normalization and session-entry copies from Gateway turn preparation while preserving tool eligibility and guarded transcript persistence. Merge readinessKeep open. The exact PR head has no actionable regression found, and the earlier release-owned changelog finding is resolved; this maintainer-authored, maintainer-labeled PR remains subject to normal exact-head merge gates. Priority: P3 Review scores
Verification
How this fits togetherGateway turns prepare plugin metadata, model/tool availability, and session facts before dispatching work and writing transcript state. The changed paths reduce repeated preparation while the existing policy and SQLite transaction owners continue to decide availability and persistence. flowchart LR
A[Gateway chat turn] --> B[Prepare runtime facts]
B --> C[Plugin policy eligibility]
B --> D[Session identity lookup]
C --> E[Tools and models]
D --> F[Guarded transcript write]
E --> G[Turn dispatch]
F --> G
Before merge
Agent review detailsSecurityNone. PR surfaceSource -59, Tests +117. Total +58 across 16 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Preserve this owner-boundary consolidation and land it only after the exact head satisfies the repository’s normal required checks. Do we have a high-confidence way to reproduce the issue? Not applicable: this is a performance/simplification PR, not a report of broken existing behavior. The supplied PR body documents real after-fix Gateway turns, while source review confirms the preserved policy and persistence paths. Is this the best way to solve the issue? Yes. Reusing same-config normalized policy at the existing eligibility owner and retaining only the session binding avoids duplicate checks and redundant copies without creating a parallel policy or persistence path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 9aa82b18253b. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Merged via squash.
|
* perf(gateway): reduce repeated turn preparation work * chore: keep turn preparation release notes in PR body
What Problem This Solves
Gateway turns repeated plugin-policy preparation and copied session data that the turn only needed to identify its current session. These costs accumulated during model/tool discovery, browser chat admission, and transcript persistence.
Related: #134246, the earlier per-turn preparation improvement. This is the requested follow-up performance and simplification pass.
Why This Change Was Made
Reuse each scan's normalized plugin policy, read the global enabled flag directly where it is the only needed fact, and keep policy decisions in the existing eligibility owner. Remove forwarding helpers and repeated owner checks after the owner has already passed the outer gate.
Transcript targeting carries the current session ID without retaining or copying the cached store. Private identity snapshots retain freshly decoded entries; caller callbacks and returned results retain their isolation copies. Existing current-session checks, durable input admission, cancellation ordering, plugin deny/allow rules, installed-plugin activation, and named bundled compatibility remain intact. No config, persistence schema, migration, dependency, or protocol change.
User Impact
Less repeated local work during turn preparation with the same available tools and durable chat behavior. This does not claim a repeatable end-to-end latency improvement: provider latency, shared-host load, and garbage collection varied between runs.
Evidence
e339ce2e2fb3d9c4e1d42c9473a35479ccaffe9bplus the preceding local performance passes. They are not final-head timing claims; newer main changes full-store caching.faa28eb7040adaaf11c84496eb2b30063c206a66: 155 tests across nine files passed, covering policy selection, manifest eligibility, browser admission, exact session rows, conformance, recovery, transcript initialization, parent forks, and replacement projection. The full build and changed-file gate passed; Codex Autoreview found no actionable finding at its configured P0 threshold.session_statusand returned the configured public model. Gateway health returned HTTP 200. This is behavior proof, not a new timing claim.858138db7e15547a29ab3cd7f1434f5f239c99beonly removes the changelog line; source and tests match the validated commit byte-for-byte. Its focused Autoreview passed, and final-head CI is green.Production LOC: net −59. Tests: net +117. The tests reuse existing owner fixtures and add no production-only test seam.
Follow-up: startup-only
preserveTemporarySessionMappinghas another fresh-row copy to investigate separately. A direct exact-reader substitution for Gateway whole-store lookup is intentionally excluded because hidden-row visibility, sparse-store shape, and unrelated-row validation differ.ClawSweeper follow-through: its current review found the runtime patch correct. The changelog removal finding/rank-up move is addressed: the release-owned changelog is unchanged, and the release-note context remains in this PR body. The first native prepare attempt correctly rejected the changelog line; no release-only override was used. The exact-head CI rank-up move is satisfied by the green final-head run.