Skip to content

feat: standards, rules every change is held to - #92

Merged
jflavan merged 44 commits into
mainfrom
feat/standards
Oct 28, 2026
Merged

jflavan merged 44 commits into
mainfrom
feat/standards

Conversation

@jflavan

@jflavan jflavan commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

Rules a team writes once, checked at every gate, with a record per change of how each rule was kept.

  • Design: docs/superpowers/specs/2026-10-28-standards-design.md, with a "Changed while building" list at its end.
  • Plan: docs/superpowers/plans/2026-10-28-standards.md.
  • Every call made while building is a bullet in docs/decisions.md under "Standards (2026-10-28)".

Standards

  • The files. A standard is loopstra/standards/<name>.md:
    • a title, free context text, and ## Rules written as - LABEL: text;
    • optional front matter: applies_to (globs), needs_person, and check (a command).
  • Where they are read. Always from main's commit, never the checkout.
  • When a file cannot be read. The loop starts no steps until it is fixed, but requests, syncing and signals keep working, so a fix from the console still lands. loopstra start warns rather than refuses.
  • Spec gate.
    • The spec's ## Standards section lists only the rules its design decides something about, plus exceptions.
    • A code check confirms each label is real.
    • spec-check judges breaches.
  • Plan gate.
    • The plan covers every rule that applies to its files.
    • A code check confirms full coverage.
    • plan-challenge judges breaches.
  • Build, resolve and review are told the rules that apply. A review finding can name a rule, and review.md gets a "Findings against the standards" list.
  • Merge gate.
    • A diff that edits loopstra/standards/ blocks. The test-protection hook also refuses such edits in every writing session, resolve included.
    • A needs_person standard that applies, or that a person added, makes the change wait for a person through the existing risky-change gate.
    • Tool checks run after the tests, through the existing fix loop. They get LOOPSTRA_BASE, the merge base, so scanners can report only new findings.
  • Done. The done-check judges each rule. The runtime appends a ## Standards section to outcome.md that names the standards' commit and lists the rules, exceptions, tool checks and scope changes. Unmet rules block.
  • Exceptions.
    • A spec or plan can write - LABEL: exception: why. No agent can grant one.
    • The gate waits for a person (spec_gate / plan_gate), even when nobody is on that gate in the config.
    • Each approval is recorded with who, where and when in the change's intent/<slug>/standards.md. Undoing the approval takes it back out.
  • Per-change scope. A person can add a standard to one change, or remove one with a note. This is a new standards-scope request, recorded in the same file.
  • Repositories without standards are unchanged. A golden test checks that the prompts are byte-identical. The standards instructions are appended from code only when standards apply; no shipped prompt template changed.

Surfaces

  • loopstra standards lists the standards, their scopes and labels, and any problems.
  • loopstra setup standards adds, edits and removes standards interactively. It suggests a base-aware scanner that is already installed and tries each new or changed check on main. setup --check checks every standard and warns when a check already fails on main.
  • Console:
    • Settings › Standards: a form with an "Edit as Markdown" toggle, and "Try it on main".
    • "Exceptions granted": every exception and scope change across changes.
    • A Standards panel on each change, with an explicit "Allow the exception and approve the plan" button and an add/remove dialog.
    • Writes go through agent-files and standards-scope requests that the loop applies and commits. The Origin check covers every POST, and "try" never runs a command the page sends.
  • Onboarding. The operator skill gets a "Set up the standards" step: draft standards from the team's design records, policies, lint configs and CI, then check them. The agent never commits.

Review

  • Building. Built task by task (20 tasks), each with its own spec-and-quality review and fix rounds. Those reviews caught, among others:
    • git failures silently dropping rules;
    • undoing an approval keeping its exceptions;
    • the done-check's schema forcing a standards field in every repository;
    • "Edit as a form" bouncing back to Markdown.
  • Branch review. I ran /code-review high on the whole branch and fixed all 10 findings, plus 6 smaller ones left from the task reviews, in one wave that was then re-reviewed:
    • files the checks rewrote are put back when a tool check keeps failing;
    • an added needs_person standard waits for a person;
    • setup's edit leaves a file untouched rather than dropping text it cannot keep;
    • loopstra start warns instead of refusing, so the console's fix can land;
    • outcome lines with empty evidence read back;
    • the console names uncommitted files the way git does (-z);
    • Needs attention survives a failed read;
    • reads of the standards are cached per commit, and the merge diff is computed once;
    • duplicated helpers are merged;
    • main is resolved once in "try on main";
    • one-line review lines;
    • tool checks start after the tests in parallel_checks mode;
    • the scope dialog can't be sent twice;
    • glob and label edge cases;
    • the hook normalizes paths.
  • Left as is.
    • The outcome parser takes the last ): before a result word, so evidence shaped like (x): met: could be misread.
    • standardsFilesAt reads one blob per file at a time, which is fine for a handful of standards.

Test plan

  • bun run check: typecheck, lint, dead-code, and 2203 tests pass, 0 fail, up from 1953
  • New tests:
    • standards, standards-record, standards-command, setup-standards, console-standards and ui-standards;
    • the standards cases in stages-*, apply, risk, hook, status, envelopes and context;
    • tests/integration/standards-tick.test.ts, standards-run.test.ts and golden-prompts.test.ts.
  • CI on ubuntu, macOS and Windows (a second run after making three tests portable to Windows)

🤖 Generated with Claude Code

jflavan and others added 30 commits October 28, 2026 07:47
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… coverage

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…, checks that fail on main

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ing rules

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The prompts design, spec-check, plan, plan-challenge, build, review and
done-check send for one change in a repository without standards, rendered
by the loop as it is now. Standards must leave them byte for byte the same.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The standards prompt variable carries the standards that apply to a change,
with what each phase does with them (src/standards-prompt.ts). phasePrompt
puts them where a repository's prompt has {{standards}}, else at the end,
and adds nothing when the repository has no standards, so its prompts stay
byte for byte what they were (the golden test).

The design and spec-check sessions get the spec's view of them
(stageStandards with no files): those for every change and those added,
then the scoped ones apart, then approved exceptions. The spec gate gets a
standards code check: a Standards section, and only labels of real rules.
A spec-check finding may name its rule in standard; the label comes first
in the rewrite's findings and the gate's evidence.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Build and resolve are given the standards that apply to the plan's files; review the
ones that apply to the diff (changedFiles, shared with the merge checks). A finding can
name a rule (finding.standard), and review.md then lists it under Findings against the
standards. REVIEW.md's template gets a Standards pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…where they say

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…them

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…w when no rule was judged

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The protect-tests hook refuses an Edit or Write under loopstra/standards/
in acceptance, build, fix, reconcile, revise and resolve. The standards
rule runs before every other rule and is never logged to
LOOPSTRA_PROTECTED_LOG. Resolve takes the standards rule only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jflavan and others added 14 commits October 28, 2026 11:56
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
README gets a Standards section (files, which apply when, each gate, exceptions,
per-change scope, the record, fail-closed reading, the commands, setup, the console,
checks that fail on main, onboarding, two worked examples, and the limits), and the
places it touches (setup's sections, gates, merge checks, the hook, configuration).
architecture.md lists the new modules by layer; decisions.md records the user's
choices, Claude's calls, the plan's deviations and the rulings made while building;
the spec's spec_gate sentence is corrected and a "Changed while building" list added.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Files the merge checks' commands rewrote are put back on every exit of
the tests check, a failing standard's check included, so a retry's rebase
never meets a dirty worktree. A needs_person standard a person added to a
change (its patterns matched nothing) brings a person: its risk patterns
are every file. The merge pass reads the branch's diff once for the
standards and the risk.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
loopstra setup standards edits a standard with its questions only when
the form keeps the file whole (the same decision the console makes); a
file with more text is left as it is, with a sentence saying to edit it by
hand or in the console as Markdown. An edit that changes no answer stages
nothing, compared by the form's text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
loopstra start no longer refuses when a standard on main cannot be read:
it prints the sentence as a warning and starts, since the running loop
is what applies a fix sent from the console (its ticks keep requests
working and start no step until main reads).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A rule judged with no evidence is written with "no detail given", and
readOutcomeStandards reads a line with empty evidence and a title holding
"): " (the title runs to the last "): " before a result).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… has them

Settings › Standards reads git status with -z through statusPaths, so a
name with spaces or other alphabets, and both paths of a rename, are
listed as they are.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Needs attention catches a git failure reading main's standards and lists
it as one Standards item instead of failing the whole list. The files of
the standards folder are read at the same time, and a read by commit sha
is kept (the last eight), so the tick, Needs attention and the requests
do not read an unchanged commit again. branchStandards and
hasStandardFiles replace the copies in apply, attention and the scheduler.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The standards.applied marker's name and zod schema live in
src/standards.ts (readAppliedMarker), used by the merge gate, the done
step and the console's panel. The console uses fsutil.readText, and
text.oneLine (its length now optional) replaces three local copies.
checkOnMain resolves main once and runOnMain checks out the commit it is
given, so LOOPSTRA_BASE is always the commit checked out.
exceptionsToApprove loses its unused gate parameter.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A finding against a standard stays on one line in review.md's Findings
against the standards, however the reviewer wrapped it. With
speed.parallel_checks, the standards' tool checks start only once the
configured commands all passed, as the spec has it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The scope dialog sends once: Add it / Remove it is off while sending and
after the loop said yes (Close only then), and a standard no longer
offered is never sent. globProblem reads a class's contents literally
([[] is no unclosed bracket), and a rule bullet with a label but no text
has its own sentence. The protect-tests hook resolves . and .. segments
before the standards rule. The done-check envelope's comment says what an
absent standards list means.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…p edits, check order

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jflavan
jflavan merged commit 48603ec into main Oct 28, 2026
13 checks passed
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