oficina / home Public

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

Plain git — no account needed to clone.

Download

Download this file

1# Local Home operator seed and provisioning
2
3> **Superseded in part** by `implementation/team-provisioning-amendment.md` §2 items 4, 5 and 6 (platform 117's fence and "no HTTP server", authorization outside the request, and the activation attestation, which is weakened).
4
5Status: design approved by configured Claude Fable (`claude-fable-5`, provider
6event metadata verified), 2026-09-08, exact reviewed commit
7898fe219f4da5092b2cc28210b344ede6a478e50. Home discussion 37 retains the verdict
8and earlier quota/permission refusals. This branch starts at directory runtime171.
9It defines an application package and local command protocol; the companion
10`home-provisioner.md` defines the authority adapters and staging proposal. No
11implementation, platform117 or live provisioning approval is implied.
12
13## Contracts and scope
14
15The governing sources are Home spec §7, §10, §14 and rulings 8, 22 and 23 in
16`docs/superpowers/specs/2026-08-30-home-design.md`; approved directory design
17fa64e286990762aecc6913bb9076a3cb75b088c3, `implementation/team-directory.md`
18(Home discussion 24); approved roster contract 4e7b3ff,
19`implementation/roster-contract.md` (discussion 28); and approved producer
2032fb49c1d5a4f0317b7291f441f78e21b7f0a11c,
21`implementation/roster-producer-storage.md` and
22`internal/home/directorydata/roster_migrations/migrations/0001_roster.sql`
23(discussion 33; use the migration embedded by RosterSchema if its filename
24changes). Shared roster 667dc8218dd5 supplies Provisioning, SignProvisioning and
25VerifyProvisioning. HTTP runtime design 5fbfdf0 is a separate integration review,
26not authority for this writer. Home discussion 35 records the source audit.
27
28The credential role alone resolves an address with its pepper. The directory
29alone creates teams and memberships. An audited operator selects an approved
30sealed request and its intended owner; a browser assertion, a visitor, an
31instance bearer and the platform account owner alone supply no team-owner
32identity proof. The operator transport authenticates the operator's authority to
33run an approved action on this exact deployment. The credential receipt below
34binds the intended owner across roles. This preserves the operator seed exception
35in §14; it does not assert that provisioning is a browser fresh-owner ceremony.
36
37This slice supports generation initialization when no generation or consumer
38exists, a new team with its first owner, initial consumer provisioning and
39activation. It provides no roster editing, token rotation, restore, owner
40confirmation, key rotation, sibling owner seeding or ownership transfer command.
41Those require their own reviewed operation and fresh-owner rules. In particular,
42missing generation alongside existing consumers is a refusal, never a repair.
43
44## Transport and command boundary
45
46Platform discussion 117 owns stopping traffic and all background work, holding
47the database lease, selecting the immutable executable and exact database, and
48resuming safely. Its private-input/result protocol is generic. The proposed
49entry point is `home operator-v1 --db <platform-selected-existing-db>`, with
50standard output captured as the private result by the transport. The fixed command and
51role permissions belong to reviewed deployment configuration. No request chooses
52a binary, path, SQL, environment variable, shell fragment or network destination.
53The command never starts an HTTP server, sends mail or makes network calls.
54
55Read one UTF-8 JSON object from private stdin with a 64 KiB hard limit including
56whitespace, then require EOF. Write one JSON result of at most 64 KiB to the
57private standard-output channel only, after transaction commit. The transport
58never tees or logs stdout and discards stderr. Input and result
59are encrypted at rest by the transport, available only through its authenticated
60private result channel, and never included in public status, receipts or logs.
61The application does not implement its own remote encryption protocol.
62
63Within the signed private wrapper defined in home-provisioner.md, operation-input
64common fields are `version:1`, `operation`, and `operation_id` (random
65canonical 32-byte base64url). Operation-specific closed objects are specified
66below. Reject unknown or duplicate fields, trailing JSON, alternate numeric
67forms, invalid UTF-8, malformed canonical base64 and oversized decoded values
68before mutation. Strings are bounded before allocating their decoded contents.
69No error includes supplied values. Exit 0 means a complete committed result is
70available; exit 2 is fixed refusal and exit 3 unavailable/ambiguous. Neither exit
71code permits automatic mutation retry. The platform queries the original result
72or explicitly reruns the exact input under a fresh fence; Home idempotency then
73returns the committed result without performing the action again.
74
75The invocation must be authorized outside the request. The local adapter accepts
76an immutable operation allowlist and expected role/origin/database identity from
77reviewed launch configuration. A request's `operation` only selects within that
78allowlist. Package constructors are private to the command adapter or receive an
79opaque validated operator context; exported structs cannot fabricate that context.
80The transport's operation ID is distinct from Home operation_id. Both must be
81bound by the adapter's verified invocation context. Current platform source has
82no signed Home invocation receipt, and this design does not assert otherwise. No body field can claim an
83operator identity or maintenance state. The platform must provide an authenticated
84invocation context or equivalent private launch configuration before command
85wiring is approved; an environment boolean supplied by the caller is insufficient.
86
87## Keys and durable private results
88
89Use the existing Rastrillo family key encoding and crypto.Sign/Verify operations,
90with strict canonical key decoding and derived key IDs. Reuse shared seal for
91stored private envelopes. Do not copy signing arithmetic or browser assertion
92validation to create operator authority.
93
94Credential operator signing uses a separately provisioned private key and context
95`oficina/home/owner-seed/v1`; the directory pins its public key outside every
96receipt. Directory provisioning signing uses its separately provisioned operator
97key and shared context `oficina/roster/provisioning/v1`. Roster response keys are
98also distinct. Keys arrive through the existing protected per-instance config
99mechanism; runtime browser assertion keys and existing data keys remain unchanged.
100Ordinary startup neither creates nor rotates any of these keys. Reject identical
101public keys across the roles within the command's configured material. Public
102key pin replacement is an explicit future operator migration, not an input field.
103
104Add role-specific operator result tables through additive migrations. Credential
105and directory databases never receive each other's tables. Each result row has
106operation_id primary key, fixed action, opaque operator reference from verified
107invocation context, creation time, a keyed request digest, and a sealed result.
108The request digest is HMAC-SHA256 using an independently provisioned 32-byte
109idempotency key. The actual shared sealer exposes Seal/Open, not a key derivation
110API. No custom KDF is introduced. Digest canonical typed operation input, not raw JSON whitespace.
111This prevents a stored bare address/name digest becoming an offline dictionary.
112
113Seal result bytes with the existing role sealer and purpose
114`operator.result/v1/<exact-origin>/<operation-id>/<action>`. A result can contain
115an authority-bearing receipt or bearer and therefore never appears plaintext in
116SQLite/WAL, logs or public receipts. Never persist the original address/input.
117Repeated exact input under the same operation ID returns the stored result;
118changed semantic input or different action refuses. A lost post-commit response
119therefore does not mint a new bearer, person or receipt. Keep successful result
120rows until an explicit reviewed retention policy exists; no rolling cleanup may
121make an old operation reusable. This initial low-volume administrative table has
122a hard 10,000-operation limit, refusing further new operations at capacity.
123
124The existing roster_operator_receipts table retains its approved public metadata
125shape and SHA256 digest of the signed provisioning record; no bearer, display
126name, input digest containing address material or private result belongs there.
127The new directory result row and that receipt commit in the same transaction.
128Private results are bounded to 48 KiB before sealing, leaving transport space.
129
130## Operations
131
132All origins come from validated configuration or must equal it exactly. Production
133team destinations reuse the compiled registry and canonical label policy from
134`directoryFeatures` and `directorydata.Config.ValidateRoute`; for Docs the origin
135is `https://<label>.docs.oficina.works`. Reject alternate ports, paths, aliases,
136userinfo, fragments, queries and unapproved app slugs. This design adds no pilot
137manifest or per-team config exception.
138
139`directory.inspect` accepts no payload and returns only current generation (or
140explicit absent), the next proposed team integer, and derived team sqid. It writes
141no authority and is not a reservation. Derive next ID from the maximum existing
142team ID and sqlite_sequence, then add one, refusing signed-64-bit overflow. No
143shared Home/suite codec exists today. Pin official github.com/sqids/sqids-go
144v0.4.1 (upstream commit 2ba95c7920dcf08340e099c7b22beb1178da6106), using
145sqids.New() and that version's fixed default alphabet, blocklist and zero minimum
146length. Encode exactly one positive integer. Require Decode to return exactly
147one integer in 1..MaxInt64 and Encode(decoded) to equal the original string.
148This preserves the integer-encoding sqid required by §10; Docs' random document
149IDs are unrelated. Golden vectors are 1=Uk, 2=gb, 3=Ef, 1000=pnd and
150MaxInt64=AqkYhRmbHpEX. Refuse zero, negative/multiple numbers, alternate encodings
151and reserved DNS labels independently. Dependency/options changes require explicit
152compatibility review and must preserve existing team sqids. The upstream
153[canonical encoding guidance](https://github.com/sqids/sqids-go/tree/v0.4.1)
154requires re-encoding; a disposable local pinned-library probe verified these vectors.
155The seed checks this proposal again under the write lock. A concurrent seed makes
156the old proposal fail; the operator obtains a new proposal and new owner receipt.
157
158`credential.owner-seed` accepts `directory`, `team_id`, `team_sqid`, and a private
159`address` bounded to 320 UTF-8 bytes from the operator-approved decrypted queue
160request. The address is transported privately into credential Home; queue
161unsealing and request approval remain the external drain's duty. The command
162normalizes and blind-indexes with the same credential helper as sign-in, resolves
163or creates the normal opaque person stub, and never mints a session. Synthetic
164live previews require already authenticated synthetic identities and an
165`existing_only:true` mode; that mode refuses a missing person and sends no mail.
166The directory cannot request address resolution over HTTP. Refactor the existing
167findOrMintPerson SQL into a transaction-capable internal helper: its current
168a.db.Writer() call cannot participate in the required operator transaction.
169Keep sign-in semantics, blindIndex and day-coarsened created_at unchanged.
170
171The result is `{version:1, operation_id, outcome:"committed", receipt}`. receipt
172uses the shared closed `{v,kid,payload,signature}` envelope pattern with canonical
173base64url bytes and raw 64-byte signature, at most 8 KiB total. Its signed payload
174contains version, purpose="owner-seed", operation_id, credential issuer, intended
175directory, proposed integer team ID and sqid, resolved person_ref, role="owner",
176issued_at and expires_at. Duration is at most 300 seconds. The credential operation
177and result are atomic with person-stub creation. Retry returns identical signed
178bytes, even after expiry; it never renews authority. An expired receipt requires
179a newly approved operation ID. The payload contains no address or team name.
180
181`directory.initialize` accepts `expected_generation:null`. Inside its transaction
182require no generation, no roster consumers, no roster tokens and no previous
183bootstrap receipt; existing teams/memberships may be retained. Accept the exact random32-byte canonical base64url generation from the verified
184external baseline record, persist it once and a bootstrap receipt
185plus sealed result atomically. Require explicit deployment precondition that no
186consumer has ever been provisioned; a database which has lost generation/receipt
187history cannot satisfy this precondition based on its own empty tables. An independently
188signed external installation record and its monotonic registry floor must attest
189that this exact directory database has never had a roster generation provisioned.
190The record issuer, signature verification and durable external registry are not
191implemented by current Home or platform. The proposed companion home-provisioner.md
192defines them and the explicit trusted fresh-owner baseline attestation; that
193amendment requires approval before constructing initial-install authority. Platform
194maintenance provides exclusion, not this Home-specific historical evidence. If
195that evidence is unavailable, initialization is unavailable. Restore cannot use
196this verb. Ordinary boot only applies empty schema and never invokes it.
197
198`directory.seed-team` accepts `expected_generation`, proposed `team_id` and
199`team_sqid`, canonical `label`, `display_name` (1..255 UTF-8 bytes), and the owner
200`receipt` (at most 8 KiB). Check receipt signature, configured issuer/directory,
201exact team proposal, fixed owner role, canonical person ref, valid issue time and
202five-minute expiry. Verify time again under the write lock. Persist the consumed
203credential receipt operation ID under a unique constraint in this same transaction.
204Expired or malformed input makes no change. A committed exact replay returns its
205stored result despite receipt expiry; changed input under either consumed owner
206receipt or directory operation refuses. Distinct directory operation IDs cannot
207reuse the same owner receipt.
208
209Require generation equality, absent team/label and unchanged next ID. Allocate
210using AUTOINCREMENT, verify the returned integer and corresponding sqid, seal name
211under the existing ID-bound helper, insert exactly the receipt's person as first
212owner, and persist result plus consumed-receipt metadata atomically. No unsealed
213placeholder is written; an encrypted placeholder of the existing test/store shape
214may only exist within the transaction before the final seal. Membership triggers
215advance epoch; do not add a second increment. Return opaque team/sqid, generation
216and resulting epoch. No team_instances row is live at this point.
217
218`directory.provision-consumer` accepts expected generation, team sqid, app slug,
219consumer ID (1..64 ASCII letters/digits/_/-), exact expected audience and expected
220sequence 0 for this initial-only operation. Require an existing team with an owner,
221no existing binding for team/app, no consumer ID/origin collision and exact compiled
222route. Insert pending team_instance, enabled consumer, current token hash and
223successful provisioning receipt in one transaction. Generate a random 32-byte
224canonical bearer; store only SHA256 of its exact 43-character string in token rows.
225The signed shared Provisioning has sequence 1, all configured bindings, current
226generation, actual epoch and configured roster public keys (1..8); owner_confirmation
227is empty for this initial generation. Verify the produced record against the
228independently pinned directory operator public key before commit. Seal the private
229result containing `{record, bearer}` for exact retries. Pending bindings do not
230serve roster pages or appear in the chooser. No content key is copied or generated
231by Home. The external provisioner creates the isolated Docs DB and its own keys.
232
233`directory.activate-consumer` accepts expected generation, consumer ID, expected
234record sequence/digest, and an opaque deployment verification operation reference.
235The verified operator context must attest successful exact-host/body/header build
236verification, assertion registration, isolated instance database/config, and the
237reviewed TeamMode acceptance gates. A string supplied by the request is not that
238attestation. Requery pending binding, consumer enabled state, token, generation and
239record metadata, then switch only that existing pending binding to live and commit
240its audit/result atomically. This package verifies an opaque approved activation
241context; it does not fetch a URL or trust arbitrary deployment evidence JSON.
242Current platform receipts do not attest all these Home-specific facts. The
243external provisioner/verification adapter and its pinned evidence verifier require
244the companion home-provisioner.md authority design and approval; no constructor may accept caller-controlled
245booleans as a substitute. Until that adapter exists, activation remains unwired. A compatibility account-link preview is not sufficient for activation.
246
247## Transaction and existing-database checks
248
249Open an existing regular database with creation disabled, through the pinned
250platform path. Check application identity, expected role/origin, migration ledger
251and required additive schema versions before any action. Never call the general
252web startup migrator to repair an unexpected DB from this command. The deployment
253applies reviewed role-specific additive migrations before operator execution.
254
255Acquire one dedicated database/sql connection. Set foreign_keys ON before beginning
256and read it back as 1 on that exact connection; pooled connections cannot substitute
257for this check. Also require secure_delete ON, expected journal configuration,
258no foreign_key_check violations, and the verified transport fence/lease. Take an
259immediate write transaction with a bounded lock timeout; all idempotency, generation,
260sequence, owner receipt and registry preconditions are rechecked inside it. Do not
261perform network work while holding the lock. Refuse wrong clocks, time rollback
262relative to persisted operator completion time, exhausted counters or corrupt rows.
263Write all related authority and audit rows together. Close/checkpoint through the
264supported transport protocol before resume; an uncertain commit remains fenced
265until querying the same operation establishes its outcome.
266
267No success path changes existing sessions, assertion keys, content encryption,
268existing team/member rows or unrelated consumers. Rollback leaves no orphaned team,
269owner, token, receipt or result. Read-only inspect has no minting side effect.
270
271## Review and acceptance
272
273Implement narrow package tests before a command adapter. Exercise actual additive
274schemas and sealer, signed owner receipts, actual shared provisioning verification,
275and real credential normalization/blind indexing. Require meaningful failures for
276FK off on the actual connection, wrong DB/role/origin, missing fence context, forged
277operator context, unknown key/purpose, browser assertion substitution, stale and
278future receipts, receipt reuse, raced integer proposal, changed-payload retry,
279commit/output loss, name-seal failure, generation mismatch, false initial install,
280consumer collision, roster epoch overflow and transaction rollback.
281
282Extend gate 2's expensive privacy half when this seed verb lands, as required
283by the Home spec. Scan SQLite, WAL, captured stdout/stderr and public receipt serialization for known
284synthetic addresses, names, bearer strings, receipt payloads and private results.
285Prove current Home session acceptance/signout and all existing team ciphertexts
286survive applying the additive tables. Mutation tests must fail when signature,
287consumed-receipt uniqueness, FK verification or idempotency checks are removed.
288Demonstrate the private-stdout command with a disposable local fence fixture only; that
289fixture is not evidence of platform maintenance correctness. Full repo gates, exact
290CI and Fable whole-code review precede integration. Live use additionally requires
291approved/shipped platform 117, operator authority and invocation/activation context
292adapters, actual two-team TeamMode acceptance and canary verification.
293