Repository navigation
fix(reference): report sloppy scripts, PHP, C# and enclosing Git facts - #1770
Conversation
Importing the source/ subtree of a legacy PHP and C# checkout produced four wrong or missing facts: - Babel's unambiguous mode parses a module first and keeps its strict-mode recovery errors after falling back to a script, so a valid sloppy-mode `delete messages;` was reported as a parse failure and the semantic IR marked the file as parser-recovered. Parsing now goes through one owner that re-parses such a script as a script. - .php and .cs files had no language; they are now detected as PHP and C# (detection only, no parsing). - A root without its own .git was reported as having no version control even inside a checkout. The adapter now resolves the nearest enclosing repository, as Git does, and reports `none` only when no ancestor has one. - The CLI recorded importer_version as null although the package version is known.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c4b639c2e3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Review follow-up. `.mjs` and `.mts` files are modules by extension, but the script fallback re-parsed them in sloppy mode and erased real strict-mode errors. The parser boundary now owns the extension rule, parses explicit modules as modules and applies the fallback only when the mode is ambiguous; the require-binding analysis uses the same rule. `.cs` and `.php` received a language but stayed classified as unknown, so source-to-bundle comparison dropped them. Both are now source extensions, like the other detected languages.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 641732e58b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…ct errors Review follow-up. A `.js` file under a package.json with `"type": "module"` is an ES module, but it went through the script fallback that erases strict-mode errors. The import now reads each in-inventory package.json and parses `.js` files in a module scope as modules. Other `.js` and `.ts` sources keep an unknown mode, because bundlers treat them as modules without that field: they are no longer forced to script, and errors that only the module parse reports are kept as an entry limitation.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d4169d85ce
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…hanged Review follow-up. - `.cjs` files parse as scripts, so module-only strict errors no longer become limitations on CommonJS trees. `.cts` keeps an unknown mode because TypeScript compiles ES import syntax there. - An unreadable or linked package.json now bounds the module scope with an unknown type instead of letting an outer `"type": "module"` apply. - The application pipeline parses as on main again. Its module-only strict errors keep a source partial; package-mode handling stays in the reference importer.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6598d42f5c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…solving package scope Review follow-up. Resolving Node package scope for `.js` kept pulling in more of Node's lookup semantics (require bindings, excluded or directory-named manifests). Only extensions now select a mode: `.mjs` and `.mts` parse as modules and `.cjs` as scripts. Every other source keeps an unknown mode, so module-only strict errors stay visible as an entry limitation instead of being dropped or asserted. This matches the require-binding analysis, which also treats unmarked paths as unknown.
baron
left a comment
There was a problem hiding this comment.
Reviewed exact head a4ff51b against current main, including parsed-owner/consumer boundaries and directly related cleanup. No confirmed source blocker.
The parser preserves explicit module strictness and unknown runtime mode instead of treating recovered sloppy syntax as proved runtime configuration. PHP/C# classification and nearest-enclosing Git facts preserve source values and unknown dirty state. CLI provenance carries the package version. No further structural repair or test pruning was justified.
Pinned Node 24.18.0/npm 11.16.0 current-main integration: 9 focused files passed (41 tests passed, 2 Windows-only skips), 8 direct producer/parser witnesses passed, and uncached check:fast passed. The compiled public import workflow was exercised on inert source; source was not executed. Exact-head hosted CI is green; final object-only merge is clean. No real provider operations were performed or claimed.
Summary
import-reference-sourcerecords wrong or missing facts for an ordinary legacy subtree:.phpand.csfiles have no language.importer_versionisnull.This PR corrects all four at their owning boundaries. They are kept together because they are all facts of one import result.
I did not open a separate issue because the PR carries the full reproduction below.
Problem and expected behavior
Reproduction: a Git repository whose committed
source/directory containslegacy.js(var messages = {};\ndelete messages;\n),index.phpandProgram.cs. Then runrea import-reference-source <repo>/source --format json --filter-output languages,parse_failures,vcs,provenance.Before (062723e):
{"languages":["JavaScript"],"parse_failures":[{"path":"legacy.js","parser":"babel","reason":"Deleting local variable in strict mode. (2:0)"}],"vcs":{"kind":"none","head":null,"dirty":null},"provenance":{"importer":"rea-agents","importer_version":null,"caller":"rea-cli"}}After:
{"languages":["C#","JavaScript","PHP"],"parse_failures":[],"vcs":{"kind":"git","head":"45763e758c7b0d62b7b7382650afffd515563b90","dirty":null},"provenance":{"importer":"rea-agents","importer_version":"6.4.0","caller":"rea-cli"}}Causes:
sourceType: "unambiguous"parses as a module first. WitherrorRecovery, it keeps those strict-mode errors after falling back toprogram.sourceType === "script".LANGUAGE_BY_EXTENSIONhad nophporcsentry.ReferenceSourceVcsAdapteronly checked<root>/.git. A missing entry there was reported askind: "none", a wrong absence claim for a subtree of a checkout.importerVersion: nullalthoughPRODUCT_IDENTITY.packageVersionis known.Change and scope
parseRecoveredJavaScriptinjavascriptSourceParser.tsparses reference sources by extension:.mjs/.mtsas modules,.cjsas scripts. Other sources fall back to a script when Babel settles on one, and errors only the module parse reports become an entry limitation. The application pipeline (parseJavaScriptSource) is unchanged.phpmaps toPHPandcstoC#. This is detection only: neither language is parsed for imports..gitentry, as Git does for a subdirectory, and reads HEAD through the existing reader. It reportsnoneonly when no ancestor has one, andunknownon any other lookup error.dirtystaysnull, so whether the subtree matches HEAD remains unknown.docs/cli.mddocuments this.importer_version.Not included:
.gitignorefiles above the selected root are still not applied to exclusions.csprojandslnare not classified as manifests.webBundleAnalyzerInspectionkeeps its own parse, because it does not report parser errors.Contract and boundary impact
src/domain/javascript/javascriptSourceParser.ts)src/domain/referenceSourceClassification.ts)src/application/ReferenceSourceVcsAdapter.ts)src/cli/utilityCommands.ts)languages,parse_failures,vcsandprovenance.importer_versionvalues change as shown..gitand may read the enclosing repository's HEAD and refs outside the selected root, through the existing read path without a subprocess. This is documented indocs/cli.md.docs/public/product-catalog.json), package, or installation impact: none.Evidence and regression coverage
tests/boundary/cli/referenceSourceLegacyFacts.test.ts: the compiled CLI on the reproduction above, asserting all four facts.parse_failuresand passes with this change..gitentry. No Windows run (the import is unsupported on native Windows).For evidence-bearing changes:
Validation performed
On macOS (Darwin 27.0, Apple Silicon), Node 24.18.0:
npm run test:fast— 375 files, 4270 passed, 7 skippednpm run test:focused -- tests/boundary/filesystem/referenceSource*.test.ts tests/boundary/cli/referenceSource*.test.ts— 19 files, 69 passed, 2 skippednpm run check— passednpm run docs:check— passednpm run verify:test-discovery— 814 test files discovered exactly oncenpm run build:cachedand the CLI run above — passedReview follow-up
.mjs/.mtsparse as modules through one parser-owned rule;.cs/.phpare classified as source..mjs/.mts/.cjs) keep an unknown mode and are not forced to script; module-only strict errors become an entry limitation..cjsparses as a script. Package-scope resolution was tried and removed again, because it kept pulling in more of Node's lookup rules; this matches the require-binding analysis, which also treats unmarked paths as unknown. The application pipeline parses as on main..cjs, unknown mode and classification; it fails on the previous head.npm run test:fast— 4270 passed; reference-source boundary — 69 passed;npm run check:fast— passed.Compatibility, safety, and release
vcs.kind: "none"as authoritative for subdirectories now receive the enclosing repository's HEAD.Review checklist
type(scope): outcome.🤖 Generated with Claude Code