Skip to content

fix: audit remediation priorities 3-9#137

Merged
lzehrung merged 9 commits into
mainfrom
fix/audit-priority-3-5-6
Jun 21, 2026
Merged

fix: audit remediation priorities 3-9#137
lzehrung merged 9 commits into
mainfrom
fix/audit-priority-3-5-6

Conversation

@lzehrung

@lzehrung lzehrung commented Jun 21, 2026

Copy link
Copy Markdown
Owner

Summary

Completes audit remediation checklist items 3–9 on top of the already-merged C1–C3 work.

Priority 3 — H1/H2 transitive BFS

  • Depth-aware re-enqueue with copy-on-write reasons
  • Order-independence regression tests

Priority 5 — P5/P6/P7 unbounded caches

  • Shared lruMap helper + LRU caps for module/resolution/lazy-symbol caches
  • Project-scoped memory-cache clearing when disk caches close

Priority 6 — SQLite schema migration

  • Read on-disk schema_version and explicit v1→v2 migrator
  • Regression tests preserving v1 data and rejecting future schema downgrades

Priority 7 — U1/U2–U4 usability

  • Strict decimal integer parsing (/^-?\d+$/)
  • Validated --scope, --ref-context, --symbols-detailed-scope
  • Value options no longer consume following flags (--threads --json rejected)
  • Agent outputs sort before truncation with bounded reference collection

Priority 8 — P1/P2 performance

  • Iterative Tarjan in graphs/cycles.ts (avoids deep-graph stack overflow)
  • Indexed cycle-edge metadata collection avoids per-SCC full-edge rescans
  • Memoized adjacency via WeakMap in graphs/adjacency.ts

Priority 9 — S1–S6 structural (scoped)

  • S3: shared ECMAScript blocks in languages/definitions/jsFamily.ts
  • S4: shared impact cycle mappers in impact/reportShared.ts
  • S5: shared include-root helpers in util/includeRoots.ts
  • S6: extracted call-compatibility hint/reset helpers from callCompatibility.ts
  • Deferred: full duplicates.ts / cli.ts god-module splits (S1/S2) — too large for this PR

Test plan

  • npm run check
  • Targeted vitest suites for explain, graph, cache, SQLite, and call compatibility

lzehrung added 3 commits June 21, 2026 13:40
- H1/H2: make transitive BFS depth-aware with copy-on-write reasons
- P5/P6/P7: add LRU caps and teardown for module/resolution caches
- P7: trim unloaded lazy symbol modules and add clear()
- SQLite: read on-disk schema_version and migrate v1 to v2 explicitly

Adds regression tests for order-independent transitive impact, cache
eviction/clear, lazy module trimming, and schema version upgrades.
- U2-U4: strict integer parsing, enum validation, and value-option guards
- U1: sort agent-tool dependency results before truncation
- P1/P2: iterative Tarjan and memoized graph adjacency
- S3-S6 (scoped): jsFamily shared blocks, includeRoots util, cycle mappers,
  and callCompatibility reset helper

Adds regression tests for CLI validation, graph algorithms, include roots,
and deterministic agent-tool ordering. Updates audit checklist items 7-9.
Remove the upstream findReferences cap in collectReferenceContext so
displayed references are chosen after sorting, not from iteration order.
Add a regression test and clarify checklist item 9 defers S1/S2 splits.
Comment thread src/agent/explain.ts
const result = await findReferences(snapshot.index, { def }, { context: "line" });
if (result.status !== "ok") return emptyReferenceContext();

const references = result.references

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: Unbounded findReferences call may cause performance issues for widely-referenced symbols.

Removing maxReferences means findReferences can return an arbitrarily large result set before the local sort-and-truncate logic runs. The previous code bounded collection at Math.max(referenceLimit, snippetLimit) + 1, which prevented excessive memory use for symbols with thousands of references. Consider adding a generous finite cap (e.g., maxReferences: Math.max(referenceLimit, snippetLimit) * 10) so the sort-before-truncate fix remains safe at scale.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

Comment thread src/indexer/build-cache/module-cache.ts Outdated
}

export function closeDiskCacheDatabase(projectRoot: string, opts?: BuildOptions): void {
clearMemoryCache();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: closeDiskCacheDatabase clears the global memoryCache, evicting entries for ALL projects.

memoryCache is a module-level singleton keyed by ${projectRoot}::${file}. Calling clearMemoryCache() inside closeDiskCacheDatabase(projectRoot) closes one project's disk cache but invalidates memory cache entries for every other project too. In multi-project usage this is an overly broad side effect. Consider clearing only entries whose key starts with the matching projectRoot, or moving the global clear to an explicit teardown function.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

Comment thread src/util/lruMap.ts Outdated
@@ -0,0 +1,21 @@
export function lruMapGet<K, V>(map: Map<K, V>, key: K): V | undefined {
const value = map.get(key);
if (value === undefined) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SUGGESTION: lruMapGet skips LRU refresh when a Map entry's value is literally undefined.

If a caller ever stores undefined as a legitimate value, lruMapGet returns early without re-inserting the key at the end of the Map iteration order. That entry would incorrectly be evicted first despite being the most recently accessed. Current callers don't hit this, but the helper should handle it correctly.

Suggested change
if (value === undefined) {
if (!map.has(key)) {
return undefined;
}

Reply with @kilocode-bot fix it to have Kilo Code address this issue.

Comment thread src/agent/explain.ts
const result = await findReferences(snapshot.index, { def }, { context: "line" });
if (result.status !== "ok") return emptyReferenceContext();

const references = result.references

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: Unbounded findReferences call may cause performance issues for widely-referenced symbols.

Removing maxReferences means findReferences can return an arbitrarily large result set before the local sort-and-truncate logic runs. The previous code bounded collection at Math.max(referenceLimit, snippetLimit) + 1, which prevented excessive memory use for symbols with thousands of references. Consider adding a generous finite cap (e.g., maxReferences: Math.max(referenceLimit, snippetLimit) * 10) so the sort-before-truncate fix remains safe at scale.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

Comment thread src/indexer/build-cache/module-cache.ts Outdated
}

export function closeDiskCacheDatabase(projectRoot: string, opts?: BuildOptions): void {
clearMemoryCache();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: closeDiskCacheDatabase clears the global memoryCache, evicting entries for ALL projects.

memoryCache is a module-level singleton keyed by ${projectRoot}::${file}. Calling clearMemoryCache() inside closeDiskCacheDatabase(projectRoot) closes one project's disk cache but invalidates memory cache entries for every other project too. In multi-project usage this is an overly broad side effect. Consider clearing only entries whose key starts with the matching projectRoot, or moving the global clear to an explicit teardown function.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

Comment thread src/util/lruMap.ts Outdated
@@ -0,0 +1,21 @@
export function lruMapGet<K, V>(map: Map<K, V>, key: K): V | undefined {
const value = map.get(key);
if (value === undefined) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SUGGESTION: lruMapGet skips LRU refresh when a Map entry's value is literally undefined.

If a caller ever stores undefined as a legitimate value, lruMapGet returns early without re-inserting the key at the end of the Map iteration order. That entry would incorrectly be evicted first despite being the most recently accessed. Current callers don't hit this, but the helper should handle it correctly.

Suggested change
if (value === undefined) {
if (!map.has(key)) {
return undefined;
}

Reply with @kilocode-bot fix it to have Kilo Code address this issue.

@kilo-code-bot

kilo-code-bot Bot commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: 7 Issues Found | Recommendation: Address before merge

2 previous issues were resolved in this revision:

  • src/cli/context.ts line 380: isCliOptionValueToken now allows dash-prefixed values that are not supported short flags.
  • src/util/lruMap.ts line 9: Replaced as V type assertion with non-null assertion !.

Overview

Severity Count
CRITICAL 0
WARNING 4
SUGGESTION 3
Issue Details (click to expand)

WARNING

File Line Issue
src/agent/explain.ts 743 Unbounded findReferences call may cause performance issues
src/indexer/build-cache/module-cache.ts N/A closeDiskCacheDatabase clears the global memoryCache
src/agent/explain.ts N/A When referenceLimit and snippetLimit are both 0, collectSnippets may behave unexpectedly
src/sqlite/schema.ts 194 ensureSchema() creates/updates tables before checking for required migrations

SUGGESTION

File Line Issue
src/util/lruMap.ts N/A lruMapGet skips LRU refresh when a Map entry is re-promoted
src/util/includeRoots.ts N/A restrictGraphToIncludeRoots() normalizes node IDs via normalizePath
src/indexer/build-cache/module-cache.ts N/A In the memory-cache path, lruMapGet() refreshes the entry's LRU position
Files Reviewed (3 files)
  • src/cli/context.ts - resolved: allows dash-prefixed option values; no new issues
  • src/util/lruMap.ts - resolved: replaced as V with !; no new issues
  • tests/cli-options-validation.test.ts - added coverage for dash-prefixed values and short-flag rejection

Fix these issues in Kilo Cloud

Previous Review Summaries (6 snapshots, latest commit 252e901)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 252e901)

Status: 3 Issues Found | Recommendation: Address before merge

1 previous issue was resolved in this revision:

  • src/indexer/build-cache/module-cache.ts now deletes stale memory cache entries on signature mismatch instead of refreshing their LRU position via lruMapGet().

Overview

Severity Count
CRITICAL 0
WARNING 2
SUGGESTION 1
Issue Details (click to expand)

WARNING

File Line Issue
src/agent/explain.ts 743 Unbounded findReferences call may cause performance issues
src/indexer/build-cache/module-cache.ts N/A closeDiskCacheDatabase clears the global memoryCache

SUGGESTION

File Line Issue
src/util/lruMap.ts N/A lruMapGet skips LRU refresh when a Map entry is re-promoted
Files Reviewed (2 files)
  • src/indexer/build-cache/module-cache.ts — stale entry eviction on signature mismatch (resolved); closeDiskCacheDatabase clearing global memoryCache still active
  • tests/module-cache-lru.test.ts — added coverage for stale signature eviction

Previous review (commit 71eb429)

Status: 3 Issues Found | Recommendation: Address before merge

2 previous issues were resolved in this revision:

  • src/agent/explain.ts now returns early when both referenceLimit and snippetLimit are zero, avoiding an unnecessary findReferences call.
  • src/sqlite/schema.ts now checks the on-disk schema version before creating tables.

Overview

Severity Count
CRITICAL 0
WARNING 2
SUGGESTION 1
Issue Details (click to expand)

WARNING

File Line Issue
src/agent/explain.ts 743 Unbounded findReferences call may cause performance issues
src/indexer/build-cache/module-cache.ts N/A closeDiskCacheDatabase clears the global memoryCache

SUGGESTION

File Line Issue
src/util/lruMap.ts N/A lruMapGet skips LRU refresh when a Map entry is re-promoted
Files Reviewed (4 files)
  • src/agent/explain.ts - early return added for zero limits (resolved); unbounded findReferences still active
  • src/sqlite/schema.ts - version check moved before table creation (resolved)
  • tests/agent-explain.test.ts - added coverage for zero-limit early return
  • tests/sqlite.test.ts - added assertion that no tables are created when version is too high

Previous review (commit 4402af0)

Status: No Issues Found | Recommendation: Merge

The previous includeRoots.ts normalization concern has been addressed in this revision: restrictGraphToIncludeRoots now normalizes both from and to.path endpoints on retained edges, keeping the returned graph consistent.

Files Reviewed (2 files)
  • src/util/includeRoots.ts
  • tests/include-roots.test.ts

Previous review (commit 66f6744)

Status: No Issues Found | Recommendation: Merge

The previous includeRoots.ts normalization concern has been addressed in this revision: restrictGraphToIncludeRoots now normalizes both from and to.path endpoints on retained edges, keeping the returned graph consistent.

Files Reviewed (2 files)
  • src/util/includeRoots.ts
  • tests/include-roots.test.ts

Previous review (commit 4a6812b)

Status: No Issues Found | Recommendation: Merge

All 3 issues from the previous review have been addressed in the latest commits:

  • src/agent/explain.tsfindReferences now uses a bounded collectionLimit instead of an unbounded call.
  • src/indexer/build-cache/module-cache.tscloseDiskCacheDatabase now clears only the closed project's entries via clearMemoryCacheForProject.
  • src/util/lruMap.tslruMapGet now correctly refreshes LRU order for entries with undefined values.
Files Reviewed (23 files)
  • src/agent/explain.ts
  • src/cli/options.ts
  • src/graphs/cycles.ts
  • src/impact/callCompatibility.ts
  • src/indexer/build-cache/module-cache.ts
  • src/indexer/incremental-plan.ts
  • src/indexer/navigation.ts
  • src/sqlite/schema.ts
  • src/util/lruMap.ts
  • src/util/lazySymbols.ts
  • docs/plans/2026-06-21-codegraph-technical-audit.md
  • tests/agent-explain.test.ts
  • tests/cli-options-validation.test.ts
  • tests/git-revision-safety.test.ts
  • tests/graph-queries.test.ts
  • tests/impact-call-compatibility/parse-resilience.test.ts
  • tests/impact-transitive-order.test.ts
  • tests/include-roots.test.ts
  • tests/incremental-plan.test.ts
  • tests/lazy-symbols.test.ts
  • tests/lru-map.test.ts
  • tests/module-cache-lru.test.ts
  • tests/sqlite.test.ts

Previous review (commit be0b2c7)

Status: 3 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 2
SUGGESTION 1
Issue Details (click to expand)

WARNING

File Line Issue
src/agent/explain.ts 737 Unbounded findReferences call may cause performance/memory issues for widely-referenced symbols after removing the maxReferences cap.
src/indexer/build-cache/module-cache.ts 113 closeDiskCacheDatabase clears global memoryCache for ALL projects, not just the one being closed.

SUGGESTION

File Line Issue
src/util/lruMap.ts 3 lruMapGet does not refresh LRU order when the stored value is literally undefined.
Files Reviewed (20 files)
  • src/agent/explain.ts - 1 issue (unbounded findReferences after cap removal)
  • src/agent/orient.ts - no issues
  • src/cli.ts - no issues
  • src/cli/context.ts - no issues
  • src/cli/graph.ts - no issues
  • src/cli/impact.ts - no issues
  • src/cli/inspect.ts - no issues
  • src/cli/options.ts - no issues
  • src/graphs/adjacency.ts - no issues
  • src/graphs/cycles.ts - no issues
  • src/impact/callCompatibility.ts - no issues
  • src/impact/reportCompact.ts - no issues
  • src/impact/reportFull.ts - no issues
  • src/impact/reportShared.ts - no issues
  • src/impact/transitive.ts - no issues
  • src/indexer/build-cache.ts - no issues
  • src/indexer/build-cache/module-cache.ts - 1 issue (overly broad clearMemoryCache in disk cache close)
  • src/languages/definitions/javascript.ts - no issues
  • src/languages/definitions/jsFamily.ts - no issues
  • src/languages/definitions/typescript.ts - no issues
  • src/sqlite/schema.ts - no issues
  • src/util/includeRoots.ts - no issues
  • src/util/lazySymbols.ts - no issues
  • src/util/lruMap.ts - 1 issue (undefined value handling in LRU refresh)
  • src/util/resolution.ts - no issues
  • tests/agent-explain.test.ts - no issues
  • tests/agent-tools-order.test.ts - no issues
  • tests/cli-options-validation.test.ts - no issues
  • tests/graph-adjacency-cache.test.ts - no issues
  • tests/graph-cycles-iterative.test.ts - no issues
  • tests/graph-queries.test.ts - no issues
  • tests/impact-transitive-order.test.ts - no issues
  • tests/include-roots.test.ts - no issues
  • tests/lazy-symbols.test.ts - no issues
  • tests/lru-map.test.ts - no issues
  • tests/module-cache-lru.test.ts - no issues
  • tests/resolution-cache-lru.test.ts - no issues
  • tests/sqlite.test.ts - no issues

Fix these issues in Kilo Cloud


Reviewed by kimi-k2.6-20260420 · Input: 23.1K · Output: 13.6K · Cached: 67.8K

@kilo-code-bot

kilo-code-bot Bot commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: 3 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 2
SUGGESTION 1
Issue Details (click to expand)

WARNING

File Line Issue
src/agent/explain.ts 737 Unbounded findReferences call may cause performance/memory issues for widely-referenced symbols after removing the maxReferences cap.
src/indexer/build-cache/module-cache.ts 113 closeDiskCacheDatabase clears global memoryCache for ALL projects, not just the one being closed.

SUGGESTION

File Line Issue
src/util/lruMap.ts 3 lruMapGet does not refresh LRU order when the stored value is literally undefined.
Files Reviewed (20 files)
  • src/agent/explain.ts - 1 issue (unbounded findReferences after cap removal)
  • src/agent/orient.ts - no issues
  • src/cli.ts - no issues
  • src/cli/context.ts - no issues
  • src/cli/graph.ts - no issues
  • src/cli/impact.ts - no issues
  • src/cli/inspect.ts - no issues
  • src/cli/options.ts - no issues
  • src/graphs/adjacency.ts - no issues
  • src/graphs/cycles.ts - no issues
  • src/impact/callCompatibility.ts - no issues
  • src/impact/reportCompact.ts - no issues
  • src/impact/reportFull.ts - no issues
  • src/impact/reportShared.ts - no issues
  • src/impact/transitive.ts - no issues
  • src/indexer/build-cache.ts - no issues
  • src/indexer/build-cache/module-cache.ts - 1 issue (overly broad clearMemoryCache in disk cache close)
  • src/languages/definitions/javascript.ts - no issues
  • src/languages/definitions/jsFamily.ts - no issues
  • src/languages/definitions/typescript.ts - no issues
  • src/sqlite/schema.ts - no issues
  • src/util/includeRoots.ts - no issues
  • src/util/lazySymbols.ts - no issues
  • src/util/lruMap.ts - 1 issue (undefined value handling in LRU refresh)
  • src/util/resolution.ts - no issues
  • tests/agent-explain.test.ts - no issues
  • tests/agent-tools-order.test.ts - no issues
  • tests/cli-options-validation.test.ts - no issues
  • tests/graph-adjacency-cache.test.ts - no issues
  • tests/graph-cycles-iterative.test.ts - no issues
  • tests/graph-queries.test.ts - no issues
  • tests/impact-transitive-order.test.ts - no issues
  • tests/include-roots.test.ts - no issues
  • tests/lazy-symbols.test.ts - no issues
  • tests/lru-map.test.ts - no issues
  • tests/module-cache-lru.test.ts - no issues
  • tests/resolution-cache-lru.test.ts - no issues
  • tests/sqlite.test.ts - no issues

Fix these issues in Kilo Cloud

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Completes technical-audit remediation items 3–9 by tightening correctness/determinism (impact BFS + agent outputs), bounding in-memory caches, introducing explicit SQLite schema versioning/migration tests, improving CLI argument validation, and addressing performance issues in cycle detection/adjacency building with targeted refactors/shared helpers.

Changes:

  • Adds explicit SQLite schema_version reading + v1→v2 migration path with regression tests.
  • Introduces shared LRU map helper and applies caps/clearing to previously unbounded caches (resolution/module/lazy-symbols).
  • Improves determinism/perf: order-stable reference iteration, sort-before-truncate for agent outputs, iterative Tarjan SCC detection, and memoized graph adjacency.

Reviewed changes

Copilot reviewed 46 out of 46 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/sqlite.test.ts Adds regression coverage for SQLite schema migration + rejecting future schema versions.
tests/resolution-cache-lru.test.ts Verifies resolveSpecifier caching behavior and explicit cache clearing.
tests/module-cache-lru.test.ts Validates module memory-cache eviction and project-scoped clearing on disk-cache close.
tests/lru-map.test.ts Adds unit tests for lruMapGet/lruMapSet eviction and refresh behavior.
tests/lazy-symbols.test.ts Adds coverage for LazyProjectIndex.clear() and trimming unloaded entries.
tests/incremental-plan.test.ts Formatting-only adjustments to existing dependent-collection tests.
tests/include-roots.test.ts Adds tests for include-roots normalization/membership and graph restriction.
tests/impact-transitive-order.test.ts Adds order-independence and copy-on-write reasons regression tests for transitive impact.
tests/impact-call-compatibility/parse-resilience.test.ts Removes stray whitespace lines (no behavior change).
tests/graph-queries.test.ts Updates edge-iteration expectations and adds SCC-heavy cycle-reporting regression.
tests/graph-cycles-iterative.test.ts Adds long-chain cycle test to guard against recursive stack overflow.
tests/graph-adjacency-cache.test.ts Adds test ensuring graphAdjacencyFor memoizes per-graph adjacency.
tests/git-revision-safety.test.ts Minor assertion formatting adjustments.
tests/cli-options-validation.test.ts Adds tests for strict integer parsing, enum validation, and value-option guarding.
tests/agent-tools-order.test.ts Verifies dependency results are sorted before truncation in agent tool output.
tests/agent-explain.test.ts Adds regression test ensuring references are sorted before truncation in explain output.
src/util/resolution.ts Caps resolveSpecifier cache via LRU helper.
src/util/lruMap.ts Introduces shared LRU get/set helpers for capped Map caches.
src/util/lazySymbols.ts Adds clear() and trims unloaded module entries; clamps maxCached to non-negative.
src/util/includeRoots.ts Introduces shared include-roots helpers and graph restriction utility.
src/sqlite/schema.ts Adds schema version read/write + migration logic and future-version rejection.
src/languages/definitions/typescript.ts Deduplicates ECMAScript structure blocks via shared jsFamily definitions.
src/languages/definitions/jsFamily.ts Adds shared ECMAScript block/split-point definitions for JS/TS family.
src/languages/definitions/javascript.ts Switches to shared ECMAScript structure blocks/split points.
src/indexer/navigation.ts Makes verified-reference scan deterministic by sorting file iteration.
src/indexer/incremental-plan.ts Removes trailing whitespace (no behavior change).
src/indexer/build-cache/module-cache.ts Adds bounded per-process memory cache with per-project clearing + LRU behavior.
src/indexer/build-cache.ts Re-exports clearMemoryCache for cache management.
src/impact/transitive.ts Reworks transitive BFS to track best depth and avoid shared-array mutation.
src/impact/reportShared.ts Extracts shared cycle mapping helpers for full/compact report generation.
src/impact/reportFull.ts Uses shared cycle mapping helper for display mapping.
src/impact/reportCompact.ts Uses shared cycle mapping helper for compact mapping.
src/impact/callCompatibility.ts Extracts reusable hint builder + reset helper to simplify main flow.
src/graphs/cycles.ts Replaces recursive Tarjan with iterative version + indexes incoming edges for SCC reporting.
src/graphs/adjacency.ts Memoizes adjacency index per graph instance via WeakMap.
src/drift/snapshot.ts Replaces local include-root filtering with shared include-roots utilities.
src/cli/options.ts Implements strict integer parsing + validated enum option parsers.
src/cli/inspect.ts Uses shared restrictGraphToIncludeRoots implementation.
src/cli/impact.ts Validates --scope and --ref-context via new parsers.
src/cli/graph.ts Validates --symbols-detailed-scope via new parser.
src/cli/context.ts Prevents value-options from consuming following flags; allows negative integer tokens.
src/cli.ts Uses shared include-roots membership helper.
src/agent/orient.ts Uses shared include-roots normalization/membership helpers.
src/agent/explain.ts Increases reference collection limit to enable stable sort-before-truncate output.
src/agent-tools.ts Sorts dependency entries before truncation for deterministic agent output.
docs/plans/2026-06-21-codegraph-technical-audit.md Updates audit plan/checklist formatting and marks addressed items as complete.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/util/includeRoots.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 46 out of 46 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

src/indexer/build-cache/module-cache.ts:255

  • lruMapGet() refreshes the memory-cache entry order even when the cache lookup is a miss due to a signature mismatch. That can keep stale entries “hot” and evict genuinely useful ones, reducing hit rate under churn.

Consider only refreshing LRU order when the entry is actually used (sig matches).

  if (mode === "memory") {
    const entry = lruMapGet(memoryCache, memoryCacheKey(projectRoot, file));
    if (entry && entry.sig === sig) {
      if (cacheEnabled && cacheReport) cacheReport.hits += 1;
      return entry.mod;
    }
    if (cacheEnabled && cacheReport) cacheReport.misses += 1;
    return null;

Comment thread src/agent/explain.ts Outdated
Comment on lines 735 to 737
const collectionLimit = Math.max(referenceLimit, snippetLimit) * AGENT_EXPLAIN_REFERENCE_COLLECTION_MULTIPLIER;
const result = await findReferences(snapshot.index, { def }, { context: "line", maxReferences: collectionLimit });
if (result.status !== "ok") return emptyReferenceContext();
Comment thread src/sqlite/schema.ts
Comment on lines +181 to +187
export const ensureSchema = (db: SqliteDatabase) => {
db.pragma("journal_mode = WAL");
db.pragma("synchronous = NORMAL");
db.pragma("temp_store = MEMORY");
db.pragma("foreign_keys = ON");

db.exec(`

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 46 out of 46 changed files in this pull request and generated 1 comment.

Comment thread src/indexer/build-cache/module-cache.ts Outdated
Comment on lines 248 to 252
if (mode === "memory") {
const entry = memoryCache.get(file);
const entry = lruMapGet(memoryCache, memoryCacheKey(projectRoot, file));
if (entry && entry.sig === sig) {
if (cacheEnabled && cacheReport) cacheReport.hits += 1;
return entry.mod;

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 46 out of 46 changed files in this pull request and generated 2 comments.

Comment thread src/cli/context.ts
Comment thread src/util/lruMap.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 46 out of 46 changed files in this pull request and generated no new comments.

@lzehrung lzehrung merged commit e503a57 into main Jun 21, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants