C-286: OAA sovereign memory layer — signed /api/oaa/kv journal#41
Merged
Conversation
Add HMAC-verified POST for structured agent KV writes with canonical JSON hashing, append-only OAA_MEMORY.json entries (OAA_MEMORY_ENTRY_V1), GET queries by key prefix, and async Civic Core mesh/ingest bridge. Document Render env vars KV_HMAC_SECRET and CIVIC_LEDGER_TOKEN; add Vitest coverage for canonical JSON and HMAC helpers.
kaizencycle
marked this pull request as ready for review
April 19, 2026 18:40
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This change introduces POST/GET
/api/oaa/kvas the sovereign append journal for Mobius: HMAC-authenticated structured writes, deterministic SHA-256 hashing over canonical JSON, append-only persistence intoOAA_MEMORY.json, and an async optional forward to Civic Protocol Core viaPOST …/mesh/ingest(when ledger URL + bearer token are configured).Motivation / problem
The stack needs a signed, hash-chained memory trail separate from hot KV. OAA already owns
OAA_MEMORY.jsonand governance surfaces; this PR implements the write contract and read surface described for C-286.What changed
types/oaa-kv.ts—AgentKVPayloadandOaaMemoryEntry(OAA_MEMORY_ENTRY_V1).lib/crypto/canonicalJson.ts— sorted-key canonical JSON for stable signing/hashing.lib/crypto/hmac.ts— SHA-256 hex, HMAC sign/verify (timing-safe).lib/kv/store.ts— append-only journal entries merged with existing memory file shape;getLatestHashwalks from the end for the latestOAA_MEMORY_ENTRY_V1only.lib/ledger/bridge.ts— fire-and-forgetsealToLedgerusingCIVIC_LEDGER_URLorLEDGER_BASE_URL+CIVIC_LEDGER_TOKENorLEDGER_ADMIN_TOKEN.pages/api/oaa/kv.ts— GET?prefix=for structured entries; POST verifies HMAC over canonical{ key, value, agent, cycle, intent, previousHash }.render.yaml— optionalKV_HMAC_SECRETandCIVIC_LEDGER_TOKENfor oaa-hub (secret also falls back toMEMORY_HMAC_SECRET/OAA_HMAC_SECRETin code).vitest.config.ts+tests/oaa-kv-sovereign.test.ts— unit tests for canonical JSON and HMAC.Breaking changes
No. New endpoint and env vars; existing memory notes remain readable.
Tests
npm run lintandnpm run type-checkstill fail on pre-existing repo issues (binary/parsing TSX files, etc.); new files pass IDE diagnostics.Checklist