Skip to content

feat(gateway): hold every receiver to the plane's one tenant - #168

Merged
karauda merged 26 commits into
mainfrom
feat/s29-receivers-one-tenant
Nov 30, 2026
Merged

karauda merged 26 commits into
mainfrom
feat/s29-receivers-one-tenant

Conversation

@karauda

@karauda karauda commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

What changed, and why

A listener.principal.tenant_id that differs from tenant_id is refused at load under directory and memory too, not only under signed, naming the key and both values. Upgrade: leave it unset or set it to tenant_id.

Under directory, an answered approval record (format 2.1) counts only if it names the directory authority, the hold's tenant and the hold's project. Under memory, the store reports each claim with the held call's tenant and project, and only the hold's count. Any other record, and a 2.0 record (which names none of them), is unreadable: a retry is blocked INDETERMINATE EVIDENCE_UNAVAILABLE and the hold stays; at restart the hold closes APPROVAL_STATE_UNKNOWN. Each is counted in guardana_control_pipeline_answers_refused_total under cause other_hold, also when the hold's own claim stands beside it. A hold made before the upgrade is a 2.0 record and stays one when answered after it, so it never releases its call: let it expire, then issue the call again.

Unsigned pause files use version 5, naming tenant and project. A plane reads a file of another tenant or project as unknown (every call blocked PAUSE_STATE_UNAVAILABLE, /healthz 503, doctor naming another tenant or project). Versions 1 and 2 are refused as an unknown version, naming the fix.

pause init now requires --tenant and --project: it creates a version 5 file, or rewrites a version 1 or 2 file in place as 5 keeping its entries. Any other file at the name is refused with the reason (a version 5 file, a signed file, or a mode or owner the plane refuses). pause add, pause remove and the console keep the file's tenancy. state restore carries a backup's 1 or 2 file to 5 for the plane's tenant and project. Under signed, pause add and pause remove on a leftover unsigned 1 or 2 file answer that the file is not signed.

pause list of an unsigned file opens with for tenant <t> project <p>; a plane of another tenant or project, or under signed, reads this file as unknown. The console shows the same line for an unsigned file. For a signed file, it shows For plane <id> tenant <t> project <p>; another plane, or a plane of another tenant or project, reads this file as unknown. /api/state gains pause.tenancy. The scenario runner skips the pause list line.

With pause.file set, a tenant_id or project_id over 256 bytes is refused at load under directory, memory and signed. The error names the key, as in tenant_id: <n> bytes, past the 256 the pause file at pause.file can name. Previously, the plane loaded. Outside signed, it then failed to start reading its pause file. Under signed, it blocked every call.

Invariant or record

ADR-0089 is accepted for receivers. Outside approvals.authority: signed, a plane's receivers hold their input to its one tenant and project. The route part of ADR-0089 comes in a later change.

How it was tested

  • Red first on the base, each recorded: TestAPlaneServesOneTenantUnderEveryAuthority (directory and memory took another listener tenant); TestAClaimOfAnotherHoldIsUnreadable and TestAMemoryClaimOfAnotherHoldIsUnreadable (another tenant's, project's, authority's or a 2.0 claim released the call); TestADirectoryClaimOfAnotherHoldIsUnreadable in cmd/guardana-gateway over a real approvals directory (the lost hold closed APPROVAL_NOT_RESUMED, want APPROVAL_STATE_UNKNOWN); pause acceptance tests (a version 2 file read clear, init wrote version 2); the 257-byte tenant accepted; the other_hold count; console and pause list tenancy; the runner's line skip; and the help form.
  • Mutants killed: the claim's tenant check off; a claim naming nothing accepted; the pause file's tenancy check off; version 2 accepted; the one-tenant check off; the 256-byte bound off by one; the unsigned-leftover case under signed off; the other_hold order restored; and pause init reading the file without its owner and mode check.
  • First-round security and code reviews found no fail-open. Second-round fixes covered stale pages, a red docs gate, and the console and pause list showing another tenancy's file as Clear or Paused. They also covered the 256-byte bound failing at start instead of load, the update migration error under signed, the other_hold count missing beside a good claim, and pause init's untested owner/mode check and dropped refusal cause.
  • The security re-check found no fail-open. An answer in no known state beside another hold's claim now counts under other_hold. The outcome was already unreadable. The console and pause list explain signed files' plane binding and that unsigned files read as unknown under signed. The 256-byte bound covers signed. Before the fix, claimhold_test.go:90 (two claim orders) and pause_test.go:182 (257-byte tenant and project ids loaded under signed) failed.
  • macOS passed on the last commit for internal/gateway (1389), internal/gatewayconfig (656), internal/console (58), internal/pause (196), cmd/guardana-control (799) and cmd/guardana-gateway (910), with make docs-check; internal/recovery (137) and internal/docscheck (472) passed on the commit before, which the last one does not touch outside internal/docscheck/configdoc.
  • Linux arm64 container: internal/pause 196 passed, 0 failed; internal/gatewayconfig 631 passed, 24 failed (all in the access-control-list family that cannot run on the container's file system, none in this change). On Linux only internal/pause and internal/gatewayconfig ran.
  • After merging main, make vet, go vet -tags twoaccounts, golangci-lint on darwin and GOOS=linux, gofmt, make check-sizes, scripts/check-brand.sh and make docs-check passed.
  • Not verified: the console page's script rendering the tenancy (only /api/state is tested). No mutant targets the runner's line skip, the console line or the help form (each has a test shown red first). Local make quality was not run; CI's make quality on this pull request is the gate.

Documentation

Accepted ADR-0089 (receivers part) and amended ADR-0082 validation line. Updated docs/status.md, docs/contracts.md (three rows for the unsigned receivers: directory claim, memory claim, unsigned pause file), docs/reference/cli.md, docs/concepts/enforcement-modes.md, docs/reference/versions.md, docs/guides/run-the-gateway.md, docs/backlog.md (B13), the configuration reference, and CHANGELOG (Changed and Fixed entries with the upgrade steps).

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>
…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
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>
…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
@karauda
karauda requested a review from a team November 29, 2026 21:38
@karauda
karauda requested a review from a team as a code owner November 29, 2026 21:38
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 29, 2026 •

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 ↗
64154c9 2026-11-30T06:39:36.399Z View logs ↗
  • Build: Failed ❌

View logs ↗
e400675 2026-11-29T21:40:59.929Z View logs ↗

The security re-check of the receivers change found three gaps, each
failing closed but misreported or late:

- claimed() stopped at an answer in no known state before it saw
  another hold's claim, so other_hold went uncounted; every claim is now
  judged first and otherHold reported whatever stands beside it.
- pause list and the console did not say that a signed pause file is
  bound to its plane and that an unsigned one reads as unknown under
  signed.
- the 256-byte bound on tenant_id and project_id with pause.file set
  skipped signed, where a longer id loaded and then blocked every call;
  it now holds under every authority.

Signed-off-by: Konrad Karauda <konrad@karauda.com>
Splits the order cases out of the unreadable-claim test to keep each under the complexity bound, and reads the pause file's tenancy through its embedded field.

Signed-off-by: Konrad Karauda <konrad@karauda.com>
@karauda
karauda merged commit b2eb336 into main Nov 30, 2026
13 of 15 checks passed
@karauda
karauda deleted the feat/s29-receivers-one-tenant branch November 30, 2026 06:59
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