Skip to content

refactor: simplify internals across the workspace - #1590

Merged
aidenybai merged 19 commits into
mainfrom
codex/extract-inspect-finalization
Aug 8, 2026
Merged

refactor: simplify internals across the workspace#1590
aidenybai merged 19 commits into
mainfrom
codex/extract-inspect-finalization

Conversation

@aidenybai

@aidenybai aidenybai commented Aug 6, 2026

Copy link
Copy Markdown
Member

Why

The runtime migration left correctness-sensitive work concentrated in oversized coordinators for scan planning, staged snapshots, baseline filtering, cache persistence, project detection, module linking, telemetry, and rendering. The workspace also accumulated duplicate graph walkers, repeated AST helpers, pass-through wrappers, speculative service layers, retired rules, and internal exports with no consumers.

This refactor makes those responsibilities explicit and independently testable while preserving the CLI contract, JSON schema, package APIs, diagnostics, and release behavior. The final audit also found a real overlap race: a synchronously starting dead-code fiber could invoke cache callbacks before their state variables were initialized.

What changed

  • decomposed CLI inspection into focused planning, staged-scan, finalization, cache, rendering, and telemetry phases
  • replaced nullable TUI state and concurrently mutated scan side channels with discriminated snapshots and explicit outcomes
  • made listener and abort registries reentrancy-safe by snapshotting before callbacks
  • separated pure scan decisions from logging, metrics, report writes, and exit-code mutation
  • fixed dead-code/lint overlap so synchronous cache callbacks cannot race state initialization, with regression coverage
  • decomposed React Compiler config evaluation into ordered ESM, CommonJS, require-resolution, and selected-property phases
  • split deslop package-entry discovery, built-path mapping, module-link input collection, style traversal, and Tarjan graph traversal into testable units
  • consolidated deslop parser result shapes, override mappings, core import-source lookup, and system concurrency facts
  • decomposed staged project resolution, materialization, execution, presentation, and cleanup while preserving snapshot ownership
  • simplified Zustand target provenance, cross-file export resolution, and scan-cache payload validation without changing diagnostic behavior
  • lazy-loaded cold CLI command implementations while leaving Commander metadata and help eager
  • fixed built-output path containment in deslop with path.relative, including sibling-prefix regression coverage
  • removed an unregistered retired rule, speculative reporter/linter layers, test-only CLI helpers, identity aliases, unused constants, a one-off codemod, stale barrels, duplicate hashing and AST helpers, and other analyzer-confirmed dead internals
  • moved hosted score I/O onto Effect's HTTP client with interruption-aware timeouts, typed response decoding, Effect console output, and fail-open recovery
  • upgraded the aligned Effect runtime, Node platform, and test integration from beta.70 to beta.102, and removed redundant single-yield generator wrappers
  • moved editor config discovery and scan execution into one traced Effect lifecycle with a single resolved config service
  • centralized the score transport's HTTP bounds and time conversion constants, and kept the types-only tree free of runtime imports
  • retained intentional compatibility and package boundaries such as InspectUiLayers and package-local atomic writers
  • kept patch changesets for affected published packages

Relative to the current main, the complete PR changes 228 files with 7,036 insertions and 6,342 deletions. The architecture pass was informed by React Grab state-machine and lifecycle patterns, OpenCode narrow runtime boundaries and lazy loading, and OpenTUI scoped ownership and pure outcome construction.

Fallow and deslop were used as evidence rather than mechanical deletion lists. The final changed-file Fallow duplicate pass reports zero groups. Remaining dead-code candidates were manually checked against package entry points, generated worker entry points, Effect layers, fixtures, and public compatibility surfaces before deletion. Truffler was run before and after the new shared utilities and found no competing helpers.

Test plan

  • nr test - all 15 package tasks; core 1,860 tests, rule plugin 26,215 tests, CLI 2,448 tests
  • nr lint - passes; remaining warnings are intentional fuzz-corpus inputs
  • nr typecheck - 16/16 tasks
  • nr format:check - 6,223 files
  • nr build --output-logs=errors-only - 9/9 tasks
  • nr check:published-deps - all five published packages valid
  • nr smoke:json-report - schema v3 complete report
  • nr smoke:packed-cli-install - version 0.9.6, 180 diagnostics, zero forbidden packages
  • node packages/react-doctor/bin/react-doctor.js --scope changed --base 1840313922918429f6bdde14b2fc878f98ec7362 --blocking warning --no-score --verbose - no issues
  • focused core, Effect score transport, editor config lifecycle, CLI, deslop, graph, Zustand, and cross-file resolver regressions
  • nlx fallow@latest dupes --changed-since HEAD --skip-local --format compact --quiet --top 100 - zero duplicate groups
  • nlx deslop-cli@latest . - completed across the full workspace and manually triaged

Note

Medium Risk
Touches core scan orchestration (dead-code/lint overlap, editor lifecycle) and networked score I/O, but behavior is largely preserved with added tests and fail-open score handling; Effect beta bump warrants regression on CI and published packages.

Overview
Bumps Effect to 4.0.0-beta.102 across the workspace and routes hosted score requests through a new requestScore helper on Effect’s HTTP client (gzip body, schema decode, timeouts, fail-open warnings) instead of ad-hoc fetch in calculate-score.

Scan orchestration moves dead-code cache telemetry variables ahead of the lint/dead-code overlap path so synchronous cache callbacks cannot run before initialization; adds regression coverage for that overlap case. Editor scans resolve config and run runInspect inside a single traced Effect program rather than mixing loadConfigWithSource with imperative runPromiseExit.

Project discovery splits the old detectors barrel into focused modules (framework, Next static export, pre-ES2023 target, React Compiler) and trims react-compiler-config-evaluator while keeping export detection behavior. Shared utilities consolidate import module-source lookup, system concurrency facts for lint/dead-code worker caps, and atomic file writes (JSON cache persistence uses the same primitive).

Package boundaries: InspectInput/InspectOutput, oxlint runner options, and Git service shapes move into dedicated types/* modules; several formerly public helpers are narrowed or deduplicated. CI runs Node 20 tests with --concurrency=1 and replaces VHS/Go terminal recordings with in-repo Terminal Control E2E (scripts/terminal-e2e.sh) and MP4/PNG artifacts.

Reviewed by Cursor Bugbot for commit 7ab01e4. Bugbot is set up for automated code reviews on this repo. Configure here.

@pkg-pr-new

pkg-pr-new Bot commented Aug 6, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/eslint-plugin-react-doctor@1590
npm i https://pkg.pr.new/oxlint-plugin-react-doctor@1590
npm i https://pkg.pr.new/react-doctor@1590

commit: 7ab01e4

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

React Doctor found no new issues. 🎉

Reviewed by React Doctor for commit 7ab01e4.

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Interactive terminal E2E

Terminal Control verified the built CLI at 7ab01e4 in a real PTY:

  • selected a project interactively and observed Scanning... before the three-second Git delay completed
  • waited for the clean result and exercised the compact report
  • opened copy context and the GitHub Actions confirmation, then cancelled safely

Download the edited MP4 and PNG evidence

@aidenybai
aidenybai marked this pull request as ready for review August 6, 2026 08:19
@aidenybai aidenybai changed the title refactor(cli): extract inspect result finalization refactor: harden scan orchestration and cache boundaries Aug 6, 2026
Comment thread packages/react-doctor/src/cli/utils/open-workflow-pull-request.ts
@aidenybai aidenybai changed the title refactor: harden scan orchestration and cache boundaries refactor: consolidate scan, cache, and graph internals Aug 6, 2026
@aidenybai aidenybai changed the title refactor: consolidate scan, cache, and graph internals refactor: simplify internals across the workspace Aug 6, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 5ab6307. Configure here.

Comment thread scripts/terminal-e2e.sh
@aidenybai
aidenybai merged commit 13138a4 into main Aug 8, 2026
27 checks passed
@github-actions github-actions Bot mentioned this pull request Aug 8, 2026
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