Skip to content

docs: promote #83 and #71 to Tier 0 in backlog#470

Merged
carlos-alm merged 9 commits intomainfrom
docs/backlog-promote-tier0
Mar 16, 2026
Merged

docs: promote #83 and #71 to Tier 0 in backlog#470
carlos-alm merged 9 commits intomainfrom
docs/backlog-promote-tier0

Conversation

@carlos-alm
Copy link
Contributor

Summary

Rationale

These two items deliver the highest immediate impact on agent experience and graph accuracy without requiring Rust porting or TypeScript migration. brief (#83) improves the context agents actually see via hooks; type inference (#71) prevents hallucinated "no callers" for method calls through typed variables.

Test plan

  • Verify BACKLOG.md renders correctly on GitHub (Tier 0 table, items removed from Tier 1h/1i)
  • No code changes — docs only

Expand the deferred Phase 3 items into a dedicated phase after
TypeScript Migration with detailed descriptions for each sub-item:
event-driven pipeline, unified engine strategy, subgraph export
filtering, transitive confidence, query caching, config profiles,
pagination standardization, and plugin system.

Renumber subsequent phases 5-9 → 6-10 with all cross-references
updated.
Add openRepo() utility that accepts an injected Repository instance or
falls back to SQLite, enabling tests to bypass the filesystem entirely.

- Add openRepo(dbPath, opts) to src/db/connection.js
- Make findMatchingNodes and buildDependencyGraph polymorphic (accept
  db or Repository via instanceof check)
- Refactor triageData, sequenceData, communitiesData to use openRepo
- Convert triage, sequence, communities test fixtures to createTestRepo()
  fluent builder (sequence dataflow tests stay on SQLite)
- Mark ROADMAP 3.13 InMemoryRepository migration item complete

Impact: 10 functions changed, 11 affected
Add new Phase 4 covering the port of JS-only build phases to Rust:
- 4.1-4.3: AST nodes, CFG, dataflow visitor ports (~587ms savings)
- 4.4: Batch SQLite inserts (~143ms)
- 4.5: Role classification & structure (~42ms)
- 4.6: Complete complexity pre-computation
- 4.7: Fix incremental rebuild data loss on native engine
- 4.8: Incremental rebuild performance (target sub-100ms)

Bump old Phases 4-10 to 5-11 with all cross-references updated.
Benchmark evidence shows ~50% of native build time is spent in
JS visitors that run identically on both engines.
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 16, 2026

Greptile Summary

Despite being titled a docs-only PR, this change bundles two distinct bodies of work: (1) a significant ROADMAP.md restructuring that inserts a new Phase 4 — Native Analysis Acceleration and renumbers all downstream phases, and (2) a substantial code refactoring that migrates communities, sequence, triage, symbol-lookup, and dependency from direct better-sqlite3 handles to a Repository abstraction via a new openRepo() helper — along with matching test rewrites that replace temp-file SQLite fixtures with the new InMemoryRepository-based createTestRepo() builder.

Key observations:

  • openRepo() in connection.js is clean and well-guarded with an instanceof Repository type check
  • Most feature files (communities.js, triage.js) migrate cleanly to the new pattern
  • sequence.js introduces a leaky abstraction: it imports SqliteRepository directly and accesses the internal repo.db property to run raw prepared statements for dataflow annotations, bypassing the repository interface — the dataflow queries should be surfaced through the Repository base class
  • The createTestRepo() builder has no .churn() method, so the triage "sort by churn" test now trivially passes on all-zero values rather than exercising real ordering logic
  • The roadmap renumbering is thorough and consistent (all cross-references and the dependency graph were updated)

Confidence Score: 4/5

  • Safe to merge with minor follow-up work recommended for the leaky abstraction in sequence.js and the churn test gap.
  • The Repository migration pattern is sound and the bulk of the changes are correct. The two issues are style/coverage concerns rather than bugs: the repo.db access in sequence.js will work correctly today but creates a maintenance hazard, and the churn sort test passes but no longer tests real behavior. Neither issue blocks merging.
  • src/features/sequence.js (leaky repo.db access) and tests/integration/triage.test.js (churn test coverage gap)

Important Files Changed

Filename Overview
src/db/connection.js Adds openRepo() helper that returns a { repo, close } pair from either an injected Repository instance or a SQLite DB path. Validates the injected value with an instanceof Repository guard.
src/features/sequence.js Migrated to openRepo pattern but introduces a leaky abstraction: imports SqliteRepository directly and accesses repo.db to run raw SQL for dataflow annotations. Dataflow queries should be moved into the Repository interface rather than bypassing it.
src/graph/builders/dependency.js Adapted to accept a dbOrRepo union by adding instanceof Repository dispatch throughout. The minConfidence path falls back to getCallEdges() (all edges) when a Repository is passed; a comment acknowledges the limitation.
tests/integration/communities.test.js Migrated from temp-file SQLite fixtures to createTestRepo() / InMemoryRepository. Tests simplified significantly, fixture logic preserved. No coverage gaps.
tests/integration/triage.test.js Migrated to createTestRepo() cleanly, but the churn sort test is now a no-op since InMemoryRepository returns churn=0 for all nodes — real churn ordering is no longer tested.

Sequence Diagram

sequenceDiagram
    participant Caller as Feature (communities / sequence / triage)
    participant openRepo as openRepo()
    participant Repo as Repository (interface)
    participant SQLite as SqliteRepository
    participant InMem as InMemoryRepository

    Caller->>openRepo: openRepo(dbPath, opts)
    alt opts.repo is set
        openRepo-->>Caller: { repo: opts.repo, close: noop }
    else open SQLite
        openRepo->>SQLite: new SqliteRepository(db)
        openRepo-->>Caller: { repo: SqliteRepository, close: db.close }
    end

    Caller->>Repo: repo.findCallees(id)
    Repo-->>Caller: callee rows

    Note over Caller,SQLite: sequence.js dataflow path only
    Caller->>SQLite: instanceof SqliteRepository check
    Caller->>SQLite: repo.db.prepare(...) — raw SQL
    SQLite-->>Caller: dataflow rows
Loading

Comments Outside Diff (2)

  1. src/features/sequence.js, line 176-177 (link)

    Leaky abstraction — repo.db bypasses the Repository interface

    sequence.js now imports SqliteRepository directly and reaches into its internal db property to run raw prepared statements for dataflow annotations. This ties a feature module to a specific repository implementation:

    import { SqliteRepository } from '../db/repository/sqlite-repository.js';
    ...
    if (hasTable && repo instanceof SqliteRepository) {
      const db = repo.db;
      const getReturns = db.prepare(`SELECT d.expression FROM dataflow d ...`);
      const getFlowsTo  = db.prepare(`SELECT d.expression FROM dataflow d ...`);
    }

    The consequence is that dataflow annotations are silently skipped for any non-SqliteRepository caller (e.g. a future RemoteRepository or a test double). The proper fix is to surface the two queries through the Repository base interface — something like getReturnsForNode(nodeId) and getFlowsToForNode(nodeId) — so every implementation can handle them and the feature code stays decoupled from the storage layer.

    If adding the methods to the interface is out of scope for this PR, at minimum a // TODO comment should note this as a known tech-debt item rather than a structural decision.

  2. tests/integration/triage.test.js, line 161-163 (link)

    Churn sort test is now a no-op

    The previous fixture inserted varied churn values (src/handler.js → 50 commits, src/formatter.js → 20, src/math.js → 2), so "sort by churn" exercised real ordering. The new fixture has no .churn() builder method and InMemoryRepository returns churn=0 for every node. The test comment acknowledges this ("verify no errors"), but it means churn-based ranking is no longer tested at all — a >= assertion over identical zeros will trivially pass even if the sort logic is broken.

    Consider either:

    1. Adding a .churn(file, count) method to TestRepoBuilder / InMemoryRepository so churn data can be seeded and the assertion can verify real ordering, or
    2. Keeping one small SQLite fixture (similar to the retained dataflow test) specifically for the churn sort case.

Last reviewed commit: 09dd0a7

**Depends on:** 6.4 (`risk_score`, `complexity_notes`), 6.5 (module summaries)
**Depends on:** 7.4 (`risk_score`, `complexity_notes`), 7.5 (module summaries)

### 10.6 -- Auto-generated Docstrings
Copy link
Contributor

Choose a reason for hiding this comment

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

Missed section renumber

Phase 10 was renumbered to Phase 11 throughout the file, but this subsection heading was left as 10.6 instead of 11.6. All other subsections under Phase 11 (11.1–11.5) were updated correctly.

Suggested change
### 10.6 -- Auto-generated Docstrings
### 11.6 -- Auto-generated Docstrings

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in ed1d34d. The subsection heading was renumbered from 10.6 to 11.6 — it belongs under Phase 11 (Interactive Visualization & Advanced Features), not Phase 10.

Comment on lines 80 to +88
if (minConfidence != null) {
edges = db
.prepare("SELECT source_id, target_id FROM edges WHERE kind = 'calls' AND confidence >= ?")
.all(minConfidence);
if (isRepo) {
// minConfidence filtering not supported by Repository — fall back to getCallEdges
edges = dbOrRepo.getCallEdges();
} else {
edges = dbOrRepo
.prepare("SELECT source_id, target_id FROM edges WHERE kind = 'calls' AND confidence >= ?")
.all(minConfidence);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

minConfidence silently ignored for Repository path

When dbOrRepo is a Repository and minConfidence is set, the code falls back to getCallEdges() with no filtering — returning all call edges regardless of confidence. The comment acknowledges this, but callers (e.g. viewer.js, export.js) pass minConfidence expecting it to filter low-confidence edges. This means Repository-backed graphs will include edges that would be excluded in the SQLite path.

Consider filtering in JS after fetching:

Suggested change
if (minConfidence != null) {
edges = db
.prepare("SELECT source_id, target_id FROM edges WHERE kind = 'calls' AND confidence >= ?")
.all(minConfidence);
if (isRepo) {
// minConfidence filtering not supported by Repository — fall back to getCallEdges
edges = dbOrRepo.getCallEdges();
} else {
edges = dbOrRepo
.prepare("SELECT source_id, target_id FROM edges WHERE kind = 'calls' AND confidence >= ?")
.all(minConfidence);
}
if (isRepo) {
// Repository has no minConfidence param — filter in JS
edges = dbOrRepo.getCallEdges().filter(e => e.confidence == null || e.confidence >= minConfidence);
} else {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is roadmap documentation only — no code changes in this PR. The minConfidence silent-ignore issue for the Repository path was already fixed in PR #462 (merged). The roadmap text here describes future work, not current behavior.

Merge origin/main into docs/backlog-promote-tier0, keeping the
PR's phase numbering (Phase 4 = Native Analysis Acceleration).
Incorporated 'DX & onboarding' addition from main into Phase 6
summary. Fixed missed subsection renumber: 10.6 -> 11.6
(Auto-generated Docstrings is in Phase 11, not 10).
@carlos-alm
Copy link
Contributor Author

@greptileai

Keep main's cross-reference to 5.7 for the dependency audit step
instead of duplicating the deliverable.
@carlos-alm carlos-alm merged commit f77a338 into main Mar 16, 2026
13 checks passed
@carlos-alm carlos-alm deleted the docs/backlog-promote-tier0 branch March 16, 2026 11:12
@github-actions github-actions bot locked and limited conversation to collaborators Mar 16, 2026
@carlos-alm
Copy link
Contributor Author

@greptileai

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant