Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ judge's own metric. Port the cases from `main`'s `tests/test_redteam.py`, re-exp
- **CI itself:** edit the workflow in the change; run the candidate in the trusted job; read secrets from an
untrusted job; trigger the trusted job on the candidate's definition.

## The adversary (the direction after the quickstart)
## The adversary (after the quickstart and a real optimizer)

Where an optimizer such as GEPA uses a model to improve an artifact, Morphogen uses a model to try to
fail the improvement. The adversary has no stake in a pass; it gains only by finding valid cases where
Expand Down Expand Up @@ -131,6 +131,30 @@ judge has run and measured them. Keep it honest:
verdict out.
- **Changes reach `main` by pull request.** Before merging, check that GitHub shows the head you pushed.
- **Decisions** go in `DECISIONS.md` as new rows (append-only: supersede, never edit).
- **A change to the policy is its own pull request**, never in the pull request of the work it judges.

## Rails (the owner's, 2026-11-21)

- **The measurer and the measured run apart.** Whatever produces the record that is scored (the harness,
the environment, the clock) is the base's code and runs outside the candidate's process; the candidate
talks to it across a process boundary and can never write that record. Time is measured per case by
that harness around the candidate's work, not as wall time around a container. This is a requirement
on any judge, not a detail of this CI: state it so another implementation could meet it.
- **Case sets renew.** No set serves forever: each has a generator or another source of fresh cases, and
reaching its staleness limit starts a renewal, not only a flag. Where cases are stored sits behind an
interface (fetch, claim a verdict's place, replace); a git repository is one store, not the only one,
so a store that enforces "the author cannot read the cases" by itself can take its place.
- **The verdict is a contract.** Its shape is written in one place (`schemas/verdict.v1.json`, explained
in `docs/verdict.md`): every field, its type, and what each KPI measurement carries. Readers outside this
repository depend on it, so any change to it is a breaking change: a new schema version, and a matching
change in those readers, agreed before it lands.
- **Judge the judge with a real optimizer.** The red team's score also counts cheats found by a real model
optimizing against the toy, reported separately from the hand-written ones. Use Haiku subagents or
OpenRouter `:free` models, never paid models.
- **A setup budget.** Track the minutes from nothing to a first verdict on a new repository; growth there
is a cost, to be justified like any other.
- **No more hardening of the CI without a red-team finding.** Effort goes to whether the judgment tells a
better change from a worse one: cases, statistics, measurement.

## Working with the owner

Expand All @@ -148,4 +172,5 @@ the judge accepts as evidence, spending money, publishing. Use plain words.
6. Case custody and staleness; the metering hook.
7. A quickstart: "an agent, a case set, is this pull request better" in ten lines, and a verdict a customer can
read.
8. The adversary (above): first on the toy, with its own A/A and red team, then on a consumer.
8. A real optimizer against the toy (the rails): its cheats, reported apart from the hand-written ones.
9. The adversary (above): first on the toy, with its own A/A and red team, then on a consumer.
1 change: 1 addition & 0 deletions DECISIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ Append-only. To change a decision, add a row that supersedes it; never edit an o
| 28 | 2026-11-19 | **Measured with the ruleset on `main`** (requires `morphogen/verdict` from the judge's app; admin bypass for pull requests only), judge `21b347f`. (a) **#92, the forger**, brought up to date with `main`: the judge refused it (protected path), then the forger's own workflow posted `morphogen/verdict` = success ("pass (forged)") 70 seconds later, so the commit's combined status reads success; GitHub still reports the pull request as **blocked**, because the forged status does not come from the app. The forgery no longer works. (b) **#96, docs only:** `pass (not judged)`, signed, posted by the app, nothing run; GitHub reports it **mergeable**. (c) **#97, one workflow file only:** `refuse: not admitted: not judged, and it touches what the judge relies on, which is a person's to merge`. #96 and #97 closed unmerged. |
| 29 | 2026-11-19 | **Owner's decision: the adversary is the direction after the quickstart** (`CLAUDE.md`, "The adversary", and step 8). A model whose only gain is finding valid cases where the candidate is worse than the base: it never sees the held-out cases, its expected answers come from outside it (the base where nothing should change, a reference, a checkable property), it can only veto (the fixed set with its stated statistics decides a pass; its cases, chosen after seeing the candidate, are hypotheses, confirmed on fresh draws for stochastic programs), it has its own A/A, and what it finds renews the held-out store. Prompt injection from the diff can only make it find less. |
| 30 | 2026-11-19 | **Timing red team, first finding: the judge's own run order made identical code look faster.** The run job ran every base case, then every candidate case, so drift in the machine's load over the run became a difference between the sides, and the paired sign test's assumption (each pair's sign a fair coin under no difference) failed. A/A (`e2e/aa_timing.py`: the dogfood toy on both sides, 30 cases, wall time as a *deciding* KPI, alpha 0.05, two orderings alternated rep by rep on the same machine): **blocked order passed identical code as faster in 4 of 30 runs (13%)**, and in 1 of 4 in an earlier quick check; **paired order, 1 of 30 (3%)**. 4 of 30 alone is weak evidence (P = 0.06 at a true 5%), but pairing is the standard control and costs nothing. Fix: `judge.run` now runs both sides itself, case by case, back to back, the order inside each pair by coin flip (`run_pairs`; `ran_first` recorded per record); the GitHub and Gitea workflows and the smoke test use it. Test: `tests/test_run_order.py`. Still open in the timing batch: wall time here is mostly container start (about 0.18 s of 0.2 s), so it measures little real work; a patched timer and a printed measurement cannot decide (the runner measures, printed numbers are only reported); doing less work only when timed, memoising and disk caches are bounded by one fresh read-only container per case, and need their own tests. |
| 31 | 2026-11-21 | **Owner's decision: five rails, and a new order of work** (`CLAUDE.md`, "Rails"; a policy pull request of its own). (1) The measurer and the measured run apart: the base's harness produces the scored record outside the candidate's process, and times each case itself; stated as a requirement on any judge, since Substrate's judge interface (Substrate S-153) adopts it for every filler and MetaSoar's harness is getting the same fix. (2) Case sets renew: a generator per set, staleness starts renewal, and storage behind an interface, not wired to one repository (a store that enforces unreadability itself, such as a database scope the author's role cannot read, may replace it later). (3) The verdict is a contract: one written shape, and any change to it is breaking, with a matching change in its readers (the Knowledge Kernel's encoder reads verdicts as DQV measurements and PROV, kernel D-99; Substrate's vocabulary has Verdict, better/worse/same, measurement, forGoal, against, kernel D-102). (4) Judge the judge with a real optimizer, Haiku subagents or OpenRouter `:free` models only, its cheats reported apart. (5) A setup budget. (6) No more CI hardening without a red-team finding. Also written down: a change to the policy is its own pull request. New order after the custody step: quickstart, a real optimizer against the toy, then the adversary. Morphogen is the rigorous filler of Substrate's judge interface; it builds nothing that only makes sense inside Substrate. Disclosed: the adversary section (row 29) reached `rebuild-8` in the same commit as the timing fix (`e73a9bb`), before this rule was written down. |
| 32 | 2026-11-21 | **Rail 1 built: the base's harness measures, the program is its child.** `judge/harness.py` runs inside the sandbox as the container's process (from the base: `.morphogen/harness.py` if the base has one, which is always protected, else the judge's own). It runs the program as a child (`python -I`, the work tree after the standard library), gives it only pipes, makes itself non-dumpable (`prctl(PR_SET_DUMPABLE, 0)`) so the child (same user) can neither trace it nor reopen its descriptors through `/proc`, enforces the case timeout, kills the child's process group, and writes the one record that leaves the sandbox: `exit`, `timed_out`, `wall_seconds` (its monotonic clock, from just before the child starts to its exit: container start-up no longer counts), `cpu_seconds` (the child's user + system time from `wait4`; a new runner KPI) and the program's `output`. `judge.run` accepts exactly one line with exactly those fields, else the case is not seen (which can only hurt the candidate). Red team first (`tests/test_harness.py`): a fake record printed by the program, a patched clock in its own process, a write to the harness's stdout through `/proc/<ppid>/fd/1`, a detached grandchild printing late, a timeout, killing the harness, and malformed records. The `/proc` write **succeeded** with the non-dumpable call switched off (the program wrote a line beside the record) and is refused with it (`EACCES`); the test makes the harness's stdout a pipe its own user owns, since reopening a root-owned pipe is refused anyway and would hide the cheat. Smoke test on real sandbox containers: honest pass, cheat refused. A/A again with harness timing (`e2e/aa_timing.py`, 30 reps): blocked order 3 of 30 false passes, paired 1 of 30; with row 30, **blocked 7 of 60 (12%), paired 2 of 60 (3%)**, at alpha 0.05. |
| 33 | 2026-11-21 | **Rail 2's store interface, and a lost-count bug in the live judge.** `judge/store.py`: `cases`, `claim`, `replace`, `version` behind one interface, with `DirStore` and `GitStore`; `inputs()` never carries answers; set names cannot escape the store; `renew()` replaces a set from the base's generator (`generate(rng, n)`, fresh randomness each time, count back to 0). `judge.ci inputs` and `claim` now use it. Found by the store's red-team test: concurrent claims of the same set in the same second made **byte-identical commits** (same parent, tree, author, message, timestamp), so the loser's push was a no-op that "succeeded" and the served count lost verdicts; the live `claim` had the same flaw. Fix: a nonce in every store commit. Also: the summary and `morphogen check` (quickstart, `judge/local.py`, in progress) give the verdict in plain words. **Paused at the owner's request**, with one known bug: an installed package lacks `schemas/` (it is outside the `judge` package), so `morphogen check` fails after `pip install`; the example in `examples/quickstart/` is untested. |
Loading