AI_happ

Regulation-to-Workflow Diff Engine

ESPR 2027 · Textile Compliance Demo
1
Current Workflow
2
Load Rule Pack
3
Proposed Diff
4
Impact Simulation
5
Approval Gate
6
Deployed
🗂
Current Workflow — v1.0
ProductRecord schema as deployed. State machine shows existing custody hops. Gaps highlighted in red.
ProductRecord Fields — v1.0
Field Type Status Source
name string ✓ Present schema.org
material string ✓ Present schema.org
countryOfOrigin Country ✓ Present schema.org
hasCertification Certification[] ✓ Present schema.org
prov:culturalTradition string ✓ Present prov: custom
prov:techniqueTerms string[] ✓ Present prov: custom
recycled_content_pct number ✗ Missing ESPR Art. 7(1)(b)
composition_by_weight object[] ✗ Missing ESPR Annex III
State Machine — v1.0

Custody hops in source chain order. The ComplianceReview state required by ESPR Art. 11 does not exist in v1.0. Records can proceed directly from TransferCustody to PutOnMarket — creating a legal gap as of 2027-07-01.

ReceiveGoods
Receipt & verification
TransferCustody
Chain of custody hop
ComplianceReview ??
NOT IN SCHEMA
PutOnMarket
Market entry event
EndOfLife
Disposal / circularity
📋
Load Rule Pack — ESPR 2027
Fetching and parsing espr-2027-rules.json. Three requirements extracted and staged for diff analysis.
Rule Pack Source
Parsing
espr-2027-rules.json
Reading regulation text…
🔀
Proposed Diff — v1.0 → v1.1
Minimum changes required to satisfy ESPR 2027. No upstream records are modified — all changes are additive.
proposeWorkflowDiffFromRuleText( ) stub · will connect to Anthropic API
+ ADD FIELD CHG-001 → ESPR-R001
recycled_content_pct — number, 0–100
New optional field on ProductRecord. Required for any product entering EU market after 2027-01-01. Validators accept 0 (explicit non-recycled declaration).
Before (v1.0)
// field does not exist
After (v1.1)
recycled_content_pct: Option<f32>, // range: 0.0–100.0 // schema path: credentialSubject
+ ADD FIELD CHG-002 → ESPR-R002
composition_by_weight — Vec<FibreComponent>
New optional field: array of {fibre: String, pct: f32}. Values must sum to 100.0. Validation at write time; legacy records exempt until 2027-01-01.
Before (v1.0)
// field does not exist
After (v1.1)
composition_by_weight: Option<Vec<FibreComponent>>, // struct FibreComponent { // fibre: String, // pct: f32, // }
+ STATE HOP CHG-003 → ESPR-R003
ComplianceReview — new CustodyEvent type
New custody event type. State machine updated: PutOnMarket is rejected unless a ComplianceReview event is present in the chain. Reviewer identity + ESPR checklist version required.
Before (v1.0)
TransferCustody → PutOnMarket ✓
After (v1.1)
TransferCustody → ComplianceReview ← NEW → PutOnMarket ✓ TransferCustody → PutOnMarket ✗ BLOCKED
Agentic Clarity note: These are Layer 1 diffs — business logic only. No DHT schema (Layer 2) is modified. Existing records remain valid and readable. The append-only chain is preserved.
📊
Impact Simulation
Blast radius across existing records. Counts are seeded from the Economy3 demo dataset (120 records).
87
Records need updating
33
Already compliant
174
Missing field values
23
Invalid state transitions
3.2
Est. person-hours
0
Records destroyed
Affected Records — Sample (top 6)
Record ID Product CHG-001 CHG-002 CHG-003
DEMO001 Bikaner Merino Rug ✗ missing ✓ present ✗ no review
DEMO002 Heritage Field Jacket ✓ 18% ✓ present ✗ no review
DEMO003 Cotton Twill Fabric ✗ missing ✗ missing ✗ no review
DEMO004 Alpaca Studio Yarn ✗ missing ✓ present ✗ no review
REC-0084 Indigo Woven Shawl ✓ 0% ✓ present ✓ reviewed
REC-0091 Recycled Denim Panel ✓ 72% ✓ present ✓ reviewed
Note on legacy records: Records created before v1.1 deployment are not retroactively invalid. They are flagged as "pre-ESPR" and exempt from enforcement until the Delegated Act grace period expires (estimated 2027-07-01 for Art. 11 state hop).
🔐
Approval Gate
Review blast radius. Add notes. Approve or reject the proposed diff before deployment.
Blast Radius Summary
Schema version v1.0 → v1.1
Changes proposed 3 (CHG-001, CHG-002, CHG-003)
Layer affected Layer 1 (business logic only)
DHT schema modified? No — append-only preserved
Records affected 87 of 120 (73%)
Invalid state transitions after deploy 23 blocked until review added
Estimated remediation effort 3.2 person-hours
Rollback available? Yes — revert to v1.0 anytime
Regulation enforcement date 2027-01-01 (fields) · 2027-07-01 (state hop)
✗ Diff rejected. No changes deployed. Workflow remains at v1.0. Return to Panel 3 to revise the diff or contact the regulation team.
🚀
Deployed — v1.1 Active
ESPR 2027 workflow changes are live. Audit trail recorded. Rollback available.
v1.1 ACTIVE — ESPR 2027 compliant
Deployed Changes
CHG-001 — recycled_content_pct ✓ Deployed
CHG-002 — composition_by_weight ✓ Deployed
CHG-003 — ComplianceReview state hop ✓ Deployed
DHT schema (Layer 2) Unchanged — no migration needed
Pre-v1.1 records Flagged "pre-ESPR" — not invalidated
Audit Trail
Rollback

Revert to v1.0 if enforcement is delayed or if the diff caused unexpected downstream effects. Rollback is non-destructive — v1.1 records remain in DHT, state machine reverts to v1.0 rules.

Connect real AI → Replace proposeWorkflowDiffFromRuleText() with one Anthropic API call to go from stub to live regulation parsing. Ask for setup instructions when ready.