Repository navigation
Description
Problem and priority
Suggested priority: P1. Graph caching is effective, but a warm graph is not a cheap warm rule.
A 1.1.0 diagnostic on 10,000 sparse constant-reference sources retrieved the same cached graph in ~4.2ms. Twenty repetitions of one nonempty, passing boundary rule still took 4.44s and allocated ~7,006,461 objects (~222ms per check). This is one diagnostic, not a representative 20-distinct-rule suite or a universal regression threshold.
Inspected repeated work
DependOnFileCondition#perform_check obtains the cached graph, then:
- FileRuleSupport.selected_nodes calls project_to_nodes, rebuilding incoming/outgoing collections, ordering labels and constructing ProjectedNodes.
- project_edges(per_internal_edge) rebuilds mapping/grouping structures and ProjectedEdges.
- The assertion filters those structures for the specific rule.
Related source: node projection, edge projection.
Some rule work is necessary; rebuilding graph-invariant views is the candidate to remove. Rubyzen's reusable parsed project and ArchSpec's evaluator illustrate why whole-suite reuse matters, but do not establish equal analysis semantics.
Reproduction and measurement
Extend benchmark/study from #92 rather than add a parallel benchmark system:
- Prebuild one graph with imports_and_constants.
- Execute one, twenty identical, and twenty genuinely different file/layer/slice policies.
- Include passing, forbidden-dependency and empty-selector controls.
- Measure cold analysis, cold-plus-whole-suite, warm-per-rule, allocations and retained/peak memory separately.
- If comparing competitors, reuse their project/model too; do not compare our warm model with another tool's fresh CLI for each rule.
Design to evaluate
Prefer analysis-owned immutable node/internal-edge indexes or a private analysis-session view bundle. Keep common projections/assertions pure; orchestration may reuse their immutable outputs.
Evaluate eager core views versus lazy bounded storage. Eagerly calculating every optional projection could worsen single-rule startup/memory. Do not memoize arbitrary custom mapper closures: they can be stateful, lack stable identity or depend on call-specific options.
If a private identity-based cache is chosen, specify concurrency, lifetime and eviction. It must not retain every past graph/root indefinitely or expose mutable arrays. A process-global unbounded query cache is not the default answer.
No new public fluent sentence should be necessary: existing project_files(...).in_path(...).should_not.depend_on_files...check remains unchanged.
Acceptance criteria
- Exact structured violations/evidence, ordering, both moods and the empty-test guard match the current implementation.
- Self-edge node presence and internal/external projection differences remain correct.
- clear_cache, global clearing, edited-source rebuilds, different roots/modes/exclusions and CLI command resets never reuse stale views.
- Custom projections, filters and logging still work without hidden filesystem work in pure projections/assertions.
- Stable views are shared within one immutable analysis; selective policies still apply their own filters correctly.
- Repeated checks show a substantial repeatable allocation reduction and useful whole-suite improvement, not merely a faster isolated hash lookup.
- Cold single-rule work, memory and thread/fiber isolation have explicit regression checks.
- Baseline identity and JSON/report contracts remain unchanged.
Related: #11, #46, #92 and #100. Content-validated watch sessions/persistent caches are separate lifecycle decisions; do not silently change the documented snapshot contract.
Activity
TristanKruse commentedon Nov 24, 2026
Continuing after #100 merged in #107. This is the next P1 item in the reviewed order: #100 → #101 → #102 → #106 → #104 → #103 → #105. All are feasible; #103/#105 need explicit bounded semantic designs, not guesses about runtime Ruby behavior.
For #101, attach three lazy immutable projection slots to the existing cached analysis entry, rather than a new graph-keyed global query cache. Share nodes/internal/external edges across file/layer checks, and leave custom closures, selectors, assertions, logging and cycle enumeration per check. Existing explicit source-snapshot invalidation remains unchanged.
Regression tests now cover exact structured results/evidence/order, snapshot invalidation and GC lifetime, concurrency, modes/exclusions, callbacks and logging. Paired baseline/candidate studies use merged #100 as baseline and identical benchmark/study harnesses, with graph-only/single/repeated/varied suites, forbidden/empty controls, allocation counts and retained-memory tradeoffs. A separate PR is being prepared; no release is being published.
TristanKruse commentedon Nov 25, 2026
Implemented in #108, pending maintainer review/merge (not released).
The existing snapshot lifetime is unchanged; no new unbounded query cache or custom-closure memoization. #102 remains next in the reviewed priority order, followed by #106, #104, #103, #105 (the latter semantic capabilities need bounded design work first).