Files
openclaw/src/hooks
cxbAsDev 4b2b5bcf89 fix(hooks): bound hook workspace manifest and HOOK.md reads (#101472)
* fix(hooks): bound hook workspace manifest and HOOK.md reads

* fix(hooks): enforce maxBytes while reading hook metadata fd

ClawSweeper review noted that openRootFileSync validates stat size
before returning the fd, but the subsequent fs.readFileSync of the fd
was unbounded. A file that grows after validation could still OOM
workspace discovery. Replace the full fd read with a chunked bounded
reader that throws once maxBytes is exceeded, and add regression
coverage for the overflow case.

* test(hooks): cover bounded hook reads through public workspace API

* refactor(hooks): use canonical bounded fd reader for hook metadata

* fix(hooks): warn and skip oversized hook metadata during discovery

ClawSweeper review required the maintainer-selected oversized-metadata
diagnostic contract: warn and skip. readRootFileUtf8 now catches the
RangeError from the canonical readFileDescriptorBoundedSync helper and
emits one warning per oversized package.json/HOOK.md identifying the
path and the byte limit, while discovery continues for other hooks.

The redundant open-time maxBytes stat check is removed so the shared
bounded reader is the single owner of the byte cap; overflow always
surfaces as RangeError, keeping the warning accurate for both static
oversized files and post-open growth.

Add focused tests: warning content for both oversized surfaces,
continued discovery alongside an oversized hook, exact-limit acceptance,
and the plain-hook fallback when a package manifest is oversized.

* chore: retrigger CI after rebase

* refactor(hooks): tighten bounded metadata coverage

---------

Co-authored-by: Peter Steinberger <steipete@gmail.com>
2026-07-17 11:23:21 +01:00
..
2026-06-04 20:08:40 -04:00
2026-06-04 20:08:40 -04:00
2026-06-04 20:08:40 -04:00
2026-06-04 20:08:40 -04:00
2026-06-04 20:08:40 -04:00
2026-06-04 20:08:40 -04:00
2026-06-04 20:08:40 -04:00
2026-06-04 20:08:40 -04:00
2026-06-04 20:08:40 -04:00
2026-06-04 20:08:40 -04:00
2026-06-04 20:08:40 -04:00