Skip to content

fix(pr-management): make the findings mod's link check read the harness stat shape - #2106

Merged
potiuk merged 1 commit into
apache:mainfrom
potiuk:fix/findings-link-check
Nov 15, 2026
Merged

potiuk merged 1 commit into
apache:mainfrom
potiuk:fix/findings-link-check

Conversation

@potiuk

@potiuk potiuk commented Nov 15, 2026

Copy link
Copy Markdown
Member

Summary

  • The review-findings mod checks that a curated sidecar (<file>.curated.json, <file>.curated.keep) is not a link before writing it, because mod hooks run outside the sandbox. The check called stat.isSymbolicLink() and stat.isFile(), which are Node's fs.Stats methods; the harness's $.fs.stat resolves { kind, size, mtimeMs, isLink }, so neither probe ever matched and the write always went ahead.
  • A new classifyWriteTarget reads that shape: a link (to a file or to nothing) or a non-file is refused, only ENOENT counts as "not there yet", and any other stat failure refuses the write. syncCuratedStateToDisk and cleanCuratedFindingsFiles both use it, and neither relies on $.fs.exists any more, which answers for what a path leads to.
  • The tests mocked Node's shape, and $ is typed any, so nothing caught the mismatch. The default mock now answers stat in the harness shape, and new cases cover a dangling link, a directory and a failing stat.

Found while re-reviewing #2080, which copied the same check; that PR got the same fix as a fixup commit.

Type of change

  • Other: Claude Code mod (plugins/magpie-pr-management/hooks/)

Test plan

  • claude plugin test plugins/magpie-pr-management: 86 passed.

Linked issues

None.

Generative AI disclosure: prepared with Claude Code (Opus 5).

🤖 Generated with Claude Code

…ss stat shape

The mod harness's `$.fs.stat` resolves `{ kind, size, mtimeMs, isLink }`, not
Node's `Stats`, so the `isSymbolicLink()` / `isFile()` probes never matched and
the curated sidecars were written through a link, or through a dangling one
that `$.fs.exists` reported as absent.

`classifyWriteTarget` judges each sidecar on `isLink` and `kind`, treats only
`ENOENT` as a missing file, and refuses on any other stat failure. The sync
and the cleanup both use it. The test mock now answers `stat` in the harness
shape, and new cases cover a dangling link, a directory and a failing stat.

Generated-by: Claude Opus 5
Claude-Session: https://claude.ai/code/session_01NyQq9UgHu7T8a8DfcfyP2M
@potiuk potiuk added family:pr-management pr-management-* skills capability:review Deep per-item code review or contributor mentoring labels Nov 15, 2026
@potiuk
potiuk enabled auto-merge (squash) November 15, 2026 13:11
@potiuk
potiuk merged commit 37f1a8f into apache:main Nov 15, 2026
9 checks passed
potiuk added a commit that referenced this pull request Nov 15, 2026
…2115)

Bumps .last-sync to 18de45e and records what the specs did not yet
describe: the two tools magpie-security-tools now ships (#2099), the POM
DTD/entity refusal (#2105), audit-report gather --product-name (#2096), and
how the findings mod decides a path is a link (#2106).

Generated-by: Claude Opus 5
Claude-Session: https://claude.ai/code/session_01NyQq9UgHu7T8a8DfcfyP2M
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

capability:review Deep per-item code review or contributor mentoring family:pr-management pr-management-* skills

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant