Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/missionmatch / internal/modules/bidoutcomes/repo.go |
| Date | Not specified in source |
| Repository | Janady13/missionmatch |
| Revision | 720d47fae476b0d38477ae4401697d372b1ea2bc |
| Branch | feature/opportunity-to-outcome |
| Path or archive member | internal/modules/bidoutcomes/repo.go |
| Original SHA-256 | 4c9b3045c568289f1578dc1b4291bef082ef70c105817ca1459adb94e8d9af6c |
| Git blob SHA | ff7148a60f79f90e8c38d6684cf3a0b888950b8f |
| Reading-copy SHA-256 | 4c9b3045c568289f1578dc1b4291bef082ef70c105817ca1459adb94e8d9af6c |
Every recorded occurrence
These 12 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/bidoutcomes/repo.go | feature/opportunity-to-outcome | 720d47fae476b0d38477ae4401697d372b1ea2bc | Open original |
| Janady13/missionmatch / internal/modules/bidoutcomes/repo.go | collision-deconfliction | 4ee5a09972608ed89f8377c6665542d5f450f0a6 | Open original |
| Janady13/missionmatch / internal/modules/bidoutcomes/repo.go | m5-price-to-win | 41000ad30fff4129fdaf5ec84e15ba14c27d4890 | Open original |
| Janady13/missionmatch / internal/modules/bidoutcomes/repo.go | master | 1e9249840a4302ec82e123b9c9cb6f75badea3e4 | Open original |
| Janady13/missionmatch / internal/modules/bidoutcomes/repo.go | mag-substrate | b82c7100a492dec67dfd1eda6b3f53def859be35 | Open original |
| Janady13/missionmatch / internal/modules/bidoutcomes/repo.go | time-to-fill-survival | b66e1e505863d4f17741a4b9ede73509e45bd6c6 | Open original |
| Janady13/missionmatch / internal/modules/bidoutcomes/repo.go | graphrag-foundation | b0ddeb9f633fd138d09309d1a17b7d13bc3a67f7 | Open original |
| Janady13/missionmatch / internal/modules/bidoutcomes/repo.go | presentation-readiness | eb574acaa29d71ce4d0f852572e87c275c79fdb7 | Open original |
| Janady13/missionmatch / internal/modules/bidoutcomes/repo.go | vendor-intelligence | fe9796a19c261951d3f2565206c0c1b5ac294465 | Open original |
| Janady13/missionmatch / internal/modules/bidoutcomes/repo.go | phase2-connectors | e038d4c687aec16f8bd9bc4d907eea14d91f8704 | Open original |
| Janady13/missionmatch / internal/modules/bidoutcomes/repo.go | feature/aioe-upgrade | 2178e7298d0e5d9af83afa12402fd587f0ba6ed8 | Open original |
| Janady13/missionmatch / internal/modules/bidoutcomes/repo.go | capture-readiness | bae6af7cb2997e819174a9e9cfff5e16067a1975 | Open original |
Recovered source transcript
Download complete source text ↓44 lines · 2.6 KB
package bidoutcomes
// repo.go holds the parameterized SQL the service runs under RunInTenantTx (RLS scoped). The statements are
// raw and parameterized rather than sqlc generated so the M7 ledger is self contained and does not require
// regenerating the dbgen package for one new table; this mirrors the AI graph layer, which authors its
// reviewed read SQL as static constants. Every statement runs as the NOBYPASSRLS app role inside a tenant
// transaction, so the organization_id is the session GUC and a row in another org is never visible or
// writable (the RLS policy plus the composite FKs both hold). The app role has SELECT, INSERT, UPDATE on
// bid_outcomes and no DELETE, so the ledger is never destroyed.
// insertOrUpsertOutcomeSQL records a new bid outcome, or upserts an existing one keyed on its id. The
// organization_id is taken from the session GUC (never a caller argument), so RLS WITH CHECK confirms the
// row belongs to the caller; the ON CONFLICT update only ever touches a row already visible to this tenant.
const insertOrUpsertOutcomeSQL = `
INSERT INTO bid_outcomes
(id, organization_id, opportunity_id, requirement_id, slate_id, submitted_at, result, award_date, awardee_uei, notes)
VALUES
(COALESCE($1, gen_random_uuid()), NULLIF(current_setting('app.current_org_id', true), '')::uuid, $2, $3, $4, $5, $6, $7, $8, $9)
ON CONFLICT (id) DO UPDATE SET
opportunity_id = EXCLUDED.opportunity_id,
requirement_id = EXCLUDED.requirement_id,
slate_id = EXCLUDED.slate_id,
submitted_at = EXCLUDED.submitted_at,
result = EXCLUDED.result,
award_date = EXCLUDED.award_date,
awardee_uei = EXCLUDED.awardee_uei,
notes = EXCLUDED.notes,
updated_at = now()
RETURNING id, opportunity_id, requirement_id, slate_id, submitted_at, result, award_date, awardee_uei, notes, created_at, updated_at`
// updateOutcomeSQL updates the result and award fields of an existing outcome. COALESCE keeps the existing
// submitted_at and award_date when the bind is null, so a partial update never wipes a known timestamp. The
// UPDATE is RLS scoped, so a row in another org is invisible and matches zero rows (the not found path).
const updateOutcomeSQL = `
UPDATE bid_outcomes SET
result = $2,
submitted_at = COALESCE($3, submitted_at),
award_date = COALESCE($4, award_date),
awardee_uei = $5,
notes = $6,
updated_at = now()
WHERE id = $1
RETURNING id, opportunity_id, requirement_id, slate_id, submitted_at, result, award_date, awardee_uei, notes, created_at, updated_at`