Skip to content

fix(test): close remove-tree lint AST false positives and negatives - #825

Open
ScriptedAlchemy wants to merge 1 commit into
mainfrom
cursor/fix-remove-tree-lint-gate-9ddd
Open

ScriptedAlchemy wants to merge 1 commit into
mainfrom
cursor/fix-remove-tree-lint-gate-9ddd

Conversation

@ScriptedAlchemy

@ScriptedAlchemy ScriptedAlchemy commented Sep 17, 2026

Copy link
Copy Markdown
Owner

After #823, scripts/check-test-remove-tree.mjs still missed four parser-backed cases Codex flagged.

Fixes

  • Shorthand maxRetries: { recursive: true, maxRetries } is accepted (ShorthandPropertyAssignment).
  • Shadowed rm: a later local binding after import { rm } from 'node:fs' is not treated as Node-bound.
  • promises rebind: import { promises as fs } from 'node:fs' (or 'fs') is a namespace / .rm carrier.
  • Option wrappers: unwrap AsExpression, ParenthesizedExpression, and SatisfiesExpression so { recursive: true } as const is still seen as recursive.

The gate stays typescript-5 AST-backed. No regex / text masking.

Tests

packages/agent-bundle/tests/check-test-remove-tree.test.ts now covers both directions:

  • shorthand maxRetries is OK
  • shadowed local rm is ignored; unshadowed Node rm still fails
  • import { promises as fs } from 'node:fs' + recursive rm without maxRetries fails; with maxRetries passes
  • { recursive: true } as const without maxRetries fails; with maxRetries passes
  • parenthesized / satisfies wrappers without retries still fail

Existing removeTree helper exemption and good-path cases stay in the file.

Notes

  • Scripts + tests/** only; no changeset (publishable changedFilePatterns exempts tests/**).
  • Do not squash-merge. Do not touch Version Packages (Version Packages #411).

Verification

Ran after pnpm build (rstest dist-freshness):

pnpm exec rstest --config rstest.unit.config.ts packages/agent-bundle/tests/check-test-remove-tree.test.ts
# pass — 13/13, including the two new regressions

pnpm exec rstest --config rstest.unit.config.ts packages/agent-bundle/tests/support/remove-tree.test.ts
# pass — 2/2

node scripts/check-test-remove-tree.mjs
# exit 0 — no false positives on the live test trees
Open in Web Open in Cursor 

Recognize shorthand maxRetries, shadowed local rm, named promises
rebinds from fs/node:fs, and assertion/paren/satisfies option wrappers.

Co-authored-by: Zack Jackson <ScriptedAlchemy@users.noreply.github.com>
@changeset-bot

changeset-bot Bot commented Sep 17, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: aeb8c3f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@ScriptedAlchemy
ScriptedAlchemy marked this pull request as ready for review September 17, 2026 05:16
@pkg-pr-new

pkg-pr-new Bot commented Sep 17, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/ScriptedAlchemy/agent-bundle@825
npm i https://pkg.pr.new/ScriptedAlchemy/agent-bundle/create-agent-bundle@825
npm i https://pkg.pr.new/ScriptedAlchemy/agent-bundle/rsc-markdown-stream@825
npm i https://pkg.pr.new/ScriptedAlchemy/agent-bundle/@agent-bundle/runtime@825

commit: aeb8c3f

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: aeb8c3f1c3

ℹ️ 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".

Comment on lines +182 to +186
if (ts.isSourceFile(current) || ts.isBlock(current) || ts.isModuleBlock(current)) {
const shadowed = current.statements.some((statement) => {
if (ts.isSourceFile(current) && ts.isImportDeclaration(statement)) return false;
return statementDeclares(statement, name);
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Handle loop bindings when resolving shadowed imports

When a newly recognized promises alias is shadowed by a loop binding—for example, import { promises as fs } from 'node:fs'; for (const fs of mockFilesystems) await fs.rm(root, { recursive: true })—this scan never sees the ForOfStatement declaration because statementDeclares only accepts variable statements, functions, and classes. The loop-local call is therefore attributed to Node and produces a lint false positive; include loop initializer bindings and analogous lexical declaration sites in shadow resolution.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-17T05:21:37.432719Z aeb8c3f Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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.

2 participants