Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(persistence): writer status labels the answering process's consumer (C-NEW-4)
time-attacka0f0f2e855f8
diff --git a/docs/wave9/sg.md b/docs/wave9/sg.mdindex 986506eb09..886586988f 100644--- a/docs/wave9/sg.md+++ b/docs/wave9/sg.md@@ -11,6 +11,7 @@ Integrator: fold these into CHANGELOG.md and docs/UPGRADING_DOWNSTREAM_AGENTS.md- **Portable canonical skills list their usable tools (#5150).** A shared skill published without `tools:` now inherits the caller's available brain tools as `usable_tools` (list, detail, and the v1 compatibility catalog), matching host-repository skills; `tools: []` still permits none. Revisions published before this release re-read their SKILL.md on `get_skill`; `list_skills` keeps them empty until republished.- **`put_skill` refuses an empty SKILL.md (A-NEW-5).** An empty or whitespace-only entry point is `invalid_params` instead of publishing a blank skill.- **`gbrain reindex --markdown` works on managed brains (#5377, C-NEW-5).** It used to fail every page with "cannot mutate a managed brain through the legacy writer", while doctor, upgrade and post-upgrade kept prescribing it. On a managed brain it now runs the projection repairs (`gbrain repair safe-chunks`, then `contextual-mode` unless `--no-embed`): no page revision, journal request or canonical file changes. `--type` is refused on managed brains with the repair commands.+- **`gbrain sources writer status` no longer reports a CLI's own consumer as the brain's ingress (C-NEW-4).** The `ingress` field (always `not_running` from a one-shot CLI) is replaced by `local_process_ingress`, which says it describes only the process that answered; ownership stays under `worktrees` and `bindings`.## Upgrade-note rows@@ -23,3 +24,4 @@ Integrator: fold these into CHANGELOG.md and docs/UPGRADING_DOWNSTREAM_AGENTS.md| Canonical skills without `tools:` inherit brain tools (#5150) | Clients reading `usable_tools` for shared skills | `gbrain call get_skill '{"name":"<skill>"}'` | Declare `tools:` in the skill to narrow it || Empty SKILL.md refused (A-NEW-5) | Editors publishing placeholder skills | none | Write a non-empty SKILL.md || Managed `reindex --markdown` delegates to projection repairs (#5377) | Managed brains with chunker or contextual-mode drift | doctor calibration hint (`gbrain reindex --markdown`) now works | Run `gbrain repair safe-chunks` / `contextual-mode` directly for per-kind control |+| `writer status`: `ingress` → `local_process_ingress` with a `scope` note (C-NEW-4) | Scripts reading `ingress` from `gbrain sources writer status --json` | none | Read `local_process_ingress.state`; for ownership read `worktrees`/`bindings` |diff --git a/src/core/persistence/diagnostics.ts b/src/core/persistence/diagnostics.tsindex 7a465494ff..9642088062 100644--- a/src/core/persistence/diagnostics.ts+++ b/src/core/persistence/diagnostics.ts@@ -79,9 +79,13 @@ export async function readWriterDiagnostics(engine: BrainEngine) {WHERE error_detail IS NOT NULL ORDER BY sequence DESC LIMIT 20`);const limits = await readJournalLimits(engine);const { persistenceConsumerStatus } = await import('./service.ts');- const ingress = persistenceConsumerStatus(engine);+ // C-NEW-4: the consumer is per process, so this is the answering process's own ingress, never proof the brain's owner is down.+ const local = persistenceConsumerStatus(engine);+ const local_process_ingress = { ...local, scope: local.state === 'not_running'+ ? 'The process that answered has no resident consumer (a one-shot CLI, for example); another process may own writes. See worktrees and bindings for ownership.'+ : 'The resident consumer of the process that answered this status.' };return { ...brain, sampled_at: new Date().toISOString(), publication_concurrency: publicationConcurrency(engine),- ingress, worktrees, counters, queue, effects, limits, capacity: capacityDiagnostics(counters, limits),+ local_process_ingress, worktrees, counters, queue, effects, limits, capacity: capacityDiagnostics(counters, limits),recent_failures: failures.map(row => ({ ...row, next_action: row.error_detail?.origin === 'database_guard' ? DATABASE_REFUSAL_HINT : DATABASE_TRIGGER_HINT })),blockers: blockers.map(row => {const health = writeHealth(row);diff --git a/test/persistence-diagnostics.test.ts b/test/persistence-diagnostics.test.tsindex 41fd3f3788..02c573b018 100644--- a/test/persistence-diagnostics.test.ts+++ b/test/persistence-diagnostics.test.ts@@ -131,3 +131,13 @@ test('admin diagnostics account for queued work and configured limits without exexpect(JSON.stringify(status)).not.toContain('execution_token');}});++test('writer status labels the answering process consumer instead of reporting it as brain ingress (C-NEW-4)', async () => {+ for (const engine of engines) {+ await disposePersistenceConsumer(engine);+ const diagnostics = await readWriterDiagnostics(engine) as Record<string, unknown> & { local_process_ingress: { state: string; scope: string } };+ expect(diagnostics.ingress).toBeUndefined();+ expect(diagnostics.local_process_ingress.state).toBe('not_running');+ expect(diagnostics.local_process_ingress.scope).toContain('another process may own');+ }+});