Repository navigation
recipes: persist safe reached-input keys within the CI verification bound - #750
Conversation
There was a problem hiding this comment.
Verdict: MUST_FIX: Narrowed keys omit a reachable macro dependency and accept incomplete directory reads.
Must fix
1. Bound source macros whose paths depend on arguments
tools/recipes.py:3669 A selected binary calls dep::run(). The dependency declares mod hidden;, defines macro_rules! call { ($module:ident) => { $module::run() }; }, and calls call!(hidden) inside run(). This executes hidden::run(), but structural edges do not substitute $module and the safety lookup accepts the macro as resolved. An in-memory fixture confirmed that dep/src/hidden.rs remains a compilation input but is omitted from key inputs. Editing its behavior leaves the green key unchanged and permits a stale skip.
Close this dependency before recording reusable green results; otherwise those results need invalidation. Omit parameterized bodies from this safety lookup so both existing callers take the opaque-owner bound. Add a CLI regression for the example.
def _source_macro_bodies(text: str, test: bool) -> dict[int, str]:
"""Lexed definition bodies, indexed exactly like rust_facts, for expansion safety checks."""
_, shape = build_view(text, test)
raw: list = []
_module_units(shape, 0, len(shape), (), raw, [])
return {k: shape[a:b] for k, (kind, _, _, a, b, _, _) in enumerate(raw)
if kind == "macro_rules!" and not re.search(r"\$\s*(?!crate\b)[A-Za-z_]\w*", shape[a:b])}2. Propagate directory enumeration and stat failures
tools/recipes.py:1117 os.walk suppresses directory I/O errors, and os.path.isfile suppresses stat errors. Injecting PermissionError into enumeration returned set(). Key assembly at line 8934 accepts that incomplete set, including on its validation pass, instead of refusing the key.
Reject these reads now to prevent incomplete ledger entries that later need removal. Preserve the errors through both operations; KeyContext.parts already reports OSError. Add enumeration and stat failure cases.
def directory_files(self, rel: str) -> set[str]:
"""Every regular file under an explicit directory; unreadable entries are errors."""
out: set[str] = set()
seen: set[str] = set()
def unlisted(error):
raise error
for base, dirs, files in os.walk(os.path.join(self.root, rel), followlinks=True, onerror=unlisted):
real = os.path.realpath(base)
if real in seen:
dirs.clear()
continue
seen.add(real)
for name in files:
path = os.path.join(base, name)
if stat.S_ISREG(os.stat(path).st_mode):
out.add(os.path.relpath(path, self.root))
return outChecked
Scope: both findings cite added lines in a full review; neither is excluded by the revert, mirror or incremental rules.
Silent failure: directory results reach key assembly and its final directory validation.
Validation: the in-memory macro fixture reproduces the omission; the proposed fix retains the dependency. Injected enumeration and stat failures return empty sets. The inline suggestion replaces an added line, and the modified module parses.
Escape catalog: C1–C4 do not match the retained findings. No ledger lessons apply. The diff changes tooling, with no engine hot path.
Notes
The full CLI suite was not rerun; validation used read-only and in-memory probes.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
| _, shape = build_view(text, test) | ||
| raw: list = [] | ||
| _module_units(shape, 0, len(shape), (), raw, []) | ||
| return {k: shape[a:b] for k, (kind, _, _, a, b, _, _) in enumerate(raw) if kind == "macro_rules!"} |
There was a problem hiding this comment.
Macro arguments can construct paths absent from structural edges; let parameterized bodies trigger the existing opaque-owner bound.
| return {k: shape[a:b] for k, (kind, _, _, a, b, _, _) in enumerate(raw) if kind == "macro_rules!"} | |
| return {k: shape[a:b] for k, (kind, _, _, a, b, _, _) in enumerate(raw) | |
| if kind == "macro_rules!" and not re.search(r"\$\s*(?!crate\b)[A-Za-z_]\w*", shape[a:b])} |
|
Addressed both MUST_FIX findings in
FAIL-first: the new public CLI regressions failed on the reviewed head in all three cases (macro stale The prior head's actual GitHub T0 is green (38/0 red, check-recipes798s), but is not claimed for this correction. Complete current-head two-core T0 is running; new-head CI and incremental review are requested. No band, assertion, timeout or safety detector was relaxed. |
There was a problem hiding this comment.
Since the last review:
- Macro argument bounds: still open for an identifier containing U+0301 at tools/recipes.py:3674.
- Directory enumeration/stat errors: fixed at tools/recipes.py:1121.
Verdict: MUST_FIX: A valid macro parameter still hides a called source file from reusable green keys.
Must fix
1. Require the fixed $crate:: tokens
tools/recipes.py:3674 A metavariable named crate + U+0301 + x passes this filter: Python's \b matches before the combining mark. Consider a dependency declaring mod hidden;, defining macro_rules! call { ($cratéx:ident) => { $cratéx::run() }; }, and invoking call!(hidden) from pub fn run(). A selected binary calling dep::run() executes hidden::run(), but the graph omits crates/dep/src/hidden.rs from key inputs. An in-memory probe confirmed that changing this file leaves the key unchanged under closure scope, with no never-skip reason.
Fix this before recording further reusable green results. Require :: after the fixed token and add "crate\u0301x" to the parameter cases in tools/recipes-key-test.py:405. This replacement retains the missing input and still accepts fixed $crate:: paths.
def _source_macro_bodies(text: str, test: bool) -> dict[int, str]:
"""Lexed bodies with only fixed $crate:: dollar paths, indexed like rust_facts."""
_, shape = build_view(text, test)
raw: list = []
_module_units(shape, 0, len(shape), (), raw, [])
return {k: shape[a:b] for k, (kind, _, _, a, b, _, _) in enumerate(raw)
if kind == "macro_rules!" and not re.search(r"\$(?!\s*crate\s*::)", shape[a:b])}Keep the existing @functools.cache decorator.
Checked
Scope: the retained kind A finding cites an added line in the incremental diff.
Silent failure: directory enumeration and child-stat exceptions reach the named error boundary in KeyContext.parts.
Validation: the supplied module and 모듈 cases retain the called input; crate\u0301x does not. The replacement retains all three. The inline suggestion replaces an added line and the modified module parses.
Escape catalog: C1–C4 do not match. No ledger lessons apply. The diff changes tooling, with no engine hot path.
Notes
dryer and crapper did not run because no Rust file changed. The full CLI suite and Rust compilation were not run; validation used code inspection and in-memory probes without the persistent cache.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
| raw: list = [] | ||
| _module_units(shape, 0, len(shape), (), raw, []) | ||
| return {k: shape[a:b] for k, (kind, _, _, a, b, _, _) in enumerate(raw) | ||
| if kind == "macro_rules!" and not re.search(r"\$(?!\s*crate\b)", shape[a:b])} |
There was a problem hiding this comment.
Python's \b accepts crate + U+0301 + x here, omitting the called file from key inputs. Require the fixed $crate:: tokens.
| if kind == "macro_rules!" and not re.search(r"\$(?!\s*crate\b)", shape[a:b])} | |
| if kind == "macro_rules!" and not re.search(r"\$(?!\s*crate\s*::)", shape[a:b])} |
|
Addressed the remaining MUST_FIX in Added The directory-error correction is unchanged. Complete current-head two-core T0 is running with unchanged CI flags/bounds. Superseded-head runs were cancelled, not represented as final-head passes. |
There was a problem hiding this comment.
Since the last review:
- Macro argument bounds: fixed at tools/recipes.py:3674. The filter requires the fixed
$crate::tokens. - Directory enumeration/stat errors: remain fixed at tools/recipes.py:1121.
Verdict: CLEAN: The stricter token filter closes the reported Unicode parameter hole and preserves conservative key inputs.
Checked
Duplicates: 0 new functions, types or constants; no new duplication. No dryer pairs were available.
Complexity: this increment changes one predicate and extends one test case; no complexity diagnostics ran.
Silent failure: 1 lookup-miss path followed through both callers. Rejected macro bodies retain owner and forward-dependency inputs.
Tests: both changed modules parse. Six isolated checks of the production regex pass: all three parameter names are rejected and fixed $crate:: paths are accepted. The old regex accepts the combining-mark parameter. The extended CLI regression asserts both rerun status and hidden-file inclusion.
Gates: no pins, thresholds or test cases were removed or relaxed.
Escape catalog: C1–C4 do not match. No engine hot path changed.
Notes
dryer and crapper did not run because no Rust file changed. The full CLI suite and Rust compilation were not run.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
|
Final verification for
The macro regression covers ASCII, non-ASCII, and combining-mark metavariable names; fixed
|
|
This branch needs a rebase before it can merge. The repository only allows rebase merges, and the merge commits in the branch stop GitHub from replaying it on main. I'm force-pushing one commit on top of current main that carries the same final changes, with the authorship kept, and will merge it once the checks pass. (AI 코딩 에이전트가 작성한 코멘트이며, 내용은 제가 확인했습니다.) |
f4e1bbd to
29dd913
Compare
There was a problem hiding this comment.
Verdict: MUST_FIX: Unicode macro names can leave changed executable code outside the ledger key.
Must fix
1. Preserve conservative inputs for Unicode macro names
tools/recipes.py:3462 In a dependency containing mod hidden;, macro_rules! 실행 { () => { crate::hidden::run() }; } and pub fn run() { 실행!(); }, the ASCII macro matchers miss the definition and invocation. This guard returns opaque=False.
A boxed Cargo recipe calling dep::run() then omits hidden.rs from Graph.key_inputs. Changing the helper's behavior leaves the retained-input digest unchanged. The key uses closure scope with no never-skip guard, so an existing green record permits a stale skip. Independent in-memory production-code probes confirmed the omission and the fix. Fixing this boundary now prevents unsafe green records from accumulating.
Replace line 3462 with:
opaque or not shape.isascii() or bool(re.search(r"(?<![\w:>\]])::|r#[A-Za-z_]", shape)),Checked
- Duplicates: the proposed fix adds one guard and no new abstraction.
- Complexity: diagnostics report no changed Rust functions.
- Silent failure: followed the omitted input through key assembly and ledger lookup; closure scope and never-skip checks do not prevent this case.
- Tests: the ASCII control retains the helper; the Unicode case omits it; the exact suggested edit retains it and makes the helper edit change the digest. The replacement parses as valid Python. Existing Unicode regressions vary metavariable names, leaving macro names uncovered.
- Gates: the retained finding requests no gate adjustment.
- Escape catalog: C1–C4 do not apply to this finding. No engine hot path is involved.
Notes
Dryer and crapper did not run because no Rust file changed. The filesystem-based CLI suite was not run; verification used in-memory production-code probes.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
| calls = frozenset(match.group(1) for match in _MACRO_PATH_CALL.finditer(shape)) | ||
| return KeySyntax( | ||
| frozenset(re.findall(r"\bextern\s+crate\s+([A-Za-z_]\w*)", shape)), | ||
| opaque or bool(re.search(r"(?<![\w:>\]])::|r#[A-Za-z_]", shape)), |
There was a problem hiding this comment.
Unicode macro names bypass the ASCII resolver and omit called helpers from ledger keys. Retain the conservative owner bound for non-ASCII syntax.
| opaque or bool(re.search(r"(?<![\w:>\]])::|r#[A-Za-z_]", shape)), | |
| opaque or not shape.isascii() or bool(re.search(r"(?<![\w:>\]])::|r#[A-Za-z_]", shape)), |
|
해당 문제는 제가 수정해서 리베이스 후 머지하겠습니다. |
|
I pushed one commit on top of the squashed head to address the review finding: a macro whose name is not ASCII (for example (AI 코딩 에이전트가 작성한 코멘트이며, 내용은 제가 확인했습니다.) |
There was a problem hiding this comment.
Since the last review: must-fix 1 is fixed at tools/recipes.py:3462. Unicode macro names now retain conservative owner and forward-dependency inputs.
Verdict: CLEAN: The new commits close the input omission and extend the regression to detect it.
Checked
- Duplicates: 0 new definitions; the existing regression is extended. No dryer pairs were available.
- Complexity: one Boolean guard is added. No changed Rust functions were reported.
- Silent failure: 1 omitted-input path followed. The new guard sets
opaque=True; the existing fallback retains the owner's compilation inputs and forward dependencies. The regression asserts calledrun, unrelatedskip, andhidden.rspresence. - Tests: isolated production syntax helpers pass for all four regression inputs and three fixed-body Unicode macro names, including a combining mark. Removing
not shape.isascii()loses opaque detection for the fixed-body cases. Unicode comments and literals leave the guard inactive. Both changed Python files parse. - Gates: no thresholds or pins moved; existing test cases remain.
- Escape catalog: C1–C4 do not match the new commits. No engine hot path changed.
Notes
Dryer and crapper did not run because no Rust file changed. Validator verification used isolated syntax probes and static input-path tracing; the filesystem CLI suite was not run.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
|
@Burntgogi Thanks for the contribution. The review is done, so I'm merging this. |
Current head: review correction
f4e1bbdThe initial replacement-head GitHub T0 passed 38 units / 0 red,
check-recipes798s under the unchanged1200s bound (run40006511533, merge-tree headerb9006e7f). Its full review found two safety defects, now corrected inf4e1bbd7a1ae5104e2c6418c737d58ff2c52e143:$crate::excludes that definition from the resolved-body safety lookup. Both existing callers retain the conservative owner/forward-dependency bound rather than guessing argument substitution, independent of metavariable identifier spelling.os.walk's error callback and unsuppressed childos.stat; failures reach the existing named key-error boundary instead of publishing an incomplete file set.New actual CLI regressions failed on
dc928a65in three cases: a called macro argument's behavior change incorrectly stayedskip, and enumeration/stat errors emitted accepted keys. Both new test methods now pass. A separately compiled Rust macro consumer changedhidden1→hidden2with size/mtime preserved, returning calledrun/ unrelatedskip; a native dangling directory-child symlink produced a namederrorkey without injection.Additional valid-name boundary:
$모듈:identreproduced the same staleskiponf04d1c9. The final token-based guard fixes it without an ASCII-only identifier assumption. The expanded regression and existing source-macro cases pass (three selected test methods), and a separately compiled Unicode-macro consumer again producedhidden1→hidden2, calledrun/ unrelatedskip. The superseded f04d1c9 and 773c0bb local full runs were cancelled; no complete-pass claim is made for them. The complete run below is on the current head.The next review exposed the
crate\u0301xcombining-mark boundary: Python\bis not a Rust identifier boundary.f4e1bbdnow requires the exact fixed$crate::tokens, preserving the cache decorator. The same CLI regression covers ASCII, non-ASCII, and combining-mark names; the combining case failed before and passes after. A real compiled combining-mark consumer producedhidden1→hidden2, calledrun/ unrelatedskip, with source size/mtime preserved.docs/contrib/local-check.mdnow states these bounds. Complete current-head two-core T0 passed with CI flags (-C target-cpu=x86-64-v3): 38 units / 0 red, wall 1421s,check-recipes1070s, unchanged1200s unit bound; 146 blocks ran, 0 green-key skips,227 gate recipes /0failures. The actual posted current-head review is CLEAN / APPROVED. Current-head GitHub CI passed: 38 units /0red, wall 1396s,check-recipes1073s under the unchanged1200s unit bound; run40013462690, actual merged checkout041833a6, AMD EPYC7763 runner. Clippy also passed. These are current-head results, distinct from the initial replacement baseline below. The prior baseline results below are not relabelled as this head.just pre-reviewagain exited75, no Claude CLI, nothing reviewed locally. No check/deadline/coverage was weakened.Replaces #587 at the requested review handoff. The old PR reached the automatic-review cap; this new branch retains its full implementation and fixes, then adds measured CI hot-path reductions. No review limit or gate is bypassed.
Change
Closes #529.
Graph.inputsremains the broad compilation/affected/narrow/release bound. New ledger-specificGraph.key_inputsuses uncut structural Reach, not the profile-pruned runtime view, and closes recipe dependencies separately. The v2 key format intentionally invalidates old green keys once.Mandatory inputs remain: the selected target's module/root sources, build scripts/helpers/literals/build dependencies, proc-macro compilation closures, manifest views/globals, dep-info, scripts and explicit file/directory reads. Broad never-skip/tree-scope safety detectors are unchanged.
targets,whyandgapsuse/report the ledger view where appropriate.Compiled invocations of resolved source macros add structural roots even in otherwise unreached modules, so generated startup code and implicit impls retain transitive helpers. Qualified source calls reuse the existing expansion edges. Generated imports, nested expansions and attributes conservatively bound the invoking owner; shadowed or unknown calls remain opaque. Nonstandard
#[path]modules participate in shared implicit-impl rules.Opaque macro expansion conservatively retains its owner's compilation and forward-dependency bounds. Compiled runtime-active owners are scanned for startup attributes (including nested
cfg_attr), unused imports/explicit crate links, and generated/foreign-link obligations. A selected Rust module's filename need not end in.rs. Ambiguous generated includes and foreign linkage retain broad inputs. This does not claim arbitrary proc-macro filesystem completeness.Persistent structural cache
tools/bloomery/reach_cache.pystores the complete structural facts/nodes/edges/rules/indexes as private JSON under~/.cache/bloomery/reach/<checkout-id>/graph.json, not per-recipe reach lists or green verdicts. Code, metadata, source corpus/enumeration, symlink referents and observed reads/probes are content checked independently of git/mtime. Fixed schema, checksum and index validation precede hydration; input stability is rechecked before publication/key output. Corrupt/foreign/stale caches rebuild. Imported code is bound to its actual loaded code marker; cache data is never executable code.A measured publication hotspot used millions of token-sized Python writes; publication now uses the standard C JSON encoder with one write, preserving the JSON protocol.
Current performance cutover
The private snapshot format is now 2 (the ledger key format remains v2). Only structural state is persisted: the recomputable
_resolvedlookup memo is omitted, and hydration discards any eager pre-snapshot resolver results. Nodes, edges, facts, rules, dispatch/index validation and fresh code/source/metadata/read/probe checks remain. Obsolete validation clauses for the omitted memo were removed; no persisted structural validation was skipped.The exact full
key_self_testprofile before this cache-format cutover passed every assertion and recorded 1,938,101,399 calls; encoding accounted for 228 cumulative seconds. A separate real-tree field probe identified 299,230 resolver-memo entries / 75,153,569 encoded bytes. This cutover removes that derived data rather than raising deadlines or dropping coverage.Verified prior baseline (
dc928a65)Current main
2a7005b8aa1bffb269129a984ee18503ca24cfbeis integrated. Exact head:dc928a659cea60f462ebd11f78a5c3d8e719debe.CI failure and bounded correction
The old head's GitHub T0 ended 38 units / 1 red:
check-recipeshit its unchanged 1200s limit (rc124); all other units passed. I did not treat the earlier local green result as that CI's result.The additional change removes avoidable work without weakening any cache/input check:
Development cProfile on the same pre-integration
b407365corpus reduced total calls 148,677,863 → 92,811,152, and cold snapshot encoder calls 6,974,181 → 2,584,263. These are bounded development probes, not a calibrated CI speed claim or measurements relabelled onto later main.Exercised correctness and complete local T0
recipes.py keyemitted the samegate-samplerkey andscope=closure (31 files, 0 directories)before/after.LC_ALL=C PYTHONDONTWRITEBYTECODE=1 \ RUSTFLAGS='-C target-cpu=x86-64-v3' \ taskset -c 2,3 bash tools/contrib-check.sh --tier t038 units / 0 red, wall 1475s.
check-recipes: 1073s, 146 blocks executed / 0 green-key skips, 227 gate recipes / 0 failures, including the full registered public key/ledger CLI suite. The per-unit limit remains 1200s. Run header:dc928a65, not an uncommitted or previous-head run.The inherited regressions still cover reached/unreached inputs, macro/implicit startup conservatism, absolute/raw paths, non-
.rsCargo roots, selected/default/inherited profiles and all mandatory read/cache safety boundaries. Their earlier fail-first and compiled shell/Rust consumer evidence remains linked from #587; it is not falsely described as recompiled in this performance-only follow-up.docs/contrib/local-check.mddescribes the retained codec and lexer contracts. Throwaway profilers/smoke drivers and the baseline-only worktree were removed after preserving output.just pre-reviewon this committed head exited 75, no Claude CLI on PATH; nothing reviewed locally. New-head GitHub CI and a full fresh review are required. No NVIDIA execution or engine-performance claim; no timeout, detector, assertion, selector, numeric band or coverage was relaxed.