Repository navigation
fix(pi): make the session roots fingerprint independent of discovery order - #4618
Conversation
…order The fingerprint sorted each root's retention keys but joined the roots in discovery order. That order follows working directories and process contexts, so the same roots found in another order invalidated the cached scope and forced a rescan. Sort the components before joining; traversal order is unchanged.
|
🦞👀 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 real behavior proof before merge. What this changesSort Pi/OMP session-root fingerprint components so discovery order does not invalidate an unchanged cache scope. Example: Two projects use /tmp/pi-sessions-alpha and /tmp/pi-sessions-beta, discovered in opposite orders on successive refreshes.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 2 items remain Keep open: this PR fixes a source-confirmed cache identity defect still present on main and in v0.77.0, with no concrete introduced bug found. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherThe Pi cost scanner resolves project and process session roots, reads local transcripts, and publishes cached token and cost reports whose scope is identified by the root fingerprint. flowchart TD
A[Project settings and process contexts] --> B[Session root discovery]
B --> C[Sorted scope fingerprint]
B --> D[Transcript scanner]
C --> E[Cache scope validation]
D --> E
E --> F[App and CLI cost reports]
Technical reviewBest possible solution: Keep the existing fingerprint owner and canonicalize its complete root components before joining them. Do we have a high-confidence way to reproduce the issue? Source confirms that reversing two configured project roots changes main's fingerprint and reaches cache invalidation; no target code was executed during this read-only review. Is this the best way to solve the issue? Sorting the existing complete components is the smallest complete fix for order-sensitive scope identity, preserving flags, retention keys, and live discovery traversal. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 6480977b47f6. Provenance checked
TestingProof path: unit tests only. SecurityNone. EvidenceWhat I checked:
Likely related people:
Review metrics
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
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 18, 2026, 3:20 PM ET / 19:20 UTC. |
Refs steipete#4618. Co-authored-by: Dhruva Sahrawat <21278423+dhruva77@users.noreply.github.com>
# Conflicts: # CHANGELOG.md
Summary
PiSessionCostScanner.sessionRootsFingerprintidentifies the set of Pi/OMP session roots behind a cached cost scan. The fingerprint is stored in the cache assessionRootsFingerprintand exposed as the report'sscopeFingerprint.The function sorts each root's retention keys, but it joins the roots in discovery order. That order comes from the order of
workingDirectories, from live process contexts, and from previously retained roots. None of these is part of the scope.Concrete scenario: two Pi projects with their own
.pi/settings.jsonsessionDirare both known to the scanner. If one refresh discovers them as[alpha, beta]and the next as[beta, alpha], the fingerprint changes even though the roots are identical. When that happens:sessionRootsChangedbecomes true, which forces a refresh and rewrites the cache scope;scopeFingerprintreject a report that covers exactly the same roots.Fix
The per-root fingerprint components are sorted before they are joined, which is a one-line
.sorted()call. Each component already carries the root path and all of its flags, so sorting is lossless.The parser that restores retained roots splits the fingerprint into components and doesn't depend on their order.
Traversal order is unchanged: the scanner still walks
defaultSessionRootsin discovery order. Two side effects:Tests
New test in
PiSessionProcessContextTests:pi cost scope ignores the discovery order of identical session roots. It sets up three synthetic projects, each with a project-levelsessionDirunder a temporaryHOME, and checks three things throughPiSessionCostScanner.scopeFingerprint(options:):[alpha, beta]and[beta, alpha]give the same fingerprint;[alpha, gamma]gives a different one;Without the fix, the reordering check fails:
scope([projects[1], projects[0]]) == forward.Notes
The fix is small and isolated: two production lines (one call plus a comment) and one focused test. Root discovery, traversal, the cache format and pricing are unchanged.