Repository navigation
feat: record compiler version provenance - #521
Merged
smaramwbc merged 1 commit intoOct 14, 2026
Merged
Conversation
Signed-off-by: MaximGit-tech <maxim@MacBook-Air-Maksim.local>
smaramwbc
approved these changes
Oct 14, 2026
smaramwbc
left a comment
Owner
There was a problem hiding this comment.
Nice work, this is thorough. All three write paths are covered, the tests bite, and no migration is needed since metadata_ is already JSONB. Merging, and I am following up with one tweak: the structured path reserves compiler and compiler_version but not model or prompt_version, so a candidate could still supply those two. Thanks!
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
Adds compiler provenance metadata to every newly compiled memory so Statewave can tell which compiler configuration produced it.
This implements the missing compiler-version information requested in #443.
What changed
LLM compiler
LLM-produced memories now record:
compilermodelprompt_versioncompiler_versionprompt_versionis a deterministic SHA-256 fingerprint of the prompt templates used to produce the memory.The normal extraction pass versions the active
_system_prompt(), including the compose-unit variant when enabled.Recall-sweep memories are versioned separately. Their prompt version includes both the active main extraction prompt and
_RECALL_SWEEP_PROMPT, because the sweep output also depends on the first-pass results it receives.Recall-sweep memories continue to carry:
Heuristic compiler
Heuristic-produced memories now record:
{ "compiler": "heuristic", "compiler_version": "heuristic:1", }The heuristic compiler uses an explicit revision rather than hashing Python source code, so formatting or comment-only changes do not unnecessarily change the compiler version.
Existing claim metadata is preserved and merged with the new compiler provenance.
Structured candidates
Memories produced directly from structured memory candidates now record:
{ "compiler": "structured", "compiler_version": "structured:1", }This keeps their provenance accurate because structured candidates bypass both LLM extraction and heuristic extraction.
Producer-supplied metadata is preserved, while the reserved compiler provenance fields are set by Statewave.
Shared versioning
Added a small compiler-version helper that produces deterministic SHA-256 fingerprints from version components.
Components are encoded separately before hashing so different component boundaries cannot accidentally produce the same fingerprint.
Backward compatibility
No database migration or backfill is required.
Existing memories without
compiler_versionremain unchanged and therefore continue to represent unknown compiler provenance, as described in #443.Tests
Added regression coverage for:
Also updated existing heuristic claim tests to account for compiler provenance being present even when no claim is attached.
Validation:
The remaining warnings are pre-existing AsyncMock warnings unrelated to this change.
Closes #443