Skip to main content

// decision_log

Every row a reason. Every move reversible.

The decision_log is the single source of truth for every catalog move Magistry makes — and the model for every other audit table on the plane. Anatomy below.

Append-only Reversal pre-stored Tier-gated writes
decision_log · live
#84193  DISCOUNT_TEST  SKU-LIN-228 (-15%)
        ACTIVE → ON_DISCOUNT       ✓ APPLIED

#84194  DRAFT          SKU-CER-019
        ACTIVE → DRAFTED           ✓ APPLIED

#84195  SCALE_WINNER   SKU-WOO-441
        ACTIVE → ACTIVE (paid sig) ✓ APPLIED

#84196  REVIVE_SEASONAL SKU-LIN-007
        SEASONAL_VAULT → PUBLISHED ⏸ HELD
        trigger: SEASONAL_WINDOW_OPEN
        reason: kill_switch flipped at 09:14

— cycle 2026-05-25T09:00Z, 142 rows total —

// anatomy

Read a row, understand the day.

Nine fields. Same shape on every row. The example below is a discount test that opened a 14-day window for a single SKU — the full evidence chain, the trigger, the reversal op, all in one row.
decision_log · row #84193
row_id            : 84193
product_id        : p_88421
sku               : SKU-LIN-228-SND-L

from_state        : ACTIVE
to_state          : ON_DISCOUNT
action            : DISCOUNT_TEST

trigger           : OPTIMIZE_CYCLE_FAILED
trigger_meta      : 2 consecutive cycles, no lift

evidence          : {
  perf_window     : 9123     (28d rolling)
  cycle_history   : 771      (2 prior cycles)
  judge_score     : 0.88     (above 0.85 floor)
  margin_tier     : "A"      (cost verified)
  store_p75       : 2.4x     (winner floor)
  current_roas    : 1.6x     (28d)
  policy_mode     : autonomous
}

reversal_op       : { action: "PRICE_RESTORE",
                      restore_to: 89.00,
                      auto_fire_at: "+14d" }

applied_to_shopify: true
applied_at        : 2026-05-25T08:02:14Z
applied_by        : catalog_agent.discount_executor

status            : APPLIED
audit_chain       : signal → plan → judge → execute → log
↶ rollback available · 1 clickstored forever

product_id

uuid

The variant the row pertains to — joined to products table.

p_88421

from_state

lifecycle_state

Where the SKU was before the action.

ACTIVE

to_state

lifecycle_state

Where it lands. Validated against ALLOWED_TRANSITIONS.

ON_DISCOUNT

action

Action enum

One of the enumerated moves — never freeform text.

DISCOUNT_TEST

trigger

Trigger enum

Why the action was emitted. The reason the engine picked this row.

OPTIMIZE_CYCLE_FAILED

evidence

jsonb

Pointers to the windows, scores, and citations behind the call.

{cycle: 771, perf: 9123, judge: 0.88}

applied_to_shopify

bool

Dry-run vs live. The single flag that gates real-world impact.

false (Phase 1)

reversal_op

jsonb

Pre-stored inverse op — populated at plan time, not rollback time.

{action: PRICE_RESTORE}

applied_at

timestamptz

When the executor stamped the mutation. Append-only past tense.

2026-05-25T08:02Z

// triggers

Why a row exists.

Every decision row carries a trigger — the reason the engine emitted the action. Triggers are enumerated; no row gets a freeform 'because we felt like it'.

AUDIT_CLASSIFICATION

Initial classification of a freshly-synced SKU into WINNER / MID / LOSER buckets.

ROAS_BELOW_FLOOR

Rolling-window ROAS falls below the store-calibrated p75 winner floor.

SALES_ZERO_N_DAYS

Zero units sold for N consecutive days — typically 21d for default plans.

OPTIMIZE_CYCLE_FAILED

Copy + image regenerate cycle ran twice without lift — discount test next.

SEASONAL_WINDOW_OPEN

Calendar trigger paired with positive signal — vault SKU returns to PUBLISHED.

ANOMALY_RESPONDER_HALT

Spend spike or conversion drop detected — auto-PAUSE within rate-limit bounds.

OPERATOR_OVERRIDE

A human did something. Logged the same way as agent moves — same plane, same shape.

// evidence

A jsonb blob with sharp edges.

The evidence column is jsonb — flexible per agent, per skill, per action type — but every key is namespaced and pointer-bearing. No prose, no vibes. Numbers, IDs, references to upstream windows.

// windows

  • perf_windowid of the rolling perf snapshot read
  • anomaly_windowid of the anomaly-detection slice
  • ad_perf_windowchannel-specific rolling perf id

// scores

  • judge_scoresecond-pass model score (0–1)
  • calibration_scorestore-specific threshold confidence
  • uniqueness_scorepgvector distance from existing catalog

// citations

  • policy_citecs_policy_chunks row id (RAG-grounded)
  • supplier_signalsupplier reality flag set
  • operator_overrideuser id, if applicable

// policy

  • policy_modeadvisory | assisted | autonomous
  • rate_limit_statusremaining budget for this action class
  • kill_switch_statecaptured at write-time, not config-time
evidence jsonb · sample
{
  "windows": {
    "perf_window":     9123,
    "anomaly_window":  4471
  },
  "scores": {
    "judge_score":     0.88,
    "calibration":     0.92,
    "uniqueness":      0.78
  },
  "citations": {
    "policy_cite":     214,
    "supplier_signal": "batch_swap_flag",
    "operator_override": null
  },
  "policy": {
    "mode":            "autonomous",
    "rate_limit":      "ok (3/8 this week)",
    "kill_switch":     "off"
  },
  "math": {
    "store_p75_roas":  2.4,
    "current_roas":    1.6,
    "margin_tier":     "A"
  }
}

// reversal model

One click. Inverse op. New row.

Rollback is not undo. It's the application of a pre-computed inverse, logged as a fresh row pointing back at the original. Two rows, one chain, full history retained.
// original
row #84193
  action      : DISCOUNT_TEST
  delta       : -15%
  status      : APPLIED
  applied_at  : 2026-05-25T08:02Z

  reversal_op : { action: "PRICE_RESTORE",
                  restore_to: 89.00,
                  fire_mode:  "one_click" }
// reversal (new row)
row #84207  (reverses #84193)
  action      : PRICE_RESTORE
  delta       : +15% (restores €89.00)
  status      : APPLIED
  applied_at  : 2026-05-25T11:32Z

  reverses    : 84193
  triggered_by: operator (jane@store.com)

— audit chain stays intact —

// why append-only

The history that doesn't move.

Editable history is not history.

If a row can be changed after the fact, it's a note. Magistry rows are events — they happened, they're stamped, they don't move.

Reversal is a new row, not an edit.

Roll back row #84193 and you get row #84194 — pointing at the original. The chain is the story; nothing gets quietly overwritten.

Append-only makes audits cheap.

When finance asks 'what did the agent do on the 14th', the answer is a SELECT. Not a reconstruction.

// decision_log

A history you can defend.

Every action a row, every row a reason, every reason a citation. The decision_log is what turns an agent into a teammate you can put on the org chart.

Append-only · One-click rollback · Built to be read