Skip to content

fix(files): a read-only run reads a stored file's text with files download - #406

Merged
leemour merged 1 commit into
mainfrom
fix/download-stdout-read
Nov 25, 2026
Merged

leemour merged 1 commit into
mainfrom
fix/download-stdout-read

Conversation

@leemour

@leemour leemour commented Nov 25, 2026

Copy link
Copy Markdown
Member

Task

A scheduled agent runs locked (DRIVE_READ_ONLY=1). It could not read a Drive file's text, because drive counted files download as a write even without --output. The ruling is that a download answered on stdout is a read. Saving it to a local path stays a local write, refused under the lock. drive should match ydisk-cli.

Closes #402

What

  • files download is declared as ydisk's files download is: effects: FETCH, --output and --overwrite as ownerOnlyOption, and cli-core's writesFileOnlyWith(command, "output"). cli-core then runs it through drive_read over MCP.
  • drive's own policy check (checkPolicy) gets writesNothing for a download without --output. The lock and --read-only let it read. A readonly permission level still refuses it, the same as cli-core's MCP check. With --output, the lock still refuses it.
  • The untrusted marks from fix(documents): mark other people's text in drive's own reads, remove trashed files as deleted #395 stay on the text and the name.
  • One capability is removed: an agent over MCP can no longer save a download into the profile's export folder (<cache>/exports/<profile>/). It reads the text instead, as in ydisk.
  • files export is unchanged. It always writes a file (--output is required), so it has no stdout case. For text, an agent has documents get and sheets show.
  • Docs (docs/usage.md, docs/recipes.md, docs/dev/CLI_ALIGNMENT.md) and a changelog fragment.

Not covered here: cli-core does not export fileOptionOf, so drive names files download itself in program.ts, as it already did for the MCP export folder.

Testing

  • New: a locked run reads the text with marks, refuses --output <path> with the DRIVE_READ_ONLY permission error without downloading or writing, and refuses the read at files.download=readonly (src/untrusted-marks.test.ts).
  • New: over locked MCP, drive_read files download answers the text. output is not accepted, and nothing lands in the export folder (src/mcp-parity.test.ts).
  • pnpm ci:quick, pnpm lint, pnpm docs:check, pnpm generate:check and pnpm contracts:check pass.
  • Full suite on a machine at load 31 on 24 cores: 77 tests timed out, all in store and sync tests. Rerun with a longer timeout: 210 of 211 pass. The one left has its own 30 s limit (extended-program.test.ts, knowledge store). CI decides.
  • A fresh agent reviewed the diff. Its findings were fixed: the readonly level now matches MCP, a false changelog claim was removed, and the MCP tests no longer pass for the wrong reason.

🤖 Generated with Claude Code

…nload

files download without --output writes nothing on this computer, but drive
counted it as a write, so DRIVE_READ_ONLY=1 and --read-only refused it and a
scheduled agent could not read a Drive file's text at all.

As in ydisk-cli, --output and --overwrite are now owner-only options and the
command is marked with cli-core's writesFileOnlyWith(command, "output"):
cli-core routes it to drive_read over MCP, and drive's policy check lets the
lock and --read-only through when no --output is given. Saving with --output
stays refused under the lock. A readonly permission level still refuses the
read, as cli-core's MCP check does. The untrusted marks from #395 stay on the
answer. files export always writes a file and is unchanged.

An agent over MCP can no longer save a download into the profile's export
folder; it reads the text instead.

Closes #402

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@leemour
leemour merged commit 06b4b77 into main Nov 25, 2026
8 checks passed
@leemour
leemour deleted the fix/download-stdout-read branch November 25, 2026 11: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.

A locked read-only run cannot read a file's text: files download/export count as writes

1 participant