mr-onion

Phase 43 Decision Record — Ownership Confirmation, Once per Site, and the Active Gate

Date: 2026-10-19 Scope: A tester confirms once, per site, that they own the site or have written permission to test it. TestForge saves that confirmation with the site, and every run on the site uses it without asking again. A valid confirmation does three things:

The script-payload test runs again behind the active gate.

Status: Locked (Emil, 2026-10-19). Not started.

Order: first after Phase 39 and R4 (the triage’s build order, item 1). Tickets TFP-218 to TFP-221.

Review before building (planning session, 2026-11-14)

This record was locked before Phase 47 (Mr Onion in CI), Phase 48 (the rename) and TFP-284 (Chromium 151). Checked against main at bc09f98. The design stands. These amendments apply; each says who decided it.

  1. Names (Phase 48, mechanical). Read every setting by its new name: the run switch is MRONION_ACTIVE, the interactive switch MRONION_INTERACTIVE, the data folder’s setting MRONION_DATA_DIR, and the product is Mr Onion. A run’s child processes get each setting under both names (Phase 48 Decision 8), so this needs no extra work. The generated script-payload test checks the new name.
  2. The run switch is set from the run’s request, never inherited. (Planning session, following the interactive switch’s rule in src/lib/run/interactive.ts.) The executor always sets MRONION_ACTIVE to “0” or “1” from what the run asked for. A value in the shell or in CI’s environment can’t open the gate.
  3. CI (owner decision, 2026-11-14): a confirmation lifts the caps, and nothing else. The app and the CLI share one pipeline, so the CLI reads a confirmation from its data folder (--data-dir) as the app does, and a confirmed deployed host runs uncapped, as Phase 47 Decision 2 foresaw. The CLI and the action get no active switch in this phase, so no attack-shaped test runs in CI until TFP-249 (D31). A CLI run always sets MRONION_ACTIVE=0. TFP-220’s acceptance adds: a CLI run against a confirmed remote fixture host is uncapped, and its active tests are Not run with the reason “not available in CI yet (TFP-249)”. The CI guide gets a short section on carrying a confirmation in the data folder.
  4. The covered-host guard stops what the route can’t (planning session). Since Chromium 151 a route’s abort doesn’t stop sendBeacon, a keepalive fetch or fetchLater. Decision 9’s guard is built on the read-only guard’s page stub (TFP-284) and dormant wrapper (TFP-287), not on the route alone. Acceptance Criterion 3 adds a beacon, a keepalive POST and a fetchLater to the uncovered host, each shown not reaching it at the server.
  5. TFP-287 comes first (owner decision, 2026-11-14). It’s built and verified before TFP-218, so the guard has the full stub from the start.
  6. TFP-221’s comparison base is today’s runs, not Phase 39’s. Since Phase 39 the browser (Chromium 151), the guard and the template have moved. “Unchanged with the switch off” is measured against runs of main taken just before TFP-219 lands, on both local Toolshop copies. For reference, Action Gate on f5b8e5c gave clean 470 / 46 failed / 18 not run and with-bugs 481 / 84 / 20. TFP-221 is a measurement session: ask the owner first, and batch it overnight (the register’s standing rules). The base is Action Gate’s runs (owner decision, 2026-11-15), not a local measurement session. Action Gate was dispatched on main at 202a17a just before TFP-219, as run 43672714248. Its clean and with-bugs report.json files are committed under benchmarks/2026-11-15-phase-43-base/: clean 470 planned / 406 passed / 46 failed / 18 not run, and with-bugs 481 / 377 / 84 / 20. Both equal 0.4.0’s.
  7. Still true: today’s ACTIVE_GATE_REASON (“not built yet”), closedGates() in src/lib/run/test-gates.ts, and the confirmation stub src/lib/run/ownership.ts that hostLimitsFor reads in the executor (TFP-157). TFP-220 replaces the stub. Acceptance Criterion 6’s template difference is measured against the current TEMPLATE_BASELINE (0fe8ffe).

Context

Decisions

  1. The confirmation is saved with the site, not with the run (Emil, 2026-10-19).
    • It lives at <data>/site-suites/<site>/ownership.json, beside Phase 42’s settings.json, in TestForge’s local data folder. It is never in the repo.
    • It records:
      • the hosts it covers, each typed by the tester;
      • its basis: “I own this site”, or “I have written permission to test it”;
      • the exact wording the tester confirmed;
      • the name of the person who confirmed;
      • their contact email (Emil, 2026-10-19);
      • the date;
      • the expiry;
      • its scopes (Decision 3);
      • when withdrawn, the date it was withdrawn.
    • The contact email says who confirmed and how to reach them.
      • It is kept in the local file only, like the rest of the confirmation.
      • This phase sends nothing to it: TestForge has no way to send mail yet (TFP-217 Part B, D25).
      • D25 uses it later as the report email’s default recipient, for a reminder before expiry, and for a notice when a confirmation is created or withdrawn.
    • Every run on the site uses it without asking.
    • Each run’s record and report name the confirmation: its hosts, basis, name, date, expiry and scopes. The run record keeps a copy as it was when the run started, so a later withdrawal doesn’t rewrite an old run’s history.
  2. Hosts are typed exactly. (Emil, 2026-10-19)
    • Each host is a full host name, such as shop.example.com. A tester covering api.example.com as well types it too.
    • No wildcards. *.example.com would cover hosts the tester never named, and some of those may belong to someone else, for example a hosted service on a customer subdomain.
    • A typed host must match a host the site’s crawl or target address uses. Otherwise it is refused, with the reason. This catches typing errors.
  3. What it unlocks (Emil, 2026-10-19).
    • Always: Phase 39’s worker and request caps are lifted on the covered hosts (Phase 39 Decision 10’s ownership row).
    • Active, its own tick: the active gate opens on the covered hosts (Decision 6).
    • Load testing, its own tick: the opt-in load-testing run (D24, its own record) may run. This phase stores the tick. It builds no load test.
    • Not the interactive gate. That stays on TESTFORGE_INTERACTIVE=1 with no confirmation (Phase 38 Decision 1, unchanged).
  4. A valid confirmation alone doesn’t make a run active. (Emil, 2026-10-19)
    • The active gate opens only when two things are true:
      • the run asks for active tests: a per-run switch, TESTFORGE_ACTIVE, set by the executor to “0” or “1” as it sets TESTFORGE_INTERACTIVE;
      • and the target host is covered by a valid confirmation with the active tick, or is a local host (Decision 7).
    • So a Standard run stays non-intrusive by default (Emil, October 2026). Confirming once removes the repeated question. It doesn’t turn every later run into an attack run.
    • The switch is a choice made per run, like interactive. It isn’t a second confirmation.
  5. Expiry (Emil, 2026-10-19).
    • 90 days by default.
    • The tester may choose another expiry, up to 1 year from the date confirmed.
    • An expired confirmation counts as absent.
    • The report says it expired and when, so the tester knows why the caps came back and the active tests didn’t run.
  6. Withdrawal (Emil, 2026-10-19).
    • A tester can withdraw it at any time.
    • A withdrawn confirmation counts as absent from the next run on. The record keeps it, with its withdrawal date, as evidence of what was confirmed and when.
  7. Local hosts need no confirmation (the D8 proposal, accepted 2026-10-19).
    • The local hosts are Phase 39 Decision 10’s list: localhost, 127.0.0.1, [::1], *.localhost, *.test.
    • On those, the active gate follows Decision 4’s switch alone.
    • This covers the local Docker copies of Toolshop and of other practice sites.
  8. When the confirmation doesn’t cover a run, the run still runs. (Emil, 2026-10-19)
    • At the start of a run that asks for active tests, TestForge checks the target host against the confirmation.
    • If the confirmation is missing, expired, withdrawn, doesn’t cover the host, or lacks the active tick, the run goes ahead with the active gate closed. Each active test is Not run, with a reason naming which of these applies. The report says how to fix it: confirm, renew, or add the host.
    • Nothing prompts mid-run. TestForge is driven by the API and runs unattended.
    • The change from Phase 35 Decision 8: that decision’s “a run whose domain doesn’t match does not start” becomes “its active tests don’t run”. Read-only and interactive tests on a site don’t need permission, so stopping the whole run would only remove harmless coverage.
  9. Active tests reach only covered hosts.
    • During an active-gate test, a request to a host the confirmation doesn’t cover is aborted. The test fails as a guard breach, naming the host. This is the read-only guard’s pattern (Phase 41, TFP-181).
    • Attack-shaped input sent to a host nobody confirmed is exactly what the confirmation exists to prevent, including through a redirect or a third-party form handler.
  10. The script-payload test runs again behind the open gate.
    • It is Phase 38’s test, unchanged: “script-shaped input is not executed”.
    • With the gate closed, it is Not run, with Decision 8’s specific reason in place of today’s “not built yet”.
  11. Model-written tests at the active gate stay Not run. (Emil, 2026-10-19)
    • Today the local model’s Comprehensive security scenarios sit at the active gate (Phase 38, TFP-147). They are never run, because they may send attack-shaped input.
    • Opening the gate doesn’t change that. Untrusted, model-written attack code against a real site is a separate decision. It goes with D6’s measurement in R5’s scenario-gaps record.
    • They stay listed, with the reason “model-written active test: not run”.
  12. Practice sites (2026-10-19).
    • A hosted practice site counts as “written permission” only when its published terms explicitly allow attack-shaped or load testing. Otherwise the tester doesn’t confirm it. It stays capped, with no active tests.
    • TestForge can’t check a site’s terms. So this rule goes in the setup documentation and in the confirmation’s wording.
  13. API first. The screen comes from R5’s app-screens record. (Emil, 2026-10-19)
    • This phase adds the API:
      • read the confirmation;
      • create or replace it;
      • withdraw it.

This follows Phase 20’s login config and Phase 42’s gap-writer opt-in.

  1. Two locked records are amended in the same commit as this record locks (Emil, 2026-10-19).
    • Phase 35 Decision 8:
      • “saved with the run” becomes “saved with the site, and named in each run’s report”;
      • and Decision 8 above replaces “does not start”.
    • Phase 39 Decision 10: “once that confirmation is saved with the run” becomes “once the site has a valid confirmation covering the host”.
    • The behaviour Phase 39 builds is otherwise unchanged.

Acceptance Criteria

  1. The stored confirmation
    • Through the API, a confirmation can be:
      • created and read back with every field of Decision 1;
      • withdrawn, keeping it with its withdrawal date.
    • The API refuses one with a missing field, an untyped host, a wildcard, an invalid contact email or an expiry beyond 1 year, each with its reason.
    • Nothing is sent to the contact email: no mail code is added in this phase.
    • It is written under the data folder, never the repo. A unit test runs on a temporary data folder (TESTFORGE_DATA_DIR).
  2. The gate
    • On the fixture, with TESTFORGE_ACTIVE=1 and a valid confirmation with the active tick, the script-payload test runs.
    • On the fixture, without TESTFORGE_ACTIVE, it is Not run, whatever the confirmation says.
    • Each of these gives its own Not-run reason:
      • missing;
      • expired;
      • withdrawn;
      • host not covered;
      • no active tick.
    • With the gate closed, the rest of the run is unchanged.
    • On a local host, TESTFORGE_ACTIVE=1 alone opens it.
    • Model-written active tests stay Not run with the gate open (Decision 11).
  3. Only covered hosts
    • A fixture case in which an active test’s submit goes to an uncovered host (by a redirect or a form’s action) fails as a guard breach naming the host.
    • No request reaches that host. The request-recording test shows it.
  4. The caps
    • Phase 39’s TFP-157 stub is replaced by the stored confirmation:
      • a remote fixture host with a valid confirmation runs at the machine limit, with no request cap;
      • with the confirmation expired or withdrawn, the same host is capped.
    • The run record shows the host row and the confirmation’s copy (Phase 39 Decision 11).
  5. The report
    • A run with a confirmation names it: hosts, basis, name, date, expiry and scopes.
    • The contact email is never in the report or its exports (Emil, 2026-10-19). Reports get shared, and the email only needs to be in the local confirmation file. A unit test checks a report built from a confirmation doesn’t contain it.
    • A run whose confirmation is missing, expired or withdrawn says so, with what to do.
  6. Unchanged by default
    • Without TESTFORGE_ACTIVE, the failure sets on both local Toolshop copies are the same as Phase 39’s final runs, test by test.
    • check:template-unchanged differs only by the script-payload test’s skip line becoming a check at run time. The difference is described and the baseline (TEMPLATE_BASELINE in nightly.yml) is updated in its own commit.
  7. One real run
    • Standard with TESTFORGE_ACTIVE=1 on the local with-bugs Toolshop copy (a local host):
      • the script-payload test runs on each form it targets;
      • its results are recorded against the answer key;
      • any finding is matched to a listed bug or explained.

Regression Policy

Each of these has a line in deferred-work-register.md.

Dependencies and order

Backlog

TFP-218 — The confirmation, stored per site, and its API

TFP-219 — The active gate opens on a covered host, by run switch

TFP-220 — Active tests reach only covered hosts; the caps come from the confirmation

TFP-221 — Measure: the script-payload test on local with-bugs

  1. TFP-218.
  2. TFP-219.
  3. TFP-220.
  4. TFP-221.

Suggested Milestone Gates

Gate A — Confirmed and gated

Gate B — Guarded and measured