Skip to content

Import brains from hasna/brains (history preserved) - #17

Merged
andrei-hasna merged 71 commits into
mainfrom
import/brains
Aug 13, 2026
Merged

Import brains from hasna/brains (history preserved)#17
andrei-hasna merged 71 commits into
mainfrom
import/brains

Conversation

@andrei-hasna

@andrei-hasna andrei-hasna commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Import brains from hasna/brains (history-preserving, merge-commit)

Task: ee9fbb4d (wave 1 batch B). Mechanism: import-mechanics-codex.md (approved; reviewers A+B GO). Import via disposable mirror → git-filter-repo --to-subdirectory-filter apps/brains --preserve-commit-hashes --preserve-commit-encoding → same-tree history capsule → one merge-commit PR (merge-commit strategy required — squash/rebase breaks imported-history reachability). No publishes, no repo-settings changes, no deletions.

Evidence

PR freeze (checklist 6): 0 open PRs on hasna/brains at import time.

Ref inventory (checklist 1): heads=2, tags=1 (lightweight v0.0.24). refs/pull/* present in the mirror; pull-only commits dropped per mechanism P3 (accepted, recorded). Peel skipped list: none (all 3 refs resolved via rev-parse ^{commit}; 0 duplicates).

Capsule: 6637703, parents=3. PARENT_SET_EQUAL GAPS=0 (checklist 3).

Tree/blob gate (checklist 4): rewritten main tree == mono subtree tree except the documented absorption fix below. 0 gitlink (160000) entries (negative submodule control). Provenance: rewritten main is an ancestor of the import head (DAG_REACHABLE); git fsck --connectivity-only rc=0 (dangling only).

In-mono absorption gate (checklist 2): bun install rc=0 · bun run check rc=0 (secrets scan 0 findings / 8,902 added lines) · turbo build --affected rc=0 · test --affected rc=0 · lint --affected rc=0.

Absorption fixes (in this PR, smallest per P1b):

  1. apps/brains/package.json — added explicit devDeps bun-types@1.3.14, @types/node@26.1.0: tsconfig.json types ["bun-types"] failed in-mono with TS2688 (bun-types unlinked in the workspace store; exact versions match the old repo's resolved tree).
    Root bun.lock updated by bun install (member registration).

Hygiene (checklist 5): no .gitattributes LFS rules, no .gitmodules, staged secrets scan 0 findings, git diff --cached --check clean.

Tag→commit manifest (checklist 8): /tmp/opencode/wave1b/brains/tag-commit-manifest.md (1 lightweight tag; 3 capsule parents; GAPS=0).

Landing requirement

Merge with GitHub's merge-commit strategy only (mechanism doc; squash or rebase breaks reachability of the imported history).


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

andrei-hasna and others added 30 commits March 14, 2026 09:30
- package.json with Commander.js, Ink, MCP SDK, Drizzle, OpenAI dependencies
- DB schema: fine_tuned_models, training_jobs, training_datasets (Drizzle/SQLite)
- OpenAI fine-tuning provider: upload, createJob, getStatus, listModels, cancel
- Thinker Labs fine-tuning provider: REST adapter with matching interface
- Data gatherers: todos, mementos, conversations, sessions (JSONL training data)
- CLI commands: models list/show, finetune start/status/list, data gather/preview/list
- MCP server: 6 tools for list_models, start_finetune, gather_training_data, etc
…ions

- Replace better-sqlite3 with bun:sqlite throughout (db, gatherers)
- Fix data gather CLI to use gatherAll() instead of broken dynamic imports
- Add display_name, description, collection, tags to fine_tuned_models schema
- Add brains models rename/describe/tag/untag/set-collection commands
- Add brains collections list/show/rename commands
- Verify end-to-end: gathered 100 training examples, started fine-tune job
  ftjob-E8Xb2NbeqHXmjM4FgpommF82 on gpt-4o-mini-2024-07-18
- Add package-metadata.ts to read version from package.json at runtime
- Refactor MCP server into createMcpServer() factory for testability
- Refactor HTTP server into startServer() / createServerFetchHandler() for testability
- Export MCP_SERVER_INFO constant; server/MCP version now tracks package.json automatically
- Add test files for server and package-metadata

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… API, tests

- Wire mementos/conversations/sessions gatherers in MCP server (BRA-00014)
- Add `brains finetune watch` command with polling loop (BRA-00015)
- Add `brains data merge` command with deduplication (BRA-00016)
- Auto-detect latest dataset when --dataset omitted (BRA-00017)
- Full REST API on HTTP server: /models, /jobs, /datasets (BRA-00018)
- Add `brains models import` to pull external fine-tuned models (BRA-00019)
- Deduplicate examples in mergeAndWriteJSONL across sources (BRA-00020)
- Per-source progress output during brains data gather (BRA-00021)
- Add `brains config` command for API key management (BRA-00022)
- Add Zod validation to all MCP tool inputs (BRA-00023)
- Add --json flag to all CLI list/show/status commands (BRA-00024)
- Write README.md with install, configure, quickstart guide (BRA-00025)
- Fix hardcoded version in HTTP server (BRA-00026)
- Migrate DB schema to drizzle-kit migrations (BRA-00027)
- Add retry with exponential backoff to all provider API calls (BRA-00028)
- Add 25 new tests covering retry, config, gatherers, MCP, schemas (BRA-00029)
…ets, economy, recordings, assistants)

- protocol.ts: shared GatherTrainingDataFn + TrainingDataProvider interface
- registry.ts: dynamic registry replacing switch/case in gatherAll()
- Gatherers for: styles, researcher, tickets, economy, recordings, assistants
  - All use optional dynamic import — gracefully skip if SDK not installed
  - Prefer gatherTrainingData() from SDK if exported, fall back to list*() calls
- gatherAll("all") now expands to all registered sources dynamically
- brains data gather --source styles/researcher/tickets/economy/recordings/assistants all work
Move config from ~/.brains/config.json to ~/.hasna/brains/config.json.
Move database from ~/.brains/brains.db to ~/.hasna/brains/brains.db.
Auto-migrates all files from old directory when new doesn't exist yet.
Existing ~/.brains/ is never deleted.
- Replace manual SqliteAdapter path resolution with createDatabase({ service: "brains" }) from @hasna/cloud
- Use migrateDotfile("brains") for ~/.brains/ → ~/.hasna/brains/ migration
- Add src/db/pg-migrate.ts: PostgreSQL migration runner (applyPgMigrations)
- Fix pg-migrations.ts: use BIGINT for Unix epoch timestamps, update feedback schema to match @hasna/cloud standard
- Add cloud CLI commands: brains cloud status/push/pull/sync/migrate-pg
- Switch feedback to use sendFeedback/listFeedback from @hasna/cloud; add feedback list CLI command
- Export applyPgMigrations from main index
- Bump version to 0.0.13
Add tests for db/index, all gatherers, providers (mocked), server HTTP routes, and retry edge cases. Coverage: server 100%, db 100%, gatherers 50-100%, providers 95-96%, retry 100%.
Extract models, finetune, data, collections, and cloud command groups into
src/cli/commands/. index.ts is now a lean entry point. Bump to 0.0.14.
brains --help was timing out because migrateDotfile() ran at module
load time, triggering fs ops on every CLI invocation including --help.
Now runs lazily on first getDb()/getRawDb() call only.
andrei-hasna and others added 24 commits May 28, 2026 15:29
The prior repair left http.ts exporting only startHttpServer while
mcp/index.ts imported isHttpMode/resolveMcpHttpPort/startMcpHttpServer,
breaking the build. Restore the canonical web-standard transport
(--http / MCP_HTTP=1, port 8802) and align the index.ts entrypoint and
tests with the rest of the @hasna MCP fleet.
`brains-mcp` now starts a shared Streamable HTTP server by default
(port 8802); pass `--stdio` (or MCP_STDIO=1) for the legacy per-process
stdio transport. This eliminates per-agent process fan-out for clients
that connect over HTTP. BREAKING for callers that relied on the bare
bin being stdio — update them to pass --stdio or connect to
http://127.0.0.1:8802/mcp.
Preserve reviewed non-risky working tree changes before fleet repo redistribution. Risky local-only paths, if any, were left uncommitted.
Resolved conflicts with current main, preserved native storage sync changes, and validated with bun test, bun run typecheck, bun run build, plus adversarial staged review.
Co-authored-by: Codewith <codewith@users.noreply.github.com>
Cut release to publish merged #1 (compact default CLI/MCP output).
npm 0.0.34 predated #1; bump so the merged changes reach the registry.
@andrei-hasna
andrei-hasna merged commit d7e56dc into main Aug 13, 2026
4 checks passed
andrei-hasna added a commit that referenced this pull request Aug 17, 2026
Delta import from org repo hasna/bridge (freeze 4fef003, 07-30): commits
1c3e5e5 (#14), da2ecae (#16), 1fd3b94 (#15), 558a9d5 (#17, release 0.7.1).

Monorepo #182 already ported most of the daemon lifecycle content, but the
org main carries two genuine additions the port missed, now imported:
- live-owner lock protection: a lock held by a live process is never
  broken on age alone (with regression test)
- config-derived stop grace: --timeout-ms no longer defaults to 5000;
  unset means derive from config (with derived-grace CLI test)
Plus the 0.7.1 release (version + changelog + changeset) and the setsid
fixture correction in serve-preflight.

Kept member absorption: bun-types/@types/node pins in package.json,
bracket-form AWS key literal in codewith-durable.test.ts.

Local gates: typecheck 0, 240 tests pass / 0 fail, build 0,
secrets scan 0 findings.

Agent: aemilianus
andrei-hasna added a commit that referenced this pull request Aug 17, 2026
Sync bridge with hasna/bridge main (delta import #14-#17). Live-owner lock protection, config-derived stop grace, 0.7.1 release + changeset; #182 content reconciled. CI green at head.

Agent: aemilianus
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