Repository navigation
fix(cli): record asynchronous reads of doc dependencies - #11850
Conversation
Re-cut of #11848, byte for byte. Node 22.13 loads native ES modules through fs.promises.readFile, which the read recorder did not wrap, so a kept name index omitted the files a code doc imports and an edit to one left the hint unchanged. The recorder now wraps fs.promises.readFile with the same content-read logic.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report🔎 Preview ·
|
There was a problem hiding this comment.
Approved pending CI. CI has not run on this head yet: the pull request is a draft, and CI runs once it is marked ready for review.
On Node 22.13.0 the unchanged name-index test fails on the base and passes with this change, so the kept name index again stamps what a code doc imports. Two optional notes are inline: a refused URL now throws synchronously inside a recorded run, and the file header grew to 18 lines.
Claims and files checked
Review mode: full; reason: no-earlier-review
- Changeset: on the minimum supported Node, the not-found hint rebuilds its name index after an imported doc dependency changes. Verified: the name-index test fails on the base and passes here on Node 22.13.0, the CLI's declared floor.
- On Node 22.13 the index left out a code doc's imports, so the hint stayed stale after an edit. Verified by reproducing it on the base.
- The daily minimum-Node run fails the name-index docs-routes test for this reason. Partly verified: the failure reproduces on the base, but the run's own log was not read.
- This is a byte-for-byte re-cut of #11848. Verified: the diffs are identical.
- The recorder wraps
fs.promises.readFilewith the existing content-read and first-read stamp logic. Verified (read-record.mjs:86-136). - Node 22.13 loads native ES modules through
fs.promises.readFile, and newer Node uses the wrapped synchronous reads. Verified: with this change, a module import inside a recorded run is recorded on both Nodes; without it, only on Node 24. - The new test reads by file URL in nested runs, sees an edit and records nothing outside a run. Verified: it fails on the base and passes here.
- The changeset is a CLI patch. Verified: the changesets check passes.
- The public API, the Node floor and the existing tests are unchanged. Verified.
read-record.test.mjson Node 22.13.0: 13 pass with the change, and 1 fails and 12 pass without it. Verified.- On macOS the CLI keeps its cache under
~/Library/Cachesand ignoresXDG_CACHE_HOME. Verified in code (user-dirs.mjs:60); not run on macOS. - On Linux both test files pass (21 tests) on Node 22.13 and 24. Verified on 22.13.0 and 24.20.0.
- No CI impact. Verified: no workflow changes.
- The governing claim is the global-mode spec's rule that a kept value is reused only while its inputs are unchanged. Verified.
- The change conflicts textually with #11805 in
read-record.mjs. Verified. - File
.changeset/record-async-doc-inputs.md: clear. - File
packages/cli/foundation/fs/read-record.mjs: two non-blocking notes, inline. - File
packages/cli/foundation/fs/read-record.test.mjs: clear.
| for (const name of RECORDED) { | ||
| const original = fs[name]; | ||
| // Older Node releases read native ES modules through the promise API. | ||
| const api = name === 'readFile' ? fs.promises : fs; |
There was a problem hiding this comment.
Non-blocking: inside recordReads, the promise API now goes through fileURLToPath (line 121) before the read. A URL it refuses, such as a non-file: scheme or a file: URL with an encoded /, now throws synchronously. Outside a run, fs.promises.readFile returns a rejected promise for the same URL, so a .catch() chain in code a gather loads would miss the error. Wrapping the path conversion in try/catch, and skipping the note when it throws, keeps the promise contract.
| * @output `seen` gets every file whose content the operation read through fs | ||
| * or imported as a doc module (`recordContentRead`), and every folder it | ||
| * (synchronously or with promises.readFile) or imported as a doc module | ||
| * (`recordContentRead`), and every folder it | ||
| * listed or probed, each with its state when first read; | ||
| * `unchangedSince(seen)` says whether all are still in that state. |
There was a problem hiding this comment.
Non-blocking (source-comment rule): the file header is now 18 lines, and the guideline keeps a header to about 12. Folding @output keeps the new fact in four lines:
* @output `seen` gets each file the operation read through fs (sync calls or
* `promises.readFile`) or imported as a doc module (`recordContentRead`),
* and each folder it listed or probed, with its state when first read;
* `unchangedSince(seen)` says whether all are still in that state.…reads # Conflicts: # packages/cli/foundation/fs/read-record.mjs
There was a problem hiding this comment.
Changes requested. The fix itself holds up: on Node 22.13.0 the unchanged name-index test fails against main's recorder and passes with this change, and the new unit case is red-first on both Nodes.
- Regression: three statements in the description are no longer true at this head, because the head merges
main— the three files are not all identical to the pull request this re-cuts (only the changeset is:read-record.mjscarries a hand-resolved conflict, andread-record.test.mjsno longer adds thepathToFileURLimport thatmainnow supplies), the Evidence counts describe the pre-merge test file (it holds 37 cases here, 37 passing on Node 22.13.0 and 36 passing with 1 failing againstmain's recorder), and the Overlap check still presents #11805 as open and conflicting when it has landed and is already merged in; please update those three places, since "identical, byte for byte" points a reader away from the merge resolution, which is the one part of this change no earlier review covered.
The resolution itself checks out: the head is the base plus this pull request's four hunks, with nothing from main dropped. Two earlier non-blocking notes still stand on their inline threads: a URL that fileURLToPath refuses now throws synchronously inside a recorded run where fs.promises.readFile would reject, and the file header is 19 lines against the about-12 guideline. CI has not run on this head, since the pull request is a draft.
Claims and files checked
Review mode: incremental; reason: none
changed rules (1): Count the changed rules mechanically from the diff
- Count the changed rules mechanically from the diff — checked: the recipe the earlier review ran under against this one, and this pull request's three changed files; one rule differs, so this review is incremental; no finding.
- The CLI's oldest supported Node is 22.13. Verified: the package declares
engines.node>=22.13.0. - On that Node the kept name index left out what a code doc imports, so the hint stayed stale after an edit. Verified: reproduced against
main's recorder (name-index.test.mjs:511). - The daily minimum-Node run fails that test for this reason. Partly verified: the failure reproduces on the base at 22.13.0, but that run's own log cannot be read from here.
- This re-cuts #11848 byte for byte, all three files identical to its head. False at this head: only the changeset matches; see the finding.
- The recorder wraps
fs.promises.readFilewith the same content-read and first-read stamp logic as the synchronous reads. Verified (read-record.mjs:129,:133,:199-201,:237). - Node 22.13 loads native ES modules through
fs.promises.readFile, and newer Node loads them through the synchronous reads. Verified: a module import inside a recorded run is recorded on both Nodes with this change, and only on Node 24 without it. - The new test records a promise read by file URL into both nested runs, sees an edit, and records nothing outside a run. Verified: it fails against
main's recorder and passes here. - The changeset is a CLI patch. Verified.
- The public API, the Node floor and every existing test are unchanged. Verified: no export, command doc,
enginesentry or existing test case changes. - Evidence: 13 pass on Node 22.13.0 with the change, and 1 fails with 12 passing without it. False at this head: the file holds 37 cases, 37 passing here and 36 passing with 1 failing against
main's recorder. - #11848 ran both files on Linux, where all 21 tests pass on Node 22.13.0 and 24.22.1. Stale: the two files hold 45 cases at this head, all passing here on 22.13.0 and 24.20.0.
name-index.test.mjscannot be judged on macOS, because the CLI keeps its user cache under~/Library/Cachesthere and ignoresXDG_CACHE_HOME, and #11834 fixes that pattern for another test. Verified in code (user-dirs.mjs: the macOS branch returns the Library path and never reads that setting) and #11834 is open and does that; not run on macOS.- This pull request's own CI run checks both files on Linux. Not yet: every CI workflow concluded skipped on this head because the pull request is a draft.
- The minimum-Node run after it merges checks 22.13. Verified: that workflow runs daily on
mainat the version the package declares. - No CI impact. Verified: no workflow, action or script changes.
- The governing claim is the global-mode spec's rule that a kept value is reused only while every input its gather read is unchanged. Verified at the tip of
main. - Overlap: #11805 rewrites the same function, the two conflict textually, and the second to land merges the first. False at this head: #11805 has landed and this head already merges it.
.changeset/record-async-doc-inputs.md: clear.packages/cli/foundation/fs/read-record.mjs: two non-blocking notes, both on existing inline threads.packages/cli/foundation/fs/read-record.test.mjs: clear.
There was a problem hiding this comment.
Approved pending CI. CI has not run on this head yet: the pull request is a draft, and CI runs once it is marked ready for review.
The rewritten description now matches the branch, and the fix holds up: on Node 22.13.0 the unchanged name-index test fails with main's recorder and passes with this change, and the new unit case fails on main and passes here on both Node 22.13.0 and 24.20.0. Two optional notes stay on their existing inline threads: inside a recorded run a refused URL now throws synchronously where fs.promises.readFile would reject, and the file header is 19 lines against the guideline's about 12.
Claims and files checked
Review mode: same-head; reason: none
- changed rules (0): none.
- The CLI's oldest supported Node is 22.13. Verified: the package declares
engines.node>=22.13.0. - The not-found hint keeps a name index and reuses it only while every file its gather read is unchanged. Verified: the index is kept through the read recorder (
kept-tree.mjs), as the global-mode spec requires. - On Node 22.13 the index left out what a code doc imports, so an edit left the hint stale. Verified: reproduced with
main's recorder (name-index.test.mjs:511). - The daily minimum-Node run fails that test for this reason. Partly verified: the failure reproduces on
main's recorder at 22.13.0 and the run reports daily failures, but its log could not be read here. - The branch started as an exact copy of the earlier cut, then merged
mainafter two overlapping pull requests landed. Verified: the pre-merge tree equals that cut's, and the merge follows. - The changeset is identical to the earlier cut's. Verified.
- In
read-record.mjs, the one merge conflict was the file header, resolved by keeping both texts, and the recording loop is the earlier cut's change unchanged. Verified by re-running the merge. - The test file adds the earlier cut's case without the URL import
mainnow supplies. Verified: the case is identical andmainimportspathToFileURL. - The recorder wraps
fs.promises.readFilewith the same content-read and first-read stamp logic as the synchronous reads. Verified (read-record.mjs:129,:133,:199-201,:221). - Node 22.13 loads native ES modules through
fs.promises.readFile; newer Node loads them through the wrapped synchronous reads. Verified: a module import inside a recorded run is recorded on both Nodes with this change, and only on Node 24 without it. - The new case records a promise read by file URL into both nested runs, sees an edit, and records nothing outside a run. Verified: it fails with
main's recorder and passes here. - The changeset is a CLI patch saying the hint refreshes after an imported doc dependency changes on the minimum Node. Verified: it matches what the tests prove.
- The public API, the Node floor and every existing test are unchanged. Verified.
- On macOS, 36 of 37 recorder cases pass on both Nodes, the other failing on
maintoo because of the/varlink (line 574). Verified as far as Linux allows: 37 cases, the assertion at line 574 compares a resolved path with one under the temporary folder, and all 37 pass on Linux; the macOS runs were not reproduced. - The name-index test cannot be judged on macOS because the CLI keeps its cache under
~/Library/Cachesthere and ignoresXDG_CACHE_HOME; a separate open pull request fixes that pattern for another test. Verified in code and on GitHub. - The earlier cut ran both files with all 21 tests passing on Node 22.13.0 and 24.22.1. Verified as reported in that pull request (13 and 8 cases); it does not name the platform.
- This pull request's CI checks both files on Linux, and the minimum-Node run checks 22.13 after merge. Pending: CI skipped while the pull request is a draft; the minimum-Node run uses the declared floor.
- No CI impact. Verified: no workflow, action or script changes.
- The governing claim is the global-mode spec's rule that a kept value is reused only while every input its gather read is unchanged. Verified on
main. - Overlap: the earlier cut is superseded, and the two other pull requests that changed
read-record.mjshave landed and are merged in. Verified. .changeset/record-async-doc-inputs.md: clear.packages/cli/foundation/fs/read-record.mjs: two non-blocking notes, both on existing inline threads.packages/cli/foundation/fs/read-record.test.mjs: clear.
There was a problem hiding this comment.
Approved pending CI. CI has not run on this head yet: the pull request is a draft, so its CI jobs were skipped.
Since the last review the branch only merges main cleanly, and the fix still holds at this head: on Node 22.13.0 the unchanged name-index test fails with main's recorder and passes with this change, and the new unit case fails on main and passes here on Node 22.13.0 and 24.20.0. Two optional notes stay on their existing inline threads: inside a recorded run a refused URL now throws synchronously where fs.promises.readFile would reject, and the file header is 19 lines against the guideline's about 12.
Claims and files checked
Review mode: incremental; reason: none
- changed rules (0): none.
- The CLI's oldest supported Node is 22.13. Verified: the package declares
engines.node>=22.13.0. - The not-found hint keeps a name index and reuses it only while every file its gather read is unchanged. Verified: the index is kept through the read recorder (
kept-tree.mjs). - On Node 22.13 the index left out what a code doc imports, so an edit left the hint stale. Verified: reproduced with
main's recorder (name-index.test.mjs:511). - The daily minimum-Node run fails that test for this reason. Partly verified: the failure reproduces with
main's recorder on 22.13.0 and the workflow runs the CLI tests daily on the declared floor, but its run history could not be read here. - The branch started as an exact copy of the earlier cut, then merged
mainafter two overlapping pull requests landed. Verified: the first tree equals the earlier cut's, both pull requests are in the history, and a later merge ofmainis clean. - The changeset is identical to the earlier cut's. Verified.
- In
read-record.mjsthe one merge conflict was the file header, resolved by keeping both texts, and the recording loop is the earlier cut's change unchanged. Verified: the earlier merge conflicted only there, and the latest merge ofmainwas clean. - The test file adds the earlier cut's case without the URL import that
mainnow supplies. Verified. - The recorder wraps
fs.promises.readFilewith the same content-read and first-read stamp logic as the synchronous reads. Verified (read-record.mjs:130,:134,:252-254,:274). - Node 22.13 loads native ES modules through
fs.promises.readFile, and newer Node through the wrapped synchronous reads. Verified: a module import inside a recorded run is recorded on both Nodes with this change, and only on Node 24 without it. - The new case records a promise read by file URL into both nested runs, sees an edit, and records nothing outside a run. Verified: it fails with
main's recorder and passes here. - The changeset is a CLI patch saying the hint refreshes after an imported doc dependency changes on the minimum Node. Verified: it matches what the tests prove.
- The public API, the Node floor and every existing test are unchanged. Verified.
- On macOS, 36 of 37 recorder cases pass on both Nodes, and the other fails on
maintoo because of the/varlink (line 574). Verified as far as Linux allows: there are 37 cases, line 574 compares a resolved path with one under the temporary folder, and all 37 pass on Linux; the macOS runs were not reproduced. - The name-index test cannot be judged on macOS because the CLI keeps its cache under
~/Library/Cachesthere; a separate open pull request fixes that pattern for another test. Verified in code and on GitHub. - The earlier cut ran both files with all 21 tests passing on Node 22.13.0 and 24.22.1. Verified as reported in that pull request.
- This pull request's CI checks both files on Linux, and the minimum-Node run checks 22.13 after merge. Pending: CI was skipped on the draft.
- No CI impact. Verified: no workflow, action or script changes.
- The governing claim is the global-mode spec's rule that a kept value is used only while every input its gather read is unchanged. Verified on
main. - Overlap: the earlier cut is superseded, and the two other pull requests that changed
read-record.mjshave landed and are merged in. Verified; a third that changed it since has also landed and arrived with the latest merge ofmain. .changeset/record-async-doc-inputs.md: clear.packages/cli/foundation/fs/read-record.mjs: two non-blocking notes, both on existing inline threads.packages/cli/foundation/fs/read-record.test.mjs: clear.
There was a problem hiding this comment.
Approved pending CI. CI has not run on this head yet: the pull request is a draft, so its CI jobs were skipped; they run once it is marked ready for review.
Since the last review the branch only merges main cleanly, and the fix still holds at this head: on Node 22.13.0 the unchanged name-index test fails with main's recorder and passes with this change, and the new unit case fails on main and passes here on Node 22.13.0 and 24.20.0. Two optional notes stay on their existing inline threads: inside a recorded run a refused URL now throws synchronously where fs.promises.readFile would reject, and the file header is 19 lines against the guideline's about 12.
Claims and files checked
Review mode: incremental; reason: none
- changed rules (0): none.
- The CLI's oldest supported Node is 22.13. Verified: the package declares
engines.node>=22.13.0. - The not-found hint keeps a name index and reuses it only while every file its gather read is unchanged. Verified: the index is kept through the read recorder (
kept-tree.mjs). - On Node 22.13 the index left out what a code doc imports, so an edit left the hint stale. Verified: reproduced with
main's recorder (name-index.test.mjs:511). - The daily minimum-Node run fails that test for this reason. Partly verified: the failure reproduces with
main's recorder on 22.13.0 and the workflow runs the CLI tests daily on the declared floor, but its run history was not read. - The branch started as an exact copy of the earlier cut, then merged
mainafter two overlapping pull requests landed. Verified: the first tree equals the earlier cut's, both pull requests are in the history, and the latest merge ofmainis clean. - The changeset is identical to the earlier cut's. Verified.
- In
read-record.mjsthe one merge conflict was the file header, resolved by keeping both texts, and the recording loop is the earlier cut's change unchanged. Verified: that merge conflicted only in the header, and later merges ofmainare clean. - The test file adds the earlier cut's case without the URL import that
mainnow supplies. Verified (read-record.test.mjs:13). - The recorder wraps
fs.promises.readFilewith the same content-read and first-read stamp logic as the synchronous reads. Verified (read-record.mjs:130,:134,:253,:274). - Node 22.13 loads native ES modules through
fs.promises.readFile, and newer Node through the wrapped synchronous reads. Verified: the name-index case fails on 22.13.0 only withmain's recorder and passes on 24.20.0 with either recorder. - The new case records a promise read by file URL into both nested runs, sees an edit, and records nothing outside a run. Verified: it fails with
main's recorder and passes here on both Nodes. - The changeset is a CLI patch saying the hint refreshes after an imported doc dependency changes on the minimum Node. Verified: it matches what the tests prove.
- The public API, the Node floor and every existing test are unchanged. Verified.
- On macOS, 36 of 37 recorder cases pass on both Nodes, and the other fails on
maintoo because of the/varlink (line 574). Verified as far as Linux allows: there are 37 cases, line 574 compares a resolved path with one under the temporary folder, and all 37 pass on Linux; the macOS runs were not reproduced. - The name-index test cannot be judged on macOS because the CLI keeps its cache under
~/Library/Cachesthere; another open pull request fixes that pattern for another test. Verified in code and on GitHub. - The earlier cut ran both files with all 21 tests passing on Node 22.13.0 and 24.22.1. Verified as reported in that pull request.
- This pull request's CI checks both files on Linux, and the minimum-Node run checks 22.13 after merge. Pending: CI was skipped on the draft.
- No CI impact. Verified: no workflow, action or script changes.
- The governing claim is the global-mode spec's rule that a kept value is used only while every input its gather read is unchanged. Verified on
main. - Overlap: the earlier cut is superseded, and the two other pull requests that changed
read-record.mjshave landed and are merged in. Verified; a third that changed it has also landed and is in the history. - The ownership and landing line describes process, not code. No code claim to check.
.changeset/record-async-doc-inputs.md: clear.packages/cli/foundation/fs/read-record.mjs: two non-blocking notes, both on existing inline threads.packages/cli/foundation/fs/read-record.test.mjs: clear.
… realpath On macOS the temporary folder is behind a symlink (/var to /private/var), so a realpath answer did not match the expected path built from os.tmpdir(), and one case failed on every Mac. The test resolves its temp root once.
There was a problem hiding this comment.
Changes requested. The fix itself holds at this head: on Node 22.13.0 the unchanged name-index test fails with main's recorder and passes with this change, and the new unit case fails on main and passes here on Node 22.13.0 and 24.20.0. The one thing to fix is the description, which no longer matches the latest commit:
- The description says
read-record.test.mjspasses 36 of 37 cases on macOS at this head with the line 574 failure unrelated to this change, and describes the test file as only #11848's new case with every existing test unchanged, but the latest commit changes the shared temp-root setup (read-record.test.mjs:29-35) to fix exactly that case, so the Evidence, What changes and Unchanged statements need updating to match this head.
Two optional notes stay on their existing inline threads: inside a recorded run a refused URL now throws synchronously where fs.promises.readFile would reject, and the file header is 19 lines against the guideline's about 12.
Claims and files checked
Review mode: incremental; reason: none
- changed rules (0): none.
- The CLI's oldest supported Node is 22.13. Verified:
engines.nodeis>=22.13.0(packages/cli/package.json:29). - The not-found hint keeps a name index and reuses it only while every file its gather read is unchanged. Verified: the index is kept through the read recorder (
name-index.mjs:26,kept-tree.mjs:31). - On Node 22.13 the index left out what a code doc imports, so an edit left the hint stale. Verified:
name-index.test.mjs:511fails withmain's recorder on 22.13.0. - The daily minimum-Node run fails that test for this reason. Partly verified: the failure reproduces and the workflow runs on the declared floor, but its run history was not read.
- The branch started as an exact copy of the earlier cut, then merged
mainafter two overlapping pull requests landed. Verified from the history; the latest commit is an authored test change, not a merge. - The changeset is identical to the earlier cut's. Verified.
- In
read-record.mjsthe one merge conflict was the header, resolved by keeping both texts, and the recording loop is the earlier cut's change unchanged. Verified; the file is unchanged since the last review. - The test file is the earlier cut's new case without its URL import. False at this head: it also changes the temp-root setup (
read-record.test.mjs:29-35), which the earlier cut does not. - The recorder wraps
fs.promises.readFilewith the same content-read and first-read stamp logic as the synchronous reads. Verified (read-record.mjs:130,:134,:253,:274). - Node 22.13 loads native ES modules through
fs.promises.readFile, and newer Node through the wrapped synchronous reads. Verified: the name-index case fails on 22.13.0 only withmain's recorder. - The new case records a promise read by file URL into both nested runs, sees an edit, and records nothing outside a run. Verified: it fails at
read-record.test.mjs:72withmain's recorder and passes here on both Nodes. - The changeset is a CLI patch saying the hint refreshes after an imported doc dependency changes on the minimum Node. Verified: it matches what the tests prove.
- The public API and the Node floor are unchanged. Verified.
- Every existing test is unchanged. False at this head: the shared
beforeAllthat every existing case runs under changed. - On macOS at this head, 36 of 37 recorder cases pass and the line 574 failure is unrelated to this change. False at this head: with the temporary folder behind a link, this head passes 37 of 37 and the previous head's file fails that case at line 574.
- The name-index test cannot be judged on macOS because the CLI keeps its cache under
~/Library/Cachesthere. Verified (user-dirs.mjs:60); another open pull request fixing that pattern for another test was checked at the last review. - The earlier cut ran both files on Linux with all 21 tests passing on two Node versions. Verified as reported in that pull request.
- This pull request's CI checks both files on Linux, and the minimum-Node run checks 22.13 after merge. Pending: CI was skipped on the draft.
- No CI impact. Verified: no workflow, action or script changes.
- The governing claim is the global-mode spec's rule that a kept value is used only while every input its gather read is unchanged. Verified on
main. - Overlap: the earlier cut is superseded, and the two other pull requests that changed
read-record.mjshave landed and are merged in. Verified. - A test-only portability fix resolves the temp root once, so 37 of 37 pass on macOS, and Linux CI is unaffected. Verified with the temporary folder behind a link (37 of 37) and on the default Linux folder (37 of 37).
- The ownership and landing line describes process, not code. No code claim to check.
.changeset/record-async-doc-inputs.md: clear.packages/cli/foundation/fs/read-record.mjs: two non-blocking notes, both on existing inline threads.packages/cli/foundation/fs/read-record.test.mjs: code clear; the description leaves out its new temp-root change.
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet because the pull request is a draft; its jobs run once it is marked ready for review.
On Node 22.13.0 the unchanged name-index test fails with main's recorder and passes with this change, and the new unit case fails on main and passes here on Node 22.13.0 and 24.20.0. The description now matches the latest commit, including the test-only temp-root change. Two optional notes stay on their existing inline threads: inside a recorded run a refused URL throws synchronously where fs.promises.readFile would reject, and the file header is 19 lines against the guideline's about 12.
Claims and files checked
Review mode: same-head; reason: none
- changed rules (0): none.
- The CLI's oldest supported Node is 22.13. Verified:
engines.nodeis>=22.13.0(packages/cli/package.json:29). - The not-found hint keeps a name index and reuses it only while every file its gather read is unchanged. Verified: the index is kept through the read recorder (
name-index.mjs:26,kept-tree.mjs:29-31). - On Node 22.13 the index left out what a code doc imports, so an edit left the hint stale. Verified:
name-index.test.mjs:511fails withmain's recorder on 22.13.0, and a plain Node import records nothing there. - The daily minimum-Node run fails that test for this reason. Partly verified: the failure reproduces and that workflow runs on the declared floor, but its run history could not be read.
- The branch started as an exact copy of the earlier cut, then merged
mainafter two overlapping pull requests landed. Verified: the second commit's tree equals the earlier cut's head of that time, and both landed changes are in this head's history. - The changeset is identical to the earlier cut's. Verified: same file contents.
- In
read-record.mjsthe one merge conflict was the header, resolved by keeping both texts, and the recording loop takes the earlier cut's promise-API switch unchanged. Verified from the merge. - The test file is the earlier cut's new case without its URL import, plus a test-only commit that resolves the temporary root (lines 29-35). Verified:
mainalready importspathToFileURL(read-record.test.mjs:13), and the temp-root change is at lines 29-35. - The recorder wraps
fs.promises.readFilewith the same content-read and first-read stamp logic as the synchronous reads. Verified (read-record.mjs:130,:134,:253,:274). - Node 22.13 loads native ES modules through
fs.promises.readFile, newer Node through the wrapped synchronous reads. Verified: Node 22.13.0's loader takesreadFilefrom the promise API on each load, and Node 24.20.0's callsfs.readFileSync. - The new case records a promise read by file URL into both nested runs, sees an edit, and records nothing outside a run. Verified: it fails at
read-record.test.mjs:72withmain's recorder and passes here on both Node versions. - The changeset says the hint refreshes its name index after an imported doc dependency changes on the minimum supported Node. Verified: it matches what the tests prove.
- The public API, the Node floor and every existing test's assertions are unchanged; only the shared temp-root setup now resolves its real path. Verified.
- On macOS at this head 37 of 37 recorder cases pass, and the promise case fails with
main's recorder. Verified on Linux with the temporary folder behind a link (37 of 37) and by the red-first run; macOS itself was not run. - Before the temp-root commit, the "keeps one state per path" case failed on every Mac, and Linux CI never saw it. Verified: with the temporary folder behind a link the earlier test file fails that case at line 574, and on the default Linux folder it passes 37 of 37.
- The name-index test cannot be judged on macOS because the CLI keeps its user cache under
~/Library/Cachesthere and ignoresXDG_CACHE_HOME. Verified (user-dirs.mjs:60); the five macOS failures were not reproduced. - Another open pull request fixes that pattern for another test. Verified: it changes only that test to read the CLI's own cache folder.
- The earlier cut ran both files with all 21 tests passing on Node 22.13.0 and 24.22.1. Verified as that pull request reports it; it does not name its platform.
- This pull request's own CI checks both files on Linux, and the minimum-Node run checks 22.13 after merge. Pending: CI is skipped on the draft.
- No CI impact. Verified: no workflow, action or script changes.
- The governing claim is the global-mode spec's rule that a kept value is reused only while every input its gather read is unchanged. Verified on
main. - Overlap: the earlier cut is superseded, and the two other pull requests that changed
read-record.mjshave landed and are merged in. Verified; a search of open pull requests found no other overlapping one. - The temp-root commit is test-only and changes no assertion. Verified.
- The ownership and landing line describes process, not code. No code claim to check.
.changeset/record-async-doc-inputs.md: clear.packages/cli/foundation/fs/read-record.mjs: two non-blocking notes, both on existing inline threads.packages/cli/foundation/fs/read-record.test.mjs: clear.
Who this helps
People using the CLI on its oldest supported Node (22.13). The not-found hint ("did you mean …?") keeps a name index and reuses it only while every file its gather read is unchanged. On Node 22.13 that index left out the files a code doc imports, so an edit to one of them left the hint showing stale names. The daily "CLI on minimum Node" run fails
name-index.test.mjs› "keeps the docs routes under the doc files that define them, and what a code doc imports" for this reason.What changes
This re-cuts #11848 (thanks to that change for the diagnosis and the fix) on a branch from
main. It started byte for byte identical to #11848's head (d63b8c9); since then it mergesmainafter #11805 and #11877 landed, so at this head:read-record.mjsis fix(cli): record asynchronous reads of doc dependencies #11848's change applied tomain's restructured recorder. The one conflict was the file's header comment, resolved by keeping both texts; the recording loop takes fix(cli): record asynchronous reads of doc dependencies #11848'sfs.promisesswitch unchanged;read-record.test.mjsis fix(cli): record asynchronous reads of doc dependencies #11848's new case, without thepathToFileURLimport thatmainnow supplies, plus a separate test-only commit that resolves the shared temp root withfs.realpathSync(lines 29-35) so the existing "keeps one state per path" case passes on macOS.The files:
packages/cli/foundation/fs/read-record.mjs: the read recorder also wrapsfs.promises.readFile, with the same content-read and first-read stamp logic as the synchronous reads. Node 22.13 loads native ES modules throughfs.promises.readFile, so the imports of a code doc were never recorded. Newer Node loads them through the synchronous reads the recorder already wraps.packages/cli/foundation/fs/read-record.test.mjs: a regression case: a promise read by file URL records into both nested operations, an edit is detected, and nothing is recorded outside an operation..changeset/record-async-doc-inputs.md: a CLI patch: the not-found hint refreshes its name index after an imported doc dependency changes on the minimum supported Node version.read-record.test.mjsnow resolves its real path.Evidence
read-record.test.mjsat this head, run locally on macOS (M5, official Node 22.13.0 build): 37 of 37 pass. Withmain's recorder, the new promise-read case fails. Before the temp-root commit, "keeps one state per path, the fullest a call gave" failed on every Mac (/varagainst realpath's/private/var); Linux CI never saw it.name-index.test.mjscannot be judged on macOS: five of its cases fail locally with or without this change, on Node 22.13 and 24.22, because the CLI keeps its user cache under~/Library/Cacheson macOS and ignores the test'sXDG_CACHE_HOME. test(cli): packed search catalog test reads the kept folder where the CLI keeps it on macOS #11834 fixes that pattern for another test. fix(cli): record asynchronous reads of doc dependencies #11848 ran both files on Linux, where all 21 tests pass on Node 22.13.0 and 24.22.1. This pull request's own CI run checks them on Linux, and the minimum-Node run after it merges checks 22.13.CI impact: none: one source file, its test and a changeset. No job, runner or time-to-green change.
Specs
spec:AST-081FR7: a kept value is reused only while every input its gather read is unchanged. This restores that on the minimum supported Node.Overlap check
Searched open pull requests for
read-record.mjs, its test,name-indexand the changeset: #11848, which this re-cut supersedes. #11805 and #11877, which also changedread-record.mjs, have landed and are merged into this branch (see above).The temp-root commit is test-only and changes no assertion; it is listed under What changes.
Overlap checked: #11848 (the same change, re-cut on a branch from main, which this one supersedes)
Owning session: noopbot (a61f66c2), under CI & Release (ca77f950). Land path: the shipper, through merge-guard.