Tuft · executed example

Find it exactly.
Keep what you found.

In the Writfold harness, Tuft is how evidence is gathered: a small language that searches one pinned commit for exact text, keeps each hit as a citation bound by digest, and prints a compact view under a token budget. Nothing is ranked, guessed or summarised.

Runs today Exact text and regex over a pinned commit · source-only preview

01 / Four steps

Every call to open(url), cited

The same client.rs as the Splicery example, plus a worker.rs that calls open(url) three more times, committed to a small repository. The program asks for every call, at that exact commit.

Download client.rs · Download worker.rs · Download find-open.tuft. Put the two Rust files in src/ of a Git repository, commit, and replace the commit id with yours.

pub fn fetch_all(urls: &[&str]) -> Vec<Conn> {
    let mut out = Vec::new();
    for url in urls {
        if let Ok(conn) = open(url) {
            out.push(conn);
        }
    }
    out
}

pub fn warm(url: &str) {
    let _ = open(url);
    let _ = open(url);
}
@hits := find text "open(url)" in "src/" at "67fefbdd2a2964581fe777fc07d9714e62a3eb91";
@ev   := retain @hits around lines 0;
@view := project @ev [path, line, excerpt(max_chars: 60)]
           sort [path asc, line asc];
emit @view budget_tokens 400;

Pin the commit.

find searches the tree of one full commit id, never your working copy. Ask again tomorrow and the answer is the same.

Keep the bytes.

retain keeps each matching line's exact bytes as a citation, bound by digest, that a Weft report and an approval can cite.

Say what is missing.

emit prints rows within the token budget and ends with a trailer that always states coverage, how many rows were shown and omitted, and a cursor for the rest.

Search is exact text or a bounded regex. Over a pinned tree that makes it complete: when the trailer says coverage=complete and hits=0, there really is nothing there.

02 / Run it

What Tuft printed

Built from source (Try it), in the directory holding the repository and the program:

writfold trial init
writfold tuft run find-open.tuft --repo repo
src/client.rs:2:     let conn = open(url)?;
src/client.rs:8:     open(url).is_ok()
src/worker.rs:4:         if let Ok(conn) = open(url) {
src/worker.rs:12:     let _ = open(url);
src/worker.rs:13:     let _ = open(url);
# coverage=complete files=2/2 hits=5 shown=5 omitted=0 cursor=none program=f38b6c3460c8

One row per hit, as path:line: text, then the trailer. Five calls in two files, every file searched, nothing omitted. Ask for the binding field instead of the excerpt and each row carries its citation digest:

src/client.rs:2:ac53d1ca0b442b46de1563d90fd42b990a9904aac528446b397d761ef9ce14ac
src/client.rs:8:1ddad0e3c4bc7307ccfa49ba0b841dd1bf7c57736a8729d0b484073b6114817e

A Weft review cites one with asset call = citation "ac53d1ca…", and Writfold refuses to prepare an edit from a report that cites anything it did not retain. --out rows.txt writes the rows to a new file and prints only the trailer.

Development binary used: Writfold SHA-256 8813db29b305bd18728776747f612860ab5459b44cd3a60b1bfdcc34e31a345b; example commit 67fefbdd2a2964581fe777fc07d9714e62a3eb91.

03 / Never silently truncated

Budgets and cursors

With budget_tokens 40 instead of 400, the view stops at a whole row and says so.

src/client.rs:2:     let conn = open(url)?;
src/client.rs:8:     open(url).is_ok()
src/worker.rs:4:         if let Ok(conn) = open(url) {
# coverage=complete files=2/2 hits=5 shown=3 omitted=2 cursor=19a4d23622840784.3 program=64a3a3aba4a6

Three rows shown, two omitted, and a cursor. Running again with --cursor 19a4d23622840784.3 prints exactly the rest:

src/worker.rs:12:     let _ = open(url);
src/worker.rs:13:     let _ = open(url);
# coverage=complete files=2/2 hits=5 shown=2 omitted=0 cursor=none program=64a3a3aba4a6

A search for retry( finds nothing, and says it looked everywhere:

# coverage=complete files=2/2 hits=0 shown=0 omitted=0 cursor=none program=39eb1506261a

The token count is a documented estimate (about four bytes per token), named in the verbose envelope. In two pilots against grep-and-read, Tuft's typed, pinned and citable output cost within about 3% of grep's tokens at equal correctness; it does not save tokens on lookups a shell pipeline can reduce. Pilot results

04 / Refuse rather than guess

When Tuft refuses

Each of these was run against the same repository and exited 1 without printing rows.

Similarity

find similar "open a connection" is parsed and refused with T301: semantic search needs the Omnigraph backend, and it is never emulated with something fuzzier.

A moving target

at "HEAD" is refused with T206. Refs, abbreviations and HEAD change under you; only a full commit id is accepted.

Overwriting

--out rows.txt when rows.txt already exists refuses before the search runs. A view is written to a new file or not at all.

Tuft v0 has no ranking, no graph follow and no live corpus; those wait for Omnigraph behind the same grammar. Tuft lives in the Writfold repository; its language reference has the grammar. In the full flow, Tuft finds the evidence, Weft checks the plan against it, Splicery prepares the edit, and Writfold applies it after approval.