Skip to content

Store: add with_audited_effect (type-enforced audit-before-effect pairing) #215

Description

@George-RD

Parent

#208 (Spec: deepened Store interface)

Blocked by

#213 (Add Store transaction combinators)

Deliverables

Add the audit-before-effect combinator so a wrong ordering stops compiling on the effect path (expand step).

  • AuditDescriptor value type carrying the audit-row inputs (kind, action, decision, reason, task_grant_id, refs) as data.
  • Store::with_audited_effect(&self, descriptor: AuditDescriptor, effect: impl FnOnce(&rusqlite::Transaction) -> Result<T, StoreError>) -> Result<T, StoreError>: runs effect and append_audit_conn inside one Immediate transaction, commits both atomically. It is the ONLY effect-path entry that can write an effect row; audit-only and non-effect internal-maintenance writes use separately named entries.
  • Pilot the rollbackable shape by migrating store/identity.rs::owner_assert_identity_binding (currently hand-pairs effect + append_audit_conn).
  • Test: a forced append_audit failure rolls back the effect row (no orphan effect — AD-105 ledger-before-consume).

Rationale in spec #208 (decision D-002). This encapsulates the 83 hand-paired append_audit_conn sites; the mass migration is T6.

Verification

./scripts/check.sh green. An effect-only write on the effect path must not compile (exercised by the migrated pilot).

🤖 Generated from spec #208 (wayfinder #189, map #182).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready-for-agentFully specified, ready for an AFK agent

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions