Skip to content

fix(cli): record asynchronous reads of doc dependencies - #11848

Closed
astracat-bot[bot] wants to merge 3 commits into
mainfrom
codebunny/fix/fix-cli-record-asynchronous-reads-of-doc-dependencies-812e5b
Closed

astracat-bot[bot] wants to merge 3 commits into
mainfrom
codebunny/fix/fix-cli-record-asynchronous-reads-of-doc-dependencies-812e5b

Conversation

@astracat-bot

@astracat-bot astracat-bot Bot commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

validation: ran pnpm exec vitest run packages/cli/foundation/suggest/name-index.test.mjs packages/cli/foundation/fs/read-record.test.mjs --project node --maxWorkers=1 on Node 22.13.0 and Node 24.22.1; all 21 tests passed on each. Prettier, targeted ESLint, and pnpm review:pre passed.

User impact

On the minimum supported Node version, the not-found hint's kept name index omitted the files imported by a code doc. Editing one of those files could therefore leave the stored hint unchanged.

Problem and solution fit

Node 22.13.0 loads native ES modules through fs.promises.readFile. The read recorder wrapped synchronous filesystem reads only, so it stamped the doc itself but missed its imported lib/name.mjs. The route assertions passed; the dependency-stamp assertion failed at name-index.test.mjs:511.

Record fs.promises.readFile with the same existing content-read wrapper and first-read stamp logic. This also preserves nested recording contexts and passes through the original promise and result. No module hooks, compatibility-policy changes, retries, waits, or assertion changes are needed.

Expected behavior and authority

Current AST-081 FR7, in docs/specs/AST-081-global-mode/spec.md, requires a kept value to be reused only while every input its gather read is unchanged. The change restores that requirement without changing the public API or the Node floor.

Evidence

  • Failing workflow: cli-minimum-node.yml, scheduled run 43689891007, job 132738152938, commit d182a5b0fc298c6da569660a95b554040aca599c.
  • The unchanged target test failed in both completed Node 22.13.0 reproductions using pnpm exec vitest run packages/cli/foundation/suggest/name-index.test.mjs --project node --maxWorkers=1 -t 'keeps the docs routes'. An earlier setup collision was excluded from the counts.
  • The same command still failed on current main fe00cdcf7421746120a240ad838aeb4352bae3d5 before the fix. On Node 24.22.1 the unchanged target already passed.
  • After the fix, both full files pass on both Node versions. The existing test still checks every dependency stamp, reuse after an unrelated edit, and invalidation after a dependency edit.
  • The added regression checks a promise read by file URL, recording into both nested operations, detecting an edit, and recording nothing outside an operation. Existing synchronous-read coverage remains green.

Scope

Only the read recorder, its regression test, and the CLI patch Changeset change. No existing tests or workflow files change. pnpm review:pre reported zero findings, and the submitted-path check found no other changed files.

@vercel

vercel Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 15, 2026 11:32am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 15, 2026
@astracat-bot

astracat-bot Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor Author

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 15, 2026, 11:43 AM UTC

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Changes requested for one release-note fix; the recorder change itself looks correct. The new regression test fails on main and passes on this branch, and the name-index test that fails on the minimum-Node job now passes under Node 22.13.0 and 24.

  • .changeset/record-async-doc-inputs.md credits no contributor, so pnpm check:changesets fails the required Lint job; add an @handle line under the summary, as pnpm changeset:new --contributor <handle> writes it.

Once the credit line is in and CI is green, this is ready for another look.

Claims and files checked

Review mode: full; reason: no-earlier-review

Claims:

  • Changeset: the not-found hint refreshes its name index after an imported doc dependency changes on the minimum supported Node version — verified: the docs-routes name-index test fails on main under Node 22.13.0 (the imported module is missing from the stamps) and passes on this branch; the CLI's engines floor is Node 22.13.0.
  • Before the fix, the kept index left out files a code doc imports on the minimum Node version — verified by the same test and by a plain-Node import probe that records nothing on main under 22.13.0.
  • Node 22.13.0 loads native ES modules through the promise readFile — verified: the probe records the importing and imported modules only once that function is wrapped.
  • The recorder wrapped synchronous reads only; the route assertions passed and the dependency-stamp assertion failed — verified: the failure is at name-index.test.mjs:511 on main.
  • The fix reuses the content-read wrapper and first-read stamps, keeps nested runs, and returns the original promise — verified in read-record.mjs:105-139 and by the nested-run test.
  • No module hooks, policy changes, retries, waits or assertion changes — verified from the diff.
  • The global-mode record requires a kept value to be used only while every input its gather read is unchanged — verified in AST-081 FR7.
  • No public API or Node floor change — verified: exports, command docs and the engines field are unchanged.
  • The minimum-Node scheduled job fails on main — verified: its Node 22.13.0 test leg failed.
  • The target test fails on main under 22.13.0 and already passes under Node 24 — verified (run under 24.20.0).
  • Both full test files pass on both Node versions after the fix — verified: 21 of 21 under 22.13.0 and 24.20.0.
  • The existing test still checks every dependency stamp, reuse after an unrelated edit and a rebuild after a dependency edit — verified in name-index.test.mjs:448-547.
  • The new regression covers a promise read by file URL, nested recording, edit detection and nothing recorded outside a run — verified in read-record.test.mjs:55-77; it fails on main under both versions.
  • Prettier and targeted ESLint pass — verified on the three files.
  • pnpm review:pre reported no findings — not reproduced; its changeset checks do not cover contributor credit, so this does not contradict the lint failure.
  • Only the recorder, its test and a CLI patch changeset change — verified: three files.

Files:

  • .changeset/record-async-doc-inputs.md — no contributor credit; required lint fails.
  • packages/cli/foundation/fs/read-record.mjs — clear.
  • packages/cli/foundation/fs/read-record.test.mjs — clear.

Automated review (maintainer link)

Comment thread .changeset/record-async-doc-inputs.md Resolved
@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · d4d980f

Storybook · Sandbox · built from this PR's head

Package size: @astryxdesign/cli 4.76 MB packed (+85 B); no new dependencies.

Not run on this PR: add ci:run-visual for Visual, ci:run-a11y for Accessibility, ci:run-rtl for RTL.

Current run: CI concluded cancelled; parts of this report may be missing.


Generated by PR Enrichment workflow | View full report

@astracat-bot

astracat-bot Bot commented Nov 15, 2026

Copy link
Copy Markdown
Contributor Author

validation: ran pnpm check:changesets (the script it runs, node scripts/check-changesets.mjs) on this change; it reported all 289 changesets valid.

Adds the contributor credit line @astracat-bot under the summary in .changeset/record-async-doc-inputs.md, in the form pnpm changeset:new --contributor astracat-bot writes. This fixes the required Lint job's changeset check.

What I was unsure of: which handle to credit. This change was written by the bot, so I followed the earlier bot fix #11186, whose changeset credits @astracat-bot (and the CLI changelog already lists that handle). If a maintainer would rather credit a person, change only that line.

No code or test changes.

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Approved pending CI: the required test jobs have not finished on this head yet.

The recorder now also records promise reads, so on Node 22.13.0 the kept name index notices edits to the modules a code doc imports; the new regression test and the name-index test fail on main and pass on this branch under Node 22.13.0 and Node 24. The changeset credit line resolves the earlier Lint failure, and nothing else is needed from you.

Claims and files checked

Review mode: full; reason: author-not-engowner

Claims:

  • Changeset: the not-found hint refreshes its name index after an imported doc dependency changes on the minimum supported Node version — verified: the docs-routes name-index test fails on main under Node 22.13.0 (the imported module is missing from the stamps) and passes on this branch.
  • Changeset credit: the entry credits a contributor — verified: @astracat-bot on its own line; check:changesets reports all 289 changesets valid and the Lint job passes.
  • Both test files pass on Node 22.13.0 and Node 24 — verified: 21 of 21 under 22.13.0 and 24.20.0.
  • Prettier, targeted ESLint and pnpm review:pre pass — verified: formatting and lint are clean, and review:pre reports zero findings.
  • Before the fix, the kept index left out files a code doc imports on the minimum Node version, so an edit could leave the hint stale — verified by the same test and a plain-Node import probe that records nothing on main under 22.13.0.
  • Node 22.13.0 loads native ES modules through the promise readFile — verified: its loader reads each module's source with the promise readFile, looked up on every load, which the head's wrapper intercepts.
  • The recorder wrapped synchronous reads only; the route assertions passed and the dependency-stamp assertion failed — verified at name-index.test.mjs:511 on main.
  • The fix reuses the content-read wrapper and first-read stamps, keeps nested runs, and returns the original promise — verified in read-record.mjs:105-139 and the nested-run test.
  • No module hooks, policy changes, retries, waits or assertion changes — verified from the diff.
  • The global-mode spec requires a kept value to be reused only while every input its gather read is unchanged — verified in its FR7.
  • No public API or Node floor change — verified: exports, command docs and the engines field are unchanged.
  • The scheduled minimum-Node workflow fails on main in its Node 22.13.0 leg — verified.
  • The target test fails on main under 22.13.0 and already passes under Node 24 — verified (run under 24.20.0).
  • The existing test still checks every dependency stamp, reuse after an unrelated edit and a rebuild after a dependency edit — verified in name-index.test.mjs:448-547.
  • The new regression covers a promise read by file URL, nested recording, edit detection and nothing recorded outside a run — verified in read-record.test.mjs:55-77; it fails on main under both versions.
  • Only the recorder, its test and a CLI patch changeset change — verified: three files.
  • Follow-up: the credit follows an earlier bot fix whose release already lists that handle — verified in the CLI changelog.

Files:

  • .changeset/record-async-doc-inputs.md — clear.
  • packages/cli/foundation/fs/read-record.mjs — clear.
  • packages/cli/foundation/fs/read-record.test.mjs — clear.

Automated review (maintainer link)

@astracat-bot

astracat-bot Bot commented Nov 15, 2026

Copy link
Copy Markdown
Contributor Author

validation: ran pnpm exec vitest run packages/cli/foundation/suggest/name-index.test.mjs packages/cli/foundation/fs/read-record.test.mjs --project node --maxWorkers=1 on the clean combined merge with main, using Node 22.13.0 and Node 24.22.1; all 44 tests passed on each. Targeted Prettier and ESLint passed. pnpm specs:for --diff origin/main and pnpm review:pre passed on the final PR branch; pre-review reported a clean merge and zero findings.

Resolved the merge conflict with main 17f7ffcc6674aa22b883d5a62d60c41e32b42249 (#11805) by matching the read recorder's header to main's description of exact probe recording. The header still covers filesystem content reads, including promise reads.

This follow-up changes only three header lines in packages/cli/foundation/fs/read-record.mjs. No behavior change: the PR's asynchronous read recording, its regression test, and main's exact-probe implementation and tests remain intact. A local trial merge verified that both changes combine without conflicts; only the header edit is submitted, not unrelated main changes. No unresolved correctness questions.

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Approved pending CI: the CI run on this head was cancelled because CI had no free capacity, so build, docsite-test and test still need a re-run here.

The recorder now also records promise reads, so on Node 22.13.0 the kept name index notices edits to the modules a code doc imports. The new regression test and the name-index test fail on main and pass on this branch, and both test files also pass on a trial merge with current main. Nothing else is needed from you.

Claims and files checked

Review mode: full; reason: author-not-engowner

Claims:

  • Changeset: the not-found hint refreshes its name index after an imported doc dependency changes on the minimum supported Node version — verified: the docs-routes name-index test fails on the base under Node 22.13.0 (the imported module is missing from the stamps) and passes on this branch.
  • Changeset credit: the entry credits a contributor — verified: @astracat-bot on line 7; the changeset check reports all 289 changesets valid and Lint passes.
  • Both test files pass on Node 22.13.0 and Node 24 — verified: 21 of 21 under 22.13.0, 24.20.0 and 24.22.1.
  • Prettier, targeted ESLint and the pre-review script pass — verified: formatting and lint are clean on the three files, and pre-review reports a clean merge and zero findings.
  • On the minimum Node version the kept index left out files a code doc imports, so an edit could leave the hint stale — verified by the same test and by a plain-Node import probe that records nothing on the base under 22.13.0.
  • Node 22.13.0 loads native ES modules through the promise readFile — verified: the probe records the importing and imported modules under 22.13.0 only once that function is wrapped.
  • The recorder wrapped synchronous reads only; the route assertions passed and the dependency-stamp assertion failed — verified at name-index.test.mjs:511 on the base.
  • The fix reuses the content-read wrapper and first-read stamps, keeps nested runs, and passes the original promise through — verified in read-record.mjs:105-139 and the nested-run test.
  • No module hooks, compatibility-policy changes, retries, waits or assertion changes — verified from the diff.
  • The global-mode spec requires a kept value to be reused only while every input its gather read is unchanged — verified in its FR7.
  • No public API or Node floor change — verified: exports, command docs and the engines field are unchanged.
  • The scheduled minimum-Node workflow failed on main in its Node 22.13.0 test leg — verified from that run.
  • The target test failed on main under 22.13.0 before the fix and already passed under Node 24.22.1 — verified (also under 24.20.0).
  • The existing name-index test still checks every dependency stamp, reuse after an unrelated edit and a rebuild after a dependency edit — verified in name-index.test.mjs:448-547.
  • The new regression covers a promise read by file URL, nested recording, edit detection and nothing recorded outside a run — verified in read-record.test.mjs:55-77; it fails on the base under all three Node versions.
  • Only the recorder, its test and a CLI patch changeset change, with no existing test or workflow changed — verified: three files.
  • Follow-up: the merge conflict with main is resolved by matching main's header, with no behaviour change, and both test files pass on the combined merge — verified: the header is main's wording, the trial merge is clean, and 44 of 44 tests pass under 22.13.0 and 24.20.0.

Files:

  • .changeset/record-async-doc-inputs.md — clear.
  • packages/cli/foundation/fs/read-record.mjs — clear; its header now matches main's and is accurate once merged.
  • packages/cli/foundation/fs/read-record.test.mjs — clear.

Automated review (maintainer link)

cixzhang added a commit that referenced this pull request Nov 17, 2026
* fix(cli): record asynchronous reads of doc dependencies

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.

* chore(changeset): credit the contributor on record-async-doc-inputs

Takes #11848's head.

* Merge remote-tracking branch 'origin/main' into fix/record-async-doc-reads

# Conflicts:
#	packages/cli/foundation/fs/read-record.mjs

* Merge remote-tracking branch 'origin/main' into fix/record-async-doc-reads

* Merge remote-tracking branch 'origin/main' into fix/record-async-doc-reads

* test(cli): read-record's temp root is its real path, so macOS matches 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.
@astracat-bot

astracat-bot Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

Landed on main as #11850 (re-cut by @cixzhang). Thanks!

@astracat-bot astracat-bot Bot closed this Nov 17, 2026
@github-actions
github-actions Bot deleted the codebunny/fix/fix-cli-record-asynchronous-reads-of-doc-dependencies-812e5b branch November 17, 2026 06:03

This branch was successfully deployed

1 active deployment
Preview — d4d980f7 Deployed Nov 15, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants