oficina / home Public

Clone
git clone https://amadan.net/oficina/home

Plain git — no account needed to clone.

Download

Download this file

1# Operator registry and first team provisioning
2
3> **Superseded in part** by `implementation/team-provisioning-amendment.md` §2 items 1, 2, 3 and 8 (the local `oficina provision` command, "normal HTTP startup does not expose it", registry custody and its floor, and the bounded `HOME_CONSUMERS` registration step).
4
5Status: design approved by configured Claude Fable (`claude-fable-5`, verified
6provider metadata), 2026-09-08, reviewed commit898fe219f4da5092b2cc28210b344ede6a478e50,
7Home discussion37. Implementation and live-use gates below remain. This makes
8`home-operator-seed.md`'s invocation, baseline and activation adapters concrete.
9It adds no live records, keys, configuration or command implementation.
10
11## Operator and authority
12
13Implement a separate local Go command, `oficina provision`, callable directly by
14a human. It uses supported CARLOS APIs/CLI and the fixed Home operator command.
15No LLM, remote shell, SQL console or manual database edit is required. Home keeps
16no platform provisioning credential. The command never serves a website.
17
18The operator authenticates to the existing CARLOS console. Every maintenance
19mutation still requires its actual browser session, CSRF, current account-owner
20lookup and `requireFreshAuth`, in that order. The reviewed maintenance request
21binds its immutable encrypted input and selected artifact/config/instance. The
22local signer cannot bypass that gate. A bearer has no invented auth_time. Source:
23platform dcf0cad `internal/console/stepup.go`, and platform117 revised maintenance
24design (currently 0c59ea2; wire API remains under review).
25
26A separately generated provisioner signing key attests the operator's selected
27installation baseline and collected evidence. Both Home roles pin this public key
28outside the signed request. It is distinct from credential owner-seed signing,
29directory provisioning signing and roster response keys. Compromise of this key
30is operator compromise; its public signature alone cannot execute anything without
31the maintenance fence and fresh console approval. The credential owner receipt
32still resolves the requested owner's identity. The operator cannot submit a
33person_ref in place of that receipt.
34
35The initial baseline is an explicit trusted owner attestation: this installation
36has never issued a roster generation or consumer record. Deployment history,
37current configured versions, and fenced schema inspection inform that decision.
38They cannot mathematically prove historical absence after a possible restore.
39The review screen states this distinction and shows the exact installation and
40baseline digest. If the owner cannot attest it, enrollment refuses and recovery
41requires its separately reviewed procedure. This is the only initial-install
42exception; retries and ordinary startup cannot repeat it.
43
44## Registry custody and persistence
45
46The first supported workflow runs natively on this Linux operator workspace.
47`oficina provision init --state <directory> --floor-dir <independent-directory>`
48requires empty regular directories on persistent local ext4/XFS filesystems,
49mode0700, no symlinks or shared/network filesystem. The floor directory must be
50outside the state directory and its backup scope. Init creates random device and
51registry IDs plus signing/encryption keys, and stores the keys only in an age
52scrypt-encrypted credential file. Unlock through a private TTY prompt or explicit
53private password FD, never an argv/env value. Keys remain in process memory only
54while the command runs. No secret is printed or committed. Initialization writes a signed initializing
55genesis and encrypted key file before creating the registry; an interrupted init
56can resume only that exact genesis after unlocking its keys. It never silently
57replaces an existing key, registry ID or partially created floor.
58
59The independent floor backend writes signed immutable sequence/head files with
60exclusive creation, file fsync and parent-directory fsync; a durable head marker
61is updated by rename under the process lock only after the immutable file is
62complete. It stores no secret and never appears inside a registry backup. Bind
63registry/device IDs and signer public-key fingerprint in the credential file,
64registry and floor genesis. Missing or mismatched identity refuses. On open, validate all bounded immutable
65floor records and their contiguous signed chain, not only the replaceable head
66marker; an old marker cannot hide a newer completed floor file. Linux filesystem
67semantics are tested directly with process/crash injection on a supported local
68filesystem; an in-memory backend is insufficient. Unsupported filesystem types
69refuse. Copying only state or rolling back its encrypted keys cannot roll back the
70independent floor. A disk failure losing both is an unrecoverable condition in this
71slice, not permission to initialize again.
72
73An optional macOS backend can use pinned
74[github.com/keybase/go-keychain v0.0.1](https://github.com/keybase/go-keychain/tree/v0.0.1)
75through native Security-framework calls. It must satisfy the identical floor
76contract before being supported; this is not a prerequisite for the Linux pilot.
77Home itself remains CGO_ENABLED=0. No secret-bearing security-command argv or
78plaintext-key fallback exists. Keys and floor identity are bound to one operator
79device. Copying them to a second device is not a supported concurrent writer.
80
81Use a dedicated local SQLite registry outside Home's database, deployment directory
82and backup schedule. Acquire an exclusive process lock for the entire operation.
83SQLite uses one writer connection, foreign_keys ON, secure_delete ON and synchronous
84FULL. Schema includes registry identity/version; installations keyed by exact
85console/account/app/primary host; immutable operation records; encrypted private
86inputs/results; and evidence records. Every installation has one current sequence,
87head digest, enrolled directory identity, baseline operation and current generation.
88Only the provisioner command writes these rows.
89
90Every record carries registry/device ID, installation ID, monotonically increasing
91sequence, previous record digest, random operation ID, fixed action, expected state,
92created time and digest of randomized sealed private payload. Sign the canonical
93closed record with Rastrillo crypto.Sign context `oficina/provisioner/record/v1`.
94Write the immutable signed record and ciphertext with the installation's new head
95in one transaction using sequence+head CAS. No update/delete API exists for records.
96A reused operation ID with identical typed request returns its stored record/result;
97changed input refuses. Retain 10,000 operations per registry and refuse new work at
98capacity until a reviewed archive policy exists. Advance state before dispatch,
99then append outcome evidence after receiving the exact private result. An ambiguous
100remote result leaves an in-flight journal record; it never causes an automatic
101second Home operation.
102
103The independent floor backend holds the latest registry sequence and signed head
104digest outside the registry backup scope. A new head follows a two-phase local protocol: commit a signed
105prepared record with old/new floor to SQLite and fsync; CAS the independent floor from
106old to new; commit finalized state and checkpoint/fsync the parent directory. Before
107any remote dispatch, require finalized matching floor. Crash between steps resumes
108only the single matching prepared record. Floor ahead without the exact prepared
109record, DB ahead without a valid adjacent preparation, competing device or any
110older/mismatched head refuses. No sequence reuse follows a failed write. The floor
111CAS primitive may be serialized by the exclusive device lock; re-read before write
112and refuse unexpected values. A floor backend without durable update semantics
113is unsupported. Tests inject crashes at every boundary.
114
115`oficina provision backup --output <exclusive-file>` exports encrypted registry
116records, private payloads and wrapped recovery keys through a password-protected
117standard age container using pinned
118[filippo.io/age v1.3.2](https://github.com/FiloSottile/age/tree/v1.3.2)
119and its scrypt recipient/identity APIs. No custom password encryption is introduced.
120Use mode0600 and atomic fsync/rename. Print only the archive digest and sequence.
121Require independent backup storage selected by the operator and a verified restore
122drill before enrolling a non-synthetic installation. Never include a plaintext key
123or decrypted owner address. A lost local registry does not make init available for
124the same surviving floor identity. A restored archive must meet the surviving independent
125floor and verify every signature/hash-chain entry; an older archive refuses. If both
126registry and independent floor are lost, this slice cannot recover or re-enroll;
127explicit recovery design and fresh owner confirmation are required. Export/import
128must be human-usable commands and carry no secrets through argv, terminal or shell
129history. Passphrases use a private terminal prompt or file descriptor.
130
131The separate durable floor protects against registry-backup rollback, not an
132attacker controlling the operator device and unlocked signing keys. Copying the
133registry and floor together and rolling both back is excluded from safe restore; document this and test
134the refusal achievable with a surviving floor. Production recovery readiness still
135requires the independent backup/restore rehearsal, not merely a second database.
136
137## Signed private operation contract
138
139The Home command receives one closed private JSON body of at most64KiB:
140`{version:1, signed_authorization, operation_input}`. signed_authorization is a
141closed signature envelope capped at16KiB; operation_input is bounded canonical
142JSON capped at48KiB and also subject to the64KiB total. Its exact typed encoding
143is reused for digest and dispatch; alternate encodings, duplicate/unknown fields
144and trailing JSON refuse. The existing operator operation fields live inside
145operation_input. The signed authorization binds SHA256 of those exact canonical
146bytes plus role, exact configured origin, installation ID, registry/device ID,
147per-role sequence, previous authorization head, operation ID, issued/expires times
148and purpose. The local journal's global sequence is bound as a reference as well.
149The platform encrypts this body for its worker through its approved private input
150protocol, decrypts there and supplies it on private stdin. Home-specific code does
151not parse the platform envelope or assume it can decrypt platform-held material.
152The public journal stores only a digest of randomized ciphertext; the signature
153with a potentially guessable plaintext digest stays inside encrypted private input.
154The Home command receives no registry decryption key.
155
156Sign authorization using context `oficina/home/operator-input/v1`, with duration
157at most300 seconds and exact fixed operation allowlist. Each Home role validates
158the pinned public key, envelope bounds, exact origin/role, receipt clock and typed
159request digest before constructing its unexported operator context. Persist the
160accepted registry identity, device identity, per-role sequence and head in its own
161operator schema with the operation result. Require sequence exactly previous+1,
162correct previous head, or exact already-committed replay. Each role has its own
163ordered authorization stream because credential and directory actions interleave;
164the outer journal's global sequence remains independent. Do not advance the
165per-role accepted stream when merely preparing a request. A refused/expired request
166gets an immutable outcome in the global journal, while the next per-role slot stays
167unaccepted. A replacement authorization for that slot requires proof the old
168attempt is not running and its authorization has expired; otherwise the provisioner
169waits/refuses. An ambiguous attempt must be reconciled, never replaced. Successful
170Home acceptance updates its stream and result in the same transaction. A lost accepted operation
171result is recovered by replay of the same signed authorization, which may return an
172already-committed result after expiry but cannot perform a new mutation.
173
174Read-only inspect has no accepted-stream mutation: it validates a separately
175signed inspect challenge bound to role/origin and expiry, returns challenge plus
176observation time with the state, and never advances authority or mints a seed.
177The private platform result channel binds that observation to the exact attempt.
178It cannot initialize an absent authority stream or be submitted as owner proof.
179
180Initial trust enrollment pins registry/device identity and operator public key
181through the reviewed per-instance protected configuration, preserving all existing
182keys. A changed pinned identity/key does not reset stored sequence/head. The first
183operation requires a create-only expected-empty operator authority table and a
184signed baseline, approved through the same fresh console gate. Thereafter absent
185operator state alongside an existing baseline/generation is a refusal. Provisioner
186and Home pin both key ID and exact encoded public key; no trust-on-first-request.
187
188The platform supplies only its accepted maintenance execution boundary. Home
189validates the private signed authorization itself; it needs no invented signed
190platform receipt. The fixed operator entry point is enabled only for maintenance
191execution of the immutable configured release. Normal HTTP startup does not expose
192it. Tests must prove direct app requests cannot invoke it.
193
194## Installation and evidence sequence
195
196`oficina provision enroll` prepares a human-readable baseline plan and immutable
197private request. It identifies existing credential/directory primary hosts,
198canonical origins, account, existing data-key fingerprints, operator public pins,
199exact release/artifact and checked configuration bindings plus registry identity. Use supported
200`carlos instances list`, route/version checks and maintenance preflight;
201restart's asleep output is not exec eligibility proof. The operator's fresh approval
202is required on the console's exact request. Existing Home databases and identities
203are retained. No credential sign-in is fabricated for the owner.
204
2051. Apply reviewed additive operator/roster schemas using a normal verified release,
206 preserving role boundaries. Load separately generated operator keys through
207 protected per-instance configuration. Verify actual host version in both body
208 and X-Carlos-Version before maintenance; record response digests and time.
2092. Fenced directory inspect confirms exact DB/schema/role/config and no generation
210 or consumer history. The external signed baseline binds this observation and the
211 owner's never-provisioned attestation. Generate a random32-byte generation in
212 the registry and include it in the signed initialize request. Directory persists
213 that exact authorized generation once; it does not substitute another random value.
2143. Obtain the proposed team integer/sqid through inspect. Collect an approved sealed
215 queue request, decrypt locally only in bounded private memory, and bind its approval
216 to the operation. The synthetic pilot instead uses an explicit operator-authored
217 synthetic plan containing already-authenticated synthetic addresses and labels,
218 signed in this same journal and approved through the same fresh console gate;
219 this creates no fake queue row or alternate Home identity authority. For synthetic previews require the already-authenticated synthetic
220 identity and existing_only credential resolution. Fresh console approval runs
221 credential.owner-seed; its private signed receipt is encrypted into the journal.
2224. Submit directory.seed-team with that receipt, exact proposed ID, reserved label,
223 sealed-input display name and generation. A raced proposal or expired receipt
224 requires a new explicit plan/approval. A receipt cannot seed a sibling team's owner.
2255. Create an isolated Docs platform instance through existing supported instance APIs,
226 with a distinct DB namespace, instance/content/DEK keys, per-instance environment
227 and consumer ID. Never clone existing Home/Docs keys or documents. Attach the exact
228 canonical team alias using `carlos domains attach --app ... --route ...`; verify
229 the returned current domain binding, primary route and environment.
2306. Register the exact consumer with credential Home by updating its bounded immutable
231 HOME_CONSUMERS manifest through protected environment configuration. Preserve every
232 existing registration and all current assertion keys. Read back the public manifest and protected configuration delivery result,
233 then use the fixed credential compatibility checker under the maintenance
234 environment binding to verify the active manifest digest and public key
235 fingerprints. Verify the actual restarted credential host version. Its normal
236 GET /authorize validation can confirm that this consumer/audience pair reaches the
237 expected sign-in flow without sending mail; it cannot alone prove key custody.
238 Current source allows16 entries/8192bytes and requires directory registration;
239 stop at the bound. Scalable registration is separate work.
2407. Provision the pending directory consumer. Verify its returned signed record using
241 the independent pinned directory operator public key. Install the exact record and
242 private bearer into the isolated Docs config using supported protected delivery.
243 The local journal records ciphertext digests and the checked maintenance
244 environment binding, never secret values in public receipts.
2458. Collect activation evidence and publish only through the approved activation rule
246 below. Verify completed two-team browser acceptance using real synthetic identities
247 and actual Home credential authentication; no pre-minted session is live evidence.
248
249Evidence is collected by typed adapters, not CLI sentence parsing: use the supported
250console/domain/instance/version response structs or add a reviewed JSON CLI output
251for a currently text-only command. Source platform dcf0cad `instances_cli.go`,
252`domains_cli.go`, `cli.go:routeVersionCheck`, `internal/console/apicli.go`; Home171
253`internal/home/runtime.go` HOME_CONSUMERS validation and `exchange.go` authorization
254validation. Current domain responses distinguish derived State from legacy Status: require
255State=live (not merely Status=live), then verify actual TLS/version. Domain claim
256alone does not prove materialized TLS. Current configGet has no revision field and
257never returns secret values; absence is not a successful secret/config comparison.
258Use maintenance's immutable protected environment binding and a fixed non-serving
259application compatibility checker against that snapshot. The Home checker reports
260only exact origins, active public operator/assertion/roster key fingerprints and
261consumer-manifest digest. The Docs checker reports exact TeamMode bindings, verified
262provisioning record digest, generation and SHA256 of the canonical bearer already
263present in protected config. These are bounded private results, never public logs.
264Checkers make no network calls, mint no sessions and change no DB/key/authority.
265They require separate small implementation/review slices; no current API is claimed
266to supply these application-specific facts. Existing secret fingerprints are compared
267privately to enrolled fingerprints, without copying existing private keys out. Dial only configured
268canonical HTTPS hosts with normal certificate validation, no redirects unless the
269specific sign-in probe validates every expected hop. Compare full expected version
270in body/header and current platform route/alias mapping. Store bounded response
271digests, typed binding facts and timestamps in the encrypted signed journal; token,
272email, assertion and unrelated response content are never retained in evidence.
273
274## Activation gate and pending roster integration
275
276An activation authorization signs exact consumer/team/app/audience, generation,
277record sequence/digest, deployed release/artifact digest, checked maintenance environment binding,
278credential registration digest, materialized alias binding, verification
279start/end time and the versioned acceptance policy. The local provisioner only emits
280it after its typed collectors pass. It is bounded to16KiB, expires within300 seconds,
281and is approved in the fresh console maintenance request. The Home command verifies
282this signed authorization and current stored bindings again before switching live;
283it never trusts a request's boolean or opaque reference as evidence.
284
285There is an ordering conflict to resolve explicitly: current roster producer32fb
286serves only live team_instances, but a real TeamMode startup/read needs a roster
287before its instance can be accepted for live entry. Proposed narrow amendment for
288review: add a separate directory-only consumer verification-window table with
289consumer primary key/FK, expiry and audited opening operation. Verification and
290activation audit/history rows use new additive tables; preserve the existing
291roster_operator_receipts CHECK enum unchanged. A signed operator
292`verify-consumer` operation may grant one pending binding at most600 seconds of
293roster reads, using an absolute issued_at/expires_at signed into its authorization.
294This grants actual app standing to that team's membership holders through its
295exact consumer; it is not merely a read-only probe. It grants no item permissions. The producer still validates its exact enabled bearer/registry/route
296and generation; it additionally accepts pending only while this audited window is
297current. The chooser remains live-only. No browser assertion or consumer request
298can open/extend the window. Only the exact enabled consumer's current/approved
299overlap bearer and exact team/app/origin receive these signed pages. Other pending
300bindings, siblings and anonymous requests remain refused. The stored expiry is
301immutable; failure, read, retry and exact replay cannot extend it. Consumer disable
302or expiry stops subsequent pending roster reads; existing client leases retain
303their already-approved60-second ceiling from the last successful fetch start.
304Tests measure that ceiling for silent SSE and protected commits as well as requests. The activation operation clears the
305window atomically with live state. A failed verification leaves the instance pending;
306a distinct deliberately approved verification attempt needs a new signed/fresh-
307approved operation and audit record, and cannot overwrite the old window/history.
308Opening while an earlier attempt is active refuses. Completed activation is
309idempotent by operation ID/digest; later verification attempts for a live binding
310refuse. Retain opening, expiry and activation outcome records after clearing the
311active window. Activation compares the accepted verification attempt, exact epoch,
312current owner membership and evidence digest under its transaction lock; a changed
313epoch/owner requires new evidence and approval.
314
315This amendment changes the approved producer contract and requires explicit Fable
316approval before implementation. No pending read exception is implied by approval of
317the core operator package alone. It enables actual two-team authentication/standing
318and isolation checks without listing unaccepted instances in the chooser. Initial
319pilot teams contain only the specifically authenticated synthetic owners. Their
320canary browser evidence does not claim general production or restore readiness.
321
322## Failure and acceptance
323
324Every step records its intent before dispatch and its exact result before preparing
325the next step. Resume inspects the journal and supported maintenance status; it never
326infers success from a timeout or deletes an ambiguous record. Cross-role operations
327are not one database transaction: a credential stub or pending team can remain after
328a later failure. The journal identifies it, and only the exact reviewed retry can
329continue. Automatic compensating deletion is prohibited.
330
331Tests cover fresh-owner refusal/removal; wrong signer/role/origin/digest; cross-role
332stream confusion; replay after expiry versus new action after expiry; floor/DB
333crashes; stale backups; lost floor/registry; concurrent processes/devices;
334create-only baseline and initial generation; exact protected config/alias/version
335mismatch; pending verification expiry; wrong team/token; activation replay and
336membership/owner changes between observation and commit. Run an actual human-usable
337synthetic CLI rehearsal, registry export/restore at the current floor and stale-copy
338refusal, then actual supported platform maintenance canary. The eventual operator runbook must bound each deliberate Home maintenance outage;
339credential Home downtime prevents suite sign-in. All source changes need
340normal full gates, Fable whole-code review and verified canary before merge/deploy.
341