Open Second Brain v1.2.0 - SOLID & DRY
This release is a codebase-wide refactor with zero behavior change: the two god modules are decomposed into cohesive domain modules, every duplicated helper gets a single source of truth, and two new guard tests make the frozen public surface mechanically enforceable. MCP tool names, CLI verbs, file formats, output strings, and exit codes are byte-identical to 1.1.0 - the release changes how the codebase is organized, not what it does, so future features land in focused modules instead of a 5,614-line monolith.
What ships
- God module split by domain.
src/mcp/brain-tools.tscarried 54 MCP tools and 100+ helpers in 5,614 lines - nine times the size of its siblings. It is now 16 cohesive modules undersrc/mcp/brain/(feedback, review, context, pack, query, entity, health, brief, analytics, knowledge, admin, recall, workspace, procedure, landscape, shared), every one under 700 lines, behind an unchangedBRAIN_TOOLSaggregator so every existing import keeps working. - Dream pass decomposed. The 2,239-line
dream.tsbecomes a 1,499-line orchestrator over four extracted modules -dream-plan.ts(scan and plan-state shapes),confidence.ts(Wilson-bound confidence math),dream-refresh.ts(apply-evidence scan and promotion planning),reconcile-outcomes.ts(contradiction classification) - each unit-tested in isolation. The Brain config YAML parser also moves out ofpolicy.tsinto its ownyaml-parse.ts. - One source of truth for duplicated helpers. Seven divergent
[[wikilink]]regexes collapse into named, purpose-documented variants inwikilink.ts, with characterization tests pinning each former call site's contract before migration. The two atomic-write implementations merge into one temp-file + fsync + rename pipeline infs-atomic.ts. - CLI verbs share context resolution. 76 verb files replace the repeated config / vault / agent boilerplate with
brainVerbContext(flags)andresolveBrainAgent(flags, config), called at the exact position of the former inline code - flag-validation order, error messages, and exit codes stay byte-identical. - Frozen-surface guards. A parity test pins the exact v1.x set of 54 Brain MCP tool names (any dropped, duplicated, or renamed tool fails CI), and a layering test fails when anything under
src/corecallsprocess.exit,process.stdout.write, orconsole.log.
Process wins
- Review economy: a tool change now produces a diff inside one focused domain module; the largest reviewable unit in
src/mcpdropped from 5,614 to 690 lines. - Provable behavior preservation: every refactor unit landed only with the full suite green, and characterization tests were written before each migration, not after.
- No shims: duplicated implementations were deleted and call sites migrated directly - the codebase ends smaller, with the single aggregation seam (
brain-tools.ts) kept only because it is the registration point tests andtools.tsalready use. - Quality record: 4,140 tests / 0 fail (47 new), TypeScript clean, lint at the pre-refactor baseline, version synced across all manifests, the OpenClaw bundle byte-identical after rebuild, an independent three-reviewer self-review pass with zero security or logic findings, and one CodeRabbit pass (one valid finding fixed, one incorrect claim refuted with evidence).
Notes
- Zero behavior change by design; the only observable delta is tool registration order inside
tools/listenumeration (the name set and every tool's schema are unchanged). - The brainstorm audit trail - consultant variants, the chosen approach, and the rejected alternatives - is committed under
docs/brainstorm/solid-dry-refactor/. - Release image: the terminal-style overview (animated GIF in this body; static PNG and the SVG source attached as assets).
