// Package forage implements autonomous internet feeding — the organism // identifies gaps, constructs URLs, fetches content, and digests it // through enzyme pipelines. The internet is supersaturated solution. // The lattice is the filter. package forage import ( "fmt" "sort" "git.mleku.dev/mleku/dendrite/pkg/gap" "git.mleku.dev/mleku/dendrite/pkg/ratio" ) // Need represents a single information need derived from the organism's // negative space. Each need has a type that determines how the organism // searches for it. type Need struct { Type NeedType // what kind of information Topic string // the specific subject (NIP number, package name, etc.) Gap gap.Gap Priority ratio.Ratio // 0 = low, 1 = critical } // NeedType classifies what the organism needs to learn. type NeedType int const ( NeedSpecification NeedType = iota // protocol spec (NIP, RFC) NeedSourceCode // library source NeedDocumentation // package docs NeedExample // usage examples NeedExplanation // conceptual description ) func (t NeedType) String() string { switch t { case NeedSpecification: return "specification" case NeedSourceCode: return "source" case NeedDocumentation: return "documentation" case NeedExample: return "example" case NeedExplanation: return "explanation" default: return "unknown" } } // Appetite analyzes gaps and produces a ranked list of information needs. // The organism's negative space shapes what it hunts for. func Appetite(gaps []gap.Gap) []Need { var needs []Need for _, gap := range gaps { switch gap.Type { case "missing_site": needs = append(needs, Need{ Type: NeedDocumentation, Topic: gap.Tag, Gap: gap, Priority: gap.Severity, }) case "orphan_event", "orphan_pubkey": needs = append(needs, Need{ Type: NeedSpecification, Topic: fmt.Sprintf("Nostr event references and %s resolution", gap.Tag), Gap: gap, Priority: gap.Severity, }) case "low_occupancy": needs = append(needs, Need{ Type: NeedExample, Topic: "lattice growth patterns and element diversity", Gap: gap, Priority: gap.Severity, }) case "weak_region": needs = append(needs, Need{ Type: NeedExplanation, Topic: "constraint design for stronger bonding", Gap: gap, Priority: gap.Severity, }) default: needs = append(needs, Need{ Type: NeedExplanation, Topic: gap.Description, Gap: gap, Priority: gap.Severity, }) } } sort.Slice(needs, func(i, j int) bool { return needs[j].Priority.Less(needs[i].Priority) }) return needs }