Skip to content

[compiler] Summaries of the compiler passes to assist agents in development#400

Closed
everettbu wants to merge 2 commits into
mainfrom
pr35595
Closed

[compiler] Summaries of the compiler passes to assist agents in development#400
everettbu wants to merge 2 commits into
mainfrom
pr35595

Conversation

@everettbu

@everettbu everettbu commented Jan 22, 2026

Copy link
Copy Markdown

Mirror of facebook/react#35595
Original author: josephsavona


Autogenerated summaries of each of the compiler passes which allow agents to get the key ideas of a compiler pass, including key input/output invariants, without having to reprocess the file each time. In the subsequent diff this seemed to help.


Stack created with Sapling. Best reviewed with ReviewStack.

  • #35607
  • #35298
  • #35596
  • #35573
  • -> #35595
  • #35539

@everettbu everettbu added CLA Signed React Core Team Opened by a member of the React Core Team labels Jan 22, 2026
@greptile-apps

greptile-apps Bot commented Jan 22, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds autogenerated documentation for all 55 compiler passes to assist AI agents in understanding the React Compiler architecture without reprocessing files repeatedly. The documentation includes detailed summaries of each pass with input/output invariants, algorithms, edge cases, and examples.

Key additions:

  • Created comprehensive documentation for all compiler passes (01-lower.md through 55-validateSourceLocations.md)
  • Added top-level README.md with architecture diagram and pass categorization by phase
  • Updated compiler/CLAUDE.md to reference the new documentation directory
  • Enhanced test runner with autocomplete functionality using Levenshtein distance for better developer experience
  • Added fixture status tracking (pass/fail) to help with test debugging

Documentation structure:

Each pass documentation follows a consistent format with sections for:

  • File location
  • Purpose and role in the pipeline
  • Input invariants and output guarantees
  • Algorithm description with code examples
  • Key data structures
  • Edge cases and TODOs
  • Real examples from fixtures

The documentation is well-structured and comprehensive, covering the entire compilation pipeline from Babel AST lowering through SSA conversion, optimization, type/effect inference, reactive scope construction, and final code generation.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk - it adds comprehensive documentation without modifying any compiler logic
  • The changes are purely additive documentation and minor test tooling improvements. No compiler logic is modified, eliminating risk of breaking existing functionality. The documentation is well-structured, comprehensive, and follows a consistent format across all 55 passes.
  • No files require special attention - all changes are documentation additions and non-critical test tooling enhancements

Important Files Changed

Filename Overview
compiler/CLAUDE.md Added reference to new pass documentation directory
compiler/packages/babel-plugin-react-compiler/docs/passes/README.md Comprehensive overview of all 55 compiler passes with architecture diagram and pass categorization
compiler/packages/babel-plugin-react-compiler/docs/passes/01-lower.md Detailed documentation of HIR lowering pass with input/output invariants and examples
compiler/packages/babel-plugin-react-compiler/docs/passes/08-inferMutationAliasingEffects.md Comprehensive documentation of mutation/aliasing inference with abstract interpretation algorithm
compiler/packages/babel-plugin-react-compiler/docs/passes/31-codegenReactiveFunction.md Detailed documentation of final codegen pass with memoization structure and cache slot allocation
compiler/packages/babel-plugin-react-compiler/docs/passes/40-validateUseMemo.md Complete validation rules for useMemo callbacks with error messages and examples
compiler/packages/babel-plugin-react-compiler/docs/passes/41-validateHooksUsage.md Rules of Hooks validation with abstract interpretation and conditional usage detection
compiler/packages/snap/src/runner-watch.ts Added autocomplete functionality with Levenshtein distance and fixture status tracking
compiler/packages/snap/src/runner.ts Added fixture status tracking for pass/fail results

Much nicer workflow for working through errors in the compiler:
* Run `yarn snap -w`, oops there are are errors
* Hit 'p' to select a fixture => the suggestions populate with recent failures, sorted alphabetically. No need to copy/paste the name of the fixture you want to focus on!
* tab/shift-tab to pick one, hit enter to select that one
* ...Focus on fixing that test...
* 'p' to re-enter the picker. Snap tracks the last state of each fixture and continues to show all tests that failed on their last run, so you can easily move on to the next one. The currently selected test is highlighted, making it easy to move to the next one.
* 'a' at any time to run all tests
* 'd' at any time to toggle debug output on/off (while focusing on a single test)
…opment

Autogenerated summaries of each of the compiler passes which allow agents to get the key ideas of a compiler pass, including key input/output invariants, without having to reprocess the file each time. In the subsequent diff this seemed to help.
@everettbu

Copy link
Copy Markdown
Author

Upstream PR was closed or merged. Code is synced via branch mirror.

@everettbu everettbu closed this Jan 23, 2026
@everettbu
everettbu deleted the pr35595 branch January 23, 2026 20:13
@everettbu
everettbu restored the pr35595 branch January 23, 2026 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed React Core Team Opened by a member of the React Core Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants