Files
erp/.claude/skills/dolibarr-sandbox-write/replay-packs/2026-07-11-books-regularization
arcodangeandClaude Fable 5 3840e74dcd feat(write-skill): idempotency keys — manifest replay is a no-op (erp#44)
Learning #4 of the 2026-07-11 rehearsal: manifest B failed mid-run and could
not be re-applied — op 1 (the DARNIS invoice) had already run and a replay
would have duplicated it. Every write op now dedupes BEFORE any POST:

- thirdparty-create.sh: by exact name (promote '#thirdparty:name=' semantics);
  ambiguous (2+) aborts; an existing fiche missing the requested role aborts
  (refuse-never-repair). Emits {"id", "deduped"} instead of a bare id.
- invoice-create.sh: supplier kind by (socid, ref_supplier) — same key with a
  different total aborts as a conflict; customer kind (or supplier without
  ref_supplier) by (socid, date, total_ttc ±0.02, line fingerprint) with descs
  HTML-unescaped. Credit notes are never candidates. A deduped DRAFT with
  validate:true is validated on replay, so an interrupted run converges.
- payment-record.sh: by (invoice, amount, normalized transaction_id), composing
  with the erp#37 varchar(50) normalization on BOTH sides so historical
  long-form nums still match; same tx + different amount aborts; without a tx
  id there is no dedupe key (warned). Dedupe answers id:null (the payments list
  exposes no paiement rowid) + the existing bank line.
- All three refuse to POST blind when the dedupe lookup fails with anything but
  the documented empty-list 404 (the voir_tous trap would otherwise mint dupes).
- promote-apply.sh: marks each op created / deduped=true inline and totals them
  in the summary — an all-deduped second run is visible proof of a no-op.
- promote-plan.sh: advertises each op's dedupe key (and flags tx=MISSING as
  'a replay WILL double-pay').

Proof:
- tests/run-tests.sh: 5 new offline cases (11 total) — dedupe hits POST
  nothing, conflicts/ambiguity abort pre-POST, long-form history dedupes,
  draft convergence validates; stub extended to serve the new lookups with the
  live-observed empty behaviors ([] for invoices/payments, 404 for tiers).
- tests/replay-idempotency.sh (new, live): double-applies a self-contained
  manifest on the sandbox — run 1 '3 created' (rows 1/1/1), run 2 '3 deduped'
  with row counts unchanged and the stored num in erp#37 short form.
- The historic manifest-B now replays on the sandbox as 5/5 deduped, zero new
  rows — the exact replay Learning #4 declared impossible.

SKILL.md updated in the same change (per-op dedupe keys, replay-safety section,
gotchas); the 2026-07-11 runbook's Learning #4 carries a dated resolution
addendum.

Closes erp#44.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VRShc4QhLLU73FLHx9vskh
2026-07-18 23:46:05 +02:00
..

Replay pack — books regularization 2026-07-11

The complete, provenance-verified write pack from the 2026-07-11 books-regularization session (memory: books-gap-2026-07). Rehearsed green on the sandbox (FAF2026010013 + payments, predicted-delta verified). Prod replay: EXECUTED 2026-07-15 (operator "go", key derived at runtime, never stored): prelude green (7 drafts → FAC004-007 + FAF2026010-012), manifests A+B applied (F1045 → FAF2026013; payment ids 7,8,13-16), fresh provenance 36/36 BEFORE writing (PDFs re-fetched from books@ per the section below — the re-fetch path works), snapshots before e97fc10e256d… / after 731c8f443ebf…, bank match --since 2026-01-010 UNKNOWN. Remaining: bucket C non-invoice UI entries (erp#57).

Contents

File What it is
manifest-A-km-payments.json 2 KissMetrics customer payments (Wise wires 2 147,00 € + 2 195,97 €, tx ids from the activity feed)
manifest-B-suppliers.json DARNIS F1045 supplier invoice (214,70 HT / 257,64 TTC) + its payment + Anthropic/Mistral payment ops
manifest-B2-sandbox-payments.json Sandbox-side payment re-run after the varchar(50) fix (erp#37)
prod-replay-prelude.sh Pre-replay guards: fresh checkpoint assumptions, target checks, env pinning
rehearsal-runbook.md Step-by-step of the rehearsal: what ran, in what order, with which gates
verify-provenance.py The anti-hallucination PoC — 36 field-level checks: every critical value re-verified against source-PDF text (pdftotext) + FRESH Qonto/Wise pulls; locale-normalized (219,50219.50, Wise 2,147 thousands format). 36/36 green at rehearsal time.

Source PDFs (not committed — re-fetchable)

verify-provenance.py expects ./pdfs/ containing: F1045_ARCODANGE_2026-06-30.pdf, F1046_ARCODANGE_2026-06-29.pdf, Invoice-9BF0758D-695749.pdf (Anthropic), invoice-MSTRL-API-814045-001.pdf (Mistral). Re-fetch via the arcodange-email-ingest skill (they live in books@ — workflow 2 downloads attachments by message id) or from the GED once erp#43 attaches them.

Who consumes this pack

  • erp#41 (provenance checker as a promote-plan stage) — industrializes verify-provenance.py.
  • erp#42 (compliance linter) — these manifests are the legitimate fixtures that must PASS.
  • erp#44 (idempotency keys) — replay these manifests twice on a checkpoint; run 2 must be all-deduped.
  • erp#43 (GED attach) — attaches the four PDFs to FAF2026010013 on the sandbox.

Rule this pack proves

No agent-typed value reaches a write without mechanical corroboration: source-anchored (the exact string exists in the source document) + cross-system (bank feed to the cent, fresh pull at check time) + read-back (predicted-delta after apply). Refuse, never repair.