oficina / alta Public

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

Plain git — no account needed to clone.

Download

Download this file

1-- Alta's state (team-provisioning-app.md §4). Sealed columns are AEAD
2-- under ALTA_DEK with a per-row purpose; nothing here is an app key, a
3-- CARLOS token, a roster bearer or team content.
4
5-- Every label ever used stays: labels are never reused (Paul, 2026-10-27).
6CREATE TABLE teams (
7 label TEXT PRIMARY KEY,
8 sealed_name BLOB NOT NULL,
9 environment TEXT NOT NULL,
10 forked INTEGER NOT NULL DEFAULT 0 CHECK (forked IN (0, 1)),
11 team_id INTEGER,
12 team_sqid TEXT,
13 epoch INTEGER,
14 generation TEXT,
15 owner_ref TEXT,
16 created_at INTEGER NOT NULL
17) STRICT;
18
19-- An app once in a team stays; a retired app's hostnames are dead for good.
20CREATE TABLE team_apps (
21 label TEXT NOT NULL REFERENCES teams(label),
22 app TEXT NOT NULL,
23 state TEXT NOT NULL CHECK (state IN ('active', 'retired')),
24 PRIMARY KEY (label, app)
25) STRICT;
26
27-- The owner's address, sealed; deleted at step 13 (§4).
28CREATE TABLE owner_inputs (
29 label TEXT PRIMARY KEY REFERENCES teams(label),
30 sealed_address BLOB NOT NULL
31) STRICT;
32
33CREATE TABLE runs (
34 id INTEGER PRIMARY KEY,
35 label TEXT NOT NULL DEFAULT '',
36 kind TEXT NOT NULL CHECK (kind IN ('initialize', 'create-team', 'add-apps', 'retire-apps')),
37 apps TEXT NOT NULL DEFAULT '',
38 plan_id TEXT,
39 plan_expires_at INTEGER,
40 state TEXT NOT NULL CHECK (state IN ('planned', 'running', 'parked', 'done', 'superseded', 'failed')),
41 code TEXT NOT NULL DEFAULT '',
42 created_at INTEGER NOT NULL,
43 updated_at INTEGER NOT NULL
44) STRICT;
45CREATE INDEX runs_label ON runs(label, id);
46
47-- One row per (plan, role). The signed bytes are kept, sealed, only so a
48-- role that answered busy can be retried with the same plan until it
49-- expires; the credential role's carry the owner and go at step 13.
50CREATE TABLE plan_submissions (
51 plan_id TEXT NOT NULL,
52 role TEXT NOT NULL CHECK (role IN ('credential', 'directory')),
53 sealed_plan BLOB,
54 state TEXT NOT NULL CHECK (state IN ('signed', 'pending', 'open', 'closed')),
55 expires_at INTEGER NOT NULL,
56 window_expires_at INTEGER,
57 PRIMARY KEY (plan_id, role)
58) STRICT;
59
60-- The state machine (§6), per team and app ('' for team-level steps), so
61-- a later add-apps run continues where an earlier one parked.
62CREATE TABLE steps (
63 label TEXT NOT NULL,
64 app TEXT NOT NULL,
65 step TEXT NOT NULL,
66 state TEXT NOT NULL CHECK (state IN ('done', 'parked', 'failed')),
67 code TEXT NOT NULL DEFAULT '',
68 data TEXT NOT NULL DEFAULT '{}',
69 updated_at INTEGER NOT NULL,
70 PRIMARY KEY (label, app, step)
71) STRICT;
72
73-- Exact signed request bytes, sealed, so a lost result is recovered by
74-- exact replay (and the roster bearer re-fetched, never stored).
75CREATE TABLE operator_requests (
76 id INTEGER PRIMARY KEY,
77 role TEXT NOT NULL CHECK (role IN ('credential', 'directory')),
78 sequence INTEGER NOT NULL,
79 operation_id TEXT NOT NULL UNIQUE,
80 action TEXT NOT NULL,
81 label TEXT NOT NULL DEFAULT '',
82 app TEXT NOT NULL DEFAULT '',
83 purpose TEXT NOT NULL,
84 head TEXT NOT NULL,
85 sealed_request BLOB NOT NULL,
86 state TEXT NOT NULL CHECK (state IN ('signed', 'committed', 'refused')),
87 expires_at INTEGER NOT NULL,
88 created_at INTEGER NOT NULL
89) STRICT;
90CREATE INDEX operator_requests_purpose ON operator_requests(label, app, purpose, id);
91
92-- Per Home role: the stream position Home will accept next (§5).
93CREATE TABLE operator_streams (
94 role TEXT PRIMARY KEY CHECK (role IN ('credential', 'directory')),
95 sequence INTEGER NOT NULL,
96 head TEXT NOT NULL,
97 updated_at INTEGER NOT NULL
98) STRICT;
99
100-- The environments Alta owns, per its own records (§8's guard).
101CREATE TABLE environments (
102 app TEXT NOT NULL,
103 environment TEXT NOT NULL,
104 label TEXT NOT NULL REFERENCES teams(label),
105 PRIMARY KEY (app, environment)
106) STRICT;
107
108-- The audit: fixed event codes, never an address, key or platform value.
109CREATE TABLE audit (
110 id INTEGER PRIMARY KEY,
111 at INTEGER NOT NULL,
112 run_id INTEGER NOT NULL DEFAULT 0,
113 label TEXT NOT NULL DEFAULT '',
114 app TEXT NOT NULL DEFAULT '',
115 event TEXT NOT NULL,
116 detail TEXT NOT NULL DEFAULT ''
117) STRICT;
118
119-- One run at a time (§8).
120CREATE TABLE run_lock (
121 singleton INTEGER PRIMARY KEY CHECK (singleton = 1),
122 run_id INTEGER NOT NULL,
123 acquired_at INTEGER NOT NULL
124) STRICT;
125
126-- Alta's session idle clock (30 minutes; sessions' TTL is the absolute 12 h).
127CREATE TABLE session_seen (
128 token_hash TEXT PRIMARY KEY,
129 seen_at INTEGER NOT NULL
130) STRICT;
131