reputation-ladder: dry-run scorer for the public edge (card #1984) #2949

Merged
hermes merged 2 commits from kb/reputation-ladder into main 2026-11-25 18:27:10 -06:00
Collaborator

Card nix-config#1984 (child of #1977 part (c)).

Lands the scorer only, in dry-run. Nothing is enforced; --enforce exits 2 and says why.

What it does

  • tails ymrtech-access.log + the two decoy logs on public, per-IP sliding-window state in SQLite
  • appends the rung it would apply to /var/lib/reputation-ladder/proposals.jsonl
  • replay subcommand scores an offline JSONL corpus (that is how the backtest ran)

Thresholds are measured, not chosen (7 days of ymrtech.com, 2026-11-18..25)

class scale outcome
mesh 11.0.0.0/24 331,128 req never scored (exempt pre-score)
WAN non-mesh 4,232 IPs / 25,597 req / 16,315x404 / 0x429 28 IPs reach rung 4
browser-shaped 247 IPs / 2,231 req 0 reach rung 4

Replay of the real corpus: {0: 2355, 2: 35, 4: 28, 5: 1} over 2,419 IPs. The single rung-5 IP is 195.178.110.22 (617 req / 617 404). The browser-shape test is the discriminator: real browsers fetch a subresource per ~2-5 documents (asset/browser-UA 0.20-0.80), UA-faking crawlers sit at 0.02 and below, so a UA string alone decides nothing.

Scope: one vhost, deliberately

ymrtech-access.log on public only. A real git clone asks hundreds of distinct paths, so the many-distinct-URLs term is a false-positive generator on git/chat/vault/paste — each needs its own measurement before it is scored.

Rungs

0 pass · 2 throttle signal · 4 proposes · 5/6 heavier · 7-9 (ban / graduated ban / permanent) unreachable here — top of this ladder is the challenge rung, and the ban rungs wait for an owner ruling.

Enforcement path, not in this PR

A ban must enter the LAPI as an alert so the profile chain and the per-host simulated stamp keep working; --enforce refuses until that exists.

Unit hygiene

ProtectSystem=strict + StateDirectory (only writable path), SupplementaryGroups=caddy to read 0640 caddy:caddy logs rather than loosening the mode, PrivateNetwork, NoNewPrivileges.

Verification done locally

  • nix build of the package: ok; the built binary's replay on the 7-day corpus reproduces {0: 2355, 2: 35, 4: 28, 5: 1}
  • nix eval .#nixosConfigurations.public.config.fleet.reputationLadder: renders as intended
  • .forgejo/tests/test-reputation-ladder.py: 13 checks, all pass; wired into repo-gates
  • public toplevel build: left to CI

After merge

Dry-run 7 days → confirm the proposals reproduce the same 17 IPs → then (and only then) discuss enabling rungs 4-6.

Card **nix-config#1984** (child of #1977 part (c)). Lands the **scorer only, in dry-run**. Nothing is enforced; `--enforce` exits 2 and says why. ### What it does - tails `ymrtech-access.log` + the two decoy logs on public, per-IP sliding-window state in SQLite - appends the rung it *would* apply to `/var/lib/reputation-ladder/proposals.jsonl` - `replay` subcommand scores an offline JSONL corpus (that is how the backtest ran) ### Thresholds are measured, not chosen (7 days of ymrtech.com, 2026-11-18..25) | class | scale | outcome | |---|---|---| | mesh `11.0.0.0/24` | 331,128 req | never scored (exempt **pre**-score) | | WAN non-mesh | 4,232 IPs / 25,597 req / 16,315x404 / **0x429** | 28 IPs reach rung 4 | | browser-shaped | 247 IPs / 2,231 req | **0** reach rung 4 | Replay of the real corpus: `{0: 2355, 2: 35, 4: 28, 5: 1}` over 2,419 IPs. The single rung-5 IP is `195.178.110.22` (617 req / 617 404). The browser-shape test is the discriminator: real browsers fetch a subresource per ~2-5 documents (asset/browser-UA 0.20-0.80), UA-faking crawlers sit at 0.02 and below, so a UA string alone decides nothing. ### Scope: one vhost, deliberately `ymrtech-access.log` on public only. A real `git clone` asks hundreds of distinct paths, so the many-distinct-URLs term is a false-positive generator on git/chat/vault/paste — each needs its own measurement before it is scored. ### Rungs 0 pass · 2 throttle signal · 4 proposes · 5/6 heavier · **7-9 (ban / graduated ban / permanent) unreachable here** — top of this ladder is the challenge rung, and the ban rungs wait for an owner ruling. ### Enforcement path, not in this PR A ban must enter the **LAPI as an alert** so the profile chain and the per-host `simulated` stamp keep working; `--enforce` refuses until that exists. ### Unit hygiene `ProtectSystem=strict` + `StateDirectory` (only writable path), `SupplementaryGroups=caddy` to read 0640 `caddy:caddy` logs rather than loosening the mode, `PrivateNetwork`, `NoNewPrivileges`. ### Verification done locally - `nix build` of the package: ok; the built binary's `replay` on the 7-day corpus reproduces `{0: 2355, 2: 35, 4: 28, 5: 1}` - `nix eval .#nixosConfigurations.public.config.fleet.reputationLadder`: renders as intended - `.forgejo/tests/test-reputation-ladder.py`: 13 checks, all pass; wired into `repo-gates` - public toplevel build: left to CI ### After merge Dry-run 7 days → confirm the proposals reproduce the same 17 IPs → then (and only then) discuss enabling rungs 4-6.
reputation-ladder: score the public edge in dry-run, propose the rung
Some checks failed
Policy Gates / Worker-scope reaper worker signature (mutation-tested) (pull_request) Successful in 7s
Policy Gates / Kanban pool capacity knob (runtime override + clamp, mutation-tested) (pull_request) Successful in 4s
NixOS Build Check / Scope changed deployable hosts (pull_request) Successful in 17s
PR base guard / Base drift / conflict check (pull_request) Successful in 17s
Policy Gates / Sentinel pass budget contract (prompt forbids the full board walk, mutation-tested) (pull_request) Successful in 5s
NixOS Build Check / Flake input regression guard (pull_request) Successful in 9s
Policy Gates / CI-scratch reaper class table (mutation-tested) (pull_request) Successful in 6s
Policy Gates / Fleet cache sweep class table (mutation-tested) (pull_request) Successful in 6s
Secret Scan / gitleaks scan (pull_request) Successful in 21s
Policy Gates / foremerge accept-order contract (real binary) (pull_request) Successful in 1m15s
Policy Gates / Scheduled foremerge reap command line (mutation-tested) (pull_request) Successful in 5s
NixOS Build Check / Hermes runtime gates (one eval of vpn's runtime) (pull_request) Successful in 1m37s
Repo Gates / Repo gates (script-only battery) (pull_request) Failing after 2m36s
Policy Gates / .forgejo/tests python suites (hermetic) (pull_request) Successful in 59s
NixOS Build Check / Build changed host closures (per-host budget) (pull_request) Successful in 3m7s
NixOS Build Check / Gate summary (pull_request) Successful in 1s
Policy Gates / Fleet control ledger (sealed profile fails the build, mutation-tested) (pull_request) Successful in 39s
c18e312c5b
Card nix-config#1984 (child of #1977 part (c)). The crowdsec request-shape
scenario plateaus at 70.58% of the measured campaign and cannot go higher
without banning real clients, so escalation has to be decided per-IP from
behaviour over time instead of from a path list.

This lands the scorer only, in dry-run: it tails ymrtech-access.log plus the
two decoy logs, keeps per-IP sliding-window state in SQLite, and appends the
rung it WOULD apply to proposals.jsonl. Nothing is enforced. --enforce exits 2
and says why: a ban has to enter the LAPI as an alert so the profile chain and
the per-host `simulated` stamp keep working, and that wiring does not exist yet.

Thresholds are measured, not chosen (7 days of ymrtech.com, 2026-11-18..25):
  mesh 11.0.0.0/24   331,128 req  -> never scored (exempt PRE-score)
  WAN non-mesh         4,232 IPs, 25,597 req, 16,315 x 404, 0 x 429
  browser-shaped         247 IPs, 2,231 req -> 0 reach rung 4
Replay of the real corpus: {0: 2355, 2: 35, 4: 28, 5: 1} over 2,419 IPs.
The browser-shape test is the discriminator: real browsers fetch a subresource
for every ~2-5 documents (asset/browser-UA 0.20-0.80), UA-faking crawler fleets
sit at 0.02 and below, so a UA string alone decides nothing.

Scope is deliberately one vhost: ymrtech-access.log on public. A real `git
clone` asks hundreds of distinct paths, so the many-distinct-URLs term is a
false-positive generator on git/chat/vault/paste; each needs its own
measurement before it is scored.

Rungs 7-9 (ban, graduated ban, permanent) are NOT reachable here: rung 6 is
top of the challenge ladder and the ban rungs wait for an owner ruling.

The unit runs with ProtectSystem=strict and writes only its StateDirectory,
reads caddy logs through SupplementaryGroups=caddy (0640 caddy:caddy) rather
than loosening the mode.
hermes force-pushed kb/reputation-ladder from c18e312c5b
Some checks failed
Policy Gates / Worker-scope reaper worker signature (mutation-tested) (pull_request) Successful in 7s
Policy Gates / Kanban pool capacity knob (runtime override + clamp, mutation-tested) (pull_request) Successful in 4s
NixOS Build Check / Scope changed deployable hosts (pull_request) Successful in 17s
PR base guard / Base drift / conflict check (pull_request) Successful in 17s
Policy Gates / Sentinel pass budget contract (prompt forbids the full board walk, mutation-tested) (pull_request) Successful in 5s
NixOS Build Check / Flake input regression guard (pull_request) Successful in 9s
Policy Gates / CI-scratch reaper class table (mutation-tested) (pull_request) Successful in 6s
Policy Gates / Fleet cache sweep class table (mutation-tested) (pull_request) Successful in 6s
Secret Scan / gitleaks scan (pull_request) Successful in 21s
Policy Gates / foremerge accept-order contract (real binary) (pull_request) Successful in 1m15s
Policy Gates / Scheduled foremerge reap command line (mutation-tested) (pull_request) Successful in 5s
NixOS Build Check / Hermes runtime gates (one eval of vpn's runtime) (pull_request) Successful in 1m37s
Repo Gates / Repo gates (script-only battery) (pull_request) Failing after 2m36s
Policy Gates / .forgejo/tests python suites (hermetic) (pull_request) Successful in 59s
NixOS Build Check / Build changed host closures (per-host budget) (pull_request) Successful in 3m7s
NixOS Build Check / Gate summary (pull_request) Successful in 1s
Policy Gates / Fleet control ledger (sealed profile fails the build, mutation-tested) (pull_request) Successful in 39s
to e2d6c64185
Some checks failed
PR base guard / Base drift / conflict check (pull_request) Successful in 26s
foremerge intent (advisory) 3 of 6 changed path(s) have no live foremerge intent: .forgejo/tests/test-reputation-ladder.py, packages/reputation-ladder/default.nix, packages/reputation-ladder/reputation_ladder.py
NixOS Build Check / Scope changed deployable hosts (pull_request) Successful in 13s
Policy Gates / Worker-scope reaper worker signature (mutation-tested) (pull_request) Successful in 7s
NixOS Build Check / Flake input regression guard (pull_request) Successful in 8s
Policy Gates / Kanban pool capacity knob (runtime override + clamp, mutation-tested) (pull_request) Successful in 9s
Policy Gates / Sentinel pass budget contract (prompt forbids the full board walk, mutation-tested) (pull_request) Successful in 5s
Secret Scan / gitleaks scan (pull_request) Successful in 1m11s
Policy Gates / CI-scratch reaper class table (mutation-tested) (pull_request) Successful in 5s
Policy Gates / Fleet cache sweep class table (mutation-tested) (pull_request) Successful in 5s
NixOS Build Check / Hermes runtime gates (one eval of vpn's runtime) (pull_request) Successful in 1m43s
Policy Gates / foremerge accept-order contract (real binary) (pull_request) Successful in 1m16s
Repo Gates / Repo gates (script-only battery) (pull_request) Failing after 2m41s
Policy Gates / Scheduled foremerge reap command line (mutation-tested) (pull_request) Successful in 5s
NixOS Build Check / Build changed host closures (per-host budget) (pull_request) Successful in 2m57s
Policy Gates / .forgejo/tests python suites (hermetic) (pull_request) Successful in 58s
NixOS Build Check / Gate summary (pull_request) Successful in 0s
Policy Gates / Fleet control ledger (sealed profile fails the build, mutation-tested) (pull_request) Successful in 21s
2026-11-25 17:24:41 -06:00
Compare
Author
Collaborator

foremerge intent coverage (advisory) — 3 of 6 changed path(s) in ymrtech/nix-config#2949 have no live foremerge intent:

  • .forgejo/tests/test-reputation-ladder.py
  • packages/reputation-ladder/default.nix
  • packages/reputation-ladder/reputation_ladder.py

Coverage was decided by reading the repo's foremerge ledger (16 in-flight intent(s) considered) against this PR's changed paths — no branch or session name is involved, so a force-push does not change the answer. Paths that legitimately need no claim (docs, .md, flake.lock) are excluded.

This is advisory and does not block the merge. To clear it, publish intent for the paths above (foremerge intent publish --agent <your agent id> --task <task> --summary <what and why> --scope file:<path>=modify), or ignore it if the work genuinely collides with nobody.

**foremerge intent coverage (advisory)** — 3 of 6 changed path(s) in ymrtech/nix-config#2949 have no live foremerge intent: - `.forgejo/tests/test-reputation-ladder.py` - `packages/reputation-ladder/default.nix` - `packages/reputation-ladder/reputation_ladder.py` Coverage was decided by reading the repo's foremerge ledger (16 in-flight intent(s) considered) against this PR's changed paths — no branch or session name is involved, so a force-push does not change the answer. Paths that legitimately need no claim (docs, `.md`, `flake.lock`) are excluded. This is advisory and does **not** block the merge. To clear it, publish intent for the paths above (`foremerge intent publish --agent <your agent id> --task <task> --summary <what and why> --scope file:<path>=modify`), or ignore it if the work genuinely collides with nobody.
hermes force-pushed kb/reputation-ladder from e2d6c64185
Some checks failed
PR base guard / Base drift / conflict check (pull_request) Successful in 26s
foremerge intent (advisory) 3 of 6 changed path(s) have no live foremerge intent: .forgejo/tests/test-reputation-ladder.py, packages/reputation-ladder/default.nix, packages/reputation-ladder/reputation_ladder.py
NixOS Build Check / Scope changed deployable hosts (pull_request) Successful in 13s
Policy Gates / Worker-scope reaper worker signature (mutation-tested) (pull_request) Successful in 7s
NixOS Build Check / Flake input regression guard (pull_request) Successful in 8s
Policy Gates / Kanban pool capacity knob (runtime override + clamp, mutation-tested) (pull_request) Successful in 9s
Policy Gates / Sentinel pass budget contract (prompt forbids the full board walk, mutation-tested) (pull_request) Successful in 5s
Secret Scan / gitleaks scan (pull_request) Successful in 1m11s
Policy Gates / CI-scratch reaper class table (mutation-tested) (pull_request) Successful in 5s
Policy Gates / Fleet cache sweep class table (mutation-tested) (pull_request) Successful in 5s
NixOS Build Check / Hermes runtime gates (one eval of vpn's runtime) (pull_request) Successful in 1m43s
Policy Gates / foremerge accept-order contract (real binary) (pull_request) Successful in 1m16s
Repo Gates / Repo gates (script-only battery) (pull_request) Failing after 2m41s
Policy Gates / Scheduled foremerge reap command line (mutation-tested) (pull_request) Successful in 5s
NixOS Build Check / Build changed host closures (per-host budget) (pull_request) Successful in 2m57s
Policy Gates / .forgejo/tests python suites (hermetic) (pull_request) Successful in 58s
NixOS Build Check / Gate summary (pull_request) Successful in 0s
Policy Gates / Fleet control ledger (sealed profile fails the build, mutation-tested) (pull_request) Successful in 21s
to 31279491c9
Some checks failed
Policy Gates / Worker-scope reaper worker signature (mutation-tested) (pull_request) Successful in 9s
Policy Gates / Kanban pool capacity knob (runtime override + clamp, mutation-tested) (pull_request) Successful in 5s
PR base guard / Base drift / conflict check (pull_request) Successful in 8s
Policy Gates / Sentinel pass budget contract (prompt forbids the full board walk, mutation-tested) (pull_request) Successful in 4s
Policy Gates / CI-scratch reaper class table (mutation-tested) (pull_request) Successful in 7s
Secret Scan / gitleaks scan (pull_request) Successful in 14s
Policy Gates / Fleet cache sweep class table (mutation-tested) (pull_request) Successful in 5s
NixOS Build Check / Scope changed deployable hosts (pull_request) Successful in 44s
NixOS Build Check / Flake input regression guard (pull_request) Successful in 5s
Policy Gates / foremerge accept-order contract (real binary) (pull_request) Successful in 1m15s
Policy Gates / Scheduled foremerge reap command line (mutation-tested) (pull_request) Successful in 4s
NixOS Build Check / Hermes runtime gates (one eval of vpn's runtime) (pull_request) Successful in 1m37s
Repo Gates / Repo gates (script-only battery) (pull_request) Failing after 2m35s
Policy Gates / .forgejo/tests python suites (hermetic) (pull_request) Successful in 55s
Policy Gates / Fleet control ledger (sealed profile fails the build, mutation-tested) (pull_request) Successful in 22s
NixOS Build Check / Build changed host closures (per-host budget) (pull_request) Successful in 2m54s
NixOS Build Check / Gate summary (pull_request) Successful in 0s
foremerge intent (advisory) 3 of 6 changed path(s) have no live foremerge intent: .forgejo/tests/test-reputation-ladder.py, packages/reputation-ladder/default.nix, packages/reputation-ladder/reputation_ladder.py
2026-11-25 17:36:14 -06:00
Compare
Author
Collaborator

Repo gates went red on e2d6c641, and it was right to. The step I added was nix-shell -p python3 --run "python3 .forgejo/tests/test-reputation-ladder.py" — the [ci] runner unit has no NIX_PATH, so it died on file 'nixpkgs' was not found in the Nix search path. That is the failure mode another workflow documents (it sets NIX_PATH: 'nixpkgs=flake:nixpkgs' at workflow level); repo-gates deliberately has no nix in it at all.

Rather than add a network/channel dependency to an offline battery, the suite now runs in the derivation's checkPhase. It is hermetic, stdlib-only, 0.6 s, and it travels with the package into every closure that imports it — nix-build-check builds public, so the gate fires there on every PR that touches the package. The repo-gates step is reverted; that file is unchanged in the diff.

Confirmed in the sandbox, not the source tree:

all checks passed
Running phase: installPhase

While mutation-testing that move I found a real defect. challenge_for() had no caller — the promise in its docstring ("a browser-shaped IP is never challenged, it only escalates to a ban") was not implemented anywhere, and dropping and not browser_shaped left the whole suite green. Both are fixed: proposals now carry browser_shaped and an explicit challenge field, and the pure function is pinned by four checks.

Five mutations, each red now:

mutation result
return rung < 4 (drop the browser-shape guard) red — 1 check
"challenge": None red — 2 checks
retune a band (score >= floor / 4) red — 3 checks
un-exempt 11.0.0.0/24 red — 2 checks
accept --enforce red — 2 checks

Head is now 31279491 (19 checks). Also folded in since the first push: proposals.jsonl rotates at 50 MB — nothing on the fleet grows without a bound.

**Repo gates went red on `e2d6c641`, and it was right to.** The step I added was `nix-shell -p python3 --run "python3 .forgejo/tests/test-reputation-ladder.py"` — the `[ci]` runner unit has **no `NIX_PATH`**, so it died on `file 'nixpkgs' was not found in the Nix search path`. That is the failure mode another workflow documents (it sets `NIX_PATH: 'nixpkgs=flake:nixpkgs'` at workflow level); repo-gates deliberately has no nix in it at all. Rather than add a network/channel dependency to an offline battery, the suite now runs in the **derivation's `checkPhase`**. It is hermetic, stdlib-only, 0.6 s, and it travels with the package into every closure that imports it — `nix-build-check` builds `public`, so the gate fires there on every PR that touches the package. The repo-gates step is reverted; that file is unchanged in the diff. Confirmed in the sandbox, not the source tree: ``` all checks passed Running phase: installPhase ``` **While mutation-testing that move I found a real defect.** `challenge_for()` had **no caller** — the promise in its docstring ("a browser-shaped IP is never challenged, it only escalates to a ban") was not implemented anywhere, and dropping `and not browser_shaped` left the whole suite green. Both are fixed: proposals now carry `browser_shaped` **and** an explicit `challenge` field, and the pure function is pinned by four checks. Five mutations, each red now: | mutation | result | |---|---| | `return rung < 4` (drop the browser-shape guard) | red — 1 check | | `"challenge": None` | red — 2 checks | | retune a band (`score >= floor / 4`) | red — 3 checks | | un-exempt `11.0.0.0/24` | red — 2 checks | | accept `--enforce` | red — 2 checks | Head is now `31279491` (19 checks). Also folded in since the first push: `proposals.jsonl` rotates at 50 MB — nothing on the fleet grows without a bound.
repo-gates: drop the ladder test step (checkPhase owns it; the [ci] runner has no nix)
Some checks reported errors
PR base guard / Base drift / conflict check (pull_request) Successful in 12s
Policy Gates / Worker-scope reaper worker signature (mutation-tested) (pull_request) Successful in 11s
Policy Gates / Kanban pool capacity knob (runtime override + clamp, mutation-tested) (pull_request) Successful in 5s
Policy Gates / Sentinel pass budget contract (prompt forbids the full board walk, mutation-tested) (pull_request) Successful in 4s
Secret Scan / gitleaks scan (pull_request) Successful in 11s
Policy Gates / CI-scratch reaper class table (mutation-tested) (pull_request) Successful in 6s
Policy Gates / Fleet cache sweep class table (mutation-tested) (pull_request) Successful in 7s
NixOS Build Check / Scope changed deployable hosts (pull_request) Successful in 57s
NixOS Build Check / Flake input regression guard (pull_request) Successful in 5s
Policy Gates / foremerge accept-order contract (real binary) (pull_request) Successful in 1m15s
Policy Gates / Scheduled foremerge reap command line (mutation-tested) (pull_request) Successful in 6s
NixOS Build Check / Hermes runtime gates (one eval of vpn's runtime) (pull_request) Successful in 1m58s
Policy Gates / .forgejo/tests python suites (hermetic) (pull_request) Successful in 55s
Policy Gates / Fleet control ledger (sealed profile fails the build, mutation-tested) (pull_request) Successful in 21s
NixOS Build Check / Build changed host closures (per-host budget) (pull_request) Successful in 4m5s
NixOS Build Check / Gate summary (pull_request) Successful in 1s
Repo Gates / Repo gates (script-only battery) (pull_request) Successful in 5m36s
foremerge intent (advisory) UNVERIFIABLE (not a verdict on the change): ledger unreadable (foremerge exit 1 for /var/lib/hermes/workspace/nix-config: {"ok":false,"error":{"code":"ERROR","message":"database is locked: Error code 5: The database file is locked"}})
4858295a73
hermes merged commit 2f64024017 into main 2026-11-25 18:27:10 -06:00
hermes deleted branch kb/reputation-ladder 2026-11-25 18:27:13 -06:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ymrtech/nix-config!2949
No description provided.