feat(access): policy, denial and principal persistence on the State Store contract (archie-core-qc8p)

This commit is contained in:
sam committed 2026-09-26 15:23:32 +10:00
1 parent c6d880a8f8
commit c41e2d76ad
17 files changed
+2925 -198

No files matched your search

@@ -11,6 +11,22 @@ import (
"github.com/jackc/pgx/v5/pgtype"
)
const ensureAgentOrgMembership = `-- name: EnsureAgentOrgMembership :exec
INSERT INTO memberships (identity_id, org_id, role)
SELECT a.identity_id, a.org_id, 'developer' FROM org_agents a
ON CONFLICT (identity_id, org_id, COALESCE(workspace_id, '')) DO NOTHING
`
// Every agent identity serves its org with the shipped developer role: an
// agent is granted access the way a user is
// (docs/prds/orgs-and-access.md, "Identity"). Idempotent, so an operator's
// later role change survives a restart, and the shipped seed never
// overwrites it.
func (q *Queries) EnsureAgentOrgMembership(ctx context.Context) error {
_, err := q.db.Exec(ctx, ensureAgentOrgMembership)
return err
}
const ensureMembership = `-- name: EnsureMembership :exec
INSERT INTO memberships (identity_id, org_id, workspace_id, role)
VALUES ($1, $2, $3, $4)