Skip to content

Feature/workspace parity low cohesion baseline#7

Merged
mohanagy merged 2 commits intomainfrom
feature/workspace-parity-low-cohesion-baseline
Apr 18, 2026
Merged

Feature/workspace parity low cohesion baseline#7
mohanagy merged 2 commits intomainfrom
feature/workspace-parity-low-cohesion-baseline

Conversation

@mohanagy
Copy link
Copy Markdown
Owner

@mohanagy mohanagy commented Apr 18, 2026

Summary

Testing

  • npm run test:run
  • npm run typecheck
  • npm run build
  • npm pack --dry-run (if packaging or install behavior changed)

Checklist

  • I updated docs for any user-visible change
  • I added or updated tests when behavior changed
  • I did not commit secrets, private corpora, or accidental generated artifacts
  • I kept this PR focused on a single change or tightly related set of changes

Related issues

Summary by CodeRabbit

Release Notes

  • New Features

    • Added workspace bridges detection to identify nodes that connect otherwise separate parts of large codebases.
    • Added structure signals analysis reporting connectivity and component metrics.
    • Enhanced benchmark reporting with question coverage tracking and expected-evidence matching.
  • Improvements

    • Improved JavaScript/TypeScript default export handling and cross-file import resolution.
    • Updated CLI command syntax for better clarity.
    • Updated documentation with new workspace-scale parity roadmap.

mohanagy and others added 2 commits April 18, 2026 13:47
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mohanagy mohanagy merged commit 5c57716 into main Apr 18, 2026
1 check passed
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 18, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4e4d6025-89d1-46ca-b31f-a6c2e16691b0

📥 Commits

Reviewing files that changed from the base of the PR and between 6ffee76 and cd01a67.

📒 Files selected for processing (39)
  • .gitignore
  • README.md
  • docs/plans/2026-04-12-upstream-parity-and-beyond.md
  • docs/plans/2026-04-18-workspace-scale-parity-roadmap.md
  • docs/plans/current-status.md
  • src/cli/main.ts
  • src/cli/parser.ts
  • src/infrastructure/benchmark.ts
  • src/infrastructure/benchmark/questions.ts
  • src/infrastructure/generate.ts
  • src/pipeline/analyze.ts
  • src/pipeline/export.ts
  • src/pipeline/export/community-summary.ts
  • src/pipeline/export/overview-bridges.ts
  • src/pipeline/export/overview-navigation.ts
  • src/pipeline/extract.ts
  • src/pipeline/extract/cross-file.ts
  • src/pipeline/extract/typescript-utils.ts
  • src/pipeline/report.ts
  • src/runtime/serve.ts
  • src/runtime/stdio-server.ts
  • src/runtime/stdio/definitions.ts
  • tests/fixtures/workspace-parity-questions.json
  • tests/fixtures/workspace-parity/backend/api.ts
  • tests/fixtures/workspace-parity/docs/architecture.md
  • tests/fixtures/workspace-parity/shared/auth.ts
  • tests/fixtures/workspace-parity/shared/index.ts
  • tests/fixtures/workspace-parity/web-app/session.ts
  • tests/fixtures/workspace-parity/worker/jobs.ts
  • tests/unit/analyze.test.ts
  • tests/unit/benchmark.test.ts
  • tests/unit/cli.test.ts
  • tests/unit/detect.test.ts
  • tests/unit/export.test.ts
  • tests/unit/extract.test.ts
  • tests/unit/generate.test.ts
  • tests/unit/pipeline.test.ts
  • tests/unit/report.test.ts
  • tests/unit/serve.test.ts

📝 Walkthrough

Walkthrough

This PR implements workspace-scale graph analysis enhancements with structure metrics computation, workspace bridge detection between communities, refactored benchmark infrastructure with question evaluation, improved cross-file JavaScript/TypeScript import resolution including default exports, and enriched output across reports, HTML, and query interfaces.

Changes

Cohort / File(s) Summary
Configuration & Documentation
.gitignore, README.md, docs/plans/...
Added .worktrees/ to gitignore; updated README and plans to reflect richer graph reporting (structure signals, workspace bridges, entity-level metrics), new workspace-scale parity roadmap document, and status documentation updates.
CLI Help & Usage Text
src/cli/main.ts, src/cli/parser.ts
Updated benchmark command description from "token reduction" to include "question coverage and structure signals"; changed hook and platform action arguments from bracketed [...] to required angle-bracket syntax <...>.
Graph Structure Analysis
src/pipeline/analyze.ts
Added analysis-entity filtering (excluding file/concept nodes), structure metrics computation (connectivity, components, low-cohesion communities), workspace bridge detection with ranking. Rewired existing anomaly/question logic to use new entity-centric helpers.
Benchmark Infrastructure
src/infrastructure/benchmark.ts, src/infrastructure/benchmark/questions.ts
Refactored token estimation and question evaluation into dedicated questions.ts module. Extended benchmark output with structure signals, question coverage counts, unmatched questions, and expected-evidence tracking. Added typed question inputs and result structures.
Export & Report Output
src/pipeline/export.ts, src/pipeline/export/community-summary.ts, src/pipeline/export/overview-bridges.ts, src/pipeline/export/overview-navigation.ts
Extracted community summary, bridge, and navigation data building into dedicated modules. Enhanced overview HTML with "Workspace Bridges" section and related rendering. Added extractor_version persistence to exported JSON.
Report Generation
src/pipeline/report.ts
Added "Structure Signals" and "Workspace Bridges" sections. Updated cohesion computation and node filtering to use analysis-entity basis. Added low-cohesion community diagnostics.
Incremental Updates & Version Handling
src/pipeline/generate.ts
Added extractor version validation; when --update is used with stale extractor cache version, rebuilds full graph instead of attempting incremental merge.
Code Extraction & Cross-File Resolution
src/pipeline/extract.ts, src/pipeline/extract/cross-file.ts, src/pipeline/extract/typescript-utils.ts
Added default export handling (classes, functions, expressions); bumped extractor cache version from 59 to 60 and exported it. Implemented TypeScript-based JS/TS cross-file relative import resolution with binding collection and scope-aware call attribution. Added utility to unwrap parenthesized expressions.
Runtime Query & Serving
src/runtime/serve.ts, src/runtime/stdio-server.ts, src/runtime/stdio/definitions.ts
Added estimateQueryTokens and QUERY_CHARS_PER_TOKEN constant. Enhanced queryGraph and getNode output with workspace bridge context. Centralized MCP tool/prompt definitions into dedicated definitions.ts module.
Test Fixtures
tests/fixtures/workspace-parity-questions.json, tests/fixtures/workspace-parity/...
Added comprehensive workspace-parity fixture corpus with six TypeScript modules demonstrating default exports, shared/barrel imports, and fragmented architecture; includes question fixture defining expected label assertions.
Unit Tests
tests/unit/...
Extensive test coverage additions: graph structure metrics validation, workspace bridge ranking, benchmark question evaluation with coverage/evidence tracking, cross-file JS/TS stitching (barrels, re-exports, default exports, shadowing), incremental rebuild behavior, bridge-aware query output, and structure signal reporting in various modes.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Query as Query Engine
    participant Graph as Graph Analysis
    participant Bridges as Bridge Detection
    participant Output as Result Formatter

    Client->>Query: queryGraph(question)
    Query->>Graph: Find matching nodes via BFS
    Graph-->>Query: visited nodes, matched labels
    Query->>Bridges: Check visited nodes for bridge entries
    Bridges->>Graph: Lookup community memberships & bridges
    Graph-->>Bridges: Bridge metadata & connected communities
    Bridges-->>Query: Bridge context (if nodes are bridges)
    Query->>Output: Combine subgraph text + bridge context
    Output-->>Client: Enhanced query result with bridge hints
Loading
sequenceDiagram
    participant Benchmark as Benchmark Module
    participant Questions as Questions Module
    participant Graph as Graph Analysis
    participant Metrics as Metrics Computation

    Benchmark->>Benchmark: Receive questions (string or spec)
    Benchmark->>Questions: normalizeQuestion(input)
    Questions-->>Benchmark: standardized spec with expected_labels
    Benchmark->>Questions: evaluateBenchmarkQuestion(graph, question)
    Questions->>Graph: querySubgraphTokens (score nodes, BFS)
    Graph-->>Questions: visited nodes, token estimate
    Questions->>Questions: Derive matched labels from nodes
    Questions-->>Benchmark: result with matched/missing labels, reduction ratio
    Benchmark->>Metrics: graphStructureMetrics(graph) [if provenance complete]
    Metrics-->>Benchmark: structure signals (components, cohesion)
    Benchmark-->>Benchmark: Aggregate per_question results + structure signals
Loading

Estimated Code Review Effort

🎯 4 (Complex) | ⏱️ ~70 minutes

Possibly Related PRs

Poem

🐰 Bridges span the workspace wide,
Structure signals show what's inside—
Questions answered, exports bare,
Cross-file stitches everywhere!
Workspace graphs now stand so tall. 🌳

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/workspace-parity-low-cohesion-baseline

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.

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.

1 participant