Documentation
¶
Overview ¶
Package writedoor turns "what did the seat change under this directory" into a unified diff the CALLER reviews and applies — the harness never applies one (register D-06). It is the delegation lane's whole write-back mechanism: a delegated implementation leg runs against the node's own throwaway copy of the context docs, and the only thing that crosses back is the text of the change plus the list of paths it touched.
Why a before/after TREE snapshot rather than an effect ledger of the tool calls: the ledger records that write_file ran, not what the bytes became, and a seat that writes a file it was never asked to touch is invisible in it. The snapshot is authoritative about the world — it sees every write however it arrived, including one the model made and then partly undid.
Index ¶
Constants ¶
const SnapshotMaxFileBytes = 1 << 20
SnapshotMaxFileBytes bounds ONE file read into a snapshot. A file larger than this is recorded as an opaque size marker rather than content: it cannot be line-diffed usefully anyway, and reading it would put the node's memory at the mercy of whatever the seat wrote. The marker still makes the file show up as CHANGED, which is the property that matters — a cap must never hide a mutation.
Variables ¶
This section is empty.
Functions ¶
func Unified ¶
Unified renders the changes as one git-style unified diff and returns the touched paths beside it. Paths are prefixed a/ and b/ so the output applies with `git apply -p1` / `patch -p1`, the two things a reviewer actually reaches for. An empty change list renders as the empty string, never as a diff with no hunks — "nothing changed" must be distinguishable at a glance.
Types ¶
type Change ¶
type Change struct {
Path string // slash-separated, relative to the snapshot root
Kind string // "added", "modified", "deleted"
Before string
After string
}
Change is one path's fate between two snapshots.
type Snapshot ¶
Snapshot is one directory tree's content, keyed by slash-separated path relative to the snapshot root. A nil Snapshot is the empty tree.
func Take ¶
Take walks root and records every regular file under it. Directories, symlinks and every other non-regular entry are SKIPPED, not followed: a symlink is a pointer out of the tree, and a write door that diffed through one would publish — and invite the caller to apply — a change to a file outside the root it was confined to.
A missing root is the empty snapshot, not an error: the write root is created on demand, so "not there yet" is a legitimate before-state.