@volter/teams 0.2.41 → 0.2.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/server/auth.mjs +9 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volter/teams",
3
- "version": "0.2.41",
3
+ "version": "0.2.42",
4
4
  "type": "module",
5
5
  "description": "Volter Teams, the neutral team plane: machine identity and daemon core, the local door and server link, admission from machine grants, product doors, and the Teams server's neutral routes (company RFC 0008).",
6
6
  "license": "MIT",
package/server/auth.mjs CHANGED
@@ -26,13 +26,19 @@ const LINEAGE_ROWS = `FROM lineage l JOIN credentials c ON c.id=l.id
26
26
  LEFT JOIN apps a ON a.id=i.app_id
27
27
  LEFT JOIN memberships installer ON installer.team_id=i.team_id AND installer.principal_id=i.installer_id
28
28
  LEFT JOIN memberships service ON service.team_id=i.team_id AND service.principal_id=i.principal_id`;
29
- export const APP_LINEAGE_REVOKED = `${APP_LINEAGE}, lineage_actors(team,id) AS (
29
+ // Materialize only this credential lineage's actors before checking their
30
+ // agency. When json_each was flattened, the hosted planner checked every
31
+ // agent in the team before matching actor.value (20,794 reads per event).
32
+ // CROSS JOIN keeps the small actor list on the left of the indexed agent
33
+ // lookup. Authority stays live: no predicate or result is cached.
34
+ export const APP_LINEAGE_REVOKED = `${APP_LINEAGE}, lineage_actors(team,id) AS MATERIALIZED (
30
35
  SELECT c.team_id,actor.value FROM lineage l JOIN credentials c ON c.id=l.id JOIN principals p ON p.id=c.principal_id
31
36
  JOIN app_credentials ac ON ac.credential_id=c.id, json_each(COALESCE(ac.actor_json,'[]')) actor WHERE actor.type='text')
32
37
  SELECT 1 FROM lineage l JOIN credentials c ON c.id=l.id JOIN principals p ON p.id=c.principal_id
33
38
  WHERE p.kind='agent' AND NOT EXISTS (${AGENT_ACTIVE.replace('VALUES(?,?)','SELECT c.team_id,c.principal_id')})
34
- UNION ALL SELECT 1 FROM lineage_actors x JOIN agents named ON named.team_id=x.team AND named.id=x.id
35
- WHERE NOT EXISTS (${AGENT_ACTIVE.replace('VALUES(?,?)','SELECT named.team_id,named.id')})
39
+ UNION ALL SELECT 1 FROM lineage_actors x CROSS JOIN agents named
40
+ WHERE named.team_id=x.team AND named.id=x.id
41
+ AND NOT EXISTS (${AGENT_ACTIVE.replace('VALUES(?,?)','SELECT named.team_id,named.id')})
36
42
  UNION ALL SELECT 1 ${LINEAGE_ROWS}
37
43
  WHERE EXISTS(SELECT 1 FROM agent_credentials d LEFT JOIN memberships dm ON dm.team_id=d.team_id AND dm.principal_id=c.principal_id WHERE d.parent_credential_id=c.id AND d.credential_id IN(SELECT id FROM lineage) AND COALESCE(dm.active,0)!=1)
38
44
  OR c.revoked_at IS NOT NULL OR (c.expires_at IS NOT NULL AND c.expires_at<=?)