Garry's Opinionated OpenClaw/Hermes Agent Brain
Company-brain ingestion
Subsystem index. Read only the entries relevant to your change. For the operator workflow, see the company-brain ingestion guide.
src/core/company-brain/{inspection,revision,types}.ts— bounded, database-free company repository plans from verified committed Git blobs. Selection, aliases, source-local references, audience requirements, dirty inputs, and schema identities are inspected without executing repository hooks, filters, or instructions. Saved plans are revalidated rather than treated as authority; search-hiding markers block readiness.source-local-reference-index.tsis shared with graph reconciliation so inspection never promises a different frontmatter target resolver. Its Git hardening (argv prefix and scrubbed environment) lives insrc/core/hardened-git.ts, shared with the writer manifest (persistence/worktree-manifest.ts, which uses the synchronoushardenedGitSyncwith a timeout and byte cap).src/core/company-brain/{admission,profile,runtime,verification,receipts,receipt-schema}.ts— trusted local new-source admission, persistent keyless source policy, exact-revision managed/legacy sync, durable phase receipts, and exact content/relationship/history verification. Admission composes with topology locks and request replay; managed sync retains owner/incarnation/revision fencing and refuses canonical file overlays. Incomplete receipt-owned checkpoints survive age-based cleanup. Completed state requires verified source content and graph, not just an advanced import bookmark. The receipt table is authoritative; saved JSON is an export.src/commands/company-brain-{inspect,connect,demo}.ts— dedicated source subcommand parsing and versioned JSON/error output. Inspection is engine-free; connect requires explicit brain/source selection and previews through the existing resident-owner route before a probe-only local connection. Human progress is stderr-scoped for JSON output.core/company-brain/{demo,sample,evidence,status}.tssupplies the real-pipeline offline sample, actual source-scoped evidence, and private receipt status without fabricated answers or host-path fields.src/core/{derived-links,link-reconciliation}.ts— source-qualified, revision-fenced atomic replacement of derived edges; manual rows survive. The source reconciliation API supports bounded cursors, refuses changed endpoints (foreign ones included) and resolves a target into another source only under the source policy it shares withput_page's link preparation (makeLinkSourceResolver:link_resolution.cross_source, or a[[source:slug]]reference from a federated origin; #4680). Standard DB extraction passes the same captured endpoint revision fences. #6808:replaceDerivedLinksDeferringConflicts(and the batch replay) turns the guard'sPageSourceMissingErrorfor the origin's or an endpoint's source into{ unknownSource }; both DB link drains (extract links|all --source db,extract --stale) keep that page's links and watermark, count it asskipped_unknown_source, name the first 20 inunknown_source_pagesand printunknownSourceSkipLine, which, unlike the settings-changed and concurrent-write lines, does not suggest a re-run (test/extract-missing-source-6808.test.ts+ Postgres twin).capturedLinkEndpoints(links, metadata, origin?)is the one place those fences are built: every endpoint at the resolver census's revision except the source-qualified origin, whichexpectedRevisionalready fences at the snapshot that supplied its body and type (#6474: fencing it again at the older census revision deferred a page rewritten between the census and its own read); the managedlinks-preparation.tsand both DB walks (extract links|all,extract --stale) pass the origin, and a self-reference's target type comes from the live snapshot rather than the census.replaceDerivedLinksBatch(engine member) publishes many origins in one transaction: one relation-semantics prime, one sorted guard lock over every origin and endpoint, one extraction-generation check and one batched origin read (engine.readPageSnapshotsBatch, built onsrc/core/page-snapshot-batch.ts: each exact ref'sreadPageSnapshotresult in one statement, page-subject purges and the '' purge marker included, line fingerprints only for pages with withdrawals, purges or a '' marker, a body-byte budget per call; Postgres binds the refs' sources for RLS;test/page-snapshot-batch.test.ts), then each origin's own checks and writes in order; any failure rolls the batch back, andreplaceDerivedLinksBatchOrReplaythen replays the origins one by one throughreplaceDerivedLinks, so each outcome (settings-changed skip, first error) is the unbatched one (test/extract-db-batch-equivalence.test.tspinsextract all --source dbrows to the per-page walk).test/derived-link-reconciliation.test.tsandtest/extract-endpoint-revision.serial.test.tscover both engines and rollback/freshness behavior.src/core/attendance-repair.tsandsrc/commands/extract-attendance-repair.ts— trusted-local historical attendance preview and exact-receipt apply. Indexed source-page slug windows precede eligibility filtering; explicit Markdown evidence uses capped endpoint and adjacency lookups, while all frontmatter remains report-only and unmaterialized. A narrowderived-links.tsdelta preserves unrelated row IDs and evidence; brain/source incarnation, page revisions, ontology/parser and affected-edge hashes fence each origin transaction. Existingop_checkpointsbanks commit proof before the private cursor advances across committed origins and revalidated skipped pages, making interruption replay idempotent. No broad derived replacement, normal-extraction watermark updates, MCP administration or provider calls. Covered by the dual-enginetest/attendance-repair.test.tsand real CLItest/attendance-repair-cli.serial.test.ts; operator contract and limits are indocs/guides/attendance-evidence.md.src/core/schema-pack/base/company-brain.yaml— optional company vocabulary extendinggbrain-base-v2without normalization rules or maintenance phases. Overrides company aliases and prefixes so product stays a distinct query and path type. Bundled throughschema-pack/bundled.tsandbundled-assets.ts; attribution is inthird-party/company-brain/. The generic fictional sample insrc/core/company-brain/sample/preserves the upstream layout and relationship metadata.test/company-brain-schema.test.tspins inherited lint, type closure, folder inference, read-only bundling, and sample references.