Skip to content

fix(resolvers): empty find must not fall through to cwd - #2483

Open
tranthanhnhatkhoa wants to merge 1 commit into
garrytan:mainfrom
tranthanhnhatkhoa:fix/resolver-empty-find
Open

fix(resolvers): empty find must not fall through to cwd#2483
tranthanhnhatkhoa wants to merge 1 commit into
garrytan:mainfrom
tranthanhnhatkhoa:fix/resolver-empty-find

Conversation

@tranthanhnhatkhoa

Copy link
Copy Markdown

Follow-up to #2482, which fixed this defect in bin/gstack-codex-session-import. Same bug, three more sites, two of them user-visible.

The bug

find ... | xargs ls -t runs ls -t with no operands when find matches nothing — and ls -t with no operands lists the current directory.

site effect when the dir is empty or absent
scripts/resolvers/review.ts:859 PLAN becomes a random .md from wherever /review was invoked, then gets read as the plan
preamble/generate-context-recovery.ts:15 "RECENT ARTIFACTS" lists unrelated cwd files
preamble/generate-context-recovery.ts:24 LATEST_CHECKPOINT points at a random file, which the skill is then told to read

All three only misfire when the projects dir has no ceo-plans / checkpoints / plans yet — a fresh install, which is exactly where a wrong answer is least likely to be recognized as wrong. A new user's first /review can silently review against someone else's markdown.

Lines 857–858 in review.ts pipe to grep -l, which reads stdin when given no files and correctly matches nothing. Left alone.

The fix

-exec ls -t {} + never runs the command when nothing matched. Same substitution as #2482, and the same reason for avoiding xargs -r: GNU-only, repo targets macOS, no existing use to follow.

Regeneration

These are resolvers, so the change propagates into generated docs:

  • bun run gen:skill-docs — 46 files
  • the three ship goldens in test/fixtures/golden/ refreshed by hand; they're byte-for-byte copies of generated output and have no update script, so gen:skill-docs leaves them stale and the golden tests fail until they're copied over

Worth knowing: .agents/skills/gstack-ship/SKILL.md and .factory/skills/gstack-ship/SKILL.md are gitignored, so git status shows nothing while their goldens go stale. Only the test catches it.

I checked every regenerated line — all are one of the three fixes or its comment. No unrelated drift.

Verified

suite before   17 fails
suite after    17 fails      (no new failures)
golden tests   3 fail -> 0

The 17 are pre-existing and unrelated; #2480, #2481 and #2482 cover 15 of them, and the remaining 2 are environmental on my box (no claude on PATH for the test user, and cdp-e2e needs Chrome).

Environment: bun 1.3.14, Ubuntu 24.04.4 LTS, main @ 960c3a8d (v1.60.2.0).

🤖 Generated with Claude Code

https://claude.ai/code/session_01H3KRWmyJnSvzzxeooDxuU3

Same defect as bin/gstack-codex-session-import: `find ... | xargs ls -t`
runs `ls -t` with NO OPERANDS when find matches nothing, and `ls -t`
with no operands lists the CURRENT DIRECTORY. Three sites, two of them
user-visible:

  review.ts:859
    PLAN becomes a random .md from wherever /review was invoked, and is
    then read as the plan for the review.

  generate-context-recovery.ts:15
    "RECENT ARTIFACTS" lists unrelated files from cwd.

  generate-context-recovery.ts:24
    LATEST_CHECKPOINT points at a random file, which the skill is then
    instructed to read.

All three only misfire when the projects dir has no ceo-plans /
checkpoints / plans yet — i.e. on a fresh install, where the wrong
output is least likely to be recognized as wrong.

`-exec ls -t {} +` never runs the command when nothing matched, and
avoids GNU-only `xargs -r` (this repo targets macOS and has no existing
`xargs -r` to follow).

Regenerated with `bun run gen:skill-docs` (46 files) and refreshed the
three ship goldens, which are byte-for-byte copies of generated output
and have no update script. Every regenerated line is one of the three
fixes or its comment — no unrelated drift.

Verified:
  suite before  17 fails
  suite after   17 fails, no golden or /spec regressions
  goldens       3 fail -> 0
@trunk-io

trunk-io Bot commented Aug 8, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

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.

1 participant