writedoor

package
v0.209.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 8, 2026 License: Apache-2.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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 IsOpaque

func IsOpaque(s string) bool

IsOpaque reports whether a snapshot entry is a marker rather than real bytes.

func Unified

func Unified(changes []Change) (diff string, files []string)

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.

func Changes

func Changes(before, after Snapshot) []Change

Changes returns every path whose content differs, sorted by path so the diff and the touched-path list are deterministic — a diff whose hunk order depends on map iteration is not reviewable and not comparable between runs.

type Snapshot

type Snapshot map[string]string

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

func Take(root string) (Snapshot, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL