Repository navigation
Conversation
…ounded map SecurePathHardeningCache hand-rolled its own key-byte-weighted LRU — eviction loop, byte ledger, and recency reordering — duplicating BoundedMap. Delegates to it instead, cutting the implementation roughly in half. Two behaviors the generic map does not model are kept in the wrapper: a path over either the per-key or the aggregate ceiling is rejected outright, and a non-positive maxEntries disables the cache rather than caching one entry. Verified as a behavior-preserving swap by differential-testing the old and new implementations against each other: 5 bound configurations x 40 seeds x 60 randomized set/get/delete operations, asserting identical return values, entry counts, byte totals, and LRU ordering after every step. Both agree exactly, including negative bounds, zero ceilings, and multibyte keys. Adds coverage for the two wrapper-specific behaviors, which had none.
OrcaWin
marked this pull request as draft
October 27, 2026 09:44
Collaborator
|
Moving this PR to draft because it has been untouched for more than 80 days (latest recorded PR activity or commit timestamp: 2026-07-28T03:18:01Z; checked on 2026-10-27). This keeps the review queue focused on active work while preserving the proposal. Please mark it ready for review when work resumes. |
This branch has not been deployed
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.
Second slice of the re-landed memory-safety work (replaces the oversized #10548). Stacked on #10824.
Why
SecurePathHardeningCachehand-rolled its own key-byte-weighted LRU — eviction loop, byte ledger, and recency reordering — which is exactly whatBoundedMapalready does. This delegates to it, cutting the implementation roughly in half (49 lines removed, 24 added).What's preserved
Two behaviors the generic map doesn't model stay in the wrapper:
maxEntriesdisables the cache rather than caching one entry (BoundedMaphas no zero-capacity mode)Proof it's behavior-preserving
The existing suite had 4 tests, which felt thin for a swap that changes eviction internals. So I differential-tested the old and new implementations directly against each other:
set/get/deleteoperationsThey agree exactly. Also covered explicitly:
maxEntries: 0, negativemaxEntries,maxKeyBytes > maxTotalKeyBytes,maxTotalKeyBytes: 0, single-entry caches, empty-string keys, re-setting an existing key (refresh without double-counting), and multibyte keys (日本語, emoji) to confirm byte-not-char accounting.The differential harness was scaffolding and isn't part of the diff — but the two wrapper-specific behaviors it exercised had no coverage before, so those are now pinned as real tests.
Verification
pnpm run typecheck— cleansrc/sharedsecure-file.test.ts(the only consumer) — 17/17One unrelated pre-existing flake (
setup-agent-sequencing.test.ts, spawns real child processes against a 5s timeout) fails under full-suite load; confirmed it fails identically on cleanmain.Made with Orca 🐋