Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
Merge remote-tracking branch 'origin/capy/w14-pr3' into capy/w14-pr2
garrytane94eca1f6d60
diff --cc CHANGELOG.mdindex 2c2b5c4845,b95f11b9f6..e946e394f8--- a/CHANGELOG.md+++ b/CHANGELOG.md@@@ -10,41 -10,58 +10,93 @@@ credits are retained; no result has beeidentifiers and attribution are available in the pre-removal Git revision`6040075c6cb95be5881cc2e1b76ef7d71f4e5d29` (retained on 2026-09-23).+## [Unreleased] - fix wave 14 PR2 (GBRA-79)++**A managed brain's Git durability is now a recorded owner setting, and the managed-worktree refusals name the command to run instead of a dead end.**++On a managed brain the persistence owner commits and pushes page writes through its Git effect, but until now that depended on a post-commit hook the owner probed for on every pass, and nothing told an operator how to turn it on (#5182). `gbrain sources writer git-durability <source> --enable|--disable [--pat-file <path>]` records the setting on the host binding (migration v234 adds the nullable `git_durability` column; nothing recorded keeps today's probe), `--enable` runs a read-only push probe first and re-queues the Git effects skipped while it was off, and `--pat-file` wires the repo-scoped push credential and retries the parked pushes. `sources push`, `bootstrap verify`'s `push_probe` and the skill-pack writer guard now name that route on a managed worktree instead of a bare `writer_coordinator_required` (#5606). Doctor's new `foreign_ownership_marker` names the stale ownership stamp that blocks a claim (#5808), `writer activate` on an already-managed brain answers `already_enabled` with the owner process to check (#5514), `gbrain repair managed-sync-orphans` retires sync bookkeeping nothing current can resume (#5459), transcript re-ingest deletes a stale part through the coordinator instead of refusing (#5235), `gbrain sources set-strategy <id> <strategy>` persists a code source's sync strategy and refuses under an unfinished managed run (contributed by @rokas-tarasevicius, supersedes #5955), and `bootstrap status` tells a project-scoped Codex MCP connection you manage yourself apart from "nothing wired" (#4082).+- ## To take advantage of this release++### To take advantage of this release++`gbrain upgrade` should do this automatically. If it didn't, or if `gbrain doctor`+warns about a partial migration:++```bash+gbrain apply-migrations --yes --no-autopilot-install # v234: persistence_host_bindings.git_durability+gbrain doctor --json | grep -E 'schema_version|foreign_ownership_marker|sync_failures'+```++On a managed brain, `gbrain sources writer status <source> --json` now reports `git_durability` (`on`, `off` or `unknown`); `gbrain sources writer git-durability <source> --enable --dry-run` previews the switch.++### Itemized changes++- **Git durability as an owner setting (#5182, [R7i]/[R7ii]).** `persistence_host_bindings.git_durability` (`enabled` | `disabled` | NULL) via migration v234 on PGLite, Postgres and PgBouncer transaction mode; `gitDurabilityPolicy` resolves `enabled`/`disabled` from the binding and consults the legacy hook probe only when nothing is recorded (fail-closed on probe error). The effect worker's per-root probe routes through it. New verb `writer git-durability` (`writer_git_durability` admin operation; `--enable`, `--disable`, `--pat-file`, `--dry-run`, the usual `--admin-intent`/`--expected-state`) with error codes `git_branch_unborn`, `git_checkout_required`, `git_detached_head`, `pat_file_unreadable`. `writer activate` and `writer status` list `git_durability` per binding. Catch-up re-queues `durability_not_enabled` Git effects without inserting under `UNIQUE(request_id, kind)`.+- **Managed-worktree refusals name the route (#5606).** `gbrain sources push` on a managed canonical worktree refuses with the owner's `writer status` and `writer git-durability` commands; `bootstrap verify`'s `push_probe` reports the managed route instead of a failure; the skill-pack writer guard and doctor's skill checks point at `gbrain call --source <source> import_skill_proposal`.+- **Doctor `foreign_ownership_marker` (#5808).** A stamp or reservation beside a source checkout whose brain or worktree this brain does not know is listed with its path and the operator step (`docs/guides/write-refusals.md#foreign-ownership-marker`).+- **`writer activate` already managed (#5514).** Reason `already_enabled` with a `next_action` naming the owner process to check, instead of a generic refusal.+- **`gbrain repair managed-sync-orphans --source <id>` (#5459).** Explicit-only, preview-bound: retires failure rows with no cursor, cursors recorded by a principal that is no longer an active local writer, and superseded pre-options cursors; live pending requests and resumable cursors are kept. Doctor `sync_failures` names it; `docs/guides/repair.md#managed-sync-orphans` and the sync-unblock runbook explain when.+- **Transcripts on a managed brain (#5235).** A stale transcript part is deleted through the coordinator (`delete_page` with the expected revision) instead of refusing the re-ingest.+- **`gbrain sources set-strategy <id> <markdown|code|auto>` (PR #5955).** Persists the sync strategy on the source; refuses `sync_run_unfinished` (exit 1) while a managed sync run is unfinished, naming the resume and the orphan-repair commands. Contributed by @rokas-tarasevicius.+- **`bootstrap status` and Codex project config (#4082).** A `<workspace>/.codex/config.toml` MCP server is reported `partial` (detected, not verified) with an adopt hint; `gbrain bootstrap hooks --adopt --harness codex` records it after a passing verify in the versioned `<home>/bootstrap/adopted-connections.json` sidecar (sha256 over transport, URL and header names; no tokens) and the phase reads `done`; a drifted or removed table reads `partial` again. Nothing is written to the Codex config and no receipt registration is fabricated.++### For contributors++- New modules: `src/core/persistence/git-durability-policy.ts`, `git-durability-administration.ts`, `managed-sync-orphans.ts` (+ `src/core/repair/managed-sync-orphans.ts`), `src/commands/sources-strategy.ts`, `src/core/bootstrap/adopted-connections.ts`, `adopt-connection.ts`, `src/core/schema-migrations/v234-persistence-git-durability.ts`.+- Tests (each proven failing on master first): `test/persistence-admin-git-durability.test.ts`, `test/doctor-foreign-ownership-marker.test.ts`, `test/persistence-activation.test.ts`, `test/repair-managed-sync-orphans.test.ts`, `test/transcripts-managed-ingest.test.ts`, `test/managed-push-remedy.serial.test.ts`, `test/doctor-skill-checks.test.ts`, `test/sources-strategy.test.ts`, `test/bootstrap-adopted-connection.serial.test.ts`. Doctor goldens regenerated (new check row; schema column count +1).+- Two hunks on wave 13 PR1's files (`effect-git.ts` resolver call, `hardenBrainRepo` managed refusal) ship as patches with the integrator, not in this PR.++ ## [0.60.162.0] - 2026-10-11++ **Dream stops merging facts that only look alike, writes refuse a typo instead of ignoring it, and a dozen smaller wrong answers are fixed.**++ Twenty-one issues and three contributor PRs, mostly about the brain quietly doing the wrong thing. Two facts that said "Invoice A is due Monday" and "Invoice B is due Tuesday" could be merged into one take because their embeddings were close; now a difference in a number, date, amount or negation keeps them apart. A `put_page` or `remember` that misspelled a parameter name was accepted with the typo silently dropped; now every write refuses an unknown parameter and names it. A `remember` of a fact you already stored word for word inserted a second copy on brains without an embedding key; now it returns the existing fact. A fence row that quoted a fence marker became a live marker and the row vanished; the marker is now encoded inside the cell. Health counters follow your schema pack instead of a hardcoded person/company list, `recall` hits say which source they came from, cross-source links your source policy approved are written by every writer, and a question like "what happened in September 2026" bounds `think` to that month on its own.++ ### How to use it++ - `gbrain dream --phase consolidate --dry-run` now lists the clusters it would write under `details.clusters` before you commit to them.+ - `gbrain config set chronicle.max_events_per_page 40` caps how many chronicle events one page may contribute (default 25).+ - `gbrain config set dream.attribution_checks true` turns on two optional checks that stop an assistant's proposal from being recorded as the user's decision. Off by default; nothing changes until you opt in.+ - `gbrain search modes` suggests EmbeddingGemma's query prompt (`task: search result | query: `) when that model is the embedder.+ - `think` with no `since`/`until` reads the one explicit date the question names (`2026-09-15`, `2026-09`, `September 2026`); the result says `window_source: 'question'`. Caller bounds still win.++ ### What you'd see++ | Before | After |+ |---|---|+ | Two untyped event facts with a 0.86 cosine merged into one take and the older one expired | They stay two facts; untyped facts need the 0.95 explicit-duplicate bar and must not differ in a number, date, amount or negation |+ | `put_page` with `expectedRevision` (typo) committed and ignored the field | `invalid_params` naming the unknown parameter, in every `strict_params` mode |+ | `put_page` on an existing page with no `expected_revision` → `revision_conflict` | `revision_required`, with `get_page` as the fix; a genuine stale revision is still `revision_conflict` |+ | `get_health.entity_page_count` 0 on a brain whose pack declares `yc` or `civic` entity pages | Counts the types the active pack declares, per source; a pack that does not load reports `entity_types_status: pack_unavailable` |+ | A provider 403 "project does not have access to model X" classified `auth` | `model_not_found`, with the model fix |++ ### Itemized changes++ - **Consolidate no longer merges unrelated event facts** (#6023). Untyped facts (no metric claim) cluster only at `max(cycle.consolidate.cluster_threshold, 0.95)` and never when `claimsDiverge` finds a negation, number, date or amount that differs; typed metric facts keep the configured threshold because a metric series is expected to change value. `--dry-run` returns up to 50 clusters in `details.clusters`; private fact text appears only for the local CLI, other callers see ids and visibility. *Things to watch:* fewer takes from untyped event facts; facts an earlier run merged keep the `valid_until` it stamped (`remember … replaces` records a correction).+ - **Write operations reject unknown parameters** (#5970). Every mutating tool (`put_page`, `remember`, `add_timeline_entry`, …) refuses a parameter it does not declare with `invalid_params` and `suggestion: 'Unknown parameter "<name>".'`, before admission and in every `strict_params` mode. Read tools keep the mode's behavior. The merging page writes (`add_tag`, `remove_tag`, `add_timeline_entry`, `takes_*`) now declare the `expected_revision` and `force` they always honored (full tool surface; the starter schema is unchanged), so a caller that sent them keeps working.+ - **`writeSingleFact` dedups exact repeats and never mints a fallback entity** (#5152, #5504 part (a), #5275). An exact repeat for the same entity, or with no resolved entity, returns the existing fact (`status: duplicate`) with or without an embedding; a remote or unattributed caller never dedups against a private-sourced fact. An unmanaged write whose entity fell back to slugification stores `entity_slug` NULL instead of a placeholder slug, so the stub guard has nothing to refuse. The legacy backstop's exact check also covers facts with no resolved entity.+ - **Fence markers written into a cell are encoded, never live** (#5395). A claim quoting a fence marker round-trips as text; the row is no longer lost.+ - **Dream `synthesize_concepts` writes one page per concept, however the label is spelled** (#5965). Stems that differ only by hyphens, underscores and dots fold onto one page per run: the spelling with a live `concepts/` page wins, otherwise the one most atoms use (ties go to the hyphenated form); the others redirect for that run. Two spellings that both already have live pages are left apart. *Things to watch:* existing duplicate pages are not merged for you; `details.folded_spellings` names each fold.+ - **Mechanical attribution checks, off by default** (#5425). `dream.attribution_checks true` makes `propose_takes` store a proposal as held by `brain` when its numbers, dates and quotes appear only in assistant turns and no user turn states or accepts them, and quarantines a synthesis sentence a later user turn takes back on the same number or date (`superseded_in_source` in `unverified_claims`). Off, output is byte-identical.+ - **Chronicle caps events per page** (#5329). `chronicle.max_events_per_page` (default 25, 1..1000) keeps the first N survivors in judge order after the date rules; dropped proposals are counted as `over_cap`.+ - **Cross-source links the source policy approved are written by every writer** (#4680). A link whose target resolves into another source under `link_resolution.cross_source`, or a `[[source:slug]]` reference from a federated source, is written by `put_page`, `capture`, the managed stale pass and the reconciliation sweep, not only by `extract links`. The write receipt reports drops as `auto_links.skipped_cross_source`; a reader granted one source still never sees the other source's endpoint, and the entity card confines an untrusted caller's outgoing edges to its own source. *Things to watch:* pages that cite another source gain the edges you opted into on their next write or stale pass; the sweep reports an unqualified target that exists only elsewhere as `cross_source` rather than `missing_target`.+ - **`links.resolution_type` is written** (#4381): `qualified` for a `[[source:slug]]` reference, `unqualified` otherwise; edges no reference derived keep NULL. Existing rows are not backfilled.+ - **Entity counters follow the active schema pack** (#4772). `get_health` / `gbrain health` (`entity_page_count`, `link_coverage`, `timeline_coverage`, `most_connected`) and doctor's `graph_coverage` / `orphan_ratio` count the page types the pack declares with `primitive: entity`, resolved per source when sources carry their own pack (`schema_pack.source.<id>`). A pack that does not load reports `entity_types_status: pack_unavailable` (0 entities, `null` ratios, a `graph_coverage` warn naming the pack). Helper shape by @Matthieusabourin2. *Things to watch:* on gbrain-base brains `yc`, `civic` and `organization` pages now count, so coverage ratios move and a `graph_coverage` warn can appear where those pages are unlinked; `gbrain schema active` repairs a broken pack.+ - **`code-callers` lists callers inside top-level `describe`/`it` blocks and other module-level statements** (#5001). A top-level statement containing a call in a JS/TS/TSX/Python/Ruby file is chunked as `module` / `__module__` (`<file-basename>::__module__`), so its calls get edges; both edge writers share `mapCodeEdges`. *Things to watch:* the next `gbrain sync` re-chunks and re-embeds those files once (priced as `grammar_drift`; `CHUNKER_VERSION` stays 8). Attribution follows @nikolai-vysotskyi's suggestion.+ - **A 403 model-access denial classifies `model_not_found`, not `auth`** (#5394). The model-not-found phrases are tested before the status map; a plain 401/403 stays `auth`.+ - **A write naming no `expected_revision` for an existing page is `revision_required`** (#5385), with `get_page` as the fix; a wrong revision stays `revision_conflict`; `force` and `revision_backfill_pending` are unchanged. `remember` and `add_tag` on an existing page still converge through the semantic retry.+ - **`propose_takes` skips atoms and every dream-written page** (#5211). New atoms carry `dream_generated: true` next to `extracted_by`, so facts extraction, the chronicle and transcript discovery skip them like other derived pages; `listCandidatePages` also drops legacy `type: atom` pages that carry neither stamp. The source page an atom was extracted from is still a candidate.+ - **Every `recall` hit names its `source_id`** (#4830), falling back to the scope's single source; a federated read with no row source leaves it absent rather than guessing.+ - **`think` bounds its evidence to the one explicit date a question names** when the caller passes no window (PR #5086). ISO day, ISO month or English month + year; a bare year, two distinct dates, an invalid date or a relative phrase leaves the window open. `window_source` and a `WINDOW_FROM_QUESTION` warning say when it applied. Contributed by @tarush1989. Supersedes #5086.+ - **Matryoshka models that answer at their native width are fitted to the brain's width** (PR #5921). A recipe that declares `matryoshka: { native, prefixes }` for a model (NVIDIA's Nemotron-3-Embed-8B at 4096 with 1024/2048) has its native-width response sliced and L2-normalized before the dimension check; every other vector is untouched. Contributed by @abudhi19. Supersedes #5921.+ - **Doctor suggests EmbeddingGemma's query task prompt** (PR #6062): `task: search result | query: ` for `embeddinggemma` models in `gbrain search modes`. The document-side formatting stays open (#3783, #5215). Contributed by @xorets. Supersedes #6062.++ ### For contributors++ - Pinned tests that changed with the contracts above: `test/legacy-fact-extraction-dedup.test.ts` and `test/facts-drain-scheduler.test.ts` (#5275: an exact unparented repeat from a second page is a duplicate), `test/write-attribution-facts-takes.test.ts` (#5504 seeds the entity page), `test/denied-after-list.test.ts` (#5970 sends only declared params), `test/managed-phase-matrix.test.ts` (#6023 fixture), `test/cycle-consolidate*.test.ts`, `test/e2e/cycle-consolidate-postgres.test.ts`, `test/managed-maintenance.test.ts`, `test/trust-taint-dream.test.ts`, `test/write-attribution-cycle.test.ts` (#6023 thresholds); `test/facts-fallback-stub-guard.test.ts`, `test/fence-write.test.ts`, `test/memory-verbs-conformance.test.ts` (#5504 NULL entity, #5152 dedup); `test/persistence-reconcile.test.ts` (#5970 refuses before admission); `test/link-preparation-shared-index.test.ts` (#4680 writes the approved edge); `test/capture-op.test.ts`, `test/persistence-revision-conflict-message.test.ts` (#5385 code); `test/evidence-delivery.test.ts` key list (#4830). Each flip carries a comment citing its issue.+ - Goldens regenerated for the contract changes above: `test/fixtures/goldens/cli/tools-json.json`, `exports/types.json`, `sql-text/links.json`, `evidence-delivery/off-path.json` (recall hits gain `source_id`) and the agent-contract journey `recall-degraded.json`.+ - New Postgres arms: `test/e2e/consolidate-divergence-postgres.test.ts`, `test/e2e/write-single-dedup-postgres.test.ts`, `test/e2e/chronicle-max-events-5329-postgres.test.ts`.+ - `docs/architecture/key-files/core-ai.md` split: providers, recipes and the Voyage width plumbing now live in `core-ai-continued.md`.+## [0.60.161.0] - 2026-10-11**`embed --max-usd` is enforced, a fence write no longer wipes a database-only page, and write-gate overrides and Git child processes are hardened.**