This repository was archived by the owner on Nov 9, 2026. It is now read-only.
Repository navigation
fix(baseline): Read only the last 4 MiB of a reviewer log - #466
Merged
Merged
Conversation
…le line The report view read every reviewer log whole, then built a line array and a same-length keep array from it, so a huge sandbox-written log cost the host memory in proportion to its size during final cleanup. It keeps only the last lines of each kind, so reading the end is enough. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…cut log, and test the cut at a character boundary Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ed open, and test the swap in a child process Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…and pin the FIFO refusal at both layers Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
The accepted device-node swap race requires human security review because the source snapshot and flag tests cannot establish deployed sandbox permissions or whether opening an attacker-swapped device is safe.
No open issues 🎉
What changed in this PR
This PR bounds memory use when Sandcastle generates reviewer-log reports, updating both the reusable Baseline Template and dotfiles’ copies.
Changes:
- Limits log input to a 4 MiB tail, preserves whole-line boundaries, and marks omitted content.
- Adds filesystem checks and open flags to reject non-regular logs and avoid blocking on swapped-in FIFOs.
- Adds boundary, encoding, and filesystem regression tests, and documents the cap.
| File | Description |
|---|---|
Support For New Projects/.claude/skills/repo-ci-baseline/template/owned/.sandcastle/lib/role-logs.test.mts |
Tests input limits, line boundaries, encoding, and unsafe file types. |
Support For New Projects/.claude/skills/repo-ci-baseline/template/owned/.sandcastle/lib/role-logs.mts |
Implements bounded tail reads and filesystem safeguards in the Template. |
Support For New Projects/.claude/skills/repo-ci-baseline/references/sandcastle.md |
Documents the cap and truncation marker. |
.sandcastle/lib/role-logs.test.mts |
Mirrors the Template’s regression tests. |
.sandcastle/lib/role-logs.mts |
Mirrors the Template’s bounded log-reading implementation. |
Review effort: Balanced
mpaulosky
added a commit
to mpaulosky/TicketManager
that referenced
this pull request
Nov 7, 2026
## Why Re-Apply the repo-ci-baseline Template so this repo carries the Template changes from mpaulosky/dotfiles#461, #460, #465 and #466. ## What changed - `4c4de51` Apply commit, `apply.sh` output alone: brings the Template changes above (new Sandcastle modules, the Template's `check.sh`, role prompts, workflow and skill updates). - Hand edits after the Apply, each a separate commit: - `.sandcastle/check.sh` (this repo's own Docker-free gate) renamed to `.sandcastle/sandbox-gate.sh`, so Apply can add the Template's Owned `check.sh`; `GATE_COMMAND` and `GATE_SCRIPT` follow. - `GATE_LIMIT_MINUTES`, which the new `step-limit.mts` needs, added to `repo-config.mts`; `CHECK_PATHS` and `.github/ci/sandcastle.sh`'s `SANDCASTLE_PATHS` extended to the review paths, with tests in `.sandcastle/repo-scripts.test.mts`. - `shared-rules.md` says a role prompt's `scripts/gate.sh` means `.sandcastle/sandbox-gate.sh` in the sandbox. - `.sandcastle/lib/role-logs.mts` and its test come from mpaulosky/dotfiles#466 (a reviewer log is read only as far as its last 4 MiB, which answers Copilot's memory-bound thread on this PR). - `LICENSE` keeps its 2022 year (the Template's Owned copy says 2021, so each re-Apply reverts it); the Seed Dockerfile pins markdownlint-cli2 0.24.0 to match `scripts/gate.sh` and the v25 lint action. ## Verification - Against `main` this PR changes no pinned action, no `global.json` SDK and no LICENSE year (the Template now carries the newer pins, mpaulosky/dotfiles#465). - The pre-push gate (`scripts/gate.sh`) passed, and the local pre-push review is recorded clean (3 rounds, 6 findings, all fixed; then a second run on the re-Applied `role-logs.mts`: 1 Advisory left open, about CI treating the review skills' Markdown as docs-only, which needs a Template change). - `GATE_LIMIT_MINUTES = 10` is the Template default: `sandbox-gate.sh` took 52 s on a warm worktree outside the sandbox, a cold or loaded sandbox run was not timed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Copilot's review of mpaulosky/TicketManager#258 (a verbatim copy of this Template file) pointed out that
lib/role-logs.mtsread every reviewer log whole into a string, then built a line array and a same-length keep array from it. The sandbox writes that log, so its size is the sandbox's choice, and a huge log cost the host memory in proportion to its size while generating the run report. The view keeps only the last lines of each kind, so reading the end of the log is enough.What changed
Both the Template's Owned
role-logs.mtsand dotfiles' copy of it:REPORT_INPUT_LIMIT(4 MiB):liveRoleLogFs.readreads at most the last 4 MiB (plus one byte, so a cut on a line break keeps that line), from a whole line;allowlistedViewapplies the same cap to the text it is given.[... lines left out]marker, so a cut log can't be mistaken for a quiet one.readLogTailchecks the log withlstatbefore opening it (a symlink, device, FIFO, socket or directory is refused without an open), then opens withO_NOFOLLOW | O_NONBLOCK | O_NOCTTYand checks withfstat, so an entry swapped in after the check can't make the host wait on a FIFO. A device node swapped in inside that window is still opened and refused afterwards; the comment names that accepted gap.references/sandcastle.mdgets one sentence on the cap.The Template's tests cover the cut at n-1, n and n+1 for both caps, a cut on a line break, a tail with no line break, CRLF, an empty file, a cut in the middle of a multi-byte character, and the refusal of a symlink, a directory and a FIFO (the FIFO swap in a child process, so a regression fails the test instead of hanging the suite). Shifting each bound or dropping each flag fails a test; the one mutant that survives is equivalent.
Not part of this change: Copilot's other thread on #258 (credentials split by invisible fillers or hex chunks in error lines).
Review
Local pre-push review: 4 rounds, 16 findings (2 Warnings and 1 Critical, all fixed behind tests), 1 Advisory left open (the wording of the comment on the accepted gap, which needs the sandbox's write access to the logs folder confirmed).
🤖 Generated with Claude Code