# Spec 12: Aere VSM (Verifiable Semantic Memory) — DONE On-chain attestation for an AI agent's vector-store memory: clear owner, verifiable append-only history, PQC-authenticated commits, and paid attested retrieval on the AERE402 rail. ## Deliverables (all real, tested) 1. Contract: `aerenew/contracts/contracts/agentic/AereVectorStore.sol` (solc 0.8.23, new file, no deployed contract modified) 2. Test: `aerenew/contracts/test/aere-vector-store.test.js` — 8 passing 3. Doc: `aerenew/docs/AERE-VSM.md` ## Contract surface - `createStore(storeId, falconPubKey?, settlementToken?, queryPrice?, paymentRecipient?)` Config FIXED at creation (no setters). Classical store (empty key, owner-signed) or post-quantum store (897-byte Falcon-512 key, header 0x09). Fail-closed on malformed key / inconsistent price config. - `commit(storeId, vectorRoot, vectorCount, uri, falconSig)` -> version Append-only versioned root. PQC store: falconSig verified in full via 0x0AE1 over a per-version challenge (COMMIT_DOMAIN|chainid|this|storeId|version|root|count|keccak(uri)); invalid sig reverts PQCVerificationFailed (fail-closed). Classical store: msg.sender==owner. Empty/zero precompile return (pre-fork) treated as INVALID. Reuses the exact Falcon-512 input construction from AerePQCAttestation.sol. - `attestRetrieval(storeId, version, queryHash, resultRoot, receiptId)` -> retrievalId Version must exist (1..current) or revert UnknownVersion (fail-closed). Priced store: must cite a matching unconsumed AERE402 receipt (PaymentRequired / ReceiptConsumed / ReceiptMismatch). - `paidQuery(storeId, queryHash, agentId, amount, nonce, deadline, authSig)` -> receiptId References existing AERE402Facilitator (NOT redeployed). Vector store is the payee, calls facilitator.settle, forwards received tokens (balance delta) to paymentRecipient in-tx; no cross-call custody. Mints a receipt bound to (store, query, agent, nonce). - Inclusion views: `verifyVectorInclusion(storeId, version, leaf, proof)` (membership in the committed vectorRoot) and `verifyResultInclusion(retrievalId, leaf, proof)` (membership in the attested resultRoot). OpenZeppelin MerkleProof (sorted-pair keccak256). - No admin, no owner override, no upgrade hook, no path rewrites a committed version. ## Real test result `npx hardhat test test/aere-vector-store.test.js` from aerenew/contracts: 8 passing. 1. PQC commit v1 then v2, append-only history preserved 2. tampered Falcon sig rejected fail-closed (also wrong-version + wrong-key rejected) 3. empty precompile return (pre-fork) treated as invalid 4. retrieval attestation records vs valid version; missing/zero version reverts 5. inclusion proof: member verifies, non-member fails (vectorRoot + resultRoot) 6. AERE402 paid-query: real facilitator settle, fee to sink, remainder to recipient, receipt gates attestRetrieval; unpaid reverts PaymentRequired, reuse ReceiptConsumed, wrong-query ReceiptMismatch; store holds 0 across the call 7. classical store: only owner may commit (non-owner NotOwner) 8. createStore fail-closed on bad key / inconsistent config / duplicate storeId Falcon MOCKED in test (MockPQCPrecompile at 0x0AE1 via hardhat_setCode); real encoding proven separately vs LIVE mainnet precompile by AerePQCAttestation path. ## Honesty flags - [VERIFY]: on-chain commit registry, PQC-authenticated commits (0x0AE1), retrieval attestation, inclusion proofs, AERE402 paid-query gate — built + tested. - [MEASURE]: embedding model, vector similarity search / index, raw vector data, and semantic quality/relevance — all OFF-CHAIN. On-chain attestation proves PROVENANCE + OWNERSHIP + that a retrieval named a committed version, NOT semantic quality/relevance. - Scope boundary preserved: PQC-authenticated memory commits do NOT make consensus post-quantum (blocks still Besu QBFT + classical ECDSA). No new token (AERE402 uses existing rails). - No em-dashes / "--" in prose. Brand "Aere Network"/"Aere", ticker AERE uppercase.