ThatAIguyA world of ideas

THE CONSCIOUSNESS ATLAS
Read. Experiment. Follow the evidence.

ConsciousnessLearn · Explore · Joseph Anady

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

Source identity, revision, and recovered contents.

GitHub sourceSource text recovered

Source identity

FieldRecorded value
Source typeGitHub source
Original recordJanady13/missionmatch / internal/modules/ai/tag.go
DateNot specified in source
RepositoryJanady13/missionmatch
Revision43d56387270ef4da4cabd794d97ca6a49909bc7d
Branchw3-ai-staffing-recommendations
Path or archive memberinternal/modules/ai/tag.go
Original SHA-25632cb6bf6bca13e0b11e4be72ed3370faee345806bb1d25066bcc189674072ff8
Git blob SHA216ff56da04076c361747264d133fdaa63e0da30
Reading-copy SHA-25632cb6bf6bca13e0b11e4be72ed3370faee345806bb1d25066bcc189674072ff8

Original source ↗

Every recorded occurrence

These 25 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/tag.gow3-ai-staffing-recommendations43d56387270ef4da4cabd794d97ca6a49909bc7dOpen original
Janady13/missionmatch / internal/modules/ai/tag.gows3-clearance4b8e7ce594c068621867f9c9deed0ec64ae6c553Open original
Janady13/missionmatch / internal/modules/ai/tag.goai-intelligence-layer5d5ddff70393a197c5f54a45280bb5dd42b24755Open original
Janady13/missionmatch / internal/modules/ai/tag.gows7-federal-signal6a9f6ce9cfb13345ffb47770d4960e7c2d9c17c2Open original
Janady13/missionmatch / internal/modules/ai/tag.gows6-retrieval6c56e29231ec05735927fa265c97d517499dfeafOpen original
Janady13/missionmatch / internal/modules/ai/tag.goper-tenant-routing9bde0f9a74b89d01980fa658e5253acda7528d0cOpen original
Janady13/missionmatch / internal/modules/ai/tag.goai-brain-liveaac32fc49c878cc5bca099459307611562d0bac1Open original
Janady13/missionmatch / internal/modules/ai/tag.gows1-ontology-syncb596f449a32a1016fbd403c36505cc00a1ac9ee6Open original
Janady13/missionmatch / internal/modules/ai/tag.godeploy-and-opsbdacd9d0b4d5998d25fc74bf4007f4c3ec538c7aOpen original
Janady13/missionmatch / internal/modules/ai/tag.gows8-teaching-loopc823f0fb6bb2aba0f39001eb6de96f4000d9321fOpen original
Janady13/missionmatch / internal/modules/ai/tag.gophase2-eval-fairnessd361af254701975fe239927656ababb56374655eOpen original
Janady13/missionmatch / internal/modules/ai/tag.gows2-alias-relationshipe4dada4601c6eb101830f9d223a9655dfa120616Open original
Janady13/missionmatch / internal/modules/ai/tag.gows9-bench-ingestionf585a9ef32fa554663ce1fba9a414a54b6e49cf0Open original
Janady13/missionmatch / internal/modules/ai/tag.goper-tenant-routing9bde0f9a74b89d01980fa658e5253acda7528d0cOpen original
Janady13/missionmatch / internal/modules/ai/tag.gows6-retrieval6c56e29231ec05735927fa265c97d517499dfeafOpen original
Janady13/missionmatch / internal/modules/ai/tag.gows1-ontology-syncb596f449a32a1016fbd403c36505cc00a1ac9ee6Open original
Janady13/missionmatch / internal/modules/ai/tag.gows8-teaching-loopc823f0fb6bb2aba0f39001eb6de96f4000d9321fOpen original
Janady13/missionmatch / internal/modules/ai/tag.gow3-ai-staffing-recommendations43d56387270ef4da4cabd794d97ca6a49909bc7dOpen original
Janady13/missionmatch / internal/modules/ai/tag.gows3-clearance4b8e7ce594c068621867f9c9deed0ec64ae6c553Open original
Janady13/missionmatch / internal/modules/ai/tag.gophase2-eval-fairnessd361af254701975fe239927656ababb56374655eOpen original
Janady13/missionmatch / internal/modules/ai/tag.goai-intelligence-layer5d5ddff70393a197c5f54a45280bb5dd42b24755Open original
Janady13/missionmatch / internal/modules/ai/tag.godeploy-and-opsbdacd9d0b4d5998d25fc74bf4007f4c3ec538c7aOpen original
Janady13/missionmatch / internal/modules/ai/tag.gows2-alias-relationshipe4dada4601c6eb101830f9d223a9655dfa120616Open original
Janady13/missionmatch / internal/modules/ai/tag.gows7-federal-signal6a9f6ce9cfb13345ffb47770d4960e7c2d9c17c2Open original
Janady13/missionmatch / internal/modules/ai/tag.goai-brain-liveaac32fc49c878cc5bca099459307611562d0bac1Open original

Recovered source transcript

package ai import ( "context" "errors" "fmt" "github.com/jackc/pgx/v5" "github.com/missionworkforce/missionmatch/internal/platform/tenant" ) // TAG (table augmented generation) answers questions that require the database to COMPUTE (count, sum, // filter, aggregate), which retrieval over text cannot do. The research is explicit that aggregation // questions must go to the database, not to vector RAG (docs/AI_RESEARCH.md, TAG). // // For cleared data the safe design is structured tool use, NOT free form natural language to SQL: the // model selects from a CURATED set of named, parameterized, read only intents and supplies typed // parameters. The model never authors SQL. Every intent is validated at startup against the read only // guard and the table allowlist, and references no eeo table, so a write or a demographics read is // impossible from the natural language path by construction. // ParamKind constrains an intent parameter so a model supplied value is type checked before binding. type ParamKind string const ( ParamText ParamKind = "text" ParamInt ParamKind = "int" ParamUUID ParamKind = "uuid" ParamEnum ParamKind = "enum" // value must be in Allowed ParamBoolean ParamKind = "bool" ) // Param describes one bound parameter of an intent. type Param struct { Name string Kind ParamKind Allowed []string // for ParamEnum } // QueryIntent is one safe, named, read only question the TAG layer can answer. SQL is parameterized // ($1, $2, ...) and runs RLS scoped as the application role, so it sees only the caller's tenant. type QueryIntent struct { Name string Description string // what question it answers, used for model routing SQL string Params []Param } // Registry is the closed set of TAG intents. Adding one is a reviewed security decision. var Registry = []QueryIntent{ { Name: "count_candidates_by_clearance", Description: "How many candidates hold a given clearance level (and optionally are available).", SQL: "SELECT clearance_level, count(*) AS n FROM candidates WHERE deleted_at IS NULL AND anonymized_at IS NULL AND ($1 = '' OR clearance_level = $1) GROUP BY clearance_level ORDER BY n DESC", Params: []Param{{Name: "clearance_level", Kind: ParamEnum, Allowed: []string{"", "none", "confidential", "secret", "top_secret", "ts_sci"}}}, }, { Name: "proposal_ready_for_requirement", Description: "How many persisted evaluations for a requirement are in the Green (proposal ready) band.", SQL: "SELECT band, count(*) AS n FROM candidate_evaluations WHERE requirement_id = $1 GROUP BY band ORDER BY n DESC", Params: []Param{{Name: "requirement_id", Kind: ParamUUID}}, }, { Name: "open_requirements_count", Description: "How many requirements are open (not soft deleted), optionally for one customer agency.", SQL: "SELECT count(*) AS n FROM requirements WHERE deleted_at IS NULL AND ($1 = '' OR customer_agency = $1)", Params: []Param{{Name: "customer_agency", Kind: ParamText}}, }, { Name: "slate_decision_mix", Description: "The approve/reject/pending decision mix of a slate's members.", SQL: "SELECT decision, count(*) AS n FROM slate_members WHERE slate_id = $1 GROUP BY decision ORDER BY n DESC", Params: []Param{{Name: "slate_id", Kind: ParamUUID}}, }, } // ValidateRegistry asserts every intent is safe: read only, references no eeo, and touches only // allowlisted tables. It is called at startup and by a test, so an unsafe intent cannot ship. func ValidateRegistry() error { for _, it := range Registry { if err := GuardReadOnlyQuery(it.SQL, ReadAllowlist); err != nil { return fmt.Errorf("ai: intent %q is unsafe: %w", it.Name, err) } } return nil } // IntentByName returns a registered intent. func IntentByName(name string) (QueryIntent, bool) { for _, it := range Registry { if it.Name == name { return it, true } } return QueryIntent{}, false } // TAGResult is the executed answer: the column names and the rows, ready to narrate. It carries no free // text from the model, only data the database returned. type TAGResult struct { Intent string Columns []string Rows [][]any } // ExecuteIntent binds the model supplied args (in the order of Params) and runs the intent RLS scoped as // the tenant. It re validates the SQL through the guard at execution time too (defense in depth), so even // a tampered registry cannot run a write or reach eeo. func ExecuteIntent(ctx context.Context, db *tenant.DB, intent QueryIntent, args []any) (*TAGResult, error) { if db == nil { return nil, errors.New("ai: no database") } if err := GuardReadOnlyQuery(intent.SQL, ReadAllowlist); err != nil { return nil, err } if len(args) != len(intent.Params) { return nil, fmt.Errorf("ai: intent %q expects %d params, got %d", intent.Name, len(intent.Params), len(args)) } out := &TAGResult{Intent: intent.Name} err := db.RunInTenantTx(ctx, func(ctx context.Context, tx pgx.Tx) error { rows, err := tx.Query(ctx, intent.SQL, args...) if err != nil { return err } defer rows.Close() for _, fd := range rows.FieldDescriptions() { out.Columns = append(out.Columns, string(fd.Name)) } for rows.Next() { vals, err := rows.Values() if err != nil { return err } out.Rows = append(out.Rows, vals) } return rows.Err() }) if err != nil { return nil, err } return out, nil }

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