Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/missionmatch / internal/modules/ai/feed.go |
| Date | Not specified in source |
| Repository | Janady13/missionmatch |
| Revision | 720d47fae476b0d38477ae4401697d372b1ea2bc |
| Branch | feature/opportunity-to-outcome |
| Path or archive member | internal/modules/ai/feed.go |
| Original SHA-256 | 6549475b3b8a5926d8ca1d4ff77c1a074ce22b102908148a56f1dd1932090d54 |
| Git blob SHA | c1e49535f22b6565a7e0fcbf2f2677440ed184c5 |
| Reading-copy SHA-256 | 6549475b3b8a5926d8ca1d4ff77c1a074ce22b102908148a56f1dd1932090d54 |
Every recorded occurrence
These 2 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 / internal/modules/ai/feed.go | feature/opportunity-to-outcome | 720d47fae476b0d38477ae4401697d372b1ea2bc | Open original |
| Janady13/missionmatch / internal/modules/ai/feed.go | feature/aioe-upgrade | 2178e7298d0e5d9af83afa12402fd587f0ba6ed8 | Open original |
Recovered source transcript
Download complete source text ↓123 lines · 6.0 KB
package ai
import (
"net/http"
"github.com/go-chi/chi/v5"
)
// The public knowledge feed: a ONE WAY publication surface.
//
// missionMATCH is a standalone product, not a member of the PANTHEON federation. The relationship runs in
// exactly one direction: missionMATCH publishes what it knows publicly, and anything that wants to learn
// from it, PANTHEON included, PULLS on its own schedule. Nothing here calls out, registers itself, or
// expects a consumer to exist.
//
// WHY THIS IS NOT AN ORGAN. An earlier version of this file exposed an organ manifest and the service was
// registered in ORACLE's registry. That was the wrong direction and is deliberately reverted. Registering
// makes this service a routable COMPONENT of PANTHEON: the orchestrator picks it as a winner for a task
// and calls into it at request time, which means PANTHEON depends on missionMATCH being up, and
// missionMATCH inherits a coupling to a system its customers have nothing to do with. A commercial
// cleared workforce platform must not be a limb of a private research federation.
//
// Publishing instead of joining also produces BETTER learning. A registered organ is delegated to: the
// orchestrator asks a question and forwards an answer it does not retain. A harvested feed is absorbed:
// the consumer embeds these cards into its own substrate and afterwards knows the material independently,
// with missionMATCH offline, deleted, or never contacted again. Learning means the knowledge survives the
// source going away, which is precisely what a pull based feed gives and a live route does not.
//
// WHAT MAY APPEAR HERE. Only the curated public knowledge cards, the same corpus behind /mm-recall: each
// one already public, already cited, contents free, and reviewed before it enters the base. No tenant
// data, no candidate, no requisition, no score, and no demographic field can reach this surface, because
// the handler holds no database and no orchestrator to reach them with. A test enforces that structurally.
//
// It is mounted at the service root, outside /api. The public nginx vhost proxies only /api/ and
// /healthz, so this is reachable across the tailnet by a harvester and is not exposed to the internet,
// and a bulk harvest does not consume the API rate limit that real user traffic depends on.
// feedSource identifies this publisher to a consumer that harvests several.
const feedSource = "missionmatch"
// feedScope is stated in the manifest so a consumer can record provenance for everything it ingests, and
// so a human reading a harvest log can see the boundary that was in force at the time.
const feedScope = "public_curated_knowledge"
// FeedHandler serves the one way publication surface. It holds NO state that could reach tenant data: no
// database, no pool, no orchestrator. That is the property that makes an unauthenticated read safe, and
// TestFeedHandlerCannotHoldADatabase fails if the type ever gains a field.
type FeedHandler struct{}
// NewFeedHandler builds the publication surface.
func NewFeedHandler() *FeedHandler { return &FeedHandler{} }
// Routes mounts the feed at the service root.
func (h *FeedHandler) Routes(r chi.Router) {
r.Get("/knowledge/manifest", h.manifest)
r.Get("/knowledge/cards", h.cards)
}
// feedManifest describes the feed to a harvester: what it is, what it publishes, and, stated explicitly,
// what it is not. FederationMember and Routable are always false and are part of the payload rather than
// only the documentation, so a consumer that auto discovers services cannot mistake this for an organ and
// register it. If someone later wants this service in an orchestrator's registry, they have to change a
// field that says in plain terms it should not be.
type feedManifest struct {
Source string `json:"source"`
Scope string `json:"scope"`
Cards int `json:"cards"`
Cursor string `json:"cards_url"`
Direction string `json:"direction"`
FederationMember bool `json:"federation_member"`
Routable bool `json:"routable"`
TenantData bool `json:"contains_tenant_data"`
Note string `json:"note"`
}
func (h *FeedHandler) manifest(w http.ResponseWriter, _ *http.Request) {
writeJSON(w, http.StatusOK, feedManifest{
Source: feedSource,
Scope: feedScope,
Cards: len(KnowledgeBase),
Cursor: "/knowledge/cards",
Direction: "publish_only",
// Stated as data, not just prose. See the type comment.
FederationMember: false,
Routable: false,
TenantData: false,
Note: "one way public knowledge feed: pull and embed this into your own store. " +
"missionMATCH is a standalone product and is not an organ of any federation; do not register " +
"it in an orchestrator registry or route tasks to it.",
})
}
// feedCard is one published unit of knowledge with the citation attached, so a consumer that embeds it
// keeps the attribution with the content rather than having to rejoin it later.
type feedCard struct {
Topic string `json:"topic"`
Text string `json:"text"`
Source string `json:"source"`
}
type feedCardsResponse struct {
Source string `json:"source"`
Scope string `json:"scope"`
Count int `json:"count"`
Cards []feedCard `json:"cards"`
}
// cards publishes the WHOLE curated set in one response, which is the shape a harvester wants: pull once,
// embed, and be done. A per query endpoint (/api/mm-recall) already exists for consumers that want to ask
// rather than absorb; this one exists so absorbing does not require guessing what to ask.
//
// The set is small, closed, and reviewed, so there is no pagination and no cursor to get wrong. If it ever
// grows past a single response the manifest gains a cursor before this endpoint changes shape.
func (h *FeedHandler) cards(w http.ResponseWriter, _ *http.Request) {
out := make([]feedCard, 0, len(KnowledgeBase))
for _, c := range KnowledgeBase {
out = append(out, feedCard{Topic: c.Topic, Text: c.Content, Source: c.Source})
}
writeJSON(w, http.StatusOK, feedCardsResponse{
Source: feedSource, Scope: feedScope, Count: len(out), Cards: out,
})
}