Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/missionmatch / db/queries/mission_tags.sql |
| Date | Not specified in source |
| Repository | Janady13/missionmatch |
| Revision | 720d47fae476b0d38477ae4401697d372b1ea2bc |
| Branch | feature/opportunity-to-outcome |
| Path or archive member | db/queries/mission_tags.sql |
| Original SHA-256 | 72e17d25f27a39e7e2ce1c90b64c0d6a74d77f53f4f74049411c479d2ed024b4 |
| Git blob SHA | e22739c922f045a54cd3a15040f8ca55fd383a81 |
| Reading-copy SHA-256 | 72e17d25f27a39e7e2ce1c90b64c0d6a74d77f53f4f74049411c479d2ed024b4 |
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 / db/queries/mission_tags.sql | feature/opportunity-to-outcome | 720d47fae476b0d38477ae4401697d372b1ea2bc | Open original |
| Janady13/missionmatch / db/queries/mission_tags.sql | collision-deconfliction | 4ee5a09972608ed89f8377c6665542d5f450f0a6 | Open original |
| Janady13/missionmatch / db/queries/mission_tags.sql | m5-price-to-win | 41000ad30fff4129fdaf5ec84e15ba14c27d4890 | Open original |
| Janady13/missionmatch / db/queries/mission_tags.sql | master | 1e9249840a4302ec82e123b9c9cb6f75badea3e4 | Open original |
| Janady13/missionmatch / db/queries/mission_tags.sql | ws8-teaching-loop | c823f0fb6bb2aba0f39001eb6de96f4000d9321f | Open original |
| Janady13/missionmatch / db/queries/mission_tags.sql | mag-substrate | b82c7100a492dec67dfd1eda6b3f53def859be35 | Open original |
| Janady13/missionmatch / db/queries/mission_tags.sql | time-to-fill-survival | b66e1e505863d4f17741a4b9ede73509e45bd6c6 | Open original |
| Janady13/missionmatch / db/queries/mission_tags.sql | graphrag-foundation | b0ddeb9f633fd138d09309d1a17b7d13bc3a67f7 | Open original |
| Janady13/missionmatch / db/queries/mission_tags.sql | ws9-bench-ingestion | f585a9ef32fa554663ce1fba9a414a54b6e49cf0 | Open original |
| Janady13/missionmatch / db/queries/mission_tags.sql | presentation-readiness | eb574acaa29d71ce4d0f852572e87c275c79fdb7 | Open original |
| Janady13/missionmatch / db/queries/mission_tags.sql | vendor-intelligence | fe9796a19c261951d3f2565206c0c1b5ac294465 | Open original |
| Janady13/missionmatch / db/queries/mission_tags.sql | ws7-federal-signal | 6a9f6ce9cfb13345ffb47770d4960e7c2d9c17c2 | Open original |
| Janady13/missionmatch / db/queries/mission_tags.sql | phase2-connectors | e038d4c687aec16f8bd9bc4d907eea14d91f8704 | Open original |
| Janady13/missionmatch / db/queries/mission_tags.sql | feature/aioe-upgrade | 2178e7298d0e5d9af83afa12402fd587f0ba6ed8 | Open original |
| Janady13/missionmatch / db/queries/mission_tags.sql | capture-readiness | bae6af7cb2997e819174a9e9cfff5e16067a1975 | Open original |
Recovered source transcript
Download complete source text ↓192 lines · 9.8 KB
-- name: UpsertFederalMissionTag :exec
-- Idempotent write of a global mission tag from the classification sync pass. ON CONFLICT DO UPDATE so a
-- re run with the same record and mission code refreshes the mechanism, evidence, and confidence rather
-- than erroring, which keeps the sync pass safely repeatable. Migrator owned, app SELECT only.
INSERT INTO federal_mission_tags (record_table, record_id, mission_code, mechanism, evidence, confidence)
VALUES (
sqlc.arg(record_table),
sqlc.arg(record_id),
sqlc.arg(mission_code),
sqlc.arg(mechanism),
sqlc.arg(evidence),
sqlc.arg(confidence)
)
ON CONFLICT (record_table, record_id, mission_code) DO UPDATE SET
mechanism = EXCLUDED.mechanism,
evidence = EXCLUDED.evidence,
confidence = EXCLUDED.confidence,
classified_at = now();
-- name: UpsertAwardIncumbentRole :exec
-- Idempotent write of an incumbent labor mix row mined from award and solicitation text. ON CONFLICT DO
-- UPDATE so a re run refreshes the count and evidence for the same record and labor category.
INSERT INTO award_incumbent_roles (record_table, record_id, labor_category, role_count, evidence)
VALUES (
sqlc.arg(record_table),
sqlc.arg(record_id),
sqlc.arg(labor_category),
sqlc.arg(role_count),
sqlc.arg(evidence)
)
ON CONFLICT (record_table, record_id, labor_category) DO UPDATE SET
role_count = EXCLUDED.role_count,
evidence = EXCLUDED.evidence,
classified_at = now();
-- name: UpsertCandidateMissionTag :exec
-- Idempotent write of a tenant candidate mission tag. RLS scopes the write to the caller's org and the
-- composite FK guarantees the candidate belongs to that org. ON CONFLICT DO UPDATE keeps the sync pass
-- repeatable, refreshing the mechanism and evidence for an existing candidate and mission code pair.
INSERT INTO candidate_mission_tags (organization_id, candidate_id, mission_code, mechanism, evidence)
VALUES (
sqlc.arg(organization_id),
sqlc.arg(candidate_id),
sqlc.arg(mission_code),
sqlc.arg(mechanism),
sqlc.arg(evidence)
)
ON CONFLICT (candidate_id, mission_code) DO UPDATE SET
mechanism = EXCLUDED.mechanism,
evidence = EXCLUDED.evidence;
-- name: UpsertRequirementMissionTag :exec
-- Idempotent write of a tenant requirement mission tag, same isolation guarantees as the candidate path.
INSERT INTO requirement_mission_tags (organization_id, requirement_id, mission_code, mechanism, evidence)
VALUES (
sqlc.arg(organization_id),
sqlc.arg(requirement_id),
sqlc.arg(mission_code),
sqlc.arg(mechanism),
sqlc.arg(evidence)
)
ON CONFLICT (requirement_id, mission_code) DO UPDATE SET
mechanism = EXCLUDED.mechanism,
evidence = EXCLUDED.evidence;
-- name: ListMissionTagsForRecord :many
-- All mission tags for one global record, ordered by mission code with the record id as a trailing unique
-- tiebreaker so the output is byte stable for fixed inputs, the AEDT reproducibility mandate.
SELECT record_table, record_id, mission_code, mechanism, evidence, confidence, classified_at
FROM federal_mission_tags
WHERE record_table = sqlc.arg(record_table) AND record_id = sqlc.arg(record_id)
ORDER BY mission_code, record_id;
-- name: ListCandidatesByMission :many
-- Tenant candidates tagged with a given mission code, RLS scoped to the caller's org through the join on
-- candidate_mission_tags. id is the trailing unique sort key so created_at ties give a total order and
-- stable LIMIT paging, the AEDT reproducibility mandate.
SELECT c.*
FROM candidates c
JOIN candidate_mission_tags t ON t.candidate_id = c.id
WHERE c.deleted_at IS NULL AND t.mission_code = sqlc.arg(mission_code)
ORDER BY c.created_at DESC, c.id
LIMIT sqlc.arg(row_limit);
-- name: ListOpportunityRecordsForClassify :many
-- Minimal projection of the global opportunity_records catalog for the missionclass sync pass: the id
-- carried as text (the record_id federal_mission_tags keys on), plus the title, psc, and naics the
-- deterministic classifier reads. Ordered by id so the pass iterates byte stably and a re run is
-- reproducible, the AEDT mandate. Migrator role reads the global catalog directly.
SELECT id::text AS record_id, title, psc, naics
FROM opportunity_records
ORDER BY id;
-- name: ListAwardsForClassify :many
-- Minimal projection of the global usaspending_awards catalog for the missionclass sync pass: the
-- generated_internal_id (the record_id the tag and incumbent role tables key on), plus the description,
-- naics_description, and naics_code the classifier reads. Ordered by generated_internal_id for byte
-- stable iteration.
SELECT generated_internal_id AS record_id, description, naics_description, naics_code
FROM usaspending_awards
ORDER BY generated_internal_id;
-- name: ListSamForClassify :many
-- Minimal projection of the cached sam_opportunities catalog for the missionclass sync pass: the
-- notice_id (the record_id award_incumbent_roles keys on for a SAM notice), plus the description_url and
-- the resource_links the attachment fetcher needs to mine the incumbent labor mix. Ordered by notice_id
-- for byte stable iteration.
SELECT notice_id AS record_id, description_url, resource_links
FROM sam_opportunities
ORDER BY notice_id;
-- name: ListIncumbentRolesByRecompete :many
-- Incumbent labor mix mined from award text, joined to its parent USASpending award so each role carries
-- the award identity (recipient_name, pop_end_date) and its evidence phrase, the traceability the WS7
-- acceptance criterion requires. The recompete signal is pop_end_date: awards whose period of performance
-- is ending are the recompete relevant ones, so rows are ordered by pop_end_date soonest first, then by
-- the award generated_internal_id and the labor_category as trailing unique tiebreakers for byte stable
-- output, the AEDT reproducibility mandate. Awards with no pop_end_date sort last. Global reference data,
-- app SELECT only. The optional pop_end_before bound (NULL means no bound) lets the caller scope to a
-- recompete window without changing the default which returns the soonest ending awards first.
SELECT a.generated_internal_id AS record_id,
a.recipient_name AS recipient_name,
a.awarding_agency AS awarding_agency,
a.naics_code AS naics_code,
a.award_amount AS award_amount,
a.pop_end_date AS pop_end_date,
r.labor_category AS labor_category,
r.role_count AS role_count,
r.evidence AS evidence
FROM award_incumbent_roles r
JOIN usaspending_awards a ON a.generated_internal_id = r.record_id
WHERE r.record_table = 'usaspending_awards'
AND (sqlc.narg('pop_end_before')::date IS NULL OR a.pop_end_date <= sqlc.narg('pop_end_before')::date)
ORDER BY a.pop_end_date ASC NULLS LAST, a.generated_internal_id, r.labor_category
LIMIT sqlc.arg('row_limit')::int;
-- name: ListCandidatesForMissionTagging :many
-- Tenant projection the Phase 5a tagging service classifies: each live candidate id, its headline, and the
-- candidate's skill names joined by single spaces into one text blob. RLS scopes the read to the caller's
-- org through the candidates row, and the LEFT JOIN keeps a candidate with no skills (the headline still
-- classifies). headline is coerced to empty text so a NULL never aborts the aggregation. Ordered by id so
-- the pass iterates byte stably and a re run is reproducible, the AEDT mandate.
SELECT c.id AS candidate_id,
COALESCE(c.headline, '')::text AS headline,
COALESCE(string_agg(s.name, ' ' ORDER BY s.name), '')::text AS skill_text
FROM candidates c
LEFT JOIN candidate_skills cs ON cs.candidate_id = c.id
LEFT JOIN skills s ON s.id = cs.skill_id
WHERE c.deleted_at IS NULL AND c.anonymized_at IS NULL
GROUP BY c.id, c.headline
ORDER BY c.id;
-- name: ListRequirementsForMissionTagging :many
-- Tenant projection the Phase 5a tagging service classifies for requirements: each live requirement id, its
-- title, its labor_category (coerced to empty when NULL), and the required skill names joined by single
-- spaces. RLS scopes the read to the caller's org; the LEFT JOIN keeps a requirement with no required
-- skills (the title and labor category still classify). Ordered by id for byte stable, reproducible
-- iteration, the AEDT mandate.
SELECT r.id AS requirement_id,
r.title::text AS title,
COALESCE(r.labor_category, '')::text AS labor_category,
COALESCE(string_agg(s.name, ' ' ORDER BY s.name), '')::text AS skill_text
FROM requirements r
LEFT JOIN required_skills rs ON rs.requirement_id = r.id
LEFT JOIN skills s ON s.id = rs.skill_id
WHERE r.deleted_at IS NULL
GROUP BY r.id, r.title, r.labor_category
ORDER BY r.id;
-- name: ListAllOrganizationIDs :many
-- Every organization id, ordered by id for a byte stable backfill iteration. Read by the BYPASSRLS
-- migrator role in the tag-missions backfill ONLY to enumerate which tenant contexts to run; the tag
-- writes themselves run as the application role inside each org's RunInTenantTx, never the migrator bypass.
SELECT id FROM organizations ORDER BY id;
-- name: MissionAliasPairs :many
-- (phrase, code) pairs that seed the missionclass AliasIndex from real rows. Two unioned sources: every
-- curated alias whose target skill is a category 'mission_area' skill, and every mission_area skill name
-- itself. The skill name to code link is mission_areas.spine_term = skills.name, because the mission_area
-- skills were promoted from the mission_spine terms the mission_areas rows carry. Ordered by phrase then
-- code for a deterministic build. Global reference data, read by the migrator role.
SELECT a.alias_text AS phrase, m.code AS code
FROM skill_aliases a
JOIN skills s ON s.id = a.skill_id AND s.category = 'mission_area'
JOIN mission_areas m ON m.spine_term = s.name
UNION
SELECT s.name AS phrase, m.code AS code
FROM skills s
JOIN mission_areas m ON m.spine_term = s.name
WHERE s.category = 'mission_area'
ORDER BY phrase, code;