Files
archie/internal/infrastructure/postgres/queries/installed_packages.sql
T
sam ed35b826ad feat(store): record accepted package authority against the pin
An archie package declares its authority; nothing in the tree recorded the
operator's acceptance of it. This lands the acceptance-record slice of
docs/prds/store.md ("Authority"):

- storepkg.Authority gains Covers (the upper-bound predicate: equal or
  narrower applies, wider does not) and Validate (forge-permission
  vocabulary, no blank grants).
- Installed carries AcceptedAuthority (nil until accepted); install leaves it
  unset, so an unaccepted package has no authority.
- AcceptPackageAuthority on the storepkg Manager records the acceptance
  against the pinned digest and refuses grants the package does not declare
  (storepkg.ErrAuthorityNotDeclared), carried over the wire.
- staterpc gains the admin-only AcceptPackageAuthority RPC;
  InstalledPackage carries accepted_authority.
2026-09-30 07:40:06 +10:00

30 lines
1.2 KiB
SQL

-- name: LockInstalledPackages :exec
SELECT pg_advisory_xact_lock(hashtextextended('installed-packages:' || $1::text, 0));
-- name: InsertInstalledPackage :exec
INSERT INTO installed_packages (org_id, name, reference, digest, descriptor, layer, update_policy)
VALUES ($1, $2, $3, $4, $5, $6, $7);
-- name: InsertInstalledRequirement :exec
INSERT INTO installed_package_requirements (org_id, package_name, required_name, required_digest)
VALUES ($1, $2, $3, $4);
-- name: GetInstalledPackage :one
SELECT org_id, name, reference, digest, descriptor, layer, update_policy, accepted_authority
FROM installed_packages WHERE org_id = $1 AND name = $2;
-- name: ListInstalledPackages :many
SELECT org_id, name, reference, digest, descriptor, layer, update_policy, accepted_authority
FROM installed_packages WHERE org_id = $1 ORDER BY name;
-- name: AcceptInstalledPackageAuthority :execrows
UPDATE installed_packages SET accepted_authority = $3
WHERE org_id = $1 AND name = $2;
-- name: DeleteInstalledPackage :execrows
DELETE FROM installed_packages WHERE org_id = $1 AND name = $2;
-- name: GetInstalledRequirement :one
SELECT required_digest FROM installed_package_requirements
WHERE org_id = $1 AND package_name = $2 AND required_name = $3;