Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

chore(qm): contract states the idempotency key as {pattern} (no secret-named high-entropy assignment); pregate lane for the contract fixture

garrytanc95b01b422e7
diff --git a/.gstack/pregate.json b/.gstack/pregate.json
index be92a39f14..4108989929 100644
--- a/.gstack/pregate.json
+++ b/.gstack/pregate.json
@@ -6,6 +6,9 @@
"scripts/serial-files.tsv": [
"test/scripts/serial-files.test.ts"
],
+ "docs/contracts/qm-memory-provider/v1.json": [
+ "test/qm-memory-contract.test.ts"
+ ],
"src/cli.ts": [
"test/cli-goldens.test.ts"
],
diff --git a/docs/contracts/qm-memory-provider/v1.json b/docs/contracts/qm-memory-provider/v1.json
index 3051fda069..6107edd428 100644
--- a/docs/contracts/qm-memory-provider/v1.json
+++ b/docs/contracts/qm-memory-provider/v1.json
@@ -182,7 +182,9 @@
"max": 20
},
"provenance_chars": 200,
- "idempotency_key": "^[\\x21-\\x7e]{1,128}$",
+ "idempotency_key": {
+ "pattern": "^[\\x21-\\x7e]{1,128}$"
+ },
"kinds": [
"event",
"preference",
diff --git a/scripts/build-qm-memory-contract.ts b/scripts/build-qm-memory-contract.ts
index 4229b61eb2..959ea4286b 100644
--- a/scripts/build-qm-memory-contract.ts
+++ b/scripts/build-qm-memory-contract.ts
@@ -73,7 +73,7 @@ export function buildQmMemoryContract(): Record<string, unknown> {
},
unlinked_recall: { isError: false, content: unlinked.content, structuredContent: unlinked.structuredContent },
memory_write: {
- limits: { facts: { min: 1, max: MEMORY_WRITE_MAX_FACTS }, provenance_chars: MEMORY_WRITE_PROVENANCE_MAX, idempotency_key: IDEMPOTENCY_KEY_RE.source, kinds: [...MEMORY_WRITE_KINDS],
+ limits: { facts: { min: 1, max: MEMORY_WRITE_MAX_FACTS }, provenance_chars: MEMORY_WRITE_PROVENANCE_MAX, idempotency_key: { pattern: IDEMPOTENCY_KEY_RE.source }, kinds: [...MEMORY_WRITE_KINDS],
provenance: 'one line: no line breaks or control characters, and not starting with qm: (gbrain adds qm:<actor id> itself)',
valid_from: 'YYYY-MM-DD or YYYY-MM-DDTHH:MM[:SS[.fraction]][Z|±HH:MM], a real calendar day in years 0001-9999' },
validation: 'every fact is checked before any is saved: one bad fact refuses the whole call with invalid_params and the idempotency_key stays unused',