Skip to content

docs(wg): add Scratch RFC (session scratch directory) - #915

Merged
softmarshmallow merged 2 commits into
mainfrom
docs/scratch-rfc
Jun 29, 2026
Merged

docs(wg): add Scratch RFC (session scratch directory)#915
softmarshmallow merged 2 commits into
mainfrom
docs/scratch-rfc

Conversation

@softmarshmallow

@softmarshmallow softmarshmallow commented Jun 29, 2026

Copy link
Copy Markdown
Member

What

Adds a dedicated WG spec — docs/wg/ai/agent/scratch.md — naming a primitive the guide had only leaned on informally (the stage-to-scratch perception path in vision.md, the archive-extraction scratch in binary.md): the per-session, system-managed, ephemeral filesystem area where the agent does working I/O and where produced files land by default, distinct from the durable workspace.

Why now

Surfaced while planning the generate_image/generate_video agent tools: when the agent produces a file (a generation, a download, a conversion), there's nowhere for it to land — the strategic agent's only durable fs surface is the workspace, which is the wrong place for throwaway output. Scratch is that tool's placement target, so the contract lands first (the tool impl is deferred).

The contract

Five invariants:

  • S1 — host-owned and per-session (the agent is told its location, doesn't choose it).
  • S2 — ephemeral; durability only by promotion (moving a file out of scratch). Nothing of value lives only in scratch.
  • S3 — the default output sink for tools that produce files.
  • S4 — reachable without per-operation approval yet inside sandbox containment (the bounded, pre-authorized middle).
  • S5not the workspace: workspace edit contracts (read-before-edit / freshness) don't govern scratch.

Plus lifecycle, a bindings table for what hosts vary (location, cleanup policy, reach mechanism, surface exposure), and the implementor checklist.

Reconciliation

  • binary.md's "Scratch space for extraction" now defers the concept to this canonical page (its section is the archive-extraction application — its location notes are this page's bindings seen from that use case). Link only, no behavioral edit.
  • vision.md's stage-to-scratch mention now links here.
  • Wired into the cluster hub (index.md Pages table).

Grounding

Primary-source: codex (writable roots = cwd + OS /tmp/$TMPDIR, no managed dir), opencode (managed /tmp/opencode + a tool-output/ store, reached via an external_directory allowlist), and sandbox products (OpenAI /mnt/data, AgentCore /mnt/workspace, e2b — per-session managed mounts). Per WG doctrine the page stays code- and product-agnostic; the grounding informed confidence, not citations.

Scope

Spec only. The generate_* tool impl and any code (a binary-write primitive, the scratch manager, capability wiring) land when the impl issue is taken, after this RFC sets the contract.

Summary by CodeRabbit

  • Documentation
    • Added a new agent guide documenting the per-session “scratch” filesystem area, including lifecycle, boundaries (scratch vs. workspace), invariants, and usage rules.
    • Updated the guide index to include the new Scratch page.
    • Linked the vision “stage-and-reattach” guidance to the Scratch documentation.
    • Refined archive-extraction scratch guidance, narrowing suggested scratch locations to OS tempdir and sandbox-provided scratch, with updated trade-offs.

Names a primitive the guide had only leaned on informally: the per-session,
system-managed, ephemeral filesystem area where the agent does working I/O and
where produced files (generated images/video, downloads, conversions) land by
default — distinct from the durable workspace.

States the scratch contract: host-owned and per-session (S1); ephemeral, with
durability only by promotion out of scratch (S2); the default output sink (S3);
reachable without per-operation approval yet inside sandbox containment (S4);
and not the workspace — workspace edit contracts don't govern it (S5). Plus
lifecycle, a bindings table for what hosts vary, and the implementor checklist.

Reconciles the prior informal usage: binary.md's 'Scratch space for extraction'
now defers the concept to this canonical page (its section is the archive-
extraction application); vision.md's stage-to-scratch mention links here.
Wires the page into the cluster hub.

Grounded against codex (writable-roots + OS tmp, no managed dir), opencode
(managed tmp + tool-output store, allowlist-reached), and sandbox products
(/mnt/data-style per-session mounts); kept code- and product-agnostic per WG
doctrine.
@vercel

vercel Bot commented Jun 29, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment Jun 29, 2026 12:33pm
5 Skipped Deployments
Project Deployment Actions Updated (UTC)
backgrounds Ignored Ignored Preview Jun 29, 2026 12:33pm
blog Ignored Ignored Preview Jun 29, 2026 12:33pm
code Ignored Ignored Jun 29, 2026 12:33pm
grida Ignored Ignored Preview Jun 29, 2026 12:33pm
viewer Ignored Ignored Preview Jun 29, 2026 12:33pm

Request Review

@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c0fb068c-d0d9-47a4-baa6-a549255e8209

📥 Commits

Reviewing files that changed from the base of the PR and between 9660794 and b13a0b9.

📒 Files selected for processing (1)
  • docs/wg/ai/agent/binary.md
✅ Files skipped from review due to trivial changes (1)
  • docs/wg/ai/agent/binary.md

Walkthrough

Adds a new scratch.md specification for the agent scratch filesystem area, including its contract, lifecycle, and implementation bindings. Updates the guide index, binary guidance, and vision doc to reference the new page.

Changes

Agent scratch filesystem spec

Layer / File(s) Summary
scratch.md specification
docs/wg/ai/agent/scratch.md
New document defining scratch concept, workspace distinction, promotion model, vocabulary, S1–S5 contract invariants, lifecycle semantics, implementation bindings, implementor checklist, out-of-scope items, and see-also cross-links.
Cross-references in index, binary, and vision docs
docs/wg/ai/agent/index.md, docs/wg/ai/agent/binary.md, docs/wg/ai/agent/vision.md
index.md adds a Scratch page row; binary.md adds an introductory note under “Scratch space for extraction” linking to scratch.md; vision.md changes the scratch reference to a link.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Possibly related issues

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: a new Scratch RFC/spec for the session scratch directory.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs/scratch-rfc

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9660794b68

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docs/wg/ai/agent/scratch.md
Codex P2 on #915: binary.md still offered a '<workspace>/.agent-scratch/'
location with 'survives reboots' as a pro, which contradicts the new scratch
contract — S2 (ephemeral, bounded lifetime) and S5 (not the workspace). Drop
the workspace-resident row; keep OS-tempdir and sandbox-provided (both satisfy
S2/S5), and frame the table as scratch's location bindings seen from the
extraction case.
@softmarshmallow
softmarshmallow merged commit d384696 into main Jun 29, 2026
12 checks passed
@softmarshmallow
softmarshmallow deleted the docs/scratch-rfc branch June 29, 2026 12:36
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