Skip to content

Company Brain

Company Brain compiles local operating knowledge into cited, agent-facing skill drafts. It is for company know-how such as processes, policies, decisions, incident playbooks, support procedures, and unresolved loops.

The first implementation is deterministic and offline-safe: it reads Markdown, detects operating-knowledge sections, attaches citation envelopes, and can project the result into a CapabilityBundle.

Compile A Vault

sb company-brain compile --json

By default, the command scans the configured vault. To compile a specific directory or file:

sb company-brain compile docs/ops --company Acme --format markdown

The report contains:

  • operating_map: cited processes, policies, decisions, and open loops
  • skills: draft agent skills compiled from process and policy entries
  • summary: source counts, entry counts, skill count, and warnings

Initialize The Standalone Datastore

Company Brain uses its own SQLite datastore instead of the shared SecondBrain runtime.db, knowledge.db, memory, work, or other split state databases. The default path is resolved with default_company_brain_db_path(state_dir) under the configured state directory.

sb company-brain db init
sb company-brain db status

To compile local Markdown and store the resulting source documents, evidence receipts, knowledge atoms, procedure skills, and run record:

sb company-brain db store docs/ops --company Acme

ingest-local remains available as the same local-store path. Use --db-path when testing a separate standalone datastore file.

Stored procedure skills are first-class Company Brain records. They preserve compiled instructions, source entry ids, safety notes, and evidence receipt ids for agent consumption:

sb company-brain skills list
sb company-brain skills get company.support-refund-process --markdown
sb company-brain skills run company.support-refund-process --json

skills run is dry-run-only in this slice. It writes a procedure skill trace to the standalone company_brain.db, keeps side effects disabled, records the planned steps, preserves evidence receipt ids, and flags steps that would need approval before a future action-capable runner could execute them.

Query The Standalone Datastore

After storing local knowledge, use the query commands against the same standalone Company Brain DB. These commands should not read from or initialize the shared SecondBrain runtime.db, knowledge.db, memory, work, or legacy state databases.

sb company-brain search "refund approval" --limit 5
sb company-brain query "When do refunds require approval?"
sb company-brain context "support agent handling refund escalation" --role support

search returns ranked knowledge atoms with evidence receipts. query returns a grounded answer plus source evidence. context builds a compact task pack for agents and should preserve source paths, receipt metadata, role, task, and DB path in JSON output:

sb company-brain search "refund approval" --json
sb company-brain query "When do refunds require approval?" --json
sb company-brain context "support agent handling refund escalation" \
  --role support \
  --json

Use --db-path for tests or alternate workspaces when you need to point the query surface at a specific standalone Company Brain datastore.

The JSON output also includes a review object. This is a deterministic Antahkarana reuse path: Company Brain uses Buddhi's contradiction detector and decision memo renderer to report evidence sufficiency, confidence, concerns, contradictions, and the recommended answer strategy without invoking the full cognitive loop.

Antahkarana Reuse Plan

Company Brain should reuse Antahkarana where it improves agent reliability, but it should not make the basic datastore, compile, search, or context commands depend on the full cognitive loop. Keep the split:

  • P0 search and context stay deterministic and read from company_brain.db.
  • P1 governed answers reuse Antahkarana components for evidence sufficiency, contradiction detection, confidence notes, and decision memos.
  • P1/P2 skill execution routes side-effecting steps through Antahkarana-style policy gates, action ledgers, and witness traces.

Useful Antahkarana components:

Layer Company Brain use
Indriya Normalize connector payloads before ingestion while preserving provenance.
Manas Add salience features for context selection without replacing retrieval.
Buddhi Detect contradictions, produce confidence notes, and render decision memos.
Viveka Require evidence before confident answers and gate risky tool actions.
Sabha Optional multi-role review for high-risk skill runs or policy conflicts.
Karma Record skill execution outcomes, regrets, and lessons as feedback.
Chitta Consolidate repeated corrections into durable Company Brain improvements.
Witness/Sakshi Attach traceable audit summaries to answers, context packs, and runs.
Bhava Monitor Tighten policy when pressure signals imply low-evidence/high-claim risk.

Implementation rule: reuse pure helpers and focused layer components first. Do not call CognitiveLoop, ContextPackService, MemoryStore, or shared state DB services from Company Brain search. Use the full Antahkarana loop only for agent actions that need reasoning, guardrails, and audit, such as executing a release checklist or proposing a customer communication.

Export Agent-Native Capabilities

Use the capability-bundle projection when another agent or review workflow needs a portable manifest:

sb company-brain compile \
  --company Acme \
  --format capability-bundle \
  --out out/company-brain.bundle.json

sb capabilities validate out/company-brain.bundle.json

Generated bundles are marked as draft-quality. Add gate-required eval suites before treating a compiled skill as release-ready automation.

Write SKILL.md Folders

Use skills-write when the compiled skill drafts should become local SecondBrain skills:

sb company-brain skills-write docs/ops \
  --company Acme \
  --out skills/company-brain

sb skills validate --path skills/company-brain --strict

The writer creates one <skill-name>/SKILL.md folder per compiled process or policy skill. Existing skill files are skipped by default; pass --force only when you intend to overwrite generated files.

Review Drift

Keep a named local baseline for routine review:

sb company-brain snapshot docs/ops \
  --company Acme \
  --name active

sb company-brain baselines
sb company-brain diff active docs/ops

Baselines are stored under the configured SecondBrain state directory. Use --fail-on-drift in CI or release checks when any semantic change should block until the Company Brain snapshot and generated skills have been reviewed.

You can also keep a standalone compile report when you need a portable artifact:

sb company-brain compile docs/ops \
  --company Acme \
  --json \
  --out out/company-brain.baseline.json

After the source Markdown changes, diff the baseline against the current compile:

sb company-brain diff out/company-brain.baseline.json docs/ops

Authoring Hints

The compiler intentionally prefers explicit operating signals:

  • headings such as Refund Process, Incident Runbook, Security Policy
  • decision markers such as DECISION: Require approval for exports
  • open-loop markers such as TODO:, OPENLOOP:, and unchecked Markdown tasks
  • owner lines such as Owner: Support Ops

Keep source files specific and current. Company Brain is not a replacement for ingest or search; it is a compiler that turns grounded company knowledge into reviewable agent operating instructions.