Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/missionmatch / db/migrations/0036_learned_models.sql |
| Date | Not specified in source |
| Repository | Janady13/missionmatch |
| Revision | 720d47fae476b0d38477ae4401697d372b1ea2bc |
| Branch | feature/opportunity-to-outcome |
| Path or archive member | db/migrations/0036_learned_models.sql |
| Original SHA-256 | fe650c226fd9da9d351349152c2a76c87234aec040a20038876e1bb96eefe93e |
| Git blob SHA | 767e2b051b8e0ba7668738fe8d419adec72c866f |
| Reading-copy SHA-256 | fe650c226fd9da9d351349152c2a76c87234aec040a20038876e1bb96eefe93e |
Every recorded occurrence
These 10 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/migrations/0036_learned_models.sql | feature/opportunity-to-outcome | 720d47fae476b0d38477ae4401697d372b1ea2bc | Open original |
| Janady13/missionmatch / db/migrations/0036_learned_models.sql | collision-deconfliction | 4ee5a09972608ed89f8377c6665542d5f450f0a6 | Open original |
| Janady13/missionmatch / db/migrations/0036_learned_models.sql | master | 1e9249840a4302ec82e123b9c9cb6f75badea3e4 | Open original |
| Janady13/missionmatch / db/migrations/0036_learned_models.sql | mag-substrate | b82c7100a492dec67dfd1eda6b3f53def859be35 | Open original |
| Janady13/missionmatch / db/migrations/0036_learned_models.sql | time-to-fill-survival | b66e1e505863d4f17741a4b9ede73509e45bd6c6 | Open original |
| Janady13/missionmatch / db/migrations/0036_learned_models.sql | presentation-readiness | eb574acaa29d71ce4d0f852572e87c275c79fdb7 | Open original |
| Janady13/missionmatch / db/migrations/0036_learned_models.sql | vendor-intelligence | fe9796a19c261951d3f2565206c0c1b5ac294465 | Open original |
| Janady13/missionmatch / db/migrations/0036_learned_models.sql | phase2-connectors | e038d4c687aec16f8bd9bc4d907eea14d91f8704 | Open original |
| Janady13/missionmatch / db/migrations/0036_learned_models.sql | feature/aioe-upgrade | 2178e7298d0e5d9af83afa12402fd587f0ba6ed8 | Open original |
| Janady13/missionmatch / db/migrations/0036_learned_models.sql | capture-readiness | bae6af7cb2997e819174a9e9cfff5e16067a1975 | Open original |
Recovered source transcript
Download complete source text ↓115 lines · 7.9 KB
-- +goose Up
-- The MAG (Model Augmented Generation) substrate coefficient and calibration store. Run as the BYPASSRLS
-- migrator role. These three tables are the ONE shared serving surface every future learned capability
-- (win probability, the display order reranker, hazard and retention timing, price to win refinements)
-- reads from: an interpretable set of numeric coefficients plus a monotone calibration map, scored into
-- shopspring/decimal in Go at request time, so serving needs no second datastore, no cloud ML service, and
-- no Python. They mirror aedt_model_versions (migration 0010): GLOBAL (no organization_id, no RLS), migrator
-- owned, SELECT granted to missionmatch_app AND missionmatch_compliance, and the migrator is the only writer.
-- The app can read the champion coefficients to serve, the compliance role can read them to audit, neither
-- can INSERT, UPDATE, or DELETE (a challenger version and a champion flip are governance actions written by
-- the migrator, never by the request path).
--
-- The output_kind CHECK is the structural mechanism that keeps the frozen decimal engine
-- (internal/modules/matching, ModelVersion v1.4.0) the ONLY per candidate scorer: a learned model may emit
-- ONLY one of opportunity_score, display_order, or confidence, and the constraint refuses any other value at
-- the database, so a candidate score is impossible to store here by construction. The feature_spec lists the
-- feature names and their source intents; it references NO eeo marker and NO protected attribute (the
-- ValidateRegistry MAG branch and GuardReadOnlyQuery enforce that at boot and at serve time).
-- ---------------------------------------------------------------------------
-- aedt_learned_models: the champion and challenger registry for the MAG surface. One row per (model_key,
-- version). The champion flag marks the served version; a partial UNIQUE index enforces at most one champion
-- per model_key, so exactly one version serves and a flip is a single row write by the migrator. The
-- feature_spec jsonb records the feature names and the Registry source intent each feature reads from, so the
-- served model is fully interpretable and the ValidateRegistry MAG branch can assert the spec names no eeo
-- marker and only Registry intents.
-- ---------------------------------------------------------------------------
CREATE TABLE aedt_learned_models (
model_key text NOT NULL,
version int NOT NULL,
family text NOT NULL,
output_kind text NOT NULL CHECK (output_kind IN ('opportunity_score', 'display_order', 'confidence')),
feature_spec jsonb NOT NULL DEFAULT '{}',
effective_from timestamptz NOT NULL DEFAULT now(),
champion boolean NOT NULL DEFAULT false,
notes text NOT NULL DEFAULT '',
PRIMARY KEY (model_key, version)
);
-- At most one champion per model_key: the served version is unique by construction.
CREATE UNIQUE INDEX uq_learned_models_champion ON aedt_learned_models (model_key) WHERE champion;
GRANT SELECT ON aedt_learned_models TO missionmatch_app;
GRANT SELECT ON aedt_learned_models TO missionmatch_compliance;
-- ---------------------------------------------------------------------------
-- aedt_model_coefficients: the interpretable numeric coefficients of a model version. One row per
-- (model_key, version, feature_name), coefficient a numeric(20,10) so a beta scans into shopspring/decimal
-- exact, never float. The reserved feature_name 'intercept' carries the bias term (the log odds base rate);
-- every real feature carries its own row. The prior only v0 stores the intercept plus every real feature at
-- 0.0, so the model reads a defensible base rate the day it ships and a learned coefficient lights up
-- automatically once a trainer fits it.
-- ---------------------------------------------------------------------------
CREATE TABLE aedt_model_coefficients (
model_key text NOT NULL,
version int NOT NULL,
feature_name text NOT NULL,
coefficient numeric(20,10) NOT NULL,
PRIMARY KEY (model_key, version, feature_name)
);
GRANT SELECT ON aedt_model_coefficients TO missionmatch_app;
GRANT SELECT ON aedt_model_coefficients TO missionmatch_compliance;
-- ---------------------------------------------------------------------------
-- aedt_calibration_bins: the monotone calibration map of a model version, one row per bin. Each bin maps a
-- raw probability range [bin_lo, bin_hi] to an empirical_rate, so a raw logistic probability is remapped to
-- a calibrated one at serve time. All three figures are numeric so they scan into shopspring/decimal exact,
-- never float. The prior only v0 seeds NO calibration bins on purpose: the serve side treats an empty bin
-- set as the identity map (the raw probability passes through unchanged), which is the honest calibration for
-- a prior only model with no held out labels to fit an isotonic map from. A trainer writes real bins later.
-- ---------------------------------------------------------------------------
CREATE TABLE aedt_calibration_bins (
model_key text NOT NULL,
version int NOT NULL,
bin_index int NOT NULL,
bin_lo numeric(12,8) NOT NULL,
bin_hi numeric(12,8) NOT NULL,
empirical_rate numeric(12,8) NOT NULL,
PRIMARY KEY (model_key, version, bin_index)
);
GRANT SELECT ON aedt_calibration_bins TO missionmatch_app;
GRANT SELECT ON aedt_calibration_bins TO missionmatch_compliance;
-- ---------------------------------------------------------------------------
-- Seed the prior only opportunity win probability v0 champion. It is a logistic model whose OutputKind is
-- opportunity_score (never a candidate score). The feature_spec lists every feature and the Registry source
-- intent it reads from; for v0 the only bound feature is the segment base rate from the bid_win_rate_by_segment
-- intent (the market base rate this prior shrinks toward). The intercept is the logit of a defensible federal
-- recompete base rate of 0.60, so logit(0.60) is ln(0.60 / 0.40), approximately 0.4054651081. Every real
-- feature coefficient is 0.0 (prior only, no learned signal yet), so the model returns the calibrated base
-- rate the day it ships and its learned coefficients light up automatically as labels accrue.
-- ---------------------------------------------------------------------------
INSERT INTO aedt_learned_models (model_key, version, family, output_kind, feature_spec, champion, notes) VALUES (
'opportunity_win_probability',
1,
'logistic',
'opportunity_score',
'{"features": [{"name": "segment_base_rate", "source_intent": "bid_win_rate_by_segment", "column": "win_rate"}]}',
true,
'Prior only v0. The intercept is the logit of a defensible federal recompete base rate of 0.60; every real feature coefficient is 0.0, so the model returns the calibrated market base rate the day it ships. Learned coefficients light up automatically as decided bid labels accrue per segment. OutputKind opportunity_score, never a candidate score; the frozen v1.4.0 engine stays the only per candidate scorer.'
) ON CONFLICT (model_key, version) DO NOTHING;
-- The intercept (the logit of the 0.60 base rate) and every real feature coefficient at 0.0 (prior only).
INSERT INTO aedt_model_coefficients (model_key, version, feature_name, coefficient) VALUES
('opportunity_win_probability', 1, 'intercept', 0.4054651081),
('opportunity_win_probability', 1, 'segment_base_rate', 0.0000000000)
ON CONFLICT (model_key, version, feature_name) DO NOTHING;
-- No calibration bins for v0: the serve side treats an empty bin set as the identity map (the raw
-- probability passes through unchanged), the honest calibration for a prior only model with no held out
-- labels. A trainer writes real isotonic bins for a later version.
-- +goose Down
DROP TABLE IF EXISTS aedt_calibration_bins;
DROP TABLE IF EXISTS aedt_model_coefficients;
DROP TABLE IF EXISTS aedt_learned_models;