Skip to content

Nucleus Basalis Phase 1: ACh attention broadcaster (issue #116 follow-up)#122

Closed
TSchonleber wants to merge 2 commits into
mainfrom
brain-regions-nb-phase-1
Closed

Nucleus Basalis Phase 1: ACh attention broadcaster (issue #116 follow-up)#122
TSchonleber wants to merge 2 commits into
mainfrom
brain-regions-nb-phase-1

Conversation

@TSchonleber
Copy link
Copy Markdown
Owner

Summary

Phase 1 of the Nucleus Basalis subsystem — basal-forebrain cholinergic broadcaster, the target-locked attention complement to Locus Coeruleus's broad-arousal NE broadcast. Pairs with the sibling LC PR (brain-regions-lc-phase-1); together they codify the dual gain/attention control axes the May 15 brain_region_coverage.md audit flagged as missing.

Phase 1 ships schema + 5 read+CRUD MCP tools + tests + docs. No behavior change to retrieval, write gates, or any existing subsystem. Phase 2 wires the shadow consult; Phase 3 closes the loop; Phase 4 enforces — all separate PRs.

Context

NB and LC together complete the four-dial neuromod surface on bg_modulators:

  • tonic_da — BG actor exploration knob (shipped 054)
  • lc_ne — LC norepinephrine broadcast (shipped 054, LC subsystem in sibling PR)
  • serotonin — raphe-analog time-horizon dial (shipped 054)
  • acetylcholineadded by this PR (the 4th dial)

LC fires on surprise broadly; NB fires on attention shifts target-locked. NE widens the aperture; ACh sharpens the focus inside it. Both are necessary for the closed-loop architecture to balance exploration and exploitation correctly.

What's in

  • Migration 068 — 3 tables (nb_attention_targets, nb_firings, nb_state) + acetylcholine REAL DEFAULT 0.5 column on bg_modulators. 4 thalamic sectors seeded as targets (cognitive, episodic, semantic, pii_sensitive). nb_state single-row seed.
  • agentmemory.mcp_tools_nucleus_basalis — 5 MCP tools (status / register_target / fire / attend_sector / signal_history).
  • docs/proposals/nucleus_basalis.md — design doc with 4 biological invariants, architectural placement diagram, Phase 2/3/4 sketch.
  • tests/test_mcp_tools_nucleus_basalis.py — 10 tests covering migration seeds, empty-state defaults, idempotent registration, fire round-trip + state updates, sector-wrapper resolution, validation errors, and history filtering/pagination.
  • CHANGELOG entry under [Unreleased].
  • docs/proposals/brain_region_coverage.md — NB row gains a "Phase 1 shipped" footnote.

What's NOT in (deliberately)

  • No shadow consult wiring into mcp_server.py:3265. That's Phase 2 — different PR, daytime work.
  • No bg_modulators.acetylcholine writes from nb_fire. That's Phase 2.
  • No LC ⇄ NB integration cascade. That's a later PR after both Phase 2s land.
  • No retrieval / write-gate behavior changes.

Live smoke

  • Migration applied to ~/agentmemory/db/brain.db (backup at ~/agentmemory/backups/brain.db.pre-nb-20260520T033433Z.db)
  • 4 thalamic sectors seeded as expected
  • bg_modulators.acetylcholine = 0.5 default present alongside the existing 3 dials

Test plan

  • Review the design proposal at docs/proposals/nucleus_basalis.md
  • Confirm migration 068 is idempotent against the live brain (re-run is gated by schema_version)
  • Run python3 -m pytest tests/test_mcp_tools_nucleus_basalis.py -x — should be 10/10 green
  • Inspect the 5 MCP tools via mcp_tools/list — confirm all discoverable
  • Merge alongside the sibling LC PR (brain-regions-lc-phase-1) — they're meant to ship together

Parallel work

Sibling PR — Locus Coeruleus Phase 1 on branch brain-regions-lc-phase-1 (codex-authored under orchestration). Both should be reviewed together; LC + NB are the dual gain/attention control axes and the design assumes both ship.

🤖 Generated with Claude Code

…-up)

The basal-forebrain cholinergic broadcaster, target-locked attention
complement to Locus Coeruleus's broad NE arousal broadcast. Pairs
with the sibling LC PR (brain-regions-lc-phase-1). Together they
codify the dual gain/attention control axes that the May 15
brain_region_coverage.md audit flagged as missing on the 🟡 partial
list.

LC fires on surprise (broadly, indiscriminately); NB fires on
attention shifts (target-locked, narrow). NE widens the aperture;
ACh sharpens the focus inside it. Both are necessary for the
closed-loop architecture to balance exploration and exploitation
correctly.

Phase 1 is inspection-only / additive per the established phase
pattern (Phase 1 schema → Phase 2 shadow → Phase 3 closed-loop →
Phase 4 enforcement). No behavior change to retrieval, write gates,
or any existing subsystem.

- Migration 068 — 3 tables (nb_attention_targets, nb_firings,
  nb_state) + acetylcholine column on bg_modulators (the 4th
  neuromod dial; mirrors tonic_da, lc_ne, serotonin). 4 thalamic
  sectors seeded as targets. nb_state single-row seed. Idempotent;
  rollback DDL in header.

- agentmemory.mcp_tools_nucleus_basalis — 5 MCP tools:
  - nb_status: current state + 24h firing summary + last 5 firings
  - nb_register_target: idempotent UPSERT on nb_attention_targets
  - nb_fire: record cholinergic broadcast; writes nb_firings + nb_state
  - nb_attend_sector: convenience wrapper resolving sector → target
  - nb_signal_history: paginated firing log with filters

- 10 tests covering migration seeds, empty-state defaults, idempotent
  target registration, fire round-trip + state update, sector
  wrapper resolution, validation errors, and history
  filtering/pagination.

- Design proposal at docs/proposals/nucleus_basalis.md with
  4 biological invariants, architectural placement diagram, Phase
  2/3/4 sketch.

- brain_region_coverage.md updated: NB row gains "Phase 1 shipped"
  footnote.

Phase 2 (separate PR) wires NB into the shadow consult at
mcp_server.py:3265 to fire on thalamic_salience activations above
threshold and broadcast ACh delta. Phase 3 closes the loop. Phase 4
enforces.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
CI schema_parity test was failing because the NB branch's
init_schema.sql lacked the 066 (retrieval_pathway_log) and 068 (NB)
table definitions, plus the bg_modulators.acetylcholine column added
by 068. Fresh installs (init_schema only) drifted from upgraded
installs (init_schema + all migrations).

Mirrors the same backfill pattern the parallel LC branch used for
066/067. Closing-paren placement of the acetylcholine column matches
SQLite's ALTER TABLE ADD COLUMN canonical form so the stored
sqlite_master.sql is byte-identical between fresh and upgraded paths.

Verified locally: tests/test_schema_parity.py + tests/test_mcp_tools_nucleus_basalis.py all green.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@TSchonleber
Copy link
Copy Markdown
Owner Author

Superseded by #138 (brainctl-consolidation-v2), which already merged this work into main as part of the v2 tool surface consolidation. Closing as redundant.

@TSchonleber TSchonleber deleted the brain-regions-nb-phase-1 branch May 21, 2026 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant