Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
Merge remote-tracking branch 'origin/gbra133-pr2b-status' into gbra133-pr2b
garrytan1c1587a261ee
diff --cc src/core/behavior-change-notice.tsindex 9927e6063a,c3db8575ff..43fe5c78e3--- a/src/core/behavior-change-notice.ts+++ b/src/core/behavior-change-notice.ts@@@ -976,8 -976,9 +976,10 @@@ export const BEHAVIOR_CHANGES: Readonly{ since: '0.60.316.0', text: '`gbrain autopilot --status` grades a running daemon from its own schedule (#7003): the daemon writes `autopilot.heartbeat.json` beside its lock with its next tick, so a healthy daemon on a long adaptive sleep no longer reads `stale` (exit 1); a missing or outdated sidecar falls back to the interval-flag rule. `--status --json` adds `stale_after_source` (`daemon` or `flag`) and `next_tick_at`.' },{ since: '0.60.318.0', text: 'On Postgres, every ANALYZE gbrain runs on its own (the import, sync, reindex and embed-drain statistics refreshes, the search guard, `gbrain repair planner-stats --apply` and the ANALYZE after a migration builds an index) now takes its table\'s lock with NOWAIT and is deferred with a warning when another session holds the table (a vacuum, an ANALYZE or an index build), instead of waiting on it: waiting on a running autovacuum made Postgres cancel it (#7083). The repair reports such a table `deferred`; rerun it once the vacuum finishes. An embed drain now skips its `content_chunks` statistics refresh when it changed fewer than 50 + 10% of the table\'s sampled chunks and the chunk statistics exist. `gbrain doctor` `planner_stats_stale` also warns when a hot table of at least 100,000 rows holds more dead rows than autovacuum\'s vacuum threshold and no vacuum has completed on it for 24 hours (`details.vacuum_starved`).' },{ since: '0.60.318.0', text: 'On a managed brain with Git durability on, a Git effect whose file is absent (a page delete) now pushes when the checkout is ahead of its upstream, so a removal commit whose first push failed reaches the remote on the retry instead of the effect completing `target_absent` with nothing pushed (#7089); its outcome reads `target_absent` with `push: committed`, and a push that keeps failing keeps the effect queued and then parks it. `gbrain doctor` `git_convergence` warns at once, instead of after 6 hours, when such a checkout is ahead with no Git effect queued, running or parked (`stranded: true` in `details.roots`), and its fix is `gbrain git commit-push --push-only --keep-checkout --path <root>`.' },- // GBRA-133 PR 2b (Postgres round trips, #6930). Sits before PR 4b's block, which test/behavior-change-notice-6712-block.test.ts pins last. `since` is restamped at the merge slot.- // GBRA-133 PR 2b (truthful status). `since` is restamped at the merge slot.- { since: '0.60.316.0', text: 'Doctor `managed_sync_latency` now grades the commit that is still waiting, not only commits that already synced: with `sync.on_commit` on or `sync.freshness_target_seconds` set, a source whose checkout HEAD has waited past the target (default 300 s) warns and past one hour fails, dated from the reflog entry that moved HEAD or the notifier\'s recorded first_due_at, and a waiting commit it cannot date (no reflog, rewritten history) warns as unknown. It grades classic sources the same way and reports keyword-visible and embedded freshness per source (`details.freshness_by_source`). `gbrain sources status` compares HEAD only (an uncommitted edit is no longer lag) and dates a behind source\'s lag from when the commit landed instead of from the last no-op sync.' },- { since: '0.60.316.0', text: '`gbrain sources mirror-readonly <id> --dry-run` and `gbrain sources mirror-writable <id> --dry-run` now print the change they would make with a `(dry-run; no side effects)` banner and write nothing (#7086); before, both ignored `--dry-run` and set or cleared the read-only mirror flag.' },++ // GBRA-133 PR 2b (Postgres round trips #6930, the idle fast path, truthful status, #7086). Sits before PR 4b's block, which test/behavior-change-notice-6712-block.test.ts pins last. `since` is restamped at the merge slot.+ { since: '0.60.320.0', text: 'On a transaction-mode pooler URL (PgBouncer or Supabase port 6543, `prepare=false`, or `GBRAIN_PREPARE=false`), gbrain now pipelines the statements of one transaction on the server connection the pooler pins for it, instead of waiting one round trip per statement, so a sync or write over a slow link finishes in fewer round trips. It still never sends a statement behind one that may end the transaction (COMMIT, ROLLBACK, END, ABORT, PREPARE TRANSACTION), never pipelines autocommit statements on such a URL, and keeps prepared statements off, so the pooler cannot hand a statement to another client\'s connection. Set `GBRAIN_PG_TXN_PIPELINE=0` to send one statement per round trip again.' },++ { since: '0.60.320.0', text: 'Doctor `managed_sync_latency` now grades the commit that is still waiting, not only commits that already synced: with `sync.on_commit` on or `sync.freshness_target_seconds` set, a source whose checkout HEAD has waited past the target (default 300 s) warns and past one hour fails, dated from the reflog entry that moved HEAD or the notifier\'s recorded first_due_at, and a waiting commit it cannot date (no reflog, rewritten history) warns as unknown. It grades classic sources the same way and reports keyword-visible and embedded freshness per source (`details.freshness_by_source`). `gbrain sources status` compares HEAD only (an uncommitted edit is no longer lag) and dates a behind source\'s lag from when the commit landed instead of from the last no-op sync.' },++ { since: '0.60.320.0', text: '`gbrain sources mirror-readonly <id> --dry-run` and `gbrain sources mirror-writable <id> --dry-run` now print the change they would make with a `(dry-run; no side effects)` banner and write nothing (#7086); before, both ignored `--dry-run` and set or cleared the read-only mirror flag.' },// #6712 PR 4b (the level-triggered sync pass, design v3.2 §13) and #6885. `since` is a placeholder equal to the branch's VERSION until the merge-slot stamp.{ since: '0.60.320.0', text: 'On a managed brain a plain `gbrain sync` of a non-company source no longer imports only `last_commit..HEAD`: each pass compares every file at HEAD with what the database absorbed (the page and its import record) and admits what differs, so out-of-band changes (a reset or revert, a rewritten history, a lost manifest, an interrupted run) converge on the next plain sync with no flag. When nothing moved since the last converged pass (same HEAD, parser, schema pack and selection, nothing open), the tick is idle and only `last_sync_at` changes; a full comparison still runs at least every 200 passes or 24 hours. A pass uses at most 4 rounds. Company-brain sources keep their cursor.' },{ since: '0.60.320.0', text: 'In committed mode (the default) a managed sync never imports a dirty working copy, as before: the level-triggered pass keeps the cursor path\'s guarantee and never adopts or writes over such a file either. When the committed file is unchanged since its import, the uncommitted edit is left alone and nothing is held; when the commit moved under an uncommitted edit, the file is held `worktree_dirty` and the page and the edit stay as they are. Commit or restore the file and sync again.' },diff --cc src/core/source-health.tsindex 01765e26ce,f9672d14ca..04ec5890cc--- a/src/core/source-health.ts+++ b/src/core/source-health.ts@@@ -20,12 -20,18 +20,19 @@@* Remote callers (federation_health on the HTTP MCP path) read the stored* `newest_content_at` column instead — NO git subprocess on a DB-supplied* local_path (preserves the v0.41.27.0 trust boundary).+ *+ * GBRA-133 PR 2b.5: the local probe compares HEAD only (an uncommitted edit+ * to a tracked file is not a pending commit), and a source that is behind+ * dates its lag from when the commit landed (the reflog entry that moved+ * HEAD off last_commit) or from the commit notifier's persisted+ * first_due_at, not from the last no-op heartbeat of last_sync_at. Both+ * paths raise the lag to first_due_at's age (src/core/sync-pending.ts).*/import { execFileSync } from './spawn.ts';+import { execFileBounded } from './bounded-child-exec.ts';import type { BrainEngine } from './engine.ts';import { parseSourceConfig, type SourceRow } from './sources-load.ts';- import { isSourceUnchangedSinceSync } from './git-head.ts';+ import { probeSourceGitState } from './git-head.ts';import { resolveHoursEnv } from './env-number.ts';import { isSyncDisabledConfig } from './sync-policy.ts';import { gitChildEnv } from './git-env.ts';