Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(#5988): remote put_page refusals name the line only; local sync output keeps the key
garrytanb6e1b45e3468
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex c267f43ea7..e4bc6ac5a8 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -93,7 +93,7 @@ Now the sync **holds** that one file and moves on. Everything else imports. The#### Prevention-- gbrain's own frontmatter writers serialize every value safely. `put_page`, `capture` and `gbrain import` share the sync screen: frontmatter gbrain reads by quoting is accepted, anything sync would hold refuses with the same code. The pre-commit hook validates staged content in one `gbrain frontmatter validate --staged` process and prints the fix and restage step.+- gbrain's own frontmatter writers serialize every value safely. `put_page`, `capture` and `gbrain import` share the sync screen: frontmatter gbrain reads by quoting is accepted, anything sync would hold refuses with the same code. A remote caller's refusal names the line but not the key, since key names can be private. The pre-commit hook validates staged content in one `gbrain frontmatter validate --staged` process and prints the fix and restage step.- New `sync.holds`, `sync.hold_cap`, `sync.hold_escalate_count`, `sync.hold_escalate_pct` and `sync.parser_regression` config keys.#### Docsdiff --git a/src/core/persistence/verb-errors.ts b/src/core/persistence/verb-errors.tsindex 72e4d7e9df..e584e40a08 100644--- a/src/core/persistence/verb-errors.ts+++ b/src/core/persistence/verb-errors.ts@@ -2,7 +2,7 @@ import { verbError, OperationError } from '../ops/contract.ts';import { isTerminalWriteState, isWriteErrorCode, type WriteErrorCode, type WriteReceipt } from './types.ts';import { pendingWriteHint } from './health.ts';import { UNBOUND_COLLISION_MESSAGE, UNBOUND_PUBLICATION_MESSAGE } from './unbound-source.ts';-import { frontmatterHoldMessageWithoutKeys, isFrontmatterHoldMessage } from '../markdown.ts';+import { isFrontmatterHoldMessage } from '../markdown.ts';const FRONTMATTER_SLUG_CONFLICT = /^The frontmatter slug "[^"\n]{1,300}" in [^/"\n][^"\n]{0,1000} conflicts with its path, which expects slug "[^"\n]{1,300}"\. Remove `slug:` or make it match the path\.$/;@@ -83,7 +83,7 @@ export function writeFailureDiagnostic(code: string, message?: string | null): {suggestion: 'Read the current page and review the intended change before submitting a corrected write.' };if (code === 'invalid_params' && message && FRONTMATTER_SLUG_CONFLICT.test(message)) return { reason: code, message,suggestion: 'Correct the frontmatter in the file and commit the change.' };- if (code === 'invalid_params' && isFrontmatterHoldMessage(message)) return { reason: code, message: frontmatterHoldMessageWithoutKeys(message!),+ if (code === 'invalid_params' && isFrontmatterHoldMessage(message)) return { reason: code, message: message!,suggestion: 'Correct the named frontmatter line in the file (one line per key, the whole value quoted) and commit the change.' };return { reason: isWriteErrorCode(code) ? code : 'storage_error', message: 'The write did not commit. Inspect its durable request on the source host.',suggestion: 'Resolve the reported write failure before starting a corrected attempt.' };diff --git a/test/put-page-recoverable-frontmatter.test.ts b/test/put-page-recoverable-frontmatter.test.tsindex 1a54baa000..df734bdfcc 100644--- a/test/put-page-recoverable-frontmatter.test.ts+++ b/test/put-page-recoverable-frontmatter.test.ts@@ -87,20 +87,21 @@ describe('put_page with recoverable frontmatter', () => {expect(strict.data).toMatchObject({ title: 'Re: payments roundup', author, source: '"Quoted" trailing' });});- test('frontmatter that needs guessing is refused with a typed code, its key and line, and no raw value', async () => {+ test('frontmatter that needs guessing is refused remotely with a typed code and its line, never a key name or raw value', async () => {const result = await put('notes/guess', '---\ntitle: alice-example first line\nalice-example second line\ntype: note\n---\n\nBody.\n');expect(result.response.isError).toBe(true);const text = JSON.stringify(result.payload);expect(text).not.toContain('alice-example');- expect(result.payload).toMatchObject({ error: 'invalid_params', code: 'invalid_frontmatter', reason: 'needs_interpretation', detail: 'key title, line 2' });- expect(result.payload.suggestion).toContain('frontmatter line 2 (key "title")');+ expect(result.payload).toMatchObject({ error: 'invalid_params', code: 'invalid_frontmatter', reason: 'needs_interpretation', detail: 'line 2' });+ expect(result.payload.suggestion).toContain('frontmatter line 2:');+ expect(result.payload.message).not.toContain('"title"');expect(await engine.readPageSnapshot('notes/guess', { sourceId: 'default' })).toBeNull();});test('a protected key that would be read as a broader value is refused', async () => {const result = await put('notes/private', '---\ntitle: "Hello\nvisibility: private\nsummary: x"\n---\n\nBody.\n');expect(result.response.isError).toBe(true);- expect(result.payload).toMatchObject({ code: 'invalid_frontmatter', reason: 'ambiguous_protected_key', detail: 'key visibility, line 3' });+ expect(result.payload).toMatchObject({ code: 'invalid_frontmatter', reason: 'ambiguous_protected_key', detail: 'line 3' });expect(await engine.readPageSnapshot('notes/private', { sourceId: 'default' })).toBeNull();});});