Skip to content

docs: align roadmap and backlog with architecture audit#503

Merged
carlos-alm merged 10 commits intomainfrom
docs/roadmap-audit-alignment
Mar 18, 2026
Merged

docs: align roadmap and backlog with architecture audit#503
carlos-alm merged 10 commits intomainfrom
docs/roadmap-audit-alignment

Conversation

@carlos-alm
Copy link
Contributor

@carlos-alm carlos-alm commented Mar 18, 2026

Summary

  • Add Phase 4 (Resolution Accuracy) with 6 sub-sections: dead role sub-categories, receiver type tracking, interface/trait implementation edges, precision/recall benchmarks, package.json exports resolution, monorepo workspace resolution
  • Reorder phases: TypeScript Migration (Phase 5) before Native Acceleration (Phase 6), per audit recommendation
  • Remove Web UI from Phase 12 (Advanced Features)
  • Add Section 5.9 (Kill List): MI formula removal, Halstead scoping, graph model migration, WASM skip
  • Add Sections 7.10-7.11: Confidence annotations on query output, shell completion
  • Add dual-engine architectural note to Phase 6
  • Backlog: mark ID 45 done, promote IDs 73/74/80 to roadmap, add Tier 1j with 10 audit-identified items (IDs 87-96)

Source

Changes derived from architectural audit (v3.1.4).

Test plan

  • Verify all internal anchor links in ROADMAP.md resolve correctly
  • Verify phase numbering is sequential and consistent throughout
  • Verify backlog IDs don't duplicate existing entries
  • Verify cross-references between ROADMAP and BACKLOG are consistent

Add Phase 4 (Resolution Accuracy) addressing the audit's top priorities:
dead role sub-categories, receiver type tracking, interface/trait
implementation edges, precision/recall benchmarks, package.json exports
resolution, and monorepo workspace support.

Reorder phases: TypeScript Migration (now Phase 5) before Native
Acceleration (now Phase 6), per audit recommendation. Remove Web UI
from Phase 12. Add kill list (5.9), confidence annotations (7.10),
shell completion (7.11), and dual-engine architectural note.

Backlog: mark ID 45 done, promote IDs 73/74/80 to roadmap, add
Tier 1j with 10 audit-identified items (IDs 87-96).
@claude
Copy link

claude bot commented Mar 18, 2026

Claude finished @carlos-alm's task —— View job


PR Review: docs: align roadmap and backlog with architecture audit

Todo List:

  • Read modified documentation files
  • Read referenced architecture audit document
  • Apply 5-phase review process
  • Provide comprehensive review feedback

Root Cause Analysis

Problem Being Solved: Aligning the project roadmap and backlog with findings from an architecture audit (v3.1.4, dated 2026-03-16) to ensure documentation reflects current strategic priorities and identified gaps.

Why This Approach: The changes systematically incorporate audit findings by: (1) reordering phases to prioritize Resolution Accuracy before Native Acceleration, (2) adding Phase 4 with 6 sub-sections addressing accuracy gaps, (3) removing Web UI from advanced features, (4) promoting backlog items to roadmap based on audit recommendations, and (5) adding audit-identified items to the backlog.

Risk Assessment: This is a documentation-only change with no code modification risk. The main risk is documentation consistency - anchor links, cross-references, and phase numbering need to be correct.

Phase 1: Configuration Change Detection ✅

No configuration changes detected - this PR only modifies documentation files.

Phase 2: Test Integrity ✅

No test changes - documentation-only PR with no risk to test integrity.

Phase 3: Code Quality ✅

Documentation-specific quality checks:

Phase numbering consistency: Updated from 11 to 12 phases correctly throughout
Cross-reference integrity: Backlog item promotions (IDs 73, 74, 80) properly marked as "PROMOTED"
New content structure: Phase 4 sections well-organized with 6 sub-sections
Anchor link compatibility: Internal links should resolve correctly post-change
Kill list additions: Section 5.9 properly added with specific items to remove

Minor concerns:

  • The architecture audit document referenced in the PR description (docs/architecture/ARCHITECTURE_AUDIT_v3.1.4_2026-03-16.md) does not exist in the repository, making it impossible to verify the changes align with actual audit findings
  • Some promoted items (IDs 73, 74, 80) maintain their original descriptions in the backlog, which could create confusion about whether they're duplicated

Phase 4: Backlog Compliance

Zero-dep: ✓ — No new runtime dependencies, pure documentation changes

Foundation-aligned: ✓ — Changes align with FOUNDATION.md principles:

  • Preserves local-first approach (P1, P4)
  • Maintains embeddable-first design (P5)
  • Focuses on planning/developing/refactoring over CI/CD (P8)
  • No violations of core principles

Problem-fit: 5 — Directly addresses core problem:

  • Reordering phases prioritizes accuracy improvements that prevent hallucinated dependencies
  • New Phase 4 sections target call graph completeness (receiver tracking, interface implementation)
  • Resolution accuracy improvements directly reduce "missed blast radius" problem
  • Confidence annotations make blind spots visible to agents

Breaking: No — Documentation changes are non-breaking

Tier: 1 (zero-dep ✓ + foundation-aligned ✓)

Phase 5: Documentation Specific Checks

Content accuracy concerns:

  1. Missing audit document: The referenced ARCHITECTURE_AUDIT_v3.1.4_2026-03-16.md doesn't exist, making it impossible to verify alignment
  2. Dependency graph complexity: The ASCII dependency graph is quite complex and may be hard to maintain as phases evolve

Positive aspects:

  1. Clear rationale: Each change includes explanation of why it was made
  2. Systematic approach: Backlog items properly promoted/demoted with clear tracking
  3. Comprehensive scope: Covers roadmap reordering, new sections, backlog updates, and kill list additions

Critical Concerns

None - this is a well-structured documentation update.

Minor Recommendations

  1. Consider adding the referenced audit document to the repository for transparency
  2. Verify all internal anchor links resolve correctly after the restructuring
  3. Consider adding a changelog section documenting these major structural changes

Final Recommendation

  • Rating: ⭐⭐⭐⭐☆ (4/5)
  • Action: APPROVE
  • Reasoning: This is a thoughtful documentation update that improves project planning alignment. The changes are well-structured, systematically implemented, and directly support the tool's core value proposition. While the missing audit document prevents full verification, the changes themselves are internally consistent and beneficial.

The PR successfully addresses the stated goal of aligning roadmap priorities with architectural audit findings, with clear benefits for development planning and stakeholder communication.

The dual-engine strategy is settled — no need for a hedging note.
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Mar 18, 2026

Greptile Summary

This PR aligns the project roadmap and backlog with the v3.1.4 architecture audit, and ships two complementary code changes that enable old native binaries (pre-type-map support) to fall back gracefully to the JS edge builder.

Documentation changes:

  • Inserts Phase 4 (Resolution Accuracy) and reorders TypeScript Migration ahead of Native Acceleration, bumping all later phases by one slot; all Depends on cross-references and the test-criteria table have been updated to match
  • Removes the Web UI section (old Phase 11.1) and adds Phases 7.10 (Confidence Annotations) and 7.11 (Shell Completion)
  • Adds ADR-001 documenting the settled dual-engine architecture and its known incremental-rebuild analysis-data-loss issue
  • Adds Tier 1j to the backlog (IDs 87–96) with PROMOTED annotations for items already committed to the roadmap

Code changes (old-native-binary compatibility):

  • patchNativeResult now initialises typeMap to [] for binaries that predate the type-map feature
  • parseFileAuto / parseFilesAuto backfill typeMap via WASM (parallel Promise.all in the bulk path) and set _typeMapBackfilled = true on affected symbols
  • build-edges.js checks _typeMapBackfilled across all symbols before deciding native vs JS call-edge builder

Issue found:

  • The backfill guard if (extracted?.symbols?.typeMap) is truthy for empty arrays and empty Maps. When the WASM extractor returns no type annotations for a file, _typeMapBackfilled is still set, which causes build-edges.js to fall back to the JS edge builder for the entire build — not just the affected file. The same guard appears in both parseFileAuto and parseFilesAuto; both should check for a non-empty collection before setting the flag.

Confidence Score: 3/5

  • Safe to merge for the docs-only portions; the code changes carry a logic bug that can silently degrade call-edge quality across the entire build for any user with an old native binary whose files have no WASM-detectable types.
  • The documentation restructure is thorough and the previously flagged issues (PROMOTED annotations, Tier 1j header, Phase 4.6/12.2 scope) are resolved. The code logic for the happy path (old native binary + WASM finds types) is correct. However, the falsy-empty guard on the backfilled typeMap means a file with zero WASM type annotations silently sets _typeMapBackfilled=true, forcing the JS edge builder for all files — a build-wide quality regression that would be invisible in CI unless precision/recall benchmarks are exercised on a codebase that mixes typed and untyped files.
  • src/domain/parser.js — the truthy-empty typeMap guard appears in both parseFileAuto and parseFilesAuto and needs the same fix in both locations.

Important Files Changed

Filename Overview
src/domain/parser.js Adds WASM typeMap backfill for old native binaries in both parseFileAuto and parseFilesAuto (using Promise.all for parallel I/O). Logic issue: truthy-empty guard on extracted.symbols.typeMap means files with no WASM type annotations still set _typeMapBackfilled = true, silently forcing the JS edge builder for all files in the build.
src/domain/graph/builder/stages/build-edges.js Adds a typeMapBackfilled guard before using the native call-edge builder — if any symbol has _typeMapBackfilled set, all files fall back to the JS builder. The logic is sound given that the old native edge builder can't consume WASM-format typeMaps, though its scope-of-impact depends on the parser.js backfill flag being set correctly.
docs/architecture/decisions/001-dual-engine-architecture.md New ADR documenting the settled dual-engine (Rust native + JS/WASM) architecture, its rationale, trade-offs, and known issues (analysis data loss on native incremental rebuilds). Well-structured and internally consistent.
docs/roadmap/ROADMAP.md Major restructure: inserts Phase 4 (Resolution Accuracy) and Phase 5 (TypeScript Migration), bumps all subsequent phases by 1-2 slots, removes Web UI (old Phase 11.1), adds Phases 7.10/7.11 and SARIF early-delivery note. All cross-reference "Depends on" lines updated to new numbering; test-criteria table aligned. Previously flagged overlaps and missing scope notes have been addressed.
docs/roadmap/BACKLOG.md Marks ID 45 done, promotes IDs 73/74/80 with strikethrough+PROMOTED annotations, adds Tier 1j (IDs 87–96). Previously flagged issues — missing PROMOTED annotations on 87/89/90/91/93 and the incorrect "All are zero-dep" claim in the Tier 1j header — are addressed per thread replies.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[parseFilesAuto or parseFileAuto] --> B[patchNativeResult]
    B --> C{typeMap empty AND calls exist?}
    C -- No --> G[Return patched, no flag set]
    C -- Yes --> D[wasmExtractSymbols]
    D --> E{extracted.symbols.typeMap truthy?}
    E -- empty array or Map = still TRUE --> H[Set typeMap to empty Map\n_typeMapBackfilled = true BUG]
    E -- non-empty Map or array --> F[Set typeMap to Map\n_typeMapBackfilled = true OK]
    E -- null or undefined --> G
    F --> I[build-edges.js]
    H --> I
    G --> I
    I --> J{any symbol has _typeMapBackfilled?}
    J -- Yes --> K[buildCallEdgesJS for ALL files]
    J -- No --> L[buildCallEdgesNative faster and more accurate]
Loading

Last reviewed commit: "fix: reconcile Phase..."

Comment on lines +177 to +192
### Tier 1j — Audit-identified gaps (from Architecture Audit v3.1.4)

Items identified by the [architectural audit](../../docs/architecture/ARCHITECTURE_AUDIT_v3.1.4_2026-03-16.md) that don't fit existing tiers. All are zero-dep and foundation-aligned.

| ID | Title | Description | Category | Benefit | Zero-dep | Foundation-aligned | Problem-fit (1-5) | Breaking | Depends on |
|----|-------|-------------|----------|---------|----------|-------------------|-------------------|----------|------------|
| 87 | Confidence annotations on query output | Every query output should include resolution statistics: `{ resolved: N, unresolved_method_calls: M, confidence: 0.XX }`. When `fn-impact` shows a blast radius of 5 functions, it should note how many method-dispatch calls may be missing. CLI displays as a footer line; MCP tools include in JSON. Makes the tool honest about its known blind spots instead of presenting precise-looking numbers without qualification. | Embeddability | Agents and users can assess how much to trust a result — a blast radius of 5 with 82% confidence is actionable, while 5 with 40% confidence means "run more analysis". Directly prevents the "missed blast radius" problem by making the gap visible | ✓ | ✓ | 5 | No | — |
| 88 | SCIP/LSP integration for top languages | Use compiler-grade symbol indices from TypeScript (tsc/tsserver), Python (Pyright), Go (gopls), and Rust (rust-analyzer) for import resolution and call graph construction. These tools export SCIP or LSP-compatible symbol tables that give 100% precision on resolved symbols — at near-zero implementation cost compared to building custom type inference. Current heuristic resolution becomes the fallback for languages without SCIP support. | Resolution | The single highest-value accuracy improvement available. Compiler-backed resolution eliminates the entire class of method-dispatch, overload, and type-narrowing resolution failures for the 4 most popular typed languages. Transforms codegraph from "~75% accurate heuristic" to "~99% accurate for TS/Py/Go/Rust, ~75% for the rest" | ✓ | ✓ | 5 | No | — |
| 89 | Call resolution precision/recall benchmark suite | Hand-annotated fixture projects per language with `expected-edges.json` manifests declaring the correct call edges. Benchmark runner compares codegraph's resolved edges against expected, reports precision (correct / total resolved) and recall (correct / total expected). CI gate fails if metrics drop below baseline. Without this, there's no way to know if a change improves or degrades call graph quality. CodeScene publishes precision metrics; Sourcegraph SCIP indexers have per-language benchmarks; codegraph has none. | Testing | The only way to measure whether resolution changes actually improve accuracy — without it, "improvements" might silently break other resolution paths. Also provides regression protection as new languages and resolution modes are added | ✓ | ✓ | 5 | No | — |
| 90 | `package.json` `exports` field resolution | Modern Node.js standard since v12. Import resolution currently uses brute-force filesystem probing (tries 10+ extensions via `fs.existsSync()`). It doesn't read `package.json` `exports` field, meaning conditional exports, subpath patterns, and package self-references are invisible. Support subpath patterns, conditional exports (`"import"`, `"require"`, `"default"`), and fall back to filesystem probing only when `exports` is absent. | Resolution | Fixes resolution failures for any project using modern Node.js package conventions — which is most projects published since 2020. Currently produces low-confidence heuristic matches for imports that should resolve deterministically | ✓ | ✓ | 4 | No | — |
| 91 | Monorepo workspace resolution | `pnpm-workspace.yaml`, npm workspaces (`package.json` `workspaces`), and `lerna.json` are not recognized. Internal package imports (`@myorg/utils`) fall through to global resolution with low confidence. Detect workspace root, enumerate workspace packages, resolve internal imports to actual source files with high confidence (0.95). | Resolution | Fixes resolution for the most common monorepo patterns — affects every monorepo user. Internal package imports currently produce wrong or missing edges | ✓ | ✓ | 4 | No | — |
| 92 | Auto-generate MCP tool schemas from types | The `tool-registry.js` (801 LOC) contains hand-maintained JSON schemas for 40+ tools. With TypeScript (Phase 5), these can be derived from types via `zod` or `typebox`. Schema drift between the implementation and MCP schema is inevitable with hand-maintenance. | Embeddability | Eliminates an entire class of MCP bugs (schema says one thing, implementation does another). Reduces maintenance burden for adding new MCP tools | ✗ | ✓ | 3 | No | Phase 5 (TypeScript) |
| 93 | Shell completion for CLI | Commander supports shell completion but it's not implemented. `codegraph completion bash\|zsh\|fish` outputs the appropriate script. Basic UX gap for a CLI tool with 40+ commands. | Developer Experience | Tab completion makes the CLI discoverable — users find commands without reading docs. Reduces friction for new users and agents exploring available commands | ✓ | ✓ | 2 | No | — |
| 94 | VS Code extension | Replace the planned Web UI (removed from roadmap Phase 12) with a VS Code extension providing: webview-based graph visualization (reusing the existing `viewer.js` HTML), go-to-definition via graph edges, inline impact annotations on hover, integration with the MCP server for queries, and a sidebar panel for triage/audit results. VS Code is the right UI target for developer tools in 2026. | Visualization | Developers get graph intelligence directly in their editor — no context switching to a browser or terminal. Impact annotations on hover surface blast radius without running commands | ✗ | ✓ | 3 | No | — |
| 95 | SARIF output for cycle detection | Add SARIF output format so cycle detection integrates with GitHub Code Scanning, showing issues inline in PRs. Currently planned for Phase 11 but could be delivered as early as Phase 7 since it's a pure output format addition. | CI | GitHub Code Scanning integration surfaces cycle violations directly in PR review — no separate CI step or comment bot needed | ✓ | ✓ | 3 | No | — |
| 96 | Fix README runtime dependency count | README claims "Only 3 runtime dependencies" but there are 5 — it omits `graphology` and `graphology-communities-louvain` which are in `package.json` `dependencies` (not optional). Correct to 5. | Documentation | Accuracy — users and contributors should be able to trust the README | ✓ | ✓ | 1 | No | — |
Copy link
Contributor

Choose a reason for hiding this comment

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

P1 Tier 1j items duplicated in ROADMAP without "PROMOTED" annotation

Five items newly added to Tier 1j are simultaneously added to the ROADMAP, but unlike IDs 73, 74, and 80 (which were pre-existing backlog items correctly struck-through and annotated with **PROMOTED**), the new overlapping entries have no cross-reference:

Backlog ID Backlog Title ROADMAP section
87 Confidence annotations on query output Phase 7.10
89 Call resolution precision/recall benchmark suite Phase 4.4
90 package.json exports field resolution Phase 4.5
91 Monorepo workspace resolution Phase 4.6
93 Shell completion for CLI Phase 7.11

Without the same strikethrough + **PROMOTED** treatment applied to 73/74/80, readers have no way to know these items are already committed roadmap phases. The PR test plan explicitly calls out "verify cross-references between ROADMAP and BACKLOG are consistent" — this is the exact gap. Each of these rows should receive the same annotation pattern, e.g.:

| 87 | ~~Confidence annotations on query output~~ | ... | **PROMOTED** — Moved to ROADMAP Phase 7.10 |

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 — added PROMOTED annotations with strikethrough titles and roadmap phase cross-references to backlog IDs 87, 89, 90, 91, and 93, matching the pattern used for IDs 73/74/80.

Comment on lines +177 to +179
### Tier 1j — Audit-identified gaps (from Architecture Audit v3.1.4)

Items identified by the [architectural audit](../../docs/architecture/ARCHITECTURE_AUDIT_v3.1.4_2026-03-16.md) that don't fit existing tiers. All are zero-dep and foundation-aligned.
Copy link
Contributor

Choose a reason for hiding this comment

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

P2 Tier 1j header incorrectly claims all items are zero-dep

The section header states: "All are zero-dep and foundation-aligned."

However, two entries in the table explicitly carry in the Zero-dep column:

  • ID 92 (Auto-generate MCP tool schemas from types) — zero-dep (requires zod or typebox)
  • ID 94 (VS Code extension) — zero-dep (requires VS Code extension APIs and bundler tooling)

The header should be corrected to reflect that the items are mostly zero-dep, or the qualifier should be removed entirely to avoid misleading prioritization reviewers who rely on the tier descriptions to pre-filter candidates.

Suggested change
### Tier 1j — Audit-identified gaps (from Architecture Audit v3.1.4)
Items identified by the [architectural audit](../../docs/architecture/ARCHITECTURE_AUDIT_v3.1.4_2026-03-16.md) that don't fit existing tiers. All are zero-dep and foundation-aligned.
Items identified by the [architectural audit](../../docs/architecture/ARCHITECTURE_AUDIT_v3.1.4_2026-03-16.md) that don't fit existing tiers. Most are zero-dep and foundation-aligned (see individual rows for exceptions).

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 — changed the Tier 1j header from "All are zero-dep and foundation-aligned" to "Most are zero-dep and foundation-aligned (see individual rows for exceptions)" to account for IDs 92 and 94.

Comment on lines +1062 to +1070
### 4.6 -- Monorepo Workspace Resolution

With analysis data loss fixed, optimize the 1-file rebuild path end-to-end. Current native 1-file rebuild is 265ms — dominated by parse (51ms), structure (13ms), roles (27ms), edges (13ms), insert (12ms), and finalize (12ms).
`pnpm-workspace.yaml`, npm workspaces (`package.json` `workspaces`), and `lerna.json` are not recognized. Internal package imports (`@myorg/utils`) fall through to global resolution with low confidence.

- **Skip unchanged phases:** Structure and roles are graph-wide computations. On a 1-file change, only the changed file's nodes/edges need updating — skip full reclassification unless the file's degree changed significantly
- **Incremental edge rebuild:** Only rebuild edges involving the changed file's symbols, not the full edge set
- **Benchmark target:** Sub-100ms native 1-file rebuilds (from current 265ms)
- Detect workspace root and enumerate workspace packages
- Resolve internal package imports to actual source files within the monorepo
- Assign high confidence (0.95) to workspace-resolved imports

**Affected files:** `src/domain/graph/builder/stages/build-structure.js`, `src/domain/graph/builder/stages/build-edges.js`, `src/domain/graph/builder/pipeline.js`
**Affected files:** `src/domain/graph/resolve.js`, `src/infrastructure/config.js`
Copy link
Contributor

Choose a reason for hiding this comment

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

P2 Phase 4.6 overlaps substantially with the existing Phase 12.2

Phase 4.6 (Monorepo Workspace Resolution) describes:

Detect workspace root and enumerate workspace packages. Resolve internal package imports to actual source files within the monorepo.

Phase 12.2 (Cross-Repository Support / Monorepo, which predates this PR) describes:

Detect workspace root (package.json workspaces, pnpm-workspace.yaml, lerna.json). Resolve internal package imports (e.g., @myorg/utils) to actual source files.

Both target the same workspace detection and internal import resolution mechanics. The distinction currently implied (4.6 = import-resolution accuracy, 12.2 = full cross-package graph support with a package column and --workspace flag) is not clearly stated in either section. A reader or implementer could reasonably implement 4.6 and then find the 12.2 scope already covered, or vice versa.

It's worth adding a note to 4.6 scoping it explicitly as the resolution layer only and deferring the full monorepo graph (package node type, cross-package edges, build --workspace) to 12.2 to avoid duplicating work.

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 — added a scope note to Phase 4.6: "This phase covers the resolution layer only — detecting workspace packages and resolving internal imports to source files. Full monorepo graph support (package node type, cross-package edges, build --workspace flag) is deferred to Phase 12.2." Also added the same scoping note to backlog ID 91's PROMOTED annotation.

Document the rationale, trade-offs, and trajectory for maintaining
both Rust native and JS/WASM engines. Covers performance requirements
for large codebases, portability for VS Code extensions and CI, parity
convergence plan, and alternatives considered.
Native binary v3.1.0 predates the type-map feature added in #501. When
the native parser doesn't return typeMap, backfill it by re-extracting
from WASM, convert to Map format, and fall back to the JS edge builder
(which handles typeMap) instead of the native edge builder (which the
old binary ignores). This restores engine parity for the build-parity
test until a new native binary ships.

Impact: 4 functions changed, 3 affected
- Add PROMOTED annotations to backlog IDs 87, 89, 90, 91, 93 that were
  simultaneously added to both backlog and roadmap without cross-references
- Fix Tier 1j header to note exceptions (IDs 92, 94 are not zero-dep)
- Add scope note to Phase 4.6 clarifying it covers resolution layer only,
  deferring full monorepo graph support to Phase 12.2
@carlos-alm
Copy link
Contributor Author

@greptileai

Comment on lines +477 to +480
for (const { filePath, relPath } of needsTypeMap) {
try {
const code = fs.readFileSync(filePath, 'utf-8');
const extracted = wasmExtractSymbols(parsers, filePath, code);
Copy link
Contributor

Choose a reason for hiding this comment

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

P2 Synchronous fs.readFileSync blocks event loop in async context

parseFilesAuto is an async function that already uses await createParsers() just above this loop. Re-reading files synchronously inside the sequential for…of loop will block the Node.js event loop once per file. On a large codebase with an old native binary where many files need the WASM typeMap backfill, this adds a noticeable serial I/O stall.

The reads can be issued in parallel using fs.promises.readFile and Promise.all, and the WASM extraction can then be batched:

if (needsTypeMap.length > 0) {
  const parsers = await createParsers();
  await Promise.all(
    needsTypeMap.map(async ({ filePath, relPath }) => {
      try {
        const code = await fs.promises.readFile(filePath, 'utf-8');
        const extracted = wasmExtractSymbols(parsers, filePath, code);
        if (extracted?.symbols?.typeMap) {
          const symbols = result.get(relPath);
          symbols.typeMap =
            extracted.symbols.typeMap instanceof Map
              ? extracted.symbols.typeMap
              : new Map(extracted.symbols.typeMap.map((e) => [e.name, e.typeName]));
          symbols._typeMapBackfilled = true;
        }
      } catch {
        /* skip — typeMap is a best-effort backfill */
      }
    }),
  );
}

Note: wasmExtractSymbols is synchronous (WASM), so the CPU work still serialises, but the I/O waiting does not.

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 — replaced the synchronous \ loop with \ inside , so I/O reads are issued in parallel and don't block the event loop. The WASM extraction () is still synchronous by nature, but the file reads no longer serialize.

@carlos-alm
Copy link
Contributor Author

Addressed the Phase 5.9 / 6.6 contradiction flagged in the Greptile summary: Phase 6.6 now explicitly scopes native acceleration to cognitive and cyclomatic metrics only, with a note that Halstead and MI are governed by the Phase 5.9 Kill List (MI removed entirely, Halstead scoped to imperative code). Native acceleration should only target the metrics that survive the Kill List.

@carlos-alm
Copy link
Contributor Author

@greptileai

…ignment

# Conflicts:
#	src/domain/parser.js

Impact: 15 functions changed, 15 affected
Items 71, 73, 74, 80, 83, 87, 89, 90, 91, 93 had strikethrough only on
titles but not on description and benefit columns, inconsistent with all
other done/promoted items in the table.
@carlos-alm carlos-alm merged commit 89c013b into main Mar 18, 2026
13 checks passed
@carlos-alm carlos-alm deleted the docs/roadmap-audit-alignment branch March 18, 2026 23:31
@github-actions github-actions bot locked and limited conversation to collaborators Mar 18, 2026
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