Repository navigation
perf(gateway): avoid repeated transcript path resolution - #184082
Conversation
Reuse the candidate canonicalized by the synchronous transcript path owner. Retain per-call external-file resolution, fallback-root containment, and moved-archive behavior. Reduce sampled allocation for sibling and relocated archive paths without adding a cache.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs maintainer review before merge. What this changesThis PR reuses the canonical transcript path already prepared by the resolver instead of canonicalizing it again during agent-directory fallback. Example: Resolve /state/agents/worker/sessions/sess-1.jsonl while using /state/agents/main/sessions as the selected directory.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR is a useful, narrowly scoped optimization with no actionable correctness findings; current main still performs the duplicate resolution. Priority: P3 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe shared session-path resolver receives persisted transcript locators and agent-directory context, then returns a canonical artifact path or a derived fallback for Gateway, archive, and Doctor consumers. flowchart TD
A[Persisted transcript locator] --> B[Shared session path resolver]
B --> C[Canonicalize candidate once]
C --> D[Agent directory containment]
D --> E[Relocation and structural fallback]
D --> F[Resolved transcript path]
E --> F
F --> G[Gateway and Doctor consumers]
Technical reviewBest possible solution: Reuse the caller’s canonical candidate within the existing resolver while retaining per-invocation resolution and all fallback checks. Do we have a high-confidence way to reproduce the issue? Source inspection establishes the duplicate canonicalization on main, and the supplied regression reports two candidate canonicalizations before the change versus one afterward; no target code was executed during this review. Is this the best way to solve the issue? The patch is the smallest complete production fix: it consumes an already-prepared fact at the existing owner without adding caching, state, or another resolution path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d4ae3a731187. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource -1, Tests +35, Other +118. Total +152 across 3 files. Added test files: 0. View PR surface stats
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 25, 2026, 10:13 PM ET / October 26, 2026, 02:13 UTC. |
…4082) Reuse the candidate canonicalized by the synchronous transcript path owner. Retain per-call external-file resolution, fallback-root containment, and moved-archive behavior. Reduce sampled allocation for sibling and relocated archive paths without adding a cache.
What Problem This Solves
Resolving a legacy absolute transcript path outside the selected agent's directory repeats filesystem canonicalization after the path-resolution owner has already canonicalized the candidate in the same synchronous call.
User Impact
A small reduction in synchronous filesystem work and allocation for sibling-agent and relocated archive paths. Ordinary transcript paths are unchanged; no whole-Gateway speedup is claimed.
Why This Change Was Made
Both callers of the private fallback helper pass the already-resolved
realTrimmed. Consume that value directly. The initial per-call external-file canonicalization, fallback-directory canonicalization, containment checks, and reroot existence checks remain. No cache, configuration, or persistent state is added. Changed symlinks are observed on the next invocation.Production delta: −1 line (
src/config/sessions/paths.ts, +2/−3). The added regression (+35 lines) and standalone benchmark (+118 lines) are proof tooling. The broader synchronous-filesystem sweep found no other pure deletion that preserved external-file or authority contracts; the change deliberately stays at one proven site.Evidence
Work-count regression:
resolves a sibling transcript once per call and observes changed symlinksfails on base4a6e70a2821644a0b0f7fbf5a1b650cbc5969b88with 2 canonicalizations instead of 1, and passes with the deletion. It also retargets the alias outside the allowed layout and confirms the next invocation falls back safely.Owner benchmark:
node --expose-gc --import ./scripts/tsx.mjs scripts/perf/session-transcript-path-measure.ts --iterations 5000 --rounds 5. Forty synthetic agent directories; existing sibling and missing-old-root/relocated paths. AB then BA; five rounds per arm per pair, 50,000 timed calls per revision per workload, plus separate allocation passes with the same work counts. Fixtures and warmup are excluded. CPU/wall time is untraced; allocation uses V8 sampling at 4096 bytes, including collected objects.Means per 5,000 resolutions:
Allocation improved in both orders. CPU was noisy: sibling pair means were 1010.30→1102.56 ms and 1998.07→1934.76 ms; relocated pair means were 864.58→945.74 ms and 1864.50→981.40 ms. Treat sibling CPU as neutral/inconclusive, not a speedup. Wall-time means were 1932.77→1844.36 ms and 2014.85→1215.76 ms respectively. Host one-minute load ranged 26.09–45.41 for base and 26.98–47.86 for candidate. These are owner measurements, not a production-frequency claim.
Validation:
node scripts/run-vitest.mjs src/config/sessions/paths.test.ts src/config/sessions.test.ts src/config/sessions/sessions.test.ts --maxWorkers=1: 64 tests passed, 143.90 s wall including first-use worker compilation; individual test execution remained milliseconds.git diff --checkpassed.4c13f9773e9c480cae0102322a7568faf8ac6fde; all 77 active PR checks passed, with no failed or pending checks.No Gateway load campaign was run: this is a synchronous duplicate deletion with no cache or lifecycle changes, using the requested pure-deletion proof path. Whole-Gateway CPU, GC, RSS/heap and latency effects are unmeasured. No production service or state was touched.