fix: gapped custom-enum child scope (B-3) + drop per-resolve CacheItem alloc (P-1)#218
Merged
Conversation
- B-3: build_child_container derives the next scope as the smallest enum member deeper than the current one, so non-contiguous custom IntEnums (TENANT=6, JOB=10) work instead of raising MaxScopeReachedError on value+1. - P-1: fetch_cache_item uses get-then-set instead of setdefault, removing the throwaway CacheItem (+2 dicts) constructed on every cache hit. Spec: planning/audits/2026-06-14-deep-audit-report.md Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… path The initial P-1 get-then-set broke setdefault's atomicity, which is load-bearing: fetch_cache_item runs outside the container lock, so concurrent first-resolvers of a singleton must share one CacheItem (the cache + double-checked lock live on it). Restore atomic setdefault on the creation path; keep a get fast path so the common hit case still avoids the throwaway allocation. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
lesnik512
added a commit
that referenced
this pull request
Jun 14, 2026
Move bundle to archive (status: shipped, pr: 218); update README Index; mark B-3/P-1 resolved in the 2026-06-14 audit report Status line. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
Batch 2 of the 2026-06-14 deep audit — the two real, low-risk code fixes.
build_child_container(scope=None)derived the next scope asself.scope.value + 1, assuming contiguous values. A gapped customIntEnum(TENANT=6, JOB=10) raisedMaxScopeReachedErrordespite a deeper member existing. Now derives the smallest member> self.scope. The stock contiguousScopeenum is unaffected.fetch_cache_itemusedsetdefault(id, CacheItem(...)), whose default is evaluated eagerly, so every cache hit (every resolve after the first) constructed and discarded aCacheItem(+2 dicts). Switched to behavior-identicalget-then-set, removing the per-resolve allocation.Bundle (plan-only, spec = the audit report):
planning/changes/active/2026-06-14.04-audit-fixes-batch2/.Test Plan
MaxScopeReachedError) — gapped case failed onmain, passes herejust test-ci);just lint-ciclean🤖 Generated with Claude Code