From 16368a98af9ce97616655b597a9867b8a407909a Mon Sep 17 00:00:00 2001 From: chappie-daemon Date: Wed, 18 Nov 2026 22:50:36 -0500 Subject: [PATCH 1/4] docs: the six KPIs, their base measurements and their thresholds Three about the rewrite (NIP parity, store performance, migration safety) and three about the factory (review share, rounds per job, escapes). Two proxies for parity were measured and rejected: zero stubs across 282 files cannot fail, and per-NIP modules overlap the advertised set at 8 of 25. --- docs/rewrite/kpis.md | 143 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 docs/rewrite/kpis.md diff --git a/docs/rewrite/kpis.md b/docs/rewrite/kpis.md new file mode 100644 index 000000000..e59521f6d --- /dev/null +++ b/docs/rewrite/kpis.md @@ -0,0 +1,143 @@ +# KPIs: what is measured, from where, and what fires + +Six numbers, three about the rewrite and three about the machine building it. Each one names +the artifact it is read from and the threshold that makes someone act. Nothing here is a +dashboard: a figure with no decision attached is a report, and a check that cannot fail is not +a check. + +**The rules this document holds itself to.** + +1. **A KPI names a command.** A number that needs a person to remember how it was produced + stops being produced. +2. **A threshold comes from the recorded distribution, not from a wish.** Where the history is + too thin to give one, the KPI is not shipped — an invented target is worse than none, + because it gets quoted. +3. **A KPI is measured from an artifact the work already writes**, so measuring costs nothing + per job. +4. **A KPI that cannot fail is not a KPI.** It is checked against the base in §7 before it is + adopted. + +## 1. NIP parity — the cutover gate + +**Status: not measurable yet, and the obvious measurements are wrong.** Both were tried on +`rewrite/main` at the time of writing, and both are recorded here so they are not tried again. + +- **Stub count.** `grep -c 'unimplemented!\|todo!('` across all 282 `.rs` files (84,757 lines) + answers **0**. This repository does not stub unimplemented behaviour, so the metric would + read zero forever and a KPI that always passes is decoration. +- **Module presence.** `crates/*/src/nipNN.rs` exists for 12 NIPs — `03 04 05 25 42 43 44 56 65 + 66 77 98` — while `package.json` advertises 25 (`1 2 3 4 9 11 12 13 14 15 16 17 20 22 25 28 + 33 40 42 43 44 45 50 65 77`). The overlap is 8, and four modules (`05 56 66 98`) are helpers + for NIPs that are not advertised. Behaviour for the rest is implemented outside a per-NIP + module, so module presence measures file layout, not coverage. + +**What to build instead: a per-NIP ledger keyed to evidence.** One row per advertised NIP, and +the row's status is set by what exists, not by what is claimed: + +| column | what it holds | +|---|---| +| `nip` | the number, from `package.json`'s `supported_nips` at the v3 grading tip | +| `oracle` | the path of the TypeScript test or feature file that pins the behaviour today, from `docs/rewrite/nip-parity.md`, or `none` where the audit found no test | +| `rust test` | the path of the Rust test that proves the same behaviour, or `none` | +| `teeth` | the inversion that makes that test fail — the same obligation `build.md` rows carry | +| `status` | `ported` when a Rust test proves it and the inversion was recorded, `partial`, or `open` | + +The KPI is `ported / advertised`. It fires in two places: a NIP moving backwards, and the +cutover requiring 25/25 `ported`. The floor is not a percentage chosen for comfort — it is the +cutover's own precondition, which is what makes it a gate rather than a score. + +## 2. Store performance — did the rewrite earn its price + +**Base: recorded.** `docs/rewrite/benchmarks/lmdb-50k-seed7.json`, from `cargo run --release -p +nostream-storage --example bench`, with the host, the load average per repeat and the workload +constants echoed into the artifact. `docs/rewrite/benchmarks.md` carries the table. + +**What fires now:** a regression against that artifact on the same workload, beyond the spread +the three repeats already show. The comparison is against the recorded run, not against a +number from memory. + +**What cannot fire yet:** the multiple against v3. The Rust/Postgres and TypeScript/Postgres +columns are absent because the host has no database, and #1132 owns them. Until it lands, a +"faster than v3" claim has no artifact behind it, and this document does not carry one. + +## 3. Migration safety — may the cutover run unattended + +**Base: recorded.** Job `031-held-descriptor` ran 300 randomised swap rounds against the +descriptor pin: 21 pinned, 0 opened the wrong directory, 279 refused. The window it narrowed is +named in the record rather than claimed closed. + +**What fires:** any round that opens a directory the pin did not hold, on any release. The +threshold is zero and it is not negotiable — this is the check that decides whether a data +migration may run without a person watching. + +## 4. Review share of job spend — is the factory paying to verify more than to build + +**Base: measured over 27 recorded jobs** in the factory history (`.factory/jobs/*/runs.jsonl`, +`t: "spans"` lines), **$103.16 in total**. The ratio is review cost (lenses plus approver) +divided by build cost, and it has a wide spread: + +| job | rounds | ratio | +|---|---|---| +| `001-nip-audit` | 4 | 2.18 | +| `027-expiry-clock` | 1 | 2.58 | +| `019-refusal-exhaustive` | 2 | 2.85 | +| `026-nwc-req-before-event` | 1 | 4.14 | +| `017-frame-budget-settings` (median) | 4 | 1.56 | +| `031-held-descriptor` | 2 | 1.16 | + +**Median 1.5 over 24 jobs that have a build session.** The useful reading is that a review +costing more than the build it reviews is *normal here*, not exceptional — so a target of +"well under 1" would be an aspiration with no history behind it. + +**What fires:** a job whose ratio exceeds 2.0, at which point the round composition is read +from `runs.jsonl` — which lenses ran, and whether a confirmation round re-read a lens that had +already passed. `031`'s round 2 spent $0.138 on a lens that had **PASSED** in round 1 and +skipped the scoper; that is the shape the threshold is looking for. + +**Caveat the number carries:** the ratio is unstable below roughly $1 of total spend, where a +small build divides into a fixed review. Report the share only for jobs above that floor, or +the KPI will reward making builds expensive. + +## 5. Rounds per merged job — is the spec buying the right amount + +**Base: measured over the same 27 jobs.** Median 3, maximum 15, distribution +`1×4 2×4 3×5 4×6 5×1 6×1 7×1 8×1 11×1 15×1`. + +**What fires:** above 5 rounds on a job whose scope is one crate. A job that needs a sixth +round is a spec defect showing up late, and the fix belongs in recon and the spec — the same +conclusion `cameri/skills#286` reaches about citations, one level up. + +## 6. Escapes — is the gate real + +**Base: recorded per job** in the `outcome` and `regret` lines of `runs.jsonl`. An escape is a +defect found after approval: by the hosted reader on the pull request, by a person, or by the +next job working in the same file. + +**What fires:** any escape. The count is not a rate to reduce gradually — the approver's whole +purpose is that the number is zero, and a single escape names the lens or the criterion that +should have caught it. + +## 7. What is deliberately not a KPI + +| candidate | why not | +|---|---| +| stub count | measured 0 across 282 files; cannot fail (§1) | +| test count | 1,390 `#[test]`/`#[tokio::test]` attributes today; the number rises with tests that prove nothing | +| files changed, diff size | rewards motion; `031` closed a real window in 4 files and a larger diff would have scored better | +| token spend | a proxy for cost, not for value; job cost is already recorded against a bracket | +| PR count, commit count | output, not distance | + +## 8. How each number is produced + +| KPI | artifact | command | +|---|---|---| +| NIP parity | `docs/rewrite/nip-porting.md` (to build) | a script over the ledger; `grep -c` over `crates/**/*.rs` for the stub check this document retires | +| performance | `docs/rewrite/benchmarks/lmdb-50k-seed7.json` | `cargo run --release -p nostream-storage --example bench -- --backend lmdb --events 50000 --seed 7 --repeats 3 --verify` | +| migration safety | the job record's `round-*/` and `build.md` | the randomized-round harness the job added, run per release | +| review share, rounds | `.factory/jobs/*/runs.jsonl` | sum `spans.sessions[].cost` by agent: `reviewer` and `approver` against `builder` | +| escapes | `.factory/jobs/*/runs.jsonl` | `outcome` and `regret` lines | + +**Order of work.** The parity ledger is the only one of the six that needs building before it +can report; the other five are read from records that already exist. Until the ledger exists, +the honest statement about parity is the one in §1: it is unknown, and the two cheap proxies +for it are wrong. From af1f9ec0a080a9edb2b9a7edcdc804ba7cb50164 Mon Sep 17 00:00:00 2001 From: chappie-daemon Date: Wed, 18 Nov 2026 22:55:42 -0500 Subject: [PATCH 2/4] chore: add the empty changeset for the KPI contract --- .changeset/kpi-contract.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .changeset/kpi-contract.md diff --git a/.changeset/kpi-contract.md b/.changeset/kpi-contract.md new file mode 100644 index 000000000..13b8475e5 --- /dev/null +++ b/.changeset/kpi-contract.md @@ -0,0 +1,11 @@ +--- +--- + +docs: six KPIs, their base measurements and their thresholds + +Three KPI define what "v4 is done" means — NIP parity as a per-NIP ledger keyed to a test +with a recorded inversion, a performance comparison against the recorded benchmark artifact, +and zero migration rounds that open a directory the pin did not hold — and three measure the +build process itself, from the job records that already exist. Two parity proxies were +measured and rejected: a stub count reads zero across 282 Rust files, and per-NIP modules +overlap the advertised set at 8 of 25, so neither can fail. No package version changes. From be79445bac329ef5faad98111a02f49fe3cd02bc Mon Sep 17 00:00:00 2001 From: chappie-daemon Date: Wed, 18 Nov 2026 22:57:26 -0500 Subject: [PATCH 3/4] docs: correct the KPI baselines and mark what a reader cannot check Greptile's three findings, all real: the benchmark command omitted the required --out, the rounds distribution summed to 24 for a 27-job claim, and the factory records are workspace-only, so the tables are now stated as recorded values with sample sizes and the excluded record named. --- docs/rewrite/kpis.md | 54 +++++++++++++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 16 deletions(-) diff --git a/docs/rewrite/kpis.md b/docs/rewrite/kpis.md index e59521f6d..51b3012cf 100644 --- a/docs/rewrite/kpis.md +++ b/docs/rewrite/kpis.md @@ -63,8 +63,11 @@ columns are absent because the host has no database, and #1132 owns them. Until ## 3. Migration safety — may the cutover run unattended **Base: recorded.** Job `031-held-descriptor` ran 300 randomised swap rounds against the -descriptor pin: 21 pinned, 0 opened the wrong directory, 279 refused. The window it narrowed is -named in the record rather than claimed closed. +descriptor pin: 21 pinned, 0 opened the wrong directory, 279 refused. That campaign was a +measurement taken during the job, not a harness this repository carries — the committed tests +that pin the same behaviour are the swap cases in `crates/nostream-cli/tests/migrate_cli.rs`, +which run one inversion at a time. **Turning the campaign into a per-release harness is open +work**, and until it exists this KPI has a recorded base and no standing command. **What fires:** any round that opens a directory the pin did not hold, on any release. The threshold is zero and it is not negotiable — this is the check that decides whether a data @@ -72,9 +75,13 @@ migration may run without a person watching. ## 4. Review share of job spend — is the factory paying to verify more than to build -**Base: measured over 27 recorded jobs** in the factory history (`.factory/jobs/*/runs.jsonl`, -`t: "spans"` lines), **$103.16 in total**. The ratio is review cost (lenses plus approver) -divided by build cost, and it has a wide spread: +**Base: measured over the 27 recorded jobs** in the factory history (`.factory/jobs/*/runs.jsonl`, +`t: "spans"` lines), **$103.16 in total**. Those records live in the operator's workspace and are +not published in this repository — the figures below are recorded values, reproducible only where +the records are shared (see §9). The ratio is review cost (lenses plus approver) divided by build +cost, over the **24** jobs whose sessions can be attributed by agent name — three (`005`, `006`, +`007`) predate the `factory-*` naming, so their build cost cannot be separated from their review +cost and they are excluded rather than guessed at. It has a wide spread: | job | rounds | ratio | |---|---|---| @@ -82,11 +89,13 @@ divided by build cost, and it has a wide spread: | `027-expiry-clock` | 1 | 2.58 | | `019-refusal-exhaustive` | 2 | 2.85 | | `026-nwc-req-before-event` | 1 | 4.14 | -| `017-frame-budget-settings` (median) | 4 | 1.56 | +| `029-pg-to-lmdb` | 3 | 2.02 | | `031-held-descriptor` | 2 | 1.16 | -**Median 1.5 over 24 jobs that have a build session.** The useful reading is that a review -costing more than the build it reviews is *normal here*, not exceptional — so a target of +**Median 1.50 over the 24 jobs with a build session**, and **seven of the 24 exceed 2.0** — +`001-nip-audit`, `019-refusal-exhaustive`, `020-pin-test-message`, `021-created-at-bound`, +`026-nwc-req-before-event`, `027-expiry-clock` and `029-pg-to-lmdb`. The useful reading is that a +review costing more than the build it reviews is *normal here*, not exceptional — so a target of "well under 1" would be an aspiration with no history behind it. **What fires:** a job whose ratio exceeds 2.0, at which point the round composition is read @@ -101,7 +110,8 @@ the KPI will reward making builds expensive. ## 5. Rounds per merged job — is the spec buying the right amount **Base: measured over the same 27 jobs.** Median 3, maximum 15, distribution -`1×4 2×4 3×5 4×6 5×1 6×1 7×1 8×1 11×1 15×1`. +`1×4 2×5 3×5 4×7 5×1 6×1 7×1 8×1 11×1 15×1` — twenty-seven jobs, the twenty-eighth record +(`001-dependabot-security-bump`) carrying no `spans` line and therefore no round count. **What fires:** above 5 rounds on a job whose scope is one crate. A job that needs a sixth round is a spec defect showing up late, and the fix belongs in recon and the spec — the same @@ -132,12 +142,24 @@ should have caught it. | KPI | artifact | command | |---|---|---| | NIP parity | `docs/rewrite/nip-porting.md` (to build) | a script over the ledger; `grep -c` over `crates/**/*.rs` for the stub check this document retires | -| performance | `docs/rewrite/benchmarks/lmdb-50k-seed7.json` | `cargo run --release -p nostream-storage --example bench -- --backend lmdb --events 50000 --seed 7 --repeats 3 --verify` | -| migration safety | the job record's `round-*/` and `build.md` | the randomized-round harness the job added, run per release | -| review share, rounds | `.factory/jobs/*/runs.jsonl` | sum `spans.sessions[].cost` by agent: `reviewer` and `approver` against `builder` | -| escapes | `.factory/jobs/*/runs.jsonl` | `outcome` and `regret` lines | +| performance | `docs/rewrite/benchmarks/lmdb-50k-seed7.json` | `cargo run --release -p nostream-storage --example bench -- --backend lmdb --events 50000 --seed 7 --repeats 3 --verify --out /tmp/bench-lmdb.json` — `--out` is required and has no default | +| migration safety | `crates/nostream-cli/tests/migrate_cli.rs` (committed swap cases); the 300-round campaign is job-time, not committed | `cargo test -p nostream-cli --test migrate_cli` per release; the campaign repeats the same assertion at scale | +| review share, rounds | `.factory/jobs/*/runs.jsonl`, workspace only (§9) | sum `spans.sessions[].cost` by agent: `reviewer` and `approver` against `builder` | +| escapes | `.factory/jobs/*/runs.jsonl`, workspace only (§9) | `outcome` and `regret` lines | **Order of work.** The parity ledger is the only one of the six that needs building before it -can report; the other five are read from records that already exist. Until the ledger exists, -the honest statement about parity is the one in §1: it is unknown, and the two cheap proxies -for it are wrong. +can report; the migration campaign needs a committed harness before it can run per release; the +rest are read from records that already exist. + +## 9. Provenance, and what a reader here cannot check + +The three rewrite KPIs are reproducible from this repository: the benchmark artifact is +committed beside its document, the swap tests are committed, and the parity ledger will be. + +The three factory numbers are not. `.factory/jobs/` is written in the operator's workspace and +**only `.factory/config.json` is published**, so the $103.16 total, the 24-job ratio sample and +the 27-job round distribution are recorded values that a reader of this repository cannot +recompute. They are stated with their sample sizes and the excluded record named, so the +thresholds can be argued about; they cannot be verified here, and this document does not +pretend otherwise. Publishing the job records, or a periodic aggregate committed under +`docs/rewrite/`, is the fix when someone needs to check them. From b2836d2a862af3925548fb0a0f3ee98cb9cbbd75 Mon Sep 17 00:00:00 2001 From: chappie-daemon Date: Wed, 18 Nov 2026 23:01:40 -0500 Subject: [PATCH 4/4] docs: the swap tests only run on Linux, so name the host in the KPI Greptile's finding: the migrate_cli swap cases are cfg(target_os = "linux"), so the same command on macOS passes while skipping every directory-pin test. The row now states Linux with /proc/self/fd, and the release record must name the host. --- docs/rewrite/kpis.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/rewrite/kpis.md b/docs/rewrite/kpis.md index 51b3012cf..4acba4976 100644 --- a/docs/rewrite/kpis.md +++ b/docs/rewrite/kpis.md @@ -143,10 +143,15 @@ should have caught it. |---|---|---| | NIP parity | `docs/rewrite/nip-porting.md` (to build) | a script over the ledger; `grep -c` over `crates/**/*.rs` for the stub check this document retires | | performance | `docs/rewrite/benchmarks/lmdb-50k-seed7.json` | `cargo run --release -p nostream-storage --example bench -- --backend lmdb --events 50000 --seed 7 --repeats 3 --verify --out /tmp/bench-lmdb.json` — `--out` is required and has no default | -| migration safety | `crates/nostream-cli/tests/migrate_cli.rs` (committed swap cases); the 300-round campaign is job-time, not committed | `cargo test -p nostream-cli --test migrate_cli` per release; the campaign repeats the same assertion at scale | +| migration safety | `crates/nostream-cli/tests/migrate_cli.rs` (committed swap cases); the 300-round campaign is job-time, not committed | `cargo test -p nostream-cli --test migrate_cli` **on Linux, with `/proc/self/fd` present**; the campaign repeats the same assertion at scale | | review share, rounds | `.factory/jobs/*/runs.jsonl`, workspace only (§9) | sum `spans.sessions[].cost` by agent: `reviewer` and `approver` against `builder` | | escapes | `.factory/jobs/*/runs.jsonl`, workspace only (§9) | `outcome` and `regret` lines | +**The platform is part of the migration measurement.** The swap cases are +`#[cfg(target_os = "linux")]` (`migrate_cli.rs:2641,2698,2736`), so the same command on macOS +passes while skipping every directory-pin test. A green run anywhere else is not evidence for +this KPI, and the release record must name the host it ran on. + **Order of work.** The parity ledger is the only one of the six that needs building before it can report; the migration campaign needs a committed harness before it can run per release; the rest are read from records that already exist.