Skip to content

Add typed detection metadata to memory notes#182

Merged
rolandpg merged 7 commits into
masterfrom
copilot/add-typed-detectionmeta-extension
Jul 7, 2026
Merged

Add typed detection metadata to memory notes#182
rolandpg merged 7 commits into
masterfrom
copilot/add-typed-detectionmeta-extension

Conversation

Copilot AI commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Detection-rule ingest now preserves structured rule metadata on notes instead of relying on body parsing alone. This adds a typed DetectionMeta extension to MemoryNote.metadata and populates it for Sigma and YARA writes so downstream consumers can query detection fields directly.

Related issue

This change addresses the follow-up for typed detection metadata support in Sigma/YARA ingest.

Changes

  • Added a shared DetectionMeta dataclass to the note schema and exposed it on MemoryNote.metadata.detection.
  • Plumbed structured metadata through note construction and MemoryManager.remember(...) so detection metadata is carried all the way into persisted notes.
  • Persisted detection metadata in the SQLite backend so it survives round-trips and is available from fetched notes.
  • Populated DetectionMeta during Sigma ingest with logsource facets, rule level/status, references, false positives, and fields.
  • Populated DetectionMeta during YARA ingest with CCCS tier, source path, MITRE ATT techniques, category, technique, author, fingerprint, and sample hashes.
  • Added regression tests covering Sigma and YARA ingest persistence of the new structured metadata slot.

Testing

  • Tests pass (pytest tests/ -v)
  • Linting passes (ruff check src/zettelforge/)
  • New tests added for new functionality
  • No new external infrastructure dependencies without discussion

Copilot AI changed the title [WIP] Add typed DetectionMeta extension to MemoryNote.Metadata Add typed detection metadata to memory notes Jul 2, 2026
Copilot AI requested a review from rolandpg July 2, 2026 01:48
claude added 2 commits July 7, 2026 02:14
…d formatting

The bulk-ingest test doubles' remember() signatures predate the new
metadata parameter, so every fixture errored per-file and bulk ingest
silently ingested zero rules. Also sort sqlite_backend imports and
apply ruff formatting so the CI lint gate passes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TqYpmV8TABMzq27HBTLtNP
@rolandpg
rolandpg marked this pull request as ready for review July 7, 2026 02:16
devin-ai-integration[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

- construct(): a partial caller Metadata (e.g. only detection set) no
  longer lands in the default domain — domain/tier fall back to the
  construct() arguments unless explicitly set, via model_fields_set.
- remember(): reject metadata= combined with evolve=True instead of
  silently dropping it; the extraction pipeline produces multiple fact
  notes and cannot carry a single caller Metadata.
- sigma/yara ingest: re-ingesting an unchanged rule now backfills the
  detection slot on notes written before DetectionMeta existed, so
  existing installations gain typed metadata without re-creating notes.

Regression tests added for all three.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TqYpmV8TABMzq27HBTLtNP
devin-ai-integration[bot]

This comment was marked as resolved.

Deep-copy a caller-supplied Metadata in construct() so reusing one
template across several remember() calls cannot cross-mutate notes.
Detection backfill on re-ingest now prefers rewrite_note (falling back
to write_note) so updated_at reflects the metadata change.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TqYpmV8TABMzq27HBTLtNP
@rolandpg
rolandpg merged commit be1f756 into master Jul 7, 2026
14 checks passed
@rolandpg
rolandpg deleted the copilot/add-typed-detectionmeta-extension branch July 7, 2026 02:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add typed DetectionMeta extension to MemoryNote.Metadata

3 participants