Skip to content

feat(plugin): add bounded scanLines to the sandbox filesystem - #55

Merged
sanchitrk merged 2 commits into
canaryfrom
claude/sandbox-scan-lines
Oct 9, 2026
Merged

sanchitrk merged 2 commits into
canaryfrom
claude/sandbox-scan-lines

Conversation

@sanchitrk

Copy link
Copy Markdown
Contributor

Second of three stacked PRs — based on #54. Merge that first.

What

  • SandboxFileSystem.scanLines(path, { startLine, endLine?, maxBytes }) — required on every backend's Provider and on Interface. Returns a window of the file's lines bounded by maxBytes, plus total lines/bytes and the first selected line's size, in one pass without holding more than the window.
  • Scan.LineScanner: the streaming implementation. The local VFS feeds it through positional reads (vfs.open/read), since the VFS read stream loads the whole file and stalls before open.
  • Scan.script + Scan.viaShell: the same rules as a POSIX sh + awk script run inside remote sandboxes (Daytona, Vercel, and the vendored third-party Vercel driver), so only the window crosses the network.
  • The scan is bounded by the file size seen when it starts, so a growing file cannot extend it.

Rules

Lines split on \n; a trailing newline ends the last line rather than starting one. A UTF-8 BOM at the start of the file is not part of the first line; one later in the file is text. Lengths are bytes.

Testing

  • test/sandbox.scan.test.ts: a shared corpus (empty, BOM variants, CRLF, multibyte, blank lines, %/\n in text, trailing spaces, a file larger than one 64 KiB read, …) checked across an independent reference, the scanner fed byte-by-byte and whole, and the shell script under the host's sh/awk. Artifact: __artifacts__/sandbox.scan.json.
  • The same corpus runs through every local backend (filesystemSpec) and live remote sandboxes (remote.spec); live Daytona and Vercel pass.

🤖 Generated with Claude Code

Base automatically changed from claude/sandbox-mutation-queue to canary October 9, 2026 08:32
sanchitrk and others added 2 commits October 9, 2026 19:43
Required on every backend: a window of a file's lines, bounded by maxBytes,
in one pass and without holding more than the window. LineScanner is the
streaming implementation the local VFS uses through positional reads; a
POSIX sh + awk script with the same rules runs inside remote sandboxes so
only the window crosses the network (Scan.viaShell). The scan is bounded by
the file size seen when it starts, so a growing file cannot extend it.

A shared corpus checks the scanner, the script and an independent reference
against each other, every local backend, and live remote sandboxes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Match the rest of the codebase, which uses TypeScript `private` rather than
`#` fields; nothing outside the class reads them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sanchitrk
sanchitrk force-pushed the claude/sandbox-scan-lines branch from 84a10d9 to 20997b4 Compare October 9, 2026 14:13
@sanchitrk
sanchitrk added this pull request to stack #58 October 9, 2026 14:14
@sanchitrk
sanchitrk merged commit f5454e1 into canary Oct 9, 2026
@sanchitrk
sanchitrk deleted the claude/sandbox-scan-lines branch October 9, 2026 14:15
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