Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/missionmatch / internal/modules/federalsignal/tenant_tag_repo.go |
| Date | Not specified in source |
| Repository | Janady13/missionmatch |
| Revision | 720d47fae476b0d38477ae4401697d372b1ea2bc |
| Branch | feature/opportunity-to-outcome |
| Path or archive member | internal/modules/federalsignal/tenant_tag_repo.go |
| Original SHA-256 | 3ff34f442c259cf300583c602e568dc3ecbfb7172f3d0a9d67e52f585ce0c2b5 |
| Git blob SHA | 0182ea0579380cf692b398b42fe60135f185007f |
| Reading-copy SHA-256 | 3ff34f442c259cf300583c602e568dc3ecbfb7172f3d0a9d67e52f585ce0c2b5 |
Every recorded occurrence
These 15 records contain identical original source bytes. Their paths and revisions remain part of the archive.
| Original record | Branch or archive | Revision / identifier | Original location |
|---|---|---|---|
| Janady13/missionmatch / internal/modules/federalsignal/tenant_tag_repo.go | feature/opportunity-to-outcome | 720d47fae476b0d38477ae4401697d372b1ea2bc | Open original |
| Janady13/missionmatch / internal/modules/federalsignal/tenant_tag_repo.go | collision-deconfliction | 4ee5a09972608ed89f8377c6665542d5f450f0a6 | Open original |
| Janady13/missionmatch / internal/modules/federalsignal/tenant_tag_repo.go | m5-price-to-win | 41000ad30fff4129fdaf5ec84e15ba14c27d4890 | Open original |
| Janady13/missionmatch / internal/modules/federalsignal/tenant_tag_repo.go | master | 1e9249840a4302ec82e123b9c9cb6f75badea3e4 | Open original |
| Janady13/missionmatch / internal/modules/federalsignal/tenant_tag_repo.go | ws8-teaching-loop | c823f0fb6bb2aba0f39001eb6de96f4000d9321f | Open original |
| Janady13/missionmatch / internal/modules/federalsignal/tenant_tag_repo.go | mag-substrate | b82c7100a492dec67dfd1eda6b3f53def859be35 | Open original |
| Janady13/missionmatch / internal/modules/federalsignal/tenant_tag_repo.go | time-to-fill-survival | b66e1e505863d4f17741a4b9ede73509e45bd6c6 | Open original |
| Janady13/missionmatch / internal/modules/federalsignal/tenant_tag_repo.go | graphrag-foundation | b0ddeb9f633fd138d09309d1a17b7d13bc3a67f7 | Open original |
| Janady13/missionmatch / internal/modules/federalsignal/tenant_tag_repo.go | ws9-bench-ingestion | f585a9ef32fa554663ce1fba9a414a54b6e49cf0 | Open original |
| Janady13/missionmatch / internal/modules/federalsignal/tenant_tag_repo.go | presentation-readiness | eb574acaa29d71ce4d0f852572e87c275c79fdb7 | Open original |
| Janady13/missionmatch / internal/modules/federalsignal/tenant_tag_repo.go | vendor-intelligence | fe9796a19c261951d3f2565206c0c1b5ac294465 | Open original |
| Janady13/missionmatch / internal/modules/federalsignal/tenant_tag_repo.go | ws7-federal-signal | 6a9f6ce9cfb13345ffb47770d4960e7c2d9c17c2 | Open original |
| Janady13/missionmatch / internal/modules/federalsignal/tenant_tag_repo.go | phase2-connectors | e038d4c687aec16f8bd9bc4d907eea14d91f8704 | Open original |
| Janady13/missionmatch / internal/modules/federalsignal/tenant_tag_repo.go | feature/aioe-upgrade | 2178e7298d0e5d9af83afa12402fd587f0ba6ed8 | Open original |
| Janady13/missionmatch / internal/modules/federalsignal/tenant_tag_repo.go | capture-readiness | bae6af7cb2997e819174a9e9cfff5e16067a1975 | Open original |
Recovered source transcript
Download complete source text ↓100 lines · 4.1 KB
package federalsignal
// Production TenantTagRepo: the DB backed adapter that makes every read and every write of the Phase 5a
// tenant tagging service run inside RunInTenantTx as the application role. RLS is therefore exercised on
// every row, the org id is set transaction locally from the validated context GUC, and a child row can
// never reference a parent in another tenant (the composite FK). This adapter never touches the migrator
// bypass: it holds a *tenant.DB whose pool authenticates as the NOBYPASSRLS application role.
import (
"context"
"fmt"
"github.com/jackc/pgx/v5"
"github.com/missionworkforce/missionmatch/internal/platform/database/dbgen"
"github.com/missionworkforce/missionmatch/internal/platform/missionclass"
"github.com/missionworkforce/missionmatch/internal/platform/tenant"
)
// tenantTagRepo is the production TenantTagRepo over a tenant scoped application DB.
type tenantTagRepo struct{ db *tenant.DB }
// NewTenantTagRepo builds the production TenantTagRepo. db MUST be a tenant.DB whose pool authenticates as
// the application role, so RunInTenantTx is the only path to the rows and RLS cannot be bypassed.
func NewTenantTagRepo(db *tenant.DB) TenantTagRepo {
return &tenantTagRepo{db: db}
}
func (r *tenantTagRepo) ListCandidatesForTagging(ctx context.Context) ([]dbgen.ListCandidatesForMissionTaggingRow, error) {
var out []dbgen.ListCandidatesForMissionTaggingRow
err := r.db.RunInTenantTx(ctx, func(ctx context.Context, tx pgx.Tx) error {
var e error
out, e = dbgen.New(tx).ListCandidatesForMissionTagging(ctx)
return e
})
return out, err
}
func (r *tenantTagRepo) ListRequirementsForTagging(ctx context.Context) ([]dbgen.ListRequirementsForMissionTaggingRow, error) {
var out []dbgen.ListRequirementsForMissionTaggingRow
err := r.db.RunInTenantTx(ctx, func(ctx context.Context, tx pgx.Tx) error {
var e error
out, e = dbgen.New(tx).ListRequirementsForMissionTagging(ctx)
return e
})
return out, err
}
// UpsertCandidateMissionTags writes every tag inside ONE tenant transaction as the application role, so
// the whole org's candidate tags commit or roll back together and RLS scopes each insert to the org GUC.
func (r *tenantTagRepo) UpsertCandidateMissionTags(ctx context.Context, tags []dbgen.UpsertCandidateMissionTagParams) error {
if len(tags) == 0 {
return nil
}
return r.db.RunInTenantTx(ctx, func(ctx context.Context, tx pgx.Tx) error {
q := dbgen.New(tx)
for _, t := range tags {
if err := q.UpsertCandidateMissionTag(ctx, t); err != nil {
return err
}
}
return nil
})
}
// UpsertRequirementMissionTags writes every requirement tag inside one tenant transaction as the
// application role, same isolation guarantees as the candidate path.
func (r *tenantTagRepo) UpsertRequirementMissionTags(ctx context.Context, tags []dbgen.UpsertRequirementMissionTagParams) error {
if len(tags) == 0 {
return nil
}
return r.db.RunInTenantTx(ctx, func(ctx context.Context, tx pgx.Tx) error {
q := dbgen.New(tx)
for _, t := range tags {
if err := q.UpsertRequirementMissionTag(ctx, t); err != nil {
return err
}
}
return nil
})
}
// AliasPairReader is the single method the backfill needs to seed the AliasIndex. The production Repo (from
// NewRepo) satisfies it, so the backfill reuses the same MissionAliasPairs read the global pass uses, which
// means the tenant pass and the global pass classify against an identical curated alias layer.
type AliasPairReader interface {
AliasPairs(ctx context.Context) (map[string]string, error)
}
// BuildAliasIndex loads the global (phrase, code) alias pairs through the given reader and compiles them
// into a missionclass.AliasIndex ONCE. The backfill builds the index a single time and shares it across
// every org, because the alias layer is global reference data the application role may read.
func BuildAliasIndex(ctx context.Context, r AliasPairReader) (missionclass.AliasIndex, error) {
pairs, err := r.AliasPairs(ctx)
if err != nil {
return missionclass.AliasIndex{}, fmt.Errorf("federalsignal: load alias pairs: %w", err)
}
return missionclass.NewAliasIndex(pairs), nil
}