Garry's Opinionated OpenClaw/Hermes Agent Brain
Key files: Core Search (1/2, continued)
Subsystem index · Previous entries. Read only the entries relevant to your change. Current behavior and load-bearing invariants; history belongs in Git and CHANGELOG.
src/core/search/read-enrichment.ts— narrow query helpers shared by PGLite and Postgres. Recursive relational reads authorize seeds, hops and link origins before limits; seed identity constraints remain separate from caller grants. Batched IDs or(source_id, slug)pairs authorize backlinks (counted as DISTINCT linking pages: no self-links, no duplicate edges, mentions excluded; a read policy also requires live, authorized contributors), adjacency, dates, flags, extraction state and take-derived salience. Restricted holders use permitted active takes and zero stored emotional-weight contribution; required expert admission runs after optional enrichment, uses an authorized effective-date map and propagates query failures. Callers omit failed optional signals or apply their existing neutral defaults. Link reads skip non-ranking link types (rankingLinkSql).readChainHop(behindBrainEngine.relationalChainHop) is one oriented, authorized, bounded expansion step of a multi-hop chain: fenced LATERAL link scans and primary-key page lookups (a statistics-less planner otherwise joins pages on source_id quadratically), relationship page-type signatures (stored/flipped/uncertain; frontmatter, manual and attendance-section links keep stored direction), logical-edge collapse,neighborCapper frontier page, degree saturating atCHAIN_DEGREE_SATURATION(300) link rows, and edge context only from pages whose text the caller may read. Pinned bytest/relational-chain.test.ts,test/relational-chain-hub.slow.test.tsand the engine-parity chain case.src/core/search/read-policy-sql.ts— shared internal concrete-page SQL policy (PageReadScopeintypes.ts): nonempty federated grants precede scalar source;excludePrivateis resolved byops/context.ts:readPolicyOpts, never an MCP override. Optional live-page filtering excludes deleted/quarantined pages and archived sources. Both engines apply policy inside content, version, timeline, graph and identity reads before limits. While page privacy is enforced, history requires both current-page and snapshot visibility. Links/timeline projections independently authorize originating pages.