Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/missionmatch / internal/modules/ai/bid_baserate.go |
| Date | Not specified in source |
| Repository | Janady13/missionmatch |
| Revision | 720d47fae476b0d38477ae4401697d372b1ea2bc |
| Branch | feature/opportunity-to-outcome |
| Path or archive member | internal/modules/ai/bid_baserate.go |
| Original SHA-256 | d3dc5d91800777b16267637985052612d0460065ae3f724edab209e0a3af4e8b |
| Git blob SHA | d02a615cc9090d1f7debe6db2c1298b1b36c2688 |
| Reading-copy SHA-256 | d3dc5d91800777b16267637985052612d0460065ae3f724edab209e0a3af4e8b |
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/ai/bid_baserate.go | feature/opportunity-to-outcome | 720d47fae476b0d38477ae4401697d372b1ea2bc | Open original |
| Janady13/missionmatch / internal/modules/ai/bid_baserate.go | collision-deconfliction | 4ee5a09972608ed89f8377c6665542d5f450f0a6 | Open original |
| Janady13/missionmatch / internal/modules/ai/bid_baserate.go | m5-price-to-win | 41000ad30fff4129fdaf5ec84e15ba14c27d4890 | Open original |
| Janady13/missionmatch / internal/modules/ai/bid_baserate.go | master | 1e9249840a4302ec82e123b9c9cb6f75badea3e4 | Open original |
| Janady13/missionmatch / internal/modules/ai/bid_baserate.go | mag-substrate | b82c7100a492dec67dfd1eda6b3f53def859be35 | Open original |
| Janady13/missionmatch / internal/modules/ai/bid_baserate.go | time-to-fill-survival | b66e1e505863d4f17741a4b9ede73509e45bd6c6 | Open original |
| Janady13/missionmatch / internal/modules/ai/bid_baserate.go | graphrag-foundation | b0ddeb9f633fd138d09309d1a17b7d13bc3a67f7 | Open original |
| Janady13/missionmatch / internal/modules/ai/bid_baserate.go | presentation-readiness | eb574acaa29d71ce4d0f852572e87c275c79fdb7 | Open original |
| Janady13/missionmatch / internal/modules/ai/bid_baserate.go | vendor-intelligence | fe9796a19c261951d3f2565206c0c1b5ac294465 | Open original |
| Janady13/missionmatch / internal/modules/ai/bid_baserate.go | phase2-connectors | e038d4c687aec16f8bd9bc4d907eea14d91f8704 | Open original |
| Janady13/missionmatch / internal/modules/ai/bid_baserate.go | feature/aioe-upgrade | 2178e7298d0e5d9af83afa12402fd587f0ba6ed8 | Open original |
| Janady13/missionmatch / internal/modules/ai/bid_baserate.go | capture-readiness | bae6af7cb2997e819174a9e9cfff5e16067a1975 | Open original |
Recovered source transcript
Download complete source text ↓42 lines · 3.0 KB
package ai
// M7 bid outcomes advisory base rate (a TAG aggregate intent, NOT a graph intent and NOT a bench intent).
// bid_win_rate_by_segment reports an advisory MARKET base rate over the caller's own bid_outcomes ledger:
// per customer agency segment (read from the linked requirement), the win count, the total decided (win
// plus loss, the denominator that excludes pending and no_bid), and the win rate as a numeric ratio. It is
// advisory context for a capture team, explicitly NOT a candidate score and NOT an employment decision
// number; the frozen matching engine stays the only scorer and no learned model consumes this read yet.
//
// Honesty and safety are enforced by construction. The denominator counts only decided bids (win plus
// loss), so a pending or no_bid bid never inflates or deflates the rate. The ratio is computed in SQL as a
// numeric divided by a numeric guarded with NULLIF so a segment with no decided bid yields a NULL rate, not
// a divide by zero; the Go side scans that ratio into a shopspring/decimal pointer (a NULL rate is a nil
// pointer), never a float64. It reads only bid_outcomes and requirements, both allowlisted tenant tables,
// never a person table, never a score, never the eeo schema. It takes no SQL parameter: it reports every
// segment of the caller's ledger, RLS scoped so one tenant's win rate can never surface in another's.
//
// The SQL is a reviewed static constant. ValidateRegistry asserts it through GuardReadOnlyQuery at boot and
// a unit test, and ExecuteIntent re guards it on every execution, so it can only ever run as a single read
// only SELECT over the allowlisted tables.
// IntentBidWinRateBySegment is the registered name of the advisory bid win rate base rate read.
const IntentBidWinRateBySegment = "bid_win_rate_by_segment"
// bidWinRateBySegmentSQL aggregates the caller's bid_outcomes by the customer agency of the linked
// requirement. The LEFT JOIN keeps outcomes whose requirement link is null (or whose requirement has no
// customer agency) under an "(unspecified)" segment label rather than dropping them. The denominator
// total_decided counts only win plus loss; the win rate is win_count over total_decided guarded with NULLIF
// so a segment with zero decided bids returns a NULL ratio, never a divide by zero. The numeric cast keeps
// the ratio exact for the shopspring/decimal scan in Go. Ordered by total decided descending with a segment
// tiebreaker for a stable, byte deterministic result.
const bidWinRateBySegmentSQL = `SELECT
COALESCE(NULLIF(r.customer_agency, ''), '(unspecified)') AS customer_agency,
count(*) FILTER (WHERE b.result = 'win') AS win_count,
count(*) FILTER (WHERE b.result IN ('win', 'loss')) AS total_decided,
(count(*) FILTER (WHERE b.result = 'win'))::numeric
/ NULLIF(count(*) FILTER (WHERE b.result IN ('win', 'loss')), 0) AS win_rate
FROM bid_outcomes b
LEFT JOIN requirements r ON r.id = b.requirement_id
GROUP BY COALESCE(NULLIF(r.customer_agency, ''), '(unspecified)')
ORDER BY total_decided DESC, customer_agency`