Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
Merge remote-tracking branch 'origin/master' into capy/pglite-analyze-replan
garrytand781ac232d4c
diff --cc CHANGELOG.mdindex 03abf61f4b,84cb13cf44..f0685053b2--- a/CHANGELOG.md+++ b/CHANGELOG.md@@@ -10,14 -10,20 +10,28 @@@ credits are retained; no result has beeidentifiers and attribution are available in the pre-removal Git revision`6040075c6cb95be5881cc2e1b76ef7d71f4e5d29` (retained on 2026-09-23).+## [Unreleased]++**A long-running PGLite process picks up fresh planner statistics instead of keeping the plans it made before them.** PGLite has no autovacuum, so a freshly imported brain has no statistics until planner-stats' first-read refresh runs `ANALYZE`. But gbrain's PGLite statement cache keeps named prepared statements, and PostgreSQL keeps a prepared statement's plan across `ANALYZE`, so every statement prepared before the refresh kept its no-statistics plan for the life of the process (a `gbrain serve`, an agent session, a script). On a 55,838-page brain imported without statistics, `entity names` with 50 names stayed at 3.4 to 3.7 s for every call after the refresh. With this fix the calls after the first take 1.2 to 1.5 s, the same as a freshly started process.++### Itemized changes++- **`ANALYZE` and `VACUUM` clear the PGLite statement cache** (`src/core/pglite-statements.ts`), like DDL already did, so the next call re-prepares and plans with the new statistics. This covers planner-stats' refreshes, `gbrain repair planner-stats`, projection statistics and the persistence journal's `VACUUM (ANALYZE)`. Postgres is unchanged. `test/pglite-statements.test.ts` checks that a statement prepared before `ANALYZE` is re-prepared after it; the check fails without the fix.++ ## [0.60.191.0] - 2026-10-13++ **`gbrain setup codex` gives Codex memory in one command, with the same target-first, hash-owned shape as `gbrain setup claude-code` (D8's Codex slice).** It shows the brain, source, launcher and owner before writing, creates a keyless brain only when none exists, and wires the MCP server plus the read-context hooks SessionStart and UserPromptSubmit. In three fresh installs on codex-cli 0.162.1, a fresh Codex session answered a question only the injected context could answer, with 0 tool calls. The bootstrap harness also stops wiring Codex transcript capture when capture was declined or in registrar mode.++ ### Itemized changes++ - **`gbrain setup codex`** (`src/core/setup/codex.ts`, `src/commands/setup.ts`): Codex needs three writes, `[mcp_servers.<name>]` in `config.toml`, the hook groups in `hooks.json` and a `[hooks.state."<key>"]` trust table per group (without it Codex lists the hook and never runs it). Memory-only by default; SessionEnd capture only with `--capture`, providers only with `--providers`, existing opt-outs win; `--scope project` exits 2 because Codex keeps hooks and config in `CODEX_HOME`. `--dry-run`, `--json`, `--surface`, `--no-hooks`, `--remove` and `GBRAIN_SURFACE` work as for Claude Code.+ - **Ownership and crash safety:** receipt `.gbrain-connection-codex-<name>.json` beside `config.toml` (receipt version 2) with a sha256 fingerprint per owned entry; write order receipt → brain → MCP → inert hook groups → trust tables, reversed on `--remove`, so every crash point leaves the hooks inert or fully wired and resume never duplicates. An entry the user edited is preserved and reported; the other owned entries are still written or removed. Setup's groups carry `GBRAIN_HOOK_LANE=setup`, and a bootstrap-lane wiring of the same events is refused as an owner conflict. `codex-toml.ts` gains single-table read, append and remove that keep every other byte.+ - **Bootstrap Codex capture gate** (`src/core/bootstrap/harness.ts`): `--no-capture` now suppresses the Codex SessionEnd capture hook and registrar mode (a non-loopback `--url`) no longer wires it, since it would capture into the local brain instead of the registered remote one. Disclosed in BEHAVIOR_CHANGES.+ - **`gbrain hook user-prompt --harness codex`** confines and parses Codex transcripts with the Codex capture spec and skips the Claude Code pressure probe; before, every native Codex prompt degraded with `transcript_outside_projects_dir`.+ - **Capability table v2:** the Codex row reports setup supported, pull connection-verified and push native-verified only when the receipt owns the UserPromptSubmit trust entry (otherwise native-pending), with a `push_evidence` field. `docs/mcp/CODEX.md` no longer says Codex has no lifecycle hooks.+ - **Tests:** the Codex lifecycle in `test/setup.test.ts` (byte-exact remove, crash resume at every seam, edited-entry preservation, a shifted hook index, two installs, unowned and remote MCP tables, consent and flags, the bootstrap-lane conflict, live trust-hash vectors); registrar mode and `--no-capture` in `test/bootstrap-harness.serial.test.ts`; Codex transcript confinement in `test/hook-command.serial.test.ts`. The #6499 backup-verification tests now run their probe stub on a virtual clock (a forced 400 ms per-repo delay fails the old tests and passes the new ones), and `test/session-seat-synthesize.test.ts` prints the whole phase result when it fails.+ - Credit: the Codex context-hook approach draws on #6408 and #6409 by @benswinney and the #5577 discussion in #6283 by @andreineacsu (evidence only; those PRs stay open).+## [0.60.190.0] - 2026-10-13**No Postgres statement outlives its budget now, a stalled managed sync says what is blocking it, and doctor stops misleading on managed and image-heavy brains (#6543, part 2).** v0.60.187.0 stopped the Supavisor wedge itself. This release closes the gaps the reporter hit around it. A statement that kept receiving bytes was never retired, so `/health?deep=1` stayed red forever. A sync stalled 300-600 s with "claimable here: no" no matter the cause. `repair failed-writes --apply` stopped at every pending write. Doctor recommended a `--retry-failed` that did nothing on a managed brain, and reported existing images as missing when only their letter case differed.