Add DFIR memory model, SQLite append-only store, SANS-aligned docs, and tests#71
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1e0e84da9b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| FROM memory_versions | ||
| GROUP BY memory_id | ||
| ) latest | ||
| ON latest.memory_id = mv.memory_id AND latest.max_version = mv.version | ||
| WHERE mv.approval_state = ? |
There was a problem hiding this comment.
Select latest approved version per memory ID
list_entries_by_scope computes the max version across all states and only then filters to approved rows, so a memory with v1=approved and v2=proposed/rejected disappears from retrieval entirely. In DFIR workflows this hides the most recent validated memory and can cause the runner to miss known-good patterns whenever a newer unapproved draft exists. Filter by approval_state='approved' inside the MAX(version) subquery (or rank approved rows) so each memory_id returns its latest approved version.
Useful? React with 👍 / 👎.
| conn.execute( | ||
| """ | ||
| INSERT INTO memory_versions (memory_id, version, approval_state, payload_json, created_at) | ||
| VALUES (?, ?, ?, ?, ?) | ||
| """, |
There was a problem hiding this comment.
Enforce monotonic version progression on inserts
put_entry inserts caller-supplied versions without checking prior versions for that memory_id, so the store accepts gaps and out-of-order history (for example inserting version=5 first or regressing after a higher version). This violates the commit’s append-only versioning contract and can permanently skew lineage/audit interpretation because version order is treated as canonical in reads. Validate against the current max version and require the next expected version before insert.
Useful? React with 👍 / 👎.
Motivation
Description
docs/DFIR_AGENTIC_V1_PLAN.mdanddocs/DFIR_MEMORY.mddescribing the v1 roadmap, memory layers, allowed operations, and validation rules.verdict/schemas/memory.pydefiningMemoryType,ApprovalState,MemoryOperation,MemoryEntry, andMemoryUpdateProposalwith validation logic enforcing evidence, timestamps, and version constraints.verdict/memory/store.pywithMemoryStoresupportingput_entry,get_latest_entry,list_entries_by_scope,put_proposal,approve_proposal, andget_proposal_statesemantics.verdict/memory/__init__.pyand unit teststests/schemas/test_memory_schema.pyandtests/memory/test_memory_store.pycovering schema validation, versioning, proposal lifecycle, and scope/confidence queries.Testing
pytest tests/schemas/test_memory_schema.pyand they passed.pytest tests/memory/test_memory_store.pyand they passed.Codex Task