Skip to content

fix(proximity): resolve emitted module paths to TypeScript sources - #3977

Merged
haelyra merged 1 commit into
affaan-m:mainfrom
Afloat16:fix/proximity-typescript-imports-20261117
Nov 19, 2026
Merged

haelyra merged 1 commit into
affaan-m:mainfrom
Afloat16:fix/proximity-typescript-imports-20261117

Conversation

@Afloat16

Copy link
Copy Markdown
Contributor

What Changed

Add TypeScript source fallbacks for relative imports whose emitted JavaScript file is absent: .js to .ts/.tsx/.d.ts, .jsx to .tsx/.d.ts, .mjs to .mts/.d.mts, and .cjs to .cts/.d.cts. Scan .mts and .cts sources as well. Both the filesystem and in-memory graph builders share the candidate list.

Why This Change

A source checkout using import { value } from './util.js' with util.ts currently has no dependency edge until emitted files exist. This causes the proximity scorer and coordination inventory to miss related edits across otherwise distant paths. The regression demonstrates a zero dependency channel before the fix and a positive channel afterward.

The fallback follows the source-extension relationships documented in the TypeScript module reference. This remains ECC's lightweight static graph: existing literal files keep precedence, and the change does not claim to reproduce TypeScript's complete resolver or tsconfig/package resolution.

Testing Done

  • Both new regression groups failed on unchanged production code and pass after the fix.
  • node tests/lib/agent-proximity.test.js: 25 passed, including real fixture files, both graph builders, module extensions, declaration fallback, literal-file precedence, and the resulting collision-risk channel.
  • ECC_TEST_ONLY=agent-proximity,control-pane-proximity,coordination-inventory npm test: repository validators and all five selected suites passed.
  • Changed-module coverage: 96.17% statements/lines, 84.37% branches, 100% functions; all 80% gates passed.
  • Independent diff review, ESLint, npm audit (zero reported vulnerabilities), and git diff --check passed.

Validation was performed on Linux. The complete repository suite and native Windows execution were not run.

Type of Change

  • fix: Restore missing source dependency edges.

Security & Quality Checklist

  • No new dependencies, network operations, credentials, or command execution.
  • Existing relative-specifier handling, self-edge exclusion, and unresolved-file behavior retained.
  • Conventional commit format.

Documentation

  • Added an inline explanation of the emitted-file fallback and its literal-file precedence.

@Afloat16
Afloat16 requested a review from affaan-m as a code owner November 17, 2026 05:50
@ecc-tools

ecc-tools Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

ECC Tools / Security Evidence

Commit: a55b14fe36097ea036e909437e735a00a3caaeb2

Security evidence gate passed (success)

No security-sensitive scanner-evidence gap detected.

Mode: enforce

Scanned 2 changed file(s). No missing scanner-evidence signal was detected.

Check publication was denied or unavailable. An app owner must enable Checks: read and write, and the installation owner must approve the updated permission.

@ecc-tools

ecc-tools Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

ECC Tools / PR Risk Taxonomy

Commit: a55b14fe36097ea036e909437e735a00a3caaeb2

PR taxonomy review recommended (neutral)

Detected 1 PR taxonomy bucket(s): CI/CD Recommendation.

Scanned 2 changed file(s).

Roadmap taxonomy buckets:

CI/CD Recommendation

CI, dependency, coverage, and contract signals should be routed into follow-up checks or verification work.

Signals:

  • 1 CI or workflow path(s) changed

Paths:

  • tests/lib/agent-proximity.test.js

Check publication was denied or unavailable. An app owner must enable Checks: read and write, and the installation owner must approve the updated permission.

@ecc-tools

ecc-tools Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

ECC Tools / Reference Set Readiness

Commit: a55b14fe36097ea036e909437e735a00a3caaeb2

Reference set readiness gaps detected (neutral)

Reference evidence present for 0/7 areas (0%) across 2 changed file(s).

This check is based on files changed in this PR. Repository-level readiness is still reported by /ecc-tools analyze comments and generated manifests.

Area Status Evidence / Next Step
Deep analyzer corpus Missing Add analyzer fixture, golden, benchmark, or reference-set files that can catch analyzer regressions.
RAG/evaluator comparison Missing Add retrieval or evaluator reference-set comparison fixtures with expected ranking behavior.
PR salvage/review corpus Missing Add stale-PR, review-thread, reopen-flow, or salvage reference cases for queue cleanup automation.
Discussion triage corpus Missing Add public discussion triage fixtures, golden cases, or reference sets for informational, answered, and no-response classifications.
Harness compatibility Missing Add cross-harness, adapter-compliance, or harness-audit evidence for Claude, Codex, OpenCode, Zed, dmux, and agent surfaces.
Security evidence Missing Attach security evidence such as SBOMs, SARIF, audit reports, or AgentShield evidence packs.
CI failure-mode evidence Missing Add captured CI failure logs, dry-run fixtures, or troubleshooting docs for common workflow failure modes.

Check publication was denied or unavailable. An app owner must enable Checks: read and write, and the installation owner must approve the updated permission.

@ecc-tools

ecc-tools Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

ECC Tools / Hosted Promotion Readiness

Commit: a55b14fe36097ea036e909437e735a00a3caaeb2

Hosted promotion readiness passed (success)

No hosted promotion evidence gaps detected across 2 changed file(s); 0 corpus scenarios had matching evidence.

This check compares PR file changes against the evaluator/RAG promotion corpus in src/analyzers/fixtures/evaluator-rag-corpus.ts.
Hosted output scoring inspected 0 completed cached hosted job results.

No evaluator corpus scenarios matched this PR.

Check publication was denied or unavailable. An app owner must enable Checks: read and write, and the installation owner must approve the updated permission.

@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Improvements
    • Dependency analysis now recognizes additional TypeScript module formats and can match emitted JavaScript references to their TypeScript source files.
    • File resolution checks the exact target first, then corresponding TypeScript sources, followed by extension and index-file alternatives. Existing JavaScript files retain priority over TypeScript alternatives, and declaration files can also be resolved.

Both dependency graph builders now map emitted JavaScript specifiers to TypeScript source candidates. The recognized source extensions include .mts and .cts. Tests cover resolution, candidate precedence, declaration files, and collision risk.

Changes: Source resolution

Layer / File(s) Summary
Candidate rules
scripts/lib/agent-proximity/graph.js
The shared candidate builder checks the literal target first, then mapped TypeScript sources, followed by extension and directory-index candidates.
Graph builder integration and validation
scripts/lib/agent-proximity/graph.js, tests/lib/agent-proximity.test.js
Both graph builders use the shared candidates. Tests check resolution for TypeScript, TSX, MTS, and CTS sources, literal .js precedence, declaration files, missing and unrelated extensions, and collision risk.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: Minimal · up to a55b1

This change lets dependency graph building resolve TypeScript source files imported through emitted JavaScript specifiers. It is a narrow addition with literal files still taking precedence, and no merge-blocking risk is identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: emitted module paths (for example, ./util.js) now resolve to TypeScript sources in the proximity graph builders. The fix prefix matches the change type. Both the title…
Description check Passed The description states the change, the reason for it, the TypeScript extension mappings, the tests run, and the validation limits. It matches the changed graph builders and the test file. The descript…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: emitted module paths (for example, ./util.js) now resolve to TypeScript sources in the proximity graph builders. The fix prefix matches the change type. Both the title and the summary describe the same resolution fallback in graph.js.

Full details: Description check

Explanation

The description states the change, the reason for it, the TypeScript extension mappings, the tests run, and the validation limits. It matches the changed graph builders and the test file. The description is detailed and on topic.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: affaan-m/ECC
  • Branch: main
  • File: .coderabbit.yaml
  • Commit: 3def2b6
  • Layers: Repository YAML
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: a772547f-8431-43d9-a323-338dc128f557
Commits

Reviewing files that changed from the base of the PR and between 3def2b6 and a55b14f.

Files selected for processing: 2

  • scripts/lib/agent-proximity/graph.js
  • tests/lib/agent-proximity.test.js

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Recent review details

Context from checks skipped due to timeout: 2

  • GitHub Check: CodeRabbit
  • GitHub Check: Greptile Review
Additional context used

Code guidelines: 10

.cursor/rules/typescript-security.md — auto-discovered
.claude/rules/node.md — auto-discovered
.cursor/rules/typescript-coding-style.md — auto-discovered
.cursor/rules/common-patterns.md — auto-discovered
.cursor/rules/kotlin-testing.md — auto-discovered
.cursor/rules/python-coding-style.md — auto-discovered
.cursor/rules/swift-patterns.md — auto-discovered
.cursor/rules/common-testing.md — auto-discovered
.agents/skills/verification-loop/SKILL.md — Agent Skill
.agents/skills/ecc-conventions/SKILL.md — Agent Skill
Path-based instructions: 13

Focus on command injection, unsafe subprocess usage, path traversal, SSRF, secret exposure, and missing tests for new CLI behavior.

CodeRabbit configuration file

Files:

  • scripts/lib/agent-proximity/graph.js
Source excerpt:

CodeRabbit inference engine (.cursor/rules/typescript-security.md)

Files:

  • scripts/lib/agent-proximity/graph.js
  • tests/lib/agent-proximity.test.js
Source excerpt: New scripts in `scripts/lib/` require a matching test in `tests/lib/`

CodeRabbit inference engine (.claude/rules/node.md)

Files:

  • scripts/lib/agent-proximity/graph.js
Source excerpt: Use spread operator for immutable updates: Source excerpt: Use async/await with try-catch: Source excerpt: Use Zod for schema-based validation: Source excerpt: No `console.log` statements in production code Source excerpt: U...

CodeRabbit inference engine (.cursor/rules/typescript-coding-style.md)

Files:

  • scripts/lib/agent-proximity/graph.js
  • tests/lib/agent-proximity.test.js
Source excerpt: `scripts/` — Node.js utilities, hooks.

CodeRabbit inference engine (.claude/rules/node.md)

Files:

  • scripts/lib/agent-proximity/graph.js
Source excerpt: `tests/` — Mirror the `scripts/` structure.

CodeRabbit inference engine (.claude/rules/node.md)

Files:

  • tests/lib/agent-proximity.test.js
Source excerpt: Encapsulate data access behind a consistent interface: Define standard operations: findAll, findById, create, update, delete Concrete implementations handle storage details (database, API, file, etc.) Business logic depends...

CodeRabbit inference engine (.cursor/rules/common-patterns.md)

Files:

  • scripts/lib/agent-proximity/graph.js
  • tests/lib/agent-proximity.test.js
Source excerpt: Use **Kotest** with spec styles (StringSpec, FunSpec, BehaviorSpec) and **MockK** for mocking.

CodeRabbit inference engine (.cursor/rules/kotlin-testing.md)

Files:

  • scripts/lib/agent-proximity/graph.js
  • tests/lib/agent-proximity.test.js
Source excerpt: Follow **PEP 8** conventions Source excerpt: Use **type annotations** on all function signatures Source excerpt: Prefer immutable data structures: Source excerpt: **black** for code formatting Source excerpt: **isort** for i...

CodeRabbit inference engine (.cursor/rules/python-coding-style.md)

Files:

  • scripts/lib/agent-proximity/graph.js
  • tests/lib/agent-proximity.test.js
Source excerpt: Define small, focused protocols.

CodeRabbit inference engine (.cursor/rules/swift-patterns.md)

Files:

  • scripts/lib/agent-proximity/graph.js
  • tests/lib/agent-proximity.test.js
Source excerpt: Test Types (ALL required): **Unit Tests** - Individual functions, utilities, components **Integration Tests** - API endpoints, database operations **E2E Tests** - Critical user flows (framework chosen per language)

CodeRabbit inference engine (.cursor/rules/common-testing.md)

Files:

  • scripts/lib/agent-proximity/graph.js
  • tests/lib/agent-proximity.test.js
Source excerpt: Review each changed file for: Unintended changes Source excerpt: Review each changed file for: Missing error handling Source excerpt: Review each changed file for: Potential edge cases

CodeRabbit inference engine (.agents/skills/verification-loop/SKILL.md)

Files:

  • scripts/lib/agent-proximity/graph.js
  • tests/lib/agent-proximity.test.js
Source excerpt: Follow *.test.js naming pattern

CodeRabbit inference engine (.agents/skills/ecc-conventions/SKILL.md)

Files:

  • tests/lib/agent-proximity.test.js
ast-grep (0.51.1)

tests/lib/agent-proximity.test.js

[warning] 142-142: Filesystem path is not a string literal; a request-/variable-derived path can enable path traversal. Validate and normalize the path before use.
Context: fs.writeFileSync(target, source)
Note: [CWE-22] Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').

(detect-non-literal-fs-filename)

@greptile-apps

greptile-apps Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

Adds TypeScript source fallbacks when relative imports name emitted JavaScript files that do not exist.

  • Dependency graphs find TypeScript sources named by emitted-JavaScript imports.

No actionable issues found. Tests were inspected but not run during this review.

Reviews (2) · Last reviewed commit: "fix(proximity): resolve emitted module p..." · Reviewed by Greptile

Afloat16 commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor Author

Could a maintainer approve the current CI runs below? This updates the existing approval request to include all ten open fixes; each current run reports action_required.

PR Current head Pending CI run
#3960 — root directory scan 974da29 44005709260
#3961 — Python dependency arrays ec62375 44446465785
#3962 — transcript short reads 5c7eeba 44004667942
#3963 — recent summary turns 9121629 44449410789
#3964 — test summary counting 83b719b 44004668353
#3965 — concurrent tracker retention e5d055f 44046242628
#3966 — module extension hooks fe4e031 44009378304
#3977 — TypeScript source resolution a55b14f 44026840875
#3979 — workspace formatter discovery 189a574 44051733837
#3980 — instinct stack aliases 9b0fe53 44051773500

The latest review follow-up in #3963 is 9121629: immutable test fixtures and isolated parse counting, with repository validators and 54 focused tests passing. The new tests still detect the original parsing regression, and the shared JSON object can remain frozen. Each PR description records its own validation scope and results.

The scanner and regression evidence for #3979 and #3980 remains committed. Their Security Evidence results report success: #3979 evidence result and #3980 evidence result.

These CI runs still need maintainer authorization before execution. Thank you!

@haelyra
haelyra merged commit 8a8deeb into affaan-m:main Nov 19, 2026
4 checks passed
@haelyra

haelyra commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

Thank you for mapping emitted module paths back to TypeScript sources. We merged your original commit history through #4048 so the related changes could be tested together.

The resulting main commit fbb1a85c59a8468c96454fc5b48cf7e4f8f79b55 passed CI, CodeQL, and Supply-Chain Watch. Thank you for helping improve ECC!

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