ThatAIguyA world of ideas

THE CONSCIOUSNESS ATLAS
Read. Experiment. Follow the evidence.

ConsciousnessLearn · Explore · Joseph Anady

Janady13/missionmatch / db/queries/mission_tags.sql

Source identity, revision, and recovered contents.

GitHub sourceSource text recovered

Source identity

FieldRecorded value
Source typeGitHub source
Original recordJanady13/missionmatch / db/queries/mission_tags.sql
DateNot specified in source
RepositoryJanady13/missionmatch
Revision720d47fae476b0d38477ae4401697d372b1ea2bc
Branchfeature/opportunity-to-outcome
Path or archive memberdb/queries/mission_tags.sql
Original SHA-25672e17d25f27a39e7e2ce1c90b64c0d6a74d77f53f4f74049411c479d2ed024b4
Git blob SHAe22739c922f045a54cd3a15040f8ca55fd383a81
Reading-copy SHA-25672e17d25f27a39e7e2ce1c90b64c0d6a74d77f53f4f74049411c479d2ed024b4

Original source ↗

Every recorded occurrence

These 15 records contain identical original source bytes. Their paths and revisions remain part of the archive.

Original recordBranch or archiveRevision / identifierOriginal location
Janady13/missionmatch / db/queries/mission_tags.sqlfeature/opportunity-to-outcome720d47fae476b0d38477ae4401697d372b1ea2bcOpen original
Janady13/missionmatch / db/queries/mission_tags.sqlcollision-deconfliction4ee5a09972608ed89f8377c6665542d5f450f0a6Open original
Janady13/missionmatch / db/queries/mission_tags.sqlm5-price-to-win41000ad30fff4129fdaf5ec84e15ba14c27d4890Open original
Janady13/missionmatch / db/queries/mission_tags.sqlmaster1e9249840a4302ec82e123b9c9cb6f75badea3e4Open original
Janady13/missionmatch / db/queries/mission_tags.sqlws8-teaching-loopc823f0fb6bb2aba0f39001eb6de96f4000d9321fOpen original
Janady13/missionmatch / db/queries/mission_tags.sqlmag-substrateb82c7100a492dec67dfd1eda6b3f53def859be35Open original
Janady13/missionmatch / db/queries/mission_tags.sqltime-to-fill-survivalb66e1e505863d4f17741a4b9ede73509e45bd6c6Open original
Janady13/missionmatch / db/queries/mission_tags.sqlgraphrag-foundationb0ddeb9f633fd138d09309d1a17b7d13bc3a67f7Open original
Janady13/missionmatch / db/queries/mission_tags.sqlws9-bench-ingestionf585a9ef32fa554663ce1fba9a414a54b6e49cf0Open original
Janady13/missionmatch / db/queries/mission_tags.sqlpresentation-readinesseb574acaa29d71ce4d0f852572e87c275c79fdb7Open original
Janady13/missionmatch / db/queries/mission_tags.sqlvendor-intelligencefe9796a19c261951d3f2565206c0c1b5ac294465Open original
Janady13/missionmatch / db/queries/mission_tags.sqlws7-federal-signal6a9f6ce9cfb13345ffb47770d4960e7c2d9c17c2Open original
Janady13/missionmatch / db/queries/mission_tags.sqlphase2-connectorse038d4c687aec16f8bd9bc4d907eea14d91f8704Open original
Janady13/missionmatch / db/queries/mission_tags.sqlfeature/aioe-upgrade2178e7298d0e5d9af83afa12402fd587f0ba6ed8Open original
Janady13/missionmatch / db/queries/mission_tags.sqlcapture-readinessbae6af7cb2997e819174a9e9cfff5e16067a1975Open original

Recovered source transcript

-- 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;

Search equations, builds, manuscript text, and recovered sources.