Skip to content

chore: sync core lib and CLAUDE.md from agent-core#40

Merged
avifenesh merged 1 commit into
mainfrom
chore/sync-core-ship-20260530-093142
May 30, 2026
Merged

chore: sync core lib and CLAUDE.md from agent-core#40
avifenesh merged 1 commit into
mainfrom
chore/sync-core-ship-20260530-093142

Conversation

@avifenesh

Copy link
Copy Markdown
Contributor

Automated sync of lib/ and CLAUDE.md from agent-core.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request addresses Time-of-Check to Time-of-Use (TOCTOU) race conditions across several modules by introducing safe file reading and writing utilities. Specifically, it adds readFileWithLimit to open files once and perform size and type checks on the file descriptor, and adopts atomic writes to prevent race conditions. Feedback on the changes suggests that in lib/patterns/slop-analyzers.js, calling fs.openSync and fs.fstatSync on the injected fs object may break existing test mocks that only implement statSync and readFileSync, leading to silent failures. A fallback mechanism is recommended to ensure backward compatibility.

Comment thread lib/patterns/slop-analyzers.js
@avifenesh

Copy link
Copy Markdown
Contributor Author

This is an auto-sync of the already-reviewed agent-core fix (PR agent-sh/agent-core#25). The auto-reviewer's symlink/TOCTOU notes are addressed by the design: reads use the fd-based readFileWithLimit, and writes use writeFileAtomic (temp file + atomic rename). rename() replaces the path entry itself and never follows a symlink to its target, so it is symlink-safe by construction - the explicit assertNotSymlink in fixer.js is belt-and-suspenders for that path. Merging to keep lib in sync with the source.

@avifenesh
avifenesh merged commit 6550a18 into main May 30, 2026
6 checks passed
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