Repository navigation
Download gate: per-box maker acceptances for the factory (#464) - #470
Draft
teaspoonai wants to merge 14 commits into
Draft
teaspoonai wants to merge 14 commits into
teaspoonai wants to merge 14 commits into
Conversation
The factory station records, as it provisions each box, a maker acceptance for it (POST /api/factory, authorized by the station-only FACTORY_TOKEN; a maker_acceptances row: no one's acceptance of the license) and writes only its id into the box, as the receipt. install.sh's first-boot run gets download tokens with it through /api/token, whatever the license's version, for MAKER_MAX_DAYS; after that, or once revoked, the box's owner accepts (#465). No secret ships in any image. Each record is per box and revocable; FACTORY_DAILY_MAX caps the boxes recorded a day, per FACTORY_TOKEN. Migration 0003 (after #468's 0002), additive. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A factory receipt is never an acceptance of its version, with or without a license server to ask; --accept-eula is honored over it. RELEASING.md follows teaport-factory's real flow (the station calls /api/factory in /provision, the box's agent writes the receipt before /etc/appliance-id, the seal removes it, the first-boot unit drops TEAPORT_ACCEPT_EULA). The data note: what a box shipped with its receipt would record. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A revoked factory record lets the owner accept, as an expired one does: it says nothing about them. RELEASING.md: /provision answers only on the boxes' USB network and only for boxes the station flashed; the record id goes beside ProvisionConfig's keys, so older agents still provision; the first-boot unit waits for /etc/appliance-id; the shared per-IP limit; how to provision a box again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RELEASING.md: the station sends a box its stored maker id again on a retry or while it stands, and records a new one only past its time, revoked, or on purpose; where the station keeps FACTORY_TOKEN; the receipt needs only method and acceptance_id; the seal checks the receipt is gone. A download with a maker record past its time is refused with 403; a later token request in the same run speaks of the factory record. A test pins the cap's per-secret 'seen'. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The station records a new maker acceptance on every /provision (it can tell neither a stored one's state nor a retry from provisioning again); the Worker bounds that at MAKER_PER_BOX_DAY (10) records a box a day, per FACTORY_TOKEN. A MAKER_MAX_DAYS set up wrong answers 503, the server's fault. The seal refuses a non-factory receipt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RELEASING.md: who may get a record is enforced by /provision answering only on the USB link (the station keeps no flash or seal record by module to check against); the box's agent treats an answer without a well-formed acceptance_id as a failed attempt; the receipt holds method and acceptance_id only; seal and provisioning again said apart. A download whose maker record is gone answers 403, as an acceptance's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RELEASING.md: the station calls /api/factory last, once its answer is built and checked, so a station failure cannot spend a box's records; a fixed URL in the station's config; how to recover a box the seal refuses. The per-box limit answers factory_box_cap. Tests: the secret before the setup checks, and the receipt exactly as the station writes it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RELEASING.md: /provision is limited by an input rule on the USB interfaces, not by its address (the station routes for the factory Wi-Fi); the station sends FACTORY_TOKEN only over https, follows no redirect, and keeps the header off any; the Worker call and the secret stay out of the code baked into boxes; the station stops calling after a 401 or 503 and waits after factory_cap; the first-boot unit started by the agent; an optional IP rule on /api/factory. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RELEASING.md: the first-boot unit needs no start from the agent (its timer tries again after a skipped start; a plain start from the provisioning unit would hang); the station stops calling only on the Worker's own bad_factory_token or factory_misconfigured, not on any 503; FACTORY_TOKEN in a 0600 file, never the environment the bake and flash commands inherit; an interface rule, not SO_BINDTODEVICE, and why; the record names the box image's pin; the receipt written atomically; a User-Agent of the station's own. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RELEASING.md: the record's installer is the pin the box's agent reports (an image_id does not tell bakes apart); an overall deadline on the station's call; the nft rule lets loopback in, names the boxes' interfaces by USB vendor, and serve checks it covers its port; fullmatch for the id; the agent makes /var/lib/teaport; restart serve after a rotation; the station keeps no maker ids in its logs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RELEASING.md: the box has its machine-id at provisioning; the station uses the serial because that is what it knows; the boxes' interfaces get unique names under one prefix by a udev rule (a .link Name= names one interface, and several boxes are attached at once); the agent is to start sending its pin; the answer's new key goes in docs/06; reading the ruleset needs sudo. An absurd MAKER_MAX_DAYS fails closed with 503. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RELEASING.md: the boxes' interfaces named tpbox$attr{ifindex}, unique while the station
runs (%n repeats usb0 and usb1 for every box, so a second box would be dropped); an inet
table; what else names usbN; restart the station after fixing the Worker's settings.
The box's agent, not the station, writes the receipt (comments). The retention cron's
maker deletes are statements of their own.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RELEASING.md: restart the station a minute after a rotation (an edge can answer for the old version that long); a Worker call that succeeds past the station's deadline spends a record. wrangler.toml: what a bad MAKER_MAX_DAYS does to existing records. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t owner's) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the teaport side of #464 (part of #465 / #283): the factory installs the engine on each box as Teaspoon AI, with a per-box maker acceptance, and no shared secret in any image. The station side (teaport-factory) and the owner's acceptance at setup (#465) are not in this PR; RELEASING.md "Worker secrets" sets what teaport-factory has to build.
Draft, stacked on #469 (base
license-installer-no-name, which carries #468): it merges after both, per the agreed order #468 → deploy + 0002 → #469 → this, and is retargeted tomainonce #469 lands.How it works
/provision), the station callsPOST /api/factorywith the station-onlyFACTORY_TOKEN, the box'sdevice_id(SHA-256 ofteaport-appliance:+ its appliance serial) and the installer pin. The Worker records a maker acceptance (maker_acceptances, no name or email: Teaspoon AI installing its own box, no one's acceptance of the license) and returns its id.{"method": "factory", "acceptance_id": "maker-…"}, root 0600.install.shsees the factory receipt and gets download tokens with it through/api/token, whatever the current license version, forMAKER_MAX_DAYSafter provisioning. A factory receipt never counts as an acceptance of any version.install.shfall back to the owner accepting; an explicit--accept-eulaalways wins.Worker
POST /api/factory: rate-limited first, thenFACTORY_TOKEN(constant-time), then misconfiguration (503: a secret under 32 characters or equal toCHECK_TOKEN/TOKEN_KEY; a badFACTORY_DAILY_MAXorMAKER_MAX_DAYS), then the body. Caps:FACTORY_DAILY_MAXboxes a day andMAKER_PER_BOX_DAY(10) records a box a day, both counted perFACTORY_TOKEN(a keyed mark on each row), so a rotation after a leak lets the factory go on at once.maker-+ 24 characters, acceptance ids 24 characters; maker tokens carryk: "maker". Neither is ever taken for the other (tested both ways). A maker token never outlives its record, and every download re-checks the record (revoked, expired, gone), with the gate open or not.FACTORY_TOKENdownloads nothing and gets no token.0003_factory.sqlonly adds a table: the Worker before it still runs, refusing maker tokens and ids (fails closed). Retention deletes maker rows and their downloads like acceptances'.The points #464 asked to think through
FACTORY_TOKEN: records for made-up boxes, each reaching every gated file forMAKER_MAX_DAYS. Brakes: the two caps, the per-IP limit. Detection: the records' IP, country and box. Remedy: rotate (stops new records), and revoke records since the leak. The station's/provisionwould hand out the same records without a leak, so it must answer only on the boxes' USB interfaces. A rollback past a rotation brings the old secret back: RELEASING.md says how to rotate again without redeploying a broken main.dl/engine/anddl/models/only, which is all a maker record reaches.docs/engine-license-data.md, "The factory's rows"): 7 years like acceptances, flagged for counsel (these rows prove no contract). Not personal data when written; thedevice_idhides the serial from nobody (serials follow a date-and-number pattern), so after sale they are the owner's data. Erasure steps added.FACTORY_TOKENis never a GitHub secret or variable, no workflow names it, the tests use a made-up one, andworker-deployleaves Worker secrets alone.Settings (decided by the product owner)
MAKER_MAX_DAYS = "3": how long a provisioned box can download under its maker record before its owner must accept. A factory install takes hours; the seal removes the receipt either way.FACTORY_DAILY_MAX = "50": the most boxes recorded in 24 hours, above the factory's busiest day for now.FACTORY_TOKENon the Worker, and the deploy.Notes
device_provision. In teaport-factory,device_provision.pyis the box's agent and runs at first boot; the flash image is the same for every box. RELEASING.md follows the real flow (the station'shandle_provisioncalls the Worker, the agent writes the receipt). The box does have/etc/machine-idby then; the station uses the serial because that is what it knows./api/factoryin only from the factory's IP; the public licenses page and FAQ once License: the owner accepts the engine license at setup; the factory installs as the maker #465 lands.Tests
--accept-eula, dry run, the exact receipt shape.Reviewed by independent agents until clean (code clean since the first rounds; the later rounds tightened the teaport-factory requirements against its code).
🤖 Generated with Claude Code