Skip to content

fix(affected): unresolved result for TypeScript workspaces — affected_count always 0 #176

Description

@Wolfvin

Bug

codelens affected returns affected_count: 0 and puts the workspace path in unresolved[] when run against a TypeScript project. The command is essentially a no-op for TS.

Reproduction

# After running scan on a TS workspace:
codelens affected /path/to/ts-workspace "auth/google-auth-cache.ts"

Actual output:

{
  "s": "ok",
  "changed_files": ["auth/google-auth-cache.ts"],
  "unresolved": ["/path/to/ts-workspace"],
  "d": 5,
  "st": {
    "changed_count": 1,
    "unresolved_count": 1,
    "affected_count": 0,
    "affected_test_count": 0,
    "affected_source_count": 0,
    "visited_total": 1
  }
}

Expected: list of files that import (directly or transitively) from auth/google-auth-cache.ts.

Root Cause Hypothesis

The affected command likely does a BFS/DFS traversal on the graph edges, but the edge lookup for TS files is not finding the correct node IDs. Possible causes:

  • Path normalization mismatch: the input "auth/google-auth-cache.ts" does not match the node ID format stored after scan (which may use backslashes on Windows, e.g. auth\google-auth-cache.ts, or includes a full prefix)
  • The reverse-dependency index (edges pointing to the changed file) is not being built correctly for js_backend file type (TypeScript is classified as js_backend in scan output)
  • Node lookup in commands/affected.py returns empty set, so BFS never starts

Investigation Entry Point

  1. After scan, query the SQLite graph directly:

    codelens query-graph /path/to/workspace "MATCH (n) WHERE n.id CONTAINS 'google-auth-cache' RETURN n.id LIMIT 5"

    This will reveal the actual node ID format stored for TS files.

  2. Compare that format against what affected passes as the starting node key.

  3. Fix the path normalization in commands/affected.py so the input filename resolves correctly against the stored node IDs.

Definition of Done

  • codelens affected <workspace> "auth/google-auth-cache.ts" returns the correct list of transitively affected files
  • Works on both Unix (/) and Windows (\) path separators
  • unresolved[] is empty when the input file exists in the scan graph
  • Test: add a test in tests/ that scans a small TS fixture, then asserts affected for a known file returns its known dependents

Labels

type: bug-fix exec: sequential

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bug-fixRegression or broken behavior

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions