oficina / equipo Public

Install identity lifecycle triggers after their boot dependencies

codex agent, operated by paul@keymail.dev pushed by paul@keymail.dev 91f9f8aaf9eb63b2eed515cfb7f8d1f74106bf3c parent fba289e
6 files changed, +34 −38
  • .rastrillo/budgets.txt +1 −1
  • internal/equipo/migrations.go +2 −1
  • internal/equipo/migrations/0082_oficina_id.sql +0 −18
  • internal/equipo/migrations/schema.sql +0 −18
  • internal/equipo/oficinaid/migrations.go +13 −0
  • internal/equipo/oficinaid/migrations/0001_lifecycle.sql +18 −0

CI cancelled — superseded by a newer push — run details

diff --git a/.rastrillo/budgets.txt b/.rastrillo/budgets.txt
index dcb7c3d3..71f9ea30 100644
--- a/.rastrillo/budgets.txt
+++ b/.rastrillo/budgets.txt
@@ -14,7 +14,7 @@ perf GET /* skip Unknown private paths render 404; this fallback contains no scr
time internal/equipo/team 60s Plan 3 loaded CI measured 45.985s; niced serial reruns measured 18.079s and 22.031s. Keep migration, recovery, accounting and concurrency assertions; 60s leaves 30 percent headroom above loaded CI.
time internal/equipotest 300s Final fix package rerun measured 187.035s (review 172.4s); 300s gives 60 percent headroom for HTTP, sandbox, authority and final regression coverage.
-size internal/equipo 19712 - Web handlers and runtime copy, including Oficina ID route wiring and reviewed strings. Identity storage and HTTP flow live in internal/equipo/oficinaid.
+size internal/equipo 19713 - Web handlers and runtime copy, including Oficina ID route wiring and reviewed strings. Identity storage and HTTP flow live in internal/equipo/oficinaid.
size internal/wire 6097 - Protocol 21 Copy dispatch, result, task flags and downgrade fields share Encode.
size internal/equipotest - 13400 Task 21 repairs historical migration and conversation fixtures after Plan 3. Measured 13024 test lines; the 300s time ceiling is unchanged.
time internal/runner/checks 90s CI worker measured 44.553s (44.6s rounded);
diff --git a/internal/equipo/migrations.go b/internal/equipo/migrations.go
index 3de6c0c2..6dc86e1f 100644
--- a/internal/equipo/migrations.go
+++ b/internal/equipo/migrations.go
@@ -1,6 +1,7 @@
package equipo
import (
+ "amadan.net/oficina/equipo/internal/equipo/oficinaid"
"amadan.net/oficina/home/connect/linkstore"
"amadan.net/oficina/home/handoff"
"embed"
@@ -17,4 +18,4 @@ var migrationFS embed.FS
// Schema contains only app tables, so migration check can compare Models.
var Schema = migrate.MustFromFS(migrationFS, "equipo")
-var BootSchema = migrate.Merge(sessions.Schema, auth.Schema, pow.Schema, migrate.MustFromFS(handoff.Migrations, "oficina_handoff"), migrate.MustFromFS(linkstore.Migrations, linkstore.SchemaNamespace), Schema)
+var BootSchema = migrate.Merge(sessions.Schema, auth.Schema, pow.Schema, migrate.MustFromFS(handoff.Migrations, "oficina_handoff"), migrate.MustFromFS(linkstore.Migrations, linkstore.SchemaNamespace), Schema, oficinaid.LifecycleSchema)
diff --git a/internal/equipo/migrations/0082_oficina_id.sql b/internal/equipo/migrations/0082_oficina_id.sql
index b1fd9128..cd47e40c 100644
--- a/internal/equipo/migrations/0082_oficina_id.sql
+++ b/internal/equipo/migrations/0082_oficina_id.sql
@@ -6,21 +6,3 @@ CREATE TRIGGER equipo_member_identity AFTER INSERT ON members WHEN NEW.identity_
END;
CREATE TABLE equipo_id_accounts (id INTEGER PRIMARY KEY AUTOINCREMENT, binding TEXT NOT NULL UNIQUE, member_key TEXT NOT NULL UNIQUE, sealed_address BLOB NOT NULL, linked_at INTEGER NOT NULL DEFAULT 0);
CREATE TABLE equipo_id_reauth (id_hash TEXT PRIMARY KEY, account_id INTEGER NOT NULL, session_hash TEXT NOT NULL, started INTEGER NOT NULL, expires INTEGER NOT NULL, purpose TEXT NOT NULL, ready INTEGER NOT NULL DEFAULT 0);
-CREATE TRIGGER equipo_id_member_delete AFTER DELETE ON members BEGIN
- DELETE FROM sessions WHERE method='oficina-id' AND subject IN (SELECT subject FROM home_identity_links WHERE person_id IN (SELECT id FROM equipo_id_accounts WHERE member_key=OLD.identity_key));
- DELETE FROM home_identity_links WHERE person_id IN (SELECT id FROM equipo_id_accounts WHERE member_key=OLD.identity_key);
- DELETE FROM equipo_id_accounts WHERE member_key=OLD.identity_key;
- DELETE FROM equipo_id_reauth;
- DELETE FROM home_link_flows;
- DELETE FROM oficina_handoff_pending;
- DELETE FROM oficina_handoff_inbox;
-END;
-CREATE TRIGGER equipo_id_member_change AFTER UPDATE OF address ON members WHEN OLD.address<>NEW.address BEGIN
- DELETE FROM sessions WHERE method='oficina-id' AND subject IN (SELECT subject FROM home_identity_links WHERE person_id IN (SELECT id FROM equipo_id_accounts WHERE member_key=OLD.identity_key));
- DELETE FROM home_identity_links WHERE person_id IN (SELECT id FROM equipo_id_accounts WHERE member_key=OLD.identity_key);
- DELETE FROM equipo_id_accounts WHERE member_key=OLD.identity_key;
- DELETE FROM equipo_id_reauth;
- DELETE FROM home_link_flows;
- DELETE FROM oficina_handoff_pending;
- DELETE FROM oficina_handoff_inbox;
-END;
diff --git a/internal/equipo/migrations/schema.sql b/internal/equipo/migrations/schema.sql
index 7c5da14e..42881be9 100644
--- a/internal/equipo/migrations/schema.sql
+++ b/internal/equipo/migrations/schema.sql
@@ -686,21 +686,3 @@ CREATE TRIGGER equipo_member_identity AFTER INSERT ON members WHEN NEW.identity_
END;
CREATE TABLE equipo_id_accounts (id INTEGER PRIMARY KEY AUTOINCREMENT, binding TEXT NOT NULL UNIQUE, member_key TEXT NOT NULL UNIQUE, sealed_address BLOB NOT NULL, linked_at INTEGER NOT NULL DEFAULT 0);
CREATE TABLE equipo_id_reauth (id_hash TEXT PRIMARY KEY, account_id INTEGER NOT NULL, session_hash TEXT NOT NULL, started INTEGER NOT NULL, expires INTEGER NOT NULL, purpose TEXT NOT NULL, ready INTEGER NOT NULL DEFAULT 0);
-CREATE TRIGGER equipo_id_member_delete AFTER DELETE ON members BEGIN
- DELETE FROM sessions WHERE method='oficina-id' AND subject IN (SELECT subject FROM home_identity_links WHERE person_id IN (SELECT id FROM equipo_id_accounts WHERE member_key=OLD.identity_key));
- DELETE FROM home_identity_links WHERE person_id IN (SELECT id FROM equipo_id_accounts WHERE member_key=OLD.identity_key);
- DELETE FROM equipo_id_accounts WHERE member_key=OLD.identity_key;
- DELETE FROM equipo_id_reauth;
- DELETE FROM home_link_flows;
- DELETE FROM oficina_handoff_pending;
- DELETE FROM oficina_handoff_inbox;
-END;
-CREATE TRIGGER equipo_id_member_change AFTER UPDATE OF address ON members WHEN OLD.address<>NEW.address BEGIN
- DELETE FROM sessions WHERE method='oficina-id' AND subject IN (SELECT subject FROM home_identity_links WHERE person_id IN (SELECT id FROM equipo_id_accounts WHERE member_key=OLD.identity_key));
- DELETE FROM home_identity_links WHERE person_id IN (SELECT id FROM equipo_id_accounts WHERE member_key=OLD.identity_key);
- DELETE FROM equipo_id_accounts WHERE member_key=OLD.identity_key;
- DELETE FROM equipo_id_reauth;
- DELETE FROM home_link_flows;
- DELETE FROM oficina_handoff_pending;
- DELETE FROM oficina_handoff_inbox;
-END;
diff --git a/internal/equipo/oficinaid/migrations.go b/internal/equipo/oficinaid/migrations.go
new file mode 100644
index 00000000..c3fb0767
--- /dev/null
+++ b/internal/equipo/oficinaid/migrations.go
@@ -0,0 +1,13 @@
+package oficinaid
+
+import (
+ "amadan.net/rastrillo/rastrillo/migrate"
+ "embed"
+)
+
+// These triggers need the app tables, sessions and shared identity stores.
+// Install them last in BootSchema; app-only schema users have no sessions.
+//
+//go:embed migrations/*.sql
+var migrations embed.FS
+var LifecycleSchema = migrate.MustFromFS(migrations, "equipo_identity")
diff --git a/internal/equipo/oficinaid/migrations/0001_lifecycle.sql b/internal/equipo/oficinaid/migrations/0001_lifecycle.sql
new file mode 100644
index 00000000..33e7eba7
--- /dev/null
+++ b/internal/equipo/oficinaid/migrations/0001_lifecycle.sql
@@ -0,0 +1,18 @@
+CREATE TRIGGER equipo_id_member_delete AFTER DELETE ON members BEGIN
+ DELETE FROM sessions WHERE method='oficina-id' AND subject IN (SELECT subject FROM home_identity_links WHERE person_id IN (SELECT id FROM equipo_id_accounts WHERE member_key=OLD.identity_key));
+ DELETE FROM home_identity_links WHERE person_id IN (SELECT id FROM equipo_id_accounts WHERE member_key=OLD.identity_key);
+ DELETE FROM equipo_id_accounts WHERE member_key=OLD.identity_key;
+ DELETE FROM equipo_id_reauth;
+ DELETE FROM home_link_flows;
+ DELETE FROM oficina_handoff_pending;
+ DELETE FROM oficina_handoff_inbox;
+END;
+CREATE TRIGGER equipo_id_member_change AFTER UPDATE OF address ON members WHEN OLD.address<>NEW.address BEGIN
+ DELETE FROM sessions WHERE method='oficina-id' AND subject IN (SELECT subject FROM home_identity_links WHERE person_id IN (SELECT id FROM equipo_id_accounts WHERE member_key=OLD.identity_key));
+ DELETE FROM home_identity_links WHERE person_id IN (SELECT id FROM equipo_id_accounts WHERE member_key=OLD.identity_key);
+ DELETE FROM equipo_id_accounts WHERE member_key=OLD.identity_key;
+ DELETE FROM equipo_id_reauth;
+ DELETE FROM home_link_flows;
+ DELETE FROM oficina_handoff_pending;
+ DELETE FROM oficina_handoff_inbox;
+END;