fix(ws): lazy + memoized session-cwd resolution (host-stats lagging toggle) - #826
Merged
Merged
Conversation
…install, per-key memo tradeoff, canonicalized expected values
…nd the per-registry memo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the production host-stats tile toggling to
laggingevery few seconds.Root cause: every ~5s auto-title sweep pass called
find_all_by_session, which eagerlystd::fs::canonicalized every session's cwd (every provider) on every call — including per-terminal comparisons. On WSL2, cwds under 9P-mounted, cloud-sync-backed paths (Google-Drive-synced/mnt/dfolders) stall 0.4–2s per resolution, blocking the async runtime and tripping the host-stats drift sampler.Fix (two layers, matching the Node original's matching semantics):
find_all_by_sessionnow resolves the session cwd lazily — only claude-scoped lookups (the only provider that uses cwd matching) ever canonicalize; non-scoped lookups (codex etc.) pay nothing.normalize_scoped_cwd_cached): each distinct raw cwd string is resolved on disk exactly once per registry lifetime, then served from the map. Lock discipline: the on-disk resolution happens outside the memo lock, so a slow path never holds it.Matching behavior is unchanged (verified by three independent reviews); the accepted tradeoff — a symlink retarget after first resolution keeps serving the first target for that raw spelling — is documented in
port/oracle/DEVIATIONS.mdDEV-0021 and pinned by a test.Evidence
identity.rs(lazy scoping, memo hit/retarget behavior, empty-cwd pin, contract tests) + 3 sweep-level integration tests inauto_title_sweep.rsdriving the real pass with real symlinked directories (claude cwd discrimination between two live terminals, canonical match through symlinks plus second-pass idempotence, codex cwd-blindness). After the rebase onto the unified-agent-names work, the sweep tests assert through theterminal.meta.updatedupsert fan-out (scoped sessions' titles now come from the naming authority).b46dfreshagent fencing family (below).cargo fmt --checkand clippy clean;freshell-ws762/762;freshell-server1159 passed (the one failure is the knowntsmxnet_bind load flake — passes in isolation).rust-gatewill be red — pre-existingb46d, not this PRcargo test --workspaceis red onmainitself in the freshagent kill/handoff fencing family (katab46d: 4–5 deterministic tests, last edited 2026-09-11, regression window PRs #798–#815, filed and currently unowned). This PR does not touchfreshell-freshagent, and that crate is not a dependent of any changed crate, so the red is inherited from base, not caused here. Per the documented merge policy, it merges via the owner-account ruleset bypass.Docs
docs/plans/2026-09-20-cwd-canonicalize-lag.md— the-usual run record: load-bearing validation (9 claims, 4 falsified-and-corrected), plan review PASSED round 1, delta review PASSED round 1, full gates passed under the user's documentedb46dwaiver.port/oracle/DEVIATIONS.mdDEV-0021: the KEPT cwd-resolution schedule divergence behind the memo.