Skip to content

feat(reaction): a route of one project with a scope per rule - #169

Merged
karauda merged 32 commits into
mainfrom
feat/s29-route-v1alpha4
Nov 30, 2026
Merged

karauda merged 32 commits into
mainfrom
feat/s29-route-v1alpha4

Conversation

@karauda

@karauda karauda commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

What changed, and why

Outside approvals.authority: signed, the key at reaction.public_key signs reaction-route/v1alpha4. Required members are kind, route_id, serial, tenant_id, project_id, lift_public_key and rules. Each rule sets scope to run, agent or principal. There is no route-wide scope. The agent and principal rules require expires_seconds and apply only to REPEATED_DENIAL version 2. The route must match the listener's tenant and the plane's project. The plane refuses a project mismatch and names both project ids. Under signed, v1alpha3 stays and v1alpha4 is refused.

A v1alpha4 route uses a 4.0 list. Its stop and covered lines add project_id, scope and subject. A lift line names scope, subject and through_line and holds a reaction-lift/v1alpha4 envelope. The reader refuses lines from another tenant or project. It requires each lift to be signed by the route's lift key and bound to the line's scope, subject, list and route. Agent and principal stops count only for current REPEATED_DENIAL version 2. A run stop of a superseded or retired rule version is kept as before.

react writes 4.0 lines with the finding's project, the rule's scope and the run's subject. stops lift --agent <id> and stops lift --principal <id> work with --public-key as well as under signed. Until per-caller principals land, an agent or principal stop matches the configured listener agent or principal in the plane's project and blocks every call on that plane until it expires or is lifted.

Outside signed, reaction-route/v1alpha1 routes and 1.0 lists are refused with route sign and stops init as remedies. Nothing is carried from either. Over a v1alpha1 route, the plane starts with every call blocked by STOP_STATE_UNAVAILABLE, stop state unknown and cause another format version. The doctor check reaction fails with run starts on it with every call blocked. A plane over a v1alpha4 route whose list is still 1.0 refuses to start, naming stops init. Before its first write, state restore refuses a backup containing a list under a v1alpha1 route or a 1.0 list.

Under signed, the plane, doctor and the stops commands reject an operator-payload envelope around a v1alpha1 body as another kind before reading any signature. This avoids directing operators to commands that signed refuses.

Invariant or record

This implements the route part of ADR-0089. Outside signed, each route names one project and each rule names its scope. The receivers part landed in the previous change.

How it was tested

  • Recorded failures on the base for the route, project and scope tests in internal/reaction/route4_test.go, the v1alpha1 refusal naming route sign and stops init, TestASignedPlaneRefusesToStartOverAnUnsignedRetiredRoute, TestAV1Alpha4ListHoldsAWiderStopOnlyOfRepeatedDenialTwo, TestDoctorSaysAPlaneOverARetiredRouteStartsBlocked and TestASignedCommandRefusesAnUnsignedV1Alpha1RouteAsAnotherKind. The base could not read a v1alpha4 route.
  • Tests killed mutants that removed the project check on routes, stop lines or covered lines, the lift signer, lifetime or scope-rule check, or the signed retired-route mapping. They also killed mutants that accepted v1alpha1 or 1.0 or let a refused poller read. Tests caught disabling the v1alpha4 wider-stop check or applying it to every scope, and disabling doctor's retired-route message or using it for every error.
  • First-round security and code reviews found no fail-open, cross-tenant acceptance or cross-project acceptance. Second-round fixes made signed startup refuse unsigned v1alpha1 bodies, rejected wider stops from superseded or retired rule versions, and corrected doctor's startup wording and history comments. The security re-check found no fail-open and one low-severity issue. This PR fixes it by making stops commands under signed report another kind for an unsigned v1alpha1 body.
  • On macOS after merging main, internal/reaction (194), internal/reaction/stopwrite (71), internal/reaction/stoplist (31), internal/gatewayconfig (657), internal/recovery (141), internal/gateway (1389), internal/console (58), internal/pause (196), cmd/guardana-control (802), cmd/guardana-gateway (915) and make docs-check passed.
  • On Linux arm64 with second-round code, internal/recovery passed all 141 tests. internal/reaction recorded 193 passes and one failure. TestReactionReachesNoFindingCode could not run go list because the container lacked go. Linux coverage excluded tests that build a binary, run go list or need filesystem ACLs. End-to-end retired-route tests ran only on macOS.
  • Code inspection and a security re-check probe covered the new list's refusal to carry an agent stop from a v1alpha4 route naming a retired rule version. That case has no dedicated test. Principal matching against the authenticated caller comes next. Local make quality was not run. CI's make quality is the gate.

Documentation

Amended ADR-0089 to record startup refusal for a 1.0 list under v1alpha4 and added the ADR-0046 pointer. In docs/contracts.md, updated the route, stop list and lift sections and the "Route under a route key" row. Updated docs/reference/reaction.md, docs/reference/reaction-signed.md, docs/reference/versions.md, docs/status.md, docs/concepts/control-and-supervision.md, docs/concepts/glossary.md, docs/concepts/privacy.md and docs/concepts/signed-operations.md. Also updated "Supervise and stop a run", "Upgrade a plane from 0.17", README.md and the site. The CHANGELOG Changed entries give the upgrade steps for a 0.19 plane.

An account that may write the signed inbox could file
<A>.<bob key id>-reject.answer before Bob answered, holding an envelope for
another approval or junk under a junk signature. The inbox left the first
out alone and the plane left the second out as unauthenticated, so the
batch read complete; Bob's reject then failed on the taken name and another
operator's approval ran the call. A name spelling A in other letter cases
took the same entry on a case-folding volume and was never listed for A.

The inbox now counts every entry whose approval id matches A without case
as named for A, and holds each file to its own label: the body's
<keyId>-<decision>, or that with -2 to -16, under one signature by the
body's key, with a body naming A. Anything else leaves the batch unjudged
(causes misnamed, malformed, other_approval). The plane reads an answer
that does not authenticate as unknown, lets a valid rejection win over
unjudged files, and otherwise holds the call INDETERMINATE (cause
batch_unjudged); a truncated batch stays unavailable. approvals approve and
reject file under the next free fresh label when the name is taken, say so
on stderr, and refuse once all sixteen are taken.

An answer by a revoked operator, by the pinned policy key or with no
signature now holds its call INDETERMINATE until a valid rejection, the
hold's expiry or the file's removal, where another operator's approval used
to run it.

Signed-off-by: Konrad Karauda <konrad@karauda.com>
A volume that folds case or normalizes names can take a name holding a
byte outside ASCII as the name an answer needs, by rules no comparison
here reproduces (APFS folds "ß" onto "SS" and "st" onto "ST"), so such
a name now makes every batch unjudged rather than being left out as
foreign.

approvals approve|reject passed over any taken name for a fresh label,
the operator's own earlier answer included, so a second answer of the
same decision was filed beside the first. A name this account's own
file holds is now refused as filed; only another account's file is
passed over, and the stderr line names it as such.

Signed-off-by: Konrad Karauda <konrad@karauda.com>
…nedBy

The uid comparison converted os.Geteuid's int to uint64, which gosec refuses; the shared helper also refuses a negative uid.

Signed-off-by: Konrad Karauda <konrad@karauda.com>
ADR-0073 records the 0.20 reading of an answer's name (the approval id
ignoring ASCII case, an ASCII-only label set) and that any valid
rejection wins over files the plane cannot judge. The approvals concept,
the signed operators guide, the command line reference, the status
page's limits and the changelog say what an operator sees: the next free
label when another account holds the name, the refusals, and that an
unjudged file holds its call INDETERMINATE until a valid rejection, the
hold's expiry or its removal.

Signed-off-by: Konrad Karauda <konrad@karauda.com>
Signed-off-by: Konrad Karauda <konrad@karauda.com>

# Conflicts:
#	CHANGELOG.md
#	site/docs/changelog.html
The answer's label scheme pushed the page past the reference budget of
1500 words. Six hand-written paragraphs say the same facts in fewer
words; the generated help blocks are unchanged.

Signed-off-by: Konrad Karauda <konrad@karauda.com>
Any account that may write the inbox can hard-link a file this account
owns under the name an operator's answer takes. The signing command read
"this account owns the inode" as "this is my earlier answer", refused, and
filed nothing, so a linked file kept the operator's rejection out until
the hold expired.

The command now refuses as filed earlier only when the file at the name,
read bounded and without following a link, is one envelope of the answer
payload type whose one signature verifies under the operator's key and
whose body is that key's answer to this approval with this decision.
Anything else is passed over for the next free label, as another
account's file is, and stderr names the taken file as "a file that is not
this answer" with its owner.

Signed-off-by: Konrad Karauda <konrad@karauda.com>
The CLI page, the signed operators guide and the changelog now say that
`approvals approve|reject --key` refuses a taken name as filed earlier
only for this account's own verified answer, and files under the next
free label otherwise. An unauthenticated answer is counted under
`unauthenticated`; a file the plane cannot hold to its name is
`misnamed`, which `/healthz` shows, and a name outside ASCII is removed
by hand. ADR-0073's amendment and the status limit say an inbox writer
can hold a call `INDETERMINATE` by truncating the batch, a valid
rejection notwithstanding, but cannot make one run.

Signed-off-by: Konrad Karauda <konrad@karauda.com>
Signed-off-by: Konrad Karauda <konrad@karauda.com>

# Conflicts:
#	CHANGELOG.md
#	site/docs/changelog.html
On a volume that folds case, a valid rejection linked under another
spelling opens through the exact name, while the plane counts that entry
misnamed. The command now treats the name as taken by this answer only
when the directory lists it byte for byte.

Signed-off-by: Konrad Karauda <konrad@karauda.com>
Signed-off-by: Konrad Karauda <konrad@karauda.com>
The command opened the inbox once but then checked the owner of a taken
name and the directory's listing by path again, so moving the inbox and
putting another directory at its path could make it refuse an answer as
filed earlier while the real inbox held only another spelling. Both now
go through the opened directory: Inbox.Lstat and Inbox.ListsExactly.

The listing reuses the plane's, bounded at 4096 names and 16 answers per
approval; past a bound, or when it cannot be listed, the name counts as
not listed and is passed over. When the passed-over file is this
account's own answer under a name the plane may not read, stderr now
says so instead of calling it a file that is not this answer.

The spelling test skips, with its reason listed in expected-skips.txt,
on a volume that does not open the other spelling through the exact
name, and covers U+017F, which APFS folds onto "s".

Signed-off-by: Konrad Karauda <konrad@karauda.com>
The command refused "filed earlier" for this key's answer to the same
approval id and decision, whatever tenant, project, request, action digest
or bundle digest it named, while the plane leaves such an answer out as
another hold's. It now compares every member the plane compares.

Signed-off-by: Konrad Karauda <konrad@karauda.com>
One tenant under every authority: a listener.principal.tenant_id apart
from tenant_id is now refused at load under directory and memory as under
signed, naming both keys.

A claim read from approvals.dir, or from the memory store, now carries
the authority, tenant and project its record names, and the plane takes
it only when they are the directory kind and the hold's own tenant and
project. A claim that names another, and a 2.0 record, which names none,
leave the hold standing: the retry is INDETERMINATE, a restart closes it
APPROVAL_STATE_UNKNOWN, and the plane counts an answer of another hold.

Signed-off-by: Konrad Karauda <konrad@karauda.com>
The unsigned pause file moves to schema_version 5, which names tenant and
project. A plane reads a file of another tenant or project as unknown and
blocks every call, as it does under any unreadable pause file. Versions 1
and 2 are refused, naming pause init --tenant --project, which rewrites
such a file as version 5 with its entries. pause add, pause remove and the
console keep the file's tenancy; state restore carries a version 2 backup
as version 5 of the plane's tenancy and refuses another one. The signed
file stays version 4.

Signed-off-by: Konrad Karauda <konrad@karauda.com>
parseAny reads the head and the entries in two functions, and the tests
that grew past the complexity bound are split, each read error checked.

Signed-off-by: Konrad Karauda <konrad@karauda.com>
Outside signed the route is reaction-route/v1alpha4: it names project_id,
and each rule a scope of run, agent or principal; agent and principal need
expires_seconds and are taken only for REPEATED_DENIAL 2. A plane refuses a
route of another project, naming both (ADR-0089).

Its list is 4.0: stop and covered lines add project_id, scope and subject;
a lift line names scope, subject and through_line and holds a
reaction-lift/v1alpha4 envelope signed by the route's lift key. A stop,
covered line or lift of another tenant or project, and a lift not signed by
the lift key, are refused.

A v1alpha1 route and a 1.0 list are refused naming route sign and stops
init; nothing is carried from them. A plane over a v1alpha1 route starts
with its stop state unknown and blocks every call; state restore refuses
both before its first write. route sign, stops init, react, stops lift
(--run, --agent, --principal) and stops list write and read the new
formats.

Signed-off-by: Konrad Karauda <konrad@karauda.com>
…e-tenant

Signed-off-by: Konrad Karauda <konrad@karauda.com>

# Conflicts:
#	CHANGELOG.md
#	cmd/guardana-control/approvals_sign.go
#	cmd/guardana-control/approvalssquat_test.go
#	docs/reference/cli.md
#	internal/gateway/authority.go
#	internal/gateway/signed_helpers_test.go
#	site/docs/changelog.html
#	site/docs/reference/cli.html
Signed-off-by: Konrad Karauda <konrad@karauda.com>
Init reads the file it would carry through ReadUnsignedV2 and wraps the
cause of a refusal: a version 5 file, a signed one, one it cannot parse,
or the mode or owner a plane's read refuses. Merge decodes its backup
through the same reader, which now refuses a signed file itself. Under
the signed authority a write to an unsigned file of version 1 or 2
answers ErrUnsigned, as the plane's read does. The signed header checks
its tenancy through Tenancy.Check, the worst-case file of a 256-byte
tenancy is pinned inside the byte bound, and the versions page lists
the versions the code writes and reads.

Signed-off-by: Konrad Karauda <konrad@karauda.com>
A claim whose record names another tenant, project or authority is
judged before the duplicate check, so a good claim filed first no
longer hides it from the other_hold count.

Signed-off-by: Konrad Karauda <konrad@karauda.com>
Outside the signed authority, with pause.file set, a tenant_id or
project_id past the pause file's 256-byte bound is refused at load,
naming the key, instead of failing when the plane starts its poller.

Signed-off-by: Konrad Karauda <konrad@karauda.com>
pause list opens an unsigned file's listing with its tenant and project
and says that a plane of another reads the file as unknown; the console
says the same of every readable file, signed ones included, and the
scenario runner skips the line. The help shows --tenant and --project
as required for pause init, and the command line page follows it.

Signed-off-by: Konrad Karauda <konrad@karauda.com>
update asks writeKind whether the file it read is of the write's kind,
which keeps update under the complexity bound, and the memory claim
test carries each case's count beside its outcome.

Signed-off-by: Konrad Karauda <konrad@karauda.com>
…an old rule

Under the signed authority a v1alpha1 body is refused as any other kind,
before its signature is read, so a plane over a file no one signed refuses
to start instead of starting blocked. Outside signed a plane over a
v1alpha1 route signed by the route key still starts with every call
blocked, and doctor now says so instead of saying run refuses to start.

Under a v1alpha4 route an agent or principal stop of a superseded or
retired rule version is refused: those scopes stop only under
REPEATED_DENIAL version 2 (ADR-0089). A run's stop of such a version is
still kept, since a carry from a route naming it writes one.

Comments describing the retired formats no longer tell their history.

Signed-off-by: Konrad Karauda <konrad@karauda.com>
…oject

ADR-0089 is accepted for its receivers: the listener's tenant, directory
and memory answers and the unsigned pause file version 5. The pages, the
configuration reference and the changelog say what a plane outside signed
now refuses, and how to upgrade a pause file and a pending hold.

Signed-off-by: Konrad Karauda <konrad@karauda.com>
…e-tenant

Signed-off-by: Konrad Karauda <konrad@karauda.com>

# Conflicts:
#	CHANGELOG.md
#	docs/backlog.md
#	site/docs/changelog.html
…pha4

Signed-off-by: Konrad Karauda <konrad@karauda.com>
…tops

Under the roster, rosterRoute read the route's body before verifying it,
so an envelope of the operator payload type around a v1alpha1 body no
one signed answered with the retired route's remedy, which names route
sign and stops init, both refused under signed. It now answers as any
other kind, as the plane's own signed reader does.

Signed-off-by: Konrad Karauda <konrad@karauda.com>
The pages, the record and the changelog say what the v1alpha4 route, the 4.0 stop list and the v1alpha4 lift do outside signed, what a 0.19 plane meets on upgrade, and that a v1alpha1 route starts a plane with every call blocked while a 1.0 list under a v1alpha4 route refuses the start.

Signed-off-by: Konrad Karauda <konrad@karauda.com>
Signed-off-by: Konrad Karauda <konrad@karauda.com>
Signed-off-by: Konrad Karauda <konrad@karauda.com>
@karauda
karauda requested a review from a team November 30, 2026 07:13
@karauda
karauda requested a review from a team as a code owner November 30, 2026 07:13
@cloudflare-workers-and-pages

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Failed ❌

View logs ↗
0a65c76 2026-11-30T07:13:29.112Z View logs ↗

@karauda
karauda merged commit c3e874f into main Nov 30, 2026
17 of 18 checks passed
@karauda
karauda deleted the feat/s29-route-v1alpha4 branch November 30, 2026 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant