Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix: a webhook capture to a mixed-case slug replaces the existing page

garrytana22efbc12402
diff --git a/CHANGELOG.md b/CHANGELOG.md
index fd2b0796f7..10f316ca3b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -84,6 +84,10 @@ Hermes transcript snapshots no longer fail while Hermes is writing, and `gbrain
- `src/core/mentions/pass.ts`: on a belief-covered source the mention pass locks the page keys and journals its link writes through `unmanagedBeliefPoint(..., 'mention_pass')`, so the drift check no longer reconciles a freshly published page as drift (#7031). Tests: `test/belief-stale-links-7031.test.ts`, `test/e2e/belief-stale-links-7031-postgres.test.ts`.
- `src/commands/doctor/checks/atom-body-recheck.ts` (new), `src/commands/doctor/checks/extraction-sync.ts`: `atom_provenance_drift` finds the `page_versions` edition whose hash matches the atom's `source_hash` and compares its body with the live body, fences removed; equal bodies count under a new `body_unchanged` detail (at most 200 groups, 20 versions each). The doctor JSON goldens gain `"body_unchanged": 0`, and `scripts/page-body-readers-baseline.tsv` gains three INLINE rows for the re-check's body reads (#6825). Test: `test/doctor-atom-provenance-drift-6825.test.ts`.
+#### Webhook captures
+
+- `src/core/minions/handlers/ingest-capture.ts`: the job normalizes its slug once (`validateSlug`) before its snapshot, applied-record and writer lookups, so a mixed-case `X-Gbrain-Slug` naming an existing page on a managed brain replaces that page instead of dead-lettering with `revision_required`. Test: `test/ingest-capture-mixed-case-slug.test.ts`.
+
## [0.60.660.0] - 2026-11-11
**Agent reads answer "nothing here" instead of refusing, and say why a list came back empty.** These fixes come from agent transcripts where models kept getting refused or got bare empty answers.
diff --git a/src/core/minions/handlers/ingest-capture.ts b/src/core/minions/handlers/ingest-capture.ts
index d6ca89ebf9..b80e9c9d58 100644
--- a/src/core/minions/handlers/ingest-capture.ts
+++ b/src/core/minions/handlers/ingest-capture.ts
@@ -165,6 +165,9 @@ export function makeIngestCaptureHandler(engine: BrainEngine) {
} else {
slug = defaultSlugForEvent(event);
}
+ // GST-2114: page lookups (the snapshot, the applied record, the writer check) are exact, and the door lowercases;
+ // normalizing once here keeps a mixed-case X-Gbrain-Slug bound to the page the door writes.
+ slug = validateSlug(slug);
// Untrusted-payload posture. For v1, the flag is propagated for audit
// but not enforced at this layer (see file header). Future v2 wiring
diff --git a/test/ingest-capture-mixed-case-slug.test.ts b/test/ingest-capture-mixed-case-slug.test.ts
new file mode 100644
index 0000000000..d36be14914
--- /dev/null
+++ b/test/ingest-capture-mixed-case-slug.test.ts
@@ -0,0 +1,34 @@
+/**
+ * GST-2114: a mixed-case X-Gbrain-Slug captures the page the door writes.
+ *
+ * On a managed brain the ingest_capture job read the snapshot with the raw mixed-case slug, missed the stored
+ * lowercase page, sent no expected_revision, and the door (which lowercases) refused revision_required, so a capture
+ * the route had answered 202 dead-lettered.
+ * Protects: on a managed brain, a capture sent to Notes/Mixed-Example replaces the existing notes/mixed-example.
+ */
+import { describe, expect, test } from 'bun:test';
+import type { BrainEngine } from '../src/core/engine.ts';
+import { computeContentHash } from '../src/core/ingestion/types.ts';
+import { makeIngestCaptureHandler } from '../src/core/minions/handlers/ingest-capture.ts';
+import type { MinionJobContext } from '../src/core/minions/types.ts';
+import { submitPageMutation } from '../src/core/persistence/page-mutations.ts';
+import { managedBrain } from './helpers/managed-brain.ts';
+
+const note = (title: string, line: string) => `---\ntype: note\ntitle: ${title}\n---\n# ${title}\n\n${line}\n`;
+const jobCtx = (id: number, data: Record<string, unknown>): MinionJobContext => ({ id, name: 'ingest_capture', data,
+ attempts_made: 0, idempotency_key: null, signal: new AbortController().signal, deadlineAtMs: null, shutdownSignal: new AbortController().signal,
+ updateProgress: async () => {}, updateTokens: async () => {}, log: async () => {}, isActive: async () => true, readInbox: async () => [] });
+const captureData = (content: string, slug: string, sourceId: string) => ({ slug, sourceId, event: { source_id: 'webhook-client-example', source_kind: 'webhook',
+ source_uri: 'mcp-webhook:client-example:1', received_at: new Date().toISOString(), content_type: 'text/markdown', content,
+ content_hash: computeContentHash(content), untrusted_payload: true } });
+const text = async (engine: BrainEngine, slug: string, sourceId: string) => (await engine.readPageSnapshot(slug, { sourceId }))?.page.compiled_truth ?? null;
+
+describe('ingest_capture with a mixed-case slug on a managed brain (GST-2114)', () => {
+ test('a capture sent to a mixed-case slug replaces the existing lowercase page', () => managedBrain(async ({ engine, ctx }) => {
+ await submitPageMutation(ctx, { operation: 'put_page', params: { slug: 'notes/mixed-example', content: note('Mixed example', 'Original body.') } });
+ const result = await makeIngestCaptureHandler(engine)(jobCtx(4, captureData(note('Mixed example', 'Captured body.'), 'Notes/Mixed-Example', 'default')));
+ expect(result.status).toBe('imported');
+ expect(result.slug).toBe('notes/mixed-example');
+ expect(await text(engine, 'notes/mixed-example', 'default')).toContain('Captured body.');
+ }), 120_000);
+});