Skip to content

Producer admission: who may post a watch, and what a refusal means

Refs #250. This is the policy applied at every event-ingestion door of the core, the client behaviour it requires, and the deployment veto it replaces. The companion document is safe deployment §3, which is about the restart gap itself.

Observed in production on revision c577dad:

  • POST /v1/events answered HTTP 200 to a request carrying no producer headers. The watch was ingested, and ingest_client recorded name=unidentified, contract=0, door=events.
  • The restart gate then refused the next deployment with unsafe_producer_configured, and kept refusing it, because something that could lose a watch had posted recently.

Admission and deployment were applying different standards to the same producer. One accepted it; the other held its acceptance against the service for a fortnight. The fix is to move the standard to the door: a producer this core would refuse to deploy around is a producer this core does not accept events from, and it is told so when it posts.

What “verified” means here — read this before describing it to anyone

Section titled “What “verified” means here — read this before describing it to anyone”

X-AutoMiner-Client, X-AutoMiner-Client-Version and X-AutoMiner-Durable are a self-declaration. Anything that can reach the door can type them. They are not authentication, they are not proof that a client has an outbox, and nothing in this system verifies that a producer actually replays anything.

What admission adds on top of the self-declaration is an operator decision: an identity is admitted only if a person enrolled and approved it (producer_enrollment), and the row records who, when and why. That turns “anyone who types extension” into “the identity an operator accepted, making the claim the operator accepted it for”. It is an allowlist over a self-declared name — a meaningful, auditable control, and not a cryptographic one.

Authentication is unchanged and lives where it already lived: the Tailnet, the optional X-Preview-Token, and the phone door’s shared secret. No universal secret is added to any client — a secret shipped inside an unpacked browser extension is not a secret.

Every route that mutates domain state from a producer’s post calls admission.guard before the mutation:

Door Route Notes
events POST /v1/events The browser extension, the Spotify and Stremio adapters, and the Windows relay agent are all HTTP clients of this one — the relay forwards the caller’s headers and the core’s status and body verbatim, so it is covered by the door rather than by a rule of its own.
youtube-android POST /v1/ingest/youtube-android The shared secret authenticates the hop and runs first (an unauthenticated caller gets 401 and is not told about enrolment). Admission runs after it and says nothing about the hop.

There is no batch or multi-envelope ingestion route, so admission is per request and atomicity is not in question: a request is admitted whole or refused whole. A route added later that reaches ingest.ingest, revanced.report or producers.record without calling admission.guard first fails core/tests/operations/test_producer_admission.py — that test walks the AST of app.py rather than trusting anyone to remember.

Checked in this order, because that is the order in which a person can act on the answer. Telling an unknown producer that its contract is out of date would send it to update a client that still would not be admitted.

  1. an identity is present and well-formed ([A-Za-z0-9][A-Za-z0-9._+-]{0,63});
  2. that identity is enrolled, approved, and not expired;
  3. the durability header parses strictly as a decimal contract number — 2.0, +2, 0x2, two and out-of-range values are refused, never coerced;
  4. the contract is at least producers.MIN_DURABLE_CONTRACT (currently 2), or the higher minimum the enrolment names;
  5. the build header is present, if the enrolment requires one.

Contract 2 does not require a build. X-AutoMiner-Client-Version is provenance, not proof: demanding a string any client could type checks nothing. What it buys is that two builds making the same claim stay distinguishable in the evidence and that a refusal can name one. It can be required per producer (--require-build), and doing so is a coordinated client rollout, not a flag flip: every build of that producer must already be sending it.

Every refusal is a non-2xx with ok: false, accepted: false, and no event_id, media_id, job or held field — nothing a client could read as an acknowledgement that its watch is somewhere.

{
"ok": false,
"accepted": false,
"errors": ["producer_identity_unknown: ..."],
"error": {
"scope": "producer",
"reason": "producer_identity_unknown",
"category": "authorization",
"retryable": false,
"message": "...",
"remedy": "...",
"doc": "docs/producer-admission.md",
"producer": {"name": "...", "contract": 2, "build": "..."},
"policy": {"mode": "enforce", "min_contract": 2}
}
}

scope: "producer" is what a client keys on: it means this client was refused, not this envelope. The reason codes are stable and appended to rather than renamed.

Reason Category HTTP What has to change
producer_identity_missing validation 400 the caller sends X-AutoMiner-Client
producer_identity_malformed validation 400 the caller sends a usable identity
producer_identity_unknown authorization 403 an operator enrols it
producer_identity_revoked authorization 403 an operator re-approves it
producer_identity_expired authorization 403 an operator re-enrols it
producer_contract_missing capability 426 a newer client build
producer_contract_malformed validation 400 the caller’s own bug
producer_contract_unsupported capability 426 a newer client build
producer_build_missing capability 426 a newer client build

A maintenance failure is a different thing entirely and is not an admission failure: an admitted producer’s event during a drain is accepted and held, answered 200 with maintenance.held, and the client must not retry it. See safe deployment §2.

It appends nothing to the event ledger, creates or updates no session or media, enqueues no job, and — this one matters — is not recorded in ingest_client. That table is the restart gate’s evidence about producers the core admits; a refused probe able to write into it could park a permanent deployment veto by posting one malformed header.

Refusals are counted in producer_rejection instead: identity, door, reason, contract, build, a count and two dates. No payload, no other header, nothing that could carry a credential or the title of something somebody was watching. The table is bounded by eviction of the least recently seen row (admission.REJECTION_ROW_LIMIT, 200), because the identity is caller-supplied.

The browser extension (extension/background.js) treats scope: "producer" as a client-level refusal, distinct from both a bad envelope and an outage:

  • the envelope stays in the outbox — persistent, counted in outboxDepth, visible in the popup, and recoverable. It is not quarantined: setting it aside would suggest the watch was bad, and it was not;
  • the queue backs off for BLOCKED_RETRY_MS (30 minutes) rather than climbing the ordinary 15s–5m curve. A permanent incompatibility must not be retried at high frequency;
  • ordering is unchanged — only the head is ever sent, so replay after approval is in acceptance order, and the core’s idempotency key handles the duplicate a worker killed after a successful POST can produce;
  • the popup shows the core’s own message and remedy, the reason code and how many events are being kept. The state is cleared by a delivery, never by a timer.

Note the trap this closes: admission answers 400 for a malformed identity header, and the previous client read any 400 as “this envelope will never be accepted” and set it aside. The watch was fine; the client was not.

Rejecting an obsolete client does not make it lossless. A client that never buffered still loses whatever it was about to send — it simply loses it at the door, visibly and with a reason, instead of having it accepted and then counted against every future deployment. What rejection buys is that the producer is ineligible, so it cannot post into a restart gap. That is a different claim from “safe”, and it is the only one this makes.

Terminal window
autominer producers # the restart verdict (exit 0 = safe)
autominer producers list # policy, enrolments, admitted, refused
autominer producers approve extension --operator "<your name>" --note "0.10.1 rollout"
autominer producers revoke extension --note "profile retired"
autominer producers policy # read the mode
autominer producers policy --set observe # audit refusals, still accept
autominer producers policy --set enforce --confirm clients-updated-rejections-accepted

Enrolment and the policy switch are local database operations, like the maintenance barrier. There is deliberately no HTTP route that can admit a producer: GET /v1/producers and /healthz are read-only.

GET /v1/producers returns the policy, the enrolments, the admitted producers and the bounded rejection audit. /healthz carries producer_admission: {mode, enforced_doors, min_contract, doors, since}.

Mode Ingestion Deployment gate
permissive (the unconfigured default) records and accepts exactly as before the policy existed, and audits what would be refused the 14-day unsafe-producer veto applies, unchanged
observe same, and the audit is the point: it is how you find out whether enforcement is safe to turn on the 14-day veto applies, unchanged
enforce refuses, before any domain mutation historical unsafe observations on enforced doors are retired — see below

The default is permissive on purpose. A core that began refusing every producer the instant this shipped would destroy exactly the watches the policy exists to protect, before any client could be updated. Enforcement is an operator decision taken after the rollout.

Do not skip step 4. The --confirm token exists so that this cannot happen by habit.

  1. Deploy the core with this change. Nothing changes for any client: the mode is permissive, every post is accepted and recorded as before, and the deployment gate behaves exactly as it did.
  2. Enrol the producers you actually have. autominer producers approve extension, plus the adapters (spotify-adapter, stremio-adapter) and the phone client if that door is configured. Enrolling the phone client is an explicit operator decision to accept a producer that is not in this repository and cannot be shown to buffer anything.
  3. Switch to observe and leave it for as long as it takes for every profile and device to post at least once. autominer producers list shows who is being refused and why. A browser profile only updates when somebody loads the new build into it, and nothing here can detect that for you.
  4. Roll the clients out, and watch the refusal list empty. Anything still listed is a real client that will start being refused in the next step.
  5. Enforce: autominer producers policy --set enforce --confirm clients-updated-rejections-accepted. Confirm on /healthz that the running process reports "mode": "enforce" and both doors in enforced_doors.
  6. Re-run autominer producers. Historical unidentified and unsupported observations now appear as retired rather than unsafe, and deployment is no longer vetoed by them.

autominer producers policy --set permissive needs no token, and it restores the old behaviour completely: posts are accepted and recorded again, and the 14-day veto comes back for anything recent and unsafe. Turning enforcement off does not leave the gate believing every admitted client is restart-safe — the gate reads the mode from the running service on every run.

Why the historical veto retires, and exactly when

Section titled “Why the historical veto retires, and exactly when”

The 14-day window existed because an unsafe producer might post again during the restart. Once the running service refuses that producer at the door, it cannot. The observation stops being a prediction and becomes history.

So producers.assess takes enforced_doors — read from the running service’s /healthz, never from the checkout — and moves recent unsafe observations on those doors from unsafe to retired. They are reported, they are kept, and they are not a refusal.

What this deliberately does not require: waiting fourteen days, a fresh watch event, a per-client retirement confirmation, or deleting a registry row.

What does not retire an observation:

  • a newer healthy claim under the same name. extension is every browser profile at once, and one good profile is not evidence about another;
  • a policy that exists only in a checkout. A not-yet-deployed policy protects nothing, which is why the gate reads the running process and why a runtime that reports no producer_admission field at all keeps every protection it had;
  • enforcement on a different door. Retirement is per door, so a path that still admits unsafe producers keeps its veto exactly as before.