ThatAIguyA world of ideas

THE CONSCIOUSNESS ATLAS
Read. Experiment. Follow the evidence.

ConsciousnessLearn · Explore · Joseph Anady

Janady13/missionmatch / internal/modules/ai/graph_clearance.go

Source identity, revision, and recovered contents.

GitHub sourceSource text recovered

Source identity

FieldRecorded value
Source typeGitHub source
Original recordJanady13/missionmatch / internal/modules/ai/graph_clearance.go
DateNot specified in source
RepositoryJanady13/missionmatch
Revision720d47fae476b0d38477ae4401697d372b1ea2bc
Branchfeature/opportunity-to-outcome
Path or archive memberinternal/modules/ai/graph_clearance.go
Original SHA-2566befdb01038fa476ae459ca083cf09d03bf22fe495f050ddef9b6bb77ed454f5
Git blob SHA835fa071fec07f40e54b00bb2d5238e1f4acf6db
Reading-copy SHA-2566befdb01038fa476ae459ca083cf09d03bf22fe495f050ddef9b6bb77ed454f5

Original source ↗

Every recorded occurrence

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

Original recordBranch or archiveRevision / identifierOriginal location
Janady13/missionmatch / internal/modules/ai/graph_clearance.gofeature/opportunity-to-outcome720d47fae476b0d38477ae4401697d372b1ea2bcOpen original
Janady13/missionmatch / internal/modules/ai/graph_clearance.gocollision-deconfliction4ee5a09972608ed89f8377c6665542d5f450f0a6Open original
Janady13/missionmatch / internal/modules/ai/graph_clearance.gom5-price-to-win41000ad30fff4129fdaf5ec84e15ba14c27d4890Open original
Janady13/missionmatch / internal/modules/ai/graph_clearance.gomaster1e9249840a4302ec82e123b9c9cb6f75badea3e4Open original
Janady13/missionmatch / internal/modules/ai/graph_clearance.gomag-substrateb82c7100a492dec67dfd1eda6b3f53def859be35Open original
Janady13/missionmatch / internal/modules/ai/graph_clearance.gotime-to-fill-survivalb66e1e505863d4f17741a4b9ede73509e45bd6c6Open original
Janady13/missionmatch / internal/modules/ai/graph_clearance.gographrag-foundationb0ddeb9f633fd138d09309d1a17b7d13bc3a67f7Open original
Janady13/missionmatch / internal/modules/ai/graph_clearance.gopresentation-readinesseb574acaa29d71ce4d0f852572e87c275c79fdb7Open original
Janady13/missionmatch / internal/modules/ai/graph_clearance.govendor-intelligencefe9796a19c261951d3f2565206c0c1b5ac294465Open original
Janady13/missionmatch / internal/modules/ai/graph_clearance.gophase2-connectorse038d4c687aec16f8bd9bc4d907eea14d91f8704Open original
Janady13/missionmatch / internal/modules/ai/graph_clearance.gofeature/aioe-upgrade2178e7298d0e5d9af83afa12402fd587f0ba6ed8Open original
Janady13/missionmatch / internal/modules/ai/graph_clearance.gocapture-readinessbae6af7cb2997e819174a9e9cfff5e16067a1975Open original

Recovered source transcript

package ai // G5 the clearance lattice. This file adds the clearance reachability plane as FIXED, named, // parameterized QueryIntents. Two of them are GLOBAL reference reads over the four clearance reference // tables seeded by migration 0023 (clearance_levels, polygraph_types, clearance_compartments, // clearance_reciprocity): they carry NO person data, so they need no suppression, but they follow the // same db *tenant.DB and RunInTenantTx signature as every other intent for uniformity. The third intent, // bench_clearance_coverage, intersects the global clearance_levels ladder with the RLS protected // candidates table, so it runs under RunInTenantTx (the app role sees only the caller's bench) and pipes // its partition through the deterministic small cell suppression layer before any count leaves the // process. // // The graph NEVER computes a match score, a band, or any employment decision number. The reachability // ladder reports which required levels a held level satisfies (a FACT from the rank ladder plus any // seeded reciprocity exception), and the coverage intent reports a suppressed headcount per level (a // STRUCTURAL count, never a score). The frozen engine in internal/modules/matching/engine stays the only // scorer and is untouched. The model never authors this SQL: every statement is a static, reviewed // constant, registered in the closed Registry, asserted by ValidateRegistry at boot, and re guarded by // GuardReadOnlyQuery on every execution. // // Headcounts are int (a headcount is an integer, suppressed as a unit). No float touches any surfaced // number on this plane: the reachability ladder surfaces ranks (int) and a satisfies boolean, and the // coverage intent surfaces an int headcount, so there is no ratio or aggregate that could pass through // float64. import ( "context" "errors" "github.com/jackc/pgx/v5" "github.com/missionworkforce/missionmatch/internal/platform/tenant" ) // The registered names of the three G5 clearance intents. Each is a FIXED entry in the closed Registry in // tag.go, so ValidateRegistry asserts it at boot and ExecuteIntent runs it through the same guard, tenant // transaction, and audit posture as every other TAG intent. const ( IntentClearanceReachability = "clearance_reachability" IntentCompartmentRequirement = "compartment_requirement_closure" IntentBenchClearanceCoverage = "bench_clearance_coverage" ) // clearanceReachabilitySQL returns, for a held clearance code, every required level it satisfies. The // base rule is the rank ladder (a held rank satisfies any required rank at or below it). A seeded // clearance_reciprocity row can ADD a satisfaction edge that the ladder would not grant (an agency // specific exception); it never removes one. Today clearance_reciprocity is empty, so this returns the // pure ladder, the live engine behavior. Deterministic ORDER BY on the required rank then the required // code, a total order over the cross joined levels. const clearanceReachabilitySQL = ` SELECT held.code AS held_code, req.code AS required_code, req.rank AS required_rank, (held.rank >= req.rank OR EXISTS (SELECT 1 FROM clearance_reciprocity cr WHERE cr.held_code = held.code AND cr.required_code = req.code AND cr.satisfies)) AS satisfies FROM clearance_levels held CROSS JOIN clearance_levels req WHERE held.code = $1 ORDER BY req.rank DESC, req.code ASC` // compartmentRequirementClosureSQL resolves a requirement's listed compartment codes to their kind (sci // or sap), so a compartment gap can be explained (a requirement that lists SI and TK needs those exact // SCI control systems, a requirement that lists SAP needs a special access program). The required codes // arrive as a single comma separated text parameter ($1); regexp_split_to_array splits the list on a comma // with the surrounding whitespace consumed by the pattern, so a list like "SI, TK" splits to the clean // codes, and the scalar array membership predicate (= ANY) keeps only the rows of the global // clearance_compartments reference table whose code is in the list. A listed code that is not a known // compartment simply does not match, so the closure returns only the recognized compartments (an unknown // marker is silently excluded, never fabricated). The split is a SCALAR array expression, never a FROM // clause set returning function, so the read stays over the single allowlisted clearance_compartments // table. Deterministic ORDER BY on the compartment code, a unique key over the table. const compartmentRequirementClosureSQL = ` SELECT cc.code AS compartment_code, cc.kind AS compartment_kind, cc.label AS compartment_label FROM clearance_compartments cc WHERE cc.code = ANY (regexp_split_to_array(btrim($1), '\s*,\s*')) ORDER BY cc.code ASC` // benchClearanceCoverageSQL counts DISTINCT candidates per held clearance level for the caller's org. RLS // scopes it to the caller's bench. The COUNT is a headcount; the result is a partition of the bench (every // non deleted, non anonymized candidate has exactly one clearance_level, which is FK enforced against // clearance_levels), so the cells sum to the bench size and Suppress can apply complementary suppression // correctly. The LEFT JOIN keeps a level with zero holders in the partition (a true zero), so the // partition spans every level and a suppressed cell is indistinguishable from an empty one. The soft // delete and anonymize filters mirror count_candidates_by_clearance so an erased candidate is never // counted. Deterministic ORDER BY on the level rank then the level code, a total order over the levels. const benchClearanceCoverageSQL = ` SELECT cl.code AS level_code, cl.rank AS level_rank, count(DISTINCT c.id) AS headcount FROM clearance_levels cl LEFT JOIN candidates c ON c.clearance_level = cl.code AND c.deleted_at IS NULL AND c.anonymized_at IS NULL GROUP BY cl.code, cl.rank ORDER BY cl.rank DESC, cl.code ASC` // ClearanceReach is one reachability edge: a held clearance code, a required level (its code and rank), // and whether the held level satisfies that required level (by the rank ladder or a seeded reciprocity // exception). It carries no score and no employment decision number, only the lattice fact. type ClearanceReach struct { HeldCode string `json:"held_code"` RequiredCode string `json:"required_code"` RequiredRank int `json:"required_rank"` Satisfies bool `json:"satisfies"` } // ClearanceReachability runs the registered clearance_reachability intent for a held clearance code, // returning every required level it satisfies by the rank ladder plus any seeded reciprocity exception. // It is a GLOBAL reference read (no person data), but follows the db *tenant.DB and RunInTenantTx // signature for uniformity with every other intent. func ClearanceReachability(ctx context.Context, db *tenant.DB, heldCode string) ([]ClearanceReach, error) { if db == nil { return nil, errors.New("ai: no database") } var out []ClearanceReach err := db.RunInTenantTx(ctx, func(ctx context.Context, tx pgx.Tx) error { if err := GuardReadOnlyQuery(clearanceReachabilitySQL, ReadAllowlist); err != nil { return err } rows, err := tx.Query(ctx, clearanceReachabilitySQL, heldCode) if err != nil { return err } defer rows.Close() for rows.Next() { var r ClearanceReach if err := rows.Scan(&r.HeldCode, &r.RequiredCode, &r.RequiredRank, &r.Satisfies); err != nil { return err } out = append(out, r) } return rows.Err() }) return out, err } // CompartmentReq is one resolved compartment in a requirement's closure: the compartment code, its kind // (sci or sap), and its label. It explains a compartment gap (which exact control systems a requirement // demands); it carries no score and no person data. type CompartmentReq struct { Code string `json:"compartment_code"` Kind string `json:"compartment_kind"` Label string `json:"compartment_label"` } // CompartmentRequirementClosure runs the registered compartment_requirement_closure intent. It takes a // comma separated list of required compartment codes (for example "SI,TK") and resolves each recognized // code to its kind and label over the global clearance_compartments reference table, so a compartment gap // can be explained. An unrecognized code does not join and is excluded, never fabricated. It is a GLOBAL // reference read (no person data) and follows the uniform RunInTenantTx signature. func CompartmentRequirementClosure(ctx context.Context, db *tenant.DB, compartmentList string) ([]CompartmentReq, error) { if db == nil { return nil, errors.New("ai: no database") } var out []CompartmentReq err := db.RunInTenantTx(ctx, func(ctx context.Context, tx pgx.Tx) error { if err := GuardReadOnlyQuery(compartmentRequirementClosureSQL, ReadAllowlist); err != nil { return err } rows, err := tx.Query(ctx, compartmentRequirementClosureSQL, compartmentList) if err != nil { return err } defer rows.Close() for rows.Next() { var r CompartmentReq if err := rows.Scan(&r.Code, &r.Kind, &r.Label); err != nil { return err } out = append(out, r) } return rows.Err() }) return out, err } // BenchCoverageRow is one clearance level in the bench coverage partition: the level code and rank, and // the suppressed Cell carrying the headcount. The caller renders RenderCount(Cell), never the raw Count, // so a suppressed sub k headcount renders the sentinel and never leaves the process as a number. It // carries no score and no candidate id, only a structural headcount. type BenchCoverageRow struct { LevelCode string `json:"level_code"` LevelRank int `json:"level_rank"` Cell Cell `json:"cell"` } // BenchClearanceCoverage runs the registered bench_clearance_coverage intent under RLS (the app role sees // only the caller's bench), counting DISTINCT candidates per clearance level, then pipes the partition // through Suppress with the caller supplied threshold k (the caller passes ConfiguredSuppressionThreshold). // Because every candidate has exactly one FK enforced clearance level, the cells form a partition of the // bench, so the counts sum to the bench size and complementary suppression is well defined. The suppressed // cells are written back onto the rows; the caller renders RenderCount, never the raw Count, for a // suppressed cell. This is the FIRST person touching read on the clearance plane, so it is RLS scoped and // suppressed by construction. func BenchClearanceCoverage(ctx context.Context, db *tenant.DB, k int) ([]BenchCoverageRow, error) { if db == nil { return nil, errors.New("ai: no database") } var out []BenchCoverageRow err := db.RunInTenantTx(ctx, func(ctx context.Context, tx pgx.Tx) error { if err := GuardReadOnlyQuery(benchClearanceCoverageSQL, ReadAllowlist); err != nil { return err } rows, err := tx.Query(ctx, benchClearanceCoverageSQL) if err != nil { return err } defer rows.Close() for rows.Next() { var ( r BenchCoverageRow headcount int ) if err := rows.Scan(&r.LevelCode, &r.LevelRank, &headcount); err != nil { return err } r.Cell = Cell{Key: []string{r.LevelCode}, Count: headcount} out = append(out, r) } return rows.Err() }) if err != nil { return nil, err } // Apply suppression over the partition before returning. The caller renders RenderCount, never the // raw Count, for a suppressed cell, so a sub k headcount never leaves the process as a number. cells := make([]Cell, len(out)) for i := range out { cells[i] = out[i].Cell } cells = Suppress(cells, k) for i := range out { out[i].Cell = cells[i] } return out, nil }

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