Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/missionmatch / db/queries/staffing.sql |
| Date | Not specified in source |
| Repository | Janady13/missionmatch |
| Revision | 720d47fae476b0d38477ae4401697d372b1ea2bc |
| Branch | feature/opportunity-to-outcome |
| Path or archive member | db/queries/staffing.sql |
| Original SHA-256 | 26ad1a78363b9c09f7023c699a7db8cedf85cbe4c5fcc03337e9b38c74ac2aa0 |
| Git blob SHA | 9df140a6a4daaf03fcd36774e59d71f638eedf5c |
| Reading-copy SHA-256 | 26ad1a78363b9c09f7023c699a7db8cedf85cbe4c5fcc03337e9b38c74ac2aa0 |
Every recorded occurrence
These 24 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/staffing.sql | feature/opportunity-to-outcome | 720d47fae476b0d38477ae4401697d372b1ea2bc | Open original |
| Janady13/missionmatch / db/queries/staffing.sql | per-tenant-routing | 9bde0f9a74b89d01980fa658e5253acda7528d0c | Open original |
| Janady13/missionmatch / db/queries/staffing.sql | collision-deconfliction | 4ee5a09972608ed89f8377c6665542d5f450f0a6 | Open original |
| Janady13/missionmatch / db/queries/staffing.sql | ws6-retrieval | 6c56e29231ec05735927fa265c97d517499dfeaf | Open original |
| Janady13/missionmatch / db/queries/staffing.sql | m5-price-to-win | 41000ad30fff4129fdaf5ec84e15ba14c27d4890 | Open original |
| Janady13/missionmatch / db/queries/staffing.sql | ws1-ontology-sync | b596f449a32a1016fbd403c36505cc00a1ac9ee6 | Open original |
| Janady13/missionmatch / db/queries/staffing.sql | master | 1e9249840a4302ec82e123b9c9cb6f75badea3e4 | Open original |
| Janady13/missionmatch / db/queries/staffing.sql | ws8-teaching-loop | c823f0fb6bb2aba0f39001eb6de96f4000d9321f | Open original |
| Janady13/missionmatch / db/queries/staffing.sql | w3-ai-staffing-recommendations | 43d56387270ef4da4cabd794d97ca6a49909bc7d | Open original |
| Janady13/missionmatch / db/queries/staffing.sql | mag-substrate | b82c7100a492dec67dfd1eda6b3f53def859be35 | Open original |
| Janady13/missionmatch / db/queries/staffing.sql | ws3-clearance | 4b8e7ce594c068621867f9c9deed0ec64ae6c553 | Open original |
| Janady13/missionmatch / db/queries/staffing.sql | phase2-eval-fairness | d361af254701975fe239927656ababb56374655e | Open original |
| Janady13/missionmatch / db/queries/staffing.sql | time-to-fill-survival | b66e1e505863d4f17741a4b9ede73509e45bd6c6 | Open original |
| Janady13/missionmatch / db/queries/staffing.sql | graphrag-foundation | b0ddeb9f633fd138d09309d1a17b7d13bc3a67f7 | Open original |
| Janady13/missionmatch / db/queries/staffing.sql | deploy-and-ops | bdacd9d0b4d5998d25fc74bf4007f4c3ec538c7a | Open original |
| Janady13/missionmatch / db/queries/staffing.sql | ws9-bench-ingestion | f585a9ef32fa554663ce1fba9a414a54b6e49cf0 | Open original |
| Janady13/missionmatch / db/queries/staffing.sql | ws2-alias-relationship | e4dada4601c6eb101830f9d223a9655dfa120616 | Open original |
| Janady13/missionmatch / db/queries/staffing.sql | presentation-readiness | eb574acaa29d71ce4d0f852572e87c275c79fdb7 | Open original |
| Janady13/missionmatch / db/queries/staffing.sql | vendor-intelligence | fe9796a19c261951d3f2565206c0c1b5ac294465 | Open original |
| Janady13/missionmatch / db/queries/staffing.sql | ws7-federal-signal | 6a9f6ce9cfb13345ffb47770d4960e7c2d9c17c2 | Open original |
| Janady13/missionmatch / db/queries/staffing.sql | ai-brain-live | aac32fc49c878cc5bca099459307611562d0bac1 | Open original |
| Janady13/missionmatch / db/queries/staffing.sql | phase2-connectors | e038d4c687aec16f8bd9bc4d907eea14d91f8704 | Open original |
| Janady13/missionmatch / db/queries/staffing.sql | feature/aioe-upgrade | 2178e7298d0e5d9af83afa12402fd587f0ba6ed8 | Open original |
| Janady13/missionmatch / db/queries/staffing.sql | capture-readiness | bae6af7cb2997e819174a9e9cfff5e16067a1975 | Open original |
Recovered source transcript
Download complete source text ↓112 lines · 5.3 KB
-- W3 AI Staffing Recommendations queries. Reads are RLS scoped by the app.current_org_id policy, so a
-- bare SELECT only ever sees the caller's org; writes pass organization_id explicitly and the RLS WITH
-- CHECK validates it matches the session org. No query here names the eeo schema, and none can: the
-- generated code is built only from public schema queries.
-- name: CreateRecommendationRun :one
INSERT INTO recommendation_runs (organization_id, view, scope_ref, model_version, parameters, created_by)
VALUES ($1, $2, $3, $4, $5, $6)
RETURNING *;
-- name: CreateStaffingRecommendation :one
INSERT INTO staffing_recommendations (
organization_id, run_id, requirement_id, candidate_id, action, rank, confidence,
value_score, rationale, rationale_source, evidence
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)
RETURNING *;
-- name: ListProactiveRecommendations :many
-- The current bench watch: pending recommendations from proactive runs, capped and paginated.
SELECT sr.* FROM staffing_recommendations sr
JOIN recommendation_runs rr ON rr.id = sr.run_id AND rr.organization_id = sr.organization_id
WHERE rr.view = 'proactive' AND sr.status = 'pending'
ORDER BY sr.candidate_id, sr.rank, sr.id
LIMIT $1 OFFSET $2;
-- name: GetStaffingRecommendationForUpdate :one
-- Locks the row for the decision path so two concurrent decisions on the same recommendation serialize;
-- the service checks existence (else 404) and status (else 409) under this lock before deciding.
SELECT * FROM staffing_recommendations WHERE id = $1 FOR UPDATE;
-- name: MarkRecommendationDecision :one
-- Status guarded: only a pending row can be decided, so a row that was concurrently superseded or
-- decided returns no row and the service surfaces 409 rather than overwriting a dead or decided row.
UPDATE staffing_recommendations
SET status = $2, decided_by = $3, decided_at = now(), decision_note = $4
WHERE id = $1 AND status = 'pending'
RETURNING *;
-- name: SupersedePendingGap :exec
-- A fresh gap run for a requirement supersedes ONLY the prior pending gap rows for that requirement.
-- Decided rows (approved, rejected, dismissed) are immutable and are never touched.
UPDATE staffing_recommendations sr
SET status = 'superseded'
FROM recommendation_runs rr
WHERE sr.run_id = rr.id
AND sr.organization_id = rr.organization_id
AND rr.view = 'gap'
AND sr.requirement_id = $1
AND sr.status = 'pending';
-- name: SupersedePendingPortfolio :exec
-- A fresh portfolio run supersedes ONLY the prior pending portfolio rows for the org. Decided rows are
-- immutable.
UPDATE staffing_recommendations sr
SET status = 'superseded'
FROM recommendation_runs rr
WHERE sr.run_id = rr.id
AND sr.organization_id = rr.organization_id
AND rr.view = 'portfolio'
AND sr.status = 'pending';
-- name: SupersedePendingProactive :exec
-- A fresh proactive recompute for one candidate supersedes ONLY that candidate's prior pending proactive
-- rows. Decided rows are immutable.
UPDATE staffing_recommendations sr
SET status = 'superseded'
FROM recommendation_runs rr
WHERE sr.run_id = rr.id
AND sr.organization_id = rr.organization_id
AND rr.view = 'proactive'
AND sr.candidate_id = $1
AND sr.status = 'pending';
-- name: DeleteRecommendationsForCandidate :exec
-- Right to erasure: when a candidate is anonymized or sourced-erased, their recommendation rows are
-- removed (anonymize in place does not delete the candidate row, so this is explicit, mirroring the
-- ai_memory cleanup).
DELETE FROM staffing_recommendations WHERE candidate_id = $1;
-- name: ListCommitments :many
-- A candidate is committed to a requirement when they are an approved slate member (the source of truth)
-- or have an approved W3 ASSIGN that has not yet flowed to a slate (provisional commitment). The gap view
-- reads this so a committed candidate is classified REASSIGN, never a duplicate ASSIGN.
SELECT sm.candidate_id AS candidate_id, sl.requirement_id AS requirement_id, 'slate'::text AS source
FROM slate_members sm
JOIN slates sl ON sl.id = sm.slate_id AND sl.organization_id = sm.organization_id
WHERE sm.decision = 'approved'
UNION
SELECT sr.candidate_id AS candidate_id, sr.requirement_id AS requirement_id, 'provisional'::text AS source
FROM staffing_recommendations sr
WHERE sr.action = 'assign' AND sr.status = 'approved' AND sr.candidate_id IS NOT NULL;
-- name: ListOpenRequirementsWithValue :many
-- Open requirements with their backing opportunity dollar value and its provenance, for the portfolio
-- value function. A standalone requirement (no opportunity) has a null value and is handled by the
-- documented value fallback in the optimizer.
SELECT r.*, o.value AS opportunity_value, o.value_source AS opportunity_value_source
FROM requirements r
LEFT JOIN opportunities o ON o.id = r.opportunity_id AND o.organization_id = r.organization_id
WHERE r.deleted_at IS NULL
AND (r.opportunity_id IS NULL OR o.status = 'open')
ORDER BY r.id
LIMIT $1 OFFSET $2;
-- name: GetRequirementWithValue :one
-- One requirement with its backing opportunity value, provenance, and status, for the gap view. The
-- service uses deleted_at and the opportunity status to 404 a requirement that is not a real open gap.
SELECT r.*, o.value AS opportunity_value, o.value_source AS opportunity_value_source, o.status AS opportunity_status
FROM requirements r
LEFT JOIN opportunities o ON o.id = r.opportunity_id AND o.organization_id = r.organization_id
WHERE r.id = $1;