jevbooks

← All design patterns

Viewfinder

State minimalism · 取景框

Frame only what is being judged

Send the one thing you are judging plus what judging it needs, and nothing else.

historylast msg

The problem

You are building a rule checker. Every time your coding assistant edits a file, you show the edit to Jev and ask whether it breaks one of the team's rules. The obvious thing to send is everything: the edit, and the whole conversation around it.

Imagine edit 1 going out as 800 tokens (the units of text you are billed for), with the rule firing at 0.84. By edit 200, the state has grown to 24,000 tokens and the same rule returns 0.52, with fifty unrelated messages between the rule and the change. Thirty times the state tokens, and less useful evidence for this decision.

Trimming blindly breaks it the other way. Send the command line 'bash cleanup.sh' on its own, without the script it runs, ask whether it is dangerous, and the model is guessing about a file it has never seen.

The solution

The Viewfinder pattern says: decide what the one thing is before you decide what to send. It is a message, a paragraph, one edit, one tool call — and that unit stays the same size however long the session runs.

Then add only the context the judgment cannot do without. A command needs the script it will run. An edit needs the rule it might break, not the chat around it. The goal is not less material, it is the right frame.

When it still does not fit, shrink in stages instead of cutting mid-sentence: 4,000 characters, then 2,000, then 1,000; if it still does not fit, stop and say so rather than send half a change. This text checker also rejects encoded files before sending them: they are outside its input contract.

Ask · Answer · Act

  1. AskPut in this one edit and this one rule, and ask whether the edit breaks the rule.
  2. Answer0.84.
  3. ActThat is over the 0.8 line, so the edit is held back and the author is told which rule it hit.

Where the name comes from

A camera viewfinder. The landscape is huge; you still choose which slice to frame before you press the shutter. What stays outside is not gone, it is just not in this picture — and every extra passer-by you let in makes the subject smaller.

Use it when

The thing being judged can be cut out on its own: one message, one paragraph, one edit, one tool call.

Not when

The judgment needs the whole picture. 'Should this tool call be kept in the conversation?' cannot be answered without the conversation.

Projects that do this

  • abide — Enforce project rules on coding agents with Jev.
  • mastra-jev-moderation — Mastra input moderation on Jev: one file, one typed request.
  • snifftest — Prose linter that flags AI writing tells with countable rules and one judgment model.

All projects with this pattern →

Read this code
Show me the code
const patch = fit(edit.patch, [4000, 2000, 1000]);       // shrink in stages, never cut mid-sentence
if (!patch || isBase64(patch)) return unreadable();      // this checker accepts plain text only
const state = { rule: rule.text, file: { path: edit.path, patch } };  // this rule, this edit, nothing else
const { answers } = await jev(state, {
  violates: noul("Does this change break `rule`?"),
});
How jevbooks recognises it

How do we know a project does this? We put one question about its README to Jev and it returns a percentage; the higher, the more it looks like it. If you copy the question, copy one thing: ask whether the text mentions this one concrete thing, never whether the project is good.

questions.json · sent for every README
{
  "state-minimalism": {
    "type": "noul",
    "instructions": {
      "what": "Does the text describe deliberately sending only the item under judgment, such as the last message or a single paragraph, rather than the whole history?",
      "not_for": "Sending full transcripts or documents."
    },
    "criteria": {
      "true": "The text explicitly describes this. One sentence is enough; other content does not cancel it.",
      "false": "The text does not describe this."
    }
  }
}

Build this with Jev →