ThatAIguyA world of ideas

THE CONSCIOUSNESS ATLAS
Read. Experiment. Follow the evidence.

ConsciousnessLearn · Explore · Joseph Anady

Janady13/missionmatch / internal/modules/ai/feed_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/feed_test.go
DateNot specified in source
RepositoryJanady13/missionmatch
Revision720d47fae476b0d38477ae4401697d372b1ea2bc
Branchfeature/opportunity-to-outcome
Path or archive memberinternal/modules/ai/feed_test.go
Original SHA-256669fcff1c771b3cd0957bdc73622c68fd817e4913692988b2c702267a71f2711
Git blob SHA163a2c5818a2f2aa1ce279ca5ad591899253511c
Reading-copy SHA-256669fcff1c771b3cd0957bdc73622c68fd817e4913692988b2c702267a71f2711

Original source ↗

Every recorded occurrence

These 2 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/feed_test.gofeature/opportunity-to-outcome720d47fae476b0d38477ae4401697d372b1ea2bcOpen original
Janady13/missionmatch / internal/modules/ai/feed_test.gofeature/aioe-upgrade2178e7298d0e5d9af83afa12402fd587f0ba6ed8Open original

Recovered source transcript

package ai import ( "encoding/json" "net/http" "net/http/httptest" "reflect" "strings" "testing" "github.com/go-chi/chi/v5" ) func feedServer() http.Handler { r := chi.NewRouter() NewFeedHandler().Routes(r) return r } func feedGet(t *testing.T, path string) (int, map[string]any) { t.Helper() rec := httptest.NewRecorder() feedServer().ServeHTTP(rec, httptest.NewRequest(http.MethodGet, path, nil)) var out map[string]any if err := json.Unmarshal(rec.Body.Bytes(), &out); err != nil { t.Fatalf("decode %s: %v (body %q)", path, err, rec.Body.String()) } return rec.Code, out } // TestFeedHandlerCannotHoldADatabase is the structural guarantee behind an unauthenticated read. // // The feed is safe to serve without a session only because this type is INCAPABLE of reaching tenant data // rather than choosing not to. A future edit adding a *tenant.DB, a pool, or the orchestrator would turn a // public endpoint into a client data path, and a reviewer would have to notice the implication. This test // notices instead: it fails the moment the type gains any field at all. func TestFeedHandlerCannotHoldADatabase(t *testing.T) { if n := reflect.TypeOf(FeedHandler{}).NumField(); n != 0 { t.Fatalf("FeedHandler gained %d field(s). This handler is served UNAUTHENTICATED and its safety "+ "rests on being unable to reach tenant data. If the new field is a database, pool, or "+ "orchestrator, the feed becomes a client data path: authenticate it or keep the state out of "+ "this type.", n) } } // TestFeedManifestDeclaresItIsNotAFederationMember is the whole point of the manifest. // // The relationship with PANTHEON is one way by design: missionMATCH publishes, a consumer pulls. An // earlier iteration registered this service as an organ in ORACLE's registry, which made it a routable // component of that federation and coupled a commercial product to a private research system. The // manifest now says so as DATA, so an auto discovering consumer cannot make that mistake again. func TestFeedManifestDeclaresItIsNotAFederationMember(t *testing.T) { code, out := feedGet(t, "/knowledge/manifest") if code != http.StatusOK { t.Fatalf("manifest status = %d, want 200", code) } if out["federation_member"] != false { t.Fatalf("federation_member = %v, want false: missionMATCH is standalone", out["federation_member"]) } if out["routable"] != false { t.Fatalf("routable = %v, want false: nothing may route tasks into this service", out["routable"]) } if out["contains_tenant_data"] != false { t.Fatalf("contains_tenant_data = %v, want false", out["contains_tenant_data"]) } if out["direction"] != "publish_only" { t.Fatalf("direction = %v, want publish_only", out["direction"]) } if out["source"] != feedSource { t.Fatalf("source = %v, want %q", out["source"], feedSource) } if n, ok := out["cards"].(float64); !ok || int(n) != len(KnowledgeBase) { t.Fatalf("cards = %v, want %d", out["cards"], len(KnowledgeBase)) } } // TestFeedCardsPublishesEveryCardWithItsCitation: a consumer embeds these into its own store, so the // attribution has to travel with the content or the provenance is lost at the moment of ingest. func TestFeedCardsPublishesEveryCardWithItsCitation(t *testing.T) { code, out := feedGet(t, "/knowledge/cards") if code != http.StatusOK { t.Fatalf("cards status = %d, want 200", code) } cards, _ := out["cards"].([]any) if len(cards) != len(KnowledgeBase) { t.Fatalf("published %d cards, want %d (the whole set, so a harvester pulls once)", len(cards), len(KnowledgeBase)) } for i, raw := range cards { c, _ := raw.(map[string]any) for _, f := range []string{"topic", "text", "source"} { if s, _ := c[f].(string); strings.TrimSpace(s) == "" { t.Fatalf("card %d has empty %q: %v", i, f, c) } } } } // TestFeedIsAPureProjectionOfTheCuratedBase pins the property that actually belongs to the feed: it // publishes the reviewed knowledge base and NOTHING else. What each card may contain is already governed // by TestKnowledgeBaseIsWellFormed and TestKnowledgeBaseNamesNoEEOSchema; re-asserting that here would // duplicate those. What is unique to this surface is that it is a bulk, unauthenticated read, so the risk // is a second data source being spliced in later. Comparing the published text back to KnowledgeBase // catches that: anything not from the curated base fails. // // Note deliberately NOT asserted: MentionsProtectedAttribute over the card text. That guard is tuned for // candidate QUESTIONS, where "veteran", "women", or "disabled" signal a demographic probe. Several cards // legitimately name federal set aside programs (SDVOSB, WOSB, 8(a)), where those words are the statutory // names of FIRM eligibility classes and have nothing to do with candidate demographics. Applying the query // guard to domain documentation is a false positive, and encoding it here would force the removal of // accurate public GovCon knowledge to satisfy a check aimed at a different attack. func TestFeedIsAPureProjectionOfTheCuratedBase(t *testing.T) { _, out := feedGet(t, "/knowledge/cards") cards, _ := out["cards"].([]any) known := make(map[string]string, len(KnowledgeBase)) for _, c := range KnowledgeBase { known[c.Topic] = c.Content } for i, raw := range cards { c, _ := raw.(map[string]any) topic, _ := c["topic"].(string) text, _ := c["text"].(string) want, ok := known[topic] if !ok { t.Fatalf("published card %d has topic %q, which is not in the curated KnowledgeBase. The feed "+ "must publish the reviewed base and nothing else.", i, topic) } if strings.TrimSpace(text) != strings.TrimSpace(want) { t.Fatalf("published card %q does not match the curated text; the feed must not rewrite cards", topic) } } }

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