Add a checkpoint gate that refuses a worse Laya checkpoint #28

Merged
james merged 4 commits from eval-gate into main 2026-11-19 13:12:34 +00:00
Owner

Adds centinela-gate, which decides whether a retrained Laya checkpoint may replace the one in service. It is step 1 of moving retraining into this repo: retraining can run unattended, so something has to stop a worse checkpoint from going live. r4, for example, lost the admin'-- SQLi block.

What it does

It replays the same recorded model inputs through the serving checkpoint (baseline) and the candidate, applies the production policy (balanced), and refuses the candidate if, in any suite:

  • it detects fewer attacks or blocks more benign requests than the baseline (-max-detection-drop / -max-fp-rise default to 0), or
  • it decides a held-out reviewer label the wrong way, unless that label is in the reviewed exceptions file, or
  • any record failed to replay.
Suite Built from Counts as correct
eval eval/dataset.jsonl grey zone (centinela-eval -states) attack blocked/shunned; benign not blocked
production the held-out production slice and its teacher labels (centinela-gate heldout) attack flagged or worse; benign allowed
labels reviewer labels joined to their training-log states (centinela-gate labels) should_block blocked; false_positive not blocked

The report (Markdown, ids only, no request content) goes in the PR that changes laya/checkpoint.env; laya/README.md now says to merge that only on ACCEPT. Usage is in eval/README.md#checkpoint-gate.

Held-out labels never train

labels splits by a SHA-256 of the normalized method, host and path (case, trailing slash/dot, percent-encoding, port, IPv6 brackets), 30% of endpoints by default. It writes the training side to a separate file, and the training pipeline must read labels only from that file.

Run integrity

compare stops (exit 2) unless:

  • both runs hold the same ids with the same per-record state hash;
  • each run comes from one -checkpoint, the two differ, and they don't answer every record identically;
  • the eval, production and labels suites are present and non-empty.

Malformed, duplicated or empty input is rejected, and every file it writes is owner-only, since suites and replays carry request bodies from the training log.

Also in this PR

  • decider.TypeSafe.AssessState replays a recorded state exactly as given; Assess now builds the state and calls it.
  • centinela-eval -states writes its grey zone as a gate suite (owner-only).
  • The eval set grows from 68 to 77 records: Java4Shell and OwnTracks attacks plus correctly padded Base64 and a benign OwnTracks update. The first 68 records are unchanged. The README's results are labelled as measured on the 68.
  • make gate.

Review

Three rounds of adversarial review and two of test review (Crush/GPT); every concrete finding was fixed except these, declined on purpose:

  • Hand-edited replay files (copying the baseline's results under a new -checkpoint name). The gate is a check an operator runs on their own files, not tamper-proofing. The Laya endpoint exposes no checkpoint digest to bind to, so the identical-answers check is there to catch mix-ups, not forgery.
  • Labels without a training-log state (requests the model never assessed) cannot be replayed. labels reports how many there are.

Testing

  • make test and make vet pass.
  • cmd/centinela-gate/gate_test.go covers the split, the label join, heldout, replay against a fake System One server, every compare rule, run validation and file modes.
  • centinela-eval -states on the new dataset sends 59 of 77 records to the model (all 34 attacks), and rules 1014938 and 1031852 appear in their states.
  • Not yet run against real checkpoints.
Adds `centinela-gate`, which decides whether a retrained Laya checkpoint may replace the one in service. It is step 1 of moving retraining into this repo: retraining can run unattended, so something has to stop a worse checkpoint from going live. r4, for example, lost the `admin'--` SQLi block. ### What it does It replays the same recorded model inputs through the serving checkpoint (baseline) and the candidate, applies the production policy (`balanced`), and refuses the candidate if, in any suite: - it detects fewer attacks or blocks more benign requests than the baseline (`-max-detection-drop` / `-max-fp-rise` default to 0), or - it decides a held-out reviewer label the wrong way, unless that label is in the reviewed exceptions file, or - any record failed to replay. | Suite | Built from | Counts as correct | |---|---|---| | `eval` | `eval/dataset.jsonl` grey zone (`centinela-eval -states`) | attack blocked/shunned; benign not blocked | | `production` | the held-out production slice and its teacher labels (`centinela-gate heldout`) | attack flagged or worse; benign allowed | | `labels` | reviewer labels joined to their training-log states (`centinela-gate labels`) | `should_block` blocked; `false_positive` not blocked | The report (Markdown, ids only, no request content) goes in the PR that changes `laya/checkpoint.env`; `laya/README.md` now says to merge that only on `ACCEPT`. Usage is in `eval/README.md#checkpoint-gate`. ### Held-out labels never train `labels` splits by a SHA-256 of the normalized method, host and path (case, trailing slash/dot, percent-encoding, port, IPv6 brackets), 30% of endpoints by default. It writes the training side to a separate file, and the training pipeline must read labels only from that file. ### Run integrity `compare` stops (exit 2) unless: - both runs hold the same ids with the same per-record state hash; - each run comes from one `-checkpoint`, the two differ, and they don't answer every record identically; - the `eval`, `production` and `labels` suites are present and non-empty. Malformed, duplicated or empty input is rejected, and every file it writes is owner-only, since suites and replays carry request bodies from the training log. ### Also in this PR - `decider.TypeSafe.AssessState` replays a recorded state exactly as given; `Assess` now builds the state and calls it. - `centinela-eval -states` writes its grey zone as a gate suite (owner-only). - The eval set grows from 68 to 77 records: Java4Shell and OwnTracks attacks plus correctly padded Base64 and a benign OwnTracks update. The first 68 records are unchanged. The README's results are labelled as measured on the 68. - `make gate`. ### Review Three rounds of adversarial review and two of test review (Crush/GPT); every concrete finding was fixed except these, declined on purpose: - **Hand-edited replay files** (copying the baseline's results under a new `-checkpoint` name). The gate is a check an operator runs on their own files, not tamper-proofing. The Laya endpoint exposes no checkpoint digest to bind to, so the identical-answers check is there to catch mix-ups, not forgery. - **Labels without a training-log state** (requests the model never assessed) cannot be replayed. `labels` reports how many there are. ### Testing - `make test` and `make vet` pass. - `cmd/centinela-gate/gate_test.go` covers the split, the label join, `heldout`, replay against a fake System One server, every compare rule, run validation and file modes. - `centinela-eval -states` on the new dataset sends 59 of 77 records to the model (all 34 attacks), and rules 1014938 and 1031852 appear in their states. - Not yet run against real checkpoints.
centinela-gate replays fixed suites (the eval grey zone, the held-out
production slice, held-out reviewer labels) through the serving and the
candidate checkpoint and refuses the candidate if detection drops, false
positives rise, or it decides a held-out label against the reviewer.
Labels are split by endpoint hash so held-out labels never train; a
reviewed exceptions file covers labels the reviewers agree were wrong.

centinela-eval -states writes its grey zone as a gate suite, and the
eval set gains Java4Shell, OwnTracks Recorder and padded-Base64 cases.
compare now requires identical id sets and state hashes in both runs,
one checkpoint per run (and two different ones), and the eval,
production and labels suites; malformed, empty or duplicated results
are rejected. The split key is canonicalized, sensitive files are
owner-only even when they already existed, and the eval -states file is
private.
heldout requires every held-out id exactly once and writes its suite
owner-only through -out; exceptions and held-out ids reject duplicates;
null states are rejected; the split key strips a port before a trailing
dot; compare refuses two runs that answer every record identically.
Require at least one gate suite and normalize IPv6 hosts
All checks were successful
test / laya (pull_request) Successful in 5s
security-scan / security-scan (pull_request) Successful in 57s
test / go (pull_request) Successful in 4m11s
92a148ca81
An empty -require list is an error, the report names the required
suites, and bracketed IPv6 hosts share the split key of the bare form.

🔎 ojo scan results

No findings.

<!-- ojo-scan-summary --> ### 🔎 ojo scan results No findings.
james merged commit 8e841677de into main 2026-11-19 13:12:34 +00:00
james deleted branch eval-gate 2026-11-19 13:12:34 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
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
ColibriSec/centinela!28
No description provided.