ThatAIguyA world of ideas

THE CONSCIOUSNESS ATLAS
Read. Experiment. Follow the evidence.

ConsciousnessLearn · Explore · Joseph Anady

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

Source identity, revision, and recovered contents.

GitHub sourceSource text recovered

Source identity

FieldRecorded value
Source typeGitHub source
Original recordJanady13/missionmatch / internal/modules/ai/safety_test.go
DateNot specified in source
RepositoryJanady13/missionmatch
Revision5d5ddff70393a197c5f54a45280bb5dd42b24755
Branchai-intelligence-layer
Path or archive memberinternal/modules/ai/safety_test.go
Original SHA-25679a86bac6e33a9a2b5954d823eb634019c1fbb8306d6ceee6438146f44a7ec18
Git blob SHAcb759d6a6d2e91895939e650235875a4e9deec57
Reading-copy SHA-25679a86bac6e33a9a2b5954d823eb634019c1fbb8306d6ceee6438146f44a7ec18

Original source ↗

Recovered source transcript

package ai import ( "errors" "os" "path/filepath" "strings" "testing" ) func TestForbidEEORejectsDemographics(t *testing.T) { bad := []string{ "SELECT * FROM eeo.candidate_demographics", "select gender, race_ethnicity from eeo.candidate_demographics", "join EEO.candidate_demographics on true", "the candidate's veteran_status is", } for _, s := range bad { if err := ForbidEEO(s); !errors.Is(err, ErrEEOForbidden) { t.Errorf("ForbidEEO(%q) must refuse the eeo schema, got %v", s, err) } } if err := ForbidEEO("SELECT full_name FROM candidates WHERE clearance_level='secret'"); err != nil { t.Errorf("a clean query must pass: %v", err) } } func TestGuardReadOnlyQuery(t *testing.T) { bad := map[string]string{ "insert": "INSERT INTO candidates (full_name) VALUES ('x')", "update": "UPDATE candidates SET available=true", "delete": "DELETE FROM candidates", "stacked": "SELECT 1 FROM candidates; DROP TABLE candidates", "eeo read": "SELECT gender FROM eeo.candidate_demographics", "hidden write in cte": "WITH x AS (DELETE FROM candidates RETURNING id) SELECT * FROM x", "non allowlisted": "SELECT * FROM auth_credentials", } for name, sql := range bad { if err := GuardReadOnlyQuery(sql, ReadAllowlist); err == nil { t.Errorf("GuardReadOnlyQuery must refuse %q", name) } } ok := []string{ "SELECT full_name, clearance_level FROM candidates WHERE available = true", "WITH ranked AS (SELECT id FROM slate_members) SELECT count(*) FROM ranked", "SELECT c.full_name FROM candidates c JOIN candidate_skills cs ON cs.candidate_id = c.id", } for _, sql := range ok { if err := GuardReadOnlyQuery(sql, ReadAllowlist); err != nil { t.Errorf("a clean allowlisted read must pass: %q: %v", sql, err) } } } // TestRegistryIsSafe asserts every curated TAG intent is read only, allowlisted, and eeo free, so an // unsafe intent cannot ship even if added by mistake. func TestRegistryIsSafe(t *testing.T) { if err := ValidateRegistry(); err != nil { t.Fatalf("a TAG intent is unsafe: %v", err) } if len(Registry) == 0 { t.Fatal("the TAG registry is empty; the safety check is a no op") } } // TestNoAIFileReferencesEEO is the required tripwire: it walks every Go file in the AI package and fails // if any of them, other than the prohibition guard (safety.go) and the tests, names the eeo schema or a // demographic column. No embedding, retrieval, graph, memory, generated query, or prompt builder in this // package may reach demographics; this test makes that hold by construction, not by review. func TestNoAIFileReferencesEEO(t *testing.T) { markers := []string{"eeo.", "candidate_demographics", "race_ethnicity", "veteran_status", "disability_status", "from eeo", "join eeo"} entries, err := os.ReadDir(".") if err != nil { t.Fatalf("read package dir: %v", err) } checked := 0 for _, e := range entries { name := e.Name() if !strings.HasSuffix(name, ".go") { continue } // safety.go IS the prohibition guard (it must name eeo to forbid it); tests describe the rule. if name == "safety.go" || strings.HasSuffix(name, "_test.go") { continue } body, err := os.ReadFile(filepath.Clean(name)) if err != nil { t.Fatalf("read %s: %v", name, err) } // The package doc permits naming eeo in a prohibition COMMENT (this is the rule being documented); // only a CODE reference is a reach. Drop comment lines, then scan the executable content. var code strings.Builder for _, line := range strings.Split(string(body), "\n") { if strings.HasPrefix(strings.TrimSpace(line), "//") { continue } code.WriteString(strings.ToLower(line)) code.WriteByte('\n') } lower := code.String() for _, m := range markers { if strings.Contains(lower, m) { t.Errorf("EEO REACH: %s contains %q in executable code; no AI path may name the eeo schema", name, m) } } checked++ } if checked == 0 { t.Fatal("no AI source files were scanned; the tripwire is not actually running") } t.Logf("scanned %d AI source files, none reach eeo", checked) }

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