Files
archie/internal/infrastructure/postgres/postgresdb/installed_package_contributions.sql.go
sam f6ee43bf55 feat(store): project installed package contributions into org resources
An install that stayed in installed_packages left every contribution
unprojected: nothing made a package's workflow a usable org resource, and
nothing stopped it on removal. This lands projection for the workflow family,
the one kind whose org resource, validation and live read path all exist:

- storepkg.Service gains Projections (family -> projector): install resolves
  each projected family's contributed names against the fetched
  layer (FilesFromLayer), applies them, and on failure withdraws and removes
  the half installation; remove withdraws before the record goes, so a failed
  withdrawal keeps the package installed and usable.
- controlplane.WorkflowProjector merges the package's entries into the org's
  workflow-definitions document — the same document the daemon's
  WorkflowDefinitions client reads per dispatch, so a projected workflow is
  usable at the next dispatch and a withdrawn one stops dispatching, without
  restarts. A contributed id displacing an operator's own workflow is refused
  (storepkg.ErrContributionCollision), never silently replaced.
- installed_package_contributions (migration 0023) records the entries a
  package projected, so removal takes exactly its own contributions out.
- stateStoreDeps wires the projector set on the State Store's pool; the
  composition is pinned by the live round-trip test over a real gRPC
  connection.

Prompts, skills, MCP server definitions and default settings remain
unprojected: their contribution formats are not settled by docs/prds/store.md
and are left for their own slices rather than half-wired here.
2026-09-30 08:05:22 +10:00

98 lines
2.8 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.31.1
// source: installed_package_contributions.sql
package postgresdb
import (
"context"
)
const deleteInstalledPackageContributions = `-- name: DeleteInstalledPackageContributions :exec
DELETE FROM installed_package_contributions
WHERE org_id = $1 AND package_name = $2 AND family = $3
`
type DeleteInstalledPackageContributionsParams struct {
OrgID string
PackageName string
Family string
}
func (q *Queries) DeleteInstalledPackageContributions(ctx context.Context, arg DeleteInstalledPackageContributionsParams) error {
_, err := q.db.Exec(ctx, deleteInstalledPackageContributions, arg.OrgID, arg.PackageName, arg.Family)
return err
}
const insertInstalledPackageContribution = `-- name: InsertInstalledPackageContribution :exec
INSERT INTO installed_package_contributions (org_id, package_name, family, entry_id)
VALUES ($1, $2, $3, $4) ON CONFLICT DO NOTHING
`
type InsertInstalledPackageContributionParams struct {
OrgID string
PackageName string
Family string
EntryID string
}
func (q *Queries) InsertInstalledPackageContribution(ctx context.Context, arg InsertInstalledPackageContributionParams) error {
_, err := q.db.Exec(ctx, insertInstalledPackageContribution,
arg.OrgID,
arg.PackageName,
arg.Family,
arg.EntryID,
)
return err
}
const listInstalledPackageContributions = `-- name: ListInstalledPackageContributions :many
SELECT org_id, package_name, family, entry_id FROM installed_package_contributions
WHERE org_id = $1 AND package_name = $2
`
type ListInstalledPackageContributionsParams struct {
OrgID string
PackageName string
}
func (q *Queries) ListInstalledPackageContributions(ctx context.Context, arg ListInstalledPackageContributionsParams) ([]InstalledPackageContribution, error) {
rows, err := q.db.Query(ctx, listInstalledPackageContributions, arg.OrgID, arg.PackageName)
if err != nil {
return nil, err
}
defer rows.Close()
var items []InstalledPackageContribution
for rows.Next() {
var i InstalledPackageContribution
if err := rows.Scan(
&i.OrgID,
&i.PackageName,
&i.Family,
&i.EntryID,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const lockInstalledPackageContributions = `-- name: LockInstalledPackageContributions :exec
SELECT pg_advisory_xact_lock(hashtextextended('installed-package-contributions:' || $1::text || ':' || $2::text, 0))
`
type LockInstalledPackageContributionsParams struct {
Column1 string
Column2 string
}
func (q *Queries) LockInstalledPackageContributions(ctx context.Context, arg LockInstalledPackageContributionsParams) error {
_, err := q.db.Exec(ctx, lockInstalledPackageContributions, arg.Column1, arg.Column2)
return err
}