Skip to content

feat: richer symbol metadata — signatures, JSDoc, type members, call graph#19

Merged
SutuSebastian merged 9 commits intomainfrom
feat/richer-symbol-metadata
Apr 8, 2026
Merged

feat: richer symbol metadata — signatures, JSDoc, type members, call graph#19
SutuSebastian merged 9 commits intomainfrom
feat/richer-symbol-metadata

Conversation

@SutuSebastian
Copy link
Copy Markdown
Contributor

@SutuSebastian SutuSebastian commented Apr 8, 2026

Summary

Enriches the structural index with significantly more queryable data, eliminating the need for agents to read source files for common structural questions.

  • Richer signatures — generic type params, return type annotations, extends/implements clauses on functions, types, interfaces, classes
  • Enum membersmembers TEXT column on symbols with JSON array of {name, value} entries
  • JSDoc extractiondoc_comment TEXT column on symbols with cleaned comment text (preserves @deprecated, @param, etc.)
  • Type members table — new type_members table indexing properties and methods of interfaces and object-literal type aliases (name, type, optional, readonly)
  • Const literal valuesvalue TEXT column on symbols for string/number/boolean/null literals, as const, simple template literals
  • Symbol nestingparent_name TEXT column on symbols tracking scope (class methods → class name, nested functions → parent function). Class methods, properties, and getters extracted as individual symbols
  • Call graph — new calls table with function-scoped, per-file-deduped call edges (caller → callee). Includes caller_scope for qualified disambiguation (e.g. UserService.run vs OrderService.run). Captures this.method() calls. Enables fan-in/fan-out, "who calls X?", dead code detection
  • Performance pass — cached scope string in parser, hoisted hot-path regex, charCodeAt JSDoc gap scan, cached getProjectRoot() in loops, eliminated redundant getAllFileHashes call in incremental path, batch DELETE for deleted files, hoisted fileURLToPath/getProjectRoot() in worker-pool, BATCH_SIZE 100→500

Schema changes

  • symbols: added members, doc_comment, value, parent_name columns
  • New table: type_members (file_path, symbol_name, name, type, is_optional, is_readonly)
  • New table: calls (file_path, caller_name, caller_scope, callee_name)
  • SCHEMA_VERSION bumped to 2

Benchmarks

merchant-dashboard-v2 (1,653 files, 24K symbols, 14K calls):

Mode Time
Full rebuild (warm) ~640ms
Incremental (no-op) ~200ms

Test plan

  • 76 new parser tests (signatures, enums, JSDoc, type members, const values, nesting, call graph)
  • All 157 tests pass
  • Format, lint, typecheck clean
  • Docs updated (architecture.md, agent skill, cursor rule, template skill)

Summary by CodeRabbit

  • New Features

    • Added call-graph analysis to identify function-to-function relationships and most-called functions.
    • Enhanced symbol metadata with JSDoc documentation, const literal values, and parent-scope relationships.
    • Added type member extraction for interfaces and object-literal types.
  • Performance

    • Optimized batch processing and worker initialization.

Signatures now include generic type parameters (`<T extends Base>`),
return type annotations (`: Promise<void>`), and class/interface
heritage (`extends`, `implements`). Enum members are extracted into a
new `members TEXT` column as JSON.

Benchmarked on a 1,653-file React/TS codebase: 973 functions gain
return types, 873 symbols gain generics, 291 enum member values
captured across 50 enums. Index time +7% (negligible), DB size
unchanged.
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 8, 2026

Warning

Rate limit exceeded

@SutuSebastian has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 6 minutes and 3 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 6 minutes and 3 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c0e10f84-a153-4d72-8bff-3a17a45ef261

📥 Commits

Reviewing files that changed from the base of the PR and between a3c5dde and 5d5d725.

📒 Files selected for processing (2)
  • docs/architecture.md
  • src/db.ts
📝 Walkthrough

Walkthrough

Adds richer symbol metadata and call/type-member extraction: schema version bumped to 2 with new members, doc_comment, value, parent_name columns; new calls and type_members tables; parser extracts JSDoc, enum members, const literals, scope parent_name, type members, and call-graph edges; indexing/adapters persist them.

Changes

Cohort / File(s) Summary
Database Schema & Storage
src/db.ts, src/parsed-types.ts
Bump SCHEMA_VERSION to 2; extend symbols with members, doc_comment, value, parent_name; add calls and type_members tables, indexes, insert helpers, exported row types; increase batch size to 500.
Parser & Extraction
src/parser.ts, src/parser.test.ts
Parser now returns typeMembers and calls; adds JSDoc extraction/cleaning, enum members, const value extraction, scope/parent_name tracking, class/type-member extraction, call-graph emission with deduplication; large tests added.
Adapters
src/adapters/types.ts, src/adapters/builtin.ts
ParsedFilePayload and parseTsJs extended to include typeMembers and calls in the parsing payload.
Indexing & Stats
src/application/index-engine.ts, src/application/run-index.ts, src/application/types.ts
Indexing now conditionally inserts type_members and calls; fetchTableStats and emptyStats() updated to include new table counts; IndexTableStats augmented; incremental indexing returns existingPaths.
Runtime & Worker Improvements
src/runtime.ts, src/worker-pool.ts
Optimized path-segment checking in isPathExcluded; hoisted project-root and worker-path resolution, and Bun detection to reduce per-worker overhead.
Docs, Skills & Rules
docs/architecture.md, .agents/skills/codemap/SKILL.md, templates/agents/skills/codemap/SKILL.md, .agents/rules/codemap.mdc, .changeset/richer-symbol-metadata.md
Documentation and agent skill/rule templates updated to describe new schema columns/tables and added SQL query examples/triggers for type-members, consts, doc-based deprecations, parent-scoped lookups, and call-graph queries.

Sequence Diagram(s)

sequenceDiagram
  participant CLI as Client
  participant Parser as Parser
  participant Adapter as Adapter
  participant Indexer as IndexEngine
  participant DB as SQLite

  CLI->>Parser: parse file
  Parser-->>Adapter: ExtractedData {symbols, typeMembers, calls, ...}
  Adapter->>Indexer: submit ParsedFilePayload (includes typeMembers,calls)
  Indexer->>DB: insertSymbols / insertTypeMembers / insertCalls
  DB-->>Indexer: OK
  Indexer-->>CLI: indexing result / stats (includes type_members, calls)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

I nibble at comments, signatures unfurl,
Members and calls hop into the burrow,
Parent names nestle where methods reside,
Enums and consts lined up side by side,
A rabbit cheers: richer maps make code fields grow! 🐇

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 9.68% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: richer symbol metadata including signatures, JSDoc, type members, and call graph extraction.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/richer-symbol-metadata

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 8, 2026

🦋 Changeset detected

Latest commit: 5d5d725

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@stainless-code/codemap Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Add doc_comment column to symbols (3,084 documented symbols on benchmark
repo) and new type_members table for interface/type-alias properties
(12,052 members extracted). Agents can now query type shapes and symbol
documentation without reading files.

SCHEMA_VERSION bumped to 2.
Captures string, number, boolean, null, negative numbers, `as const`,
and simple template literals. 615 values extracted on benchmark repo.
Adds parent_name column to symbols for scope tracking. A visitor stack
assigns parent context to nested functions/consts (10,202 nested symbols
on benchmark). Class methods, properties, and getters/setters are now
extracted as individual symbols with parent_name pointing to the class.
New `calls` table tracks which functions call which. Edges are deduped
per file and limited to function-scoped calls (module-level excluded).

Benchmark (merchant-dashboard-v2): 13,804 edges, 2,700 callers,
5,310 callees. Index time unchanged, DB +5MB (23→28MB).
@SutuSebastian SutuSebastian changed the title feat: richer symbol metadata — generics, return types, enum members feat: richer symbol metadata — signatures, JSDoc, type members, call graph Apr 8, 2026
@SutuSebastian SutuSebastian added enhancement New feature or request documentation Improvements or additions to documentation labels Apr 8, 2026
@SutuSebastian SutuSebastian marked this pull request as ready for review April 8, 2026 14:23
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/parser.ts (1)

163-197: ⚠️ Potential issue | 🔴 Critical

Fix scope tracking in multi-declarator variable declarations.

The VariableDeclaration handler pushes all function-valued declarators onto scopeStack before their initializers are visited, but VariableDeclaration:exit only pops those whose names match the current top of the stack. For const a = () => {}, b = () => {}, both are pushed during enter, then only b is popped during exit (since it's the top), leaving a stranded. This corrupts currentParent() for all subsequent symbols, affecting parent_name, call edges, and component/hook attribution for the rest of the file.

Current code (lines 204–219)
    "VariableDeclaration:exit"(node: any) {
      for (const decl of node.declarations) {
        const name = decl.id?.name;
        if (!name) continue;
        const init = decl.init;
        const isArrowOrFn =
          init?.type === "ArrowFunctionExpression" ||
          init?.type === "FunctionExpression";
        if (isArrowOrFn && scopeStack[scopeStack.length - 1] === name) {
          scopeStack.pop();
        }

Track pushed declarators individually or pop them in reverse order during exit to ensure all pushed names are removed.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/parser.ts` around lines 163 - 197, The VariableDeclaration handler is
pushing multiple function-valued declarator names onto scopeStack but
VariableDeclaration:exit only pops when the top matches a single name, leaving
earlier pushed names stranded; update the exit handler (the
"VariableDeclaration:exit" block) to iterate the node.declarations in reverse
order and pop from scopeStack for each declarator whose name matches the current
top until all pushed declarators are removed (or use a per-declaration
pushedNames list stored during enter and pop them in reverse), ensuring
scopeStack and currentParent() are correctly restored for subsequent symbols.
🧹 Nitpick comments (2)
docs/architecture.md (1)

176-190: Document the new class-member kind values.

src/parser.ts now emits method, property, getter, and setter rows for class members, but this schema table still documents only the original six values. Anyone using this page as the schema contract will write filters that miss those symbols.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/architecture.md` around lines 176 - 190, Update the schema docs to
include the new class-member kind values emitted by src/parser.ts: add "method",
"property", "getter", and "setter" to the Kind column description so the table
lists `function`, `const`, `class`, `interface`, `type`, `enum`, `method`,
`property`, `getter`, `setter`; ensure the description clarifies these are used
for class members (e.g., "method, property, getter, setter — class member
symbols") so consumers can write correct filters for class members emitted by
the parser.
templates/agents/skills/codemap/SKILL.md (1)

218-220: Keep the shipped template examples aligned with the authoring skill.

This copy only adds the enum-members lookup, while .agents/skills/codemap/SKILL.md now also documents type_members, doc_comment, value, parent_name, and calls queries. Because codemap agents init installs this file, published users won't see most of the new query surface.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@templates/agents/skills/codemap/SKILL.md` around lines 218 - 220, Update the
shipped template in SKILL.md so it matches the authoring skill by adding the
missing query examples and fields: extend the enum example (the SELECT from
symbols where kind='enum' and name='TransactionStatus') to also show
type_members, doc_comment, value, parent_name and calls columns; include example
results or notes for each of those fields and a brief example query showing how
to select type_members and doc_comment (and value/parent_name/calls) from the
symbols table so the installed template exposes the same query surface as the
authoring skill.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/db.ts`:
- Around line 125-130: The calls table currently stores only caller_name and
conflates same-named callers in a file; add a persistent qualified caller
identity (e.g., caller_key or caller_scope which encodes scope path or
parent+line metadata) and replace or augment caller_name with this column, then
enforce uniqueness/indexing on (file_path, caller_key) and use (file_path,
caller_key, callee_name) for deduping edges; update any creation/insert logic
that writes to calls (and the analogous schema at the other occurrence) to
populate caller_key and to dedupe/idx based on the new qualified key rather than
bare caller_name.

---

Outside diff comments:
In `@src/parser.ts`:
- Around line 163-197: The VariableDeclaration handler is pushing multiple
function-valued declarator names onto scopeStack but VariableDeclaration:exit
only pops when the top matches a single name, leaving earlier pushed names
stranded; update the exit handler (the "VariableDeclaration:exit" block) to
iterate the node.declarations in reverse order and pop from scopeStack for each
declarator whose name matches the current top until all pushed declarators are
removed (or use a per-declaration pushedNames list stored during enter and pop
them in reverse), ensuring scopeStack and currentParent() are correctly restored
for subsequent symbols.

---

Nitpick comments:
In `@docs/architecture.md`:
- Around line 176-190: Update the schema docs to include the new class-member
kind values emitted by src/parser.ts: add "method", "property", "getter", and
"setter" to the Kind column description so the table lists `function`, `const`,
`class`, `interface`, `type`, `enum`, `method`, `property`, `getter`, `setter`;
ensure the description clarifies these are used for class members (e.g.,
"method, property, getter, setter — class member symbols") so consumers can
write correct filters for class members emitted by the parser.

In `@templates/agents/skills/codemap/SKILL.md`:
- Around line 218-220: Update the shipped template in SKILL.md so it matches the
authoring skill by adding the missing query examples and fields: extend the enum
example (the SELECT from symbols where kind='enum' and name='TransactionStatus')
to also show type_members, doc_comment, value, parent_name and calls columns;
include example results or notes for each of those fields and a brief example
query showing how to select type_members and doc_comment (and
value/parent_name/calls) from the symbols table so the installed template
exposes the same query surface as the authoring skill.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 47a97353-916b-4db4-9665-2890eb797feb

📥 Commits

Reviewing files that changed from the base of the PR and between 630c0b4 and a3470d0.

📒 Files selected for processing (14)
  • .agents/rules/codemap.mdc
  • .agents/skills/codemap/SKILL.md
  • .changeset/richer-symbol-metadata.md
  • docs/architecture.md
  • src/adapters/builtin.ts
  • src/adapters/types.ts
  • src/application/index-engine.ts
  • src/application/run-index.ts
  • src/application/types.ts
  • src/db.ts
  • src/parsed-types.ts
  • src/parser.test.ts
  • src/parser.ts
  • templates/agents/skills/codemap/SKILL.md

Comment thread src/db.ts
Comment thread src/parser.ts
…declarator scope fix

- Add caller_scope column to calls table (dot-joined scope path, e.g.
  UserService.run) so same-named methods across classes are no longer
  conflated. Dedup key now uses full scope path.
- Handle this.foo() calls in CallExpression (emitted as this.methodName).
- Fix multi-declarator scope corruption: VariableDeclaration:exit now
  iterates in reverse so const a = () => {}, b = () => {} correctly
  pops both scopes.
- Document new class-member kind values (method, property, getter,
  setter) in architecture.md.
- Sync template SKILL.md with authoring skill query examples.
@SutuSebastian
Copy link
Copy Markdown
Contributor Author

@coderabbitai Re: the outside-diff Critical finding on src/parser.ts lines 163–197 (multi-declarator VariableDeclaration scope corruption) — this is fixed in e525e06. VariableDeclaration:exit now iterates declarations in reverse order so all pushed scopes are correctly popped. Test coverage added.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 8, 2026

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
git show e525e06 -- src/parser.ts

Length of output: 2801


@SutuSebastian: Confirmed — the fix in e525e06 is correct. Iterating node.declarations in reverse on VariableDeclaration:exit ensures the scope stack is unwound in proper LIFO order (last-pushed scope is popped first), so for a pattern like const a = () => {}, b = () => {} both scopes are correctly popped without corrupting the stack. The additional caller_scope (dot-joined scope path) and this.method() handling in the same commit are solid improvements on top of that. Thanks for the thorough fix and added test coverage!


🧠 Learnings used
Learnt from: CR
Repo: stainless-code/codemap PR: 0
File: .cursor/rules/no-bypass-hooks.mdc:0-0
Timestamp: 2026-04-07T08:12:50.196Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Ensure hook dependencies are correctly specified in dependency arrays to avoid stale closures and unintended side effects

If you found this review helpful, would you consider giving us a shout-out on X?

Thank you for using CodeRabbit!

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/db.ts (1)

8-12: ⚠️ Potential issue | 🟡 Minor

Update the schema-version policy comment to match current behavior.

The header comment still says to keep pre-release schema at 1, but Line 12 now uses 2. This can cause incorrect future versioning decisions.

Suggested doc fix
- * Pre-release: keep at **1** until the first npm release — do not bump for DDL
- * tweaks; run `--full` locally after pulling. After v1.0, bump in lockstep with
- * `createTables` / `createIndexes` when the on-disk schema changes.
+ * Bump in lockstep with `createTables` / `createIndexes` whenever on-disk schema
+ * changes. `createSchema()` rebuilds automatically on version mismatch.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/db.ts` around lines 8 - 12, The header comment describing pre-release
schema versioning is out of sync with the exported constant SCHEMA_VERSION (now
2); update the comment above SCHEMA_VERSION to reflect the current policy (e.g.,
“Pre-release: keep at 2 until the first npm release” or change the wording to
avoid a hardcoded number and reference SCHEMA_VERSION) so future contributors
won't be misled; locate the comment immediately above the exported constant
SCHEMA_VERSION and adjust the wording accordingly.
🧹 Nitpick comments (2)
src/db.ts (1)

188-190: Add a caller_scope index for disambiguated call-graph lookups.

calls now disambiguates by caller_scope, but current indexes only cover caller_name, callee_name, and file_path. Queries keyed by scope will degrade as the table grows.

Suggested index addition
     CREATE INDEX IF NOT EXISTS idx_calls_caller ON calls(caller_name, file_path);
+    CREATE INDEX IF NOT EXISTS idx_calls_scope ON calls(caller_scope, file_path, callee_name);
     CREATE INDEX IF NOT EXISTS idx_calls_callee ON calls(callee_name, file_path);
     CREATE INDEX IF NOT EXISTS idx_calls_file ON calls(file_path);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/db.ts` around lines 188 - 190, Add an index on the calls.caller_scope
column to support disambiguated call-graph lookups; update the SQL DDL where
existing indexes are created (see existing CREATE INDEX IF NOT EXISTS
idx_calls_caller, idx_calls_callee, idx_calls_file) by adding a new statement
such as creating idx_calls_caller_scope on calls(caller_scope) (or a
multi-column index like idx_calls_caller_scope ON calls(caller_scope,
caller_name, file_path) if queries filter by scope plus name/file) so that
queries using caller_scope are covered and remain performant as the calls table
grows.
docs/architecture.md (1)

314-316: Expand the parser extraction checklist for completeness.

This section now covers signatures and enum members, but it still omits other newly extracted outputs (doc_comment, value, parent_name, plus call/type-member extraction). Adding them here would keep the parser checklist self-contained.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/architecture.md` around lines 314 - 316, Update the parser extraction
checklist paragraph (the bullets listing "Symbols", "Enum members", "Imports")
to also enumerate the newly extracted outputs: include "doc_comment"
(docblock/JSDoc associated with symbols), "value" (literal/initializer values
for variables/enum members), "parent_name" (the enclosing class/module name for
nested members), and "calls/type-members" (extracted call expressions and type
member references). Amend the bullets so each item mirrors the existing format
(give example shapes like JSON or type annotations) and reference the existing
entries "Functions", "Enum members", and "Imports" to keep the checklist
self-contained and consistent with the current phrasing.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@src/db.ts`:
- Around line 8-12: The header comment describing pre-release schema versioning
is out of sync with the exported constant SCHEMA_VERSION (now 2); update the
comment above SCHEMA_VERSION to reflect the current policy (e.g., “Pre-release:
keep at 2 until the first npm release” or change the wording to avoid a
hardcoded number and reference SCHEMA_VERSION) so future contributors won't be
misled; locate the comment immediately above the exported constant
SCHEMA_VERSION and adjust the wording accordingly.

---

Nitpick comments:
In `@docs/architecture.md`:
- Around line 314-316: Update the parser extraction checklist paragraph (the
bullets listing "Symbols", "Enum members", "Imports") to also enumerate the
newly extracted outputs: include "doc_comment" (docblock/JSDoc associated with
symbols), "value" (literal/initializer values for variables/enum members),
"parent_name" (the enclosing class/module name for nested members), and
"calls/type-members" (extracted call expressions and type member references).
Amend the bullets so each item mirrors the existing format (give example shapes
like JSON or type annotations) and reference the existing entries "Functions",
"Enum members", and "Imports" to keep the checklist self-contained and
consistent with the current phrasing.

In `@src/db.ts`:
- Around line 188-190: Add an index on the calls.caller_scope column to support
disambiguated call-graph lookups; update the SQL DDL where existing indexes are
created (see existing CREATE INDEX IF NOT EXISTS idx_calls_caller,
idx_calls_callee, idx_calls_file) by adding a new statement such as creating
idx_calls_caller_scope on calls(caller_scope) (or a multi-column index like
idx_calls_caller_scope ON calls(caller_scope, caller_name, file_path) if queries
filter by scope plus name/file) so that queries using caller_scope are covered
and remain performant as the calls table grows.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 15500306-e7e9-434e-b5be-36423651f5a1

📥 Commits

Reviewing files that changed from the base of the PR and between a3470d0 and e525e06.

📒 Files selected for processing (6)
  • .agents/skills/codemap/SKILL.md
  • docs/architecture.md
  • src/db.ts
  • src/parser.test.ts
  • src/parser.ts
  • templates/agents/skills/codemap/SKILL.md
✅ Files skipped from review due to trivial changes (2)
  • src/parser.test.ts
  • templates/agents/skills/codemap/SKILL.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • .agents/skills/codemap/SKILL.md
  • src/parser.ts

- Cache scopeStack.join(".") via scopePush/scopePop helpers
- Hoist hot-path regex literals (RE_COMPONENT, RE_HOOK) to module scope
- Replace findJsDoc gap regex with charCodeAt loop (no .slice())
- Cache getProjectRoot() in getChangedFiles, insertParsedResults, indexFiles
- Eliminate redundant getAllFileHashes call in incremental path
- Batch DELETE for deleted files (single IN() vs N separate DELETEs)
- Hoist fileURLToPath and getProjectRoot() in worker-pool spawn loop
- Increase BATCH_SIZE 100→500 for fewer INSERT round-trips
- Zero-alloc isPathExcluded via charCodeAt segment scan
- Update docs: schema version 1→2, batch size references
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/db.ts (1)

185-190: Consider adding a composite unique index or constraint on calls for deduplication.

The documentation (line 202 in architecture.md) states edges are deduped per (caller_scope, callee) per file. While the parser may handle deduplication before insert, the schema doesn't enforce uniqueness. A unique index would prevent duplicate rows if the same data is inserted twice (e.g., during a retry or concurrent indexing scenario).

🔧 Optional: Add unique constraint for data integrity
-    CREATE INDEX IF NOT EXISTS idx_calls_caller ON calls(caller_name, file_path);
+    CREATE UNIQUE INDEX IF NOT EXISTS idx_calls_unique ON calls(file_path, caller_scope, callee_name);
+    CREATE INDEX IF NOT EXISTS idx_calls_caller ON calls(caller_name, file_path);

Then update insertCalls to use INSERT OR IGNORE or INSERT OR REPLACE:

-    "INSERT INTO calls (file_path, caller_name, caller_scope, callee_name)",
+    "INSERT OR IGNORE INTO calls (file_path, caller_name, caller_scope, callee_name)",
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/db.ts` around lines 185 - 190, Add a schema-level unique constraint/index
to enforce deduplication of call edges (e.g., CREATE UNIQUE INDEX IF NOT EXISTS
idx_calls_unique ON calls(caller_scope, callee_name, file_path)) so the DB
prevents duplicate rows for the same (caller_scope, callee) per file, and update
the insert path (the insertCalls function) to use INSERT OR IGNORE or INSERT OR
REPLACE to avoid errors on conflicts; include this change in the
migration/initialization SQL so existing DBs get the new constraint and handle
potential conflicts during inserts.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/db.ts`:
- Around line 185-190: Add a schema-level unique constraint/index to enforce
deduplication of call edges (e.g., CREATE UNIQUE INDEX IF NOT EXISTS
idx_calls_unique ON calls(caller_scope, callee_name, file_path)) so the DB
prevents duplicate rows for the same (caller_scope, callee) per file, and update
the insert path (the insertCalls function) to use INSERT OR IGNORE or INSERT OR
REPLACE to avoid errors on conflicts; include this change in the
migration/initialization SQL so existing DBs get the new constraint and handle
potential conflicts during inserts.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 788f6cb4-d187-4f84-a123-06e8743de9d5

📥 Commits

Reviewing files that changed from the base of the PR and between e525e06 and a3c5dde.

📒 Files selected for processing (8)
  • .changeset/richer-symbol-metadata.md
  • docs/architecture.md
  • src/application/index-engine.ts
  • src/application/run-index.ts
  • src/db.ts
  • src/parser.ts
  • src/runtime.ts
  • src/worker-pool.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • .changeset/richer-symbol-metadata.md
  • src/application/run-index.ts
  • src/application/index-engine.ts
  • src/parser.ts

… checklist

- Update SCHEMA_VERSION comment to reflect current bump-on-change policy
- Add idx_calls_scope covering index for caller_scope queries
- Expand parser extraction checklist in architecture.md with JSDoc,
  const values, type members, call graph, and symbol nesting
@SutuSebastian SutuSebastian merged commit 53b2c52 into main Apr 8, 2026
9 checks passed
@SutuSebastian SutuSebastian deleted the feat/richer-symbol-metadata branch April 8, 2026 15:19
@github-actions github-actions bot mentioned this pull request Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant