feat(core,ledger): decision mutation contract B1+B2 (GH-330)#337
Merged
Conversation
… fields (GH-330) B1: Add status_to_is_active() helper as single source of truth for the is_active/status mapping (COMPAT-01). Modify decision materialization in append_event() and insert_imported_decision() to always write both columns in sync. Deactivation UPDATE now also sets status='superseded'. B2: Extend DecisionPayload with 5 optional fields: authority, affected_paths, tags, review_after, reversibility. Decision materialization reads these from the payload instead of hardcoded defaults. All existing callers pass None and get safe defaults. extract_decision() updated to parse new fields from event JSON. Contract: COMPAT-01, MUTATION-01 Refs: GH-decision-deepening Track B1, B2 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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
status_to_is_active()helper enforcing COMPAT-01 invariant.append_event()andinsert_imported_decision()now write bothstatusandis_activein sync. Deactivation UPDATE setsstatus = 'superseded'alongsideis_active = FALSE.DecisionPayloadwith 5 optional fields (authority,affected_paths,tags,review_after,reversibility). Decision materialization reads these from payload with safe defaults.extract_decision()parses new fields from event JSON.Nonefor new fields).edda-deriveandedda-servetest modules.Contract compliance
is_activeandstatusalways agree — verified by integration testUPDATE decisionsstatements are insqlite_store.rsonlycargo clippy --workspace --all-targets -- -D warningspassesTest plan
test_status_to_is_active— unit test for the mapping helpertest_status_is_active_sync_on_insert— insert + supersede cycle with COMPAT-01 checktest_decision_payload_new_fields_roundtrip— write with all new fields, read back correctlytest_decision_payload_defaults_when_none— verify defaults (human/[]/[]/NULL/medium)test_decision_payload_serde_backward_compat— old JSON without new fields deserializestest_decision_payload_serde_with_new_fields— new JSON round-trips correctlycargo clippy --workspace --all-targets -- -D warningszero warningscargo test -p edda-core -p edda-ledgerall pass (2 pre-existing failures on main excluded)Closes #330
🤖 Generated with Claude Code