diff --git a/OFF_DataQuality/.gitignore b/OFF_DataQuality/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..57a303904aa225f7dec64a334508e17c9efa91b0 --- /dev/null +++ b/OFF_DataQuality/.gitignore @@ -0,0 +1,23 @@ +# Python cache/artifacts +__pycache__/ +*.py[cod] +*.pyo +*.pyd +.pytest_cache/ + +# Local environments +.venv/ +venv/ + +# Local data artifacts & databases (do not commit) +*.db +openfoodfacts-products.jsonl +config/secret_key +config/logs/ +results/tmp_engine_runs/ + +# OS/editor +.DS_Store +Thumbs.db +.vscode/ +.idea/ diff --git a/OFF_DataQuality/README.md b/OFF_DataQuality/README.md new file mode 100644 index 0000000000000000000000000000000000000000..6c40763bfd634a8a4c953a731246711604bf16d3 --- /dev/null +++ b/OFF_DataQuality/README.md @@ -0,0 +1,206 @@ +# OFF_DataQuality: Perl-to-Python Data Quality Migration & Benchmarking Framework + +## Overview + +**OFF_DataQuality** is an end-to-end framework designed to modernize legacy data quality validation logic for **Open Food Facts (OFF)**. + +Historically, Open Food Facts relied on legacy **Perl (`.pl`)** scripts to enforce quality controls across millions of food products—ranging from energy unit conversions (kcal vs. kJ) and macro-nutrient balance checks (sugars, fats, carbohydrates) to jurisdiction-specific allergen and packaging compliance regulations. + +This project provides an automated pipeline for: +1. **Extracting** relational, threshold, and logic conditions from legacy Perl scripts. +2. **Migrating** rules into modern **Python** validation logic using LLMs (Groq / GPT-oss-120b) with deterministic fallback templates and semantic guardrail verification. +3. **Generating Declarative Targets** for **dbt-core** (DuckDB SQL tests) and **SodaCL** (Soda data quality contracts). +4. **Benchmarking Parity** across legacy Perl outputs vs. Python, dbt, and Soda execution engines with conservative statistical confidence scoring (95% Wilson bounds & Beta posteriors). +5. **Interactive Dashboarding** to inspect side-by-side rule performance, win distributions by complexity (simple, medium, intricate), and legal traceability metadata. + +--- + +## Core Architecture & Workflow + +```mermaid +flowchart TD + A[Legacy Perl Rules .pl] --> B[Perl Logic Extractor] + B --> C{Migration Engine} + C -->|LLM / Groq GPT-oss-120b| D[Python Rules] + C -->|Declarative Generator| E[dbt DuckDB SQL Tests] + C -->|Declarative Generator| F[SodaCL YAML Contracts] + D --> G[Semantic Guardrails Verification] + E --> H[DuckDB Parity Execution] + F --> H + G --> H + H --> I[Statistical Confidence & Parity Validator] + I --> J[Streamlit Comparison Dashboard] +``` + +--- + +## Key Features + +### 1. Automated Perl Rule Extraction & Translation +- **Perl Extractor (`extractor/perl_logic_extractor.py`)**: Parses legacy `.pl` condition files to isolate numeric bounds, relational field constraints, and tag generation logic. +- **LLM Converter (`migration/llm_converter.py`)**: Translates extracted rules into executable Python functions via LLM API calls with 2-stage runtime and semantic contract validation. +- **Deterministic Fallback**: If LLM API access is unavailable or semantic checks fail, the system falls back to deterministic rule templates. + +### 2. Multi-Engine Declarative Pilot (`dbt` & `SodaCL`) +- **dbt Target**: Automatically generates dbt SQL test models and `count_violations` macros backed by DuckDB. +- **SodaCL Target**: Automatically generates SodaCL contract YAML files for automated data quality scanning. + +### 3. Statistical Parity & Confidence Scoring +Rule confidence is computed conservatively to prevent inflation on sparse evidence: +$$ ext{overall\_confidence} = ext{llm\_confidence} imes ext{parity\_ci\_lower\_95} imes ext{evidence\_ci\_lower\_95}$$ +Where `parity_ci_lower_95` uses the **Wilson score interval** and `evidence_ci_lower_95` uses a **Beta posterior credible bound** on positive violation matches. + +### 4. Jurisdiction Profile Layers +- **`global`**: Generic Open Food Facts nutrient consistency and boundary rules. +- **`canada`**: Phase-1 Canadian regulatory proxy rules (e.g., Front-of-Package (FOP) symbols, bilingual label indicators, allergen statements) with legal citations, source URLs, and review metadata. +- **`hybrid`**: Unified execution across both global and Canadian rule sets. + +### 5. Interactive Streamlit Dashboard +An interactive UI (`dashboard/app.py`) presenting per-rule accuracy, side-by-side code/SQL comparisons, engine recommendations, and legal traceability metadata. + +--- + +## Repository Structure + +```text +OFF_DataQuality/ +├── README.md # Project documentation and execution guide +├── requirements.txt # Core dependencies (duckdb, streamlit, pandas, openai, dbt, soda) +├── pytest.ini # Test configuration +├── inspect_duckdb.py # Utility script for inspecting DuckDB tables +├── config/ +│ ├── hypercorn.toml # Server configuration +│ └── custom-covers/ # Custom asset configuration directories +├── dashboard/ +│ └── app.py # Interactive Streamlit parity comparison dashboard +├── data/ +│ ├── load_dataset.py # Streamed product dataset loader (real OFF JSONL / sample) +│ └── sample_products.jsonl # 400 sample OFF product records for out-of-the-box execution +├── declarative/ +│ └── check_runners.py # Declarative dbt & Soda check generation & execution +├── duckdb_utils/ +│ └── create_tables.py # In-memory DuckDB table creation & schema setup +├── extractor/ +│ └── perl_logic_extractor.py # Legacy Perl script logic parser +├── llm-test/ +│ └── test_groq.py # Verification script for Groq API integration +├── migration/ +│ └── llm_converter.py # LLM translation pipeline with semantic guardrails +├── perl_checks/ +│ ├── legacy_checks.py # Simulated & file-based legacy Perl rule runner +│ └── rules/ # 19 legacy Perl validation rules (.pl) +├── python_checks/ +│ └── generated_checks.py # Auto-generated Python quality check routines +├── results/ +│ ├── engine_comparison.json # Pre-computed benchmark comparison report +│ ├── migration_results.json # Migration execution output +│ └── declarative_runtime/ # Generated dbt & Soda test models and contracts +├── rulepacks/ +│ └── registry.py # Global, Canada, and Hybrid rule-pack registry +├── tests/ # Comprehensive pytest suite +└── validation/ + ├── parity_validator.py # End-to-end parity validation pipeline + ├── engine_comparison.py # Multi-engine comparative benchmark suite + └── verification.py # Semantic and runtime verification contracts +``` + +--- + +## Security & Publishing Norms + +- **No Hardcoded Credentials**: API keys (such as `GROQ_API_KEY`) are read strictly from environment variables. +- **Sanitized Configurations**: Local secret keys, temporary logs, and local SQLite/DuckDB binary database files are excluded. +- **Reproducible Sample Dataset**: Includes 400 sample product records (`data/sample_products.jsonl`) so the entire pipeline can be benchmarked offline out-of-the-box. + +--- + +## Quick Start + +### 1. Installation + +Clone the repository and install dependencies: + +```bash +git clone https://huggingface.co/datasets/offCanada/Final_Deliverables +cd Final_Deliverables/OFF_DataQuality +pip install -r requirements.txt +``` + +### 2. Run Parity Validator Pipeline + +Run parity validation on sample products using the default Python target: + +```bash +python -m validation.parity_validator --size 300 --seed 17 +``` + +Run with declarative targets (`dbt` or `soda`): + +```bash +python -m validation.parity_validator --size 300 --execution-engine dbt +python -m validation.parity_validator --size 300 --execution-engine soda +``` + +Run using file-based Perl rule files: + +```bash +python -m validation.parity_validator --size 300 --perl-rules-dir perl_checks/rules +``` + +### 3. Run Multi-Engine Comparison Benchmark + +Execute a comparison experiment across Python, dbt, and Soda engines: + +```bash +python -m validation.engine_comparison --size 300 --mode off --llm-provider groq +``` + +Run with specific rule profiles: + +```bash +python -m validation.engine_comparison --size 300 --profile global +python -m validation.engine_comparison --size 300 --profile canada +python -m validation.engine_comparison --size 300 --profile hybrid +``` + +### 4. Launch the Streamlit Dashboard + +Explore benchmark metrics, engine recommendations, and rule details interactively: + +```bash +streamlit run dashboard/app.py +``` + +### 5. Running with Groq LLM Integration (Optional) + +To enable real LLM translation via Groq: + +```powershell +# Windows PowerShell +$env:GROQ_API_KEY="your_groq_api_key_here" +``` + +```bash +# Bash / Linux / macOS +export GROQ_API_KEY="your_groq_api_key_here" +``` + +Then run with Groq provider: + +```bash +python -m validation.parity_validator --size 300 --llm-provider groq --llm-model openai/gpt-oss-120b +``` + +### 6. Automated Testing + +Run the test suite using `pytest`: + +```bash +pytest -q +``` + +--- + +## License & Attribution + +This project is part of the **Open Food Facts (Canada)** data quality modernization effort. All product sample data and rule definitions conform to Open Food Facts open-data specifications. diff --git a/OFF_DataQuality/config/hypercorn.toml b/OFF_DataQuality/config/hypercorn.toml new file mode 100644 index 0000000000000000000000000000000000000000..98d1c62876ab3214c1607026228a555f3713fbd9 --- /dev/null +++ b/OFF_DataQuality/config/hypercorn.toml @@ -0,0 +1,9 @@ +# http1 & http2 binding +bind = ["0.0.0.0:9810"] +# http3 quick binding +quick_bind = ["0.0.0.0:9810"] +# http path prefix for codex +root_path = "" +# This can be a number or "auto" for Codex to guess a good value. +# https://github.com/ajslater/codex#bulk-database-updates-fail +max_import_batch_size = "auto" diff --git a/OFF_DataQuality/dashboard/app.py b/OFF_DataQuality/dashboard/app.py new file mode 100644 index 0000000000000000000000000000000000000000..5229f14ddb938e53d991ed46442ad2ecb14eed9c --- /dev/null +++ b/OFF_DataQuality/dashboard/app.py @@ -0,0 +1,787 @@ +"""Streamlit dashboard for cross-engine migration comparison.""" +from __future__ import annotations + +import html +import json +import os +import sys +from pathlib import Path +from typing import Dict, List, Mapping + +import pandas as pd +import plotly.express as px +import plotly.graph_objects as go +import streamlit as st + +PROJECT_ROOT = Path(__file__).resolve().parent.parent +if str(PROJECT_ROOT) not in sys.path: + sys.path.insert(0, str(PROJECT_ROOT)) + +from rulepacks.registry import DEFAULT_PROFILE, SUPPORTED_PROFILES +from validation.engine_comparison import COMPARISON_PATH, run_engine_comparison + +DEFAULT_SOURCE_JSONL = PROJECT_ROOT / "openfoodfacts-products.jsonl" +ENGINE_COLORS = { + "python": "#2563eb", + "dbt": "#f97316", + "soda": "#10b981", +} + + +def load_report() -> dict: + if not COMPARISON_PATH.exists(): + return {} + with COMPARISON_PATH.open("r", encoding="utf-8") as handle: + return json.load(handle) + + +def _inject_theme() -> None: + st.markdown( + """ + + """, + unsafe_allow_html=True, + ) + + +def _to_pct(value: object) -> float: + try: + return round(float(value) * 100, 2) + except (TypeError, ValueError): + return 0.0 + + +def _render_stat_chip(label: str, value: object) -> None: + st.markdown( + ( + "
" + f"
{label}
" + f"
{value}
" + "
" + ), + unsafe_allow_html=True, + ) + + +def _render_explain_chip(title: str, lines: List[str]) -> None: + safe_items = "".join(f"
  • {html.escape(line)}
  • " for line in lines if line) + st.markdown( + ( + "
    " + f"
    {html.escape(title)}
    " + f"" + "
    " + ), + unsafe_allow_html=True, + ) + + +def _engine_summary_frame(per_engine_summary: Mapping[str, Mapping[str, object]]) -> pd.DataFrame: + rows: List[Dict[str, object]] = [] + for engine in ("python", "dbt", "soda"): + summary = per_engine_summary.get(engine, {}) + rows.append( + { + "engine": engine.upper(), + "rules": int(summary.get("rules", 0)), + "passed": int(summary.get("passed", 0)), + "avg_overall_confidence_pct": _to_pct(summary.get("avg_overall_confidence", 0.0)), + "avg_effective_confidence_pct": _to_pct(summary.get("avg_effective_confidence", 0.0)), + "avg_parity_ci_low_pct": _to_pct(summary.get("avg_parity_ci_lower", 0.0)), + "avg_equivalence_rate_pct": _to_pct(summary.get("avg_equivalence_rate", 0.0)), + "avg_mutation_score_pct": _to_pct(summary.get("avg_mutation_score", 0.0)), + "fallback_rules": int(summary.get("fallback_rules", 0)), + "real_llm_rules": int(summary.get("real_llm_rules", 0)) if engine == "python" else None, + "real_llm_rate_pct": _to_pct(summary.get("real_llm_rate", 0.0)) if engine == "python" else None, + "repairs_applied": int(summary.get("repairs_applied", 0)) if engine == "python" else None, + } + ) + return pd.DataFrame(rows) + + +def _rule_frame(rule_comparison: List[Mapping[str, object]]) -> pd.DataFrame: + rows: List[Dict[str, object]] = [] + for item in rule_comparison: + engines = item.get("engines", {}) + py = engines.get("python", {}) + dbt = engines.get("dbt", {}) + soda = engines.get("soda", {}) + best_engine = str(item.get("best_engine", "python")) + + effective_confidences = { + "python": float(py.get("effective_confidence", py.get("overall_confidence", 0.0))), + "dbt": float(dbt.get("effective_confidence", dbt.get("overall_confidence", 0.0))), + "soda": float(soda.get("effective_confidence", soda.get("overall_confidence", 0.0))), + } + sorted_conf = sorted(effective_confidences.values(), reverse=True) + margin = sorted_conf[0] - sorted_conf[1] if len(sorted_conf) > 1 else sorted_conf[0] + decision_scores = { + "python": float(py.get("decision_score", effective_confidences["python"])), + "dbt": float(dbt.get("decision_score", effective_confidences["dbt"])), + "soda": float(soda.get("decision_score", effective_confidences["soda"])), + } + sorted_scores = sorted(decision_scores.values(), reverse=True) + score_margin = sorted_scores[0] - sorted_scores[1] if len(sorted_scores) > 1 else sorted_scores[0] + + rows.append( + { + "rule_name": item.get("rule_name", ""), + "severity": item.get("severity", ""), + "condition": item.get("condition", ""), + "condition_type": item.get("condition_type", "unknown"), + "complexity": item.get("complexity", "unknown"), + "declarative_friendly": bool(item.get("declarative_friendly", False)), + "jurisdiction": str(item.get("jurisdiction", "global")), + "regulatory_type": str(item.get("regulatory_type", "")), + "legal_citation": str(item.get("legal_citation", "")), + "review_status": str(item.get("review_status", "")), + "products_tested": int(item.get("products_tested", 0)), + "best_engine": best_engine, + "best_effective_pct": _to_pct(effective_confidences.get(best_engine, 0.0)), + "effective_margin_pct": round(margin * 100, 2), + "best_decision_score": round(decision_scores.get(best_engine, 0.0), 4), + "decision_margin": round(score_margin, 4), + "python_status": py.get("status", "n/a"), + "dbt_status": dbt.get("status", "n/a"), + "soda_status": soda.get("status", "n/a"), + "python_effective_pct": _to_pct(py.get("effective_confidence", py.get("overall_confidence", 0.0))), + "dbt_effective_pct": _to_pct(dbt.get("effective_confidence", dbt.get("overall_confidence", 0.0))), + "soda_effective_pct": _to_pct(soda.get("effective_confidence", soda.get("overall_confidence", 0.0))), + "python_decision_score": round(decision_scores["python"], 4), + "dbt_decision_score": round(decision_scores["dbt"], 4), + "soda_decision_score": round(decision_scores["soda"], 4), + "python_overall_pct": _to_pct(py.get("overall_confidence", 0.0)), + "dbt_overall_pct": _to_pct(dbt.get("overall_confidence", 0.0)), + "soda_overall_pct": _to_pct(soda.get("overall_confidence", 0.0)), + "python_equivalence_pct": _to_pct(py.get("equivalence_match_rate", 1.0)), + "python_mutation_pct": _to_pct(py.get("mutation_score", 1.0)), + "python_verification_pct": _to_pct(py.get("verification_score", 1.0)), + "python_repair_applied": bool(py.get("counterexample_repair_applied", False)), + "python_mismatches": int(py.get("mismatches", 0)), + "dbt_mismatches": int(dbt.get("mismatches", 0)), + "soda_mismatches": int(soda.get("mismatches", 0)), + "python_real_llm": bool(py.get("real_llm_used", False)), + "python_provider": py.get("conversion_provider", ""), + "dbt_provider": dbt.get("conversion_provider", ""), + "soda_provider": soda.get("conversion_provider", ""), + "selection_reason": item.get("selection_reason", ""), + "declarative_tie_break_applied": bool(item.get("declarative_tie_break_applied", False)), + "recommendation": item.get("recommendation", ""), + } + ) + frame = pd.DataFrame(rows) + if frame.empty: + return frame + return frame.sort_values(by=["best_effective_pct", "rule_name"], ascending=[False, True]).reset_index(drop=True) + + +def _build_effective_chart(frame: pd.DataFrame) -> go.Figure: + chart = frame[["rule_name", "python_effective_pct", "dbt_effective_pct", "soda_effective_pct"]].copy() + chart = chart.melt(id_vars=["rule_name"], var_name="engine", value_name="effective_pct") + chart["engine"] = chart["engine"].str.replace("_effective_pct", "", regex=False).str.upper() + fig = px.bar( + chart, + x="rule_name", + y="effective_pct", + color="engine", + barmode="group", + color_discrete_map={"PYTHON": ENGINE_COLORS["python"], "DBT": ENGINE_COLORS["dbt"], "SODA": ENGINE_COLORS["soda"]}, + ) + fig.update_layout( + height=460, + margin=dict(l=20, r=20, t=30, b=80), + xaxis=dict(title=None, tickangle=-30), + yaxis=dict(title="Effective confidence (%)", range=[0, 100]), + legend=dict(orientation="h", y=1.08, x=0), + plot_bgcolor="#ffffff", + paper_bgcolor="#ffffff", + ) + return fig + + +def _build_best_engine_chart(frame: pd.DataFrame) -> go.Figure: + dist = frame["best_engine"].value_counts().rename_axis("engine").reset_index(name="rules") + fig = px.pie( + dist, + names="engine", + values="rules", + hole=0.58, + color="engine", + color_discrete_map=ENGINE_COLORS, + ) + fig.update_layout(height=420, margin=dict(l=5, r=5, t=10, b=10), legend=dict(orientation="h", y=-0.1, x=0)) + fig.update_traces(textinfo="label+value") + return fig + + +def _complexity_summary_frame(per_complexity_summary: Mapping[str, Mapping[str, object]]) -> pd.DataFrame: + rows: List[Dict[str, object]] = [] + for tier in ("simple", "medium", "intricate", "unknown"): + info = per_complexity_summary.get(tier) + if not info: + continue + rows.append( + { + "complexity": tier, + "rules": int(info.get("rules", 0)), + "python_wins": int(info.get("python_wins", 0)), + "dbt_wins": int(info.get("dbt_wins", 0)), + "soda_wins": int(info.get("soda_wins", 0)), + "avg_best_effective_pct": _to_pct(info.get("avg_best_effective_confidence", 0.0)), + } + ) + return pd.DataFrame(rows) + + +def _engine_detail_frame(selected_rule: Mapping[str, object]) -> pd.DataFrame: + rows: List[Dict[str, object]] = [] + engines = selected_rule.get("engines", {}) + for engine in ("python", "dbt", "soda"): + row = engines.get(engine, {}) + rows.append( + { + "engine": engine.upper(), + "status": row.get("status", "n/a"), + "overall_confidence_pct": _to_pct(row.get("overall_confidence", 0.0)), + "effective_confidence_pct": _to_pct(row.get("effective_confidence", row.get("overall_confidence", 0.0))), + "decision_score": float(row.get("decision_score", row.get("effective_confidence", 0.0))), + "parity_ci_low_pct": _to_pct(row.get("parity_ci_lower", 0.0)), + "equivalence_pct": _to_pct(row.get("equivalence_match_rate", 1.0)), + "mutation_pct": _to_pct(row.get("mutation_score", 1.0)), + "verification_pct": _to_pct(row.get("verification_score", 1.0)), + "mismatches": int(row.get("mismatches", 0)), + "provider_factor_pct": _to_pct(row.get("provider_factor", 0.0)), + "provider": row.get("conversion_provider", ""), + "execution_mode": row.get("execution_mode", ""), + "cloud_connected": bool(row.get("cloud_connected", False)), + "cloud_scan_id": row.get("cloud_scan_id", ""), + "cloud_scan_url": row.get("cloud_scan_url", ""), + "real_llm_used": bool(row.get("real_llm_used")) if engine == "python" else None, + "repair_applied": bool(row.get("counterexample_repair_applied", False)) if engine == "python" else None, + "artifact_lines": int(row.get("conversion_lines", 0)), + } + ) + return pd.DataFrame(rows) + + +def _engine_artifact(selected_rule: Mapping[str, object], engine: str) -> str: + return str(selected_rule.get("engines", {}).get(engine, {}).get("conversion_artifact", "")).strip() + + +def _engine_failed_cases(selected_rule: Mapping[str, object], engine: str) -> List[Mapping[str, object]]: + return list(selected_rule.get("engines", {}).get(engine, {}).get("failed_test_cases", [])) + + +def _engine_equivalence_counterexamples(selected_rule: Mapping[str, object], engine: str) -> List[Mapping[str, object]]: + return list(selected_rule.get("engines", {}).get(engine, {}).get("equivalence_counterexamples", [])) + + +def main() -> None: + st.set_page_config(page_title="OFF Migration Comparison Dashboard", layout="wide") + _inject_theme() + st.markdown( + """ +
    +

    Open Food Facts Migration Comparison Dashboard

    +

    Compare Python (LLM), dbt, and Soda migrations for every rule, side-by-side.

    +
    + """, + unsafe_allow_html=True, + ) + + with st.sidebar: + st.subheader("Comparison Run") + size = st.slider("Dataset size", min_value=100, max_value=500, value=300, step=25) + default_mode = "OFF JSONL" if DEFAULT_SOURCE_JSONL.exists() else "Synthetic" + dataset_mode = st.radio("Dataset mode", options=["OFF JSONL", "Synthetic"], index=0 if default_mode == "OFF JSONL" else 1) + use_off_source = dataset_mode == "OFF JSONL" + seed = st.number_input("Seed (synthetic mode)", min_value=1, max_value=99999, value=17, disabled=use_off_source) + source_jsonl_text = st.text_input("Source JSONL path", value=str(DEFAULT_SOURCE_JSONL), disabled=not use_off_source) + perl_rules_dir_text = st.text_input("Perl rules directory (optional)", value="") + llm_provider = "groq" + st.caption("Python engine uses Groq for LLM conversion in this dashboard.") + llm_model = st.text_input("LLM model override", value="openai/gpt-oss-120b") + soda_mode = st.selectbox( + "Soda mode", + options=["local", "cloud"], + index=0, + help="Use `cloud` to attempt Soda Cloud scan publishing; falls back to local if unavailable.", + ) + profile = st.selectbox("Rule profile", options=list(SUPPORTED_PROFILES), index=list(SUPPORTED_PROFILES).index(DEFAULT_PROFILE)) + has_groq_key = bool(os.getenv("GROQ_API_KEY")) + if not has_groq_key: + st.warning("GROQ_API_KEY is not set. Python engine will fall back unless key is provided.") + + if st.button("Run Full Comparison"): + try: + if not has_groq_key: + raise RuntimeError("GROQ_API_KEY is required. Set it before running the comparison.") + with st.spinner("Running Python + dbt + Soda comparison..."): + run_engine_comparison( + dataset_size=int(size), + seed=int(seed), + source_jsonl=Path(source_jsonl_text) if use_off_source else None, + use_default_off_source=use_off_source, + llm_provider=llm_provider, + llm_model=llm_model.strip() or None, + perl_rules_dir=Path(perl_rules_dir_text) if perl_rules_dir_text.strip() else None, + results_path=COMPARISON_PATH, + require_real_llm=True, + profile=profile, + soda_mode=soda_mode, + ) + st.success("Comparison completed.") + except Exception as exc: # noqa: BLE001 + st.error(str(exc)) + + payload = load_report() + if not payload: + st.info("No comparison report found yet. Click 'Run Full Comparison' in the sidebar.") + return + + dataset = payload.get("dataset", {}) + rule_comparison = list(payload.get("rule_comparison", [])) + engine_summary = payload.get("per_engine_summary", {}) + complexity_summary = payload.get("per_complexity_summary", {}) + run_config = payload.get("run_config", {}) + comparison_method = payload.get("comparison_method", {}) + comparison_fingerprint = payload.get("comparison_fingerprint", {}) + frame = _rule_frame(rule_comparison) + if frame.empty: + st.warning("Comparison report has no rule rows.") + return + + python_wins = int((frame["best_engine"] == "python").sum()) + dbt_wins = int((frame["best_engine"] == "dbt").sum()) + soda_wins = int((frame["best_engine"] == "soda").sum()) + avg_best = frame["best_effective_pct"].mean() + canada_rules = int((frame["jurisdiction"] == "ca").sum()) if "jurisdiction" in frame.columns else 0 + + k1, k2, k3 = st.columns(3, gap="large") + with k1: + _render_stat_chip("Rules compared", len(frame)) + with k2: + _render_stat_chip("Python wins", python_wins) + with k3: + _render_stat_chip("dbt wins", dbt_wins) + k4, k5, k6 = st.columns(3, gap="large") + with k4: + _render_stat_chip("Soda wins", soda_wins) + with k5: + _render_stat_chip("Avg best effective %", f"{avg_best:.2f}%") + with k6: + _render_stat_chip("Canada rules", canada_rules) + + st.caption(f"Generated at: {payload.get('generated_at_utc', 'n/a')}") + st.caption(f"Dataset size: {dataset.get('products_tested', 'n/a')}") + st.caption(f"Dataset source: {dataset.get('source_jsonl', 'n/a')}") + st.caption(f"Profile: {dataset.get('profile', DEFAULT_PROFILE)}") + st.caption( + "Confidence context: we compare engines using effective confidence " + "(overall confidence x provider factor), with status and mismatches prioritized." + ) + if run_config: + st.caption( + f"LLM provider={run_config.get('llm_provider', 'n/a')} | " + f"GROQ key set={run_config.get('groq_api_key_set')} | " + f"Require real LLM={run_config.get('require_real_llm')} | " + f"Run profile={run_config.get('profile', DEFAULT_PROFILE)} | " + f"Soda mode={run_config.get('soda_mode', 'local')} | " + f"Soda Cloud creds set={run_config.get('soda_cloud_credentials_set', False)}" + ) + if comparison_fingerprint: + st.caption( + f"Comparison run ID: {comparison_fingerprint.get('comparison_run_id', 'n/a')} | " + f"Run SHA: {str(comparison_fingerprint.get('comparison_sha256', ''))[:12]}" + ) + st.caption( + f"Dataset fingerprint: {str(comparison_fingerprint.get('dataset_fingerprint_sha256', ''))[:16]} | " + f"Rulepack fingerprint: {str(comparison_fingerprint.get('rulepack_fingerprint_sha256', ''))[:16]} | " + f"Commit: {str(comparison_fingerprint.get('code_commit', 'unknown'))[:12]}" + ) + st.caption( + f"Cross-engine consistency -> " + f"dataset={comparison_fingerprint.get('dataset_fingerprint_consistent', False)} | " + f"rulepack={comparison_fingerprint.get('rulepack_fingerprint_consistent', False)}" + ) + selection_lines: List[str] = [ + str( + comparison_method.get( + "best_engine_ranking", + "Prefer MATCH status, then fewer mismatches, then higher effective confidence.", + ) + ) + ] + if comparison_method.get("hybrid_tie_break"): + selection_lines.append(str(comparison_method["hybrid_tie_break"])) + if comparison_method.get("declarative_tie_break"): + selection_lines.append(str(comparison_method["declarative_tie_break"])) + _render_explain_chip("How Best Migration Is Chosen", selection_lines) + + st.subheader("Engine Summary") + summary_frame = _engine_summary_frame(engine_summary) + st.dataframe( + summary_frame, + use_container_width=True, + hide_index=True, + column_config={ + "engine": st.column_config.TextColumn("Engine"), + "rules": st.column_config.NumberColumn("Rules", format="%d"), + "passed": st.column_config.NumberColumn("Passed", format="%d"), + "avg_overall_confidence_pct": st.column_config.NumberColumn("Avg overall %", format="%.2f"), + "avg_effective_confidence_pct": st.column_config.NumberColumn("Avg effective %", format="%.2f"), + "avg_parity_ci_low_pct": st.column_config.NumberColumn("Avg parity CI low %", format="%.2f"), + "avg_equivalence_rate_pct": st.column_config.NumberColumn("Avg equivalence %", format="%.2f"), + "avg_mutation_score_pct": st.column_config.NumberColumn("Avg mutation %", format="%.2f"), + "fallback_rules": st.column_config.NumberColumn("Fallback rules", format="%d"), + "real_llm_rules": st.column_config.NumberColumn("Real LLM rules", format="%d"), + "real_llm_rate_pct": st.column_config.NumberColumn("Real LLM rate %", format="%.2f"), + "repairs_applied": st.column_config.NumberColumn("Repairs applied", format="%d"), + }, + ) + + complexity_frame = _complexity_summary_frame(complexity_summary) + if not complexity_frame.empty: + st.subheader("Mixed-Complexity Benchmark Summary") + st.dataframe( + complexity_frame, + use_container_width=True, + hide_index=True, + column_config={ + "complexity": st.column_config.TextColumn("Complexity tier"), + "rules": st.column_config.NumberColumn("Rules", format="%d"), + "python_wins": st.column_config.NumberColumn("Python wins", format="%d"), + "dbt_wins": st.column_config.NumberColumn("dbt wins", format="%d"), + "soda_wins": st.column_config.NumberColumn("Soda wins", format="%d"), + "avg_best_effective_pct": st.column_config.NumberColumn("Avg best effective %", format="%.2f"), + }, + ) + + left, right = st.columns([0.72, 0.28], gap="large") + with left: + st.subheader("Effective Confidence by Rule and Engine") + st.plotly_chart(_build_effective_chart(frame), use_container_width=True) + with right: + st.subheader("Best Engine Distribution") + st.plotly_chart(_build_best_engine_chart(frame), use_container_width=True) + + st.subheader("Rule Validation Table (Comparison View)") + show_advanced = st.checkbox("Show advanced metrics", value=False) + show_providers = st.checkbox("Show provider columns", value=False) + jurisdictions = sorted(frame["jurisdiction"].dropna().unique().tolist()) + selected_jurisdictions = st.multiselect("Filter jurisdiction", options=jurisdictions, default=jurisdictions) + table_frame = frame[frame["jurisdiction"].isin(selected_jurisdictions)] if selected_jurisdictions else frame + columns = [ + "rule_name", + "jurisdiction", + "regulatory_type", + "review_status", + "legal_citation", + "complexity", + "condition_type", + "severity", + "best_engine", + "best_effective_pct", + "decision_margin", + "recommendation", + ] + if show_advanced: + columns.extend( + [ + "best_decision_score", + "effective_margin_pct", + "python_effective_pct", + "dbt_effective_pct", + "soda_effective_pct", + "python_equivalence_pct", + "python_mutation_pct", + "python_verification_pct", + "python_repair_applied", + "python_mismatches", + "dbt_mismatches", + "soda_mismatches", + "python_real_llm", + "declarative_tie_break_applied", + "selection_reason", + ] + ) + if show_providers: + columns.extend(["python_provider", "dbt_provider", "soda_provider"]) + st.dataframe( + table_frame[columns], + use_container_width=True, + hide_index=True, + column_config={ + "rule_name": st.column_config.TextColumn("Rule"), + "jurisdiction": st.column_config.TextColumn("Jurisdiction"), + "regulatory_type": st.column_config.TextColumn("Regulatory type"), + "review_status": st.column_config.TextColumn("Review status"), + "legal_citation": st.column_config.TextColumn("Legal citation"), + "complexity": st.column_config.TextColumn("Complexity"), + "condition_type": st.column_config.TextColumn("Condition type"), + "severity": st.column_config.TextColumn("Severity"), + "best_engine": st.column_config.TextColumn("Best migration"), + "best_effective_pct": st.column_config.NumberColumn("Best effective %", format="%.2f"), + "best_decision_score": st.column_config.NumberColumn("Best decision score", format="%.4f"), + "effective_margin_pct": st.column_config.NumberColumn("Win margin %", format="%.2f"), + "decision_margin": st.column_config.NumberColumn("Score margin", format="%.4f"), + "python_effective_pct": st.column_config.NumberColumn("Python effective %", format="%.2f"), + "dbt_effective_pct": st.column_config.NumberColumn("dbt effective %", format="%.2f"), + "soda_effective_pct": st.column_config.NumberColumn("Soda effective %", format="%.2f"), + "python_equivalence_pct": st.column_config.NumberColumn("Python equiv %", format="%.2f"), + "python_mutation_pct": st.column_config.NumberColumn("Python mutation %", format="%.2f"), + "python_verification_pct": st.column_config.NumberColumn("Python verify %", format="%.2f"), + "python_repair_applied": st.column_config.CheckboxColumn("Repair applied"), + "python_mismatches": st.column_config.NumberColumn("Python mismatches", format="%d"), + "dbt_mismatches": st.column_config.NumberColumn("dbt mismatches", format="%d"), + "soda_mismatches": st.column_config.NumberColumn("Soda mismatches", format="%d"), + "python_real_llm": st.column_config.CheckboxColumn("Python real LLM"), + "declarative_tie_break_applied": st.column_config.CheckboxColumn("dbt/soda tie-break"), + "selection_reason": st.column_config.TextColumn("Selection reason"), + "recommendation": st.column_config.TextColumn("Recommendation"), + "python_provider": st.column_config.TextColumn("Python provider"), + "dbt_provider": st.column_config.TextColumn("dbt provider"), + "soda_provider": st.column_config.TextColumn("Soda provider"), + }, + ) + + st.subheader("Rule Detail") + rule_names = [row.get("rule_name", "") for row in rule_comparison] + selected_rule_name = st.selectbox("Select rule", rule_names) + selected_rule = next(row for row in rule_comparison if row.get("rule_name") == selected_rule_name) + + d1, d2, d3 = st.columns(3, gap="large") + with d1: + _render_stat_chip("Best migration", str(selected_rule.get("best_engine", "n/a")).upper()) + with d2: + _render_stat_chip("Severity", str(selected_rule.get("severity", "n/a"))) + with d3: + _render_stat_chip("Products tested", int(selected_rule.get("products_tested", 0))) + best_engine = str(selected_rule.get("best_engine", "python")) + best_effective = selected_rule.get("engines", {}).get(best_engine, {}).get("effective_confidence", 0.0) + detail_row = frame.loc[frame["rule_name"] == selected_rule_name].iloc[0] + d4, d5 = st.columns(2, gap="large") + with d4: + _render_stat_chip("Best effective %", f"{_to_pct(best_effective):.2f}") + with d5: + _render_stat_chip("Decision margin", f"{float(detail_row['decision_margin']):.4f}") + + st.caption(f"Condition: {selected_rule.get('condition', 'n/a')}") + st.caption(f"Rule IR hash: {selected_rule.get('rule_ir_hash', 'n/a')}") + st.caption(f"Condition type: {selected_rule.get('condition_type', 'n/a')}") + st.caption(f"Complexity tier: {selected_rule.get('complexity', 'n/a')}") + st.caption(f"Declarative friendly: {selected_rule.get('declarative_friendly', 'n/a')}") + st.caption(f"Jurisdiction: {selected_rule.get('jurisdiction', 'global')}") + st.caption(f"Regulatory type: {selected_rule.get('regulatory_type', 'n/a')}") + st.caption(f"Legal citation: {selected_rule.get('legal_citation', 'n/a')}") + source_url = str(selected_rule.get("source_url", "")).strip() + if source_url: + st.markdown(f"Source URL: [{source_url}]({source_url})") + else: + st.caption("Source URL: n/a") + st.caption(f"Effective date: {selected_rule.get('effective_date', 'n/a')}") + st.caption(f"Review status: {selected_rule.get('review_status', 'n/a')}") + st.caption(f"Reviewer: {selected_rule.get('reviewer', 'n/a')}") + st.caption(f"Exemption logic: {selected_rule.get('exemption_logic', 'n/a')}") + st.caption(f"Selection reason: {selected_rule.get('selection_reason', 'n/a')}") + st.caption(f"dbt/soda explicit tie-break applied: {selected_rule.get('declarative_tie_break_applied', False)}") + st.caption(f"Recommendation: {selected_rule.get('recommendation', 'n/a')}") + soda_meta = selected_rule.get("engines", {}).get("soda", {}) + st.caption( + "Soda execution: " + f"mode={soda_meta.get('execution_mode', 'n/a')} | " + f"cloud_connected={soda_meta.get('cloud_connected', False)} | " + f"scan_id={soda_meta.get('cloud_scan_id', '') or 'n/a'}" + ) + soda_scan_url = str(soda_meta.get("cloud_scan_url", "")).strip() + if soda_scan_url: + st.markdown(f"Soda Cloud scan URL: [{soda_scan_url}]({soda_scan_url})") + + st.markdown("**Engine metrics for selected rule**") + st.dataframe( + _engine_detail_frame(selected_rule), + use_container_width=True, + hide_index=True, + column_config={ + "engine": st.column_config.TextColumn("Engine"), + "status": st.column_config.TextColumn("Status"), + "overall_confidence_pct": st.column_config.NumberColumn("Overall %", format="%.2f"), + "effective_confidence_pct": st.column_config.NumberColumn("Effective %", format="%.2f"), + "decision_score": st.column_config.NumberColumn("Decision score", format="%.4f"), + "parity_ci_low_pct": st.column_config.NumberColumn("Parity CI low %", format="%.2f"), + "equivalence_pct": st.column_config.NumberColumn("Equivalence %", format="%.2f"), + "mutation_pct": st.column_config.NumberColumn("Mutation %", format="%.2f"), + "verification_pct": st.column_config.NumberColumn("Verification %", format="%.2f"), + "mismatches": st.column_config.NumberColumn("Mismatches", format="%d"), + "provider_factor_pct": st.column_config.NumberColumn("Provider factor %", format="%.2f"), + "provider": st.column_config.TextColumn("Provider"), + "execution_mode": st.column_config.TextColumn("Execution mode"), + "cloud_connected": st.column_config.CheckboxColumn("Cloud connected"), + "cloud_scan_id": st.column_config.TextColumn("Cloud scan ID"), + "cloud_scan_url": st.column_config.TextColumn("Cloud scan URL"), + "real_llm_used": st.column_config.CheckboxColumn("Real LLM used"), + "repair_applied": st.column_config.CheckboxColumn("Repair applied"), + "artifact_lines": st.column_config.NumberColumn("Artifact lines", format="%d"), + }, + ) + + st.markdown("**All three migration artifacts for this rule**") + c1, c2, c3 = st.columns(3, gap="large") + with c1: + st.markdown("`PYTHON`") + st.code(_engine_artifact(selected_rule, "python"), language="python") + with c2: + st.markdown("`DBT`") + st.code(_engine_artifact(selected_rule, "dbt"), language="sql") + with c3: + st.markdown("`SODA`") + st.code(_engine_artifact(selected_rule, "soda"), language="yaml") + + st.markdown("**Python Equivalence Counterexamples**") + python_counterexamples = _engine_equivalence_counterexamples(selected_rule, "python") + if python_counterexamples: + st.dataframe(pd.DataFrame(python_counterexamples), use_container_width=True, hide_index=True) + else: + st.success("No Python equivalence counterexamples.") + + st.markdown("**Parity mismatch samples by engine**") + for engine, title in [("python", "Python"), ("dbt", "dbt"), ("soda", "Soda")]: + st.markdown(f"`{title}`") + failed_cases = _engine_failed_cases(selected_rule, engine) + if failed_cases: + st.dataframe(pd.DataFrame(failed_cases), use_container_width=True, hide_index=True) + else: + st.success(f"No mismatches for {title}.") + + +if __name__ == "__main__": + main() diff --git a/OFF_DataQuality/data/__init__.py b/OFF_DataQuality/data/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/OFF_DataQuality/data/load_dataset.py b/OFF_DataQuality/data/load_dataset.py new file mode 100644 index 0000000000000000000000000000000000000000..ebe5c74de5794ce3a4d0adbbccc77db7f0cd6fa3 --- /dev/null +++ b/OFF_DataQuality/data/load_dataset.py @@ -0,0 +1,494 @@ +"""Dataset utilities for the migration prototype. + +This module creates a reduced Open Food Facts-like JSONL dataset and loads +it into DuckDB for downstream parity validation. +""" +from __future__ import annotations + +import argparse +import json +import random +from dataclasses import dataclass +from pathlib import Path +from typing import Dict, Iterable, List, Mapping + +PROJECT_ROOT = Path(__file__).resolve().parent.parent +DB_PATH = PROJECT_ROOT / "off_quality.db" +SAMPLE_FILE = Path(__file__).resolve().parent / "sample_products.jsonl" +DEFAULT_OFF_JSONL = PROJECT_ROOT / "openfoodfacts-products.jsonl" + +CORE_FIELDS = [ + "product_id", + "energy_kj", + "energy_kj_computed", + "energy_kcal", + "fat", + "saturated_fat", + "carbohydrates", + "sugars", + "starch", + "sodium", + "ingredients_text", + "ingredients_text_present", + "contains_statement_present", + "allergen_evidence_present", + "fop_threshold_exceeded", + "fop_symbol_present", + "fop_exempt_proxy", + "product_is_prepackaged_proxy", +] + +# Additional fields used for OFF language-related checks. +OPTIONAL_FIELDS = ["lc", "lang", "language_code"] + + +def _to_int_flag(value: bool) -> int: + return 1 if value else 0 + + +def _compute_fop_threshold_exceeded(sugars: object, saturated_fat: object, sodium: object) -> int: + """Proxy Front-of-Pack trigger for prototype experiments. + + This is intentionally a simplified threshold model to exercise migration + architecture and should not be interpreted as full legal implementation. + """ + sugars_val = _to_float(sugars) or 0.0 + sat_fat_val = _to_float(saturated_fat) or 0.0 + sodium_val = _to_float(sodium) or 0.0 + return _to_int_flag((sugars_val >= 15.0) or (sat_fat_val >= 6.0) or (sodium_val >= 0.6)) + + +@dataclass(frozen=True) +class DatasetConfig: + """Configuration for synthetic dataset generation.""" + + size: int = 300 + seed: int = 17 + output_path: Path = SAMPLE_FILE + + +def _maybe(probability: float, rng: random.Random) -> bool: + return rng.random() < probability + + +def _to_float(value: object) -> float | None: + if value is None: + return None + if isinstance(value, bool): + return None + if isinstance(value, (int, float)): + return float(value) + if isinstance(value, str): + text = value.strip() + if not text: + return None + try: + return float(text) + except ValueError: + return None + return None + + +def _first_number(*values: object) -> float | None: + for value in values: + parsed = _to_float(value) + if parsed is not None: + return parsed + return None + + +def _apply_deterministic_synthetic_scenarios(index: int, product: Dict[str, object], rng: random.Random) -> None: + """Inject deterministic rule-violation scenarios for synthetic datasets. + + This keeps synthetic runs visually informative in the dashboard by ensuring + each rule receives recurring, known-positive examples. + """ + bucket = index % 21 + + if bucket == 1: + # energy_kcal > energy_kj + energy_kj = float(product["energy_kj"]) + product["energy_kcal"] = round(energy_kj + rng.uniform(1.0, 50.0), 1) + elif bucket == 2: + # energy_kj < (3.7 * energy_kcal - 2) + energy_kcal = round(rng.uniform(80.0, 320.0), 1) + product["energy_kcal"] = energy_kcal + product["energy_kj"] = round((3.7 * energy_kcal) - rng.uniform(3.0, 30.0), 1) + elif bucket == 3: + # energy_kj > (4.7 * energy_kcal + 2) + energy_kcal = round(rng.uniform(80.0, 320.0), 1) + product["energy_kcal"] = energy_kcal + product["energy_kj"] = round((4.7 * energy_kcal) + rng.uniform(3.0, 30.0), 1) + elif bucket == 4: + # energy_kj > 3911 + product["energy_kj"] = round(rng.uniform(3912.0, 5200.0), 1) + elif bucket == 5: + # saturated_fat > (fat + 0.001) + fat = round(rng.uniform(10.0, 80.0), 3) + product["fat"] = fat + product["saturated_fat"] = round(fat + rng.uniform(0.01, 9.0), 3) + elif bucket == 6: + # sugars + starch > carbohydrates + 0.001 + carbs = round(rng.uniform(10.0, 90.0), 3) + sugars = round(rng.uniform(3.0, 60.0), 3) + starch = round(max((carbs - sugars) + rng.uniform(0.01, 6.0), 0.0), 3) + product["carbohydrates"] = carbs + product["sugars"] = sugars + product["starch"] = starch + elif bucket == 7: + # fat > 105 + product["fat"] = round(rng.uniform(106.0, 135.0), 1) + elif bucket == 8: + # saturated_fat > 105 + product["saturated_fat"] = round(rng.uniform(106.0, 135.0), 1) + elif bucket == 9: + # carbohydrates > 105 + product["carbohydrates"] = round(rng.uniform(106.0, 140.0), 1) + elif bucket == 10: + # sugars > 105 + product["sugars"] = round(rng.uniform(106.0, 140.0), 1) + elif bucket == 11: + # missing lc + product["lc"] = "" + product["language_code"] = "" + elif bucket == 12: + # missing lang + product["lang"] = "" + if product.get("lc"): + product["language_code"] = str(product["lc"]) + else: + product["language_code"] = "" + elif bucket == 13: + # energy_kj_computed < (0.7 * energy_kj - 5) + energy_kj = float(product["energy_kj"]) + product["energy_kj_computed"] = round((0.7 * energy_kj) - rng.uniform(6.0, 25.0), 1) + elif bucket == 14: + # energy_kj_computed > (1.3 * energy_kj + 5) + energy_kj = float(product["energy_kj"]) + product["energy_kj_computed"] = round((1.3 * energy_kj) + rng.uniform(6.0, 25.0), 1) + elif bucket == 15: + # Allergen evidence present but ingredients text missing. + product["allergen_evidence_present"] = 1 + product["contains_statement_present"] = 1 + product["ingredients_text"] = "" + product["ingredients_text_present"] = 0 + elif bucket == 16: + # Contains statement present without allergen evidence. + product["contains_statement_present"] = 1 + product["allergen_evidence_present"] = 0 + product["ingredients_text"] = "Contains: milk, soy." + product["ingredients_text_present"] = 1 + elif bucket == 17: + # FOP required but symbol missing. + product["fop_threshold_exceeded"] = 1 + product["fop_symbol_present"] = 0 + product["fop_exempt_proxy"] = 0 + product["product_is_prepackaged_proxy"] = 1 + elif bucket == 18: + # FOP symbol present but threshold not exceeded (and not exempt). + product["fop_threshold_exceeded"] = 0 + product["fop_symbol_present"] = 1 + product["fop_exempt_proxy"] = 0 + product["product_is_prepackaged_proxy"] = 1 + elif bucket == 19: + # FOP symbol present on exempt product (proxy inconsistency). + product["fop_threshold_exceeded"] = 1 + product["fop_symbol_present"] = 1 + product["fop_exempt_proxy"] = 1 + product["product_is_prepackaged_proxy"] = 1 + elif bucket == 20: + # Not prepackaged proxy case (used to suppress FOP obligations). + product["product_is_prepackaged_proxy"] = 0 + product["fop_symbol_present"] = 0 + + +def generate_product(index: int, rng: random.Random) -> Dict[str, object]: + """Generate a single product with occasional quality rule violations.""" + energy_kj = rng.randint(50, 4800) + energy_kcal = int(round(energy_kj / 4.184)) + + fat = round(rng.uniform(0.0, 100.0), 1) + saturated_fat = round(rng.uniform(0.0, fat), 1) + carbohydrates = round(rng.uniform(0.0, 100.0), 1) + sugars = round(rng.uniform(0.0, carbohydrates), 1) + starch = round(rng.uniform(0.0, max(carbohydrates - sugars, 0.0)), 1) + sodium = round(rng.uniform(0.0, 1.5), 3) + + if _maybe(0.10, rng): + energy_kcal = energy_kj + rng.randint(1, 100) + if _maybe(0.07, rng): + energy_kj = round((3.7 * energy_kcal) - rng.uniform(3.0, 30.0), 1) + if _maybe(0.07, rng): + energy_kj = round((4.7 * energy_kcal) + rng.uniform(3.0, 30.0), 1) + if _maybe(0.08, rng): + saturated_fat = round(fat + rng.uniform(0.1, 20.0), 1) + if _maybe(0.07, rng): + starch = round(max((carbohydrates - sugars) + rng.uniform(0.01, 6.0), 0.0), 1) + + energy_kj_computed = round(float(energy_kj) * rng.uniform(0.92, 1.08), 1) + if _maybe(0.06, rng): + energy_kj_computed = round((0.65 * float(energy_kj)) - rng.uniform(1.0, 8.0), 1) + if _maybe(0.06, rng): + energy_kj_computed = round((1.35 * float(energy_kj)) + rng.uniform(1.0, 8.0), 1) + + product: Dict[str, object] = { + "product_id": f"{index:013d}", + "energy_kj": energy_kj, + "energy_kj_computed": energy_kj_computed, + "energy_kcal": energy_kcal, + "fat": fat, + "saturated_fat": saturated_fat, + "carbohydrates": carbohydrates, + "sugars": sugars, + "starch": starch, + "sodium": sodium, + } + + for nutrient in ("fat", "saturated_fat", "carbohydrates", "sugars"): + if _maybe(0.08, rng): + product[nutrient] = round(rng.uniform(106.0, 140.0), 1) + + language_code = rng.choices( + ["en", "fr", "es", "de", "it", "", None], + weights=[0.55, 0.1, 0.08, 0.06, 0.06, 0.08, 0.07], + k=1, + )[0] + lang_value = rng.choices( + ["en", "fr", "es", "de", "it", "xx", "", None], + weights=[0.5, 0.1, 0.08, 0.06, 0.06, 0.03, 0.09, 0.08], + k=1, + )[0] + product["lc"] = language_code + product["lang"] = lang_value + product["language_code"] = language_code or lang_value + ingredients_text = rng.choices( + [ + "Sugar, milk powder, cocoa butter.", + "Water, apple juice concentrate.", + "Ingredients: wheat flour, salt, yeast.", + "", + None, + ], + weights=[0.30, 0.22, 0.22, 0.16, 0.10], + k=1, + )[0] + product["ingredients_text"] = ingredients_text if ingredients_text is not None else "" + product["ingredients_text_present"] = _to_int_flag(str(product["ingredients_text"]).strip() != "") + + # Prototype proxies for Canadian allergen/FOP checks. + contains_statement_present = _maybe(0.22, rng) + allergen_evidence_present = contains_statement_present or _maybe(0.15, rng) + fop_threshold_exceeded = _compute_fop_threshold_exceeded(product.get("sugars"), product.get("saturated_fat"), product.get("sodium")) + fop_exempt_proxy = _to_int_flag(_maybe(0.10, rng)) + product_is_prepackaged_proxy = _to_int_flag(not _maybe(0.05, rng)) + fop_symbol_present = _to_int_flag( + (fop_threshold_exceeded == 1 and _maybe(0.78, rng)) + or (fop_threshold_exceeded == 0 and _maybe(0.10, rng)) + ) + + product["contains_statement_present"] = _to_int_flag(contains_statement_present) + product["allergen_evidence_present"] = _to_int_flag(allergen_evidence_present) + product["fop_threshold_exceeded"] = int(fop_threshold_exceeded) + product["fop_symbol_present"] = int(fop_symbol_present) + product["fop_exempt_proxy"] = int(fop_exempt_proxy) + product["product_is_prepackaged_proxy"] = int(product_is_prepackaged_proxy) + _apply_deterministic_synthetic_scenarios(index=index, product=product, rng=rng) + return product + + +def generate_products(config: DatasetConfig) -> List[Dict[str, object]]: + """Generate ``config.size`` synthetic products.""" + rng = random.Random(config.seed) + return [generate_product(i, rng) for i in range(1, config.size + 1)] + + +def extract_product_from_off_record(record: Mapping[str, object]) -> Dict[str, object] | None: + """Extract prototype fields from one Open Food Facts product object.""" + product_id = str(record.get("code") or record.get("_id") or record.get("id") or "").strip() + if not product_id: + return None + + nutriments = record.get("nutriments") + if not isinstance(nutriments, Mapping): + nutriments = {} + + energy_kj = _first_number( + nutriments.get("energy-kj_100g"), + nutriments.get("energy-kj"), + nutriments.get("energy_100g"), + nutriments.get("energy"), + ) + energy_kcal = _first_number( + nutriments.get("energy-kcal_100g"), + nutriments.get("energy-kcal"), + nutriments.get("energy-kcal_value"), + nutriments.get("energy-kcal_value_computed"), + ) + energy_kj_computed = _first_number( + nutriments.get("energy-kj_value_computed"), + nutriments.get("energy-kj_value-computed"), + nutriments.get("energy-kj_computed"), + ) + fat = _first_number(nutriments.get("fat_100g"), nutriments.get("fat")) + saturated_fat = _first_number(nutriments.get("saturated-fat_100g"), nutriments.get("saturated-fat")) + carbohydrates = _first_number(nutriments.get("carbohydrates_100g"), nutriments.get("carbohydrates")) + sugars = _first_number(nutriments.get("sugars_100g"), nutriments.get("sugars")) + starch = _first_number(nutriments.get("starch_100g"), nutriments.get("starch")) + sodium = _first_number(nutriments.get("sodium_100g"), nutriments.get("sodium")) + if sodium is None: + salt_value = _first_number(nutriments.get("salt_100g"), nutriments.get("salt")) + if salt_value is not None: + sodium = round(float(salt_value) * 0.393, 4) + lc = record.get("lc") + lang = record.get("lang") + language_code = lc or lang + ingredients_text = str(record.get("ingredients_text") or "").strip() + + allergens_tags = record.get("allergens_tags") + allergens_list = allergens_tags if isinstance(allergens_tags, list) else [] + contains_statement_present = bool(record.get("allergens")) or bool(record.get("traces")) or bool(allergens_list) + allergen_evidence_present = contains_statement_present or bool(record.get("allergens_from_ingredients")) + + labels_tags = record.get("labels_tags") + labels_list = labels_tags if isinstance(labels_tags, list) else [] + labels_text = " ".join(str(item).lower() for item in labels_list) + fop_symbol_present = ( + ("high-in-sugars" in labels_text) + or ("high-in-sodium" in labels_text) + or ("high-in-saturated-fat" in labels_text) + ) + + categories_tags = record.get("categories_tags") + categories_list = categories_tags if isinstance(categories_tags, list) else [] + categories_text = " ".join(str(item).lower() for item in categories_list) + fop_exempt_proxy = ("en:waters" in categories_text) or ("en:unflavoured-waters" in categories_text) + product_is_prepackaged_proxy = True + fop_threshold_exceeded = _compute_fop_threshold_exceeded(sugars, saturated_fat, sodium) + + return { + "product_id": product_id, + "energy_kj": energy_kj, + "energy_kj_computed": energy_kj_computed, + "energy_kcal": energy_kcal, + "fat": fat, + "saturated_fat": saturated_fat, + "carbohydrates": carbohydrates, + "sugars": sugars, + "starch": starch, + "sodium": sodium, + "ingredients_text": ingredients_text, + "ingredients_text_present": _to_int_flag(ingredients_text != ""), + "contains_statement_present": _to_int_flag(contains_statement_present), + "allergen_evidence_present": _to_int_flag(allergen_evidence_present), + "fop_threshold_exceeded": int(fop_threshold_exceeded), + "fop_symbol_present": _to_int_flag(fop_symbol_present), + "fop_exempt_proxy": _to_int_flag(fop_exempt_proxy), + "product_is_prepackaged_proxy": _to_int_flag(product_is_prepackaged_proxy), + "lc": lc, + "lang": lang, + "language_code": language_code, + } + + +def extract_products_from_off_jsonl(source_path: Path, max_products: int = 300) -> List[Dict[str, object]]: + """Stream OFF JSONL and extract up to ``max_products`` normalized records.""" + products: List[Dict[str, object]] = [] + with source_path.open("r", encoding="utf-8", errors="ignore") as handle: + for line in handle: + if len(products) >= max_products: + break + if not line.strip(): + continue + try: + record = json.loads(line) + except json.JSONDecodeError: + continue + if not isinstance(record, Mapping): + continue + extracted = extract_product_from_off_record(record) + if extracted is not None: + products.append(extracted) + + if not products: + raise ValueError(f"No usable products extracted from {source_path}") + return products + + +def write_products_jsonl(products: Iterable[Dict[str, object]], output_path: Path) -> None: + """Persist product records to JSONL.""" + output_path.parent.mkdir(parents=True, exist_ok=True) + with output_path.open("w", encoding="utf-8") as handle: + for record in products: + handle.write(json.dumps(record) + "\n") + + +def read_products_jsonl(path: Path = SAMPLE_FILE) -> List[Dict[str, object]]: + """Read products from JSONL into a list.""" + records: List[Dict[str, object]] = [] + with path.open("r", encoding="utf-8") as handle: + for line in handle: + if line.strip(): + records.append(json.loads(line)) + return records + + +def create_and_load_dataset( + size: int = 300, + seed: int = 17, + output_path: Path = SAMPLE_FILE, + db_path: Path = DB_PATH, + source_jsonl: Path | None = None, +) -> List[Dict[str, object]]: + """Build dataset records and load them into DuckDB. + + Notes: + - ``seed`` is used only for synthetic generation. + - When ``source_jsonl`` is provided, records are streamed from that file and + ``seed`` has no effect. + """ + if source_jsonl is not None: + products = extract_products_from_off_jsonl(Path(source_jsonl), max_products=size) + else: + config = DatasetConfig(size=size, seed=seed, output_path=output_path) + products = generate_products(config) + write_products_jsonl(products, output_path) + + # Local import avoids module cycles between data and duckdb layers. + from duckdb_utils.create_tables import load_jsonl_to_duckdb, recreate_nutrition_table + + recreate_nutrition_table(db_path=db_path) + load_jsonl_to_duckdb(jsonl_path=output_path, db_path=db_path) + return products + + +def parse_args() -> argparse.Namespace: + parser = argparse.ArgumentParser(description="Generate and load prototype dataset.") + parser.add_argument("--size", type=int, default=300, help="Number of products (100-500 recommended).") + parser.add_argument( + "--seed", + type=int, + default=17, + help="Random seed for synthetic data reproducibility (ignored when --source-jsonl is set).", + ) + parser.add_argument( + "--source-jsonl", + type=Path, + default=None, + help="Path to OFF JSONL source file (if omitted, synthetic data is generated).", + ) + return parser.parse_args() + + +def main() -> None: + args = parse_args() + products = create_and_load_dataset(size=args.size, seed=args.seed, source_jsonl=args.source_jsonl) + print(f"Generated {len(products)} records at {SAMPLE_FILE}") + if args.source_jsonl: + print(f"Source dataset: {Path(args.source_jsonl).resolve()}") + else: + print("Source dataset: synthetic generator") + print(f"Loaded dataset into {DB_PATH}") + + +if __name__ == "__main__": + main() diff --git a/OFF_DataQuality/data/sample_products.jsonl b/OFF_DataQuality/data/sample_products.jsonl new file mode 100644 index 0000000000000000000000000000000000000000..19498133bf5dc132dd537bb7fb6242b3a5175dec --- /dev/null +++ b/OFF_DataQuality/data/sample_products.jsonl @@ -0,0 +1,400 @@ +{"product_id": "0000101209159", "energy_kj": 2582.0, "energy_kj_computed": null, "energy_kcal": 617.0, "fat": 48.0, "saturated_fat": 10.0, "carbohydrates": 36.0, "sugars": 32.0, "starch": null, "sodium": 0.004, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0000105000011", "energy_kj": 1172.0, "energy_kj_computed": null, "energy_kcal": 280.0, "fat": 0.0, "saturated_fat": null, "carbohydrates": 70.0, "sugars": null, "starch": null, "sodium": 0.3, "ingredients_text": "CHAMOMILE FLOWERS.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000105000042", "energy_kj": 0.0, "energy_kj_computed": null, "energy_kcal": 0.0, "fat": 0.0, "saturated_fat": null, "carbohydrates": 1.47, "sugars": null, "starch": null, "sodium": 0.004, "ingredients_text": "Peppermint.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000105000059", "energy_kj": 893.0, "energy_kj_computed": null, "energy_kcal": 213.32, "fat": 0.0, "saturated_fat": null, "carbohydrates": 53.33, "sugars": null, "starch": null, "sodium": 0.0, "ingredients_text": "LINDEN FLOWERS.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000105000073", "energy_kj": 1117.0, "energy_kj_computed": null, "energy_kcal": 267.0, "fat": 0.0, "saturated_fat": null, "carbohydrates": 60.0, "sugars": null, "starch": null, "sodium": 0.135128, "ingredients_text": "Hibiscus flowers.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000105000196", "energy_kj": 1004.0, "energy_kj_computed": null, "energy_kcal": 240.0, "fat": 0.0, "saturated_fat": null, "carbohydrates": 60.0, "sugars": null, "starch": null, "sodium": 0.135128, "ingredients_text": "TEA, CINNAMON & NATURAL APPLE FLAVOR.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000105000219", "energy_kj": 150.0, "energy_kj_computed": null, "energy_kcal": 35.5, "fat": 0.0, "saturated_fat": null, "carbohydrates": 8.89, "sugars": null, "starch": null, "sodium": 0.0, "ingredients_text": "GREEN TEA.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000105000318", "energy_kj": 186.0, "energy_kj_computed": null, "energy_kcal": 44.3, "fat": 0.0, "saturated_fat": null, "carbohydrates": 11.1, "sugars": null, "starch": null, "sodium": 0.0, "ingredients_text": "SHAVE GRASS.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000105000356", "energy_kj": 0.0, "energy_kj_computed": null, "energy_kcal": 0.0, "fat": 0.0, "saturated_fat": null, "carbohydrates": 3.33, "sugars": null, "starch": null, "sodium": 0.0, "ingredients_text": "Chamomile spearmint.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000105000363", "energy_kj": 186.0, "energy_kj_computed": null, "energy_kcal": 44.3, "fat": 0.0, "saturated_fat": null, "carbohydrates": 11.1, "sugars": null, "starch": null, "sodium": 0.0, "ingredients_text": "ARTICHOKE MALVA SENNA LEAF HIBISCUS CHAMOMILE NATURAL APPLE FLAVOR.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000105000417", "energy_kj": 0.0, "energy_kj_computed": null, "energy_kcal": 0.0, "fat": 0.0, "saturated_fat": null, "carbohydrates": 0.0, "sugars": null, "starch": null, "sodium": 0.0, "ingredients_text": "Andropogon citratus, uva ursi, hibiscus flowers, cinnamon, equisetum arvense, flourensia cernua.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000105200923", "energy_kj": 0.0, "energy_kj_computed": null, "energy_kcal": 0.0, "fat": 0.0, "saturated_fat": null, "carbohydrates": 3.33, "sugars": null, "starch": null, "sodium": 0.0, "ingredients_text": "Shave grass, corn silk, uva ursi, juliana adstringen, boldo, hibiscus flowers, orange blossom.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000105200961", "energy_kj": 1674.0, "energy_kj_computed": null, "energy_kcal": 400.0, "fat": 0.0, "saturated_fat": null, "carbohydrates": 100.0, "sugars": null, "starch": null, "sodium": 0.0, "ingredients_text": "EUCALYPTUS LICORICE GINGER ELDER MULLEIN CINNAMON ORANGE BLOSSOM.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000111048403", "energy_kj": 3586.0, "energy_kj_computed": null, "energy_kcal": 857.0, "fat": 100.0, "saturated_fat": 7.14, "carbohydrates": 0.0, "sugars": null, "starch": null, "sodium": 0.0, "ingredients_text": "100% canola oil no additives or preservatives", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000111301201", "energy_kj": 19200.0, "energy_kj_computed": null, "energy_kcal": 4590.0, "fat": 510.0, "saturated_fat": 76.4, "carbohydrates": 0.0, "sugars": 0.0, "starch": null, "sodium": 5.1, "ingredients_text": "CANOLA OIL, WATER, PALM OIL, PALM KERNEL OIL, SALT, WHEY POWDER (MILK), VEGETABLE MONO AND DIGLYCERIDES, SOYBEAN LECITHIN, POTASSIUM SORBATE (PRESERVATIVE), CITRIC ACID, ARTIFICIAL FLAVOR, VITAMIN E (DL-ALPHA-TOCOPHEROL ACETATE), VITAMIN A PALMITATE, BETA CAROTENE & VITAMIN D3.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000111301263", "energy_kj": 2389.0, "energy_kj_computed": null, "energy_kcal": 571.0, "fat": 57.14, "saturated_fat": 10.71, "carbohydrates": 0.0, "sugars": 0.0, "starch": null, "sodium": 0.536, "ingredients_text": "Canola oil, water, palm oil, flax oil, palm kernel oil, whey powder (milk), salt, vegetable mono and diglycerides, soybean lecithin, potassium sorbate (preservative), citric acid, artificial flavor, vitamin e (dl-alpha-tocopherol acetate), calcium disodium edta (to preserve freshness), vitamin a palmitate, beta-carotene, vitamin d3.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000127534587", "energy_kj": 1390.0, "energy_kj_computed": null, "energy_kcal": 332.0, "fat": 4.61, "saturated_fat": 0.0, "carbohydrates": 83.1, "sugars": 15.4, "starch": null, "sodium": 0.984, "ingredients_text": "RYE FLOUR, WATER, WHEAT, FLOUR, MALT, MOLASSES, SUGAR, ONION, YEAST, CARAWAY SEEDS, SALT.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000130008136", "energy_kj": null, "energy_kj_computed": null, "energy_kcal": null, "fat": null, "saturated_fat": null, "carbohydrates": null, "sugars": null, "starch": null, "sodium": null, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0000140323687", "energy_kj": null, "energy_kj_computed": null, "energy_kcal": null, "fat": null, "saturated_fat": null, "carbohydrates": null, "sugars": null, "starch": null, "sodium": null, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0000141013129", "energy_kj": null, "energy_kj_computed": null, "energy_kcal": null, "fat": null, "saturated_fat": null, "carbohydrates": null, "sugars": null, "starch": null, "sodium": null, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0000159479269", "energy_kj": 907.0, "energy_kj_computed": null, "energy_kcal": 217.0, "fat": 34.7, "saturated_fat": 21.5, "carbohydrates": 54.2, "sugars": 53.6, "starch": null, "sodium": null, "ingredients_text": "SUGAR, COCOA BUTTER, SKIMMED MILK POWDER, COCOA MASS, WHEY POWDER (FROM MILK), LACTOSE, MILK FAT, EMULSIFIER (SOYA LECITHIN), NATURAL VANILLA EXTRACT. MILK CHOCOLATE CONTAINS MILK SOLIDS 14% MINIMUM AND COCOA SOLIDS 25% MINIMUM.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000159487776", "energy_kj": 907.0, "energy_kj_computed": null, "energy_kcal": 217.0, "fat": 34.7, "saturated_fat": null, "carbohydrates": 54.2, "sugars": 53.6, "starch": null, "sodium": null, "ingredients_text": "SUGAR, COCOA BUTTER, SKIMMED MILK POWDER, COCOA MASS, WHEY POWDER (FROM MILK), LACTOSE, MILK FAT, EMULSIFIER (SOYA LECITHIN), NATURAL VANILLA EXTRACT.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000168175589", "energy_kj": 2130.0, "energy_kj_computed": null, "energy_kcal": 509.0, "fat": 26.1, "saturated_fat": 16.03, "carbohydrates": 60.0, "sugars": 30.3, "starch": null, "sodium": null, "ingredients_text": "Fortified wheat flour (with calcium, iron, niacin, thiamin), vegetable oil (palm), sugar, wholemeal wheat flour, dried cream cheese (2.5%) (milk), dried skimmed milk, oatmeal, low fat yogurt powder (milk), dried whey (milk), dextrose, raising agents (sodium bicarbonate, ammonium bicarbonate), salt, wheat starch, natural lemon flavouring, colour (beta carotene).", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000168178238", "energy_kj": 2008.0, "energy_kj_computed": null, "energy_kcal": 480.0, "fat": 20.0, "saturated_fat": 10.4, "carbohydrates": 68.2, "sugars": 38.6, "starch": null, "sodium": null, "ingredients_text": "Flour (wheat flour, calcium, iron, niacin, thiamin), milk chocolate (27%) [sugar, cocoa butter, dried skimmed milk, cocoa mass, dried whey (milk), butter oil (milk), emulsifier (soya lecithin), natural flavouring], sugar, vegetable oil (palm), partially inverted sugar syrup, molasses, raising agents (sodium bicarbonate, disodium diphosphate), ground ginger, salt, natural ginger flavouring.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000171812457", "energy_kj": 837.0, "energy_kj_computed": null, "energy_kcal": 200.0, "fat": 9.2, "saturated_fat": 6.21, "carbohydrates": 27.11, "sugars": 26.6, "starch": null, "sodium": 0.04, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0000197571406", "energy_kj": 765.0, "energy_kj_computed": null, "energy_kcal": 183.0, "fat": 0.3, "saturated_fat": null, "carbohydrates": 45.7, "sugars": 0.6, "starch": null, "sodium": 2.44, "ingredients_text": "BLACK CHICKPEA GRAM FLOUR, SALT, RAISING AGENT, CALCIUM OXIDE, RICE FLOUR, SUNFLOWER OIL.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000204286484", "energy_kj": 1533.0, "energy_kj_computed": 1533.0, "energy_kcal": null, "fat": 1.0, "saturated_fat": null, "carbohydrates": 2.5, "sugars": null, "starch": null, "sodium": null, "ingredients_text": "Proteinmischung (_Sojaprotein_, _Weizenprotein_, _Molkenprotein_, _Wheyprotein_), _Milchprotein_, _H\u00fchnereiweiss_, Kakaopulver (nur Sorte Schoko), Aroma, Pflanzen\u00f6l, S\u00fc\u00dfungsmittel Natriumsaccharin und Acesulfam-K.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "de", "lang": "de", "language_code": "de"} +{"product_id": "0000208066259", "energy_kj": 5.0, "energy_kj_computed": null, "energy_kcal": 1.2, "fat": 0.0, "saturated_fat": null, "carbohydrates": 0.3, "sugars": null, "starch": null, "sodium": null, "ingredients_text": "100% TEA & PASSION", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000209024937", "energy_kj": 1966.0, "energy_kj_computed": null, "energy_kcal": 470.0, "fat": 28.9, "saturated_fat": 16.4, "carbohydrates": 46.3, "sugars": 18.2, "starch": null, "sodium": 0.24, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0000228000080", "energy_kj": null, "energy_kj_computed": null, "energy_kcal": null, "fat": null, "saturated_fat": null, "carbohydrates": null, "sugars": null, "starch": null, "sodium": null, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0000234022960", "energy_kj": 1732.0, "energy_kj_computed": null, "energy_kcal": 414.0, "fat": 22.2, "saturated_fat": 15.8, "carbohydrates": 45.0, "sugars": 7.4, "starch": null, "sodium": 0.48, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0000236555909", "energy_kj": null, "energy_kj_computed": null, "energy_kcal": null, "fat": null, "saturated_fat": null, "carbohydrates": null, "sugars": null, "starch": null, "sodium": null, "ingredients_text": "Enriched bleached flour (wheat flour, malt barley flour, niacin, ferrous sulfate, thiamine mono-nitrate, riboflavin, folic acid), water, sugar, yeast, ethoxylated mon-diglycerides, salt, diacetyl tartaric acid esters of mono-diglycerides (datem), polysorbate 60, calcium sulfate, soya lecithin, vegetable shortening (soybean, cottonseed, and/or canola oils), propionic acid, potassium bromate, ascorbic acid, sodium propionate (a preservatives), l. cysteine, enzyme, phosphoric acid, azodicarbonmide (ada).", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000236598784", "energy_kj": null, "energy_kj_computed": null, "energy_kcal": null, "fat": null, "saturated_fat": null, "carbohydrates": null, "sugars": null, "starch": null, "sodium": null, "ingredients_text": "Enriched bleached flour (wheat flour, malt barley flour, niacin, ferrous sulfate, thiamine mononitrate, riboflavin, folic acid), water, yeast, sugar, soy oil, rye flour, salt, spices, acetic acid, lactic acid, natural flavor.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000241013128", "energy_kj": 992.0, "energy_kj_computed": null, "energy_kcal": 237.0, "fat": 9.5, "saturated_fat": 4.2, "carbohydrates": 32.0, "sugars": 21.7, "starch": null, "sodium": 0.144, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0000247016406", "energy_kj": 1699.0, "energy_kj_computed": null, "energy_kcal": 406.0, "fat": 20.0, "saturated_fat": 2.4, "carbohydrates": 50.0, "sugars": 5.4, "starch": null, "sodium": 0.0, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0000250632969", "energy_kj": 1533.0, "energy_kj_computed": 1533.0, "energy_kcal": null, "fat": 1.0, "saturated_fat": null, "carbohydrates": 2.5, "sugars": null, "starch": null, "sodium": null, "ingredients_text": "Proteinmischung (_Sojaprotein_, _Weizenprotein_, _Molkenprotein_, _Wheyprotein_), _Milchprotein_, _H\u00fchnereiweiss_, Kakaopulver (nur Sorte Schoko), Aroma, Pflanzen\u00f6l, S\u00fc\u00dfungsmittel Natriumsaccharin und Acesulfam-K.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "de", "lang": "de", "language_code": "de"} +{"product_id": "0000260440264", "energy_kj": 724.0, "energy_kj_computed": null, "energy_kcal": 173.0, "fat": 0.5, "saturated_fat": 0.1, "carbohydrates": 42.0, "sugars": 42.0, "starch": null, "sodium": 0.04, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0000281621505", "energy_kj": 1879.0, "energy_kj_computed": null, "energy_kcal": 449.0, "fat": 18.0, "saturated_fat": null, "carbohydrates": 58.0, "sugars": null, "starch": null, "sodium": null, "ingredients_text": "Glucose fructose syrup, sugar, cocoa mass, cocoa butter, teacher's blended scotch whisky (10%), alcohol, milk sugar, whole milk powder, emulsifier: lecithins.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000281756504", "energy_kj": 2029.0, "energy_kj_computed": null, "energy_kcal": 485.0, "fat": 26.25, "saturated_fat": 9.75, "carbohydrates": 58.75, "sugars": 6.5, "starch": null, "sodium": 0.012, "ingredients_text": "Sugar, wheat starch, glucose syrup, whole soya flour, milk sugar, vegetable fat, cocoa butter, cocoa mass, whole milk powder, caramel sugar syrup, dextrose, peanuts, hazelnuts, glucose fructose syrup, vegetable oil, emulsifier: lecithins, humectant: invertase, rice flour, flavouring, orange peel, acidity regulator: citric acid, egg powder, cocoa solids: milk chocolate: cocoa solids 25% min., milk solids 14% min.; chocolate: cocoa solids 35% min.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000309444901", "energy_kj": 598.0, "energy_kj_computed": null, "energy_kcal": 143.0, "fat": 0.0, "saturated_fat": null, "carbohydrates": 32.14, "sugars": 25.0, "starch": null, "sodium": 0.643, "ingredients_text": "Banana peppers, onions, high fructose corn syrup, water, vinegar, salt, mustard seeds, calcium chloride, 0.1% sodium benzoate (preservative), celery seeds, natural flavors, polysorbate 80, sodium bisulfite (preservative), and yellow 5.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000309512075", "energy_kj": 1046.0, "energy_kj_computed": null, "energy_kcal": 250.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 43.75, "sugars": 34.38, "starch": null, "sodium": 1.188, "ingredients_text": "Catsup, vinegar, brown sugar, apricots, enzymes pepper, sugar, garlic salt, pepper and liquid smoke, worcestershire sauce and secret spices.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000310413620", "energy_kj": 1322.0, "energy_kj_computed": null, "energy_kcal": 316.0, "fat": 15.09, "saturated_fat": 6.5, "carbohydrates": 0.54, "sugars": 0.2, "starch": null, "sodium": 1.084, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0000360053005", "energy_kj": 837.0, "energy_kj_computed": null, "energy_kcal": 200.0, "fat": 0.0, "saturated_fat": null, "carbohydrates": 80.0, "sugars": null, "starch": null, "sodium": 0.0, "ingredients_text": "Sorbitol, gum base, maltitol, maltitol syrup, xylitol, dicalcium phosphate, natural flavors, less than 2% of: sodium bicarbonate, glycerine, vitamin c (as calcium ascorbate), gum arabic, vitamin e (as d-alpha-tocopheryl acetate), vitamin a (as palmitate), maltodextrin, carnauba wax, citrus extract", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000360054002", "energy_kj": 837.0, "energy_kj_computed": null, "energy_kcal": 200.0, "fat": 0.0, "saturated_fat": null, "carbohydrates": 80.0, "sugars": 0.0, "starch": null, "sodium": 0.6, "ingredients_text": "Sorbitol, gum base, maltitol syrup, xylitol, natural cinnamon flavor, dicalcium phosphate, glycerine, sodium bicarbonate, vitamin c (as calcium ascorbate), vitamin e (as d-alpha-tocopheryl acetate), maltodextrin, vitamin a (as palmitate), carnauba wax, soy lecithin, citrus extract.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000417011002", "energy_kj": 4020.0, "energy_kj_computed": null, "energy_kcal": 960.0, "fat": 112.0, "saturated_fat": 73.6, "carbohydrates": 240.0, "sugars": 198.0, "starch": null, "sodium": 0.64, "ingredients_text": "SUGAR, COCOA BUTTER, CREAM POWDER (16%), CORN (11%), COCOA MASS, LACTOSE, EMULSIFIER: LECITHIN (SOY), SALT BARLEY MALT, NATURAL FLAVOR.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000417012009", "energy_kj": 2142.0, "energy_kj_computed": null, "energy_kcal": 512.0, "fat": 28.0, "saturated_fat": 15.6, "carbohydrates": 56.0, "sugars": 43.6, "starch": null, "sodium": 0.052832000000000004, "ingredients_text": "Sugar, cocoa butter, raisins, cocoa mass, whole milk powder, hazelnuts, lactose, skimmed milk powder, butterfat, jamaican rum, emulsifier: lecithin (soy), natural flavor.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000417296003", "energy_kj": 3830.0, "energy_kj_computed": null, "energy_kcal": 915.0, "fat": 125.0, "saturated_fat": 67.2, "carbohydrates": 229.0, "sugars": 224.0, "starch": null, "sodium": 0.228, "ingredients_text": "SUGAR, COCOA BUTTER, COCOA MASS, WHOLE MILK POWDER, ALMONDS (7.7%), LACTOSE, SKIM MILK POWDER, BUTTERFAT, EMULSIFIER: LECITHIN (SOY), NATURAL FLAVOR.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000433070274", "energy_kj": 1929.0, "energy_kj_computed": null, "energy_kcal": 461.0, "fat": 21.4, "saturated_fat": 1.8, "carbohydrates": 55.2, "sugars": 51.6, "starch": null, "sodium": 0.1, "ingredients_text": "Sugar, almonds, water, sorbitol, invert sugar, food coloring, turmeric, carmine, fd&c blue @1: egg white", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000433821494", "energy_kj": 4060.0, "energy_kj_computed": null, "energy_kcal": 969.0, "fat": 76.5, "saturated_fat": 44.6, "carbohydrates": 242.0, "sugars": 102.0, "starch": null, "sodium": 0.764, "ingredients_text": "ONLY THE BEST: UN-BLEACHED FLOUR, ORGANIC STEEL CUT WHOLE OATS, ORGANIC CALIFORNIA RAISINS, CREAMERY BUTTER, WHOLE EGG, UN-REFINED SUGAR, MADAGASCAR VANILLA.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000433821500", "energy_kj": 4060.0, "energy_kj_computed": null, "energy_kcal": 969.0, "fat": 76.5, "saturated_fat": 44.6, "carbohydrates": 242.0, "sugars": 102.0, "starch": null, "sodium": 0.764, "ingredients_text": "ONLY THE BEST: UN-BLEACHED FLOUR, 100% ORGANIC PEANUT BUTTER, PEANUTS, CREAMERY BUTTER, UN-REFINED SUGAR, WHOLE EGG.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000433906023", "energy_kj": 1623.0, "energy_kj_computed": null, "energy_kcal": 388.0, "fat": 17.65, "saturated_fat": 10.29, "carbohydrates": 50.0, "sugars": 17.65, "starch": null, "sodium": 0.147, "ingredients_text": "Bart & judy's proprietary rice flour blend, butter, sweet potato, cranberries, brown cane sugar, whole egg, baking soda, salt.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000433906030", "energy_kj": 2460.0, "energy_kj_computed": null, "energy_kcal": 588.0, "fat": 51.9, "saturated_fat": 30.3, "carbohydrates": 147.0, "sugars": 51.9, "starch": null, "sodium": 0.432, "ingredients_text": "BART & JUDY'S PROPRIETARY RICE FLOUR BLEND, BUTTER, FRESH GROUND GINGER, BROWN CANE SUGAR, MOLASSES, WHOLE EGG, BAKING SODA, SALT.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000450193000", "energy_kj": 883.0, "energy_kj_computed": null, "energy_kcal": 211.0, "fat": 11.27, "saturated_fat": 7.04, "carbohydrates": 22.54, "sugars": 16.9, "starch": null, "sodium": 0.056, "ingredients_text": "Milk, cream, sugar, corn syrup, guar gum, locust bean gum, natural vanilla flavor, vanilla beans, lactase enzyme*.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000450193031", "energy_kj": 1000.0, "energy_kj_computed": null, "energy_kcal": 239.0, "fat": 15.49, "saturated_fat": 7.04, "carbohydrates": 22.54, "sugars": 15.49, "starch": null, "sodium": 0.134, "ingredients_text": "Milk, cream, sugar, corn syrup, pecans (pecans, cottonseed oil, salt), natural flavor, guar gum, locust bean gum, lactase enzyme*", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000460938714", "energy_kj": 1590.0, "energy_kj_computed": 1541.7, "energy_kcal": null, "fat": 0.5, "saturated_fat": null, "carbohydrates": 1.1, "sugars": null, "starch": null, "sodium": null, "ingredients_text": "100% Soja-Protein-Isolat (_Soja_), Aroma, S\u00fc\u00dfstoff Natrium-Saccharin.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "de", "lang": "de", "language_code": "de"} +{"product_id": "0000470322800", "energy_kj": 1644.0, "energy_kj_computed": 1647.4499999999998, "energy_kcal": null, "fat": 4.6, "saturated_fat": null, "carbohydrates": 8.8, "sugars": 6.0, "starch": null, "sodium": 0.484632, "ingredients_text": "Molkenproteinkonzentrat 99%(_Wheyproteinkonzentrat_), (nur Schoko Kakaopulver ent\u00f6lt), Aroma, Pflanzen\u00f6l aus Raps, S\u00fc\u00dfungsmittel Acesulfam-K und Sucralose.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "de", "lang": "de", "language_code": "de"} +{"product_id": "0000501050603", "energy_kj": 1644.0, "energy_kj_computed": 1647.4499999999998, "energy_kcal": null, "fat": 4.6, "saturated_fat": null, "carbohydrates": 8.8, "sugars": 6.0, "starch": null, "sodium": 0.484632, "ingredients_text": "Molkenproteinkonzentrat 99%(_Wheyproteinkonzentrat_), (nur Schoko Kakaopulver ent\u00f6lt), Aroma, Pflanzen\u00f6l aus Raps, S\u00fc\u00dfungsmittel Acesulfam-K und Sucralose.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "de", "lang": "de", "language_code": "de"} +{"product_id": "0000522061596", "energy_kj": 3910.0, "energy_kj_computed": null, "energy_kcal": 933.0, "fat": 12.2, "saturated_fat": 5.57, "carbohydrates": 233.0, "sugars": 3.33, "starch": null, "sodium": null, "ingredients_text": "WHEAT FLOUR, SALT (4,8%), PALM OIL, ACIDITY REGULATOR (SODIUM HYDROXIDE), MALTED WHEAT FLOUR, EMULSIFIER (MONO-UND DIGLYDERIDES OF FATTY ACIDS).", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000526938306", "energy_kj": 1644.0, "energy_kj_computed": 1647.4499999999998, "energy_kcal": null, "fat": 4.6, "saturated_fat": null, "carbohydrates": 8.8, "sugars": 6.0, "starch": null, "sodium": 0.484632, "ingredients_text": "Molkenproteinkonzentrat 99%(_Wheyproteinkonzentrat_), (nur Schoko Kakaopulver ent\u00f6lt), Aroma, Pflanzen\u00f6l aus Raps, S\u00fc\u00dfungsmittel Acesulfam-K und Sucralose.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "de", "lang": "de", "language_code": "de"} +{"product_id": "0000539003206", "energy_kj": 1954.0, "energy_kj_computed": null, "energy_kcal": 467.0, "fat": 23.0, "saturated_fat": 14.0, "carbohydrates": 57.0, "sugars": 57.0, "starch": null, "sodium": 0.12, "ingredients_text": "Sugar, cocoa butter, whole milk powder, williams pear brandy (8%), cocoa mass, lactose, invert sugar, skimmed milk powder, thickener (gum arabic), emulsifier (soy lecithin), barley malt extract, flavoring vanillin.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000554004509", "energy_kj": 1167.0, "energy_kj_computed": null, "energy_kcal": 279.0, "fat": 6.3, "saturated_fat": 0.5, "carbohydrates": 48.2, "sugars": 4.4, "starch": null, "sodium": 0.436, "ingredients_text": "Eau ; f\u00e9cule de tapioca ; farine de riz ; f\u00e9cule de pomme de terre ; huiles v\u00e9g\u00e9tales : huile de colza, huile de tournesol ; levure ; humectant : glyc\u00e9rol v\u00e9g\u00e9tal ; stabilisant : hydroxypropyl-m\u00e9thyl-cellulose ; amidon de ma\u00efs ; blanc d\u2019\u0153uf d\u00e9shydrat\u00e9 ; sucre en poudre ; enveloppes de psyllium en poudre ; farine de ma\u00efs ; sel iod\u00e9 : sel ; iodate de potassium ; amidon de ma\u00efs ferment\u00e9 ; amidon de riz.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0000557910210", "energy_kj": 1552.0, "energy_kj_computed": null, "energy_kcal": 371.0, "fat": 7.1, "saturated_fat": 1.6, "carbohydrates": 60.0, "sugars": 1.0, "starch": null, "sodium": 0.004, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0000604007221", "energy_kj": 561.0, "energy_kj_computed": null, "energy_kcal": 134.0, "fat": 3.0, "saturated_fat": 0.3, "carbohydrates": 47.9, "sugars": 3.8, "starch": null, "sodium": 0.52, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0000605013450", "energy_kj": 1230.0, "energy_kj_computed": null, "energy_kcal": 294.0, "fat": 5.4, "saturated_fat": 0.6, "carbohydrates": 48.0, "sugars": 3.3, "starch": null, "sodium": 0.6, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0000606009841", "energy_kj": 1272.0, "energy_kj_computed": null, "energy_kcal": 304.0, "fat": null, "saturated_fat": 1.7, "carbohydrates": null, "sugars": 12.7, "starch": null, "sodium": 0.28, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0000609124107", "energy_kj": 1760.0, "energy_kj_computed": null, "energy_kcal": 421.0, "fat": 57.4, "saturated_fat": 35.1, "carbohydrates": 105.0, "sugars": 98.9, "starch": null, "sodium": 0.143, "ingredients_text": "MILK CHOCOLATE (SUGAR, MILK, COCOA BUTTER, CHOCOLATE, SOY LECITHIN - AN EMULAFIER, VANLLAN - AN ARTIFICIAL FLAVOR)", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000609133703", "energy_kj": 2301.0, "energy_kj_computed": null, "energy_kcal": 550.0, "fat": 32.5, "saturated_fat": 20.0, "carbohydrates": 57.5, "sugars": 55.0, "starch": null, "sodium": 0.075, "ingredients_text": "Milk chocolate (sugar, milk, cocoa butter, chocolate, soy lecithin - an emulsifier, vanillin - an artificial flavor).", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000609231508", "energy_kj": 4550.0, "energy_kj_computed": null, "energy_kcal": 1090.0, "fat": 159.0, "saturated_fat": 102.0, "carbohydrates": 272.0, "sugars": 272.0, "starch": null, "sodium": 0.338, "ingredients_text": "MILK CHOCOLATE (SUGAR, MILK, COCOA BUTTER, CHOCOLATE, SOY LECITHIN (AN EMULSIFIER), VANILLIN - AN ARTIFICIAL FLAVOR).", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000609340767", "energy_kj": 2400.0, "energy_kj_computed": null, "energy_kcal": 575.0, "fat": 81.2, "saturated_fat": 50.0, "carbohydrates": 144.0, "sugars": 125.0, "starch": null, "sodium": 0.03, "ingredients_text": "SEMI-SWEET CHOCOLATE: (SUGAR, CHOCOLATE LIQUOR PROCESSED WITH ALKALI, COCOA BUTTER, MILK FAT, SOY LECITHIN, VANILLIN-AN ARTIFICIAL FLAVOR, NATURAL FLAVORS).", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000609346752", "energy_kj": 2090.0, "energy_kj_computed": null, "energy_kcal": 500.0, "fat": 100.0, "saturated_fat": 62.5, "carbohydrates": 125.0, "sugars": 125.0, "starch": null, "sodium": 0.25, "ingredients_text": "WHITE CHOCOLATE: (SUGAR, COCOA BUTTER, MILK, VANILLIN AN ARTIFICIAL FLAVOR).", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000609406104", "energy_kj": 2238.0, "energy_kj_computed": null, "energy_kcal": 535.0, "fat": 32.56, "saturated_fat": 20.93, "carbohydrates": 58.14, "sugars": 55.81, "starch": null, "sodium": 0.081, "ingredients_text": "Milk chocolate (sugar, milk, cocoa butter, chocolate, soy lecithin-an emulsifier, vanillin-an artificial flavor).", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000609407101", "energy_kj": 2238.0, "energy_kj_computed": null, "energy_kcal": 535.0, "fat": 32.56, "saturated_fat": 20.93, "carbohydrates": 58.14, "sugars": 55.81, "starch": null, "sodium": 0.081, "ingredients_text": "Milk chocolate (sugar, milk, cocoa butter, chocolate, soy lecithin - an emulsifier, vanillin-an artificial flavor).", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000609900114", "energy_kj": 2314.0, "energy_kj_computed": null, "energy_kcal": 553.0, "fat": 39.47, "saturated_fat": 23.68, "carbohydrates": 44.74, "sugars": 28.95, "starch": null, "sodium": 0.0, "ingredients_text": "Bittersweet chocolate (chocolate, sugar, cocoa butter, soy lecithin-an emulsifier, vanilla).", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000609941001", "energy_kj": 2301.0, "energy_kj_computed": null, "energy_kcal": 550.0, "fat": 32.5, "saturated_fat": 20.0, "carbohydrates": 57.5, "sugars": 55.0, "starch": null, "sodium": 0.075, "ingredients_text": "Milk chocolate (sugar, milk, cocoa butter, chocolate, soy lecithin-an emulsifier, vanillian-an artificial flavor).", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000609941049", "energy_kj": 2197.0, "energy_kj_computed": null, "energy_kcal": 525.0, "fat": 32.5, "saturated_fat": 20.0, "carbohydrates": 57.5, "sugars": 47.5, "starch": null, "sodium": 0.012, "ingredients_text": "Semi-sweet chocolate: (sugar, chocolate processed with alkali, cocoa butter, milk fat, soy lecithin-an emulsifier, vanillian-an artificial flavor, natural flavors).", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000609941759", "energy_kj": 2710.0, "energy_kj_computed": null, "energy_kcal": 648.0, "fat": 92.6, "saturated_fat": 54.0, "carbohydrates": 162.0, "sugars": 154.0, "starch": null, "sodium": 0.231, "ingredients_text": "MILK CHOCOLATE (SUGAR, MILK, COCOA BUTTER, CHOCOLATE, SOY LECITHIN-AN EMULSIFIER, VANILLIAN-AN ARTIFICIAL FLAVOR).", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000609941766", "energy_kj": 2326.0, "energy_kj_computed": null, "energy_kcal": 556.0, "fat": 33.33, "saturated_fat": 19.44, "carbohydrates": 58.33, "sugars": 55.56, "starch": null, "sodium": 0.083, "ingredients_text": "Milk chocolate (sugar, milk, cocoa butter, chocolate, soy lecithin - an emulsifier, vanillian-an artificial flavor).", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000609962037", "energy_kj": 2314.0, "energy_kj_computed": null, "energy_kcal": 553.0, "fat": 31.58, "saturated_fat": 21.05, "carbohydrates": 57.89, "sugars": 55.26, "starch": null, "sodium": 0.079, "ingredients_text": "Milk chocolate (sugar, milk, cocoa butter, chocolate, soy lecithin-an emulsifier, vanillian-an artificial flavor).", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000609962044", "energy_kj": 2201.0, "energy_kj_computed": null, "energy_kcal": 526.0, "fat": 31.58, "saturated_fat": 21.05, "carbohydrates": 57.89, "sugars": 50.0, "starch": null, "sodium": 0.013000000000000001, "ingredients_text": "Semi-sweet chocolate: (sugar, chocolate processed with alkali, cocoa butter, milk fat, soy lecithin-an emulsifier, vanillian-an artificial flavor, natural flavors).", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000609962082", "energy_kj": 2550.0, "energy_kj_computed": null, "energy_kcal": 609.0, "fat": 83.1, "saturated_fat": 55.4, "carbohydrates": 152.0, "sugars": 132.0, "starch": null, "sodium": 0.0342, "ingredients_text": "SEMI-SWEET CHOCOLATE: (SUGAR, CHOCOLATE PROCESSED WITH ALKALI, COCOA BUTTER, MILK FAT, SOY LECITHIN-AN EMULSIFIER, VANILLIAN-AN ARTIFICIAL FLAVOR, NATURAL FLAVORS).", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000609965007", "energy_kj": 2820.0, "energy_kj_computed": null, "energy_kcal": 675.0, "fat": 68.8, "saturated_fat": 50.0, "carbohydrates": 169.0, "sugars": 150.0, "starch": null, "sodium": 0.312, "ingredients_text": "MILK CHOCOLATE (SUGAR, MILK, COCOA BUTTER, CHOCOLATE, SOY LECITHIN-AN EMULSIFIER, VANILLIAN-AN ARTIFICIAL FLAVOR). MALT CENTER: (CORN SYRUP, WHEY (DAIRY), MALTED MILK (MALTED BARLEY, WHEAT FLOUR, MILK, BICARBONATE OF SODA, SALT), SUGAR, MALT EXTRACT, COCO", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000609983001", "energy_kj": 2326.0, "energy_kj_computed": null, "energy_kcal": 556.0, "fat": 33.33, "saturated_fat": 19.44, "carbohydrates": 58.33, "sugars": 55.56, "starch": null, "sodium": 0.083, "ingredients_text": "Milk chocolate (sugar, milk, cocoa butter, chocolate, soy lecithin - an emulsifier, vanillian-an artificial flavors).", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000609983032", "energy_kj": 2209.0, "energy_kj_computed": null, "energy_kcal": 528.0, "fat": 33.33, "saturated_fat": 19.44, "carbohydrates": 58.33, "sugars": 50.0, "starch": null, "sodium": 0.014, "ingredients_text": "Semi-sweet chocolate (sugar, chocolate processed with alkali, cocoa butter, milk fat, soy lecithin-an emulsifier, vanilla-an artificial flavor, natural flavors).", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000609989010", "energy_kj": 2272.0, "energy_kj_computed": null, "energy_kcal": 543.0, "fat": 31.43, "saturated_fat": 20.0, "carbohydrates": 57.14, "sugars": 54.29, "starch": null, "sodium": 0.07100000000000001, "ingredients_text": "Milk chocolate (sugar, milk, cocoa butter, chocolate, soy lecithin (an emulsifier), vanillin-an-artificial flavor)", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000609989027", "energy_kj": 2314.0, "energy_kj_computed": null, "energy_kcal": 553.0, "fat": 31.58, "saturated_fat": 21.05, "carbohydrates": 57.89, "sugars": 55.26, "starch": null, "sodium": 0.079, "ingredients_text": "Mix chocolate (sugar, milk, cocoa butter, chocolate, soy lecithin (an emulsifier), vanillin-an artificial flavor).", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000628006569", "energy_kj": 1188.0, "energy_kj_computed": null, "energy_kcal": 284.0, "fat": 2.1, "saturated_fat": 0.38, "carbohydrates": 54.4, "sugars": 3.1, "starch": null, "sodium": 0.52, "ingredients_text": "Farine de _bl\u00e9_ (farine de _bl\u00e9_, _gluten de bl\u00e9_, farine de _bl\u00e9_ malt\u00e9), eau, _graines de s\u00e9same_ d\u00e9cortiqu\u00e9es toast\u00e9es 1 %, sel, germe de _bl\u00e9_ 1 %, levure, \u00e9mulsifiant : E472e, agent de traitement de la farine E300.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0000630135899", "energy_kj": 9.0, "energy_kj_computed": null, "energy_kcal": 2.1, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 1.0, "sugars": 0.0, "starch": null, "sodium": null, "ingredients_text": "Water, xylitol, citric acid, lactic acid, apple juice concentrate*, ascorbic acid, malic acid, natural and artificial flavors, sucralose, blueberry juice concentrate, sodium benzoate and potassium sorbate (as a preservative).", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000630138791", "energy_kj": 8270.0, "energy_kj_computed": null, "energy_kcal": 1980.0, "fat": 0.0, "saturated_fat": null, "carbohydrates": 494.0, "sugars": 0.0, "starch": null, "sodium": 0.0, "ingredients_text": "WATER, GLYCERIN, CITRIC ACID, XYLITOL, APPLE JUICE CONCENTRATE*, ASCORBIC ACID, XANTHAN GUM, SUCRALOSE, MALIC ACID, NATURAL AND ARTIFICIAL FLAVORS, SODIUM BENZOATE AND POTASSIUM SORBATE (AS PRESERVATIVES), YELLOW #5, BLUE #1.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000651003214", "energy_kj": 69.4, "energy_kj_computed": null, "energy_kcal": 16.6, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 4.15, "sugars": 1.39, "starch": null, "sodium": 0.00706, "ingredients_text": "ROMAINE HEARTS.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000651041001", "energy_kj": 69.4, "energy_kj_computed": null, "energy_kcal": 16.6, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 4.15, "sugars": 1.39, "starch": null, "sodium": 0.00706, "ingredients_text": "ROMAINE.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000651041025", "energy_kj": 45.9, "energy_kj_computed": null, "energy_kcal": 11.1, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 2.76, "sugars": 1.39, "starch": null, "sodium": 0.0482, "ingredients_text": "GREEN LEAF.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000651213019", "energy_kj": 69.4, "energy_kj_computed": null, "energy_kcal": 16.6, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 4.15, "sugars": 0.0, "starch": null, "sodium": 0.0894, "ingredients_text": "SPINACH.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000651213026", "energy_kj": 69.4, "energy_kj_computed": null, "energy_kcal": 16.6, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 4.15, "sugars": 0.0, "starch": null, "sodium": 0.0894, "ingredients_text": "COOKING SPINACH", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000651319018", "energy_kj": 187.0, "energy_kj_computed": null, "energy_kcal": 44.8, "fat": 0.705, "saturated_fat": 0.0, "carbohydrates": 11.2, "sugars": 2.8, "starch": null, "sodium": 0.0353, "ingredients_text": "BRUSSELS SPROUTS.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000651511016", "energy_kj": 55.5, "energy_kj_computed": null, "energy_kcal": 13.2, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 3.31, "sugars": 1.65, "starch": null, "sodium": 0.0955, "ingredients_text": "CELERY", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000651813103", "energy_kj": 222.0, "energy_kj_computed": null, "energy_kcal": 53.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 7.06, "sugars": 1.18, "starch": null, "sodium": 0.08331200000000001, "ingredients_text": "Kalettes [kale sprouts].", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000653007548", "energy_kj": 1247.0, "energy_kj_computed": null, "energy_kcal": 298.0, "fat": 5.3, "saturated_fat": 1.0, "carbohydrates": 52.0, "sugars": 2.0, "starch": null, "sodium": 0.72, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0000672016408", "energy_kj": 1632.0, "energy_kj_computed": null, "energy_kcal": 390.0, "fat": 24.3, "saturated_fat": 4.8, "carbohydrates": 46.2, "sugars": 26.8, "starch": null, "sodium": 0.168, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0000682009841", "energy_kj": 1046.0, "energy_kj_computed": null, "energy_kcal": 250.0, "fat": 1.2, "saturated_fat": 0.2, "carbohydrates": 51.0, "sugars": 1.3, "starch": null, "sodium": 0.44, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0000698309041", "energy_kj": 2209.0, "energy_kj_computed": null, "energy_kcal": 528.0, "fat": 30.56, "saturated_fat": 22.22, "carbohydrates": 61.11, "sugars": 55.56, "starch": null, "sodium": 0.097, "ingredients_text": "Sugar, vegetable oil (coconut (tree nut), palm kernel, palm), cocoa butter, whole milk powder, cocoa mass, whey powder, cereals (corn flour, rice flour, wheat flour, sugar, lowfat cocoa powder, barley's, malt extract, salt), hazelnuts (tree nut), lowfat cocoa powder, skim milk powder, soy lecithin (emulsifier), artificial flavourings.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000698465815", "energy_kj": 2264.0, "energy_kj_computed": null, "energy_kcal": 541.0, "fat": 32.43, "saturated_fat": 21.62, "carbohydrates": 59.46, "sugars": 56.76, "starch": null, "sodium": 0.081, "ingredients_text": "Sugar, vegetable oil (coconut (tree nut), palm kernel, palm), cocoa mass, cocoa butter, whey powder, lowfat cocoa powder, whole milk powder, hazelnuts (tree nut), cereals (corn flour, rice flour, wheat flour, sugar, lowfat cocoa powder, barley's malt extract, salt), skim milk powder, soy lecithin (emulsifier), artificial flavourings.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000729181042", "energy_kj": 2125.0, "energy_kj_computed": null, "energy_kcal": 508.0, "fat": 27.5, "saturated_fat": 17.5, "carbohydrates": 60.0, "sugars": 37.5, "starch": null, "sodium": 0.16459200000000002, "ingredients_text": "Sugar, puffed rice (12%), vegetable oil & fat (palm), milk powder, glucose syrup, cocoa mass, cocoa butter, water, soy flour, hazelnuts (3%), butter oil, glycerin (humectants), soya & rapeseed lecithin and pgpr (emulsifier), salt, vanillin, artificial fla", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000730012144", "energy_kj": 1071.0, "energy_kj_computed": null, "energy_kcal": 256.0, "fat": 1.6, "saturated_fat": 0.3, "carbohydrates": 47.7, "sugars": 1.4, "starch": null, "sodium": 0.52, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0000764001770", "energy_kj": 192.0, "energy_kj_computed": null, "energy_kcal": 46.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 11.67, "sugars": 10.42, "starch": null, "sodium": 0.015, "ingredients_text": "Fuji apple cider, apple cider, pomegranate juice.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000764001787", "energy_kj": 226.0, "energy_kj_computed": null, "energy_kcal": 54.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 13.33, "sugars": 13.33, "starch": null, "sodium": 0.004, "ingredients_text": "Filtered water, lemon juice, pure cane sugar.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000764003033", "energy_kj": 192.0, "energy_kj_computed": null, "energy_kcal": 46.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 11.25, "sugars": 10.0, "starch": null, "sodium": 0.01, "ingredients_text": "Apple cider, natural flavor and spice.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000764003040", "energy_kj": 192.0, "energy_kj_computed": null, "energy_kcal": 46.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 11.67, "sugars": 8.33, "starch": null, "sodium": 0.006, "ingredients_text": "Pink lady apple cider, apple cider.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000764114944", "energy_kj": 192.0, "energy_kj_computed": null, "energy_kcal": 46.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 11.67, "sugars": 10.42, "starch": null, "sodium": 0.017, "ingredients_text": "100% organic apple juice.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000764708617", "energy_kj": 192.0, "energy_kj_computed": null, "energy_kcal": 46.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 11.67, "sugars": 8.33, "starch": null, "sodium": 0.006096, "ingredients_text": "Opal apple cider, apple cider.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000770324146", "energy_kj": 1502.0, "energy_kj_computed": null, "energy_kcal": 359.0, "fat": 2.7, "saturated_fat": 1.6, "carbohydrates": 5.8, "sugars": 1.4, "starch": null, "sodium": 0.292, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0000780016406", "energy_kj": 1251.0, "energy_kj_computed": null, "energy_kcal": 299.0, "fat": 11.0, "saturated_fat": 1.6, "carbohydrates": 44.0, "sugars": 18.0, "starch": null, "sodium": 0.256, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0000790100027", "energy_kj": 1343.0, "energy_kj_computed": null, "energy_kcal": 321.0, "fat": 0.0, "saturated_fat": null, "carbohydrates": 78.57, "sugars": 64.29, "starch": null, "sodium": 0.036000000000000004, "ingredients_text": "Concentrated apple puree, concentrated apple juice, ascorbic acid (vitamin c), natural pineapple flavor, natural mango flavor, concentrated black carrot juice (for color), pectin, coconut oil, shellac, beeswax.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000790100058", "energy_kj": 1343.0, "energy_kj_computed": null, "energy_kcal": 321.0, "fat": 0.0, "saturated_fat": null, "carbohydrates": 78.57, "sugars": 64.29, "starch": null, "sodium": 0.036000000000000004, "ingredients_text": "Concentrated apple puree, concentrated apple juice, ascorbic acid (vitamin c), natural blueberry flavor, natural pomegranate flavor, concentrated black carrot juice (for color), pectin, coconut oil, shellac, beeswax.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000790105282", "energy_kj": 1046.0, "energy_kj_computed": null, "energy_kcal": 250.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 65.0, "sugars": 42.5, "starch": null, "sodium": 0.025, "ingredients_text": "Corn syrup, sugar, water, gelatin, natural & artificial flavor, root beer concentrate (caramel color, water, natural & artificial flavor), mineral oil*, carnauba wax.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000790110002", "energy_kj": 1151.0, "energy_kj_computed": null, "energy_kcal": 275.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 67.5, "sugars": 40.0, "starch": null, "sodium": 0.012, "ingredients_text": "Corn syrup, sugar, water, gelatin, dextrose, citric acid, natural & artificial flavor, fd&c red 40, yellow 5, yellow 6, blue 1, mineral oil, carnauba wax.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000790110019", "energy_kj": 1151.0, "energy_kj_computed": null, "energy_kcal": 275.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 67.5, "sugars": 40.0, "starch": null, "sodium": 0.012, "ingredients_text": "Corn syrup, sugar, water, gelatin, dextrose, citric acid, natural & artificial flavor, fd&c red 40, yellow 5, yellow 6, blue 1, mineral oil, carnauba wax.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000790110026", "energy_kj": 1151.0, "energy_kj_computed": null, "energy_kcal": 275.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 67.5, "sugars": 40.0, "starch": null, "sodium": 0.012, "ingredients_text": "Corn syrup, sugar, water, gelatin, dextrose, citric acid, natural & artificial flavor, fd&c red 40, yellow 5, yellow 6, blue 1, mineral oil, carnauba wax.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000790110033", "energy_kj": 2820.0, "energy_kj_computed": null, "energy_kcal": 675.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 169.0, "sugars": 100.0, "starch": null, "sodium": 0.03, "ingredients_text": "CORN SYRUP, SUGAR, WATER, GELATIN, DEXTROSE, CITRIC ACID, NATURAL & ARTIFICIAL FLAVOR, FD&C RED 40, YELLOW 5, YELLOW 6, BLUE 1, MINERAL OIL, CARNAUBA WAX", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000790110040", "energy_kj": 1151.0, "energy_kj_computed": null, "energy_kcal": 275.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 67.5, "sugars": 40.0, "starch": null, "sodium": 0.012, "ingredients_text": "Corn syrup, sugar, water, gelatin, dextrose, citric acid, natural & artificial flavor, fd&c red 40, yellow 5, yellow 6, blue 1, mineral oil, carnauba wax.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000790110057", "energy_kj": 1151.0, "energy_kj_computed": null, "energy_kcal": 275.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 67.5, "sugars": 40.0, "starch": null, "sodium": 0.012, "ingredients_text": "Corn syrup, sugar, water, gelatin, dextrose, citric acid, natural & artificial flavor, fd&c red 40, yellow 5, yellow 6, blue 1, mineral oil, carnauba wax.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000790200123", "energy_kj": 1674.0, "energy_kj_computed": null, "energy_kcal": 400.0, "fat": 32.0, "saturated_fat": 20.0, "carbohydrates": 60.0, "sugars": 0.0, "starch": null, "sodium": 0.0, "ingredients_text": "Maltitol, chocolate liquor, cocoa butter, inulin (natural vegetable fiber), soy lecithin, vanilla, cinnamon.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000790310013", "energy_kj": 1360.0, "energy_kj_computed": null, "energy_kcal": 325.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 75.0, "sugars": 57.5, "starch": null, "sodium": 0.0508, "ingredients_text": "sugar, corn syrup, white grape juice from concentrate, gelatin, citric acid, tartaric acid, fumaric acid, sorbitol, natural & artificial flavours, silicon dioxide (anticaking agent), artificial colours (fd&c red 40, yellow 6, blue 1, yellow 5)", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000790310020", "energy_kj": 586.0, "energy_kj_computed": null, "energy_kcal": 140.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 34.0, "sugars": 24.0, "starch": null, "sodium": 0.03048, "ingredients_text": "sugar, corn syrup, modified corn starch, citrict acid, sodium citrate, natural and artificial flavours, mineral oil, carnauba wax, red 40, yellow 6, yellow 5, blue 1.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000790310044", "energy_kj": null, "energy_kj_computed": null, "energy_kcal": null, "fat": null, "saturated_fat": null, "carbohydrates": null, "sugars": null, "starch": null, "sodium": null, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0000790310075", "energy_kj": 1255.0, "energy_kj_computed": null, "energy_kcal": 300.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 70.0, "sugars": 52.5, "starch": null, "sodium": 0.05, "ingredients_text": "Sugar, corn syrup, white grape juice from concentrate, gelatin, citric acid, sorbitol, natural & artificial flavors, carnauba wax, artificial colors (fd&c blue 1, yellow 5, yellow 6, red 40).", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000790350040", "energy_kj": 1883.0, "energy_kj_computed": null, "energy_kcal": 450.0, "fat": 17.5, "saturated_fat": 17.5, "carbohydrates": 77.5, "sugars": 75.0, "starch": null, "sodium": 0.0, "ingredients_text": "Sugar, assorted nonpareils (sugar, corn starch, confectioners glaze, fd&c red 40, yellow 5, yellow 6, blue 1, carnauba wax), hydrogenated palm kernel oil, whey protein concentrate [milk], cocoa powder, chocolate liquor, cocoa powder (processed with alkali), soy lecithin, natural flavor.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000790350187", "energy_kj": 1464.0, "energy_kj_computed": null, "energy_kcal": 350.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 85.0, "sugars": 60.0, "starch": null, "sodium": 0.075, "ingredients_text": "Sugar, corn syrup, modified corn starch, citric acid, sodium citrate, natural and artificial flavors, mineral oil, carnauba wax, red 40, yellow 6, yellow 5, blue 1.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000790350385", "energy_kj": 1197.0, "energy_kj_computed": null, "energy_kcal": 286.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 71.43, "sugars": 42.86, "starch": null, "sodium": 0.0, "ingredients_text": "Corn syrup, sugar, water, apple juice concentrate, modified food starch (corn), gelatin, dextrose, apple puree, citric acid, artificial flavor, ascorbic acid, mineral oil, carnuba wax, artificial colors (fd&c red 40, yellow 5, blue 1).", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000790400004", "energy_kj": 1494.0, "energy_kj_computed": null, "energy_kcal": 357.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 92.86, "sugars": 75.0, "starch": null, "sodium": 0.0, "ingredients_text": "Fuji apples.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000790400028", "energy_kj": 1343.0, "energy_kj_computed": null, "energy_kcal": 321.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 85.71, "sugars": 64.29, "starch": null, "sodium": 0.0, "ingredients_text": "Bananas, strawberries.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000790400042", "energy_kj": 1494.0, "energy_kj_computed": null, "energy_kcal": 357.0, "fat": 1.79, "saturated_fat": 0.0, "carbohydrates": 89.29, "sugars": 78.57, "starch": null, "sodium": 0.0, "ingredients_text": "Mangos.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000790400066", "energy_kj": 1477.0, "energy_kj_computed": null, "energy_kcal": 353.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 94.12, "sugars": 82.35, "starch": null, "sodium": 0.059000000000000004, "ingredients_text": "Grapes.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000790400301", "energy_kj": 1464.0, "energy_kj_computed": null, "energy_kcal": 350.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 90.0, "sugars": 70.0, "starch": null, "sodium": 0.0, "ingredients_text": "Fuji apples, ascorbic acid, citric acid.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000790400325", "energy_kj": 1464.0, "energy_kj_computed": null, "energy_kcal": 350.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 90.0, "sugars": 60.0, "starch": null, "sodium": 0.0, "ingredients_text": "Bananas, strawberries.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000790400349", "energy_kj": 1464.0, "energy_kj_computed": null, "energy_kcal": 350.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 90.0, "sugars": 80.0, "starch": null, "sodium": 0.0, "ingredients_text": "Mangos.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000790400363", "energy_kj": 1569.0, "energy_kj_computed": null, "energy_kcal": 375.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 91.67, "sugars": 83.33, "starch": null, "sodium": 0.042672, "ingredients_text": "Grapes.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000790410003", "energy_kj": 1360.0, "energy_kj_computed": null, "energy_kcal": 325.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 82.5, "sugars": 75.0, "starch": null, "sodium": 0.0, "ingredients_text": "Caranberries, sugar, natural flavors, sunflower oil.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000790410010", "energy_kj": 1360.0, "energy_kj_computed": null, "energy_kcal": 325.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 82.5, "sugars": 75.0, "starch": null, "sodium": 0.0, "ingredients_text": "Cranberries, sugar, natural flavors, sunflower oil.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000790410027", "energy_kj": 1360.0, "energy_kj_computed": null, "energy_kcal": 325.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 82.5, "sugars": 75.0, "starch": null, "sodium": 0.0, "ingredients_text": "Cranberries, sugar, natural flavors,sunflower oil.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000790410034", "energy_kj": 3450.0, "energy_kj_computed": null, "energy_kcal": 825.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 206.0, "sugars": 188.0, "starch": null, "sodium": 0.0, "ingredients_text": "CRANBERRIES, SUGAR, NATURAL FLAVORS, SUNFLOWER OIL.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000790410041", "energy_kj": 2300.0, "energy_kj_computed": null, "energy_kcal": 550.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 138.0, "sugars": 81.2, "starch": null, "sodium": 0.0, "ingredients_text": "DRIED APRICOTS, NATURAL FLAVORS, SULFUR DIOXIDE (TO PRESERVE FLAVOR), CITRIC ACID, ASCORBIC ACID, MALIC ACID.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000790410058", "energy_kj": 3030.0, "energy_kj_computed": null, "energy_kcal": 725.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 181.0, "sugars": 18.8, "starch": null, "sodium": 0.0, "ingredients_text": "HONEY CRISP APPLES, SULFUR DIOXIDE (TO PRESERVE FRESHNESS).", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000790410065", "energy_kj": 3560.0, "energy_kj_computed": null, "energy_kcal": 850.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 212.0, "sugars": 162.0, "starch": null, "sodium": 0.438, "ingredients_text": "MANGO, SUGAR, MANGO JUICE, SULFUR DIOXIDE (TO PRESERVE FLAVOR), CITRIC ACID.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000790410553", "energy_kj": 1456.0, "energy_kj_computed": null, "energy_kcal": 348.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 82.61, "sugars": 73.91, "starch": null, "sodium": 0.0, "ingredients_text": "Cranberries, mangos, blueberries, sugar, sunflower oil, sulfur dioxide (to preserve flavor).", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000790420002", "energy_kj": 7210.0, "energy_kj_computed": null, "energy_kcal": 1720.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 431.0, "sugars": 363.0, "starch": null, "sodium": 0.681, "ingredients_text": "APPLES, SODIUM SULPHITE.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000790430018", "energy_kj": 1971.0, "energy_kj_computed": null, "energy_kcal": 471.0, "fat": 25.88, "saturated_fat": 8.24, "carbohydrates": 51.76, "sugars": 44.71, "starch": null, "sodium": 0.188, "ingredients_text": "Peanuts flavored dried cranberries (cranberries, sugar, sunflower oil, natural flavor), peanut flavored coating dried cane syrup, palm kernel oil, partially defatted peanut flour, whey powder [milk], salt, soy lecithin [an emulsifier], yogurt flavored coating (sugar, palm kernel oil and/or palm oil, nonfat dry milk, whey powder, nonfat yogurt powder [cultured whey, nonfat milk], titanium dioxide [color], soy lecithin [an emulsifier], lactic acid, vanilla), sugar, corn oil, salt, coloring (includes vegetable juice), tapioca dextrin, honey, gum arabic, natural flavors, corn syrup, confectioner's glaze.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000790430063", "energy_kj": 1971.0, "energy_kj_computed": null, "energy_kcal": 471.0, "fat": 25.88, "saturated_fat": 8.24, "carbohydrates": 51.76, "sugars": 40.0, "starch": null, "sodium": 0.188, "ingredients_text": "Peanuts, strawberry flavored dried cranberries (cranberries, sugar, natural flavors, citric acid, sunflower oil, elderberry juice concentrate [color]), peanut flavored coating (dried cane syrup, palm kernel oil, partially defatted peanut flour, whey powder [milk], salt, soy lecithin [an emulsifier]), yogurt flavored coating (sugar, palm kernel oil and/or palm oil, nonfat dry milk, whey powder, nonfat yogurt powder [cultured whey, nonfat milk], titanium dioxide [color], soy lecithin [an emulsifier], lactic acid, vanilla), sugar, corn oil, salt, coloring (includes beet juice beta carotene, beet juice concentrate), tapioca dextrin, honey, gum arabic, corn syrup, natural flavors, confectioner's glaze.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000790430070", "energy_kj": 1971.0, "energy_kj_computed": null, "energy_kcal": 471.0, "fat": 25.88, "saturated_fat": 8.24, "carbohydrates": 51.76, "sugars": 44.71, "starch": null, "sodium": 0.188, "ingredients_text": "Peanuts, flavored dried cranberries (cranberries, sugar, sunflower oil, natural flavor). peanut flavored coating (dried cane syrup, palm kernel oil, partially defatted peanut flour, whey powder [milk], salt, soy lecithin [an emulsifier], yogurt flavored coating (sugar, palm kernel oil and/or palm oil, nonfat dry milk, whey powder, nonfat yogurt powder [cultured whey, nonfat milk], titanium dioxide [color], soy lecithin [an emulsifier], lactic acid, vanilla), sugar, corn oil, salt, coloring (includes vegetable juice), tapioca dextrin, honey, gum arabic, natural flavors, corn syrup, confectioner's glaze.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000790440017", "energy_kj": 5550.0, "energy_kj_computed": null, "energy_kcal": 1330.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 332.0, "sugars": 281.0, "starch": null, "sodium": 2.33, "ingredients_text": "APPLES, SODIUM SULPHITE (TO PRESERVE FRESHNESS).", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000790440024", "energy_kj": 5550.0, "energy_kj_computed": null, "energy_kcal": 1330.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 332.0, "sugars": 281.0, "starch": null, "sodium": 2.3, "ingredients_text": "APPLES, SODIUM SULPHITE (TO PRESERVE FRESHNESS).", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000790440031", "energy_kj": 5550.0, "energy_kj_computed": null, "energy_kcal": 1330.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 332.0, "sugars": 281.0, "starch": null, "sodium": 2.33, "ingredients_text": "APPLES, SODIUM SULPHITE (TO PRESERVE FRESHNESS).", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000790500117", "energy_kj": 2930.0, "energy_kj_computed": null, "energy_kcal": 700.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 175.0, "sugars": 93.8, "starch": null, "sodium": 0.095, "ingredients_text": "SUGAR, CORN SYRUP, WHITE GRAPE JUICE CONCENTRATE, GELATIN, CITRIC ACID, NATURAL AND ARTIFICIAL FLAVOR, FD&C RED 40, YELLOW 5, YELLOW 6, BLUE 1, RED 3, CARNAUBA WAX.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000790500148", "energy_kj": 2930.0, "energy_kj_computed": null, "energy_kcal": 700.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 175.0, "sugars": 93.8, "starch": null, "sodium": 0.095, "ingredients_text": "SUGAR, CORN SYRUP, WHITE GRAPE JUICE CONCENTRATE, GELATIN, CITRIC ACID, NATURAL AND ARTIFICIAL FLAVOR, FD&C RED 40, YELLOW 5, YELLOW 6, BLUE 1, RED 3, CARNAUBA WAX.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000790500186", "energy_kj": 1255.0, "energy_kj_computed": null, "energy_kcal": 300.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 70.0, "sugars": 37.5, "starch": null, "sodium": 0.038, "ingredients_text": "Sugar, corn syrup, white grape juice concentrate, gelatin, citric acid, natural and artificial flavor, fd&c red 40, yellow 5, yellow 6, blue 1, red 3, carnauba wax.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000790500230", "energy_kj": 2930.0, "energy_kj_computed": null, "energy_kcal": 700.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 175.0, "sugars": 93.8, "starch": null, "sodium": 0.095, "ingredients_text": "SUGAR, CORN SYRUP, WHITE GRAPE JUICE CONCENTRATE, GELATIN, CITRIC ACID, NATURAL AND ARTIFICIAL FLAVOR, FD&C RED 40, YELLOW 5, YELLOW 6, BLUE 1, RED 3, CARNAUBA WAX.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000790500247", "energy_kj": 2930.0, "energy_kj_computed": null, "energy_kcal": 700.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 175.0, "sugars": 93.8, "starch": null, "sodium": 0.095, "ingredients_text": "SUGAR, CORN SYRUP, WHITE GRAPE JUICE CONCENTRATE, GELATIN, CITRIC ACID, NATURAL AND ARTIFICIAL FLAVOR, FD&C RED 40, YELLOW 5, YELLOW 6, BLUE 1, RED 3, CARNAUBA WAX.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000790500254", "energy_kj": 2930.0, "energy_kj_computed": null, "energy_kcal": 700.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 175.0, "sugars": 93.8, "starch": null, "sodium": 0.095, "ingredients_text": "SUGAR, CORN SYRUP, WHITE GRAPE JUICE CONCENTRATE, GELATIN, CITRIC ACID, NATURAL AND ARTIFICIAL FLAVOR, FD&C RED 40, YELLOW 5, YELLOW 6, BLUE 1, RED 3, CARNAUBA WAX.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000790520603", "energy_kj": 1360.0, "energy_kj_computed": null, "energy_kcal": 325.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 80.0, "sugars": 45.0, "starch": null, "sodium": 0.17500000000000002, "ingredients_text": "Grape juice, concentrate, corn syrup, sugar, modified food starch, apple puree, gelatin, citric acid, sodium citrate, ascorbic acid (vitamin c), natural and artificial flavors, fd&c red 40, yellow 5, blue 1, red 3, carnauba wax.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000790520702", "energy_kj": 1293.0, "energy_kj_computed": null, "energy_kcal": 309.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 79.37, "sugars": null, "starch": null, "sodium": 0.176, "ingredients_text": "Grape juice concentrate, corn syrup, modified food starch, apple puree, gelatin, citric acid, sodium citrate, ascorbic acid (vitamin c), natural & artificial flavors, fd&c red 40, yellow 5, blue 1, red 3, carnauba wax.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000790620105", "energy_kj": 1255.0, "energy_kj_computed": null, "energy_kcal": 300.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 100.0, "sugars": 60.0, "starch": null, "sodium": 0.1016, "ingredients_text": "Sugar, white grape juice from concentrate, corn syrup, modified corn starch, gelatin, citric acid, apple puree, natural and artificial flavors, sodium citrate, ascorbic acid (vitamin c), carnauba wax, artificial colors (fd&c red 40, yellow 5, yellow 6, re", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000790620112", "energy_kj": 2930.0, "energy_kj_computed": null, "energy_kcal": 700.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 175.0, "sugars": 106.0, "starch": null, "sodium": 0.03, "ingredients_text": "CORN SYRUP, SUGAR, WATER, APPLE JUICE CONCENTRATE, MODIFIED FOOD STARCH (CORN), GELATIN, DEXTROSE, APPLE PUREE, CITRIC ACID, NATURAL & ARTIFICIAL FLAVOR, ASCORBIC ACID (VITAMIN C), MINERAL OIL, CARNAUBA WAX, ARTIFICIAL COLORS (FD&C RED 40, YELLOW 5, YELLO", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000790900115", "energy_kj": 1674.0, "energy_kj_computed": null, "energy_kcal": 400.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 100.0, "sugars": 100.0, "starch": null, "sodium": 0.0, "ingredients_text": "SUCROSE, LACTOSE (MILK), CORN SYRUP SOLIDS, NATURAL AND ARTIFICIAL FLAVOR, FD&C BLUE 1, PROCESSED WITH CARBON DIOXIDE FOR POPPING EFFECT.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000790900122", "energy_kj": 1674.0, "energy_kj_computed": null, "energy_kcal": 400.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 100.0, "sugars": 100.0, "starch": null, "sodium": 0.0, "ingredients_text": "SUCROSE, LACTOSE (MILK), CORN SYRUP SOLIDS, NATURAL AND ARTIFICIAL FLAVOR, FD&C YELLOW 5, PROCESSED WITH CARBON DIOXIDE FOR POPPING EFFECT.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000790900139", "energy_kj": 1674.0, "energy_kj_computed": null, "energy_kcal": 400.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 100.0, "sugars": 100.0, "starch": null, "sodium": 0.0, "ingredients_text": "SUCROSE, LACTOSE (MILK), CORN SYRUP SOLIDS, NATURAL AND ARTIFICIAL FLAVOR, FD&C YELLOW 5, BLUE 1, PROCESSED WITH CARBON DIOXIDE FOR POPPING EFFECT.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000800000002", "energy_kj": 1447.0, "energy_kj_computed": 1352.0, "energy_kcal": 346.0, "fat": 4.7, "saturated_fat": 0.7, "carbohydrates": 65.0, "sugars": 35.0, "starch": null, "sodium": 0.04, "ingredients_text": "EPICES A PAINS DI EPICES ln Epices cannelle) gingembre, coriandre, anis, clous de girofle, anis \u00e9toil\u00e9, muscade, poivre SCIcre.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0000806029526", "energy_kj": 1218.0, "energy_kj_computed": null, "energy_kcal": 291.0, "fat": 10.0, "saturated_fat": 0.9, "carbohydrates": 39.7, "sugars": 1.8, "starch": null, "sodium": 0.356, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0000822006563", "energy_kj": 1125.0, "energy_kj_computed": null, "energy_kcal": 269.0, "fat": 3.0, "saturated_fat": 0.3, "carbohydrates": 47.9, "sugars": 3.8, "starch": null, "sodium": 0.532, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0000835766119", "energy_kj": 1197.0, "energy_kj_computed": null, "energy_kcal": 286.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 80.95, "sugars": 76.19, "starch": null, "sodium": 0.0, "ingredients_text": "Pure raw honey, whole organic raspberries", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000835766317", "energy_kj": 6450.0, "energy_kj_computed": null, "energy_kcal": 1540.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 385.0, "sugars": 363.0, "starch": null, "sodium": 0.0, "ingredients_text": "PURE RAW HONEY", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000835766331", "energy_kj": 1197.0, "energy_kj_computed": null, "energy_kcal": 286.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 80.95, "sugars": 76.19, "starch": null, "sodium": 0.0, "ingredients_text": "Pure raw honey, organic cinnamon", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000835766355", "energy_kj": 1197.0, "energy_kj_computed": null, "energy_kcal": 286.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 80.95, "sugars": 76.19, "starch": null, "sodium": 0.0, "ingredients_text": "Pure raw honey, lemon juice", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000835766553", "energy_kj": 6450.0, "energy_kj_computed": null, "energy_kcal": 1540.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 385.0, "sugars": 363.0, "starch": null, "sodium": 0.0, "ingredients_text": "PURE RAW HONEY, WHOLE ORGANIC HIBISCUS FLOWERS", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000835766560", "energy_kj": 15100.0, "energy_kj_computed": null, "energy_kcal": 3600.0, "fat": 0.0, "saturated_fat": null, "carbohydrates": 900.0, "sugars": 800.0, "starch": null, "sodium": 0.0, "ingredients_text": "PURE RAW HONEY, CINNAMON.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000835766577", "energy_kj": 15100.0, "energy_kj_computed": null, "energy_kcal": 3600.0, "fat": 0.0, "saturated_fat": null, "carbohydrates": 900.0, "sugars": 800.0, "starch": null, "sodium": 0.0, "ingredients_text": "PURE RAW HONEY, LEMON JUICE.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000835766584", "energy_kj": 15100.0, "energy_kj_computed": null, "energy_kcal": 3600.0, "fat": 0.0, "saturated_fat": null, "carbohydrates": 900.0, "sugars": 800.0, "starch": null, "sodium": 0.0, "ingredients_text": "PURE RAW HONEY, REAL RASPBERRIES.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000835766607", "energy_kj": 1255.0, "energy_kj_computed": null, "energy_kcal": 300.0, "fat": 0.0, "saturated_fat": null, "carbohydrates": 90.0, "sugars": 80.0, "starch": null, "sodium": 0.0, "ingredients_text": "Pure raw honey, real hibiscus flowers.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000835766614", "energy_kj": 15100.0, "energy_kj_computed": null, "energy_kcal": 3600.0, "fat": 0.0, "saturated_fat": null, "carbohydrates": 900.0, "sugars": 800.0, "starch": null, "sodium": 0.0, "ingredients_text": "PURE RAW HONEY", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000850600108", "energy_kj": 0.0, "energy_kj_computed": null, "energy_kcal": 0.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 0.0, "sugars": 0.0, "starch": null, "sodium": 0.651, "ingredients_text": "SHRIMP SALT, SODIUM PHOSPHATE (TO RETAIN MOISTURE)", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000886100252", "energy_kj": null, "energy_kj_computed": null, "energy_kcal": null, "fat": null, "saturated_fat": null, "carbohydrates": null, "sugars": null, "starch": null, "sodium": null, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0000901000017", "energy_kj": 4640.0, "energy_kj_computed": null, "energy_kcal": 1110.0, "fat": 37.8, "saturated_fat": 0.0, "carbohydrates": 277.0, "sugars": 0.0, "starch": null, "sodium": 2.27, "ingredients_text": "STONE GROUND ORGANIC YELLOW CORN, EXPELLER PRESSED SAFFLOWER OR SUNFLOWER OIL, SALT AND LIME.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000901002042", "energy_kj": 2110.0, "energy_kj_computed": null, "energy_kcal": 504.0, "fat": 139.0, "saturated_fat": 18.9, "carbohydrates": 126.0, "sugars": 63.0, "starch": null, "sodium": 0.577, "ingredients_text": "DRY ROASTED ALMONDS, CASHEWS, PISTACHIOS, PURE CANE SUGAR, RICE SYRUP, DRIED BLUEBERRIES, POMEGRANATE POWDER, SEA SALT AND NATURAL FLAVORS.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000901005005", "energy_kj": 71.0, "energy_kj_computed": null, "energy_kcal": 17.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 4.0, "sugars": 3.0, "starch": null, "sodium": 0.011, "ingredients_text": "Organic coconut water, ascorbic acid.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000901881036", "energy_kj": 126.0, "energy_kj_computed": null, "energy_kcal": 30.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 8.0, "sugars": 7.0, "starch": null, "sodium": 0.0, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0000901881326", "energy_kj": 1205.0, "energy_kj_computed": null, "energy_kcal": 288.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 72.0, "sugars": 72.0, "starch": null, "sodium": 0.0, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0000946909078", "energy_kj": 1393.0, "energy_kj_computed": null, "energy_kcal": 333.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 0.0, "sugars": 0.0, "starch": null, "sodium": 0.0, "ingredients_text": "Vital wheat gluten.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000974300144", "energy_kj": 212.0, "energy_kj_computed": null, "energy_kcal": 50.4, "fat": 0.0, "saturated_fat": null, "carbohydrates": 12.6, "sugars": null, "starch": null, "sodium": 5.16, "ingredients_text": "CAPERBERRIES, WATER, VINEGAR AND SALT.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0000996284712", "energy_kj": 1180.0, "energy_kj_computed": null, "energy_kcal": 282.0, "fat": 24.64, "saturated_fat": 18.21, "carbohydrates": 1.79, "sugars": null, "starch": null, "sodium": 0.4, "ingredients_text": "Pasteurized cow milk, pasteurized sheep milk, pasteurized goat milk, salt, rennet.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0001000004005", "energy_kj": null, "energy_kj_computed": null, "energy_kcal": null, "fat": null, "saturated_fat": null, "carbohydrates": null, "sugars": null, "starch": null, "sodium": null, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0001000008218", "energy_kj": null, "energy_kj_computed": null, "energy_kcal": null, "fat": null, "saturated_fat": null, "carbohydrates": null, "sugars": null, "starch": null, "sodium": null, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0001000008706", "energy_kj": null, "energy_kj_computed": null, "energy_kcal": null, "fat": null, "saturated_fat": null, "carbohydrates": null, "sugars": null, "starch": null, "sodium": null, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0001100000136", "energy_kj": null, "energy_kj_computed": null, "energy_kcal": null, "fat": null, "saturated_fat": null, "carbohydrates": null, "sugars": null, "starch": null, "sodium": null, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "de", "lang": "de", "language_code": "de"} +{"product_id": "0001100064084", "energy_kj": 2960.0, "energy_kj_computed": null, "energy_kcal": 708.0, "fat": 93.6, "saturated_fat": 72.8, "carbohydrates": 177.0, "sugars": 83.3, "starch": null, "sodium": 0.416, "ingredients_text": "WHEAT FLOUR - COCONUT OIL - DEHYDRATED GLUCOSE SYRUP - SUGAR HAZELNUTS 10.8% IN THE CREAM CORRESPONDING TO 8,6% OF THE TOTAL INGREDIENTS - WHEY POWDER (MILK) - SOYA FLOUR - DRIED SKIMMED MILK - LOW FAT COCOA - DEXTROSE - EMULSIFIER: SOYA LECITHIN - RAISIN", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0001146901886", "energy_kj": null, "energy_kj_computed": null, "energy_kcal": null, "fat": null, "saturated_fat": null, "carbohydrates": null, "sugars": null, "starch": null, "sodium": null, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0001182000086", "energy_kj": null, "energy_kj_computed": null, "energy_kcal": null, "fat": null, "saturated_fat": null, "carbohydrates": null, "sugars": null, "starch": null, "sodium": null, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "de", "lang": "de", "language_code": "de"} +{"product_id": "0001200001217", "energy_kj": null, "energy_kj_computed": null, "energy_kcal": null, "fat": null, "saturated_fat": null, "carbohydrates": null, "sugars": null, "starch": null, "sodium": null, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0001210078780", "energy_kj": null, "energy_kj_computed": null, "energy_kcal": null, "fat": null, "saturated_fat": null, "carbohydrates": null, "sugars": null, "starch": null, "sodium": null, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0001390000007", "energy_kj": 1582.0, "energy_kj_computed": null, "energy_kcal": 378.0, "fat": 8.2, "saturated_fat": 1.0, "carbohydrates": 9.1, "sugars": 3.0, "starch": null, "sodium": 0.44, "ingredients_text": "o, sin gluten, sin lactosa, sin az\u00fccares lientes: 100% Spirulina cruda pura procedefi tura ec016gica. PAIS DE ORIGEjs NOUE", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0001686413511", "energy_kj": 1300.0, "energy_kj_computed": null, "energy_kcal": 310.0, "fat": 0.2, "saturated_fat": 0.2, "carbohydrates": 77.5, "sugars": 55.5, "starch": null, "sodium": 0.02, "ingredients_text": "GLUCOSE SYRUP, SUGAR, DEXTROSE, GELATIN, CITRIC ACID, FLAVOR, GLAZING AGENT: BEESWAX WHITE AND YELLOW, CARNAUBA WAX, ACIDITY REGULATOR: SODIUM CITRATE, CARAMEL SYRUP, STABILIZER: CARRAGEENAN.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0001757016092", "energy_kj": 1990.0, "energy_kj_computed": null, "energy_kcal": 476.0, "fat": 85.0, "saturated_fat": 34.0, "carbohydrates": 119.0, "sugars": 108.0, "starch": null, "sodium": 0.198, "ingredients_text": "SUGAR, COCOA BUTTER, HAZELNUTS, WHOLE MILK POWDER, COCOA MASS RUM - RAISINS [RAISINS, RUM 60% VOL., RUM FLAVOR], LACTOSE, WHEY POWDER, HAZELNUT PASTE, EMULSIFIER: SOY LECITHIN, FLAVOR: VANILLE EXTRACT. COCOA SOLIDS: 31% MINIMUM IN CHOCOLATE.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0002000000271", "energy_kj": null, "energy_kj_computed": null, "energy_kcal": null, "fat": null, "saturated_fat": null, "carbohydrates": null, "sugars": null, "starch": null, "sodium": null, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0002000000448", "energy_kj": 741.0, "energy_kj_computed": null, "energy_kcal": 177.0, "fat": 11.0, "saturated_fat": 10.0, "carbohydrates": 18.0, "sugars": 17.0, "starch": null, "sodium": 0.02, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0002000000493", "energy_kj": 372.0, "energy_kj_computed": null, "energy_kcal": 89.0, "fat": 1.5, "saturated_fat": 0.5, "carbohydrates": 2.9, "sugars": 0.5, "starch": null, "sodium": 0.8, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0002000000585", "energy_kj": 2146.0, "energy_kj_computed": null, "energy_kcal": 513.0, "fat": 26.0, "saturated_fat": 8.0, "carbohydrates": 60.0, "sugars": 23.0, "starch": null, "sodium": 0.272, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0002000000592", "energy_kj": 1197.0, "energy_kj_computed": null, "energy_kcal": 286.0, "fat": 7.2, "saturated_fat": 1.7, "carbohydrates": 40.0, "sugars": 0.6, "starch": null, "sodium": 0.252, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0002000000608", "energy_kj": 347.0, "energy_kj_computed": null, "energy_kcal": 83.0, "fat": 2.8, "saturated_fat": 2.0, "carbohydrates": 11.1, "sugars": 11.1, "starch": null, "sodium": 0.052, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0002000000707", "energy_kj": 1163.0, "energy_kj_computed": null, "energy_kcal": 278.0, "fat": 22.0, "saturated_fat": 14.0, "carbohydrates": 0.0, "sugars": 0.0, "starch": null, "sodium": 0.8, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0002000000714", "energy_kj": 184.0, "energy_kj_computed": null, "energy_kcal": 44.0, "fat": 0.1, "saturated_fat": 0.07, "carbohydrates": 4.3, "sugars": 3.6, "starch": null, "sodium": 0.052, "ingredients_text": "Lait de brebis \u00e9cr\u00e9me pasteuris\u00e9* ferments lactiques s\u00e9lectionn\u00e9s. * Issu de l'agriculture biologique", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0002000000776", "energy_kj": 828.0, "energy_kj_computed": null, "energy_kcal": 198.0, "fat": 12.0, "saturated_fat": 2.5, "carbohydrates": 0.6, "sugars": 0.6, "starch": null, "sodium": 1.16, "ingredients_text": "More information on www.paulandlinh.com M\u00e9kong Biscuits \u00e0 l'abricot sans gluten et sans lait Inar\u00e9d:ents: abncots\u2022 27% . swe de canne'. \u0152ufs*, huile de colza'. fanne de riz'. fanne de ch\u00e0tagne\u2022, amandes*e miel'. (amidon de mais'. poudre de vanille Bourbon'. poudre \u00e0 IZ c bicarbonate de sodium, tartrate monopotassique), ar\u00f4me naturel d'abricot Produits ISSUS de rAgricu!ture Fabriqu\u00e9s dans un ateLer uti\u2022", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0002000000967", "energy_kj": 2050.0, "energy_kj_computed": null, "energy_kcal": 490.0, "fat": 20.0, "saturated_fat": 9.9, "carbohydrates": 70.1, "sugars": 23.6, "starch": null, "sodium": 0.264, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0002000001186", "energy_kj": 59.0, "energy_kj_computed": null, "energy_kcal": 14.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 2.0, "sugars": 1.3, "starch": null, "sodium": 0.012, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0002000001421", "energy_kj": 347.0, "energy_kj_computed": null, "energy_kcal": 83.0, "fat": 3.3, "saturated_fat": 0.55, "carbohydrates": 5.5, "sugars": 1.0, "starch": null, "sodium": 0.4, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0002000001711", "energy_kj": 1699.0, "energy_kj_computed": null, "energy_kcal": 406.0, "fat": 14.0, "saturated_fat": 9.0, "carbohydrates": 70.0, "sugars": 45.0, "starch": null, "sodium": null, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0002000001780", "energy_kj": 1109.0, "energy_kj_computed": null, "energy_kcal": 265.0, "fat": 10.0, "saturated_fat": 5.0, "carbohydrates": 30.0, "sugars": 1.0, "starch": null, "sodium": 0.16, "ingredients_text": "P\u00e2te* '53.570 (farine de bl\u00e9* , eau, sel, levure*), sauce tomate* 17% (pur\u00e9e de tomate* , oignon* sucre* , sel, ail* , origan* , basilic* , poivre* , persil* , concentr\u00e9 de tomate* , amidon de ma\u00efs , herbes de Provence*), mozzarella* 16% marin\u00e9e \u00e0 l'huile d'olive* et au basilic* 0.05%, emmental r\u00e2p\u00e9* , tomates s\u00e9ch\u00e9es marin\u00e9es* 3.3% (tomates s\u00e9ch\u00e9es* , huile de tournesol* , huile d'olive extra vierge* , vinaigre de vin* , sel, ail* , persil* , basilic*), olives non d\u00e9noyaut\u00e9es*. Huile* infus\u00e9e au piment* et au basilic*. Poids net 5g. *Ingr\u00e9dients issus de l'agriculture biologique Mati\u00e8res premi\u00e8res surgel\u00e9es, produit \u00e0 ne pas congeler. Les informations en gras sont destin\u00e9es aux personnes intol\u00e9rantes ou allergiques Produit \u00e9labor\u00e9 dans un atelier qui utilise : des c\u00e9r\u00e9ales contenant du gluten, des crustac\u00e9s, des mollusques, des oeufs, du poisson, du soja, des graines de s\u00e9sames, des fruits \u00e0 coque et de la moutarde.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0002000001896", "energy_kj": 586.0, "energy_kj_computed": null, "energy_kcal": 140.0, "fat": 11.0, "saturated_fat": 0.9, "carbohydrates": 7.2, "sugars": 6.4, "starch": null, "sodium": 0.24, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0002000002046", "energy_kj": 1130.0, "energy_kj_computed": null, "energy_kcal": 270.0, "fat": 5.2, "saturated_fat": 0.6, "carbohydrates": 43.0, "sugars": 4.7, "starch": null, "sodium": 0.48, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0002000002299", "energy_kj": 766.0, "energy_kj_computed": null, "energy_kcal": 183.0, "fat": 1.0, "saturated_fat": 0.5, "carbohydrates": 37.0, "sugars": 3.5, "starch": null, "sodium": 0.4, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0002000002336", "energy_kj": 356.0, "energy_kj_computed": null, "energy_kcal": 85.0, "fat": 2.8, "saturated_fat": 2.1, "carbohydrates": 10.0, "sugars": 8.0, "starch": null, "sodium": 0.04, "ingredients_text": "brebis vanille ou allergiques entre OOC et +6'C \u2022.N0ir sur l'opercule du pot \u00eatre vendus s\u00e9par\u00e9ment, m\u00e9tal Lo' plastique: \u00e0 rec cier localement > www.consignesdetn.fr 250 g valable uniquement pour la France", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0002000002466", "energy_kj": 904.0, "energy_kj_computed": null, "energy_kcal": 216.0, "fat": 2.9, "saturated_fat": 0.7, "carbohydrates": 44.0, "sugars": 0.7, "starch": null, "sodium": 0.38, "ingredients_text": "eau, amidon de ma\u00efs* , farine de riz complet* , farine de millet* , farine de sarrasin* 3,3%, amidon de manioc* , levure de boulanger, prot\u00e9ines de tournesol* , huile d'olive* , sel, psyllium*, \u00e9paississants : gomme de guar* et de xanthane, sucre de canne*", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0002000002473", "energy_kj": 1477.0, "energy_kj_computed": null, "energy_kcal": 353.0, "fat": 2.9, "saturated_fat": 1.0, "carbohydrates": 74.0, "sugars": 1.0, "starch": null, "sodium": 0.36, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0002000002510", "energy_kj": 2008.0, "energy_kj_computed": null, "energy_kcal": 480.0, "fat": 23.8, "saturated_fat": 1.9, "carbohydrates": 55.7, "sugars": 0.5, "starch": null, "sodium": 0.52, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0002000002527", "energy_kj": null, "energy_kj_computed": null, "energy_kcal": null, "fat": null, "saturated_fat": null, "carbohydrates": null, "sugars": null, "starch": null, "sodium": null, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0002000002688", "energy_kj": 1331.0, "energy_kj_computed": null, "energy_kcal": 318.0, "fat": 0.76, "saturated_fat": 0.1, "carbohydrates": 77.8, "sugars": 69.6, "starch": null, "sodium": 0.0024, "ingredients_text": "Gel\u00e9e Royale 8% Ingr\u00e9dients issus de l'agriculture biologique", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0002000003012", "energy_kj": 883.0, "energy_kj_computed": null, "energy_kcal": 211.0, "fat": 11.0, "saturated_fat": 1.3, "carbohydrates": 22.0, "sugars": 3.1, "starch": null, "sodium": 0.2, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0002000003173", "energy_kj": 1925.0, "energy_kj_computed": null, "energy_kcal": 460.0, "fat": 16.0, "saturated_fat": 1.3, "carbohydrates": 73.0, "sugars": 18.0, "starch": null, "sodium": 0.156, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0002000003197", "energy_kj": 1021.0, "energy_kj_computed": null, "energy_kcal": 244.0, "fat": 20.0, "saturated_fat": 10.0, "carbohydrates": 0.0, "sugars": 0.0, "starch": null, "sodium": 0.94, "ingredients_text": "Chaudin de porc, sel, poivre, conservateur : E250, colorant : caramel ordinaire, fumage au bois de h\u00eatre. Enveloppe: boyau naturel. Abats de porc origine France et UE", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0002000003395", "energy_kj": 1674.0, "energy_kj_computed": null, "energy_kcal": 400.0, "fat": null, "saturated_fat": 1.8, "carbohydrates": null, "sugars": 5.5, "starch": null, "sodium": 0.96, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0002000003555", "energy_kj": 192.0, "energy_kj_computed": null, "energy_kcal": 46.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 9.7, "sugars": 9.7, "starch": null, "sodium": 0.0, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0002000003913", "energy_kj": null, "energy_kj_computed": null, "energy_kcal": null, "fat": null, "saturated_fat": null, "carbohydrates": null, "sugars": null, "starch": null, "sodium": null, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0002000004316", "energy_kj": 2356.0, "energy_kj_computed": null, "energy_kcal": 563.0, "fat": 35.0, "saturated_fat": 17.0, "carbohydrates": 50.0, "sugars": 49.0, "starch": null, "sodium": 0.056, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0002000005078", "energy_kj": 1038.0, "energy_kj_computed": null, "energy_kcal": 248.0, "fat": 0.3, "saturated_fat": 0.05, "carbohydrates": 60.0, "sugars": 59.0, "starch": null, "sodium": 0.02, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0002000005641", "energy_kj": null, "energy_kj_computed": null, "energy_kcal": null, "fat": null, "saturated_fat": null, "carbohydrates": null, "sugars": null, "starch": null, "sodium": null, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0002000005801", "energy_kj": 146.0, "energy_kj_computed": null, "energy_kcal": 35.0, "fat": 0.5, "saturated_fat": 0.5, "carbohydrates": 8.3, "sugars": 5.0, "starch": null, "sodium": 0.032, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0002000005924", "energy_kj": 2046.0, "energy_kj_computed": null, "energy_kcal": 489.0, "fat": 22.0, "saturated_fat": 12.0, "carbohydrates": 63.0, "sugars": 27.0, "starch": null, "sodium": 0.24, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0002000006266", "energy_kj": 644.0, "energy_kj_computed": null, "energy_kcal": 154.0, "fat": 6.37, "saturated_fat": 0.69, "carbohydrates": 10.1, "sugars": 1.27, "starch": null, "sodium": 0.372, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0002000008390", "energy_kj": 1360.0, "energy_kj_computed": null, "energy_kcal": 325.0, "fat": 4.0, "saturated_fat": 1.1, "carbohydrates": 50.5, "sugars": 1.5, "starch": null, "sodium": 1.72, "ingredients_text": "Farine de _bl\u00e9_, _morue_, pommes de terre, oeufs entiers, poudres \u00e0 lever : bicarbonate de soude, pyrophosphate acide de sodium; ail, piment, sel, persil. Traces possibles de : _lait_, _soja_, _c\u00e9leri_, _crustac\u00e9s_, _mollusques_, _fruits \u00e0 coques_, _lupin_, _sulfites_, et leurs d\u00e9riv\u00e9s.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0002000008536", "energy_kj": 1527.0, "energy_kj_computed": null, "energy_kcal": 365.0, "fat": 13.0, "saturated_fat": 8.0, "carbohydrates": 55.0, "sugars": 25.0, "starch": null, "sodium": 0.148, "ingredients_text": "Farine de _bl\u00e9_ (_gluten_), raisins secs 13 %, sucre, _beurre_ (_lait_), \u00e9corces d'oranges confites 9 % (\u00e9corces d'oranges, sirop de glucose-fructose, sucre), levain naturel (farine de _bl\u00e9_ (_gluten_), eau), jaune d\u2019_\u0153ufs_ frais, \u00e9mulsifiants: mono - et diglyc\u00e9rides d'acides gras, sirop de glucose, sel, prot\u00e9ines de _lait_, ar\u00f4mes, _lai_t \u00e9cr\u00e9m\u00e9 en poudre.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0002000008895", "energy_kj": 134.0, "energy_kj_computed": null, "energy_kcal": 32.0, "fat": 0.1, "saturated_fat": 0.04, "carbohydrates": 5.9, "sugars": 1.0, "starch": null, "sodium": 0.004, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0002000009335", "energy_kj": 703.0, "energy_kj_computed": null, "energy_kcal": 168.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 68.1, "sugars": 0.0, "starch": null, "sodium": null, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0002000010775", "energy_kj": 1033.0, "energy_kj_computed": null, "energy_kcal": 247.0, "fat": 12.0, "saturated_fat": 1.3, "carbohydrates": 16.0, "sugars": 2.4, "starch": null, "sodium": 0.52, "ingredients_text": "Prot\u00e9ines de soja et de bl\u00e9 r\u00e9hydrat\u00e9es, Eau, Chapelure (farine de bl\u00e9, eau, huile de colza, levure, sel \u00e9pices (pa rika curcuma)) ; Huiles v\u00e9g\u00e9tales (tournesol colza), BIPanc d'\u0153uf* en poudre, Amidon de ma\u00efs, Fi6res d'agrumes, Extrait de levure, Farine de bl\u00e9, Epices (oignon en poudre, paprika, piment rouge, ail deshydrat\u00e9 cumin, origan) ; Concentr\u00e9 de tomates, Vinaigre, Sel, Ail, Jaune d'\u0153uf*, Sel iod\u00e9, Moutarde, Sucre, (*Poules \u00e9lev\u00e9es au sol,) Peut contenir : s\u00e9same, c\u00e9leri,", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0002000012151", "energy_kj": 2958.0, "energy_kj_computed": null, "energy_kcal": 707.0, "fat": 8.2, "saturated_fat": 1.2, "carbohydrates": 0.6, "sugars": 0.5, "starch": null, "sodium": 1.16, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0002000012267", "energy_kj": 452.0, "energy_kj_computed": null, "energy_kcal": 108.0, "fat": 1.9, "saturated_fat": 0.5, "carbohydrates": 18.0, "sugars": 14.0, "starch": null, "sodium": 10.04, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0002000012557", "energy_kj": 1619.0, "energy_kj_computed": null, "energy_kcal": 387.0, "fat": 24.0, "saturated_fat": 7.4, "carbohydrates": 15.0, "sugars": 4.8, "starch": null, "sodium": 0.84, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0002000012847", "energy_kj": 1351.0, "energy_kj_computed": null, "energy_kcal": 323.0, "fat": 10.8, "saturated_fat": 5.8, "carbohydrates": 48.6, "sugars": 8.0, "starch": null, "sodium": 0.04, "ingredients_text": "flocons d'avoine* , sucre de coco* 8% huile de coco* 7%, miel* 6%, noix de coco* 3%, noix de cajou* 3%, noisettes* 2%, graines de pavot* 1 % sel, poudre de vanille*. * Ingr\u00e9dients issus de l'agriculture biologique", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0002000013042", "energy_kj": 322.0, "energy_kj_computed": null, "energy_kcal": 77.0, "fat": 12.0, "saturated_fat": 2.2, "carbohydrates": 34.0, "sugars": 21.0, "starch": null, "sodium": 0.52, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0002000013363", "energy_kj": 2121.0, "energy_kj_computed": null, "energy_kcal": 507.0, "fat": 24.0, "saturated_fat": 16.7, "carbohydrates": 66.0, "sugars": 22.4, "starch": null, "sodium": 0.08, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0002000014391", "energy_kj": 410.0, "energy_kj_computed": null, "energy_kcal": 98.0, "fat": 6.6, "saturated_fat": 4.9, "carbohydrates": 4.4, "sugars": 3.4, "starch": null, "sodium": 0.052, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0002000015886", "energy_kj": 234.0, "energy_kj_computed": null, "energy_kcal": 56.0, "fat": 1.3, "saturated_fat": 0.8, "carbohydrates": 6.4, "sugars": 6.4, "starch": null, "sodium": 0.072, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0002000018306", "energy_kj": 2213.0, "energy_kj_computed": null, "energy_kcal": 529.0, "fat": 29.0, "saturated_fat": 17.0, "carbohydrates": 59.0, "sugars": 32.0, "starch": null, "sodium": 0.172, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0002000019655", "energy_kj": 1598.0, "energy_kj_computed": null, "energy_kcal": 382.0, "fat": 8.1, "saturated_fat": 1.2, "carbohydrates": 60.0, "sugars": 9.3, "starch": null, "sodium": 0.04, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0002042861915", "energy_kj": 1533.0, "energy_kj_computed": 1533.0, "energy_kcal": null, "fat": 1.0, "saturated_fat": null, "carbohydrates": 2.5, "sugars": null, "starch": null, "sodium": null, "ingredients_text": "Proteinmischung (_Sojaprotein_, _Weizenprotein_, _Molkenprotein_, _Wheyprotein_), _Milchprotein_, _H\u00fchnereiweiss_, Kakaopulver (nur Sorte Schoko), Aroma, Pflanzen\u00f6l, S\u00fc\u00dfungsmittel Natriumsaccharin und Acesulfam-K.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "de", "lang": "de", "language_code": "de"} +{"product_id": "0002069000045", "energy_kj": 983.0, "energy_kj_computed": null, "energy_kcal": 235.0, "fat": 11.76, "saturated_fat": 5.88, "carbohydrates": 23.53, "sugars": null, "starch": null, "sodium": 0.119888, "ingredients_text": "Seasoned flour (wheat flour wheat starch baking powder [sodium bicarbonate, glucond, deltalactone, calcium, phosphate, sodium acid pyrophosphate], salt, pepper), shrimp,water, soybean oil, salt, and sugar.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0002122666621", "energy_kj": 1110.0, "energy_kj_computed": null, "energy_kcal": 266.0, "fat": 15.5, "saturated_fat": null, "carbohydrates": 66.5, "sugars": null, "starch": null, "sodium": null, "ingredients_text": "SUGAR, ALMONDS (30%), GLUCOSE SYRUP, HONEY, EGG WHITE, WAFERS (POTATO STARCH, WATER, VEGETABLE OIL), CORN STARCH, FLAVOURINGS.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0002124810206", "energy_kj": 0.0, "energy_kj_computed": null, "energy_kcal": 0.0, "fat": 0.0, "saturated_fat": null, "carbohydrates": 0.0, "sugars": null, "starch": null, "sodium": 41.667, "ingredients_text": "MEDITERRANEAN SEA SALT.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0002150018386", "energy_kj": null, "energy_kj_computed": null, "energy_kcal": null, "fat": null, "saturated_fat": null, "carbohydrates": null, "sugars": null, "starch": null, "sodium": null, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0002169806608", "energy_kj": 837.0, "energy_kj_computed": null, "energy_kcal": 200.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 50.0, "sugars": 25.0, "starch": null, "sodium": 7.75, "ingredients_text": "BROWN RICE FLOUR, CHILI POWDER, SEA SALT, PAPRIKA, EVAPORATED CANE JUICE, GRANULATED ONION, GRANULATED GARLIC, GROUND CUMIN, AND OREGANO.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0002200001221", "energy_kj": null, "energy_kj_computed": null, "energy_kcal": null, "fat": null, "saturated_fat": null, "carbohydrates": null, "sugars": null, "starch": null, "sodium": null, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0002580000005", "energy_kj": null, "energy_kj_computed": null, "energy_kcal": null, "fat": null, "saturated_fat": null, "carbohydrates": null, "sugars": null, "starch": null, "sodium": null, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0002652009530", "energy_kj": 2389.0, "energy_kj_computed": null, "energy_kcal": 571.0, "fat": 32.14, "saturated_fat": 25.0, "carbohydrates": 60.71, "sugars": 39.29, "starch": null, "sodium": 0.072136, "ingredients_text": "Palm and coconut fat, wheat flour, dextrose, sugar, chocolate (sugar, cocoa liquor, cocoa butter, soya lecithin (emulsifier)), lactose (milk), cocoa powder, sweet lupin flour, wheat starch, barley malt extract, salt, egg, soya lecithin (emulsifier), natur", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0002806600002", "energy_kj": null, "energy_kj_computed": null, "energy_kcal": null, "fat": null, "saturated_fat": null, "carbohydrates": null, "sugars": null, "starch": null, "sodium": null, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0002859037565", "energy_kj": 2620.0, "energy_kj_computed": null, "energy_kcal": 625.0, "fat": 50.0, "saturated_fat": 25.0, "carbohydrates": 156.0, "sugars": 125.0, "starch": null, "sodium": 0.125, "ingredients_text": "SUGAR, WHEAT STARCH, WHOLE SOYA FLOUR, GLUCOSE SYRUP, COCOA BUTTER, PALM FAT, CARAMEL SUGAR SYRUP, WHOLE MILK POWDER, LACTOSE, COCOA MASS, DEXTROSE, PEANUTS, HAZELNUTS, GLUCOSE-FRUCTOSE SYRUP, SUNFLOWER LECITHIN, INVERTASE, SOYA BEAN OIL, RICE FLOUR, ARTI", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0002859038722", "energy_kj": 1670.0, "energy_kj_computed": null, "energy_kcal": 400.0, "fat": 119.0, "saturated_fat": 100.0, "carbohydrates": 100.0, "sugars": 50.0, "starch": null, "sodium": 0.188, "ingredients_text": "PALM OIL, SUGAR, LOW FAT COCOA, WHEY POWDER, COCOA POWDER, SOY LECITHIN, VANILLA EXTRACT.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0002859038746", "energy_kj": 2615.0, "energy_kj_computed": null, "energy_kcal": 625.0, "fat": 50.0, "saturated_fat": 37.5, "carbohydrates": 40.0, "sugars": 35.0, "starch": null, "sodium": 0.0762, "ingredients_text": "Palm oil, sugar, low fat cocoa, whey powder, cocoa powder, hazelnut flavor, soy lecithin, vanilla extract.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0002859038760", "energy_kj": 2510.0, "energy_kj_computed": null, "energy_kcal": 600.0, "fat": 47.5, "saturated_fat": 37.5, "carbohydrates": 40.0, "sugars": 27.5, "starch": null, "sodium": 0.0762, "ingredients_text": "Palm oil, sugar, low fat cocoa, whey powder, cocoa powder, natural flavor, coffee and other natural flavors, soy lecithin, vanilla extract.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0002859063557", "energy_kj": 2620.0, "energy_kj_computed": null, "energy_kcal": 625.0, "fat": 50.0, "saturated_fat": 25.0, "carbohydrates": 156.0, "sugars": 125.0, "starch": null, "sodium": 0.125, "ingredients_text": "SUGAR, WHEAT STARCH, WHOLE SOYA FLOUR, GLUCOSE SYRUP, COCOA BUTTER, PALM FAT, CARAMEL SUGAR SYRUP, WHOLE MILK POWDER, LACTOSE, COCOA MASS DEXTROSE, PEANUTS, HAZELNUTS, GLUCOSE-FRUCTOSE SYRUP, SUNFLOWER LECITHIN, INVERTASE, SOYA BEAN OIL, RICE FLOUR, ARTIF", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0002859067142", "energy_kj": 6860.0, "energy_kj_computed": null, "energy_kcal": 1640.0, "fat": 275.0, "saturated_fat": 160.0, "carbohydrates": 410.0, "sugars": 390.0, "starch": null, "sodium": 0.6, "ingredients_text": "SUGAR, PARTLY HYDROGENATED VEGETABLE FATS (PALM, SHEA, RAPESEED, SOY, SUNFLOWER, COCONUT; IN VARYING PROPORTIONS), COCOA MASS, WHOLE MILK POWDER, COCOA BUTTER, SKIMMED MILK POWDER, FAT REDUCED COCOA POWDER, WHEY POWDER (FROM MILK), MILK FAT, EMULSIFIERS (", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0002983542515", "energy_kj": 1590.0, "energy_kj_computed": 1541.7, "energy_kcal": null, "fat": 0.5, "saturated_fat": null, "carbohydrates": 1.1, "sugars": null, "starch": null, "sodium": null, "ingredients_text": "100% Soja-Protein-Isolat (_Soja_)", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "de", "lang": "de", "language_code": "de"} +{"product_id": "0003004032145", "energy_kj": 1674.0, "energy_kj_computed": null, "energy_kcal": 400.0, "fat": 36.0, "saturated_fat": 36.0, "carbohydrates": 18.0, "sugars": 18.0, "starch": null, "sodium": 1.2, "ingredients_text": "Farine de BL\u00c9 , garniture p\u00e2tissi\u00e8re 25 % ( eau, sucre , \u0152UFS entier , amidon modifi\u00e9 de pomme de terre amidon de ma\u00efs, poudre de LAIT entier, graisse de palme. poudre de LACTOS\u00c9RUM correcteurs d'acidit\u00e9 (E263, E450), \u00e9mulsifiants (E471, E472b, E472e), ar\u00f4mes sel, sirop de glucose \u00e9paississant (E415)), jus de betterave rouge d\u00e9shydrat\u00e9, extrait de carotte, gla\u00e7age ( sucre, eau, sirop de glucose, \u00e9mulsifiant (E471), acidifiant (E330), \u0152UF entier sucre, eau, levure huile et mati\u00e8res grasses v\u00e9g\u00e9tales (palme), BEURRE, poudre de CR\u00c8ME, poudre de CR\u00c8ME. poudre de LAIT \u00e9cr\u00e9m\u00e9. poudre de LACTOS\u00c9RUM. sel iode, \u00e9mulsifiants (E322, E471, E481), correcteurs d'acidit\u00e9 E170, E341) acidifiant (E330), ar\u00f4me.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0003006010349", "energy_kj": 1670.0, "energy_kj_computed": null, "energy_kcal": 400.0, "fat": 68.0, "saturated_fat": 48.0, "carbohydrates": 100.0, "sugars": 96.0, "starch": null, "sodium": 0.122, "ingredients_text": "SUGAR, WHOLE MILK POWDER, COCOA BUTTER, COCOA MASS, EMULSIFIER: SOY LECITHIN, BOURBON VANILLA EXTRACT.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0003006012749", "energy_kj": 2259.0, "energy_kj_computed": null, "energy_kcal": 540.0, "fat": 34.0, "saturated_fat": 24.0, "carbohydrates": 50.0, "sugars": 48.0, "starch": null, "sodium": 0.06, "ingredients_text": "Sugar, whole milk powder,cocoa butter, cocoa liquor, emulsifier: soy lecithin, bourbon vanilla extract.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0003006013180", "energy_kj": 2259.0, "energy_kj_computed": null, "energy_kcal": 540.0, "fat": 34.0, "saturated_fat": 24.0, "carbohydrates": 50.0, "sugars": 48.0, "starch": null, "sodium": 0.06, "ingredients_text": "Sugar, whole milk powder, cocoa butter, cocoa mass, emulsifier: soy lecithin, bourbon vanilla extract.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0003006013371", "energy_kj": 2090.0, "energy_kj_computed": null, "energy_kcal": 500.0, "fat": 93.8, "saturated_fat": 62.5, "carbohydrates": 125.0, "sugars": 119.0, "starch": null, "sodium": 0.155, "ingredients_text": "SUGAR, FULL CREAM MILK POWDER, COCOA BUTTER, COCOA MASS, EMULSIFIER LECITHIN (SOY), BOURBON VANILLA EXTRACT.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0003026400168", "energy_kj": 1021.0, "energy_kj_computed": null, "energy_kcal": 244.0, "fat": 4.44, "saturated_fat": 0.0, "carbohydrates": 53.33, "sugars": 6.67, "starch": null, "sodium": 0.078, "ingredients_text": "Organic sweet brown rice, filtered water, dates, cashews, cinnamon, natural vanilla flavor, and sea salt.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0003160279507", "energy_kj": 1120.0, "energy_kj_computed": null, "energy_kcal": 266.0, "fat": 7.3, "saturated_fat": 5.0, "carbohydrates": 66.6, "sugars": 41.8, "starch": null, "sodium": null, "ingredients_text": "GLUCOSE FRUCTOSE SYRUP, WHEAT FLOUR, SUGAR, APRICOTS DRIED PASSED, COCOA BUTTER, WHEY POWDER, COCOA MASS, SKIMMED MILK POWDER, CARAMEL SUGAR SYRUP, RAISING AGENTS: DISODIUM DIPHOSPHATE, SODIUM HYDROGEN CARBONATE, POTASSIUM CARBONATE; PURE BUTTERFAT, LACTO", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0003160441904", "energy_kj": 1260.0, "energy_kj_computed": null, "energy_kcal": 301.0, "fat": 4.6, "saturated_fat": null, "carbohydrates": 75.3, "sugars": null, "starch": null, "sodium": null, "ingredients_text": "WHEAT FLOUR, SUGAR, GLUCOSE FRUCTOSE SYRUP, COCOA MASS, COCOA BUTTER, SPICES RAISING AGENTS; DISODIUM DIPHOSPHATE, SODIUM HYDROGEN CARBONATE, POTASSIUM CARBONATE; CARAMEL SUGAR SYRUP, POTATO STARCH, BUTTERFAT, EDIBLE GELATINE, EMULSIFIER; SOYA LECITHINS.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0003383900585", "energy_kj": 2850.0, "energy_kj_computed": null, "energy_kcal": 682.0, "fat": 0.0, "saturated_fat": null, "carbohydrates": 170.0, "sugars": 88.2, "starch": null, "sodium": 0.0597, "ingredients_text": "APRICOTS, SULFUR DIOXIDE AS A PRESERVATIVE TO PROMOTE COLOR RETENTION", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0003413052826", "energy_kj": 799.0, "energy_kj_computed": null, "energy_kcal": 191.0, "fat": 0.7, "saturated_fat": 0.2, "carbohydrates": 40.3, "sugars": 3.7, "starch": null, "sodium": 0.48, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0003535048370", "energy_kj": 2364.0, "energy_kj_computed": null, "energy_kcal": 565.0, "fat": 37.7, "saturated_fat": 24.9, "carbohydrates": 48.1, "sugars": 47.1, "starch": null, "sodium": null, "ingredients_text": "Sugar, vegetable fats (palm kernel, coconut, palm), whole milk powder, chocolate powder (13%) (sugar cocoa), cocoa butter, cocoa mass, skimmed milk powder, whey powder, hazelnuts, emulsifier: soya lecithin, flavor.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0003535048455", "energy_kj": 2389.0, "energy_kj_computed": null, "energy_kcal": 571.0, "fat": 37.3, "saturated_fat": 25.2, "carbohydrates": 53.6, "sugars": 53.1, "starch": null, "sodium": null, "ingredients_text": "Milk chocolate praline (cocoa solids: 30% minimum) with yogurt-flavoured mousses filling. ingredients: sugar, vegetable fats (palm kernel, coconut, palm), whole milk powder, cocoa butter, cocoa mass, whey powder, skimmed milk powder, emulsifier: soya leci", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0003586000303", "energy_kj": 2247.0, "energy_kj_computed": null, "energy_kcal": 537.0, "fat": 36.67, "saturated_fat": 3.33, "carbohydrates": 46.67, "sugars": 1.67, "starch": null, "sodium": 0.677672, "ingredients_text": "Potatoes, sunflower oil, salt, flavor, wheat flour, yeast extract, paprika, chili powder, onion powder, sugar, soy protein hydrolyzate, coloring: beetroot and red pepper extract, garlic powder, citric acid and lactic acid, smoke flavor.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0004200001805", "energy_kj": null, "energy_kj_computed": null, "energy_kcal": null, "fat": null, "saturated_fat": null, "carbohydrates": null, "sugars": null, "starch": null, "sodium": null, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0004272000089", "energy_kj": null, "energy_kj_computed": null, "energy_kcal": null, "fat": null, "saturated_fat": null, "carbohydrates": null, "sugars": null, "starch": null, "sodium": null, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0004590111412", "energy_kj": 11100.0, "energy_kj_computed": null, "energy_kcal": 2650.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 663.0, "sugars": 561.0, "starch": null, "sodium": 0.0, "ingredients_text": "SUGAR, GLUCOSE SYRUP, PGI RED ORANGE JUICE OF SICILY, CITRIC ACID, NATURAL FLAVOR OF PGI RED ORANGE OF SICILY.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0004835501510", "energy_kj": 6180.0, "energy_kj_computed": null, "energy_kcal": 1480.0, "fat": 55.6, "saturated_fat": 5.57, "carbohydrates": 200.0, "sugars": 156.0, "starch": null, "sodium": 0.000657, "ingredients_text": "SUGAR, ALMONDS 20%, APRICOT KERNEL, ALBUMEN, RICE FLOUR, WHEAT FLOUR, EGG YOLK, EMULSIFIER: MONO-AND DIGLYCERIDES OF FATTY ACIDS, EGGS, PASTEURIZED WHOLE MILK, FLAVOURS, SALT, BUTTER, HONEY, RAISING AGENT (SODIUM CARBONATES, DIPHOSPHATES, AMMONIUM CARBONA", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0005173877367", "energy_kj": null, "energy_kj_computed": null, "energy_kcal": null, "fat": null, "saturated_fat": null, "carbohydrates": null, "sugars": null, "starch": null, "sodium": null, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0005216437657", "energy_kj": 1162.0, "energy_kj_computed": null, "energy_kcal": 277.77777777778, "fat": 11.111111111111, "saturated_fat": 0.0, "carbohydrates": 44.444444444444, "sugars": 44.444444444444, "starch": null, "sodium": 8.1111111111112, "ingredients_text": "Salt, sugar, monosodium glutamate, anistar.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0005216437664", "energy_kj": 1163.0, "energy_kj_computed": null, "energy_kcal": 278.0, "fat": 5.5600000000000005, "saturated_fat": null, "carbohydrates": 48.89, "sugars": 48.89, "starch": null, "sodium": 8.111, "ingredients_text": "Salt, sugar, monosodium glutamate, anistar.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0005216437688", "energy_kj": 1163.0, "energy_kj_computed": null, "energy_kcal": 278.0, "fat": 5.5600000000000005, "saturated_fat": null, "carbohydrates": 48.89, "sugars": 48.89, "starch": null, "sodium": 8.111, "ingredients_text": "Salt, sugar, monosodium glutamate, and spices", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0005216437695", "energy_kj": 1163.0, "energy_kj_computed": null, "energy_kcal": 278.0, "fat": 5.5600000000000005, "saturated_fat": null, "carbohydrates": 48.89, "sugars": 48.89, "starch": null, "sodium": 8.111, "ingredients_text": "Salt, sugar, monosodium glutamate, anistar.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0005216437701", "energy_kj": 12900.0, "energy_kj_computed": null, "energy_kcal": 3070.0, "fat": 61.8, "saturated_fat": null, "carbohydrates": 543.0, "sugars": 543.0, "starch": null, "sodium": 0.0901, "ingredients_text": "SALT, SUGAR, MONOSODIUM GLUTAMATE AND SPICES", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0005216437732", "energy_kj": 1163.0, "energy_kj_computed": null, "energy_kcal": 278.0, "fat": 5.5600000000000005, "saturated_fat": null, "carbohydrates": 48.89, "sugars": 48.89, "starch": null, "sodium": 8.111, "ingredients_text": "Salt, sugar, monosodium glutamate, anistar", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0005216437763", "energy_kj": 12900.0, "energy_kj_computed": null, "energy_kcal": 3070.0, "fat": 61.8, "saturated_fat": null, "carbohydrates": 543.0, "sugars": 543.0, "starch": null, "sodium": 0.0901, "ingredients_text": "SALT, SUGAR, MONOSODIUM GLUTAMATE, ANISTAR.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0005216438500", "energy_kj": 1163.0, "energy_kj_computed": null, "energy_kcal": 278.0, "fat": 5.5600000000000005, "saturated_fat": null, "carbohydrates": 48.89, "sugars": 48.89, "starch": null, "sodium": 8.111, "ingredients_text": "Salt, sugar, monosodium glutamate and spices.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0005216438517", "energy_kj": 1163.0, "energy_kj_computed": null, "energy_kcal": 278.0, "fat": 5.5600000000000005, "saturated_fat": null, "carbohydrates": 48.89, "sugars": 48.89, "starch": null, "sodium": 8.111, "ingredients_text": "Salt, sugar, monosodium glutamate and spices.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0005216438524", "energy_kj": 1163.0, "energy_kj_computed": null, "energy_kcal": 278.0, "fat": 5.5600000000000005, "saturated_fat": null, "carbohydrates": 48.89, "sugars": 48.89, "starch": null, "sodium": 8.111, "ingredients_text": "Salt, sugar, monosodium glutamate and spices", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0005216438548", "energy_kj": 12900.0, "energy_kj_computed": null, "energy_kcal": 3070.0, "fat": 61.8, "saturated_fat": null, "carbohydrates": 543.0, "sugars": 543.0, "starch": null, "sodium": 0.0901, "ingredients_text": "SALT, SUGAR, MONOSODIUM GLUTAMATE AND SPICES.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0005216438555", "energy_kj": 1163.0, "energy_kj_computed": null, "energy_kcal": 278.0, "fat": 5.5600000000000005, "saturated_fat": null, "carbohydrates": 48.89, "sugars": 48.89, "starch": null, "sodium": 8.111, "ingredients_text": "Salt, sugar, monosodium glutamate and spices.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0005216438579", "energy_kj": 1163.0, "energy_kj_computed": null, "energy_kcal": 278.0, "fat": 5.5600000000000005, "saturated_fat": null, "carbohydrates": 48.89, "sugars": 48.89, "starch": null, "sodium": 8.111, "ingredients_text": "Salt,sugar,monosodium glutamate, and spices", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0005216438623", "energy_kj": 1163.0, "energy_kj_computed": null, "energy_kcal": 278.0, "fat": 5.5600000000000005, "saturated_fat": null, "carbohydrates": 48.89, "sugars": 48.89, "starch": null, "sodium": 8.111, "ingredients_text": "Salt, sugar, monosodium glutamate, and spices.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0005216438647", "energy_kj": 1163.0, "energy_kj_computed": null, "energy_kcal": 278.0, "fat": 5.5600000000000005, "saturated_fat": null, "carbohydrates": 48.89, "sugars": 48.89, "starch": null, "sodium": 8.111, "ingredients_text": "Salt, sugar, monosodium glutamate and spices.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0005329003107", "energy_kj": null, "energy_kj_computed": null, "energy_kcal": null, "fat": null, "saturated_fat": null, "carbohydrates": null, "sugars": null, "starch": null, "sodium": null, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "es", "lang": "es", "language_code": "es"} +{"product_id": "0005404490105", "energy_kj": 26900.0, "energy_kj_computed": null, "energy_kcal": 6430.0, "fat": 714.0, "saturated_fat": null, "carbohydrates": null, "sugars": null, "starch": null, "sodium": null, "ingredients_text": "EXTRA VIRGIN OLIVE OIL", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0005800698280", "energy_kj": null, "energy_kj_computed": null, "energy_kcal": null, "fat": null, "saturated_fat": null, "carbohydrates": null, "sugars": null, "starch": null, "sodium": null, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "de", "lang": "de", "language_code": "de"} +{"product_id": "0006100008441", "energy_kj": null, "energy_kj_computed": null, "energy_kcal": null, "fat": null, "saturated_fat": null, "carbohydrates": null, "sugars": null, "starch": null, "sodium": null, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "de", "lang": "de", "language_code": "de"} +{"product_id": "0006167023135", "energy_kj": 2201.0, "energy_kj_computed": null, "energy_kcal": 526.0, "fat": 28.95, "saturated_fat": 5.26, "carbohydrates": 55.26, "sugars": 50.0, "starch": null, "sodium": 0.053, "ingredients_text": "Cashewnuts 45%, sesame 10%, pistachios 5%, sugar, glucose syrup, aromalemon 0,5%.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0006345049070", "energy_kj": 761.0, "energy_kj_computed": null, "energy_kcal": 182.0, "fat": 8.2, "saturated_fat": 2.9, "carbohydrates": 0.1, "sugars": 0.05, "starch": null, "sodium": 0.6, "ingredients_text": "jarret de porc avec os, eau, conservateur:E250, dextrose, bouillon : extrait de carotte, extrait de CELERI rave, extrait e poireau, d'\u00e9pices , saccharose, antioxydant.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0006423460193", "energy_kj": 2247.0, "energy_kj_computed": null, "energy_kcal": 537.0, "fat": 31.71, "saturated_fat": 21.95, "carbohydrates": 58.54, "sugars": 56.1, "starch": null, "sodium": 0.073, "ingredients_text": "Sugar, vegetable oil (coconut (tree nut), palm kernel, palm cocoa butter, whole milk powder, cocoa mass, whey powder, lowfat cocoa powder, cereals (corn flour, rice flour, wheat flour, sugar, lowfat cocoa powder, barley's malt extract, sal-t), skim milk powder, hazelnuts (tree nut), soy lecithin (emulsifier), artificial flavourings.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0006423461077", "energy_kj": 2201.0, "energy_kj_computed": null, "energy_kcal": 526.0, "fat": 28.95, "saturated_fat": 18.42, "carbohydrates": 63.16, "sugars": 57.89, "starch": null, "sodium": 0.053, "ingredients_text": "Sugar, vegetable fats (coconut (tree nut), palm kernel, palm), cocoa butter, whole milk powder, cocoa mass, low fat cocoa powder, whey powder, cereals (corn flour, rice flour, wheat flour, sugar, low fat cocoa powder, barley's malt extract, salt), hazelnuts, emulsifier: soya lecithin, skimmed milk powder, flavourings.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0006423462951", "energy_kj": 2510.0, "energy_kj_computed": null, "energy_kcal": 600.0, "fat": 81.2, "saturated_fat": 56.2, "carbohydrates": 150.0, "sugars": 144.0, "starch": null, "sodium": 0.22, "ingredients_text": "SUGAR, VEGETABLE OIL (COCONUT (TREE NUT), PALM KERNEL, PALM), COCOA BUTTER, WHOLE MILK POWDER, COCOA MASS, SKIM MILK POWDER, WHEY POWDER, LOWFAT COCOA POWDER, CEREALS (CORN FLOUR, RICE FLOUR, WHEAT FLOUR, SUGAR, LOWFAT COCOA POWDER, BARLEY'S MALT EXTRACT,", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0006446001977", "energy_kj": 2180.0, "energy_kj_computed": null, "energy_kcal": 522.0, "fat": 85.0, "saturated_fat": 51.0, "carbohydrates": 130.0, "sugars": 125.0, "starch": null, "sodium": 0.201, "ingredients_text": "SUGAR, WHOLE MILK POWDER, COCOA BUTTER, CHOCOLATE LIQUOR, VEGETABLE FATS (OIL PALM, COCONUT), LACTOSE, SKIMMED MILK POWDER, EMULSIFIER: SOY LECITHIN, NATURAL VANILLA FLAVOR.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0006446001984", "energy_kj": 1800.0, "energy_kj_computed": null, "energy_kcal": 431.0, "fat": 68.0, "saturated_fat": 45.4, "carbohydrates": 108.0, "sugars": 102.0, "starch": null, "sodium": 0.114, "ingredients_text": "SUGAR, COCOA BUTTER, WHOLE MILK POWDER, CHOCOLATE LIQUOR, VEGETABLE FAT (OIL PALM), SWEET WHEY POWDER, COCOA POWDER (LOW FAT), LACTOSE, EMULSIFIER: SOY LECITHIN, NATURAL VANILLA FLAVOR.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0006446002264", "energy_kj": 2300.0, "energy_kj_computed": null, "energy_kcal": 550.0, "fat": 81.2, "saturated_fat": 56.2, "carbohydrates": 138.0, "sugars": 131.0, "starch": null, "sodium": 0.188, "ingredients_text": "SUGAR, WHOLE MILK POWDER, COCOA BUTTER, VEGETABLE FATS (OIL PALM, COCONUT), CHOCOLATE LIQUOR, SKIMMED MILK POWDER, LACTOSE, EMULSIFIER, SOY LECITHIN, NATURAL VANILLA FLAVOR.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0006446002660", "energy_kj": 2420.0, "energy_kj_computed": null, "energy_kcal": 579.0, "fat": 92.1, "saturated_fat": 59.2, "carbohydrates": 145.0, "sugars": 138.0, "starch": null, "sodium": 0.0974, "ingredients_text": "SUGAR, COCOA BUTTER, WHOLE MILK POWDER, VEGETABLE FAT (OIL PALM), CHOCOLATE LIQUOR, SWEET WHEY POWDER, COCOA POWDER (LOW FAT), LACTOSE, EMULSIFIER: SOY LECITHIN, NATURAL VANILLA FLAVOR.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0006446002677", "energy_kj": 2300.0, "energy_kj_computed": null, "energy_kcal": 550.0, "fat": 87.5, "saturated_fat": 56.2, "carbohydrates": 138.0, "sugars": 131.0, "starch": null, "sodium": 0.125, "ingredients_text": "SUGAR, VEGETABLE FATS (OIL PALM), WHOLE MILK POWDER, COCOA BUTTER CHOCOLATE LIQUOR, SWEET WHEY POWDER, COCOA POWDER (LOW FAT), LACTOSE, EMULSIFIER: SOY LECITHIN, NATURAL VANILLA FLAVOR.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0006446003520", "energy_kj": 2200.0, "energy_kj_computed": null, "energy_kcal": 525.0, "fat": 100.0, "saturated_fat": 62.5, "carbohydrates": 131.0, "sugars": 125.0, "starch": null, "sodium": 0.188, "ingredients_text": "SUGAR, WATER, WHOLE MILK POWDER, CHOCOLATE LIQUOR, EMULSIFIER, SOY LECITHIN.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0006446004084", "energy_kj": 2320.0, "energy_kj_computed": null, "energy_kcal": 554.0, "fat": 104.0, "saturated_fat": 62.3, "carbohydrates": 138.0, "sugars": 132.0, "starch": null, "sodium": 0.208, "ingredients_text": "SUGAR, COCOA BUTTER, WHOLE MILK POWDER, CHOCOLATE LIQUOR, EMULSIFIER: SOY LECITHIN.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0006669004953", "energy_kj": 389.0, "energy_kj_computed": null, "energy_kcal": 93.0, "fat": 0.6, "saturated_fat": 0.3, "carbohydrates": 7.6, "sugars": 0.1, "starch": null, "sodium": 0.4, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0006894530005", "energy_kj": 2970.0, "energy_kj_computed": null, "energy_kcal": 710.0, "fat": 77.2, "saturated_fat": 46.3, "carbohydrates": 177.0, "sugars": 100.0, "starch": null, "sodium": 0.347, "ingredients_text": "UNBLEACHED WHEAT FLOUR, SUGAR, VEGETABLE SHORTENINGS (PALM OIL, COCONUT OIL), CHOCOLATE LIQUOR, COCOA BUTTER, NONFAT DRY MILK, WHEY POWDER (FROM MILK), HAZELNUTS, LOW FAT COCOA POWDER (PROCESSED WITH ALKALI), CANDIED ORANGE PEEL (ORANGE PEEL, GLUCOSE FRUC", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0007200000021", "energy_kj": null, "energy_kj_computed": null, "energy_kcal": null, "fat": null, "saturated_fat": null, "carbohydrates": null, "sugars": null, "starch": null, "sodium": null, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0007371000080", "energy_kj": null, "energy_kj_computed": null, "energy_kcal": null, "fat": null, "saturated_fat": null, "carbohydrates": null, "sugars": null, "starch": null, "sodium": null, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0007430039976", "energy_kj": 314.0, "energy_kj_computed": null, "energy_kcal": 75.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 16.67, "sugars": 10.0, "starch": null, "sodium": 0.592, "ingredients_text": "Tomato puree (water, tomato paste, high fructose corn syrup, water, wheat flour, contains 2% or less of the following: salt, ascorbic acid, natural flavor.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0007715997786", "energy_kj": 557.0, "energy_kj_computed": null, "energy_kcal": 133.0, "fat": 22.2, "saturated_fat": 0.0, "carbohydrates": 33.3, "sugars": 33.3, "starch": null, "sodium": 0.333, "ingredients_text": "NONFAT MILK, PARTIALLY HYDROGENATED SOYBEAN OIL, CONTAINS 0.5% OR LESS OF: DIPOTASSIUM PHOSPHATE, CARRAGEENAN, VITAMIN A PALMITATE, VITAMIN D3.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0007781502693", "energy_kj": 1570.0, "energy_kj_computed": null, "energy_kcal": 375.0, "fat": 17.3, "saturated_fat": 7.4, "carbohydrates": 93.8, "sugars": 4.93, "starch": null, "sodium": 1.38, "ingredients_text": "WHOLE WHEAT FLOUR, WATER, SHORTENING (SOYBEAN OIL, HYDROGENATED SOYBEAN OIL), BAKING BLEND (SALT, MONO - AND DIGLYCERIDES, SODIUM BICARBONATE, DEXTROSE, CALCIUM PROPIONATE, SODIUM ALUMINUM PHOSPHATE, SODIUM ALUMINUM SULFATE, FUMARIC ACID, CORN STARCH, YEAS", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0007815002489", "energy_kj": 1140.0, "energy_kj_computed": null, "energy_kcal": 273.0, "fat": 6.82, "saturated_fat": 3.41, "carbohydrates": 45.5, "sugars": null, "starch": null, "sodium": 0.636, "ingredients_text": "FLOUR (WHEAT FLOUR, ENRICHMENT (NIACIN, REDUCED IRON, THIAMINE MONONITRATE, RIBOFLAVIN, FOLIC ACID), ENZYME), WATER, SHORTENING (SOYBEAN OIL, HYDROGENATED SOYBEAN OIL), BAKING BLEND (SALT, MONO AND DIGLYCERIDES, SODIUM BICARBONATE, DEXTROSE, CALCIUM PROPI", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008001000654", "energy_kj": 895.0, "energy_kj_computed": null, "energy_kcal": 214.0, "fat": 21.43, "saturated_fat": 3.57, "carbohydrates": 10.71, "sugars": 0.0, "starch": null, "sodium": 0.446, "ingredients_text": "White beans, hand peeled garlic, fresh lemon juice salt, black pepper, safflower oil", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008001000661", "energy_kj": 895.0, "energy_kj_computed": null, "energy_kcal": 214.0, "fat": 21.43, "saturated_fat": 3.57, "carbohydrates": 10.71, "sugars": 0.0, "starch": null, "sodium": 0.381, "ingredients_text": "Chickpeas, hand peeled garlic, roasted red pepper fresh lemon juice, salt, black pepper, safflower oil", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008001200016", "energy_kj": 1197.0, "energy_kj_computed": null, "energy_kcal": 286.0, "fat": 25.0, "saturated_fat": 3.57, "carbohydrates": 10.71, "sugars": 0.0, "starch": null, "sodium": 0.907288, "ingredients_text": "Chickpeas, hand peeled garlic, buffalo sauce fresh lemon juice, salt, black pepper, safflower oil", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008005125193", "energy_kj": 770.0, "energy_kj_computed": null, "energy_kcal": 184.0, "fat": 3.0, "saturated_fat": 1.5, "carbohydrates": 46.0, "sugars": 1.0, "starch": null, "sodium": 0.15, "ingredients_text": "FILLING: ORGANIC CHEESE BLEND (RICOTTA CHEESE, MOZZARELLA CHEESE, CHEDDAR CHEESE [MILK, VINEGAR, SALT, CHEESE CULTURES, ENZYMES]), ORGANIC BREADCRUMBS (WHEAT FLOUR, EVAPORATED CANE SYRUP, YEAST, SEA SALT), ORGANIC SPINACH, ORGANIC SPINACH POWDER, ORGANIC", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008005158306", "energy_kj": 795.0, "energy_kj_computed": null, "energy_kcal": 190.0, "fat": 2.5, "saturated_fat": 1.0, "carbohydrates": 24.0, "sugars": 1.0, "starch": null, "sodium": 0.13, "ingredients_text": "Filling: organic butternut squash, organic ricotta cheese (milk, vinegar, salt), organic cheddar cheese (pasteurized cow's milk, salt, cheese cultures, enzymes), organic parmesan cheese (cultured milk, powdered cellulose, microbial enzymes), organic breadcrumbs (wheat flour, evaporated cane syrup, yeast, sea salt), organic honey, organic eggs, organic canola oil, sea salt, organic black pepper, organic nutmeg, organic cinnamon, organic annatto oil. pasta: organic durum flour, water, organic eggs, organic turmeric oil.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008005159709", "energy_kj": 602.0, "energy_kj_computed": null, "energy_kcal": 144.0, "fat": 4.0, "saturated_fat": 2.0, "carbohydrates": 36.0, "sugars": 1.0, "starch": null, "sodium": 0.22, "ingredients_text": "FILLING: ORGANIC KALE, ORGANIC WHITE BEANS, ORGANIC RICOTTA CHEESE (MILK, VINEGAR, SALT), ORGANIC CHEDDAR CHEESE (MILK, ENZYMES, SALT), ORGANIC ROMANO CHEESE (MILK, SALT, ENZYMES), ORGANIC ASIAGO CHEESE (PASTEURIZED WHOLE MILK, CULTURE, SALT, ENZYMES), OR", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008005658134", "energy_kj": 457.0, "energy_kj_computed": null, "energy_kcal": 109.0, "fat": 6.82, "saturated_fat": 4.34, "carbohydrates": 27.3, "sugars": 0.622, "starch": null, "sodium": 0.217, "ingredients_text": "FILLING: RICOTTA CHEESE (MILK, WHEY, CREAM, VINEGAR, SALT, NATURAL STABILIZERS [XANTHAN GUM, LOCUST BEAN GUM, GUAR GUM]), PARMESAN CHEESE (CULTURED PASTEURIZED MILK, SALT, ENZYMES), ASIAGO CHEESE (MILK, ENZYMES, SALT), MOZZARELLA CHEESE (CULTURED PASTEURI", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008005914193", "energy_kj": 920.0, "energy_kj_computed": null, "energy_kcal": 220.0, "fat": 6.0, "saturated_fat": 3.0, "carbohydrates": 35.0, "sugars": 1.0, "starch": null, "sodium": 0.2, "ingredients_text": "Filling: water, cheddar cheese (milk, enzymes, salt), spinach, potato flake (potatoes, monoglycerides, sodium acid pyrophosphate, citric acid), blended oil (canola, olive), salt, black pepper. dough: bleached wheat flour, water, potato flour (potatoes, monoglycerides), eggs.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008005914865", "energy_kj": 619.0, "energy_kj_computed": null, "energy_kcal": 148.0, "fat": 7.0, "saturated_fat": 3.0, "carbohydrates": 37.0, "sugars": 1.0, "starch": null, "sodium": 0.26, "ingredients_text": "FILLING: WATER, ONIONS, POTATO FLAKE (POTATOES, MONOGLYCERIDES, SODIUM ACID PYROPHOSPHATE, CITRIC ACID), CHEDDAR CHEESE (MILK, ENZYMES, SALT), BUTTER, BLENDED OIL (CANOLA, OLIVE), SALT, BLACK PEPPER, ONION POWDER, DOUGH: BLEACHED WHEAT FLOUR, WATER, POTAT", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008005959101", "energy_kj": 962.0, "energy_kj_computed": null, "energy_kcal": 230.0, "fat": 7.0, "saturated_fat": 3.5, "carbohydrates": 30.0, "sugars": 1.0, "starch": null, "sodium": 0.36, "ingredients_text": "FILLING: Ricotta cheese (pasteurized milk, whey, vinegar, salt, stabilizers [guar gum, xanthan gum, locust bean gum]), crab & lobster blend (crab meat, lobster meat), glycerin, white wine, breadcrumbs (wheat flour, sugar, yeast, salt), butter (cream, natural flavoring), wheat flour, heavy cream, sea salt, paprika oil, eggs, parsley, sugar, black pepper. PASTA: Wheat flour, water, eggs, tomato paste, paprika oil, annatto oil, beta-carotene (color).", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008006915137", "energy_kj": 313.0, "energy_kj_computed": null, "energy_kcal": 74.8, "fat": 6.45, "saturated_fat": 3.87, "carbohydrates": 18.7, "sugars": 1.29, "starch": null, "sodium": 0.271, "ingredients_text": "FILLING: RICOTTA CHEESE (MILK, WHEY, CREAM, VINEGAR, SALT, NATURAL STABILIZERS [XANTHAN GUM, LOCUST BEAN GUM, GUAR GUM]), ASIAGO CHEESE (PASTEURIZED PART SKIM MILK, CHEESE CULTURE, SALT, ENZYMES), MOZZARELLA CHEESE (PASTEURIZED WHOLE MILK, CULTURE, SALT,", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008006935401", "energy_kj": 686.0, "energy_kj_computed": null, "energy_kcal": 164.0, "fat": 5.0, "saturated_fat": 2.5, "carbohydrates": 41.0, "sugars": 1.0, "starch": null, "sodium": 0.33, "ingredients_text": "FILLING: PUMPKIN, RICOTTA CHEESE (PASTEURIZED WHEY, WHOLE MILK, CREAM, VINEGAR, SALT), CHEDDAR CHEESE (MILK, ENZYMES, SALT), PARMESAN CHEESE (PASTEURIZED MILK, CHEESE CULTURES, SALT, ENZYMES), BREADCRUMBS (WHEAT FLOUR, EVAPORATED CANE SYRUP, YEAST, SEA SA", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008006958011", "energy_kj": 711.0, "energy_kj_computed": null, "energy_kcal": 170.0, "fat": 9.0, "saturated_fat": 5.0, "carbohydrates": 25.0, "sugars": 2.0, "starch": null, "sodium": 0.49, "ingredients_text": "Filling: ricotta cheese (milk. whey, cream, vinegar, salt, natural stabilizers [xanthan gum, locust bean gum, guar gum]), mozzarella cheese (pasteurized whole milk. culture, salt, enzymes), tomatoes, parmesan cheese (milk, salt, enzymes), parmesan flavor (parmesan cheese {milk, culture, salt, enzymes} salt, yeast extract, unsalted butter, corn oil. olive oil, cream powder, sugar and natural flavoring), eggs, basil, parsley, bread crumbs (wheat flour, evaporated cane syrup, yeast. sea salt), salt, black pepper. pasta: durum flour, water, eggs, beta-carotene.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008006958554", "energy_kj": 435.0, "energy_kj_computed": null, "energy_kcal": 104.0, "fat": 10.0, "saturated_fat": 5.0, "carbohydrates": 26.0, "sugars": 1.0, "starch": null, "sodium": 0.68, "ingredients_text": "FILLING: RICOTTA CHEESE (MILK, WHEY, CREAM, VINEGAR, SALT, NATURAL STABILIZERS [XANTHAN GUM, LOCUST BEAN GUM, GUAR GUM]), MOZZARELLA CHEESE (PASTEURIZED WHOLE MILK, CULTURE, SALT, ENZYMES), CHEDDAR CHEESE (PASTEURIZED MILK, CHEESE CULTURES, SALT, ENZYMES)", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008006958936", "energy_kj": 469.0, "energy_kj_computed": null, "energy_kcal": 112.0, "fat": 6.0, "saturated_fat": 3.5, "carbohydrates": 28.0, "sugars": 1.0, "starch": null, "sodium": 0.26, "ingredients_text": "FILLING: SHRIMP, RICOTTA CHEESE (MILK, WHEY, CREAM, VINEGAR, SALT, NATURAL STABILIZERS [XANTHAN GUM, LOCUST BEAN GUM, GUAR GUM]), MOZZARELLA CHEESE (PASTEURIZED WHOLE MILK, CULTURE, SALT, ENZYMES), GLYCERINE, WHITE WINE, BREAD CRUMBS (WHEAT FLOUR, SUGAR,", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008006974011", "energy_kj": 485.0, "energy_kj_computed": null, "energy_kcal": 116.0, "fat": 8.0, "saturated_fat": 4.5, "carbohydrates": 29.0, "sugars": 1.0, "starch": null, "sodium": 0.5, "ingredients_text": "FILLING: RICOTTA CHEESE (MILK, WHEY, CREAM, VINEGAR, SALT, NATURAL STABILIZERS [XANTHAN GUM, LOCUST BEAN GUM, GUAR GUM]), MOZZARELLA CHEESE (PASTEURIZED WHOLE MILK, CULTURES, SALT, ENZYMES), BASIL PARMESAN CHEESE (PASTEURIZED MILK, CHEESE CULTURES, SALT,", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008006996013", "energy_kj": 1130.0, "energy_kj_computed": null, "energy_kcal": 270.0, "fat": 8.0, "saturated_fat": 5.0, "carbohydrates": 34.0, "sugars": 5.0, "starch": null, "sodium": 0.42, "ingredients_text": "Filling: ricotta cheese (milk, whey, cream, vinegar, salt, natural stabilizers [xanthan gum, locust bean gum, guar gum]), cheese powder (dehydrated blend of whey, cheese [granular and cheddar {pasteurized milk, cheese culture, salt, enzymes}], buttermilk solids, whey protein concentrate, salt), mozzarella cheese (pasteurized whole milk, culture, salt, enzymes), eggs, breadcrumbs (wheat flour, evaporated cane syrup, yeast, sea salt), milk, annatto oil. pasta: durum flour, water, eggs, annatto oil.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008009958223", "energy_kj": 879.0, "energy_kj_computed": null, "energy_kcal": 210.0, "fat": 7.0, "saturated_fat": 2.5, "carbohydrates": 31.0, "sugars": 1.0, "starch": null, "sodium": 0.32, "ingredients_text": "Filling: kale, hummus (chickpeas, sunflower oil, olive oil, sesame tahini, water, sea salt, citric acid, garlic, guar gum, cumin), chickpeas, ricotta cheese (pasteurized whole milk, culture, salt, enzymes), cheddar cheese (milk, enzymes, salt), romano cheese (milk, salt, enzymes), asiago cheese (pasteurized whole milk, culture, salt, enzymes), bread crumbs (wheat flour, evaporated cane syrup, yeast, sea salt), garlic, romano flavor (romano cheese {milk, culture, salt, enzymes}, salt, yeast extract, unsalted butter, corn oil, olive oil, creme powder, non-fat dry milk, olive oil, onion powder, garlic powder), blended oil (canola, olive), lemon juice, red pepper, black pepper, salt.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008009995020", "energy_kj": 402.0, "energy_kj_computed": null, "energy_kcal": 96.0, "fat": 12.0, "saturated_fat": 7.0, "carbohydrates": 24.0, "sugars": 1.0, "starch": null, "sodium": 0.5, "ingredients_text": "FILLING: RICOTTA CHEESE (MILK, WHEY, CREAM, VINEGAR, SALT, NATURAL STABILIZERS [XANTHAN GUM, LOCUST BEAN GUM, GUAR GUM]), CHEDDAR CHEESE (MILK, ENZYMES, SALT), MOZZARELLA CHEESE (PASTEURIZED WHOLE MILK, CULTURE, SALT, ENZYMES), BRIE CHEESE (PASTEURIZED CU", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008017310112", "energy_kj": 42.0, "energy_kj_computed": null, "energy_kcal": 10.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 2.0, "sugars": 2.0, "starch": null, "sodium": 0.025, "ingredients_text": "eau, riz, levure de riz, sucre, alcool (8,5% par volume), sel.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0008017311102", "energy_kj": 4.0, "energy_kj_computed": null, "energy_kcal": 1.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 0.0, "sugars": 0.0, "starch": null, "sodium": 0.32, "ingredients_text": "", "ingredients_text_present": 0, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "fr", "lang": "fr", "language_code": "fr"} +{"product_id": "0008077101101", "energy_kj": 1800.0, "energy_kj_computed": null, "energy_kcal": 431.0, "fat": 46.2, "saturated_fat": 18.5, "carbohydrates": 108.0, "sugars": 46.2, "starch": null, "sodium": 0.918, "ingredients_text": "WHEAT FLOUR, PARTIALLY HYDROGENATED PALM AND CANOLA OILS, SUGAR, WHOLE MILK POWDER, NON-FAT MILK POWDER, CHOCOLATE LIQUOR, COCOA (PROCESSED WITH ALKALI), CHEESE, SALT, SOY-LECITHIN, SODIUM BICARBONATE (LEAVENING), YEAST POWDER, ARTIFICIAL FLAVORS, NATURAL COLORING (BETA CAROTENE AND CARAMEL).", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008077101118", "energy_kj": 2226.0, "energy_kj_computed": null, "energy_kcal": 532.0, "fat": 28.07, "saturated_fat": 10.53, "carbohydrates": 61.4, "sugars": 26.32, "starch": null, "sodium": 0.439, "ingredients_text": "Wheat flour, partially hydrogenated palm and canola oils, sugar, whey, lactose, whole milk powder, cheese, salt, soy-lecithin, strawberry powder, natural coloring (beet red, beta carotene and caramel), sodium bicarbonate (leavening), yeast powder, artificial flavor, citric acid.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008077101132", "energy_kj": 2280.0, "energy_kj_computed": null, "energy_kcal": 545.0, "fat": 31.82, "saturated_fat": 11.36, "carbohydrates": 59.09, "sugars": 29.55, "starch": null, "sodium": 0.277368, "ingredients_text": "Wheat flour, vegetable oils (palm, soybean, canola), sugar, whole milk powder, skim milk powder, whey powder, cocoa mass, cocoa powder, lactose, emulsifiers (soy lecithin, propylene glycol esters of fatty acids, disodium phosphate), leavenings (ammonium bicarbonate, sodium bicarbonate), salt, cheese powder (cheddar cheese, whey, lactic acid), autolyzed yeast extract, strawberry powder, artificial flavors, natural colors (beet red, beta-carotene), enzyme (papain), citric acid.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008077102115", "energy_kj": 2230.0, "energy_kj_computed": null, "energy_kcal": 533.0, "fat": 26.67, "saturated_fat": 20.0, "carbohydrates": 66.67, "sugars": 26.67, "starch": null, "sodium": 0.333, "ingredients_text": "Cracker: wheat flour, shortening, vegetable oil, sugar, butter, cocoa mass, cocoa powder, full cream milk powder, amino acid seasoning, sugar ester, emulsifier (soya lecithin), salt, sodium bicarbonate, ammonium bicarbonate, autolysed yeast powder, caramel powder, enzyme (papain), milk flavor & butter flavor, vanilla flavor, vanillin. chocolate cream: sugar, shortening, cocoa mass, full cream milk powder, soya lecithin (emulsifier), vanilla flavoring & vanillin.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008077102122", "energy_kj": 2230.0, "energy_kj_computed": null, "energy_kcal": 533.0, "fat": 30.0, "saturated_fat": 16.67, "carbohydrates": 60.0, "sugars": 26.67, "starch": null, "sodium": 0.367, "ingredients_text": "Wheat flour, sugar, vegetable shortening (partially hydrogenated palm & soya bean oils), cocoa mass, whole milk powder, malt extract, seasoning (natural), emulsifier (soya-lecithin), leavening (ammonium bicarbonate & sodium bicarbonate), enzyme (papain), salt, artificial vanilla flavoring.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008077102139", "energy_kj": 1116.0, "energy_kj_computed": null, "energy_kcal": 266.68, "fat": 26.67, "saturated_fat": 13.33, "carbohydrates": 66.67, "sugars": 26.67, "starch": null, "sodium": 0.367, "ingredients_text": "WHEAT FLOUR, VEGETABLE SHORTENING (PARTIALLY HYDROGENATED PALM & SOYA BEAN OILS), SUGAR, LACTOSE, WHOLE MILK POWDER, MALT EXTRACT, SEASONING (NATURAL), EMULSIFIER (SOYA-LECITHIN), LEAVING (AMMONIUM BICARBONATE & SODIUM BICARBONATE), DEHYDRATED STRAWBERRY, SALT, NATURAL COLORING (E-162), ARTIFICIAL STRAWBERRY FLAVORING, CITRIC ACID.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008077102146", "energy_kj": 2230.0, "energy_kj_computed": null, "energy_kcal": 533.0, "fat": 26.67, "saturated_fat": 13.33, "carbohydrates": 66.67, "sugars": 33.33, "starch": null, "sodium": 0.367, "ingredients_text": "Wheat flour, vegetable shortening (partially hydrogenate palm & canola oils), sugar, malt syrup, lactose, whole milk powder, skim milk powder, emulsifier, (soya-lecithin), seasoning (natural), leavening (ammonium bicarbonate & sodium bicarbonate), salt, sugar flavor, milk flavor.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008077102207", "energy_kj": 2222.0, "energy_kj_computed": null, "energy_kcal": 531.0, "fat": 28.85, "saturated_fat": 15.38, "carbohydrates": 61.54, "sugars": 26.92, "starch": null, "sodium": 0.34600000000000003, "ingredients_text": "Wheat flour, sugar, vegetable shortening (partially hydrogenated palm & soya bean oils), cocoa mass, whole milk powder, malt extract, seasoning (natural), emulsifier (soya-lecithin), leavening (ammonium bicarbonate & sodium bicarbonate), enzyme (papain), salt, artificial vanilla flavoring.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008077102214", "energy_kj": 1094.0, "energy_kj_computed": null, "energy_kcal": 261.52, "fat": 26.92, "saturated_fat": 11.54, "carbohydrates": 65.38, "sugars": 23.08, "starch": null, "sodium": 0.365, "ingredients_text": "WHEAT FLOUR, VEGETABLE SHORTENING (PARTIALLY HYDROGENATED PALM & SOYA BEAN OILS), SUGAR, LACTOSE, SKIM MILK POWDER, MALT EXTRACT, SEASONING (NATURAL), EMULSIFIER (SOYA-LECITHIN), LEAVENING (AMMONIUM BICARBONATE & SODIUM BICARBONATE), DEHYDRATED STRAWBERRY, SALT, NATURAL COLORING (E-162), ARTIFICIAL STRAWBERRY FLAVORING, CITRIC ACID.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008077201108", "energy_kj": 1800.0, "energy_kj_computed": null, "energy_kcal": 431.0, "fat": 46.2, "saturated_fat": 18.5, "carbohydrates": 108.0, "sugars": 46.2, "starch": null, "sodium": 0.918, "ingredients_text": "WHEAT FLOUR, PARTIALLY HYDROGENATED PALM AND CANOLA OILS, SUGAR, WHOLE MILK POWDER, NON-FAT MILK POWDER, CHOCOLATE LIQUOR, COCOA (PROCESSED WITH ALKALI), CHEESE, SALT, SOY LECITHIN, SODIUM BICARBONATE (LEAVENING), YEAST POWDER, ARTIFICIAL FLAVORS, NATURAL", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008107259949", "energy_kj": null, "energy_kj_computed": null, "energy_kcal": null, "fat": null, "saturated_fat": null, "carbohydrates": null, "sugars": null, "starch": null, "sodium": null, "ingredients_text": "Enriched flour (wheat flour, malted barley flour, niacin, iron, thiamin mononitrate, riboflavin, folic acid), whole wheat flour, water, soybean oil, brown sugar, flax, whole soy flour, whole rye flour, yeast, oat bran, salt, sesame seed, black sesame seed, poppy seed, pretzel salt.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008107359946", "energy_kj": null, "energy_kj_computed": null, "energy_kcal": null, "fat": null, "saturated_fat": null, "carbohydrates": null, "sugars": null, "starch": null, "sodium": null, "ingredients_text": "Flour, water, soybean oil, sugar, yeast, sea salt, rosemary, salt", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008107829944", "energy_kj": null, "energy_kj_computed": null, "energy_kcal": null, "fat": null, "saturated_fat": null, "carbohydrates": null, "sugars": null, "starch": null, "sodium": null, "ingredients_text": "ENRICHED FLOUR (WHEAT FLOUR, MALTED BARLEY FLOUR, NIACIN, IRON, THIAMINE MONONITRATE, RIBOFLAVIN, FOLIC ACID), WATER, SOYBEAN OIL, SUGAR, EXTRA COARSE SEA SALT, YEAST, SALT", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008112100281", "energy_kj": 3347.0, "energy_kj_computed": null, "energy_kcal": 800.0, "fat": 93.333333333333, "saturated_fat": 13.333333333333, "carbohydrates": 0.0, "sugars": 0.0, "starch": null, "sodium": 0.0, "ingredients_text": "Sesame oil", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008112100298", "energy_kj": 3469.0, "energy_kj_computed": null, "energy_kcal": 829.0, "fat": 92.0, "saturated_fat": 14.0, "carbohydrates": 0.0, "sugars": null, "starch": null, "sodium": 0.0, "ingredients_text": "Sesame oil", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008127000019", "energy_kj": 3350.0, "energy_kj_computed": null, "energy_kcal": 800.0, "fat": 93.3, "saturated_fat": 13.3, "carbohydrates": 0.0, "sugars": 0.0, "starch": null, "sodium": 0.0, "ingredients_text": "Extra virgin olive oil", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008155902903", "energy_kj": 1490.0, "energy_kj_computed": null, "energy_kcal": 357.0, "fat": 35.7, "saturated_fat": 5.36, "carbohydrates": 3.57, "sugars": 0.0, "starch": null, "sodium": 0.929, "ingredients_text": "OIL (SOYBEAN AND OLIVE), CIDER VINEGAR, SALT, MONOSODIUM GLUTAMATE, NATURAL FLAVORING, SPICES.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008155902910", "energy_kj": 2690.0, "energy_kj_computed": null, "energy_kcal": 643.0, "fat": 71.43, "saturated_fat": 10.71, "carbohydrates": 7.14, "sugars": 0.0, "starch": null, "sodium": 0.143, "ingredients_text": "Oil (soybean and olive), balsamic vinegar, cider, vinegar, salt, monosodium glutamate, natural flavoring, spices", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008155902927", "energy_kj": 1197.0, "energy_kj_computed": null, "energy_kcal": 286.0, "fat": 28.57, "saturated_fat": 3.57, "carbohydrates": 0.0, "sugars": 0.0, "starch": null, "sodium": 0.643, "ingredients_text": "Oil (soybean and olive), water, cider vinegar, lemon juice, salt, monosodium glutamate, natural flavoring, spices", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008170751449", "energy_kj": 154.0, "energy_kj_computed": null, "energy_kcal": 37.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 9.25, "sugars": 0.0, "starch": null, "sodium": 0.189, "ingredients_text": "LENTILS, WATER, SALT, ANTIOXIDANT: ASCORBIC ACID.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008229101126", "energy_kj": 2880.0, "energy_kj_computed": null, "energy_kcal": 688.0, "fat": 79.1, "saturated_fat": 36.1, "carbohydrates": 172.0, "sugars": 127.0, "starch": null, "sodium": 0.903, "ingredients_text": "SUGAR, ENRICHED WHEAT FLOUR BLEACHED (FLOUR, MALTED BARLEY FLOUR, NIACIN, REDUCED IRON, THIAMINE MONONITRATE, RIBOFLAVIN, FOLIC ACID), PARTIALLY HYDROGENATED VEGETABLE OIL (SOYBEAN AND/OR COTTONSEED OIL) AND PALM KERNAL OIL, WHEY, WATER, EGG YOLK, SOYBEAN", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008229101133", "energy_kj": 1293.0, "energy_kj_computed": null, "energy_kcal": 309.0, "fat": 8.82, "saturated_fat": 2.2, "carbohydrates": 55.11, "sugars": 26.46, "starch": null, "sodium": 0.507, "ingredients_text": "Enriched wheat flour bleached (flour, malted barley flour, niacin, reduced iron, thiamine mononitrate, riboflavin, folic acid) water, sugar, soy oil, nonfat dry milk, contains 2% or less of: soy flour, leavening (baking soda, sodium acid pyrophosphate), wheat starch, salt, dry egg yolk, sour cream solids (cultured sour cream, maltodextrin, cultured buttermilk, cultured skim milk, whey, lactic acid), spice, cinnamon, cellulose gum, sodium stearoyl lactylate, food starch-modified, partially hydrogenated vegetable oil, (soybean, cottonseed), natural mixed tocopherols, agar, calcium carbonate, dextrose, canola oil, soy lecithin, mono & diglycerides, sorbitan monostearate, corn starch, corn oil, alpha tocopherols as preservatives, beta carotene as color, natural & artificial flavor.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008229101157", "energy_kj": 1377.0, "energy_kj_computed": null, "energy_kcal": 329.0, "fat": 8.82, "saturated_fat": 2.94, "carbohydrates": 58.82, "sugars": 29.41, "starch": null, "sodium": 0.541, "ingredients_text": "Enriched wheat flour bleached (flour, malted barley flour, niacin, iron, thiamine mononitrate, riboflavin, folic acid), sugar, water, soy oil, nonfat dry milk, contains 2% or less of: soy flour, dextrose, dry egg yolk, leavening (baking soda, sodium acid pyrophosphate), wheat starch, salt, dry whey, soy lecithin, sodium propionate and sodium diacetate, mono & dyglycerides, sour cream solids (cultured sour cream, maltodextrin, cultured buttermilk, cultured skim milk, whey, lactic acid), spice, cinnamon, cellulose gum, natural and artificial flavor, sodium stearoyl lactylate, corn starch, maltodextrin, food starch-modified, natural mixed tocopherols, alpha tocopherals, beta carotene, corn oil, partially hydrogenated vegetable oil (soybean, cottonseed), corn syrup, calcium carbonate, calcium sulfate, agar, locust bean gum, sunflower oil, disodium phosphate", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008229106084", "energy_kj": null, "energy_kj_computed": null, "energy_kcal": null, "fat": null, "saturated_fat": null, "carbohydrates": null, "sugars": null, "starch": null, "sodium": null, "ingredients_text": "Enriched wheat flour (wheat flour, barley malt, niacin, iron, thiamine mononitrate, riboflavin, folic acid), sugar, water, raisins (raisins, partially hydrogenated vegetable oil {soybean, cotton seed}), brown sugar, frozen apple slices (apples, ascorbic acid or erythorbic acid, salt, citric acid), yeast, contains 2% or less of: soy oil, salt, cinnamon, monodiglycerides with propionic acid and phosphoric acid, calcium propionate, calcium sulfate, enzymes, corn syrup, shortening (partially hydrogenated soybean, cotton seed, and/or canola oils), calcium carbonate, dextrose, agar, titanium dioxide, monoglycerides, natural and artificial flavors, ascorbic acid, fd&c yellow #5, cerelose, red #40", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008229106091", "energy_kj": null, "energy_kj_computed": null, "energy_kcal": null, "fat": null, "saturated_fat": null, "carbohydrates": null, "sugars": null, "starch": null, "sodium": null, "ingredients_text": "Enriched wheat flour (wheat flour, barley malt, niacin, iron, thiamine mononitrate, riboflavin, folic acid), water, sugar, sweetened dried cherry cranberries (cranberries, sugar, cherry juice, sunflower oil), cherry pie filling (pitted red tart cherries, water, high fructose corn syrup, corn syrup, modified corn starch, red 40, erythorbic acid), yeast, contains 2% or less of: soy oil, salt, monodiglycerides with propionic acid and phosphoric acid, calcium propionate, calcium sulfate, enzymes, corn syrup, shortening (partially hydrogenated soybean, cottonseed, and/or canola oils), calcium carbonate, dextrose, agar, titanium dioxide, monoglycerides, natural & artificial flavors, ascorbic acid, fd&c red #40 and #3", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008229106107", "energy_kj": null, "energy_kj_computed": null, "energy_kcal": null, "fat": null, "saturated_fat": null, "carbohydrates": null, "sugars": null, "starch": null, "sodium": null, "ingredients_text": "Enriched wheat flour (wheat flour, barley malt, niacin, iron, thiamine mononitrate, riboflavin, folic acid), water, sugar, dried cranberries (cranberries, sugar, sunflower oil), natural and artificial flavors, yeast, orange marmalade (corn syrup, orange peel, high fructose corn syrup, sugar, orange juice {from concentrate}, water, citric acid, sodium citrate, potassium sorbate, natural orange oil, pectin), contains 2% or less of: soy oil, salt, monodiglycerides with propionic acid and phosphoric acid, calcium propionate, enzymes, corn syrup, shortening (partially hydrogenated soybean, cottonseed, and/or canola oils), calcium carbonate, dextrose, agar, titanium dioxide, monoglycerides, ascorbic acid, calcium sulfate, artificial colors including fd&c yellow #6", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008229107005", "energy_kj": null, "energy_kj_computed": null, "energy_kcal": null, "fat": null, "saturated_fat": null, "carbohydrates": null, "sugars": null, "starch": null, "sodium": null, "ingredients_text": "Sugar, water, bleached wheat flour, eggs, corn syrup, egg whites, cocoa, nonfat dry milk, instant starch, powdered sugar, baking powder (sodium acid pyrophasphate, sodium bicarbonate, cornstarch, monocalcium phosphate), shortening (partially hydrogenated soybean oil & soybean oil with propylene, glycol monoesters, mono & diglycerides & soybean lecithin added), salt, sodium bicarbonate, conditioner (lactylic oleate, silicon dioxide, wheat enzymes, ascorbic acid, mixed tocopherols), vanilla, soybean oil, partially hydrogenated palm oil, chocolate.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008273000253", "energy_kj": 104.0, "energy_kj_computed": null, "energy_kcal": 24.9, "fat": 1.19, "saturated_fat": 0.299, "carbohydrates": 6.23, "sugars": 4.75, "starch": null, "sodium": 0.0481, "ingredients_text": "FILTERED WATER, SOYBEANS, HIGH FRUCTOSE CORN SYRUP, SUGAR, LOW DE CORN SYRUP, COCOA POWDER, CORN OIL, MIXTURE ADDITIVE (FILTERED WATER, CALCIUM CARBONATE, ARABIC GUM, GLYCERIN ESTERS OF FATTY ACIDS), ARTIFICIAL FLAVOR, SALT, GLYCERIN ESTERS OF FATTY ACIDS", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008274000061", "energy_kj": 165.0, "energy_kj_computed": null, "energy_kcal": 39.4, "fat": 0.0, "saturated_fat": null, "carbohydrates": 10.1, "sugars": 9.86, "starch": null, "sodium": 0.00141, "ingredients_text": "Sparkling filtered water, cane sugar, pineapple juice from concentrate, honey, ginger root, lemon and lime juices from concentrate, spices", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008274000078", "energy_kj": 165.0, "energy_kj_computed": null, "energy_kcal": 39.4, "fat": 0.0, "saturated_fat": null, "carbohydrates": 10.1, "sugars": 9.86, "starch": null, "sodium": 0.00141, "ingredients_text": "Sparkling filtered water, cane sugar, pineapple juice from concentrate, honey, ginger root, lemon and lime juices from concentrate, spices", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008274000092", "energy_kj": 165.0, "energy_kj_computed": null, "energy_kcal": 39.43661971831, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 9.8591549295775, "sugars": 9.0140845070423, "starch": null, "sodium": 0.008450704225352, "ingredients_text": "Sparkling filtered water, sweetened by a blend of canadian white water clover honey (very mild), pineapple juice from concentrate, fresh ginger root, lemon and lime juices from concentrate and spices.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008274000498", "energy_kj": 71.0, "energy_kj_computed": null, "energy_kcal": 17.0, "fat": 0.0, "saturated_fat": null, "carbohydrates": 4.23, "sugars": 3.75, "starch": null, "sodium": 4.297680000000001, "ingredients_text": "Freshly made from: live organic kombucha (spring water, organic cane sugar, organic oolong tea, organic yerba mate tea, organic coffee, kombucha culture).", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008274000511", "energy_kj": 88.0, "energy_kj_computed": null, "energy_kcal": 21.0, "fat": 0.0, "saturated_fat": null, "carbohydrates": 5.07, "sugars": 4.58, "starch": null, "sodium": 0.004, "ingredients_text": "Live organic kombucha (spring water, organic evaporated cane juice, organic oolong tea, organic yerba mate tea, kombucha culture), organic fresh ginger root, organic raspberry juice, organic raspberry puree, organic lemon juice.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008274000528", "energy_kj": 88.0, "energy_kj_computed": null, "energy_kcal": 21.0, "fat": 0.0, "saturated_fat": null, "carbohydrates": 5.0, "sugars": 4.58, "starch": null, "sodium": 0.004, "ingredients_text": "Live organic kombucha (spring water, organic evaporated cane juice, organic oolong tea, organic yerba mate tea, kombucha culture), organic hibiscus, organic fresh ginger root, organic pink grapefruit juice.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008274000535", "energy_kj": 35.9, "energy_kj_computed": null, "energy_kcal": 8.57, "fat": 0.0, "saturated_fat": null, "carbohydrates": 2.14, "sugars": 1.94, "starch": null, "sodium": 0.00169, "ingredients_text": "FRESHLY MADE FROM: LIVE ORGANIC KOMBUCHA (SPRING WATER, ORGANIC EVAPORATED CANE JUICE, ORGANIC OOLONG TEA, ORGANIC YERBA MATE TEA, KOMBUCHA CULTURE), ORGANIC FRESH GINGER ROOT, ORGANIC CRANBERRY JUICE, ORGANIC RASPBERRY JUICE.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008274000542", "energy_kj": 35.9, "energy_kj_computed": null, "energy_kcal": 8.57, "fat": 0.0, "saturated_fat": null, "carbohydrates": 2.14, "sugars": 1.94, "starch": null, "sodium": 0.00169, "ingredients_text": "FRESHLY MADE FROM: LIVE ORGANIC KOMBUCHA (SPRING WATER, ORGANIC EVAPORATED CANE JUICE, ORGANIC OOLONG TEA, ORGANIC YERBA MATE TEA, KOMBUCHA CULTURE), ORGANIC FRESH GINGER ROOT, ORGANIC LEMON JUICE, ORGANIC GOJI BERRIES.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008274111118", "energy_kj": 607.0, "energy_kj_computed": null, "energy_kcal": 145.0, "fat": 2.0, "saturated_fat": 2.0, "carbohydrates": 35.0, "sugars": 35.0, "starch": null, "sodium": 0.005, "ingredients_text": "Ginger ale.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008274123456", "energy_kj": 15100.0, "energy_kj_computed": null, "energy_kcal": 3600.0, "fat": 0.0, "saturated_fat": null, "carbohydrates": 900.0, "sugars": 900.0, "starch": null, "sodium": 0.0, "ingredients_text": "DICED BABY GINGER ROOT, RAW CANE SUGAR AND NOTHING ELSE!", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008274130003", "energy_kj": 63.0, "energy_kj_computed": null, "energy_kcal": 15.0, "fat": 0.0, "saturated_fat": null, "carbohydrates": 3.94, "sugars": 3.94, "starch": null, "sodium": 0.001, "ingredients_text": "Sparkling filtered water, pineapple juice concentrate, honey, ginger root, lemon and lime juice concentrates, spices, stevia rebaudiana leaf extract.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008274234152", "energy_kj": 2950.0, "energy_kj_computed": null, "energy_kcal": 705.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 176.0, "sugars": 88.2, "starch": null, "sodium": 0.0, "ingredients_text": "CANDY INGREDIENTS: SUGAR, GINGER, TAPIOCA STARCH.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008274333336", "energy_kj": 155.0, "energy_kj_computed": null, "energy_kcal": 37.0, "fat": 0.0, "saturated_fat": null, "carbohydrates": 9.3, "sugars": 9.3, "starch": null, "sodium": 0.001, "ingredients_text": "Sparkling filtered water (sweetened by a blend of canadian white water clover honey (very mild) and pineapple juice from concentrate), fresh ginger root, lemon and lime juices from concentrate and spices.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008274333381", "energy_kj": 15100.0, "energy_kj_computed": null, "energy_kcal": 3600.0, "fat": 0.0, "saturated_fat": null, "carbohydrates": 900.0, "sugars": 900.0, "starch": null, "sodium": 0.0, "ingredients_text": "DICED BABY GINGER ROOT, RAW CANE SUGAR.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008295612229", "energy_kj": 105.0, "energy_kj_computed": null, "energy_kcal": 25.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 5.0, "sugars": 5.0, "starch": null, "sodium": 0.0, "ingredients_text": "Wine Vinegar, Concentrated Grape Must, Caramel E 150d, Antioxidant (Sulphites) E 224. 6% Acidity", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008295615268", "energy_kj": 1255.0, "energy_kj_computed": null, "energy_kcal": 300.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 73.33, "sugars": 66.67, "starch": null, "sodium": 0.067, "ingredients_text": "Cooked grape must, (39%), (wine vinegar, concentrated and cooked grape must, colouring: caramel e150d, antioxidant:(sulfites) e224), wine vinegar, thickener: guar gum and xanthan gum.", "ingredients_text_present": 1, "contains_statement_present": 1, "allergen_evidence_present": 1, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008295616241", "energy_kj": 63.0, "energy_kj_computed": null, "energy_kcal": 15.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": null, "sugars": 3.0, "starch": null, "sodium": 0.0, "ingredients_text": "vinaigre de vin, moult de raisin concentr\u00e9, colorant E150d, antioxyg\u00e8ne: sulfites (E224)", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "it", "lang": "it", "language_code": "it"} +{"product_id": "0008295660084", "energy_kj": 1255.0, "energy_kj_computed": null, "energy_kcal": 300.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 73.33, "sugars": 66.67, "starch": null, "sodium": 0.067, "ingredients_text": "Balsamic condiment (min. 90%), glucose syrup, guar gum, xanthan gum stabilizer, natural raspberry flavor.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008295660107", "energy_kj": 973.0, "energy_kj_computed": null, "energy_kcal": 233.0, "fat": 0.0, "saturated_fat": null, "carbohydrates": 53.3, "sugars": 53.3, "starch": null, "sodium": 0.444, "ingredients_text": "ORGANIC GRAPE MUST, "ACETO BALSAMICO DI MODENA IGP" ORGANIC (39%), ORGANIC WINE VINEGAR.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008295660770", "energy_kj": 523.0, "energy_kj_computed": null, "energy_kcal": 125.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 13.33, "sugars": 13.33, "starch": null, "sodium": 0.0, "ingredients_text": "Concentrated grape must, wine vinegar.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008295661012", "energy_kj": 364.0, "energy_kj_computed": null, "energy_kcal": 87.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 13.33, "sugars": 13.33, "starch": null, "sodium": 0.0, "ingredients_text": "Wine vinegar, concentrated grape must, caramel.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008295661036", "energy_kj": 418.0, "energy_kj_computed": null, "energy_kcal": 100.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 20.0, "sugars": 20.0, "starch": null, "sodium": 0.0, "ingredients_text": "Wine vinegar, concentrated grape must.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008295661050", "energy_kj": 2230.0, "energy_kj_computed": null, "energy_kcal": 533.0, "fat": 0.0, "saturated_fat": 22.2, "carbohydrates": 133.0, "sugars": 33.3, "starch": null, "sodium": 0.0, "ingredients_text": "WINE VINEGAR, CONCENTRATED GRAPE MUST, CARAMEL.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008295661074", "energy_kj": 699.0, "energy_kj_computed": null, "energy_kcal": 167.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 33.33, "sugars": 33.33, "starch": null, "sodium": 0.0, "ingredients_text": "Wine vinegar, concentrated grape must, caramel.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008295661098", "energy_kj": 837.0, "energy_kj_computed": null, "energy_kcal": 200.0, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 40.0, "sugars": 40.0, "starch": null, "sodium": 0.0, "ingredients_text": "Concentrated grape must, wine vinegar, caramel.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008295663146", "energy_kj": 556.0, "energy_kj_computed": null, "energy_kcal": 133.0, "fat": 0.0, "saturated_fat": null, "carbohydrates": 33.33, "sugars": 33.33, "starch": null, "sodium": 1.6, "ingredients_text": "White wine vinegar (made from real wine), water, corn syrup, salt, brown sugar, diluted with water to 4% acidity (40 grain).", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008295663160", "energy_kj": 3720.0, "energy_kj_computed": null, "energy_kcal": 889.0, "fat": 0.0, "saturated_fat": null, "carbohydrates": 222.0, "sugars": 222.0, "starch": null, "sodium": 10.7, "ingredients_text": "WHITE WINE VINEGAR (MADE FROM REAL WINE), WATER, CORN SYRUP, SALT, BROWN SUGAR, DRIED ITALIAN HERBS, NATURAL FLAVOR, DILUTED WITH WATER TO 4% ACIDITY (40 GRAIN).", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 1, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} +{"product_id": "0008295663177", "energy_kj": 279.0, "energy_kj_computed": null, "energy_kcal": 66.6667, "fat": 0.0, "saturated_fat": 0.0, "carbohydrates": 13.3333, "sugars": 13.3333, "starch": null, "sodium": 0.0, "ingredients_text": "Wine vinegar, concentrated grape must, colour.", "ingredients_text_present": 1, "contains_statement_present": 0, "allergen_evidence_present": 0, "fop_threshold_exceeded": 0, "fop_symbol_present": 0, "fop_exempt_proxy": 0, "product_is_prepackaged_proxy": 1, "lc": "en", "lang": "en", "language_code": "en"} diff --git a/OFF_DataQuality/declarative/__init__.py b/OFF_DataQuality/declarative/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..95ec0e22ca13defeb2e5f3d659f555377c6a4edb --- /dev/null +++ b/OFF_DataQuality/declarative/__init__.py @@ -0,0 +1,2 @@ +"""Declarative check execution helpers (dbt-core / soda-core prototypes).""" + diff --git a/OFF_DataQuality/declarative/check_runners.py b/OFF_DataQuality/declarative/check_runners.py new file mode 100644 index 0000000000000000000000000000000000000000..a163509bbfa4024f6ec0c6ac6a5694224522c887 --- /dev/null +++ b/OFF_DataQuality/declarative/check_runners.py @@ -0,0 +1,742 @@ +"""Declarative check runners for dbt-core and soda-core pilots. + +These runners are intentionally lightweight: +- They always compute violating product IDs from DuckDB SQL conditions + (deterministic parity baseline). +- They optionally execute dbt/soda commands to prove declarative integration. +""" +from __future__ import annotations + +import os +import re +import shutil +import subprocess +from pathlib import Path +from typing import Dict, List, Mapping, Sequence + +import duckdb + +from duckdb_utils.create_tables import TABLE_NAME + +PROJECT_ROOT = Path(__file__).resolve().parent.parent +RUNTIME_DIR = PROJECT_ROOT / "results" / "declarative_runtime" +OUTPUT_TAIL_CHARS = 4000 + + +def _sql_for_rule(rule: Mapping[str, object]) -> str: + condition = str(rule["duckdb_condition"]) + return f"SELECT product_id FROM {TABLE_NAME} WHERE {condition}" + + +def _query_rule_product_ids(rule: Mapping[str, object], db_path: Path) -> List[str]: + query = _sql_for_rule(rule) + with duckdb.connect(db_path.as_posix()) as con: + rows = con.execute(query).fetchall() + return sorted(str(row[0]) for row in rows) + + +def _build_per_product_tags( + rules: Sequence[Mapping[str, object]], + per_rule_ids: Dict[str, List[str]], + products: Sequence[Mapping[str, object]], +) -> Dict[str, List[str]]: + per_product_tags: Dict[str, List[str]] = {str(product.get("product_id")): [] for product in products} + for rule in rules: + rule_name = str(rule["rule_name"]) + tag = str(rule["tag"]) + for product_id in per_rule_ids[rule_name]: + if product_id in per_product_tags: + per_product_tags[product_id].append(tag) + return per_product_tags + + +def _run_command(command: List[str], cwd: Path, env: Mapping[str, str] | None = None) -> Dict[str, object]: + try: + full_env = os.environ.copy() + if env: + full_env.update(env) + completed = subprocess.run( + command, + cwd=cwd, + env=full_env, + capture_output=True, + text=True, + encoding="utf-8", + errors="replace", + check=False, + timeout=180, + ) + stdout = completed.stdout or "" + stderr = completed.stderr or "" + return { + "command": " ".join(command), + "executed": True, + "success": completed.returncode == 0, + "return_code": completed.returncode, + "stdout_tail": stdout[-OUTPUT_TAIL_CHARS:], + "stderr_tail": stderr[-OUTPUT_TAIL_CHARS:], + } + except FileNotFoundError: + return { + "command": " ".join(command), + "executed": False, + "success": False, + "return_code": None, + "stdout_tail": "", + "stderr_tail": f"Command not found: {command[0]}", + } + except subprocess.TimeoutExpired as exc: + return { + "command": " ".join(command), + "executed": True, + "success": False, + "return_code": None, + "stdout_tail": (exc.stdout or "")[-OUTPUT_TAIL_CHARS:] if exc.stdout else "", + "stderr_tail": (exc.stderr or "")[-OUTPUT_TAIL_CHARS:] if exc.stderr else "Command timed out.", + } + + +def _soda_cloud_credentials() -> Dict[str, str] | None: + api_key_id = os.getenv("SODA_CLOUD_API_KEY_ID", "").strip() + api_key_secret = os.getenv("SODA_CLOUD_API_KEY_SECRET", "").strip() + host = os.getenv("SODA_CLOUD_HOST", "").strip() + if not (api_key_id and api_key_secret and host): + return None + return { + "api_key_id": api_key_id, + "api_key_secret": api_key_secret, + "host": host, + } + + +def _extract_cloud_scan_metadata(stdout_tail: str, stderr_tail: str) -> Dict[str, str]: + text = f"{stdout_tail}\n{stderr_tail}" + scan_id = "" + scan_url = "" + + scan_match = re.search(r"(?:scan[\s_-]?id)\s*[:=]\s*([a-zA-Z0-9\-]+)", text, flags=re.IGNORECASE) + if scan_match: + scan_id = scan_match.group(1).strip() + + url_match = re.search(r"(https?://[^\s]+)", text) + if url_match: + scan_url = url_match.group(1).strip().rstrip(".,)") + + return { + "scan_id": scan_id, + "scan_url": scan_url, + } + + +def _write_soda_data_source_config(config_path: Path, data_source_name: str, runtime_db_path: Path) -> None: + config_path.write_text( + "\n".join( + [ + "type: duckdb", + f"name: {data_source_name}", + "connection:", + f" database: {runtime_db_path.as_posix()}", + " schema: main", + ] + ) + + "\n", + encoding="utf-8", + ) + + +def _resolve_soda_cloud_config(target_path: Path) -> tuple[Path | None, str]: + explicit_path = os.getenv("SODA_CLOUD_CONFIG_PATH", "").strip() + candidate_paths = [] + if explicit_path: + candidate_paths.append(Path(explicit_path).expanduser()) + candidate_paths.append(PROJECT_ROOT / "sc_config.yml") + + for candidate in candidate_paths: + if candidate.is_file(): + shutil.copyfile(candidate, target_path) + return target_path, str(candidate) + + credentials = _soda_cloud_credentials() + if credentials is None: + return None, "" + + target_path.write_text( + "\n".join( + [ + "soda_cloud:", + f" host: {credentials['host']}", + f" api_key_id: {credentials['api_key_id']}", + f" api_key_secret: {credentials['api_key_secret']}", + ] + ) + + "\n", + encoding="utf-8", + ) + return target_path, "env" + + +def _prepare_dbt_project(rules: Sequence[Mapping[str, object]], db_path: Path, root_dir: Path) -> Dict[str, object]: + project_dir = root_dir / "dbt_project" + tests_dir = project_dir / "tests" + models_dir = project_dir / "models" + macros_dir = project_dir / "macros" + runtime_db_path = root_dir / "dbt_runtime.db" + tests_dir.mkdir(parents=True, exist_ok=True) + models_dir.mkdir(parents=True, exist_ok=True) + macros_dir.mkdir(parents=True, exist_ok=True) + shutil.copyfile(db_path, runtime_db_path) + + (project_dir / "dbt_project.yml").write_text( + "\n".join( + [ + "name: off_quality_declarative", + "version: '1.0'", + "config-version: 2", + "profile: off_quality_duckdb", + "model-paths: ['models']", + "test-paths: ['tests']", + ] + ) + + "\n", + encoding="utf-8", + ) + + (project_dir / "profiles.yml").write_text( + "\n".join( + [ + "off_quality_duckdb:", + " target: dev", + " outputs:", + " dev:", + " type: duckdb", + f" path: '{runtime_db_path.as_posix()}'", + " schema: main", + " threads: 1", + ] + ) + + "\n", + encoding="utf-8", + ) + + (models_dir / "sources.yml").write_text( + "\n".join( + [ + "version: 2", + "sources:", + " - name: off_source", + " schema: main", + " tables:", + " - name: nutrition_table", + ] + ) + + "\n", + encoding="utf-8", + ) + + test_sql_by_rule: Dict[str, str] = {} + for rule in rules: + rule_name = str(rule["rule_name"]) + condition = str(rule["duckdb_condition"]) + sql = ( + "SELECT product_id\n" + "FROM {{ source('off_source', 'nutrition_table') }}\n" + f"WHERE {condition}" + ) + test_sql_by_rule[rule_name] = sql + (tests_dir / f"{rule_name}.sql").write_text(sql + "\n", encoding="utf-8") + + # dbt test command uses multiprocessing in this environment and fails with WinError 5. + # Use run-operation to execute each rule query in real dbt runtime instead. + (macros_dir / "count_violations.sql").write_text( + "\n".join( + [ + "{% macro count_violations(condition_sql) %}", + " {% set q %}", + " select count(*) as violation_count", + " from {{ source('off_source', 'nutrition_table') }}", + " where {{ condition_sql }}", + " {% endset %}", + " {% set t = run_query(q) %}", + " {% if execute %}", + " {% set c = t.columns[0].values()[0] %}", + " {% do log('VIOLATION_COUNT=' ~ c, info=True) %}", + " {% endif %}", + "{% endmacro %}", + ] + ) + + "\n", + encoding="utf-8", + ) + + dbt_cmd = shutil.which("dbt") + if not dbt_cmd: + return { + "run": { + "command": "dbt test --project-dir ... --profiles-dir ...", + "executed": False, + "success": False, + "return_code": None, + "stdout_tail": "", + "stderr_tail": "dbt CLI not found. Install dbt-duckdb.", + }, + "test_sql_by_rule": test_sql_by_rule, + } + + debug_info = _run_command( + [dbt_cmd, "debug", "--project-dir", str(project_dir), "--profiles-dir", str(project_dir)], + cwd=project_dir, + ) + per_rule_runs: Dict[str, Dict[str, object]] = {} + for rule in rules: + rule_name = str(rule["rule_name"]) + condition = str(rule["duckdb_condition"]) + args_yaml = f"{{condition_sql: {condition!r}}}" + per_rule_runs[rule_name] = _run_command( + [ + dbt_cmd, + "run-operation", + "count_violations", + "--project-dir", + str(project_dir), + "--profiles-dir", + str(project_dir), + "--args", + args_yaml, + ], + cwd=project_dir, + ) + + all_executed = bool(debug_info.get("executed")) and all(bool(run.get("executed")) for run in per_rule_runs.values()) + all_success_codes = ( + debug_info.get("return_code") == 0 and all(run.get("return_code") == 0 for run in per_rule_runs.values()) + ) + failing_rules = [rule_name for rule_name, run in per_rule_runs.items() if run.get("return_code") != 0] + summary_stdout, summary_stderr = _summarize_soda_runs(per_rule_runs) + + run_info = { + "command": ( + f"dbt debug + dbt run-operation count_violations " + f"(per-rule x{len(per_rule_runs)}) --project-dir {project_dir} --profiles-dir {project_dir}" + ), + "executed": all_executed, + "success": all_success_codes, + "return_code": 0 if all_success_codes else 2, + "stdout_tail": summary_stdout, + "stderr_tail": summary_stderr, + "real_execution": all_success_codes, + "failed_rules": failing_rules, + } + return {"run": run_info, "test_sql_by_rule": test_sql_by_rule} + + +def _prepare_soda_cloud_scan( + rules: Sequence[Mapping[str, object]], + db_path: Path, + root_dir: Path, +) -> Dict[str, object]: + soda_dir = root_dir / "soda_cloud" + soda_dir.mkdir(parents=True, exist_ok=True) + runtime_db_path = root_dir / "soda_cloud_runtime.db" + shutil.copyfile(db_path, runtime_db_path) + + data_source_name = "off_quality" + config_path = soda_dir / "data_source.yml" + soda_cloud_config_path = soda_dir / "soda_cloud.yml" + contracts_dir = soda_dir / "contracts" + contracts_dir.mkdir(parents=True, exist_ok=True) + + check_yaml_by_rule: Dict[str, str] = {} + soda_cloud_config, cloud_config_source = _resolve_soda_cloud_config(soda_cloud_config_path) + if soda_cloud_config is None: + return { + "run": { + "command": "soda contract verify -c -ds data_source.yml -sc soda_cloud.yml -p", + "executed": False, + "success": False, + "return_code": None, + "stdout_tail": "", + "stderr_tail": ( + "Soda Cloud config missing. Provide sc_config.yml, set SODA_CLOUD_CONFIG_PATH, " + "or set SODA_CLOUD_API_KEY_ID, SODA_CLOUD_API_KEY_SECRET, SODA_CLOUD_HOST." + ), + "mode": "cloud", + "cloud_connected": False, + "cloud_scan_id": "", + "cloud_scan_url": "", + "real_execution": False, + "failed_rules": [str(rule["rule_name"]) for rule in rules], + }, + "check_yaml_by_rule": check_yaml_by_rule, + } + + _write_soda_data_source_config(config_path=config_path, data_source_name=data_source_name, runtime_db_path=runtime_db_path) + + soda_cmd = shutil.which("soda") + if not soda_cmd: + return { + "run": { + "command": ( + f"soda contract verify -c -ds {config_path} " + f"-sc {soda_cloud_config_path} -p" + ), + "executed": False, + "success": False, + "return_code": None, + "stdout_tail": "", + "stderr_tail": "soda CLI not found. Install soda-duckdb.", + "mode": "cloud", + "cloud_connected": False, + "cloud_scan_id": "", + "cloud_scan_url": "", + "real_execution": False, + "failed_rules": [str(rule["rule_name"]) for rule in rules], + }, + "check_yaml_by_rule": check_yaml_by_rule, + } + + with duckdb.connect(db_path.as_posix()) as con: + columns = [str(row[1]) for row in con.execute(f"PRAGMA table_info('{TABLE_NAME}')").fetchall()] + + soda_env = { + "OTEL_SDK_DISABLED": "true", + "PYTHONUTF8": "1", + "PYTHONIOENCODING": "utf-8", + } + per_rule_runs: Dict[str, Dict[str, object]] = {} + first_cloud_meta = {"scan_id": "", "scan_url": ""} + for rule in rules: + rule_name = str(rule["rule_name"]) + condition = str(rule["duckdb_condition"]) + check_block = ( + f" - failed_rows:\n" + f" name: {rule_name}\n" + f" expression: {condition}\n" + ) + check_yaml_by_rule[rule_name] = check_block.rstrip("\n") + + contract_lines: List[str] = [ + f"dataset: {data_source_name}/main/{TABLE_NAME}", + "columns:", + ] + for column in columns: + contract_lines.append(f" - name: {column}") + contract_lines.extend(["checks:", check_block.rstrip("\n")]) + + contract_path = contracts_dir / f"{rule_name}.yml" + contract_path.write_text("\n".join(contract_lines) + "\n", encoding="utf-8") + + run = _run_command( + [ + soda_cmd, + "contract", + "verify", + "-c", + str(contract_path), + "-ds", + str(config_path), + "-sc", + str(soda_cloud_config), + "-p", + "-v", + ], + cwd=soda_dir, + env=soda_env, + ) + per_rule_runs[rule_name] = run + cloud_meta = _extract_cloud_scan_metadata( + stdout_tail=str(run.get("stdout_tail", "")), + stderr_tail=str(run.get("stderr_tail", "")), + ) + if not first_cloud_meta["scan_id"] and cloud_meta["scan_id"]: + first_cloud_meta["scan_id"] = cloud_meta["scan_id"] + if not first_cloud_meta["scan_url"] and cloud_meta["scan_url"]: + first_cloud_meta["scan_url"] = cloud_meta["scan_url"] + + all_executed = all(bool(run.get("executed")) for run in per_rule_runs.values()) + all_success_codes = all(run.get("return_code") in {0, 1} for run in per_rule_runs.values()) + all_real = all(_soda_run_is_real(run) for run in per_rule_runs.values()) + all_published = all(_soda_cloud_publish_succeeded(run) for run in per_rule_runs.values()) + failing_rules = [ + rule_name + for rule_name, run in per_rule_runs.items() + if not (_soda_run_is_real(run) and _soda_cloud_publish_succeeded(run)) + ] + + summary_stdout, summary_stderr = _summarize_soda_runs(per_rule_runs) + + run_info = { + "command": ( + f"soda contract verify (per-rule x{len(per_rule_runs)}) -ds {config_path} " + f"-sc {soda_cloud_config} -p" + ), + "executed": all_executed, + "success": all_success_codes, + "return_code": 0 if all_success_codes else 3, + "stdout_tail": summary_stdout, + "stderr_tail": summary_stderr, + "mode": "cloud", + "real_execution": all_real, + "cloud_connected": all_published, + "cloud_scan_id": first_cloud_meta["scan_id"], + "cloud_scan_url": first_cloud_meta["scan_url"], + "cloud_config_source": cloud_config_source, + "failed_rules": failing_rules, + } + return {"run": run_info, "check_yaml_by_rule": check_yaml_by_rule} + + +def _prepare_soda_contract(rules: Sequence[Mapping[str, object]], db_path: Path, root_dir: Path) -> Dict[str, object]: + soda_dir = root_dir / "soda" + soda_dir.mkdir(parents=True, exist_ok=True) + data_source_name = "off_quality" + runtime_db_path = root_dir / "soda_runtime.db" + config_path = soda_dir / "data_source.yml" + contracts_dir = soda_dir / "contracts" + contracts_dir.mkdir(parents=True, exist_ok=True) + shutil.copyfile(db_path, runtime_db_path) + + _write_soda_data_source_config(config_path=config_path, data_source_name=data_source_name, runtime_db_path=runtime_db_path) + + with duckdb.connect(db_path.as_posix()) as con: + columns = [str(row[1]) for row in con.execute(f"PRAGMA table_info('{TABLE_NAME}')").fetchall()] + + check_yaml_by_rule: Dict[str, str] = {} + soda_cmd = shutil.which("soda") + if not soda_cmd: + return { + "run": { + "command": f"soda contract verify -c -ds {config_path}", + "executed": False, + "success": False, + "return_code": None, + "stdout_tail": "", + "stderr_tail": "soda CLI not found. Install soda-duckdb.", + }, + "check_yaml_by_rule": check_yaml_by_rule, + } + + soda_env = { + # Avoid blocked telemetry calls and Windows cp1252 console issues with emoji output. + "OTEL_SDK_DISABLED": "true", + "PYTHONUTF8": "1", + "PYTHONIOENCODING": "utf-8", + } + per_rule_runs: Dict[str, Dict[str, object]] = {} + for rule in rules: + rule_name = str(rule["rule_name"]) + condition = str(rule["duckdb_condition"]) + check_block = ( + f" - failed_rows:\n" + f" name: {rule_name}\n" + f" expression: {condition}\n" + ) + check_yaml_by_rule[rule_name] = check_block.rstrip("\n") + + contract_lines: List[str] = [ + f"dataset: {data_source_name}/main/{TABLE_NAME}", + "columns:", + ] + for column in columns: + contract_lines.append(f" - name: {column}") + contract_lines.extend(["checks:", check_block.rstrip("\n")]) + + contract_path = contracts_dir / f"{rule_name}.yml" + contract_path.write_text("\n".join(contract_lines) + "\n", encoding="utf-8") + + per_rule_runs[rule_name] = _run_command( + [soda_cmd, "contract", "verify", "-c", str(contract_path), "-ds", str(config_path)], + cwd=soda_dir, + env=soda_env, + ) + + all_executed = all(bool(run.get("executed")) for run in per_rule_runs.values()) + all_success_codes = all(run.get("return_code") in {0, 1} for run in per_rule_runs.values()) + all_real = all(_soda_run_is_real(run) for run in per_rule_runs.values()) + failing_rules = [rule_name for rule_name, run in per_rule_runs.items() if not _soda_run_is_real(run)] + + summary_stdout = "\n".join( + f"{rule_name}: rc={run.get('return_code')}, success={run.get('success')}" + for rule_name, run in per_rule_runs.items() + )[-1200:] + summary_stderr = "\n".join( + f"{rule_name}: {str(run.get('stderr_tail', '')).strip()}" + for rule_name, run in per_rule_runs.items() + if str(run.get("stderr_tail", "")).strip() + )[-1200:] + + run_info = { + "command": f"soda contract verify (per-rule x{len(per_rule_runs)}) -ds {config_path}", + "executed": all_executed, + "success": all_success_codes, + "return_code": 0 if all_success_codes else 3, + "stdout_tail": summary_stdout, + "stderr_tail": summary_stderr, + "mode": "local", + "real_execution": all_real, + "cloud_connected": False, + "cloud_scan_id": "", + "cloud_scan_url": "", + "failed_rules": failing_rules, + } + return {"run": run_info, "check_yaml_by_rule": check_yaml_by_rule} + + +def _dbt_run_is_real(run_info: Mapping[str, object]) -> bool: + if "real_execution" in run_info: + return bool(run_info.get("real_execution")) + if not bool(run_info.get("executed")): + return False + return run_info.get("return_code") in {0, 1} + + +def _soda_run_is_real(run_info: Mapping[str, object]) -> bool: + if not bool(run_info.get("executed")): + return False + output = f"{run_info.get('stdout_tail', '')}\n{run_info.get('stderr_tail', '')}".lower() + if "soda v3 commands are not supported" in output: + return False + if "contract results for" in output: + return True + if run_info.get("return_code") in {0, 1}: + return True + return bool(run_info.get("success")) + + +def _soda_cloud_publish_succeeded(run_info: Mapping[str, object]) -> bool: + if not bool(run_info.get("executed")): + return False + output = f"{run_info.get('stdout_tail', '')}\n{run_info.get('stderr_tail', '')}".lower() + if "results sent to soda cloud" in output: + return True + if "to view the dataset on soda cloud" in output: + return True + if "cloud.soda.io/o/" in output: + return True + return False + + +def _summarize_soda_runs(per_rule_runs: Mapping[str, Mapping[str, object]]) -> tuple[str, str]: + summary_stdout = "\n".join( + f"{rule_name}: rc={run.get('return_code')}, success={run.get('success')}" + for rule_name, run in per_rule_runs.items() + ) + summary_stderr = "\n".join( + f"{rule_name}: {str(run.get('stderr_tail', '')).strip()}" + for rule_name, run in per_rule_runs.items() + if str(run.get("stderr_tail", "")).strip() + ) + + for rule_name, run in per_rule_runs.items(): + if not _soda_run_is_real(run): + failing_stdout = str(run.get("stdout_tail", "")).strip() + failing_stderr = str(run.get("stderr_tail", "")).strip() + if failing_stdout: + summary_stdout = f"{summary_stdout}\n\nFirst failing rule: {rule_name}\n{failing_stdout}" + if failing_stderr: + summary_stderr = f"{summary_stderr}\n\nFirst failing rule: {rule_name}\n{failing_stderr}" + break + + return summary_stdout[-1200:], summary_stderr[-1200:] + + +def run_declarative_checks( + rules: Sequence[Mapping[str, object]], + products: Sequence[Mapping[str, object]], + db_path: Path, + engine: str, + soda_mode: str = "local", +) -> Dict[str, object]: + """Run declarative checks and return parity-compatible output payload.""" + if engine not in {"dbt", "soda"}: + raise ValueError(f"Unsupported declarative engine: {engine}") + if soda_mode not in {"local", "cloud"}: + raise ValueError("soda_mode must be one of: local, cloud") + + runtime_root = RUNTIME_DIR / engine + runtime_root.mkdir(parents=True, exist_ok=True) + + per_rule_ids: Dict[str, List[str]] = {} + for rule in rules: + per_rule_ids[str(rule["rule_name"])] = _query_rule_product_ids(rule, db_path=db_path) + + per_product_tags = _build_per_product_tags(rules=rules, per_rule_ids=per_rule_ids, products=products) + + if engine == "dbt": + artifact = _prepare_dbt_project(rules=rules, db_path=db_path, root_dir=runtime_root) + run_info = artifact["run"] + snippets = artifact["test_sql_by_rule"] + is_real = _dbt_run_is_real(run_info) + provider = "dbt_core" if is_real else "dbt_core_sql_fallback" + confidence = 0.99 if is_real else 0.92 + note_prefix = ( + "dbt tests executed through dbt-core." + if is_real + else "dbt execution unavailable/failed; used SQL-equivalent declarative parity." + ) + else: + if soda_mode == "cloud": + cloud_artifact = _prepare_soda_cloud_scan(rules=rules, db_path=db_path, root_dir=runtime_root) + cloud_run = cloud_artifact["run"] + snippets = cloud_artifact["check_yaml_by_rule"] + cloud_ok = bool(cloud_run.get("cloud_connected")) and bool(cloud_run.get("real_execution")) + if cloud_ok: + run_info = cloud_run + is_real = True + provider = "soda_cloud" + confidence = 0.99 + note_prefix = "Soda Cloud scan executed successfully." + else: + run_info = dict(cloud_run) + run_info.update( + { + "mode": "cloud_sql_fallback", + "real_execution": False, + "cloud_connected": bool(cloud_run.get("cloud_connected", False)), + "cloud_scan_id": str(cloud_run.get("cloud_scan_id", "")), + "cloud_scan_url": str(cloud_run.get("cloud_scan_url", "")), + "failed_rules": [str(rule["rule_name"]) for rule in rules], + } + ) + is_real = False + provider = "soda_core_sql_fallback" + confidence = 0.92 + note_prefix = "Soda Cloud unavailable/failed; used SQL-equivalent declarative parity (fast fallback)." + else: + artifact = _prepare_soda_contract(rules=rules, db_path=db_path, root_dir=runtime_root) + run_info = artifact["run"] + snippets = artifact["check_yaml_by_rule"] + is_real = bool(run_info.get("real_execution")) or _soda_run_is_real(run_info) + provider = "soda_core" if is_real else "soda_core_sql_fallback" + confidence = 0.99 if is_real else 0.92 + note_prefix = ( + "Soda contract verification executed through soda-core." + if is_real + else "Soda execution unavailable/failed; used SQL-equivalent declarative parity." + ) + + conversion_metadata: Dict[str, Dict[str, object]] = {} + for rule in rules: + rule_name = str(rule["rule_name"]) + conversion_metadata[rule_name] = { + "function_name": f"{engine}_{rule_name}", + "python_code": snippets.get(rule_name, _sql_for_rule(rule)), + "llm_confidence": confidence, + "conversion_notes": ( + f"{note_prefix} " + f"Command: {run_info['command']} | " + f"Success: {run_info['success']} | " + f"Return code: {run_info['return_code']}" + ), + "provider": provider, + "execution_mode": str(run_info.get("mode", "local")), + "cloud_connected": bool(run_info.get("cloud_connected", False)), + "cloud_scan_id": str(run_info.get("cloud_scan_id", "")), + "cloud_scan_url": str(run_info.get("cloud_scan_url", "")), + } + + return { + "per_product": per_product_tags, + "per_rule": per_rule_ids, + "conversion_metadata": conversion_metadata, + "engine_run": run_info, + } diff --git a/OFF_DataQuality/duckdb_utils/__init__.py b/OFF_DataQuality/duckdb_utils/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/OFF_DataQuality/duckdb_utils/create_tables.py b/OFF_DataQuality/duckdb_utils/create_tables.py new file mode 100644 index 0000000000000000000000000000000000000000..018f4b053b769ba943188018df9c574b2b2faa80 --- /dev/null +++ b/OFF_DataQuality/duckdb_utils/create_tables.py @@ -0,0 +1,116 @@ +"""DuckDB helpers for the migration prototype.""" +from __future__ import annotations + +from pathlib import Path +from typing import Dict, List + +import duckdb + +DB_PATH = Path(__file__).resolve().parent.parent / "off_quality.db" +TABLE_NAME = "nutrition_table" + +SCHEMA_SQL = f""" +CREATE TABLE IF NOT EXISTS {TABLE_NAME} ( + product_id TEXT, + energy_kj DOUBLE, + energy_kj_computed DOUBLE, + energy_kcal DOUBLE, + fat DOUBLE, + saturated_fat DOUBLE, + carbohydrates DOUBLE, + sugars DOUBLE, + starch DOUBLE, + sodium DOUBLE, + ingredients_text TEXT, + ingredients_text_present INTEGER, + contains_statement_present INTEGER, + allergen_evidence_present INTEGER, + fop_threshold_exceeded INTEGER, + fop_symbol_present INTEGER, + fop_exempt_proxy INTEGER, + product_is_prepackaged_proxy INTEGER, + lc TEXT, + lang TEXT, + language_code TEXT +) +""" + + +def connect(db_path: Path = DB_PATH) -> duckdb.DuckDBPyConnection: + return duckdb.connect(db_path.as_posix()) + + +def recreate_nutrition_table(db_path: Path = DB_PATH) -> None: + """Drop and recreate the main table for deterministic runs.""" + with connect(db_path) as con: + con.execute(f"DROP TABLE IF EXISTS {TABLE_NAME}") + con.execute(SCHEMA_SQL) + + +def load_jsonl_to_duckdb(jsonl_path: Path, db_path: Path = DB_PATH) -> None: + """Load JSONL records into DuckDB.""" + with connect(db_path) as con: + con.execute( + f""" + INSERT INTO {TABLE_NAME} + SELECT + product_id, + energy_kj, + energy_kj_computed, + energy_kcal, + fat, + saturated_fat, + carbohydrates, + sugars, + starch, + sodium, + ingredients_text, + ingredients_text_present, + contains_statement_present, + allergen_evidence_present, + fop_threshold_exceeded, + fop_symbol_present, + fop_exempt_proxy, + product_is_prepackaged_proxy, + lc, + lang, + language_code + FROM read_json_auto(?) + """, + [jsonl_path.as_posix()], + ) + + +def fetch_products(db_path: Path = DB_PATH) -> List[Dict[str, object]]: + """Read all products from DuckDB as dictionaries.""" + with connect(db_path) as con: + rows = con.execute(f"SELECT * FROM {TABLE_NAME}").fetchdf() + return rows.to_dict("records") + + +def count_rows(db_path: Path = DB_PATH) -> int: + with connect(db_path) as con: + value = con.execute(f"SELECT COUNT(*) FROM {TABLE_NAME}").fetchone() + return int(value[0] if value else 0) + + +def count_violations(condition_sql: str, db_path: Path = DB_PATH) -> int: + """Count records matching a rule condition.""" + query = f"SELECT COUNT(*) FROM {TABLE_NAME} WHERE {condition_sql}" + with connect(db_path) as con: + value = con.execute(query).fetchone() + return int(value[0] if value else 0) + + +def sample_violations(condition_sql: str, limit: int = 5, db_path: Path = DB_PATH) -> List[Dict[str, object]]: + """Return sample violating records for dashboard drilldown.""" + query = f""" + SELECT * + FROM {TABLE_NAME} + WHERE {condition_sql} + ORDER BY product_id + LIMIT {int(limit)} + """ + with connect(db_path) as con: + rows = con.execute(query).fetchdf() + return rows.to_dict("records") diff --git a/OFF_DataQuality/extractor/__init__.py b/OFF_DataQuality/extractor/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/OFF_DataQuality/extractor/perl_logic_extractor.py b/OFF_DataQuality/extractor/perl_logic_extractor.py new file mode 100644 index 0000000000000000000000000000000000000000..7f28d1e738ef2415f16038bbe11d7033de6e606f --- /dev/null +++ b/OFF_DataQuality/extractor/perl_logic_extractor.py @@ -0,0 +1,316 @@ +"""Perl logic extractor for converting legacy checks into structured rules.""" +from __future__ import annotations + +import hashlib +import json +import re +from typing import Dict, Iterable, List, Mapping, Sequence + +RULE_NAME_RE = re.compile(r"#\s*RULE_NAME:\s*(?P[a-zA-Z0-9_]+)") +SEVERITY_RE = re.compile(r"#\s*SEVERITY:\s*(?P[a-zA-Z0-9_]+)") +COMPLEXITY_RE = re.compile(r"#\s*COMPLEXITY:\s*(?P[a-zA-Z0-9_]+)") +DECLARATIVE_RE = re.compile(r"#\s*DECLARATIVE_FRIENDLY:\s*(?P[a-zA-Z0-9_]+)") +TAG_RE = re.compile(r'"(?P[a-z0-9\-]+)"\s*;') + +VAR_COMPARE_RE = re.compile( + r"if\s*\(\s*\$(?P[a-zA-Z_]\w*)\s*(?P>=|<=|>|<|==|!=)\s*\$(?P[a-zA-Z_]\w*)\s*\)", + re.DOTALL, +) +VALUE_COMPARE_RE = re.compile( + r"if\s*\(\s*\$(?P[a-zA-Z_]\w*)\s*(?P>=|<=|>|<|==|!=)\s*(?P\d+(?:\.\d+)?)\s*\)", + re.DOTALL, +) +MISSING_FIELD_RE = re.compile( + r'if\s*\(\s*!defined\s+\$(?P[a-zA-Z_]\w*)\s*\|\|\s*\$(?P=field)\s+eq\s+""\s*\)', + re.DOTALL, +) +SCALED_FIELD_COMPARE_RE = re.compile( + r"if\s*\(\s*\$(?P[a-zA-Z_]\w*)\s*(?P>=|<=|>|<|==|!=)\s*\(\s*\$(?P[a-zA-Z_]\w*)\s*\*\s*(?P\d+(?:\.\d+)?)\s*\)\s*\)", + re.DOTALL, +) +AFFINE_FIELD_COMPARE_RE = re.compile( + r"if\s*\(\s*\$(?P[a-zA-Z_]\w*)\s*(?P>=|<=|>|<|==|!=)\s*\(\s*(?P\d+(?:\.\d+)?)\s*\*\s*\$(?P[a-zA-Z_]\w*)\s*(?P[+-])\s*(?P\d+(?:\.\d+)?)\s*\)\s*\)", + re.DOTALL, +) +SUM_FIELDS_COMPARE_RE = re.compile( + r"if\s*\(\s*\(\s*\$(?P[a-zA-Z_]\w*)\s*\+\s*\$(?P[a-zA-Z_]\w*)\s*\)\s*(?P>=|<=|>|<|==|!=)\s*\(\s*\$(?P[a-zA-Z_]\w*)\s*(?P[+-])\s*(?P\d+(?:\.\d+)?)\s*\)\s*\)", + re.DOTALL, +) +IF_CONDITION_RE = re.compile(r"if\s*\(\s*(?P.*?)\s*\)\s*\{", re.DOTALL) +THRESHOLD_CLAUSE_RE = re.compile( + r"^\s*\(?\s*\$(?P[a-zA-Z_]\w*)\s*(?P>=|<=|>|<|==|!=)\s*(?P\d+(?:\.\d+)?)\s*\)?\s*$" +) + + +def _extract_named_value(pattern: re.Pattern[str], text: str, default: str) -> str: + match = pattern.search(text) + if not match: + return default + return match.group("value").strip() + + +def _extract_tag(perl_logic: str) -> str: + match = TAG_RE.search(perl_logic) + if not match: + raise ValueError(f"Unable to extract tag from Perl logic:\n{perl_logic}") + return match.group("tag") + + +def _default_rule_name(tag: str) -> str: + return tag.replace("-", "_") + + +def _parse_declarative_flag(value: str) -> bool: + return value.strip().lower() in {"yes", "true", "1", "y"} + + +def _default_complexity(condition_type: str) -> str: + if condition_type in {"field_comparison", "field_threshold", "missing_field"}: + return "simple" + if condition_type == "compound_threshold_and": + return "medium" + if condition_type == "sum_fields_comparison": + return "medium" + if condition_type == "affine_field_comparison": + return "intricate" + return "intricate" + + +def _build_rule_ir(rule: Mapping[str, object]) -> Dict[str, object]: + condition_type = str(rule.get("condition_type", "unknown")) + ir: Dict[str, object] = { + "version": "1.0", + "rule_name": rule.get("rule_name"), + "condition_type": condition_type, + "severity": rule.get("severity"), + "tag": rule.get("tag"), + } + if condition_type in {"field_comparison", "field_threshold", "missing_field", "scaled_field_comparison", "affine_field_comparison"}: + ir["left_operand"] = rule.get("left_operand") + if condition_type in {"field_comparison", "field_threshold", "scaled_field_comparison", "affine_field_comparison", "sum_fields_comparison"}: + ir["operator"] = rule.get("operator") + if condition_type in {"field_comparison", "field_threshold", "scaled_field_comparison", "affine_field_comparison", "sum_fields_comparison"}: + ir["right_operand"] = rule.get("right_operand") + if condition_type == "sum_fields_comparison": + ir["left_operands"] = rule.get("left_operands") + ir["right_offset"] = rule.get("right_offset") + if condition_type == "scaled_field_comparison": + ir["scale_factor"] = rule.get("scale_factor") + if condition_type == "affine_field_comparison": + ir["scale_factor"] = rule.get("scale_factor") + ir["offset"] = rule.get("offset") + if condition_type == "compound_threshold_and": + ir["clauses"] = rule.get("clauses") + return ir + + +def _attach_rule_ir(rule: Dict[str, object]) -> Dict[str, object]: + ir = _build_rule_ir(rule) + ir_json = json.dumps(ir, sort_keys=True, default=str) + rule["rule_ir"] = ir + rule["rule_ir_hash"] = hashlib.sha1(ir_json.encode("utf-8")).hexdigest()[:12] + return rule + + +def extract_rule(perl_logic: str) -> Dict[str, object]: + """Extract one structured rule from a Perl snippet.""" + perl_logic = perl_logic.lstrip("\ufeff").strip() + tag = _extract_tag(perl_logic) + rule_name = _extract_named_value(RULE_NAME_RE, perl_logic, _default_rule_name(tag)) + severity = _extract_named_value(SEVERITY_RE, perl_logic, "error") + complexity_meta = _extract_named_value(COMPLEXITY_RE, perl_logic, "") + declarative_meta = _extract_named_value(DECLARATIVE_RE, perl_logic, "") + declarative_friendly = _parse_declarative_flag(declarative_meta) if declarative_meta else None + + missing_match = MISSING_FIELD_RE.search(perl_logic) + if missing_match: + field = missing_match.group("field") + return { + "rule_name": rule_name, + "condition": f"missing({field})", + "duckdb_condition": f"{field} IS NULL OR TRIM({field}) = ''", + "condition_type": "missing_field", + "left_operand": field, + "operator": "missing", + "right_operand": None, + "complexity": complexity_meta or _default_complexity("missing_field"), + "declarative_friendly": True if declarative_friendly is None else declarative_friendly, + "tag": tag, + "severity": severity, + "perl_logic": perl_logic.strip(), + } + + scaled_match = SCALED_FIELD_COMPARE_RE.search(perl_logic) + if scaled_match: + left = scaled_match.group("left") + operator = scaled_match.group("op") + right = scaled_match.group("right") + factor = float(scaled_match.group("factor")) + condition = f"{left} {operator} ({right} * {factor})" + return { + "rule_name": rule_name, + "condition": condition, + "duckdb_condition": f"{left} {operator} ({right} * {factor})", + "condition_type": "scaled_field_comparison", + "left_operand": left, + "operator": operator, + "right_operand": right, + "scale_factor": factor, + "complexity": complexity_meta or _default_complexity("scaled_field_comparison"), + "declarative_friendly": False if declarative_friendly is None else declarative_friendly, + "tag": tag, + "severity": severity, + "perl_logic": perl_logic.strip(), + } + + affine_match = AFFINE_FIELD_COMPARE_RE.search(perl_logic) + if affine_match: + left = affine_match.group("left") + operator = affine_match.group("op") + right = affine_match.group("right") + factor = float(affine_match.group("factor")) + offset = float(affine_match.group("offset")) + if affine_match.group("sign") == "-": + offset *= -1.0 + offset_sign = "+" if offset >= 0 else "-" + offset_abs = abs(offset) + condition = f"{left} {operator} ({factor} * {right} {offset_sign} {offset_abs})" + return { + "rule_name": rule_name, + "condition": condition, + "duckdb_condition": condition, + "condition_type": "affine_field_comparison", + "left_operand": left, + "operator": operator, + "right_operand": right, + "scale_factor": factor, + "offset": offset, + "complexity": complexity_meta or _default_complexity("affine_field_comparison"), + "declarative_friendly": False if declarative_friendly is None else declarative_friendly, + "tag": tag, + "severity": severity, + "perl_logic": perl_logic.strip(), + } + + sum_match = SUM_FIELDS_COMPARE_RE.search(perl_logic) + if sum_match: + left_a = sum_match.group("left_a") + left_b = sum_match.group("left_b") + operator = sum_match.group("op") + right = sum_match.group("right") + offset = float(sum_match.group("offset")) + if sum_match.group("sign") == "-": + offset *= -1.0 + offset_sign = "+" if offset >= 0 else "-" + offset_abs = abs(offset) + condition = f"({left_a} + {left_b}) {operator} ({right} {offset_sign} {offset_abs})" + return { + "rule_name": rule_name, + "condition": condition, + "duckdb_condition": condition, + "condition_type": "sum_fields_comparison", + "left_operands": [left_a, left_b], + "operator": operator, + "right_operand": right, + "right_offset": offset, + "left_operand": None, + "complexity": complexity_meta or _default_complexity("sum_fields_comparison"), + "declarative_friendly": True if declarative_friendly is None else declarative_friendly, + "tag": tag, + "severity": severity, + "perl_logic": perl_logic.strip(), + } + + if "&&" in perl_logic: + condition_match = IF_CONDITION_RE.search(perl_logic) + if condition_match: + condition_body = condition_match.group("condition").strip() + clauses: List[Dict[str, object]] = [] + for part in [token.strip() for token in condition_body.split("&&")]: + clause_match = THRESHOLD_CLAUSE_RE.match(part) + if not clause_match: + clauses = [] + break + clauses.append( + { + "left_operand": clause_match.group("left"), + "operator": clause_match.group("op"), + "right_operand": float(clause_match.group("right")), + } + ) + if clauses: + duckdb_condition = " AND ".join( + f"{clause['left_operand']} {clause['operator']} {clause['right_operand']}" for clause in clauses + ) + condition = " && ".join( + f"{clause['left_operand']} {clause['operator']} {clause['right_operand']}" for clause in clauses + ) + return { + "rule_name": rule_name, + "condition": condition, + "duckdb_condition": duckdb_condition, + "condition_type": "compound_threshold_and", + "clauses": clauses, + "left_operand": None, + "operator": "&&", + "right_operand": None, + "complexity": complexity_meta or _default_complexity("compound_threshold_and"), + "declarative_friendly": True if declarative_friendly is None else declarative_friendly, + "tag": tag, + "severity": severity, + "perl_logic": perl_logic.strip(), + } + + var_match = VAR_COMPARE_RE.search(perl_logic) + if var_match: + left = var_match.group("left") + operator = var_match.group("op") + right = var_match.group("right") + condition = f"{left} {operator} {right}" + return { + "rule_name": rule_name, + "condition": condition, + "duckdb_condition": condition, + "condition_type": "field_comparison", + "left_operand": left, + "operator": operator, + "right_operand": right, + "complexity": complexity_meta or _default_complexity("field_comparison"), + "declarative_friendly": True if declarative_friendly is None else declarative_friendly, + "tag": tag, + "severity": severity, + "perl_logic": perl_logic.strip(), + } + + value_match = VALUE_COMPARE_RE.search(perl_logic) + if value_match: + left = value_match.group("left") + operator = value_match.group("op") + right = value_match.group("right") + condition = f"{left} {operator} {right}" + return { + "rule_name": rule_name, + "condition": condition, + "duckdb_condition": condition, + "condition_type": "field_threshold", + "left_operand": left, + "operator": operator, + "right_operand": float(right), + "complexity": complexity_meta or _default_complexity("field_threshold"), + "declarative_friendly": True if declarative_friendly is None else declarative_friendly, + "tag": tag, + "severity": severity, + "perl_logic": perl_logic.strip(), + } + + raise ValueError(f"Unsupported Perl condition format:\n{perl_logic}") + + +def extract_rules(perl_snippets: Sequence[str] | str) -> List[Dict[str, object]]: + """Extract structured rules from Perl snippets.""" + snippets: Iterable[str] + if isinstance(perl_snippets, str): + snippets = [chunk.strip() for chunk in perl_snippets.split("\n\n") if chunk.strip()] + else: + snippets = perl_snippets + return [_attach_rule_ir(extract_rule(snippet)) for snippet in snippets] diff --git a/OFF_DataQuality/inspect_duckdb.py b/OFF_DataQuality/inspect_duckdb.py new file mode 100644 index 0000000000000000000000000000000000000000..d7e9c6ee9ee03a267da91d0b736d714c9a6f974f --- /dev/null +++ b/OFF_DataQuality/inspect_duckdb.py @@ -0,0 +1,6 @@ +import duckdb + +print('module', duckdb) +print('attrs', dir(duckdb)) +print('has_connect', 'connect' in dir(duckdb)) +print('location', getattr(duckdb, '__file__', None)) diff --git a/OFF_DataQuality/llm-test/test_groq.py b/OFF_DataQuality/llm-test/test_groq.py new file mode 100644 index 0000000000000000000000000000000000000000..a55932be5ead18f7b5449fd071643cec4dcdaf8a --- /dev/null +++ b/OFF_DataQuality/llm-test/test_groq.py @@ -0,0 +1,26 @@ +import os + +from openai import OpenAI + + +def main() -> None: + api_key = os.getenv("GROQ_API_KEY") + if not api_key: + raise RuntimeError("GROQ_API_KEY is not set. Set it in your shell before running.") + + client = OpenAI( + api_key=api_key, + base_url="https://api.groq.com/openai/v1", + ) + + response = client.chat.completions.create( + model="openai/gpt-oss-120b", + messages=[{"role": "user", "content": "Explain quantum tunnelling in one paragraph"}], + temperature=0.7, + max_tokens=500, + ) + print(response.choices[0].message.content) + + +if __name__ == "__main__": + main() diff --git a/OFF_DataQuality/migration/__init__.py b/OFF_DataQuality/migration/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/OFF_DataQuality/migration/llm_converter.py b/OFF_DataQuality/migration/llm_converter.py new file mode 100644 index 0000000000000000000000000000000000000000..b2b0cad5ec7d9220492ca0219e1c4634687925da --- /dev/null +++ b/OFF_DataQuality/migration/llm_converter.py @@ -0,0 +1,714 @@ +"""LLM-style conversion from structured rules to Python check code.""" +from __future__ import annotations + +import json +import os +import re +from dataclasses import asdict, dataclass +from typing import Dict, List, Sequence + + +@dataclass(frozen=True) +class ConversionResult: + rule_name: str + function_name: str + python_code: str + llm_confidence: float + conversion_notes: str + provider: str + + +def _safe_identifier(name: str) -> str: + sanitized = re.sub(r"[^a-zA-Z0-9_]", "_", name).strip("_") + if not sanitized: + sanitized = "generated_rule" + if sanitized[0].isdigit(): + sanitized = f"rule_{sanitized}" + return sanitized + + +def _python_literal(value: object) -> str: + if isinstance(value, str): + return repr(value) + if isinstance(value, (int, float)): + return str(value) + if value is None: + return "None" + return repr(str(value)) + + +def _confidence_for_rule(rule: Dict[str, object]) -> float: + condition_type = str(rule.get("condition_type", "")) + if condition_type == "field_comparison": + return 0.98 + if condition_type == "field_threshold": + return 0.96 + if condition_type == "missing_field": + return 0.93 + if condition_type == "sum_fields_comparison": + return 0.91 + if condition_type == "compound_threshold_and": + return 0.90 + if condition_type == "affine_field_comparison": + return 0.89 + if condition_type == "scaled_field_comparison": + return 0.88 + return 0.80 + + +def _build_python_code(rule: Dict[str, object], function_name: str) -> str: + tag_literal = _python_literal(rule["tag"]) + condition_type = str(rule.get("condition_type")) + + if condition_type == "field_comparison": + left = str(rule["left_operand"]) + right = str(rule["right_operand"]) + operator = str(rule["operator"]) + return f"""def {function_name}(product): + left_raw = product.get({left!r}) + right_raw = product.get({right!r}) + try: + left_value = float(left_raw) + right_value = float(right_raw) + except (TypeError, ValueError): + return None + if left_value {operator} right_value: + return {tag_literal} + return None +""" + + if condition_type == "field_threshold": + left = str(rule["left_operand"]) + operator = str(rule["operator"]) + right_literal = _python_literal(rule["right_operand"]) + return f"""def {function_name}(product): + left_raw = product.get({left!r}) + try: + left_value = float(left_raw) + except (TypeError, ValueError): + return None + if left_value {operator} {right_literal}: + return {tag_literal} + return None +""" + + if condition_type == "missing_field": + field = str(rule["left_operand"]) + return f"""def {function_name}(product): + value = product.get({field!r}) + if value is None or str(value).strip() == "": + return {tag_literal} + return None +""" + + if condition_type == "scaled_field_comparison": + left = str(rule["left_operand"]) + right = str(rule["right_operand"]) + operator = str(rule["operator"]) + factor = float(rule["scale_factor"]) + return f"""def {function_name}(product): + left_raw = product.get({left!r}) + right_raw = product.get({right!r}) + try: + left_value = float(left_raw) + right_value = float(right_raw) + except (TypeError, ValueError): + return None + scaled_value = right_value * {factor} + if left_value {operator} scaled_value: + return {tag_literal} + return None +""" + + if condition_type == "compound_threshold_and": + clauses = list(rule.get("clauses", [])) + lines = [ + f"def {function_name}(product):", + " try:", + ] + for idx, clause in enumerate(clauses): + field = str(clause["left_operand"]) + lines.append(f" value_{idx} = float(product.get({field!r}))") + lines.append(" except (TypeError, ValueError):") + lines.append(" return None") + checks: List[str] = [] + for idx, clause in enumerate(clauses): + operator = str(clause["operator"]) + threshold = float(clause["right_operand"]) + checks.append(f"(value_{idx} {operator} {threshold})") + joined = " and ".join(checks) if checks else "False" + lines.append(f" if {joined}:") + lines.append(f" return {tag_literal}") + lines.append(" return None") + return "\n".join(lines) + "\n" + + if condition_type == "affine_field_comparison": + left = str(rule["left_operand"]) + right = str(rule["right_operand"]) + operator = str(rule["operator"]) + factor = float(rule["scale_factor"]) + offset = float(rule["offset"]) + return f"""def {function_name}(product): + left_raw = product.get({left!r}) + right_raw = product.get({right!r}) + try: + left_value = float(left_raw) + right_value = float(right_raw) + except (TypeError, ValueError): + return None + target = ({factor} * right_value) + ({offset}) + if left_value {operator} target: + return {tag_literal} + return None +""" + + if condition_type == "sum_fields_comparison": + left_operands = list(rule.get("left_operands", [])) + if len(left_operands) != 2: + raise ValueError("sum_fields_comparison requires exactly two left_operands.") + left_a = str(left_operands[0]) + left_b = str(left_operands[1]) + right = str(rule["right_operand"]) + operator = str(rule["operator"]) + right_offset = float(rule["right_offset"]) + return f"""def {function_name}(product): + left_a_raw = product.get({left_a!r}) + left_b_raw = product.get({left_b!r}) + right_raw = product.get({right!r}) + try: + left_a_value = float(left_a_raw) + left_b_value = float(left_b_raw) + right_value = float(right_raw) + except (TypeError, ValueError): + return None + left_sum = left_a_value + left_b_value + right_target = right_value + ({right_offset}) + if left_sum {operator} right_target: + return {tag_literal} + return None +""" + + raise ValueError(f"Unsupported condition type: {condition_type}") + + +def _extract_code_block(text: str) -> str: + match = re.search(r"```(?:python)?\s*(?P.*?)```", text, re.DOTALL | re.IGNORECASE) + if match: + return match.group("code").strip() + return text.strip() + + +def _validate_generated_code(code: str, function_name: str) -> None: + namespace: Dict[str, object] = {} + exec(code, {}, namespace) + fn = namespace.get(function_name) + if not callable(fn): + raise ValueError(f"Generated code does not define callable `{function_name}`.") + # Basic runtime contract checks to avoid unsafe generated code. + probe_products = [ + {}, + { + "energy_kj": None, + "energy_kj_computed": None, + "energy_kcal": 100.0, + "fat": None, + "saturated_fat": None, + "carbohydrates": None, + "sugars": None, + "language_code": None, + "ingredients_text_present": None, + "contains_statement_present": None, + "allergen_evidence_present": None, + "fop_threshold_exceeded": None, + "fop_symbol_present": None, + "fop_exempt_proxy": None, + "product_is_prepackaged_proxy": None, + }, + { + "energy_kj": 100.0, + "energy_kj_computed": 100.0, + "energy_kcal": 10.0, + "fat": 10.0, + "saturated_fat": 2.0, + "carbohydrates": 15.0, + "sugars": 5.0, + "language_code": "en", + "ingredients_text_present": 1, + "contains_statement_present": 0, + "allergen_evidence_present": 0, + "fop_threshold_exceeded": 0, + "fop_symbol_present": 0, + "fop_exempt_proxy": 0, + "product_is_prepackaged_proxy": 1, + }, + ] + for product in probe_products: + try: + result = fn(product) + except Exception as exc: # noqa: BLE001 - intentional hard guard for generated code + raise ValueError(f"Generated function raised {exc.__class__.__name__}: {exc}") from exc + if result is not None and not isinstance(result, str): + raise ValueError("Generated function must return str or None.") + + +def _comparison_truth_pairs(operator_token: str) -> tuple[tuple[float, float], tuple[float, float]]: + pairs = { + ">": ((2.0, 1.0), (1.0, 2.0)), + "<": ((1.0, 2.0), (2.0, 1.0)), + ">=": ((2.0, 2.0), (1.0, 2.0)), + "<=": ((2.0, 2.0), (3.0, 2.0)), + "==": ((2.0, 2.0), (2.0, 3.0)), + "!=": ((2.0, 3.0), (2.0, 2.0)), + } + if operator_token not in pairs: + raise ValueError(f"Unsupported comparison operator: {operator_token}") + return pairs[operator_token] + + +def _threshold_truth_values(operator_token: str, threshold: float) -> tuple[float, float]: + if operator_token == ">": + return threshold + 1.0, threshold + if operator_token == "<": + return threshold - 1.0, threshold + if operator_token == ">=": + return threshold, threshold - 1.0 + if operator_token == "<=": + return threshold, threshold + 1.0 + if operator_token == "==": + return threshold, threshold + 1.0 + if operator_token == "!=": + return threshold + 1.0, threshold + raise ValueError(f"Unsupported threshold operator: {operator_token}") + + +def _semantic_test_cases(rule: Dict[str, object]) -> List[tuple[Dict[str, object], str | None, str]]: + condition_type = str(rule.get("condition_type")) + tag = str(rule["tag"]) + + if condition_type == "field_comparison": + left = str(rule["left_operand"]) + right = str(rule["right_operand"]) + operator_token = str(rule["operator"]) + true_pair, false_pair = _comparison_truth_pairs(operator_token) + return [ + ({left: true_pair[0], right: true_pair[1]}, tag, "comparison_true"), + ({left: false_pair[0], right: false_pair[1]}, None, "comparison_false"), + ({left: None, right: true_pair[1]}, None, "comparison_missing_left"), + ({left: true_pair[0], right: None}, None, "comparison_missing_right"), + ({left: "nan_text", right: true_pair[1]}, None, "comparison_non_numeric_left"), + ] + + if condition_type == "field_threshold": + left = str(rule["left_operand"]) + operator_token = str(rule["operator"]) + threshold = float(rule["right_operand"]) + true_value, false_value = _threshold_truth_values(operator_token, threshold) + return [ + ({left: true_value}, tag, "threshold_true"), + ({left: false_value}, None, "threshold_false"), + ({left: None}, None, "threshold_missing"), + ({left: "nan_text"}, None, "threshold_non_numeric"), + ] + + if condition_type == "missing_field": + field = str(rule["left_operand"]) + return [ + ({field: None}, tag, "missing_none"), + ({field: ""}, tag, "missing_empty_string"), + ({field: " "}, tag, "missing_whitespace"), + ({field: "en"}, None, "missing_present"), + ] + + if condition_type == "scaled_field_comparison": + left = str(rule["left_operand"]) + right = str(rule["right_operand"]) + operator_token = str(rule["operator"]) + factor = float(rule["scale_factor"]) + true_right = 10.0 + scaled = true_right * factor + if operator_token == ">": + true_left, false_left = scaled + 1.0, scaled - 1.0 + elif operator_token == ">=": + true_left, false_left = scaled, scaled - 1.0 + elif operator_token == "<": + true_left, false_left = scaled - 1.0, scaled + 1.0 + elif operator_token == "<=": + true_left, false_left = scaled, scaled + 1.0 + elif operator_token == "==": + true_left, false_left = scaled, scaled + 1.0 + elif operator_token == "!=": + true_left, false_left = scaled + 1.0, scaled + else: + raise ValueError(f"Unsupported scaled comparison operator: {operator_token}") + return [ + ({left: true_left, right: true_right}, tag, "scaled_true"), + ({left: false_left, right: true_right}, None, "scaled_false"), + ({left: None, right: true_right}, None, "scaled_missing_left"), + ({left: true_left, right: None}, None, "scaled_missing_right"), + ({left: "nan_text", right: true_right}, None, "scaled_non_numeric"), + ] + + if condition_type == "affine_field_comparison": + left = str(rule["left_operand"]) + right = str(rule["right_operand"]) + operator_token = str(rule["operator"]) + factor = float(rule["scale_factor"]) + offset = float(rule["offset"]) + true_right = 10.0 + target = (factor * true_right) + offset + if operator_token == ">": + true_left, false_left = target + 1.0, target - 1.0 + elif operator_token == ">=": + true_left, false_left = target, target - 1.0 + elif operator_token == "<": + true_left, false_left = target - 1.0, target + 1.0 + elif operator_token == "<=": + true_left, false_left = target, target + 1.0 + elif operator_token == "==": + true_left, false_left = target, target + 1.0 + elif operator_token == "!=": + true_left, false_left = target + 1.0, target + else: + raise ValueError(f"Unsupported affine comparison operator: {operator_token}") + return [ + ({left: true_left, right: true_right}, tag, "affine_true"), + ({left: false_left, right: true_right}, None, "affine_false"), + ({left: None, right: true_right}, None, "affine_missing_left"), + ({left: true_left, right: None}, None, "affine_missing_right"), + ({left: "nan_text", right: true_right}, None, "affine_non_numeric"), + ] + + if condition_type == "sum_fields_comparison": + left_operands = list(rule.get("left_operands", [])) + if len(left_operands) != 2: + raise ValueError("sum_fields_comparison rule must define two left operands.") + left_a = str(left_operands[0]) + left_b = str(left_operands[1]) + right = str(rule["right_operand"]) + operator_token = str(rule["operator"]) + right_offset = float(rule["right_offset"]) + right_value = 20.0 + target = right_value + right_offset + if operator_token == ">": + true_sum, false_sum = target + 1.0, target - 1.0 + elif operator_token == ">=": + true_sum, false_sum = target, target - 1.0 + elif operator_token == "<": + true_sum, false_sum = target - 1.0, target + 1.0 + elif operator_token == "<=": + true_sum, false_sum = target, target + 1.0 + elif operator_token == "==": + true_sum, false_sum = target, target + 1.0 + elif operator_token == "!=": + true_sum, false_sum = target + 1.0, target + else: + raise ValueError(f"Unsupported sum comparison operator: {operator_token}") + + true_a = true_sum / 2.0 + true_b = true_sum - true_a + false_a = false_sum / 2.0 + false_b = false_sum - false_a + return [ + ({left_a: true_a, left_b: true_b, right: right_value}, tag, "sum_true"), + ({left_a: false_a, left_b: false_b, right: right_value}, None, "sum_false"), + ({left_a: None, left_b: true_b, right: right_value}, None, "sum_missing_left_a"), + ({left_a: true_a, left_b: None, right: right_value}, None, "sum_missing_left_b"), + ({left_a: true_a, left_b: true_b, right: None}, None, "sum_missing_right"), + ] + + if condition_type == "compound_threshold_and": + clauses = list(rule.get("clauses", [])) + if not clauses: + raise ValueError("compound_threshold_and rule must define clauses.") + true_product: Dict[str, object] = {} + false_product: Dict[str, object] = {} + missing_product: Dict[str, object] = {} + for idx, clause in enumerate(clauses): + field = str(clause["left_operand"]) + operator_token = str(clause["operator"]) + threshold = float(clause["right_operand"]) + true_value, false_value = _threshold_truth_values(operator_token, threshold) + true_product[field] = true_value + false_product[field] = true_value + missing_product[field] = true_value + if idx == 0: + false_product[field] = false_value + missing_product[field] = None + return [ + (true_product, tag, "compound_true"), + (false_product, None, "compound_false"), + (missing_product, None, "compound_missing"), + ] + + raise ValueError(f"Unsupported condition type for semantic checks: {condition_type}") + + +def _validate_generated_semantics(code: str, function_name: str, rule: Dict[str, object]) -> None: + namespace: Dict[str, object] = {} + exec(code, {}, namespace) + fn = namespace.get(function_name) + if not callable(fn): + raise ValueError(f"Generated code does not define callable `{function_name}`.") + + for product, expected, case_name in _semantic_test_cases(rule): + try: + result = fn(product) + except Exception as exc: # noqa: BLE001 + raise ValueError(f"Semantic test `{case_name}` raised {exc.__class__.__name__}: {exc}") from exc + if result != expected: + raise ValueError( + f"Semantic test `{case_name}` failed: expected {expected!r}, got {result!r}." + ) + + +def _normalize_function_name(code: str, function_name: str) -> str: + """Rename the first generated function to the expected runtime name.""" + match = re.search(r"def\s+(?P[a-zA-Z_]\w*)\s*\(", code) + if not match: + return code + found_name = match.group("name") + if found_name == function_name: + return code + start, end = match.span("name") + return code[:start] + function_name + code[end:] + + +def _build_llm_prompt(rule: Dict[str, object], function_name: str) -> str: + rule_payload = { + "rule_name": rule["rule_name"], + "tag": rule["tag"], + "condition_type": rule["condition_type"], + "condition": rule.get("condition"), + "duckdb_condition": rule.get("duckdb_condition"), + "left_operand": rule.get("left_operand"), + "left_operands": rule.get("left_operands"), + "operator": rule.get("operator"), + "right_operand": rule.get("right_operand"), + "scale_factor": rule.get("scale_factor"), + "offset": rule.get("offset"), + "right_offset": rule.get("right_offset"), + "clauses": rule.get("clauses"), + "complexity": rule.get("complexity"), + } + examples: List[Dict[str, object]] = [] + for product, expected, case_name in _semantic_test_cases(rule): + examples.append({"case": case_name, "input": product, "expected": expected}) + return ( + "Generate one Python function for a data-quality rule.\n" + f"Function name must be exactly: {function_name}\n" + "Input: product (dict)\n" + "Output: return the rule tag string if the VIOLATION condition is TRUE; else return None.\n" + "Important: do NOT invert the condition.\n" + "Important: return only Python code, no markdown, no explanation.\n" + "Behavior requirements:\n" + "- field_comparison and field_threshold rules: if value is missing/non-numeric, return None.\n" + '- missing_field rule: None, empty string "", or whitespace-only string => return tag.\n' + "- Otherwise return None.\n" + f"Rule JSON: {json.dumps(rule_payload)}\n" + f"Validation examples (must pass): {json.dumps(examples)}" + ) + + +def _build_llm_repair_prompt( + rule: Dict[str, object], + function_name: str, + previous_code: str, + error_message: str, +) -> str: + return ( + "Your previous function failed validator checks.\n" + f"Validation error: {error_message}\n" + "Fix the function so all examples pass.\n" + "Return only corrected Python code.\n" + f"Previous code:\n{previous_code}\n\n" + f"{_build_llm_prompt(rule, function_name)}" + ) + + +def _call_groq( + rule: Dict[str, object], + function_name: str, + model: str, + prompt: str | None = None, +) -> str: + api_key = os.getenv("GROQ_API_KEY") + if not api_key: + raise RuntimeError("GROQ_API_KEY is not set.") + + try: + from openai import OpenAI + except Exception as exc: # noqa: BLE001 + raise RuntimeError("openai package is required for Groq provider.") from exc + + endpoint = os.getenv("GROQ_ENDPOINT", "https://api.groq.com/openai/v1") + client = OpenAI(api_key=api_key, base_url=endpoint) + response = client.chat.completions.create( + model=model, + messages=[ + {"role": "system", "content": "You are a strict Python code generator for data quality rules."}, + {"role": "user", "content": prompt or _build_llm_prompt(rule, function_name)}, + ], + temperature=0.0, + ) + content = response.choices[0].message.content + if not isinstance(content, str): + content = str(content) + return _extract_code_block(content) + + +def convert_rule_to_python( + rule: Dict[str, object], + provider: str = "groq", + model: str | None = None, +) -> ConversionResult: + """Convert one structured rule to Python code and confidence metadata.""" + function_name = f"check_{_safe_identifier(str(rule['rule_name']))}" + confidence = _confidence_for_rule(rule) + provider_used = provider + + if provider == "groq": + strict_llm = os.getenv("LLM_STRICT", "0").strip().lower() in {"1", "true", "yes", "on"} + chosen_model = model or os.getenv("GROQ_MODEL", "openai/gpt-oss-120b") + first_attempt_code = "" + try: + python_code = _call_groq(rule, function_name=function_name, model=chosen_model) + first_attempt_code = python_code + python_code = _normalize_function_name(python_code, function_name=function_name) + _validate_generated_code(python_code, function_name=function_name) + _validate_generated_semantics(python_code, function_name=function_name, rule=rule) + notes = f"Converted via Groq ({chosen_model})." + confidence = min(0.99, confidence + 0.01) + except ( + RuntimeError, + ValueError, + TypeError, + json.JSONDecodeError, + TimeoutError, + ) as exc: + repair_exc: Exception | None = None + try: + repair_prompt = _build_llm_repair_prompt( + rule=rule, + function_name=function_name, + previous_code=first_attempt_code or "# no usable code returned in first attempt", + error_message=f"{exc.__class__.__name__}: {exc}", + ) + python_code = _call_groq( + rule, + function_name=function_name, + model=chosen_model, + prompt=repair_prompt, + ) + python_code = _normalize_function_name(python_code, function_name=function_name) + _validate_generated_code(python_code, function_name=function_name) + _validate_generated_semantics(python_code, function_name=function_name, rule=rule) + notes = f"Converted via Groq ({chosen_model}) after repair pass." + confidence = min(0.99, confidence + 0.005) + except ( + RuntimeError, + ValueError, + TypeError, + json.JSONDecodeError, + TimeoutError, + ) as second_exc: + repair_exc = second_exc + + if repair_exc is not None: + if strict_llm: + raise RuntimeError( + f"Groq conversion failed and LLM_STRICT=1 is enabled. " + f"First error: {exc.__class__.__name__}: {exc} | " + f"Repair error: {repair_exc.__class__.__name__}: {repair_exc}" + ) from repair_exc + python_code = _build_python_code(rule, function_name=function_name) + _validate_generated_code(python_code, function_name=function_name) + _validate_generated_semantics(python_code, function_name=function_name, rule=rule) + notes = ( + f"Groq conversion failed after retry " + f"(first: {exc.__class__.__name__}: {exc}; " + f"retry: {repair_exc.__class__.__name__}: {repair_exc}). " + "Fell back to deterministic converter." + ) + provider_used = "simulated_fallback" + confidence = max(0.70, confidence - 0.05) + else: + if provider not in {"simulated", "simulated_fallback"}: + provider_used = "simulated_fallback" + python_code = _build_python_code(rule, function_name=function_name) + _validate_generated_code(python_code, function_name=function_name) + _validate_generated_semantics(python_code, function_name=function_name, rule=rule) + notes = f"Converted {rule['condition_type']} rule using deterministic template." + + return ConversionResult( + rule_name=str(rule["rule_name"]), + function_name=function_name, + python_code=python_code, + llm_confidence=confidence, + conversion_notes=notes, + provider=provider_used, + ) + + +def _build_counterexample_repair_prompt( + rule: Dict[str, object], + function_name: str, + previous_code: str, + counterexamples: Sequence[Dict[str, object]], +) -> str: + limited = list(counterexamples)[:5] + return ( + "Your previous code fails equivalence against legacy Perl behavior.\n" + "Fix the function using these concrete failing examples.\n" + "Return only Python code.\n" + f"Function name must remain: {function_name}\n" + f"Counterexamples: {json.dumps(limited)}\n" + f"Previous code:\n{previous_code}\n\n" + f"{_build_llm_prompt(rule, function_name)}" + ) + + +def repair_conversion_with_counterexamples( + rule: Dict[str, object], + converted_rule: Dict[str, object], + counterexamples: Sequence[Dict[str, object]], + provider: str = "groq", + model: str | None = None, +) -> Dict[str, object]: + """Attempt counterexample-driven repair for an already converted rule.""" + if provider != "groq": + return dict(converted_rule) + if not counterexamples: + return dict(converted_rule) + + function_name = str(converted_rule["function_name"]) + previous_code = str(converted_rule["python_code"]) + chosen_model = model or os.getenv("GROQ_MODEL", "openai/gpt-oss-120b") + repair_prompt = _build_counterexample_repair_prompt( + rule=rule, + function_name=function_name, + previous_code=previous_code, + counterexamples=counterexamples, + ) + repaired_code = _call_groq(rule, function_name=function_name, model=chosen_model, prompt=repair_prompt) + repaired_code = _normalize_function_name(repaired_code, function_name=function_name) + _validate_generated_code(repaired_code, function_name=function_name) + _validate_generated_semantics(repaired_code, function_name=function_name, rule=rule) + + repaired = dict(converted_rule) + repaired["python_code"] = repaired_code + repaired["provider"] = "groq" + repaired["llm_confidence"] = min(0.99, float(converted_rule.get("llm_confidence", 0.9)) + 0.01) + repaired["conversion_notes"] = ( + f"{converted_rule.get('conversion_notes', '')} " + "Counterexample-driven Groq repair applied." + ).strip() + return repaired + + +def convert_rules( + rules: Sequence[Dict[str, object]], + provider: str = "groq", + model: str | None = None, +) -> List[Dict[str, object]]: + """Batch convert structured rules to generated Python snippets.""" + return [asdict(convert_rule_to_python(rule, provider=provider, model=model)) for rule in rules] diff --git a/OFF_DataQuality/perl_checks/__init__.py b/OFF_DataQuality/perl_checks/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/OFF_DataQuality/perl_checks/legacy_checks.py b/OFF_DataQuality/perl_checks/legacy_checks.py new file mode 100644 index 0000000000000000000000000000000000000000..059f2cd7236d65b7a34d9dcfbab2dc831676c621 --- /dev/null +++ b/OFF_DataQuality/perl_checks/legacy_checks.py @@ -0,0 +1,590 @@ +"""Simulated legacy Perl checks for migration parity testing.""" +from __future__ import annotations + +from dataclasses import dataclass +from pathlib import Path +from typing import Callable, Dict, List, Mapping, Sequence, Set + +Product = Mapping[str, object] + + +@dataclass(frozen=True) +class LegacyRule: + rule_name: str + tag: str + severity: str + condition: str + duckdb_condition: str + complexity: str + declarative_friendly: bool + perl_logic: str + evaluator: Callable[[Product], bool] + + +def _to_float(value: object) -> float | None: + if value is None: + return None + try: + return float(value) + except (TypeError, ValueError): + return None + + +def _greater_than(left_value: object, right_value: object) -> bool: + left = _to_float(left_value) + right = _to_float(right_value) + return left is not None and right is not None and left > right + + +def _greater_than_plus_offset(left_value: object, right_value: object, offset: float) -> bool: + left = _to_float(left_value) + right = _to_float(right_value) + return left is not None and right is not None and left > (right + offset) + + +def _affine_compare( + left_value: object, + right_value: object, + operator: str, + factor: float, + offset: float, +) -> bool: + left = _to_float(left_value) + right = _to_float(right_value) + if left is None or right is None: + return False + target = (factor * right) + offset + if operator == ">": + return left > target + if operator == "<": + return left < target + if operator == ">=": + return left >= target + if operator == "<=": + return left <= target + if operator == "==": + return left == target + if operator == "!=": + return left != target + return False + + +def _sum_compare( + left_a: object, + left_b: object, + operator: str, + right: object, + right_offset: float, +) -> bool: + left_a_num = _to_float(left_a) + left_b_num = _to_float(left_b) + right_num = _to_float(right) + if left_a_num is None or left_b_num is None or right_num is None: + return False + left_sum = left_a_num + left_b_num + right_value = right_num + right_offset + if operator == ">": + return left_sum > right_value + if operator == "<": + return left_sum < right_value + if operator == ">=": + return left_sum >= right_value + if operator == "<=": + return left_sum <= right_value + if operator == "==": + return left_sum == right_value + if operator == "!=": + return left_sum != right_value + return False + + +def _is_missing(value: object) -> bool: + return value is None or str(value).strip() == "" + + +def _compare_values(left_value: object, operator: str, right_value: object) -> bool: + left = _to_float(left_value) + right = _to_float(right_value) + if left is None or right is None: + return False + if operator == ">": + return left > right + if operator == "<": + return left < right + if operator == ">=": + return left >= right + if operator == "<=": + return left <= right + if operator == "==": + return left == right + if operator == "!=": + return left != right + return False + + +LEGACY_RULES: List[LegacyRule] = [ + LegacyRule( + rule_name="energy_kcal_vs_kj", + tag="energy-value-in-kcal-greater-than-in-kj", + severity="error", + condition="energy_kcal > energy_kj", + duckdb_condition="energy_kcal > energy_kj", + complexity="simple", + declarative_friendly=True, + perl_logic=""" +# RULE_NAME: energy_kcal_vs_kj +# SEVERITY: error +# COMPLEXITY: simple +# DECLARATIVE_FRIENDLY: yes +if ($energy_kcal > $energy_kj) { + push @{$product_ref->{$data_quality_tags}}, "energy-value-in-kcal-greater-than-in-kj"; +} +""".strip(), + evaluator=lambda product: _greater_than(product.get("energy_kcal"), product.get("energy_kj")), + ), + LegacyRule( + rule_name="energy_kj_mismatch_low", + tag="energy-value-in-kcal-does-not-match-value-in-kj-low", + severity="error", + condition="energy_kj < (3.7 * energy_kcal - 2)", + duckdb_condition="energy_kj < (3.7 * energy_kcal - 2)", + complexity="intricate", + declarative_friendly=False, + perl_logic=""" +# RULE_NAME: energy_kj_mismatch_low +# SEVERITY: error +# COMPLEXITY: intricate +# DECLARATIVE_FRIENDLY: no +if ($energy_kj < (3.7 * $energy_kcal - 2)) { + push @{$product_ref->{$data_quality_tags}}, "energy-value-in-kcal-does-not-match-value-in-kj-low"; +} +""".strip(), + evaluator=lambda product: _affine_compare( + product.get("energy_kj"), + product.get("energy_kcal"), + operator="<", + factor=3.7, + offset=-2.0, + ), + ), + LegacyRule( + rule_name="energy_kj_mismatch_high", + tag="energy-value-in-kcal-does-not-match-value-in-kj-high", + severity="error", + condition="energy_kj > (4.7 * energy_kcal + 2)", + duckdb_condition="energy_kj > (4.7 * energy_kcal + 2)", + complexity="intricate", + declarative_friendly=False, + perl_logic=""" +# RULE_NAME: energy_kj_mismatch_high +# SEVERITY: error +# COMPLEXITY: intricate +# DECLARATIVE_FRIENDLY: no +if ($energy_kj > (4.7 * $energy_kcal + 2)) { + push @{$product_ref->{$data_quality_tags}}, "energy-value-in-kcal-does-not-match-value-in-kj-high"; +} +""".strip(), + evaluator=lambda product: _affine_compare( + product.get("energy_kj"), + product.get("energy_kcal"), + operator=">", + factor=4.7, + offset=2.0, + ), + ), + LegacyRule( + rule_name="energy_kj_over_3911", + tag="value-over-3911-energy", + severity="error", + condition="energy_kj > 3911", + duckdb_condition="energy_kj > 3911", + complexity="simple", + declarative_friendly=True, + perl_logic=""" +# RULE_NAME: energy_kj_over_3911 +# SEVERITY: error +# COMPLEXITY: simple +# DECLARATIVE_FRIENDLY: yes +if ($energy_kj > 3911) { + push @{$product_ref->{$data_quality_tags}}, "value-over-3911-energy"; +} +""".strip(), + evaluator=lambda product: _greater_than(product.get("energy_kj"), 3911), + ), + LegacyRule( + rule_name="energy_kj_computed_mismatch_low", + tag="energy-value-in-kj-does-not-match-value-computed-from-other-nutrients-low", + severity="error", + condition="energy_kj_computed < (0.7 * energy_kj - 5)", + duckdb_condition="energy_kj_computed < (0.7 * energy_kj - 5)", + complexity="intricate", + declarative_friendly=False, + perl_logic=""" +# RULE_NAME: energy_kj_computed_mismatch_low +# SEVERITY: error +# COMPLEXITY: intricate +# DECLARATIVE_FRIENDLY: no +if ($energy_kj_computed < (0.7 * $energy_kj - 5)) { + push @{$product_ref->{$data_quality_tags}}, "energy-value-in-kj-does-not-match-value-computed-from-other-nutrients-low"; +} +""".strip(), + evaluator=lambda product: _affine_compare( + product.get("energy_kj_computed"), + product.get("energy_kj"), + operator="<", + factor=0.7, + offset=-5.0, + ), + ), + LegacyRule( + rule_name="energy_kj_computed_mismatch_high", + tag="energy-value-in-kj-does-not-match-value-computed-from-other-nutrients-high", + severity="error", + condition="energy_kj_computed > (1.3 * energy_kj + 5)", + duckdb_condition="energy_kj_computed > (1.3 * energy_kj + 5)", + complexity="intricate", + declarative_friendly=False, + perl_logic=""" +# RULE_NAME: energy_kj_computed_mismatch_high +# SEVERITY: error +# COMPLEXITY: intricate +# DECLARATIVE_FRIENDLY: no +if ($energy_kj_computed > (1.3 * $energy_kj + 5)) { + push @{$product_ref->{$data_quality_tags}}, "energy-value-in-kj-does-not-match-value-computed-from-other-nutrients-high"; +} +""".strip(), + evaluator=lambda product: _affine_compare( + product.get("energy_kj_computed"), + product.get("energy_kj"), + operator=">", + factor=1.3, + offset=5.0, + ), + ), + LegacyRule( + rule_name="saturated_fat_vs_fat", + tag="saturated-fat-greater-than-fat", + severity="error", + condition="saturated_fat > (1 * fat + 0.001)", + duckdb_condition="saturated_fat > (1 * fat + 0.001)", + complexity="simple", + declarative_friendly=True, + perl_logic=""" +# RULE_NAME: saturated_fat_vs_fat +# SEVERITY: error +# COMPLEXITY: simple +# DECLARATIVE_FRIENDLY: yes +if ($saturated_fat > (1 * $fat + 0.001)) { + push @{$product_ref->{$data_quality_tags}}, "saturated-fat-greater-than-fat"; +} +""".strip(), + evaluator=lambda product: _greater_than_plus_offset(product.get("saturated_fat"), product.get("fat"), 0.001), + ), + LegacyRule( + rule_name="sugars_plus_starch_vs_carbohydrates", + tag="sugars-plus-starch-greater-than-carbohydrates", + severity="error", + condition="(sugars + starch) > (carbohydrates + 0.001)", + duckdb_condition="(sugars + starch) > (carbohydrates + 0.001)", + complexity="medium", + declarative_friendly=True, + perl_logic=""" +# RULE_NAME: sugars_plus_starch_vs_carbohydrates +# SEVERITY: error +# COMPLEXITY: medium +# DECLARATIVE_FRIENDLY: yes +if (($sugars + $starch) > ($carbohydrates + 0.001)) { + push @{$product_ref->{$data_quality_tags}}, "sugars-plus-starch-greater-than-carbohydrates"; +} +""".strip(), + evaluator=lambda product: _sum_compare( + product.get("sugars"), + product.get("starch"), + operator=">", + right=product.get("carbohydrates"), + right_offset=0.001, + ), + ), + LegacyRule( + rule_name="fat_over_105g", + tag="fat-value-over-105g", + severity="warning", + condition="fat > 105", + duckdb_condition="fat > 105", + complexity="simple", + declarative_friendly=True, + perl_logic=""" +# RULE_NAME: fat_over_105g +# SEVERITY: warning +# COMPLEXITY: simple +# DECLARATIVE_FRIENDLY: yes +if ($fat > 105) { + push @{$product_ref->{$data_quality_tags}}, "fat-value-over-105g"; +} +""".strip(), + evaluator=lambda product: _greater_than(product.get("fat"), 105), + ), + LegacyRule( + rule_name="saturated_fat_over_105g", + tag="saturated-fat-value-over-105g", + severity="warning", + condition="saturated_fat > 105", + duckdb_condition="saturated_fat > 105", + complexity="simple", + declarative_friendly=True, + perl_logic=""" +# RULE_NAME: saturated_fat_over_105g +# SEVERITY: warning +# COMPLEXITY: simple +# DECLARATIVE_FRIENDLY: yes +if ($saturated_fat > 105) { + push @{$product_ref->{$data_quality_tags}}, "saturated-fat-value-over-105g"; +} +""".strip(), + evaluator=lambda product: _greater_than(product.get("saturated_fat"), 105), + ), + LegacyRule( + rule_name="carbohydrates_over_105g", + tag="carbohydrates-value-over-105g", + severity="warning", + condition="carbohydrates > 105", + duckdb_condition="carbohydrates > 105", + complexity="simple", + declarative_friendly=True, + perl_logic=""" +# RULE_NAME: carbohydrates_over_105g +# SEVERITY: warning +# COMPLEXITY: simple +# DECLARATIVE_FRIENDLY: yes +if ($carbohydrates > 105) { + push @{$product_ref->{$data_quality_tags}}, "carbohydrates-value-over-105g"; +} +""".strip(), + evaluator=lambda product: _greater_than(product.get("carbohydrates"), 105), + ), + LegacyRule( + rule_name="sugars_over_105g", + tag="sugars-value-over-105g", + severity="warning", + condition="sugars > 105", + duckdb_condition="sugars > 105", + complexity="simple", + declarative_friendly=True, + perl_logic=""" +# RULE_NAME: sugars_over_105g +# SEVERITY: warning +# COMPLEXITY: simple +# DECLARATIVE_FRIENDLY: yes +if ($sugars > 105) { + push @{$product_ref->{$data_quality_tags}}, "sugars-value-over-105g"; +} +""".strip(), + evaluator=lambda product: _greater_than(product.get("sugars"), 105), + ), + LegacyRule( + rule_name="main_language_code_missing", + tag="main-language-code-missing", + severity="bug", + condition="missing(lc)", + duckdb_condition="lc IS NULL OR TRIM(lc) = ''", + complexity="simple", + declarative_friendly=True, + perl_logic=""" +# RULE_NAME: main_language_code_missing +# SEVERITY: bug +# COMPLEXITY: simple +# DECLARATIVE_FRIENDLY: yes +if (!defined $lc || $lc eq "") { + push @{$product_ref->{$data_quality_tags}}, "main-language-code-missing"; +} +""".strip(), + evaluator=lambda product: _is_missing(product.get("lc")), + ), + LegacyRule( + rule_name="main_language_missing", + tag="main-language-missing", + severity="bug", + condition="missing(lang)", + duckdb_condition="lang IS NULL OR TRIM(lang) = ''", + complexity="simple", + declarative_friendly=True, + perl_logic=""" +# RULE_NAME: main_language_missing +# SEVERITY: bug +# COMPLEXITY: simple +# DECLARATIVE_FRIENDLY: yes +if (!defined $lang || $lang eq "") { + push @{$product_ref->{$data_quality_tags}}, "main-language-missing"; +} + """.strip(), + evaluator=lambda product: _is_missing(product.get("lang")), + ), + LegacyRule( + rule_name="ca_allergen_evidence_missing_ingredients_text", + tag="ca-allergen-evidence-but-missing-ingredients-text", + severity="warning", + condition="allergen_evidence_present > 0 && ingredients_text_present == 0", + duckdb_condition="allergen_evidence_present > 0 AND ingredients_text_present == 0", + complexity="medium", + declarative_friendly=True, + perl_logic=""" +# RULE_NAME: ca_allergen_evidence_missing_ingredients_text +# SEVERITY: warning +# COMPLEXITY: medium +# DECLARATIVE_FRIENDLY: yes +if (($allergen_evidence_present > 0) && ($ingredients_text_present == 0)) { + push @{$product_ref->{$data_quality_tags}}, "ca-allergen-evidence-but-missing-ingredients-text"; +} +""".strip(), + evaluator=lambda product: ( + _compare_values(product.get("allergen_evidence_present"), ">", 0) + and _compare_values(product.get("ingredients_text_present"), "==", 0) + ), + ), + LegacyRule( + rule_name="ca_contains_statement_without_allergen_evidence", + tag="ca-contains-statement-without-allergen-evidence", + severity="warning", + condition="contains_statement_present > 0 && allergen_evidence_present == 0", + duckdb_condition="contains_statement_present > 0 AND allergen_evidence_present == 0", + complexity="medium", + declarative_friendly=True, + perl_logic=""" +# RULE_NAME: ca_contains_statement_without_allergen_evidence +# SEVERITY: warning +# COMPLEXITY: medium +# DECLARATIVE_FRIENDLY: yes +if (($contains_statement_present > 0) && ($allergen_evidence_present == 0)) { + push @{$product_ref->{$data_quality_tags}}, "ca-contains-statement-without-allergen-evidence"; +} +""".strip(), + evaluator=lambda product: ( + _compare_values(product.get("contains_statement_present"), ">", 0) + and _compare_values(product.get("allergen_evidence_present"), "==", 0) + ), + ), + LegacyRule( + rule_name="ca_fop_required_but_symbol_missing", + tag="ca-fop-required-but-symbol-missing", + severity="error", + condition="fop_threshold_exceeded > 0 && fop_symbol_present == 0 && fop_exempt_proxy == 0 && product_is_prepackaged_proxy > 0", + duckdb_condition=( + "fop_threshold_exceeded > 0 AND fop_symbol_present == 0 " + "AND fop_exempt_proxy == 0 AND product_is_prepackaged_proxy > 0" + ), + complexity="medium", + declarative_friendly=True, + perl_logic=""" +# RULE_NAME: ca_fop_required_but_symbol_missing +# SEVERITY: error +# COMPLEXITY: medium +# DECLARATIVE_FRIENDLY: yes +if (($fop_threshold_exceeded > 0) && ($fop_symbol_present == 0) && ($fop_exempt_proxy == 0) && ($product_is_prepackaged_proxy > 0)) { + push @{$product_ref->{$data_quality_tags}}, "ca-fop-required-but-symbol-missing"; +} +""".strip(), + evaluator=lambda product: ( + _compare_values(product.get("fop_threshold_exceeded"), ">", 0) + and _compare_values(product.get("fop_symbol_present"), "==", 0) + and _compare_values(product.get("fop_exempt_proxy"), "==", 0) + and _compare_values(product.get("product_is_prepackaged_proxy"), ">", 0) + ), + ), + LegacyRule( + rule_name="ca_fop_symbol_present_but_not_required", + tag="ca-fop-symbol-present-but-not-required", + severity="warning", + condition="fop_symbol_present > 0 && fop_threshold_exceeded == 0 && fop_exempt_proxy == 0 && product_is_prepackaged_proxy > 0", + duckdb_condition=( + "fop_symbol_present > 0 AND fop_threshold_exceeded == 0 " + "AND fop_exempt_proxy == 0 AND product_is_prepackaged_proxy > 0" + ), + complexity="medium", + declarative_friendly=True, + perl_logic=""" +# RULE_NAME: ca_fop_symbol_present_but_not_required +# SEVERITY: warning +# COMPLEXITY: medium +# DECLARATIVE_FRIENDLY: yes +if (($fop_symbol_present > 0) && ($fop_threshold_exceeded == 0) && ($fop_exempt_proxy == 0) && ($product_is_prepackaged_proxy > 0)) { + push @{$product_ref->{$data_quality_tags}}, "ca-fop-symbol-present-but-not-required"; +} +""".strip(), + evaluator=lambda product: ( + _compare_values(product.get("fop_symbol_present"), ">", 0) + and _compare_values(product.get("fop_threshold_exceeded"), "==", 0) + and _compare_values(product.get("fop_exempt_proxy"), "==", 0) + and _compare_values(product.get("product_is_prepackaged_proxy"), ">", 0) + ), + ), + LegacyRule( + rule_name="ca_fop_symbol_present_on_exempt_product", + tag="ca-fop-symbol-present-on-exempt-product", + severity="warning", + condition="fop_symbol_present > 0 && fop_exempt_proxy > 0 && product_is_prepackaged_proxy > 0", + duckdb_condition="fop_symbol_present > 0 AND fop_exempt_proxy > 0 AND product_is_prepackaged_proxy > 0", + complexity="medium", + declarative_friendly=True, + perl_logic=""" +# RULE_NAME: ca_fop_symbol_present_on_exempt_product +# SEVERITY: warning +# COMPLEXITY: medium +# DECLARATIVE_FRIENDLY: yes +if (($fop_symbol_present > 0) && ($fop_exempt_proxy > 0) && ($product_is_prepackaged_proxy > 0)) { + push @{$product_ref->{$data_quality_tags}}, "ca-fop-symbol-present-on-exempt-product"; +} +""".strip(), + evaluator=lambda product: ( + _compare_values(product.get("fop_symbol_present"), ">", 0) + and _compare_values(product.get("fop_exempt_proxy"), ">", 0) + and _compare_values(product.get("product_is_prepackaged_proxy"), ">", 0) + ), + ), +] + + +RULE_FILES_DIR = Path(__file__).resolve().parent / "rules" + + +def load_rule_snippets_from_directory(rules_dir: Path = RULE_FILES_DIR) -> List[str]: + snippets: List[str] = [] + for file_path in sorted(rules_dir.glob("*.pl")): + content = file_path.read_text(encoding="utf-8").lstrip("\ufeff").strip() + if content: + snippets.append(content) + if not snippets: + raise ValueError(f"No Perl rule files found in {rules_dir}") + return snippets + + +def get_perl_rule_snippets( + rules: Sequence[LegacyRule] = LEGACY_RULES, + rules_dir: Path | None = None, +) -> List[str]: + if rules_dir is not None: + return load_rule_snippets_from_directory(Path(rules_dir)) + return [rule.perl_logic for rule in rules] + + +def get_legacy_rule_map(rules: Sequence[LegacyRule] = LEGACY_RULES) -> Dict[str, LegacyRule]: + return {rule.rule_name: rule for rule in rules} + + +def run_perl_checks(products: Sequence[Product], rules: Sequence[LegacyRule] = LEGACY_RULES) -> Dict[str, Dict[str, object]]: + """Run simulated Perl checks and return per-product and per-rule outputs.""" + per_product_tags: Dict[str, List[str]] = {} + per_rule_products: Dict[str, Set[str]] = {rule.rule_name: set() for rule in rules} + + for product in products: + product_id = str(product.get("product_id")) + emitted_tags: List[str] = [] + for rule in rules: + if rule.evaluator(product): + emitted_tags.append(rule.tag) + per_rule_products[rule.rule_name].add(product_id) + per_product_tags[product_id] = emitted_tags + + return { + "per_product": per_product_tags, + "per_rule": {name: sorted(ids) for name, ids in per_rule_products.items()}, + } diff --git a/OFF_DataQuality/perl_checks/rules/01_energy_kcal_vs_kj.pl b/OFF_DataQuality/perl_checks/rules/01_energy_kcal_vs_kj.pl new file mode 100644 index 0000000000000000000000000000000000000000..a0ec6d4c22855e036d34612303db49766aa4139a --- /dev/null +++ b/OFF_DataQuality/perl_checks/rules/01_energy_kcal_vs_kj.pl @@ -0,0 +1,7 @@ +# RULE_NAME: energy_kcal_vs_kj +# SEVERITY: error +# COMPLEXITY: simple +# DECLARATIVE_FRIENDLY: yes +if ($energy_kcal > $energy_kj) { + push @{$product_ref->{$data_quality_tags}}, "energy-value-in-kcal-greater-than-in-kj"; +} diff --git a/OFF_DataQuality/perl_checks/rules/02_energy_kj_mismatch_low.pl b/OFF_DataQuality/perl_checks/rules/02_energy_kj_mismatch_low.pl new file mode 100644 index 0000000000000000000000000000000000000000..0478bf90922140b69a599d25c42869e3c2293dad --- /dev/null +++ b/OFF_DataQuality/perl_checks/rules/02_energy_kj_mismatch_low.pl @@ -0,0 +1,7 @@ +# RULE_NAME: energy_kj_mismatch_low +# SEVERITY: error +# COMPLEXITY: intricate +# DECLARATIVE_FRIENDLY: no +if ($energy_kj < (3.7 * $energy_kcal - 2)) { + push @{$product_ref->{$data_quality_tags}}, "energy-value-in-kcal-does-not-match-value-in-kj-low"; +} diff --git a/OFF_DataQuality/perl_checks/rules/03_energy_kj_mismatch_high.pl b/OFF_DataQuality/perl_checks/rules/03_energy_kj_mismatch_high.pl new file mode 100644 index 0000000000000000000000000000000000000000..dc9daf4f0e4f8bffcda48bd4802ed9d3371576f5 --- /dev/null +++ b/OFF_DataQuality/perl_checks/rules/03_energy_kj_mismatch_high.pl @@ -0,0 +1,7 @@ +# RULE_NAME: energy_kj_mismatch_high +# SEVERITY: error +# COMPLEXITY: intricate +# DECLARATIVE_FRIENDLY: no +if ($energy_kj > (4.7 * $energy_kcal + 2)) { + push @{$product_ref->{$data_quality_tags}}, "energy-value-in-kcal-does-not-match-value-in-kj-high"; +} diff --git a/OFF_DataQuality/perl_checks/rules/04_energy_kj_over_3911.pl b/OFF_DataQuality/perl_checks/rules/04_energy_kj_over_3911.pl new file mode 100644 index 0000000000000000000000000000000000000000..aa6609cfe0c30349222422baa9993866b2cb3901 --- /dev/null +++ b/OFF_DataQuality/perl_checks/rules/04_energy_kj_over_3911.pl @@ -0,0 +1,7 @@ +# RULE_NAME: energy_kj_over_3911 +# SEVERITY: error +# COMPLEXITY: simple +# DECLARATIVE_FRIENDLY: yes +if ($energy_kj > 3911) { + push @{$product_ref->{$data_quality_tags}}, "value-over-3911-energy"; +} diff --git a/OFF_DataQuality/perl_checks/rules/05_saturated_fat_vs_fat.pl b/OFF_DataQuality/perl_checks/rules/05_saturated_fat_vs_fat.pl new file mode 100644 index 0000000000000000000000000000000000000000..2efa63513c0d483173a6cba3024386faa0978169 --- /dev/null +++ b/OFF_DataQuality/perl_checks/rules/05_saturated_fat_vs_fat.pl @@ -0,0 +1,7 @@ +# RULE_NAME: saturated_fat_vs_fat +# SEVERITY: error +# COMPLEXITY: simple +# DECLARATIVE_FRIENDLY: yes +if ($saturated_fat > (1 * $fat + 0.001)) { + push @{$product_ref->{$data_quality_tags}}, "saturated-fat-greater-than-fat"; +} diff --git a/OFF_DataQuality/perl_checks/rules/06_sugars_plus_starch_vs_carbohydrates.pl b/OFF_DataQuality/perl_checks/rules/06_sugars_plus_starch_vs_carbohydrates.pl new file mode 100644 index 0000000000000000000000000000000000000000..d330a70f295c7a687e8d9cf5d0ecd1c32972fe49 --- /dev/null +++ b/OFF_DataQuality/perl_checks/rules/06_sugars_plus_starch_vs_carbohydrates.pl @@ -0,0 +1,7 @@ +# RULE_NAME: sugars_plus_starch_vs_carbohydrates +# SEVERITY: error +# COMPLEXITY: medium +# DECLARATIVE_FRIENDLY: yes +if (($sugars + $starch) > ($carbohydrates + 0.001)) { + push @{$product_ref->{$data_quality_tags}}, "sugars-plus-starch-greater-than-carbohydrates"; +} diff --git a/OFF_DataQuality/perl_checks/rules/07_fat_over_105g.pl b/OFF_DataQuality/perl_checks/rules/07_fat_over_105g.pl new file mode 100644 index 0000000000000000000000000000000000000000..20d32756c658a90b98b54dad43e7224902737977 --- /dev/null +++ b/OFF_DataQuality/perl_checks/rules/07_fat_over_105g.pl @@ -0,0 +1,7 @@ +# RULE_NAME: fat_over_105g +# SEVERITY: warning +# COMPLEXITY: simple +# DECLARATIVE_FRIENDLY: yes +if ($fat > 105) { + push @{$product_ref->{$data_quality_tags}}, "fat-value-over-105g"; +} diff --git a/OFF_DataQuality/perl_checks/rules/08_saturated_fat_over_105g.pl b/OFF_DataQuality/perl_checks/rules/08_saturated_fat_over_105g.pl new file mode 100644 index 0000000000000000000000000000000000000000..7d556ee7a51bd0b4fd431be2c974ed1b16446f5f --- /dev/null +++ b/OFF_DataQuality/perl_checks/rules/08_saturated_fat_over_105g.pl @@ -0,0 +1,7 @@ +# RULE_NAME: saturated_fat_over_105g +# SEVERITY: warning +# COMPLEXITY: simple +# DECLARATIVE_FRIENDLY: yes +if ($saturated_fat > 105) { + push @{$product_ref->{$data_quality_tags}}, "saturated-fat-value-over-105g"; +} diff --git a/OFF_DataQuality/perl_checks/rules/09_carbohydrates_over_105g.pl b/OFF_DataQuality/perl_checks/rules/09_carbohydrates_over_105g.pl new file mode 100644 index 0000000000000000000000000000000000000000..d6eb7860a01c6c0d18979af964c221d08e6365d1 --- /dev/null +++ b/OFF_DataQuality/perl_checks/rules/09_carbohydrates_over_105g.pl @@ -0,0 +1,7 @@ +# RULE_NAME: carbohydrates_over_105g +# SEVERITY: warning +# COMPLEXITY: simple +# DECLARATIVE_FRIENDLY: yes +if ($carbohydrates > 105) { + push @{$product_ref->{$data_quality_tags}}, "carbohydrates-value-over-105g"; +} diff --git a/OFF_DataQuality/perl_checks/rules/10_sugars_over_105g.pl b/OFF_DataQuality/perl_checks/rules/10_sugars_over_105g.pl new file mode 100644 index 0000000000000000000000000000000000000000..4839ef5b4f1f3b904caef45abfcf4f9a39c4abce --- /dev/null +++ b/OFF_DataQuality/perl_checks/rules/10_sugars_over_105g.pl @@ -0,0 +1,7 @@ +# RULE_NAME: sugars_over_105g +# SEVERITY: warning +# COMPLEXITY: simple +# DECLARATIVE_FRIENDLY: yes +if ($sugars > 105) { + push @{$product_ref->{$data_quality_tags}}, "sugars-value-over-105g"; +} diff --git a/OFF_DataQuality/perl_checks/rules/11_main_language_code_missing.pl b/OFF_DataQuality/perl_checks/rules/11_main_language_code_missing.pl new file mode 100644 index 0000000000000000000000000000000000000000..5f53d1b6d65f01f4efe61dd288ec8f65766f382d --- /dev/null +++ b/OFF_DataQuality/perl_checks/rules/11_main_language_code_missing.pl @@ -0,0 +1,7 @@ +# RULE_NAME: main_language_code_missing +# SEVERITY: bug +# COMPLEXITY: simple +# DECLARATIVE_FRIENDLY: yes +if (!defined $lc || $lc eq "") { + push @{$product_ref->{$data_quality_tags}}, "main-language-code-missing"; +} diff --git a/OFF_DataQuality/perl_checks/rules/12_main_language_missing.pl b/OFF_DataQuality/perl_checks/rules/12_main_language_missing.pl new file mode 100644 index 0000000000000000000000000000000000000000..bc720aa612352115b1575fce56786caa4fd1e2e9 --- /dev/null +++ b/OFF_DataQuality/perl_checks/rules/12_main_language_missing.pl @@ -0,0 +1,7 @@ +# RULE_NAME: main_language_missing +# SEVERITY: bug +# COMPLEXITY: simple +# DECLARATIVE_FRIENDLY: yes +if (!defined $lang || $lang eq "") { + push @{$product_ref->{$data_quality_tags}}, "main-language-missing"; +} diff --git a/OFF_DataQuality/perl_checks/rules/13_energy_kj_computed_mismatch_low.pl b/OFF_DataQuality/perl_checks/rules/13_energy_kj_computed_mismatch_low.pl new file mode 100644 index 0000000000000000000000000000000000000000..a576d43befed2205cf764bffe23998fd9907c112 --- /dev/null +++ b/OFF_DataQuality/perl_checks/rules/13_energy_kj_computed_mismatch_low.pl @@ -0,0 +1,7 @@ +# RULE_NAME: energy_kj_computed_mismatch_low +# SEVERITY: error +# COMPLEXITY: intricate +# DECLARATIVE_FRIENDLY: no +if ($energy_kj_computed < (0.7 * $energy_kj - 5)) { + push @{$product_ref->{$data_quality_tags}}, "energy-value-in-kj-does-not-match-value-computed-from-other-nutrients-low"; +} diff --git a/OFF_DataQuality/perl_checks/rules/14_energy_kj_computed_mismatch_high.pl b/OFF_DataQuality/perl_checks/rules/14_energy_kj_computed_mismatch_high.pl new file mode 100644 index 0000000000000000000000000000000000000000..972ddc46428d08954e02f929c38eb7cd2655ec26 --- /dev/null +++ b/OFF_DataQuality/perl_checks/rules/14_energy_kj_computed_mismatch_high.pl @@ -0,0 +1,7 @@ +# RULE_NAME: energy_kj_computed_mismatch_high +# SEVERITY: error +# COMPLEXITY: intricate +# DECLARATIVE_FRIENDLY: no +if ($energy_kj_computed > (1.3 * $energy_kj + 5)) { + push @{$product_ref->{$data_quality_tags}}, "energy-value-in-kj-does-not-match-value-computed-from-other-nutrients-high"; +} diff --git a/OFF_DataQuality/perl_checks/rules/15_ca_allergen_evidence_missing_ingredients_text.pl b/OFF_DataQuality/perl_checks/rules/15_ca_allergen_evidence_missing_ingredients_text.pl new file mode 100644 index 0000000000000000000000000000000000000000..79ef17d6ece4644b4542a31b840ac057b3e47857 --- /dev/null +++ b/OFF_DataQuality/perl_checks/rules/15_ca_allergen_evidence_missing_ingredients_text.pl @@ -0,0 +1,7 @@ +# RULE_NAME: ca_allergen_evidence_missing_ingredients_text +# SEVERITY: warning +# COMPLEXITY: medium +# DECLARATIVE_FRIENDLY: yes +if (($allergen_evidence_present > 0) && ($ingredients_text_present == 0)) { + push @{$product_ref->{$data_quality_tags}}, "ca-allergen-evidence-but-missing-ingredients-text"; +} diff --git a/OFF_DataQuality/perl_checks/rules/16_ca_contains_statement_without_allergen_evidence.pl b/OFF_DataQuality/perl_checks/rules/16_ca_contains_statement_without_allergen_evidence.pl new file mode 100644 index 0000000000000000000000000000000000000000..d47e484541d6ae8e54d06b3c716b530bf60722f0 --- /dev/null +++ b/OFF_DataQuality/perl_checks/rules/16_ca_contains_statement_without_allergen_evidence.pl @@ -0,0 +1,7 @@ +# RULE_NAME: ca_contains_statement_without_allergen_evidence +# SEVERITY: warning +# COMPLEXITY: medium +# DECLARATIVE_FRIENDLY: yes +if (($contains_statement_present > 0) && ($allergen_evidence_present == 0)) { + push @{$product_ref->{$data_quality_tags}}, "ca-contains-statement-without-allergen-evidence"; +} diff --git a/OFF_DataQuality/perl_checks/rules/17_ca_fop_required_but_symbol_missing.pl b/OFF_DataQuality/perl_checks/rules/17_ca_fop_required_but_symbol_missing.pl new file mode 100644 index 0000000000000000000000000000000000000000..1fd04fb83af7d97a62c63d75d4bb0620fe66deaf --- /dev/null +++ b/OFF_DataQuality/perl_checks/rules/17_ca_fop_required_but_symbol_missing.pl @@ -0,0 +1,7 @@ +# RULE_NAME: ca_fop_required_but_symbol_missing +# SEVERITY: error +# COMPLEXITY: medium +# DECLARATIVE_FRIENDLY: yes +if (($fop_threshold_exceeded > 0) && ($fop_symbol_present == 0) && ($fop_exempt_proxy == 0) && ($product_is_prepackaged_proxy > 0)) { + push @{$product_ref->{$data_quality_tags}}, "ca-fop-required-but-symbol-missing"; +} diff --git a/OFF_DataQuality/perl_checks/rules/18_ca_fop_symbol_present_but_not_required.pl b/OFF_DataQuality/perl_checks/rules/18_ca_fop_symbol_present_but_not_required.pl new file mode 100644 index 0000000000000000000000000000000000000000..40f858fd914b6f6b5741b7c638089dd301d94ffd --- /dev/null +++ b/OFF_DataQuality/perl_checks/rules/18_ca_fop_symbol_present_but_not_required.pl @@ -0,0 +1,7 @@ +# RULE_NAME: ca_fop_symbol_present_but_not_required +# SEVERITY: warning +# COMPLEXITY: medium +# DECLARATIVE_FRIENDLY: yes +if (($fop_symbol_present > 0) && ($fop_threshold_exceeded == 0) && ($fop_exempt_proxy == 0) && ($product_is_prepackaged_proxy > 0)) { + push @{$product_ref->{$data_quality_tags}}, "ca-fop-symbol-present-but-not-required"; +} diff --git a/OFF_DataQuality/perl_checks/rules/19_ca_fop_symbol_present_on_exempt_product.pl b/OFF_DataQuality/perl_checks/rules/19_ca_fop_symbol_present_on_exempt_product.pl new file mode 100644 index 0000000000000000000000000000000000000000..c82dd93e7443e60279c450a1e6c115dded487640 --- /dev/null +++ b/OFF_DataQuality/perl_checks/rules/19_ca_fop_symbol_present_on_exempt_product.pl @@ -0,0 +1,7 @@ +# RULE_NAME: ca_fop_symbol_present_on_exempt_product +# SEVERITY: warning +# COMPLEXITY: medium +# DECLARATIVE_FRIENDLY: yes +if (($fop_symbol_present > 0) && ($fop_exempt_proxy > 0) && ($product_is_prepackaged_proxy > 0)) { + push @{$product_ref->{$data_quality_tags}}, "ca-fop-symbol-present-on-exempt-product"; +} diff --git a/OFF_DataQuality/pytest.ini b/OFF_DataQuality/pytest.ini new file mode 100644 index 0000000000000000000000000000000000000000..53bfcf9276d71c928071856de4249bbd657a2470 --- /dev/null +++ b/OFF_DataQuality/pytest.ini @@ -0,0 +1,2 @@ +[pytest] +testpaths = tests diff --git a/OFF_DataQuality/python_checks/__init__.py b/OFF_DataQuality/python_checks/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/OFF_DataQuality/python_checks/generated_checks.py b/OFF_DataQuality/python_checks/generated_checks.py new file mode 100644 index 0000000000000000000000000000000000000000..85be184f32e147832520dc3852cafe56f0267d72 --- /dev/null +++ b/OFF_DataQuality/python_checks/generated_checks.py @@ -0,0 +1,36 @@ +"""Runtime compiler for generated Python checks.""" +from __future__ import annotations + +from typing import Callable, Dict, List, Tuple + + +def compile_generated_checks( + converted_rules: List[Dict[str, object]], +) -> Tuple[Dict[str, Callable[[Dict[str, object]], object]], Dict[str, Dict[str, object]]]: + """Compile generated Python snippets into callable checks.""" + checks: Dict[str, Callable[[Dict[str, object]], object]] = {} + metadata: Dict[str, Dict[str, object]] = {} + + for converted in converted_rules: + function_name = str(converted["function_name"]) + rule_name = str(converted["rule_name"]) + code = str(converted["python_code"]) + + namespace: Dict[str, object] = {} + exec(code, {}, namespace) + check_fn = namespace[function_name] + checks[rule_name] = check_fn + metadata[rule_name] = { + "function_name": function_name, + "python_code": code, + "llm_confidence": float(converted["llm_confidence"]), + "conversion_notes": converted["conversion_notes"], + "provider": converted.get("provider", "unknown"), + } + return checks, metadata + + +def render_generated_module(metadata: Dict[str, Dict[str, object]]) -> str: + """Return a readable module-like rendering of generated checks.""" + code_blocks = [str(info["python_code"]).rstrip() for info in metadata.values()] + return "\n\n".join(code_blocks) + "\n" diff --git a/OFF_DataQuality/requirements.txt b/OFF_DataQuality/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..f10e5f75793655f674438ca575ffdcc63bf23201 --- /dev/null +++ b/OFF_DataQuality/requirements.txt @@ -0,0 +1,8 @@ +duckdb +streamlit +pandas +openai +pytest +plotly +dbt-duckdb +soda-duckdb diff --git a/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/dbt_project.yml b/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/dbt_project.yml new file mode 100644 index 0000000000000000000000000000000000000000..298a835daac9169ef49a0c2c9ec0805acb39bb87 --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/dbt_project.yml @@ -0,0 +1,6 @@ +name: off_quality_declarative +version: '1.0' +config-version: 2 +profile: off_quality_duckdb +model-paths: ['models'] +test-paths: ['tests'] diff --git a/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/macros/count_violations.sql b/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/macros/count_violations.sql new file mode 100644 index 0000000000000000000000000000000000000000..b2f5860e30680cd91ea4d3cb7a30a3aa06aeadb1 --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/macros/count_violations.sql @@ -0,0 +1,12 @@ +{% macro count_violations(condition_sql) %} + {% set q %} + select count(*) as violation_count + from {{ source('off_source', 'nutrition_table') }} + where {{ condition_sql }} + {% endset %} + {% set t = run_query(q) %} + {% if execute %} + {% set c = t.columns[0].values()[0] %} + {% do log('VIOLATION_COUNT=' ~ c, info=True) %} + {% endif %} +{% endmacro %} diff --git a/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/models/sources.yml b/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/models/sources.yml new file mode 100644 index 0000000000000000000000000000000000000000..2257ae92ba3422631b5dad7eb6b2bb5d8ae8d22e --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/models/sources.yml @@ -0,0 +1,6 @@ +version: 2 +sources: + - name: off_source + schema: main + tables: + - name: nutrition_table diff --git a/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/profiles.yml b/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/profiles.yml new file mode 100644 index 0000000000000000000000000000000000000000..671409d1df80f793c1356e269083428aedfa8030 --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/profiles.yml @@ -0,0 +1,8 @@ +off_quality_duckdb: + target: dev + outputs: + dev: + type: duckdb + path: 'results/declarative_runtime/dbt/dbt_runtime.db' + schema: main + threads: 1 diff --git a/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/ca_allergen_evidence_missing_ingredients_text.sql b/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/ca_allergen_evidence_missing_ingredients_text.sql new file mode 100644 index 0000000000000000000000000000000000000000..5cba65e89f6db7703a9e0ad372581da55a6eef26 --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/ca_allergen_evidence_missing_ingredients_text.sql @@ -0,0 +1,3 @@ +SELECT product_id +FROM {{ source('off_source', 'nutrition_table') }} +WHERE allergen_evidence_present > 0.0 AND ingredients_text_present == 0.0 diff --git a/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/ca_contains_statement_without_allergen_evidence.sql b/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/ca_contains_statement_without_allergen_evidence.sql new file mode 100644 index 0000000000000000000000000000000000000000..f1bbfced480baca63044d9b1e8dd8df3ddcbc32d --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/ca_contains_statement_without_allergen_evidence.sql @@ -0,0 +1,3 @@ +SELECT product_id +FROM {{ source('off_source', 'nutrition_table') }} +WHERE contains_statement_present > 0.0 AND allergen_evidence_present == 0.0 diff --git a/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/ca_fop_required_but_symbol_missing.sql b/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/ca_fop_required_but_symbol_missing.sql new file mode 100644 index 0000000000000000000000000000000000000000..54a383000949f62d7a8e51b9638bce352e78158b --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/ca_fop_required_but_symbol_missing.sql @@ -0,0 +1,3 @@ +SELECT product_id +FROM {{ source('off_source', 'nutrition_table') }} +WHERE fop_threshold_exceeded > 0.0 AND fop_symbol_present == 0.0 AND fop_exempt_proxy == 0.0 AND product_is_prepackaged_proxy > 0.0 diff --git a/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/ca_fop_symbol_present_but_not_required.sql b/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/ca_fop_symbol_present_but_not_required.sql new file mode 100644 index 0000000000000000000000000000000000000000..73875a8ab4bd3a5b60c4d8a6b21f77480e43c791 --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/ca_fop_symbol_present_but_not_required.sql @@ -0,0 +1,3 @@ +SELECT product_id +FROM {{ source('off_source', 'nutrition_table') }} +WHERE fop_symbol_present > 0.0 AND fop_threshold_exceeded == 0.0 AND fop_exempt_proxy == 0.0 AND product_is_prepackaged_proxy > 0.0 diff --git a/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/ca_fop_symbol_present_on_exempt_product.sql b/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/ca_fop_symbol_present_on_exempt_product.sql new file mode 100644 index 0000000000000000000000000000000000000000..ede059e6c0d080f918d675f407995bbc6bf0da2b --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/ca_fop_symbol_present_on_exempt_product.sql @@ -0,0 +1,3 @@ +SELECT product_id +FROM {{ source('off_source', 'nutrition_table') }} +WHERE fop_symbol_present > 0.0 AND fop_exempt_proxy > 0.0 AND product_is_prepackaged_proxy > 0.0 diff --git a/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/carbohydrates_over_105g.sql b/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/carbohydrates_over_105g.sql new file mode 100644 index 0000000000000000000000000000000000000000..f674900f480f0b5bb5ac7282084555a66e3a420a --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/carbohydrates_over_105g.sql @@ -0,0 +1,3 @@ +SELECT product_id +FROM {{ source('off_source', 'nutrition_table') }} +WHERE carbohydrates > 105 diff --git a/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/energy_kcal_vs_kj.sql b/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/energy_kcal_vs_kj.sql new file mode 100644 index 0000000000000000000000000000000000000000..bb6de3c4fa58c30006d2d0fc04b3c4fad22601b8 --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/energy_kcal_vs_kj.sql @@ -0,0 +1,3 @@ +SELECT product_id +FROM {{ source('off_source', 'nutrition_table') }} +WHERE energy_kcal > energy_kj diff --git a/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/energy_kj_computed_mismatch_high.sql b/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/energy_kj_computed_mismatch_high.sql new file mode 100644 index 0000000000000000000000000000000000000000..f8441a685c40801367b2648c26c093481edd3b8d --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/energy_kj_computed_mismatch_high.sql @@ -0,0 +1,3 @@ +SELECT product_id +FROM {{ source('off_source', 'nutrition_table') }} +WHERE energy_kj_computed > (1.3 * energy_kj + 5.0) diff --git a/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/energy_kj_computed_mismatch_low.sql b/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/energy_kj_computed_mismatch_low.sql new file mode 100644 index 0000000000000000000000000000000000000000..22467e455417d26dd6eac5f5b3a7861f5147a951 --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/energy_kj_computed_mismatch_low.sql @@ -0,0 +1,3 @@ +SELECT product_id +FROM {{ source('off_source', 'nutrition_table') }} +WHERE energy_kj_computed < (0.7 * energy_kj - 5.0) diff --git a/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/energy_kj_mismatch_high.sql b/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/energy_kj_mismatch_high.sql new file mode 100644 index 0000000000000000000000000000000000000000..040af1ce76762014a8178e74220750b594a5b82b --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/energy_kj_mismatch_high.sql @@ -0,0 +1,3 @@ +SELECT product_id +FROM {{ source('off_source', 'nutrition_table') }} +WHERE energy_kj > (4.7 * energy_kcal + 2.0) diff --git a/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/energy_kj_mismatch_low.sql b/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/energy_kj_mismatch_low.sql new file mode 100644 index 0000000000000000000000000000000000000000..b5ffd498bfb159be98afb6dcc4a6afa0b4f0fb04 --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/energy_kj_mismatch_low.sql @@ -0,0 +1,3 @@ +SELECT product_id +FROM {{ source('off_source', 'nutrition_table') }} +WHERE energy_kj < (3.7 * energy_kcal - 2.0) diff --git a/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/energy_kj_over_3911.sql b/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/energy_kj_over_3911.sql new file mode 100644 index 0000000000000000000000000000000000000000..edb9969136f8213e57ca3e9a552285eec334a5b9 --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/energy_kj_over_3911.sql @@ -0,0 +1,3 @@ +SELECT product_id +FROM {{ source('off_source', 'nutrition_table') }} +WHERE energy_kj > 3911 diff --git a/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/fat_over_105g.sql b/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/fat_over_105g.sql new file mode 100644 index 0000000000000000000000000000000000000000..df23a2b562b92785ae9280e8d2dafbf8efe97fb9 --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/fat_over_105g.sql @@ -0,0 +1,3 @@ +SELECT product_id +FROM {{ source('off_source', 'nutrition_table') }} +WHERE fat > 105 diff --git a/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/main_language_code_missing.sql b/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/main_language_code_missing.sql new file mode 100644 index 0000000000000000000000000000000000000000..be4cd787a3b310e7cac47965864d59d957071050 --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/main_language_code_missing.sql @@ -0,0 +1,3 @@ +SELECT product_id +FROM {{ source('off_source', 'nutrition_table') }} +WHERE lc IS NULL OR TRIM(lc) = '' diff --git a/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/main_language_missing.sql b/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/main_language_missing.sql new file mode 100644 index 0000000000000000000000000000000000000000..b92c5c22b7a5f219f859d2c38548c1828b87ec2c --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/main_language_missing.sql @@ -0,0 +1,3 @@ +SELECT product_id +FROM {{ source('off_source', 'nutrition_table') }} +WHERE lang IS NULL OR TRIM(lang) = '' diff --git a/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/saturated_fat_over_105g.sql b/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/saturated_fat_over_105g.sql new file mode 100644 index 0000000000000000000000000000000000000000..4c5bd8a6b1670fe861db743f4fbfbf11b73f7986 --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/saturated_fat_over_105g.sql @@ -0,0 +1,3 @@ +SELECT product_id +FROM {{ source('off_source', 'nutrition_table') }} +WHERE saturated_fat > 105 diff --git a/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/saturated_fat_vs_fat.sql b/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/saturated_fat_vs_fat.sql new file mode 100644 index 0000000000000000000000000000000000000000..728306ddde0fbce6be6ad92a3d91012b946c4e80 --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/saturated_fat_vs_fat.sql @@ -0,0 +1,3 @@ +SELECT product_id +FROM {{ source('off_source', 'nutrition_table') }} +WHERE saturated_fat > (1.0 * fat + 0.001) diff --git a/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/sugars_over_105g.sql b/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/sugars_over_105g.sql new file mode 100644 index 0000000000000000000000000000000000000000..3c821e0c07aca8d835c051b2116e886d14f16a87 --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/sugars_over_105g.sql @@ -0,0 +1,3 @@ +SELECT product_id +FROM {{ source('off_source', 'nutrition_table') }} +WHERE sugars > 105 diff --git a/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/sugars_plus_starch_vs_carbohydrates.sql b/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/sugars_plus_starch_vs_carbohydrates.sql new file mode 100644 index 0000000000000000000000000000000000000000..13936a538534e6b04ecb8cfb1480f7acc2ec8aca --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/dbt/dbt_project/tests/sugars_plus_starch_vs_carbohydrates.sql @@ -0,0 +1,3 @@ +SELECT product_id +FROM {{ source('off_source', 'nutrition_table') }} +WHERE (sugars + starch) > (carbohydrates + 0.001) diff --git a/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/ca_allergen_evidence_missing_ingredients_text.yml b/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/ca_allergen_evidence_missing_ingredients_text.yml new file mode 100644 index 0000000000000000000000000000000000000000..8b2e70f35a0d83ec161c2cb0a4853ec9fdb647f0 --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/ca_allergen_evidence_missing_ingredients_text.yml @@ -0,0 +1,27 @@ +dataset: off_quality/main/nutrition_table +columns: + - name: product_id + - name: energy_kj + - name: energy_kj_computed + - name: energy_kcal + - name: fat + - name: saturated_fat + - name: carbohydrates + - name: sugars + - name: starch + - name: sodium + - name: ingredients_text + - name: ingredients_text_present + - name: contains_statement_present + - name: allergen_evidence_present + - name: fop_threshold_exceeded + - name: fop_symbol_present + - name: fop_exempt_proxy + - name: product_is_prepackaged_proxy + - name: lc + - name: lang + - name: language_code +checks: + - failed_rows: + name: ca_allergen_evidence_missing_ingredients_text + expression: allergen_evidence_present > 0.0 AND ingredients_text_present == 0.0 diff --git a/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/ca_contains_statement_without_allergen_evidence.yml b/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/ca_contains_statement_without_allergen_evidence.yml new file mode 100644 index 0000000000000000000000000000000000000000..40f3ee627c0d08c9591b3622492e01f8176f3251 --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/ca_contains_statement_without_allergen_evidence.yml @@ -0,0 +1,27 @@ +dataset: off_quality/main/nutrition_table +columns: + - name: product_id + - name: energy_kj + - name: energy_kj_computed + - name: energy_kcal + - name: fat + - name: saturated_fat + - name: carbohydrates + - name: sugars + - name: starch + - name: sodium + - name: ingredients_text + - name: ingredients_text_present + - name: contains_statement_present + - name: allergen_evidence_present + - name: fop_threshold_exceeded + - name: fop_symbol_present + - name: fop_exempt_proxy + - name: product_is_prepackaged_proxy + - name: lc + - name: lang + - name: language_code +checks: + - failed_rows: + name: ca_contains_statement_without_allergen_evidence + expression: contains_statement_present > 0.0 AND allergen_evidence_present == 0.0 diff --git a/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/ca_fop_required_but_symbol_missing.yml b/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/ca_fop_required_but_symbol_missing.yml new file mode 100644 index 0000000000000000000000000000000000000000..d49c55b6db065bb7827cf477ea562f62813c046a --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/ca_fop_required_but_symbol_missing.yml @@ -0,0 +1,27 @@ +dataset: off_quality/main/nutrition_table +columns: + - name: product_id + - name: energy_kj + - name: energy_kj_computed + - name: energy_kcal + - name: fat + - name: saturated_fat + - name: carbohydrates + - name: sugars + - name: starch + - name: sodium + - name: ingredients_text + - name: ingredients_text_present + - name: contains_statement_present + - name: allergen_evidence_present + - name: fop_threshold_exceeded + - name: fop_symbol_present + - name: fop_exempt_proxy + - name: product_is_prepackaged_proxy + - name: lc + - name: lang + - name: language_code +checks: + - failed_rows: + name: ca_fop_required_but_symbol_missing + expression: fop_threshold_exceeded > 0.0 AND fop_symbol_present == 0.0 AND fop_exempt_proxy == 0.0 AND product_is_prepackaged_proxy > 0.0 diff --git a/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/ca_fop_symbol_present_but_not_required.yml b/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/ca_fop_symbol_present_but_not_required.yml new file mode 100644 index 0000000000000000000000000000000000000000..0085cd01e318557a23e4a04e8304c2fc00b66aeb --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/ca_fop_symbol_present_but_not_required.yml @@ -0,0 +1,27 @@ +dataset: off_quality/main/nutrition_table +columns: + - name: product_id + - name: energy_kj + - name: energy_kj_computed + - name: energy_kcal + - name: fat + - name: saturated_fat + - name: carbohydrates + - name: sugars + - name: starch + - name: sodium + - name: ingredients_text + - name: ingredients_text_present + - name: contains_statement_present + - name: allergen_evidence_present + - name: fop_threshold_exceeded + - name: fop_symbol_present + - name: fop_exempt_proxy + - name: product_is_prepackaged_proxy + - name: lc + - name: lang + - name: language_code +checks: + - failed_rows: + name: ca_fop_symbol_present_but_not_required + expression: fop_symbol_present > 0.0 AND fop_threshold_exceeded == 0.0 AND fop_exempt_proxy == 0.0 AND product_is_prepackaged_proxy > 0.0 diff --git a/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/ca_fop_symbol_present_on_exempt_product.yml b/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/ca_fop_symbol_present_on_exempt_product.yml new file mode 100644 index 0000000000000000000000000000000000000000..491c8f7e26b4c8fe13f73bd3bd6abcc64ecc45f4 --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/ca_fop_symbol_present_on_exempt_product.yml @@ -0,0 +1,27 @@ +dataset: off_quality/main/nutrition_table +columns: + - name: product_id + - name: energy_kj + - name: energy_kj_computed + - name: energy_kcal + - name: fat + - name: saturated_fat + - name: carbohydrates + - name: sugars + - name: starch + - name: sodium + - name: ingredients_text + - name: ingredients_text_present + - name: contains_statement_present + - name: allergen_evidence_present + - name: fop_threshold_exceeded + - name: fop_symbol_present + - name: fop_exempt_proxy + - name: product_is_prepackaged_proxy + - name: lc + - name: lang + - name: language_code +checks: + - failed_rows: + name: ca_fop_symbol_present_on_exempt_product + expression: fop_symbol_present > 0.0 AND fop_exempt_proxy > 0.0 AND product_is_prepackaged_proxy > 0.0 diff --git a/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/carbohydrates_over_105g.yml b/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/carbohydrates_over_105g.yml new file mode 100644 index 0000000000000000000000000000000000000000..4245ad87e0773553d5ef335d737499e5e195994e --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/carbohydrates_over_105g.yml @@ -0,0 +1,27 @@ +dataset: off_quality/main/nutrition_table +columns: + - name: product_id + - name: energy_kj + - name: energy_kj_computed + - name: energy_kcal + - name: fat + - name: saturated_fat + - name: carbohydrates + - name: sugars + - name: starch + - name: sodium + - name: ingredients_text + - name: ingredients_text_present + - name: contains_statement_present + - name: allergen_evidence_present + - name: fop_threshold_exceeded + - name: fop_symbol_present + - name: fop_exempt_proxy + - name: product_is_prepackaged_proxy + - name: lc + - name: lang + - name: language_code +checks: + - failed_rows: + name: carbohydrates_over_105g + expression: carbohydrates > 105 diff --git a/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/energy_kcal_vs_kj.yml b/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/energy_kcal_vs_kj.yml new file mode 100644 index 0000000000000000000000000000000000000000..884145f4cb5a38ebd44751151fc45af999ca5343 --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/energy_kcal_vs_kj.yml @@ -0,0 +1,27 @@ +dataset: off_quality/main/nutrition_table +columns: + - name: product_id + - name: energy_kj + - name: energy_kj_computed + - name: energy_kcal + - name: fat + - name: saturated_fat + - name: carbohydrates + - name: sugars + - name: starch + - name: sodium + - name: ingredients_text + - name: ingredients_text_present + - name: contains_statement_present + - name: allergen_evidence_present + - name: fop_threshold_exceeded + - name: fop_symbol_present + - name: fop_exempt_proxy + - name: product_is_prepackaged_proxy + - name: lc + - name: lang + - name: language_code +checks: + - failed_rows: + name: energy_kcal_vs_kj + expression: energy_kcal > energy_kj diff --git a/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/energy_kj_computed_mismatch_high.yml b/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/energy_kj_computed_mismatch_high.yml new file mode 100644 index 0000000000000000000000000000000000000000..f4cc61285b3d879fe694a4e1b73a34624f47f857 --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/energy_kj_computed_mismatch_high.yml @@ -0,0 +1,27 @@ +dataset: off_quality/main/nutrition_table +columns: + - name: product_id + - name: energy_kj + - name: energy_kj_computed + - name: energy_kcal + - name: fat + - name: saturated_fat + - name: carbohydrates + - name: sugars + - name: starch + - name: sodium + - name: ingredients_text + - name: ingredients_text_present + - name: contains_statement_present + - name: allergen_evidence_present + - name: fop_threshold_exceeded + - name: fop_symbol_present + - name: fop_exempt_proxy + - name: product_is_prepackaged_proxy + - name: lc + - name: lang + - name: language_code +checks: + - failed_rows: + name: energy_kj_computed_mismatch_high + expression: energy_kj_computed > (1.3 * energy_kj + 5.0) diff --git a/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/energy_kj_computed_mismatch_low.yml b/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/energy_kj_computed_mismatch_low.yml new file mode 100644 index 0000000000000000000000000000000000000000..eefe9fd1bdaec604d20b12bff9482fddb86de826 --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/energy_kj_computed_mismatch_low.yml @@ -0,0 +1,27 @@ +dataset: off_quality/main/nutrition_table +columns: + - name: product_id + - name: energy_kj + - name: energy_kj_computed + - name: energy_kcal + - name: fat + - name: saturated_fat + - name: carbohydrates + - name: sugars + - name: starch + - name: sodium + - name: ingredients_text + - name: ingredients_text_present + - name: contains_statement_present + - name: allergen_evidence_present + - name: fop_threshold_exceeded + - name: fop_symbol_present + - name: fop_exempt_proxy + - name: product_is_prepackaged_proxy + - name: lc + - name: lang + - name: language_code +checks: + - failed_rows: + name: energy_kj_computed_mismatch_low + expression: energy_kj_computed < (0.7 * energy_kj - 5.0) diff --git a/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/energy_kj_mismatch_high.yml b/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/energy_kj_mismatch_high.yml new file mode 100644 index 0000000000000000000000000000000000000000..1093ce93be2e685910fe0a9b34cf0c1057e50310 --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/energy_kj_mismatch_high.yml @@ -0,0 +1,27 @@ +dataset: off_quality/main/nutrition_table +columns: + - name: product_id + - name: energy_kj + - name: energy_kj_computed + - name: energy_kcal + - name: fat + - name: saturated_fat + - name: carbohydrates + - name: sugars + - name: starch + - name: sodium + - name: ingredients_text + - name: ingredients_text_present + - name: contains_statement_present + - name: allergen_evidence_present + - name: fop_threshold_exceeded + - name: fop_symbol_present + - name: fop_exempt_proxy + - name: product_is_prepackaged_proxy + - name: lc + - name: lang + - name: language_code +checks: + - failed_rows: + name: energy_kj_mismatch_high + expression: energy_kj > (4.7 * energy_kcal + 2.0) diff --git a/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/energy_kj_mismatch_low.yml b/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/energy_kj_mismatch_low.yml new file mode 100644 index 0000000000000000000000000000000000000000..bf94b05e21945b82e70f19a06d24419e5f7fabf4 --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/energy_kj_mismatch_low.yml @@ -0,0 +1,27 @@ +dataset: off_quality/main/nutrition_table +columns: + - name: product_id + - name: energy_kj + - name: energy_kj_computed + - name: energy_kcal + - name: fat + - name: saturated_fat + - name: carbohydrates + - name: sugars + - name: starch + - name: sodium + - name: ingredients_text + - name: ingredients_text_present + - name: contains_statement_present + - name: allergen_evidence_present + - name: fop_threshold_exceeded + - name: fop_symbol_present + - name: fop_exempt_proxy + - name: product_is_prepackaged_proxy + - name: lc + - name: lang + - name: language_code +checks: + - failed_rows: + name: energy_kj_mismatch_low + expression: energy_kj < (3.7 * energy_kcal - 2.0) diff --git a/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/energy_kj_over_3911.yml b/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/energy_kj_over_3911.yml new file mode 100644 index 0000000000000000000000000000000000000000..04f6dd1e9535b56d1510f2fd40cc9855a64cf1ca --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/energy_kj_over_3911.yml @@ -0,0 +1,27 @@ +dataset: off_quality/main/nutrition_table +columns: + - name: product_id + - name: energy_kj + - name: energy_kj_computed + - name: energy_kcal + - name: fat + - name: saturated_fat + - name: carbohydrates + - name: sugars + - name: starch + - name: sodium + - name: ingredients_text + - name: ingredients_text_present + - name: contains_statement_present + - name: allergen_evidence_present + - name: fop_threshold_exceeded + - name: fop_symbol_present + - name: fop_exempt_proxy + - name: product_is_prepackaged_proxy + - name: lc + - name: lang + - name: language_code +checks: + - failed_rows: + name: energy_kj_over_3911 + expression: energy_kj > 3911 diff --git a/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/fat_over_105g.yml b/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/fat_over_105g.yml new file mode 100644 index 0000000000000000000000000000000000000000..e39e19ea374830ca8a5c997bc05e273f3683cf02 --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/fat_over_105g.yml @@ -0,0 +1,27 @@ +dataset: off_quality/main/nutrition_table +columns: + - name: product_id + - name: energy_kj + - name: energy_kj_computed + - name: energy_kcal + - name: fat + - name: saturated_fat + - name: carbohydrates + - name: sugars + - name: starch + - name: sodium + - name: ingredients_text + - name: ingredients_text_present + - name: contains_statement_present + - name: allergen_evidence_present + - name: fop_threshold_exceeded + - name: fop_symbol_present + - name: fop_exempt_proxy + - name: product_is_prepackaged_proxy + - name: lc + - name: lang + - name: language_code +checks: + - failed_rows: + name: fat_over_105g + expression: fat > 105 diff --git a/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/main_language_code_missing.yml b/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/main_language_code_missing.yml new file mode 100644 index 0000000000000000000000000000000000000000..a5fbd9d53adccfb8551875efa0d139326a2aa9ae --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/main_language_code_missing.yml @@ -0,0 +1,27 @@ +dataset: off_quality/main/nutrition_table +columns: + - name: product_id + - name: energy_kj + - name: energy_kj_computed + - name: energy_kcal + - name: fat + - name: saturated_fat + - name: carbohydrates + - name: sugars + - name: starch + - name: sodium + - name: ingredients_text + - name: ingredients_text_present + - name: contains_statement_present + - name: allergen_evidence_present + - name: fop_threshold_exceeded + - name: fop_symbol_present + - name: fop_exempt_proxy + - name: product_is_prepackaged_proxy + - name: lc + - name: lang + - name: language_code +checks: + - failed_rows: + name: main_language_code_missing + expression: lc IS NULL OR TRIM(lc) = '' diff --git a/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/main_language_missing.yml b/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/main_language_missing.yml new file mode 100644 index 0000000000000000000000000000000000000000..6b74857b8e43cffd35e1a3c1077853d0db0cd746 --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/main_language_missing.yml @@ -0,0 +1,27 @@ +dataset: off_quality/main/nutrition_table +columns: + - name: product_id + - name: energy_kj + - name: energy_kj_computed + - name: energy_kcal + - name: fat + - name: saturated_fat + - name: carbohydrates + - name: sugars + - name: starch + - name: sodium + - name: ingredients_text + - name: ingredients_text_present + - name: contains_statement_present + - name: allergen_evidence_present + - name: fop_threshold_exceeded + - name: fop_symbol_present + - name: fop_exempt_proxy + - name: product_is_prepackaged_proxy + - name: lc + - name: lang + - name: language_code +checks: + - failed_rows: + name: main_language_missing + expression: lang IS NULL OR TRIM(lang) = '' diff --git a/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/saturated_fat_over_105g.yml b/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/saturated_fat_over_105g.yml new file mode 100644 index 0000000000000000000000000000000000000000..5231c27a2b77079c42cf399f43abeb98fadddff7 --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/saturated_fat_over_105g.yml @@ -0,0 +1,27 @@ +dataset: off_quality/main/nutrition_table +columns: + - name: product_id + - name: energy_kj + - name: energy_kj_computed + - name: energy_kcal + - name: fat + - name: saturated_fat + - name: carbohydrates + - name: sugars + - name: starch + - name: sodium + - name: ingredients_text + - name: ingredients_text_present + - name: contains_statement_present + - name: allergen_evidence_present + - name: fop_threshold_exceeded + - name: fop_symbol_present + - name: fop_exempt_proxy + - name: product_is_prepackaged_proxy + - name: lc + - name: lang + - name: language_code +checks: + - failed_rows: + name: saturated_fat_over_105g + expression: saturated_fat > 105 diff --git a/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/saturated_fat_vs_fat.yml b/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/saturated_fat_vs_fat.yml new file mode 100644 index 0000000000000000000000000000000000000000..006010b2631a40cacf4213fcb654e928d3f885ca --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/saturated_fat_vs_fat.yml @@ -0,0 +1,27 @@ +dataset: off_quality/main/nutrition_table +columns: + - name: product_id + - name: energy_kj + - name: energy_kj_computed + - name: energy_kcal + - name: fat + - name: saturated_fat + - name: carbohydrates + - name: sugars + - name: starch + - name: sodium + - name: ingredients_text + - name: ingredients_text_present + - name: contains_statement_present + - name: allergen_evidence_present + - name: fop_threshold_exceeded + - name: fop_symbol_present + - name: fop_exempt_proxy + - name: product_is_prepackaged_proxy + - name: lc + - name: lang + - name: language_code +checks: + - failed_rows: + name: saturated_fat_vs_fat + expression: saturated_fat > (1.0 * fat + 0.001) diff --git a/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/sugars_over_105g.yml b/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/sugars_over_105g.yml new file mode 100644 index 0000000000000000000000000000000000000000..0c4f23f7f5702d18dd502ae0afe5fcc0de0b6983 --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/sugars_over_105g.yml @@ -0,0 +1,27 @@ +dataset: off_quality/main/nutrition_table +columns: + - name: product_id + - name: energy_kj + - name: energy_kj_computed + - name: energy_kcal + - name: fat + - name: saturated_fat + - name: carbohydrates + - name: sugars + - name: starch + - name: sodium + - name: ingredients_text + - name: ingredients_text_present + - name: contains_statement_present + - name: allergen_evidence_present + - name: fop_threshold_exceeded + - name: fop_symbol_present + - name: fop_exempt_proxy + - name: product_is_prepackaged_proxy + - name: lc + - name: lang + - name: language_code +checks: + - failed_rows: + name: sugars_over_105g + expression: sugars > 105 diff --git a/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/sugars_plus_starch_vs_carbohydrates.yml b/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/sugars_plus_starch_vs_carbohydrates.yml new file mode 100644 index 0000000000000000000000000000000000000000..122bedd8ec354f14556d80690dcb68a137ef6826 --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/soda/soda/contracts/sugars_plus_starch_vs_carbohydrates.yml @@ -0,0 +1,27 @@ +dataset: off_quality/main/nutrition_table +columns: + - name: product_id + - name: energy_kj + - name: energy_kj_computed + - name: energy_kcal + - name: fat + - name: saturated_fat + - name: carbohydrates + - name: sugars + - name: starch + - name: sodium + - name: ingredients_text + - name: ingredients_text_present + - name: contains_statement_present + - name: allergen_evidence_present + - name: fop_threshold_exceeded + - name: fop_symbol_present + - name: fop_exempt_proxy + - name: product_is_prepackaged_proxy + - name: lc + - name: lang + - name: language_code +checks: + - failed_rows: + name: sugars_plus_starch_vs_carbohydrates + expression: (sugars + starch) > (carbohydrates + 0.001) diff --git a/OFF_DataQuality/results/declarative_runtime/soda/soda/data_source.yml b/OFF_DataQuality/results/declarative_runtime/soda/soda/data_source.yml new file mode 100644 index 0000000000000000000000000000000000000000..cfb1fa860bd4343d474fde86c9c8fdd38f04461f --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/soda/soda/data_source.yml @@ -0,0 +1,5 @@ +type: duckdb +name: off_quality +connection: + database: C:/dev/OFF_DataQuality_Prototype/results/declarative_runtime/soda/soda_runtime.db + schema: main diff --git a/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/ca_allergen_evidence_missing_ingredients_text.yml b/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/ca_allergen_evidence_missing_ingredients_text.yml new file mode 100644 index 0000000000000000000000000000000000000000..8b2e70f35a0d83ec161c2cb0a4853ec9fdb647f0 --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/ca_allergen_evidence_missing_ingredients_text.yml @@ -0,0 +1,27 @@ +dataset: off_quality/main/nutrition_table +columns: + - name: product_id + - name: energy_kj + - name: energy_kj_computed + - name: energy_kcal + - name: fat + - name: saturated_fat + - name: carbohydrates + - name: sugars + - name: starch + - name: sodium + - name: ingredients_text + - name: ingredients_text_present + - name: contains_statement_present + - name: allergen_evidence_present + - name: fop_threshold_exceeded + - name: fop_symbol_present + - name: fop_exempt_proxy + - name: product_is_prepackaged_proxy + - name: lc + - name: lang + - name: language_code +checks: + - failed_rows: + name: ca_allergen_evidence_missing_ingredients_text + expression: allergen_evidence_present > 0.0 AND ingredients_text_present == 0.0 diff --git a/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/ca_contains_statement_without_allergen_evidence.yml b/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/ca_contains_statement_without_allergen_evidence.yml new file mode 100644 index 0000000000000000000000000000000000000000..40f3ee627c0d08c9591b3622492e01f8176f3251 --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/ca_contains_statement_without_allergen_evidence.yml @@ -0,0 +1,27 @@ +dataset: off_quality/main/nutrition_table +columns: + - name: product_id + - name: energy_kj + - name: energy_kj_computed + - name: energy_kcal + - name: fat + - name: saturated_fat + - name: carbohydrates + - name: sugars + - name: starch + - name: sodium + - name: ingredients_text + - name: ingredients_text_present + - name: contains_statement_present + - name: allergen_evidence_present + - name: fop_threshold_exceeded + - name: fop_symbol_present + - name: fop_exempt_proxy + - name: product_is_prepackaged_proxy + - name: lc + - name: lang + - name: language_code +checks: + - failed_rows: + name: ca_contains_statement_without_allergen_evidence + expression: contains_statement_present > 0.0 AND allergen_evidence_present == 0.0 diff --git a/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/ca_fop_required_but_symbol_missing.yml b/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/ca_fop_required_but_symbol_missing.yml new file mode 100644 index 0000000000000000000000000000000000000000..d49c55b6db065bb7827cf477ea562f62813c046a --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/ca_fop_required_but_symbol_missing.yml @@ -0,0 +1,27 @@ +dataset: off_quality/main/nutrition_table +columns: + - name: product_id + - name: energy_kj + - name: energy_kj_computed + - name: energy_kcal + - name: fat + - name: saturated_fat + - name: carbohydrates + - name: sugars + - name: starch + - name: sodium + - name: ingredients_text + - name: ingredients_text_present + - name: contains_statement_present + - name: allergen_evidence_present + - name: fop_threshold_exceeded + - name: fop_symbol_present + - name: fop_exempt_proxy + - name: product_is_prepackaged_proxy + - name: lc + - name: lang + - name: language_code +checks: + - failed_rows: + name: ca_fop_required_but_symbol_missing + expression: fop_threshold_exceeded > 0.0 AND fop_symbol_present == 0.0 AND fop_exempt_proxy == 0.0 AND product_is_prepackaged_proxy > 0.0 diff --git a/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/ca_fop_symbol_present_but_not_required.yml b/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/ca_fop_symbol_present_but_not_required.yml new file mode 100644 index 0000000000000000000000000000000000000000..0085cd01e318557a23e4a04e8304c2fc00b66aeb --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/ca_fop_symbol_present_but_not_required.yml @@ -0,0 +1,27 @@ +dataset: off_quality/main/nutrition_table +columns: + - name: product_id + - name: energy_kj + - name: energy_kj_computed + - name: energy_kcal + - name: fat + - name: saturated_fat + - name: carbohydrates + - name: sugars + - name: starch + - name: sodium + - name: ingredients_text + - name: ingredients_text_present + - name: contains_statement_present + - name: allergen_evidence_present + - name: fop_threshold_exceeded + - name: fop_symbol_present + - name: fop_exempt_proxy + - name: product_is_prepackaged_proxy + - name: lc + - name: lang + - name: language_code +checks: + - failed_rows: + name: ca_fop_symbol_present_but_not_required + expression: fop_symbol_present > 0.0 AND fop_threshold_exceeded == 0.0 AND fop_exempt_proxy == 0.0 AND product_is_prepackaged_proxy > 0.0 diff --git a/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/ca_fop_symbol_present_on_exempt_product.yml b/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/ca_fop_symbol_present_on_exempt_product.yml new file mode 100644 index 0000000000000000000000000000000000000000..491c8f7e26b4c8fe13f73bd3bd6abcc64ecc45f4 --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/ca_fop_symbol_present_on_exempt_product.yml @@ -0,0 +1,27 @@ +dataset: off_quality/main/nutrition_table +columns: + - name: product_id + - name: energy_kj + - name: energy_kj_computed + - name: energy_kcal + - name: fat + - name: saturated_fat + - name: carbohydrates + - name: sugars + - name: starch + - name: sodium + - name: ingredients_text + - name: ingredients_text_present + - name: contains_statement_present + - name: allergen_evidence_present + - name: fop_threshold_exceeded + - name: fop_symbol_present + - name: fop_exempt_proxy + - name: product_is_prepackaged_proxy + - name: lc + - name: lang + - name: language_code +checks: + - failed_rows: + name: ca_fop_symbol_present_on_exempt_product + expression: fop_symbol_present > 0.0 AND fop_exempt_proxy > 0.0 AND product_is_prepackaged_proxy > 0.0 diff --git a/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/carbohydrates_over_105g.yml b/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/carbohydrates_over_105g.yml new file mode 100644 index 0000000000000000000000000000000000000000..4245ad87e0773553d5ef335d737499e5e195994e --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/carbohydrates_over_105g.yml @@ -0,0 +1,27 @@ +dataset: off_quality/main/nutrition_table +columns: + - name: product_id + - name: energy_kj + - name: energy_kj_computed + - name: energy_kcal + - name: fat + - name: saturated_fat + - name: carbohydrates + - name: sugars + - name: starch + - name: sodium + - name: ingredients_text + - name: ingredients_text_present + - name: contains_statement_present + - name: allergen_evidence_present + - name: fop_threshold_exceeded + - name: fop_symbol_present + - name: fop_exempt_proxy + - name: product_is_prepackaged_proxy + - name: lc + - name: lang + - name: language_code +checks: + - failed_rows: + name: carbohydrates_over_105g + expression: carbohydrates > 105 diff --git a/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/energy_kcal_vs_kj.yml b/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/energy_kcal_vs_kj.yml new file mode 100644 index 0000000000000000000000000000000000000000..884145f4cb5a38ebd44751151fc45af999ca5343 --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/energy_kcal_vs_kj.yml @@ -0,0 +1,27 @@ +dataset: off_quality/main/nutrition_table +columns: + - name: product_id + - name: energy_kj + - name: energy_kj_computed + - name: energy_kcal + - name: fat + - name: saturated_fat + - name: carbohydrates + - name: sugars + - name: starch + - name: sodium + - name: ingredients_text + - name: ingredients_text_present + - name: contains_statement_present + - name: allergen_evidence_present + - name: fop_threshold_exceeded + - name: fop_symbol_present + - name: fop_exempt_proxy + - name: product_is_prepackaged_proxy + - name: lc + - name: lang + - name: language_code +checks: + - failed_rows: + name: energy_kcal_vs_kj + expression: energy_kcal > energy_kj diff --git a/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/energy_kj_computed_mismatch_high.yml b/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/energy_kj_computed_mismatch_high.yml new file mode 100644 index 0000000000000000000000000000000000000000..f4cc61285b3d879fe694a4e1b73a34624f47f857 --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/energy_kj_computed_mismatch_high.yml @@ -0,0 +1,27 @@ +dataset: off_quality/main/nutrition_table +columns: + - name: product_id + - name: energy_kj + - name: energy_kj_computed + - name: energy_kcal + - name: fat + - name: saturated_fat + - name: carbohydrates + - name: sugars + - name: starch + - name: sodium + - name: ingredients_text + - name: ingredients_text_present + - name: contains_statement_present + - name: allergen_evidence_present + - name: fop_threshold_exceeded + - name: fop_symbol_present + - name: fop_exempt_proxy + - name: product_is_prepackaged_proxy + - name: lc + - name: lang + - name: language_code +checks: + - failed_rows: + name: energy_kj_computed_mismatch_high + expression: energy_kj_computed > (1.3 * energy_kj + 5.0) diff --git a/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/energy_kj_computed_mismatch_low.yml b/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/energy_kj_computed_mismatch_low.yml new file mode 100644 index 0000000000000000000000000000000000000000..eefe9fd1bdaec604d20b12bff9482fddb86de826 --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/energy_kj_computed_mismatch_low.yml @@ -0,0 +1,27 @@ +dataset: off_quality/main/nutrition_table +columns: + - name: product_id + - name: energy_kj + - name: energy_kj_computed + - name: energy_kcal + - name: fat + - name: saturated_fat + - name: carbohydrates + - name: sugars + - name: starch + - name: sodium + - name: ingredients_text + - name: ingredients_text_present + - name: contains_statement_present + - name: allergen_evidence_present + - name: fop_threshold_exceeded + - name: fop_symbol_present + - name: fop_exempt_proxy + - name: product_is_prepackaged_proxy + - name: lc + - name: lang + - name: language_code +checks: + - failed_rows: + name: energy_kj_computed_mismatch_low + expression: energy_kj_computed < (0.7 * energy_kj - 5.0) diff --git a/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/energy_kj_mismatch_high.yml b/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/energy_kj_mismatch_high.yml new file mode 100644 index 0000000000000000000000000000000000000000..1093ce93be2e685910fe0a9b34cf0c1057e50310 --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/energy_kj_mismatch_high.yml @@ -0,0 +1,27 @@ +dataset: off_quality/main/nutrition_table +columns: + - name: product_id + - name: energy_kj + - name: energy_kj_computed + - name: energy_kcal + - name: fat + - name: saturated_fat + - name: carbohydrates + - name: sugars + - name: starch + - name: sodium + - name: ingredients_text + - name: ingredients_text_present + - name: contains_statement_present + - name: allergen_evidence_present + - name: fop_threshold_exceeded + - name: fop_symbol_present + - name: fop_exempt_proxy + - name: product_is_prepackaged_proxy + - name: lc + - name: lang + - name: language_code +checks: + - failed_rows: + name: energy_kj_mismatch_high + expression: energy_kj > (4.7 * energy_kcal + 2.0) diff --git a/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/energy_kj_mismatch_low.yml b/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/energy_kj_mismatch_low.yml new file mode 100644 index 0000000000000000000000000000000000000000..bf94b05e21945b82e70f19a06d24419e5f7fabf4 --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/energy_kj_mismatch_low.yml @@ -0,0 +1,27 @@ +dataset: off_quality/main/nutrition_table +columns: + - name: product_id + - name: energy_kj + - name: energy_kj_computed + - name: energy_kcal + - name: fat + - name: saturated_fat + - name: carbohydrates + - name: sugars + - name: starch + - name: sodium + - name: ingredients_text + - name: ingredients_text_present + - name: contains_statement_present + - name: allergen_evidence_present + - name: fop_threshold_exceeded + - name: fop_symbol_present + - name: fop_exempt_proxy + - name: product_is_prepackaged_proxy + - name: lc + - name: lang + - name: language_code +checks: + - failed_rows: + name: energy_kj_mismatch_low + expression: energy_kj < (3.7 * energy_kcal - 2.0) diff --git a/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/energy_kj_over_3911.yml b/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/energy_kj_over_3911.yml new file mode 100644 index 0000000000000000000000000000000000000000..04f6dd1e9535b56d1510f2fd40cc9855a64cf1ca --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/energy_kj_over_3911.yml @@ -0,0 +1,27 @@ +dataset: off_quality/main/nutrition_table +columns: + - name: product_id + - name: energy_kj + - name: energy_kj_computed + - name: energy_kcal + - name: fat + - name: saturated_fat + - name: carbohydrates + - name: sugars + - name: starch + - name: sodium + - name: ingredients_text + - name: ingredients_text_present + - name: contains_statement_present + - name: allergen_evidence_present + - name: fop_threshold_exceeded + - name: fop_symbol_present + - name: fop_exempt_proxy + - name: product_is_prepackaged_proxy + - name: lc + - name: lang + - name: language_code +checks: + - failed_rows: + name: energy_kj_over_3911 + expression: energy_kj > 3911 diff --git a/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/fat_over_105g.yml b/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/fat_over_105g.yml new file mode 100644 index 0000000000000000000000000000000000000000..e39e19ea374830ca8a5c997bc05e273f3683cf02 --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/fat_over_105g.yml @@ -0,0 +1,27 @@ +dataset: off_quality/main/nutrition_table +columns: + - name: product_id + - name: energy_kj + - name: energy_kj_computed + - name: energy_kcal + - name: fat + - name: saturated_fat + - name: carbohydrates + - name: sugars + - name: starch + - name: sodium + - name: ingredients_text + - name: ingredients_text_present + - name: contains_statement_present + - name: allergen_evidence_present + - name: fop_threshold_exceeded + - name: fop_symbol_present + - name: fop_exempt_proxy + - name: product_is_prepackaged_proxy + - name: lc + - name: lang + - name: language_code +checks: + - failed_rows: + name: fat_over_105g + expression: fat > 105 diff --git a/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/main_language_code_missing.yml b/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/main_language_code_missing.yml new file mode 100644 index 0000000000000000000000000000000000000000..a5fbd9d53adccfb8551875efa0d139326a2aa9ae --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/main_language_code_missing.yml @@ -0,0 +1,27 @@ +dataset: off_quality/main/nutrition_table +columns: + - name: product_id + - name: energy_kj + - name: energy_kj_computed + - name: energy_kcal + - name: fat + - name: saturated_fat + - name: carbohydrates + - name: sugars + - name: starch + - name: sodium + - name: ingredients_text + - name: ingredients_text_present + - name: contains_statement_present + - name: allergen_evidence_present + - name: fop_threshold_exceeded + - name: fop_symbol_present + - name: fop_exempt_proxy + - name: product_is_prepackaged_proxy + - name: lc + - name: lang + - name: language_code +checks: + - failed_rows: + name: main_language_code_missing + expression: lc IS NULL OR TRIM(lc) = '' diff --git a/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/main_language_missing.yml b/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/main_language_missing.yml new file mode 100644 index 0000000000000000000000000000000000000000..6b74857b8e43cffd35e1a3c1077853d0db0cd746 --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/main_language_missing.yml @@ -0,0 +1,27 @@ +dataset: off_quality/main/nutrition_table +columns: + - name: product_id + - name: energy_kj + - name: energy_kj_computed + - name: energy_kcal + - name: fat + - name: saturated_fat + - name: carbohydrates + - name: sugars + - name: starch + - name: sodium + - name: ingredients_text + - name: ingredients_text_present + - name: contains_statement_present + - name: allergen_evidence_present + - name: fop_threshold_exceeded + - name: fop_symbol_present + - name: fop_exempt_proxy + - name: product_is_prepackaged_proxy + - name: lc + - name: lang + - name: language_code +checks: + - failed_rows: + name: main_language_missing + expression: lang IS NULL OR TRIM(lang) = '' diff --git a/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/saturated_fat_over_105g.yml b/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/saturated_fat_over_105g.yml new file mode 100644 index 0000000000000000000000000000000000000000..5231c27a2b77079c42cf399f43abeb98fadddff7 --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/saturated_fat_over_105g.yml @@ -0,0 +1,27 @@ +dataset: off_quality/main/nutrition_table +columns: + - name: product_id + - name: energy_kj + - name: energy_kj_computed + - name: energy_kcal + - name: fat + - name: saturated_fat + - name: carbohydrates + - name: sugars + - name: starch + - name: sodium + - name: ingredients_text + - name: ingredients_text_present + - name: contains_statement_present + - name: allergen_evidence_present + - name: fop_threshold_exceeded + - name: fop_symbol_present + - name: fop_exempt_proxy + - name: product_is_prepackaged_proxy + - name: lc + - name: lang + - name: language_code +checks: + - failed_rows: + name: saturated_fat_over_105g + expression: saturated_fat > 105 diff --git a/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/saturated_fat_vs_fat.yml b/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/saturated_fat_vs_fat.yml new file mode 100644 index 0000000000000000000000000000000000000000..006010b2631a40cacf4213fcb654e928d3f885ca --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/saturated_fat_vs_fat.yml @@ -0,0 +1,27 @@ +dataset: off_quality/main/nutrition_table +columns: + - name: product_id + - name: energy_kj + - name: energy_kj_computed + - name: energy_kcal + - name: fat + - name: saturated_fat + - name: carbohydrates + - name: sugars + - name: starch + - name: sodium + - name: ingredients_text + - name: ingredients_text_present + - name: contains_statement_present + - name: allergen_evidence_present + - name: fop_threshold_exceeded + - name: fop_symbol_present + - name: fop_exempt_proxy + - name: product_is_prepackaged_proxy + - name: lc + - name: lang + - name: language_code +checks: + - failed_rows: + name: saturated_fat_vs_fat + expression: saturated_fat > (1.0 * fat + 0.001) diff --git a/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/sugars_over_105g.yml b/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/sugars_over_105g.yml new file mode 100644 index 0000000000000000000000000000000000000000..0c4f23f7f5702d18dd502ae0afe5fcc0de0b6983 --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/sugars_over_105g.yml @@ -0,0 +1,27 @@ +dataset: off_quality/main/nutrition_table +columns: + - name: product_id + - name: energy_kj + - name: energy_kj_computed + - name: energy_kcal + - name: fat + - name: saturated_fat + - name: carbohydrates + - name: sugars + - name: starch + - name: sodium + - name: ingredients_text + - name: ingredients_text_present + - name: contains_statement_present + - name: allergen_evidence_present + - name: fop_threshold_exceeded + - name: fop_symbol_present + - name: fop_exempt_proxy + - name: product_is_prepackaged_proxy + - name: lc + - name: lang + - name: language_code +checks: + - failed_rows: + name: sugars_over_105g + expression: sugars > 105 diff --git a/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/sugars_plus_starch_vs_carbohydrates.yml b/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/sugars_plus_starch_vs_carbohydrates.yml new file mode 100644 index 0000000000000000000000000000000000000000..122bedd8ec354f14556d80690dcb68a137ef6826 --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/contracts/sugars_plus_starch_vs_carbohydrates.yml @@ -0,0 +1,27 @@ +dataset: off_quality/main/nutrition_table +columns: + - name: product_id + - name: energy_kj + - name: energy_kj_computed + - name: energy_kcal + - name: fat + - name: saturated_fat + - name: carbohydrates + - name: sugars + - name: starch + - name: sodium + - name: ingredients_text + - name: ingredients_text_present + - name: contains_statement_present + - name: allergen_evidence_present + - name: fop_threshold_exceeded + - name: fop_symbol_present + - name: fop_exempt_proxy + - name: product_is_prepackaged_proxy + - name: lc + - name: lang + - name: language_code +checks: + - failed_rows: + name: sugars_plus_starch_vs_carbohydrates + expression: (sugars + starch) > (carbohydrates + 0.001) diff --git a/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/data_source.yml b/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/data_source.yml new file mode 100644 index 0000000000000000000000000000000000000000..589d1eea166af9267b347fcdd681173867240197 --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/data_source.yml @@ -0,0 +1,5 @@ +type: duckdb +name: off_quality +connection: + database: C:/dev/OFF_DataQuality_Prototype/results/declarative_runtime/soda/soda_cloud_runtime.db + schema: main diff --git a/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/soda_cloud.yml b/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/soda_cloud.yml new file mode 100644 index 0000000000000000000000000000000000000000..eccdcab464096519d4964d6cb42204dc321cdb5c --- /dev/null +++ b/OFF_DataQuality/results/declarative_runtime/soda/soda_cloud/soda_cloud.yml @@ -0,0 +1,4 @@ +soda_cloud: + host: cloud.us.soda.io + api_key_id: 500b32e7-7f6e-48d9-99b6-6baf7d493827 + api_key_secret: YhYpBOl2CcnATIhcR9hiz0ftitPJmR66MLEsgPdfkCeOCzdCRsI-gQ diff --git a/OFF_DataQuality/results/engine_comparison.json b/OFF_DataQuality/results/engine_comparison.json new file mode 100644 index 0000000000000000000000000000000000000000..eaa316068bd6e0d750b585b467366624d3cf44b5 --- /dev/null +++ b/OFF_DataQuality/results/engine_comparison.json @@ -0,0 +1,2427 @@ +{ + "generated_at_utc": "2026-03-20T02:16:51.454190+00:00", + "comparison_fingerprint": { + "comparison_run_id": "comparison_20260320T021651454190p0000_802895b4", + "comparison_sha256": "5e38ef21823aded9830415be43d4189df6c1b7facaa3942d11746129d5cbec94", + "engine_run_ids": { + "python": "parity_20260320T020923217791p0000_522963ec", + "dbt": "parity_20260320T021319241433p0000_babb0a3c", + "soda": "parity_20260320T021651369626p0000_93e7e9a5" + }, + "dataset_fingerprint_sha256_by_engine": { + "python": "edc06c70fc61d470398d05743822716e42722100fe4f1dcb721aff4895aabd76", + "dbt": "edc06c70fc61d470398d05743822716e42722100fe4f1dcb721aff4895aabd76", + "soda": "edc06c70fc61d470398d05743822716e42722100fe4f1dcb721aff4895aabd76" + }, + "rulepack_fingerprint_sha256_by_engine": { + "python": "ceec8ffe16d3fc6fd32744c834c7a34068b108a398f12c9abf86da0f5a390149", + "dbt": "ceec8ffe16d3fc6fd32744c834c7a34068b108a398f12c9abf86da0f5a390149", + "soda": "ceec8ffe16d3fc6fd32744c834c7a34068b108a398f12c9abf86da0f5a390149" + }, + "dataset_fingerprint_consistent": true, + "rulepack_fingerprint_consistent": true, + "dataset_fingerprint_sha256": "edc06c70fc61d470398d05743822716e42722100fe4f1dcb721aff4895aabd76", + "rulepack_fingerprint_sha256": "ceec8ffe16d3fc6fd32744c834c7a34068b108a398f12c9abf86da0f5a390149", + "code_commit": "fdda1c042a421a0dd81a90c7ca692dccb4915106", + "code_commits_by_engine": { + "python": "fdda1c042a421a0dd81a90c7ca692dccb4915106", + "dbt": "fdda1c042a421a0dd81a90c7ca692dccb4915106", + "soda": "fdda1c042a421a0dd81a90c7ca692dccb4915106" + } + }, + "comparison_method": { + "best_engine_ranking": "Prefer MATCH status, then fewer mismatches, then higher effective_confidence. effective_confidence = overall_confidence * provider_factor.", + "decision_score": "decision_score = effective_confidence + architecture_bonus(declarative for simple rules / python for complex rules) - mismatch_penalty - review_penalty.", + "hybrid_tie_break": "If python and best declarative engine are close (within 0.20 effective confidence): prefer declarative for declarative-friendly rules, prefer python for non-declarative rules.", + "declarative_tie_break": "When dbt and soda are exactly tied on status/mismatches/scores for a rule, use a stable hash of rule_name to select dbt or soda explicitly.", + "provider_factor_notes": { + "python_real_llm": 1.0, + "python_simulated_fallback": 0.55, + "dbt_sql_fallback": 0.85, + "soda_cloud": 1.0, + "soda_sql_fallback": 0.85 + } + }, + "dataset": { + "jsonl_path": "C:\\dev\\OFF_DataQuality_Prototype\\data\\sample_products.jsonl", + "duckdb_path": "C:\\dev\\OFF_DataQuality_Prototype\\off_quality.db", + "products_tested": 400, + "source_jsonl": "C:\\dev\\OFF_DataQuality_Prototype\\openfoodfacts-products.jsonl", + "perl_rules_source": "inline_legacy_rules", + "execution_engine": "python", + "soda_mode": "cloud", + "profile": "hybrid", + "profile_rule_count": 19, + "dataset_fingerprint_sha256": "edc06c70fc61d470398d05743822716e42722100fe4f1dcb721aff4895aabd76", + "rulepack_fingerprint_sha256": "ceec8ffe16d3fc6fd32744c834c7a34068b108a398f12c9abf86da0f5a390149" + }, + "engines": [ + "python", + "dbt", + "soda" + ], + "engine_run_fingerprints": { + "python": { + "run_id": "parity_20260320T020923217791p0000_522963ec", + "generated_at_utc": "2026-03-20T02:09:23.217791+00:00", + "execution_engine": "python", + "soda_mode": "cloud", + "llm_provider": "groq", + "llm_model": "openai/gpt-oss-120b", + "code_commit": "fdda1c042a421a0dd81a90c7ca692dccb4915106", + "dataset_fingerprint": { + "source_mode": "off_jsonl", + "source_jsonl": "C:\\dev\\OFF_DataQuality_Prototype\\openfoodfacts-products.jsonl", + "requested_size": 400, + "products_tested": 400, + "seed": null, + "product_id_first": "0000101209159", + "product_id_last": "0008295663177", + "sha256": "edc06c70fc61d470398d05743822716e42722100fe4f1dcb721aff4895aabd76" + }, + "rulepack_fingerprint": { + "profile": "hybrid", + "rule_count": 19, + "rule_names_sha256": "c39c2b95539ad714a422b372ca37457381efad3eab0ab3cf6183fb84e78799b2", + "rule_ir_sha256": "ceec8ffe16d3fc6fd32744c834c7a34068b108a398f12c9abf86da0f5a390149" + } + }, + "dbt": { + "run_id": "parity_20260320T021319241433p0000_babb0a3c", + "generated_at_utc": "2026-03-20T02:13:19.241433+00:00", + "execution_engine": "dbt", + "soda_mode": "cloud", + "llm_provider": "groq", + "llm_model": "openai/gpt-oss-120b", + "code_commit": "fdda1c042a421a0dd81a90c7ca692dccb4915106", + "dataset_fingerprint": { + "source_mode": "off_jsonl", + "source_jsonl": "C:\\dev\\OFF_DataQuality_Prototype\\openfoodfacts-products.jsonl", + "requested_size": 400, + "products_tested": 400, + "seed": null, + "product_id_first": "0000101209159", + "product_id_last": "0008295663177", + "sha256": "edc06c70fc61d470398d05743822716e42722100fe4f1dcb721aff4895aabd76" + }, + "rulepack_fingerprint": { + "profile": "hybrid", + "rule_count": 19, + "rule_names_sha256": "c39c2b95539ad714a422b372ca37457381efad3eab0ab3cf6183fb84e78799b2", + "rule_ir_sha256": "ceec8ffe16d3fc6fd32744c834c7a34068b108a398f12c9abf86da0f5a390149" + } + }, + "soda": { + "run_id": "parity_20260320T021651369626p0000_93e7e9a5", + "generated_at_utc": "2026-03-20T02:16:51.369626+00:00", + "execution_engine": "soda", + "soda_mode": "cloud", + "llm_provider": "groq", + "llm_model": "openai/gpt-oss-120b", + "code_commit": "fdda1c042a421a0dd81a90c7ca692dccb4915106", + "dataset_fingerprint": { + "source_mode": "off_jsonl", + "source_jsonl": "C:\\dev\\OFF_DataQuality_Prototype\\openfoodfacts-products.jsonl", + "requested_size": 400, + "products_tested": 400, + "seed": null, + "product_id_first": "0000101209159", + "product_id_last": "0008295663177", + "sha256": "edc06c70fc61d470398d05743822716e42722100fe4f1dcb721aff4895aabd76" + }, + "rulepack_fingerprint": { + "profile": "hybrid", + "rule_count": 19, + "rule_names_sha256": "c39c2b95539ad714a422b372ca37457381efad3eab0ab3cf6183fb84e78799b2", + "rule_ir_sha256": "ceec8ffe16d3fc6fd32744c834c7a34068b108a398f12c9abf86da0f5a390149" + } + } + }, + "per_engine_summary": { + "python": { + "rules": 19, + "passed": 19, + "avg_overall_confidence": 0.2826, + "avg_effective_confidence": 0.2826, + "avg_parity_ci_lower": 0.9905, + "avg_equivalence_rate": 1.0, + "avg_mutation_score": 0.6053, + "fallback_rules": 0, + "real_llm_rules": 19, + "real_llm_rate": 1.0, + "repairs_applied": 0 + }, + "dbt": { + "rules": 19, + "passed": 19, + "avg_overall_confidence": 0.2946, + "avg_effective_confidence": 0.2946, + "avg_parity_ci_lower": 0.9905, + "avg_equivalence_rate": 1.0, + "avg_mutation_score": 1.0, + "fallback_rules": 0 + }, + "soda": { + "rules": 19, + "passed": 19, + "avg_overall_confidence": 0.2946, + "avg_effective_confidence": 0.2946, + "avg_parity_ci_lower": 0.9905, + "avg_equivalence_rate": 1.0, + "avg_mutation_score": 1.0, + "fallback_rules": 0 + } + }, + "per_complexity_summary": { + "simple": { + "rules": 9, + "python_wins": 0, + "dbt_wins": 5, + "soda_wins": 4, + "avg_best_effective_confidence": 0.4464 + }, + "medium": { + "rules": 6, + "python_wins": 0, + "dbt_wins": 4, + "soda_wins": 2, + "avg_best_effective_confidence": 0.2306 + }, + "intricate": { + "rules": 4, + "python_wins": 4, + "dbt_wins": 0, + "soda_wins": 0, + "avg_best_effective_confidence": 0.0446 + } + }, + "rule_comparison": [ + { + "rule_name": "ca_allergen_evidence_missing_ingredients_text", + "tag": "ca-allergen-evidence-but-missing-ingredients-text", + "severity": "warning", + "condition": "allergen_evidence_present > 0.0 && ingredients_text_present == 0.0", + "jurisdiction": "ca", + "profile_tags": [ + "canada", + "hybrid" + ], + "regulatory_type": "statutory_proxy", + "legal_citation": "FDR B.01.010.1(2); FDR B.01.010.3", + "source_url": "https://laws-lois.justice.gc.ca/eng/regulations/C.R.C.,_c._870/section-B.01.010.1.html", + "effective_date": "2012-08-04", + "review_status": "draft", + "reviewer": "pending-mentor-review", + "required_fields": [ + "allergen_evidence_present", + "ingredients_text_present", + "ingredients_text" + ], + "exemption_logic": "Proxy check: flags records with allergen evidence but no ingredient text present.", + "rule_notes": "Phase-1 Canada allergen rule using OFF-available proxy fields.", + "rule_ir_hash": "89636a09e83b", + "condition_type": "compound_threshold_and", + "complexity": "medium", + "declarative_friendly": true, + "products_tested": 400, + "best_engine": "soda", + "selection_reason": "hybrid-close-declarative:explicit-hash-tie-break-odd->soda", + "declarative_tie_break_applied": true, + "recommendation": "Declarative-friendly rule; prefer dbt/soda for readability and operations.", + "engines": { + "python": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.2015, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 2, + "mutation_score": 1.0, + "mutation_total": 0, + "mutation_killed": 0, + "verification_score": 1.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.2015, + "provider_factor": 1.0, + "real_llm_used": true, + "decision_score": 0.3015, + "conversion_provider": "groq", + "conversion_notes": "Converted via Groq (openai/gpt-oss-120b).", + "execution_mode": "", + "cloud_connected": false, + "cloud_scan_id": "", + "cloud_scan_url": "", + "conversion_artifact": "def check_ca_allergen_evidence_missing_ingredients_text(product):\n \"\"\"\n Returns the rule tag if allergen evidence is present (>0) while ingredients text is missing (==0).\n Returns None otherwise or if required fields are missing/non-numeric.\n \"\"\"\n tag = \"ca-allergen-evidence-but-missing-ingredients-text\"\n\n allergen_val = product.get(\"allergen_evidence_present\")\n ingredients_val = product.get(\"ingredients_text_present\")\n\n # If either value is missing or not a number, do not flag a violation\n if allergen_val is None or ingredients_val is None:\n return None\n if not isinstance(allergen_val, (int, float)) or not isinstance(ingredients_val, (int, float)):\n return None\n\n if allergen_val > 0.0 and ingredients_val == 0.0:\n return tag\n return None", + "conversion_lines": 19, + "failed_test_cases": [] + }, + "dbt": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.2193, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 0, + "mutation_score": 1.0, + "mutation_total": 0, + "mutation_killed": 0, + "verification_score": 1.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.2193, + "provider_factor": 1.0, + "real_llm_used": null, + "decision_score": 0.2543, + "conversion_provider": "dbt_core", + "conversion_notes": "dbt tests executed through dbt-core. Command: dbt debug + dbt run-operation count_violations (per-rule x19) --project-dir C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\dbt\\dbt_project --profiles-dir C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\dbt\\dbt_project | Success: True | Return code: 0", + "execution_mode": "local", + "cloud_connected": false, + "cloud_scan_id": "", + "cloud_scan_url": "", + "conversion_artifact": "SELECT product_id\nFROM {{ source('off_source', 'nutrition_table') }}\nWHERE allergen_evidence_present > 0.0 AND ingredients_text_present == 0.0", + "conversion_lines": 3, + "failed_test_cases": [] + }, + "soda": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.2193, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 0, + "mutation_score": 1.0, + "mutation_total": 0, + "mutation_killed": 0, + "verification_score": 1.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.2193, + "provider_factor": 1.0, + "real_llm_used": null, + "decision_score": 0.2543, + "conversion_provider": "soda_cloud", + "conversion_notes": "Soda Cloud scan executed successfully. Command: soda contract verify (per-rule x19) -ds C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\soda\\soda_cloud\\data_source.yml -sc C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\soda\\soda_cloud\\soda_cloud.yml -p | Success: True | Return code: 0", + "execution_mode": "cloud", + "cloud_connected": true, + "cloud_scan_id": "", + "cloud_scan_url": "https://cloud.us.soda.io/o/c9e7e376-1da2-49c5-93cb-78c6d95273ee/datasets/5e60cafe-18fc-4d01-8390-0057b49d7765", + "conversion_artifact": " - failed_rows:\n name: ca_allergen_evidence_missing_ingredients_text\n expression: allergen_evidence_present > 0.0 AND ingredients_text_present == 0.0", + "conversion_lines": 3, + "failed_test_cases": [] + } + } + }, + { + "rule_name": "ca_contains_statement_without_allergen_evidence", + "tag": "ca-contains-statement-without-allergen-evidence", + "severity": "warning", + "condition": "contains_statement_present > 0.0 && allergen_evidence_present == 0.0", + "jurisdiction": "ca", + "profile_tags": [ + "canada", + "hybrid" + ], + "regulatory_type": "statutory_proxy", + "legal_citation": "FDR B.01.010.3(1)(b), (2)", + "source_url": "https://laws-lois.justice.gc.ca/eng/regulations/C.R.C.,_c._870/section-B.01.010.3.html", + "effective_date": "2012-08-04", + "review_status": "draft", + "reviewer": "pending-mentor-review", + "required_fields": [ + "contains_statement_present", + "allergen_evidence_present" + ], + "exemption_logic": "Proxy check: 'contains' proxy without allergen evidence proxy.", + "rule_notes": "Phase-1 Canada allergen consistency rule.", + "rule_ir_hash": "224946da0a1f", + "condition_type": "compound_threshold_and", + "complexity": "medium", + "declarative_friendly": true, + "products_tested": 400, + "best_engine": "dbt", + "selection_reason": "hybrid-close-declarative:explicit-hash-tie-break-even->dbt", + "declarative_tie_break_applied": true, + "recommendation": "Declarative-friendly rule; prefer dbt/soda for readability and operations.", + "engines": { + "python": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.0451, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 2, + "mutation_score": 1.0, + "mutation_total": 0, + "mutation_killed": 0, + "verification_score": 1.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.0451, + "provider_factor": 1.0, + "real_llm_used": true, + "decision_score": 0.1451, + "conversion_provider": "groq", + "conversion_notes": "Converted via Groq (openai/gpt-oss-120b).", + "execution_mode": "", + "cloud_connected": false, + "cloud_scan_id": "", + "cloud_scan_url": "", + "conversion_artifact": "def check_ca_contains_statement_without_allergen_evidence(product: dict):\n tag = \"ca-contains-statement-without-allergen-evidence\"\n cs = product.get(\"contains_statement_present\")\n ae = product.get(\"allergen_evidence_present\")\n # If either value is missing or not numeric, do not flag\n if cs is None or ae is None:\n return None\n if not isinstance(cs, (int, float)) or not isinstance(ae, (int, float)):\n return None\n if cs > 0.0 and ae == 0.0:\n return tag\n return None", + "conversion_lines": 12, + "failed_test_cases": [] + }, + "dbt": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.049, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 0, + "mutation_score": 1.0, + "mutation_total": 0, + "mutation_killed": 0, + "verification_score": 1.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.049, + "provider_factor": 1.0, + "real_llm_used": null, + "decision_score": 0.084, + "conversion_provider": "dbt_core", + "conversion_notes": "dbt tests executed through dbt-core. Command: dbt debug + dbt run-operation count_violations (per-rule x19) --project-dir C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\dbt\\dbt_project --profiles-dir C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\dbt\\dbt_project | Success: True | Return code: 0", + "execution_mode": "local", + "cloud_connected": false, + "cloud_scan_id": "", + "cloud_scan_url": "", + "conversion_artifact": "SELECT product_id\nFROM {{ source('off_source', 'nutrition_table') }}\nWHERE contains_statement_present > 0.0 AND allergen_evidence_present == 0.0", + "conversion_lines": 3, + "failed_test_cases": [] + }, + "soda": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.049, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 0, + "mutation_score": 1.0, + "mutation_total": 0, + "mutation_killed": 0, + "verification_score": 1.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.049, + "provider_factor": 1.0, + "real_llm_used": null, + "decision_score": 0.084, + "conversion_provider": "soda_cloud", + "conversion_notes": "Soda Cloud scan executed successfully. Command: soda contract verify (per-rule x19) -ds C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\soda\\soda_cloud\\data_source.yml -sc C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\soda\\soda_cloud\\soda_cloud.yml -p | Success: True | Return code: 0", + "execution_mode": "cloud", + "cloud_connected": true, + "cloud_scan_id": "", + "cloud_scan_url": "https://cloud.us.soda.io/o/c9e7e376-1da2-49c5-93cb-78c6d95273ee/datasets/5e60cafe-18fc-4d01-8390-0057b49d7765", + "conversion_artifact": " - failed_rows:\n name: ca_contains_statement_without_allergen_evidence\n expression: contains_statement_present > 0.0 AND allergen_evidence_present == 0.0", + "conversion_lines": 3, + "failed_test_cases": [] + } + } + }, + { + "rule_name": "ca_fop_required_but_symbol_missing", + "tag": "ca-fop-required-but-symbol-missing", + "severity": "error", + "condition": "fop_threshold_exceeded > 0.0 && fop_symbol_present == 0.0 && fop_exempt_proxy == 0.0 && product_is_prepackaged_proxy > 0.0", + "jurisdiction": "ca", + "profile_tags": [ + "canada", + "hybrid" + ], + "regulatory_type": "statutory_proxy", + "legal_citation": "FDR B.01.350(1)", + "source_url": "https://laws-lois.justice.gc.ca/eng/regulations/C.R.C.,_c._870/section-B.01.350.html", + "effective_date": "2026-01-01", + "review_status": "draft", + "reviewer": "pending-mentor-review", + "required_fields": [ + "fop_threshold_exceeded", + "fop_symbol_present", + "fop_exempt_proxy", + "product_is_prepackaged_proxy" + ], + "exemption_logic": "Applies only when proxy not exempt and prepackaged proxy is true.", + "rule_notes": "Phase-1 Canada FOP threshold-vs-symbol proxy.", + "rule_ir_hash": "6a505be71205", + "condition_type": "compound_threshold_and", + "complexity": "medium", + "declarative_friendly": true, + "products_tested": 400, + "best_engine": "dbt", + "selection_reason": "hybrid-close-declarative:explicit-hash-tie-break-even->dbt", + "declarative_tie_break_applied": true, + "recommendation": "Declarative-friendly rule; prefer dbt/soda for readability and operations.", + "engines": { + "python": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.8902, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 2, + "mutation_score": 1.0, + "mutation_total": 0, + "mutation_killed": 0, + "verification_score": 1.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.8902, + "provider_factor": 1.0, + "real_llm_used": true, + "decision_score": 0.9902, + "conversion_provider": "groq", + "conversion_notes": "Converted via Groq (openai/gpt-oss-120b).", + "execution_mode": "", + "cloud_connected": false, + "cloud_scan_id": "", + "cloud_scan_url": "", + "conversion_artifact": "def check_ca_fop_required_but_symbol_missing(product):\n \"\"\"\n Returns the rule tag \"ca-fop-required-but-symbol-missing\" if the compound condition is met,\n otherwise returns None.\n \"\"\"\n # Extract required fields\n fop_threshold_exceeded = product.get(\"fop_threshold_exceeded\")\n fop_symbol_present = product.get(\"fop_symbol_present\")\n fop_exempt_proxy = product.get(\"fop_exempt_proxy\")\n product_is_prepackaged_proxy = product.get(\"product_is_prepackaged_proxy\")\n\n # If any required field is missing or not a number, do not flag a violation\n for value in (\n fop_threshold_exceeded,\n fop_symbol_present,\n fop_exempt_proxy,\n product_is_prepackaged_proxy,\n ):\n if value is None:\n return None\n if not isinstance(value, (int, float)):\n return None\n\n # Evaluate the compound condition\n if (\n fop_threshold_exceeded > 0.0\n and fop_symbol_present == 0.0\n and fop_exempt_proxy == 0.0\n and product_is_prepackaged_proxy > 0.0\n ):\n return \"ca-fop-required-but-symbol-missing\"\n\n return None", + "conversion_lines": 33, + "failed_test_cases": [] + }, + "dbt": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.9684, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 0, + "mutation_score": 1.0, + "mutation_total": 0, + "mutation_killed": 0, + "verification_score": 1.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.9684, + "provider_factor": 1.0, + "real_llm_used": null, + "decision_score": 1.0034, + "conversion_provider": "dbt_core", + "conversion_notes": "dbt tests executed through dbt-core. Command: dbt debug + dbt run-operation count_violations (per-rule x19) --project-dir C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\dbt\\dbt_project --profiles-dir C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\dbt\\dbt_project | Success: True | Return code: 0", + "execution_mode": "local", + "cloud_connected": false, + "cloud_scan_id": "", + "cloud_scan_url": "", + "conversion_artifact": "SELECT product_id\nFROM {{ source('off_source', 'nutrition_table') }}\nWHERE fop_threshold_exceeded > 0.0 AND fop_symbol_present == 0.0 AND fop_exempt_proxy == 0.0 AND product_is_prepackaged_proxy > 0.0", + "conversion_lines": 3, + "failed_test_cases": [] + }, + "soda": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.9684, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 0, + "mutation_score": 1.0, + "mutation_total": 0, + "mutation_killed": 0, + "verification_score": 1.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.9684, + "provider_factor": 1.0, + "real_llm_used": null, + "decision_score": 1.0034, + "conversion_provider": "soda_cloud", + "conversion_notes": "Soda Cloud scan executed successfully. Command: soda contract verify (per-rule x19) -ds C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\soda\\soda_cloud\\data_source.yml -sc C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\soda\\soda_cloud\\soda_cloud.yml -p | Success: True | Return code: 0", + "execution_mode": "cloud", + "cloud_connected": true, + "cloud_scan_id": "", + "cloud_scan_url": "https://cloud.us.soda.io/o/c9e7e376-1da2-49c5-93cb-78c6d95273ee/datasets/5e60cafe-18fc-4d01-8390-0057b49d7765", + "conversion_artifact": " - failed_rows:\n name: ca_fop_required_but_symbol_missing\n expression: fop_threshold_exceeded > 0.0 AND fop_symbol_present == 0.0 AND fop_exempt_proxy == 0.0 AND product_is_prepackaged_proxy > 0.0", + "conversion_lines": 3, + "failed_test_cases": [] + } + } + }, + { + "rule_name": "ca_fop_symbol_present_but_not_required", + "tag": "ca-fop-symbol-present-but-not-required", + "severity": "warning", + "condition": "fop_symbol_present > 0.0 && fop_threshold_exceeded == 0.0 && fop_exempt_proxy == 0.0 && product_is_prepackaged_proxy > 0.0", + "jurisdiction": "ca", + "profile_tags": [ + "canada", + "hybrid" + ], + "regulatory_type": "guidance_proxy", + "legal_citation": "FDR B.01.350; CFIA FOP guidance", + "source_url": "https://inspection.canada.ca/en/food-labels/labelling/industry/nutrition-labelling/fop-nutrition-symbol", + "effective_date": "2026-01-01", + "review_status": "draft", + "reviewer": "pending-mentor-review", + "required_fields": [ + "fop_threshold_exceeded", + "fop_symbol_present", + "fop_exempt_proxy", + "product_is_prepackaged_proxy" + ], + "exemption_logic": "Proxy warning for symbol present when threshold proxy not exceeded and not exempt.", + "rule_notes": "Phase-1 Canada FOP over-labelling consistency rule.", + "rule_ir_hash": "4d20f5612a17", + "condition_type": "compound_threshold_and", + "complexity": "medium", + "declarative_friendly": true, + "products_tested": 400, + "best_engine": "dbt", + "selection_reason": "hybrid-close-declarative:explicit-hash-tie-break-even->dbt", + "declarative_tie_break_applied": true, + "recommendation": "Declarative-friendly rule; prefer dbt/soda for readability and operations.", + "engines": { + "python": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.0451, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 2, + "mutation_score": 1.0, + "mutation_total": 0, + "mutation_killed": 0, + "verification_score": 1.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.0451, + "provider_factor": 1.0, + "real_llm_used": true, + "decision_score": 0.1451, + "conversion_provider": "groq", + "conversion_notes": "Converted via Groq (openai/gpt-oss-120b).", + "execution_mode": "", + "cloud_connected": false, + "cloud_scan_id": "", + "cloud_scan_url": "", + "conversion_artifact": "def check_ca_fop_symbol_present_but_not_required(product: dict):\n tag = \"ca-fop-symbol-present-but-not-required\"\n # Required fields\n fields = [\"fop_symbol_present\", \"fop_threshold_exceeded\", \"fop_exempt_proxy\", \"product_is_prepackaged_proxy\"]\n values = {}\n for f in fields:\n v = product.get(f, None)\n # Missing field rule: None, empty, whitespace -> violation (but not applicable for this rule type)\n if v is None:\n return None\n # Non-numeric check for field_comparison/threshold rules\n if not isinstance(v, (int, float)):\n return None\n values[f] = v\n if (values[\"fop_symbol_present\"] > 0.0 and\n values[\"fop_threshold_exceeded\"] == 0.0 and\n values[\"fop_exempt_proxy\"] == 0.0 and\n values[\"product_is_prepackaged_proxy\"] > 0.0):\n return tag\n return None", + "conversion_lines": 20, + "failed_test_cases": [] + }, + "dbt": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.049, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 0, + "mutation_score": 1.0, + "mutation_total": 0, + "mutation_killed": 0, + "verification_score": 1.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.049, + "provider_factor": 1.0, + "real_llm_used": null, + "decision_score": 0.084, + "conversion_provider": "dbt_core", + "conversion_notes": "dbt tests executed through dbt-core. Command: dbt debug + dbt run-operation count_violations (per-rule x19) --project-dir C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\dbt\\dbt_project --profiles-dir C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\dbt\\dbt_project | Success: True | Return code: 0", + "execution_mode": "local", + "cloud_connected": false, + "cloud_scan_id": "", + "cloud_scan_url": "", + "conversion_artifact": "SELECT product_id\nFROM {{ source('off_source', 'nutrition_table') }}\nWHERE fop_symbol_present > 0.0 AND fop_threshold_exceeded == 0.0 AND fop_exempt_proxy == 0.0 AND product_is_prepackaged_proxy > 0.0", + "conversion_lines": 3, + "failed_test_cases": [] + }, + "soda": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.049, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 0, + "mutation_score": 1.0, + "mutation_total": 0, + "mutation_killed": 0, + "verification_score": 1.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.049, + "provider_factor": 1.0, + "real_llm_used": null, + "decision_score": 0.084, + "conversion_provider": "soda_cloud", + "conversion_notes": "Soda Cloud scan executed successfully. Command: soda contract verify (per-rule x19) -ds C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\soda\\soda_cloud\\data_source.yml -sc C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\soda\\soda_cloud\\soda_cloud.yml -p | Success: True | Return code: 0", + "execution_mode": "cloud", + "cloud_connected": true, + "cloud_scan_id": "", + "cloud_scan_url": "https://cloud.us.soda.io/o/c9e7e376-1da2-49c5-93cb-78c6d95273ee/datasets/5e60cafe-18fc-4d01-8390-0057b49d7765", + "conversion_artifact": " - failed_rows:\n name: ca_fop_symbol_present_but_not_required\n expression: fop_symbol_present > 0.0 AND fop_threshold_exceeded == 0.0 AND fop_exempt_proxy == 0.0 AND product_is_prepackaged_proxy > 0.0", + "conversion_lines": 3, + "failed_test_cases": [] + } + } + }, + { + "rule_name": "ca_fop_symbol_present_on_exempt_product", + "tag": "ca-fop-symbol-present-on-exempt-product", + "severity": "warning", + "condition": "fop_symbol_present > 0.0 && fop_exempt_proxy > 0.0 && product_is_prepackaged_proxy > 0.0", + "jurisdiction": "ca", + "profile_tags": [ + "canada", + "hybrid" + ], + "regulatory_type": "guidance_proxy", + "legal_citation": "FDR B.01.350(5)-(15)", + "source_url": "https://laws-lois.justice.gc.ca/eng/regulations/C.R.C.,_c._870/section-B.01.350.html", + "effective_date": "2026-01-01", + "review_status": "draft", + "reviewer": "pending-mentor-review", + "required_fields": [ + "fop_symbol_present", + "fop_exempt_proxy", + "product_is_prepackaged_proxy" + ], + "exemption_logic": "Proxy warning on symbol presence for exempt categories.", + "rule_notes": "Phase-1 Canada FOP exemption consistency rule.", + "rule_ir_hash": "4e274edaa3ca", + "condition_type": "compound_threshold_and", + "complexity": "medium", + "declarative_friendly": true, + "products_tested": 400, + "best_engine": "soda", + "selection_reason": "hybrid-close-declarative:explicit-hash-tie-break-odd->soda", + "declarative_tie_break_applied": true, + "recommendation": "Declarative-friendly rule; prefer dbt/soda for readability and operations.", + "engines": { + "python": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.0451, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 2, + "mutation_score": 1.0, + "mutation_total": 0, + "mutation_killed": 0, + "verification_score": 1.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.0451, + "provider_factor": 1.0, + "real_llm_used": true, + "decision_score": 0.1451, + "conversion_provider": "groq", + "conversion_notes": "Converted via Groq (openai/gpt-oss-120b).", + "execution_mode": "", + "cloud_connected": false, + "cloud_scan_id": "", + "cloud_scan_url": "", + "conversion_artifact": "def check_ca_fop_symbol_present_on_exempt_product(product: dict):\n \"\"\"\n Returns the rule tag if the product violates the rule:\n fop_symbol_present > 0.0 && fop_exempt_proxy > 0.0 && product_is_prepackaged_proxy > 0.0\n Otherwise returns None.\n \"\"\"\n tag = \"ca-fop-symbol-present-on-exempt-product\"\n\n # Helper to validate numeric fields\n def _is_valid_number(value):\n return isinstance(value, (int, float)) and not isinstance(value, bool)\n\n fop_symbol_present = product.get(\"fop_symbol_present\")\n fop_exempt_proxy = product.get(\"fop_exempt_proxy\")\n product_is_prepackaged_proxy = product.get(\"product_is_prepackaged_proxy\")\n\n # If any required field is missing or not numeric, rule does not apply\n if not (_is_valid_number(fop_symbol_present) and\n _is_valid_number(fop_exempt_proxy) and\n _is_valid_number(product_is_prepackaged_proxy)):\n return None\n\n if (fop_symbol_present > 0.0 and\n fop_exempt_proxy > 0.0 and\n product_is_prepackaged_proxy > 0.0):\n return tag\n\n return None", + "conversion_lines": 28, + "failed_test_cases": [] + }, + "dbt": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.049, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 0, + "mutation_score": 1.0, + "mutation_total": 0, + "mutation_killed": 0, + "verification_score": 1.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.049, + "provider_factor": 1.0, + "real_llm_used": null, + "decision_score": 0.084, + "conversion_provider": "dbt_core", + "conversion_notes": "dbt tests executed through dbt-core. Command: dbt debug + dbt run-operation count_violations (per-rule x19) --project-dir C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\dbt\\dbt_project --profiles-dir C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\dbt\\dbt_project | Success: True | Return code: 0", + "execution_mode": "local", + "cloud_connected": false, + "cloud_scan_id": "", + "cloud_scan_url": "", + "conversion_artifact": "SELECT product_id\nFROM {{ source('off_source', 'nutrition_table') }}\nWHERE fop_symbol_present > 0.0 AND fop_exempt_proxy > 0.0 AND product_is_prepackaged_proxy > 0.0", + "conversion_lines": 3, + "failed_test_cases": [] + }, + "soda": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.049, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 0, + "mutation_score": 1.0, + "mutation_total": 0, + "mutation_killed": 0, + "verification_score": 1.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.049, + "provider_factor": 1.0, + "real_llm_used": null, + "decision_score": 0.084, + "conversion_provider": "soda_cloud", + "conversion_notes": "Soda Cloud scan executed successfully. Command: soda contract verify (per-rule x19) -ds C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\soda\\soda_cloud\\data_source.yml -sc C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\soda\\soda_cloud\\soda_cloud.yml -p | Success: True | Return code: 0", + "execution_mode": "cloud", + "cloud_connected": true, + "cloud_scan_id": "", + "cloud_scan_url": "https://cloud.us.soda.io/o/c9e7e376-1da2-49c5-93cb-78c6d95273ee/datasets/5e60cafe-18fc-4d01-8390-0057b49d7765", + "conversion_artifact": " - failed_rows:\n name: ca_fop_symbol_present_on_exempt_product\n expression: fop_symbol_present > 0.0 AND fop_exempt_proxy > 0.0 AND product_is_prepackaged_proxy > 0.0", + "conversion_lines": 3, + "failed_test_cases": [] + } + } + }, + { + "rule_name": "carbohydrates_over_105g", + "tag": "carbohydrates-value-over-105g", + "severity": "warning", + "condition": "carbohydrates > 105", + "jurisdiction": "global", + "profile_tags": [ + "global", + "hybrid" + ], + "regulatory_type": "off_internal", + "legal_citation": "", + "source_url": "", + "effective_date": "", + "review_status": "reviewed", + "reviewer": "prototype", + "required_fields": [], + "exemption_logic": "none", + "rule_notes": "OFF-derived global rule: carbohydrates_over_105g", + "rule_ir_hash": "7261087f016d", + "condition_type": "field_threshold", + "complexity": "simple", + "declarative_friendly": true, + "products_tested": 400, + "best_engine": "soda", + "selection_reason": "hybrid-close-declarative:explicit-hash-tie-break-odd->soda", + "declarative_tie_break_applied": true, + "recommendation": "Declarative-friendly rule; prefer dbt/soda for readability and operations.", + "engines": { + "python": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.9181, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 22, + "mutation_score": 1.0, + "mutation_total": 1, + "mutation_killed": 1, + "verification_score": 1.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.9181, + "provider_factor": 1.0, + "real_llm_used": true, + "decision_score": 1.0181, + "conversion_provider": "groq", + "conversion_notes": "Converted via Groq (openai/gpt-oss-120b).", + "execution_mode": "", + "cloud_connected": false, + "cloud_scan_id": "", + "cloud_scan_url": "", + "conversion_artifact": "def check_carbohydrates_over_105g(product: dict):\n \"\"\"\n Returns the tag 'carbohydrates-value-over-105g' if the product's\n 'carbohydrates' field is numeric and greater than 105.\n Otherwise returns None.\n \"\"\"\n tag = \"carbohydrates-value-over-105g\"\n value = product.get(\"carbohydrates\", None)\n\n # If the value is missing or not a number, do not flag a violation\n if value is None or not isinstance(value, (int, float)):\n return None\n\n # Check the threshold condition\n if value > 105:\n return tag\n\n return None", + "conversion_lines": 18, + "failed_test_cases": [] + }, + "dbt": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.9371, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 0, + "mutation_score": 1.0, + "mutation_total": 0, + "mutation_killed": 0, + "verification_score": 1.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.9371, + "provider_factor": 1.0, + "real_llm_used": null, + "decision_score": 0.9721, + "conversion_provider": "dbt_core", + "conversion_notes": "dbt tests executed through dbt-core. Command: dbt debug + dbt run-operation count_violations (per-rule x19) --project-dir C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\dbt\\dbt_project --profiles-dir C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\dbt\\dbt_project | Success: True | Return code: 0", + "execution_mode": "local", + "cloud_connected": false, + "cloud_scan_id": "", + "cloud_scan_url": "", + "conversion_artifact": "SELECT product_id\nFROM {{ source('off_source', 'nutrition_table') }}\nWHERE carbohydrates > 105", + "conversion_lines": 3, + "failed_test_cases": [] + }, + "soda": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.9371, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 0, + "mutation_score": 1.0, + "mutation_total": 0, + "mutation_killed": 0, + "verification_score": 1.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.9371, + "provider_factor": 1.0, + "real_llm_used": null, + "decision_score": 0.9721, + "conversion_provider": "soda_cloud", + "conversion_notes": "Soda Cloud scan executed successfully. Command: soda contract verify (per-rule x19) -ds C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\soda\\soda_cloud\\data_source.yml -sc C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\soda\\soda_cloud\\soda_cloud.yml -p | Success: True | Return code: 0", + "execution_mode": "cloud", + "cloud_connected": true, + "cloud_scan_id": "", + "cloud_scan_url": "https://cloud.us.soda.io/o/c9e7e376-1da2-49c5-93cb-78c6d95273ee/datasets/5e60cafe-18fc-4d01-8390-0057b49d7765", + "conversion_artifact": " - failed_rows:\n name: carbohydrates_over_105g\n expression: carbohydrates > 105", + "conversion_lines": 3, + "failed_test_cases": [] + } + } + }, + { + "rule_name": "energy_kcal_vs_kj", + "tag": "energy-value-in-kcal-greater-than-in-kj", + "severity": "error", + "condition": "energy_kcal > energy_kj", + "jurisdiction": "global", + "profile_tags": [ + "global", + "hybrid" + ], + "regulatory_type": "off_internal", + "legal_citation": "", + "source_url": "", + "effective_date": "", + "review_status": "reviewed", + "reviewer": "prototype", + "required_fields": [], + "exemption_logic": "none", + "rule_notes": "OFF-derived global rule: energy_kcal_vs_kj", + "rule_ir_hash": "413d25898535", + "condition_type": "field_comparison", + "complexity": "simple", + "declarative_friendly": true, + "products_tested": 400, + "best_engine": "soda", + "selection_reason": "hybrid-close-declarative:explicit-hash-tie-break-odd->soda", + "declarative_tie_break_applied": true, + "recommendation": "Declarative-friendly rule; prefer dbt/soda for readability and operations.", + "engines": { + "python": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.049, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 23, + "mutation_score": 0.0, + "mutation_total": 1, + "mutation_killed": 0, + "verification_score": 0.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.049, + "provider_factor": 1.0, + "real_llm_used": true, + "decision_score": 0.099, + "conversion_provider": "groq", + "conversion_notes": "Converted via Groq (openai/gpt-oss-120b).", + "execution_mode": "", + "cloud_connected": false, + "cloud_scan_id": "", + "cloud_scan_url": "", + "conversion_artifact": "def check_energy_kcal_vs_kj(product):\n \"\"\"\n Returns the rule tag if energy_kcal > energy_kj.\n Returns None if any value is missing, None, empty/whitespace string, or non-numeric.\n \"\"\"\n tag = \"energy-value-in-kcal-greater-than-in-kj\"\n left = product.get(\"energy_kcal\")\n right = product.get(\"energy_kj\")\n\n # Missing or None values\n if left is None or right is None:\n return None\n\n # Empty or whitespace-only strings are considered missing for this rule\n if isinstance(left, str) and left.strip() == \"\":\n return None\n if isinstance(right, str) and right.strip() == \"\":\n return None\n\n # Non-numeric values\n if not isinstance(left, (int, float)):\n return None\n if not isinstance(right, (int, float)):\n return None\n\n if left > right:\n return tag\n return None", + "conversion_lines": 28, + "failed_test_cases": [] + }, + "dbt": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.049, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 0, + "mutation_score": 1.0, + "mutation_total": 0, + "mutation_killed": 0, + "verification_score": 1.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.049, + "provider_factor": 1.0, + "real_llm_used": null, + "decision_score": 0.084, + "conversion_provider": "dbt_core", + "conversion_notes": "dbt tests executed through dbt-core. Command: dbt debug + dbt run-operation count_violations (per-rule x19) --project-dir C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\dbt\\dbt_project --profiles-dir C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\dbt\\dbt_project | Success: True | Return code: 0", + "execution_mode": "local", + "cloud_connected": false, + "cloud_scan_id": "", + "cloud_scan_url": "", + "conversion_artifact": "SELECT product_id\nFROM {{ source('off_source', 'nutrition_table') }}\nWHERE energy_kcal > energy_kj", + "conversion_lines": 3, + "failed_test_cases": [] + }, + "soda": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.049, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 0, + "mutation_score": 1.0, + "mutation_total": 0, + "mutation_killed": 0, + "verification_score": 1.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.049, + "provider_factor": 1.0, + "real_llm_used": null, + "decision_score": 0.084, + "conversion_provider": "soda_cloud", + "conversion_notes": "Soda Cloud scan executed successfully. Command: soda contract verify (per-rule x19) -ds C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\soda\\soda_cloud\\data_source.yml -sc C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\soda\\soda_cloud\\soda_cloud.yml -p | Success: True | Return code: 0", + "execution_mode": "cloud", + "cloud_connected": true, + "cloud_scan_id": "", + "cloud_scan_url": "https://cloud.us.soda.io/o/c9e7e376-1da2-49c5-93cb-78c6d95273ee/datasets/5e60cafe-18fc-4d01-8390-0057b49d7765", + "conversion_artifact": " - failed_rows:\n name: energy_kcal_vs_kj\n expression: energy_kcal > energy_kj", + "conversion_lines": 3, + "failed_test_cases": [] + } + } + }, + { + "rule_name": "energy_kj_computed_mismatch_high", + "tag": "energy-value-in-kj-does-not-match-value-computed-from-other-nutrients-high", + "severity": "error", + "condition": "energy_kj_computed > (1.3 * energy_kj + 5.0)", + "jurisdiction": "global", + "profile_tags": [ + "global", + "hybrid" + ], + "regulatory_type": "off_internal", + "legal_citation": "", + "source_url": "", + "effective_date": "", + "review_status": "reviewed", + "reviewer": "prototype", + "required_fields": [], + "exemption_logic": "none", + "rule_notes": "OFF-derived global rule: energy_kj_computed_mismatch_high", + "rule_ir_hash": "ac2e3831ada8", + "condition_type": "affine_field_comparison", + "complexity": "intricate", + "declarative_friendly": false, + "products_tested": 400, + "best_engine": "python", + "selection_reason": "hybrid-close-procedural:prefer-python", + "declarative_tie_break_applied": false, + "recommendation": "Procedural preference: rule is intricate (affine_field_comparison). Python migration is preferred under current evidence.", + "engines": { + "python": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.0446, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 22, + "mutation_score": 0.0, + "mutation_total": 3, + "mutation_killed": 0, + "verification_score": 0.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.0446, + "provider_factor": 1.0, + "real_llm_used": true, + "decision_score": 0.1296, + "conversion_provider": "groq", + "conversion_notes": "Converted via Groq (openai/gpt-oss-120b).", + "execution_mode": "", + "cloud_connected": false, + "cloud_scan_id": "", + "cloud_scan_url": "", + "conversion_artifact": "def check_energy_kj_computed_mismatch_high(product):\n \"\"\"\n Returns the rule tag if energy_kj_computed > (1.3 * energy_kj + 5.0),\n otherwise returns None. Missing or non\u2011numeric values also yield None.\n \"\"\"\n tag = \"energy-value-in-kj-does-not-match-value-computed-from-other-nutrients-high\"\n left = product.get(\"energy_kj_computed\")\n right = product.get(\"energy_kj\")\n\n # Missing values\n if left is None or right is None:\n return None\n\n # Non\u2011numeric values (exclude bool which is subclass of int)\n if isinstance(left, bool) or isinstance(right, bool):\n return None\n if not isinstance(left, (int, float)) or not isinstance(right, (int, float)):\n return None\n\n # Apply affine comparison\n if left > (1.3 * right + 5.0):\n return tag\n return None", + "conversion_lines": 23, + "failed_test_cases": [] + }, + "dbt": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.049, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 0, + "mutation_score": 1.0, + "mutation_total": 0, + "mutation_killed": 0, + "verification_score": 1.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.049, + "provider_factor": 1.0, + "real_llm_used": null, + "decision_score": 0.049, + "conversion_provider": "dbt_core", + "conversion_notes": "dbt tests executed through dbt-core. Command: dbt debug + dbt run-operation count_violations (per-rule x19) --project-dir C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\dbt\\dbt_project --profiles-dir C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\dbt\\dbt_project | Success: True | Return code: 0", + "execution_mode": "local", + "cloud_connected": false, + "cloud_scan_id": "", + "cloud_scan_url": "", + "conversion_artifact": "SELECT product_id\nFROM {{ source('off_source', 'nutrition_table') }}\nWHERE energy_kj_computed > (1.3 * energy_kj + 5.0)", + "conversion_lines": 3, + "failed_test_cases": [] + }, + "soda": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.049, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 0, + "mutation_score": 1.0, + "mutation_total": 0, + "mutation_killed": 0, + "verification_score": 1.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.049, + "provider_factor": 1.0, + "real_llm_used": null, + "decision_score": 0.049, + "conversion_provider": "soda_cloud", + "conversion_notes": "Soda Cloud scan executed successfully. Command: soda contract verify (per-rule x19) -ds C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\soda\\soda_cloud\\data_source.yml -sc C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\soda\\soda_cloud\\soda_cloud.yml -p | Success: True | Return code: 0", + "execution_mode": "cloud", + "cloud_connected": true, + "cloud_scan_id": "", + "cloud_scan_url": "https://cloud.us.soda.io/o/c9e7e376-1da2-49c5-93cb-78c6d95273ee/datasets/5e60cafe-18fc-4d01-8390-0057b49d7765", + "conversion_artifact": " - failed_rows:\n name: energy_kj_computed_mismatch_high\n expression: energy_kj_computed > (1.3 * energy_kj + 5.0)", + "conversion_lines": 3, + "failed_test_cases": [] + } + } + }, + { + "rule_name": "energy_kj_computed_mismatch_low", + "tag": "energy-value-in-kj-does-not-match-value-computed-from-other-nutrients-low", + "severity": "error", + "condition": "energy_kj_computed < (0.7 * energy_kj - 5.0)", + "jurisdiction": "global", + "profile_tags": [ + "global", + "hybrid" + ], + "regulatory_type": "off_internal", + "legal_citation": "", + "source_url": "", + "effective_date": "", + "review_status": "reviewed", + "reviewer": "prototype", + "required_fields": [], + "exemption_logic": "none", + "rule_notes": "OFF-derived global rule: energy_kj_computed_mismatch_low", + "rule_ir_hash": "2845fdb42a7e", + "condition_type": "affine_field_comparison", + "complexity": "intricate", + "declarative_friendly": false, + "products_tested": 400, + "best_engine": "python", + "selection_reason": "hybrid-close-procedural:prefer-python", + "declarative_tie_break_applied": false, + "recommendation": "Procedural preference: rule is intricate (affine_field_comparison). Python migration is preferred under current evidence.", + "engines": { + "python": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.0446, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 22, + "mutation_score": 1.0, + "mutation_total": 2, + "mutation_killed": 2, + "verification_score": 1.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.0446, + "provider_factor": 1.0, + "real_llm_used": true, + "decision_score": 0.1796, + "conversion_provider": "groq", + "conversion_notes": "Converted via Groq (openai/gpt-oss-120b).", + "execution_mode": "", + "cloud_connected": false, + "cloud_scan_id": "", + "cloud_scan_url": "", + "conversion_artifact": "def check_energy_kj_computed_mismatch_low(product):\n tag = \"energy-value-in-kj-does-not-match-value-computed-from-other-nutrients-low\"\n # missing_field rule for the whole input\n if product is None or (isinstance(product, str) and product.strip() == \"\"):\n return tag\n if not isinstance(product, dict):\n return None\n left = product.get(\"energy_kj_computed\")\n right = product.get(\"energy_kj\")\n # field_comparison rule: missing or non-numeric values yield None\n if left is None or right is None:\n return None\n try:\n left_val = float(left)\n right_val = float(right)\n except (TypeError, ValueError):\n return None\n if left_val < (0.7 * right_val - 5.0):\n return tag\n return None", + "conversion_lines": 20, + "failed_test_cases": [] + }, + "dbt": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.049, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 0, + "mutation_score": 1.0, + "mutation_total": 0, + "mutation_killed": 0, + "verification_score": 1.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.049, + "provider_factor": 1.0, + "real_llm_used": null, + "decision_score": 0.049, + "conversion_provider": "dbt_core", + "conversion_notes": "dbt tests executed through dbt-core. Command: dbt debug + dbt run-operation count_violations (per-rule x19) --project-dir C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\dbt\\dbt_project --profiles-dir C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\dbt\\dbt_project | Success: True | Return code: 0", + "execution_mode": "local", + "cloud_connected": false, + "cloud_scan_id": "", + "cloud_scan_url": "", + "conversion_artifact": "SELECT product_id\nFROM {{ source('off_source', 'nutrition_table') }}\nWHERE energy_kj_computed < (0.7 * energy_kj - 5.0)", + "conversion_lines": 3, + "failed_test_cases": [] + }, + "soda": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.049, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 0, + "mutation_score": 1.0, + "mutation_total": 0, + "mutation_killed": 0, + "verification_score": 1.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.049, + "provider_factor": 1.0, + "real_llm_used": null, + "decision_score": 0.049, + "conversion_provider": "soda_cloud", + "conversion_notes": "Soda Cloud scan executed successfully. Command: soda contract verify (per-rule x19) -ds C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\soda\\soda_cloud\\data_source.yml -sc C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\soda\\soda_cloud\\soda_cloud.yml -p | Success: True | Return code: 0", + "execution_mode": "cloud", + "cloud_connected": true, + "cloud_scan_id": "", + "cloud_scan_url": "https://cloud.us.soda.io/o/c9e7e376-1da2-49c5-93cb-78c6d95273ee/datasets/5e60cafe-18fc-4d01-8390-0057b49d7765", + "conversion_artifact": " - failed_rows:\n name: energy_kj_computed_mismatch_low\n expression: energy_kj_computed < (0.7 * energy_kj - 5.0)", + "conversion_lines": 3, + "failed_test_cases": [] + } + } + }, + { + "rule_name": "energy_kj_mismatch_high", + "tag": "energy-value-in-kcal-does-not-match-value-in-kj-high", + "severity": "error", + "condition": "energy_kj > (4.7 * energy_kcal + 2.0)", + "jurisdiction": "global", + "profile_tags": [ + "global", + "hybrid" + ], + "regulatory_type": "off_internal", + "legal_citation": "", + "source_url": "", + "effective_date": "", + "review_status": "reviewed", + "reviewer": "prototype", + "required_fields": [], + "exemption_logic": "none", + "rule_notes": "OFF-derived global rule: energy_kj_mismatch_high", + "rule_ir_hash": "13c3c72ed774", + "condition_type": "affine_field_comparison", + "complexity": "intricate", + "declarative_friendly": false, + "products_tested": 400, + "best_engine": "python", + "selection_reason": "hybrid-close-procedural:prefer-python", + "declarative_tie_break_applied": false, + "recommendation": "Procedural preference: rule is intricate (affine_field_comparison). Python migration is preferred under current evidence.", + "engines": { + "python": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.0446, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 22, + "mutation_score": 0.0, + "mutation_total": 3, + "mutation_killed": 0, + "verification_score": 0.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.0446, + "provider_factor": 1.0, + "real_llm_used": true, + "decision_score": 0.1296, + "conversion_provider": "groq", + "conversion_notes": "Converted via Groq (openai/gpt-oss-120b).", + "execution_mode": "", + "cloud_connected": false, + "cloud_scan_id": "", + "cloud_scan_url": "", + "conversion_artifact": "def check_energy_kj_mismatch_high(product):\n \"\"\"\n Returns the rule tag if energy_kj > (4.7 * energy_kcal + 2.0), otherwise None.\n Missing or non-numeric values result in None.\n \"\"\"\n tag = \"energy-value-in-kcal-does-not-match-value-in-kj-high\"\n left = product.get(\"energy_kj\")\n right = product.get(\"energy_kcal\")\n\n # Missing values\n if left is None or right is None:\n return None\n\n # Non-numeric values\n if not isinstance(left, (int, float)) or not isinstance(right, (int, float)):\n return None\n\n if left > (4.7 * right + 2.0):\n return tag\n return None", + "conversion_lines": 20, + "failed_test_cases": [] + }, + "dbt": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.049, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 0, + "mutation_score": 1.0, + "mutation_total": 0, + "mutation_killed": 0, + "verification_score": 1.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.049, + "provider_factor": 1.0, + "real_llm_used": null, + "decision_score": 0.049, + "conversion_provider": "dbt_core", + "conversion_notes": "dbt tests executed through dbt-core. Command: dbt debug + dbt run-operation count_violations (per-rule x19) --project-dir C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\dbt\\dbt_project --profiles-dir C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\dbt\\dbt_project | Success: True | Return code: 0", + "execution_mode": "local", + "cloud_connected": false, + "cloud_scan_id": "", + "cloud_scan_url": "", + "conversion_artifact": "SELECT product_id\nFROM {{ source('off_source', 'nutrition_table') }}\nWHERE energy_kj > (4.7 * energy_kcal + 2.0)", + "conversion_lines": 3, + "failed_test_cases": [] + }, + "soda": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.049, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 0, + "mutation_score": 1.0, + "mutation_total": 0, + "mutation_killed": 0, + "verification_score": 1.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.049, + "provider_factor": 1.0, + "real_llm_used": null, + "decision_score": 0.049, + "conversion_provider": "soda_cloud", + "conversion_notes": "Soda Cloud scan executed successfully. Command: soda contract verify (per-rule x19) -ds C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\soda\\soda_cloud\\data_source.yml -sc C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\soda\\soda_cloud\\soda_cloud.yml -p | Success: True | Return code: 0", + "execution_mode": "cloud", + "cloud_connected": true, + "cloud_scan_id": "", + "cloud_scan_url": "https://cloud.us.soda.io/o/c9e7e376-1da2-49c5-93cb-78c6d95273ee/datasets/5e60cafe-18fc-4d01-8390-0057b49d7765", + "conversion_artifact": " - failed_rows:\n name: energy_kj_mismatch_high\n expression: energy_kj > (4.7 * energy_kcal + 2.0)", + "conversion_lines": 3, + "failed_test_cases": [] + } + } + }, + { + "rule_name": "energy_kj_mismatch_low", + "tag": "energy-value-in-kcal-does-not-match-value-in-kj-low", + "severity": "error", + "condition": "energy_kj < (3.7 * energy_kcal - 2.0)", + "jurisdiction": "global", + "profile_tags": [ + "global", + "hybrid" + ], + "regulatory_type": "off_internal", + "legal_citation": "", + "source_url": "", + "effective_date": "", + "review_status": "reviewed", + "reviewer": "prototype", + "required_fields": [], + "exemption_logic": "none", + "rule_notes": "OFF-derived global rule: energy_kj_mismatch_low", + "rule_ir_hash": "5a7e9e033cc8", + "condition_type": "affine_field_comparison", + "complexity": "intricate", + "declarative_friendly": false, + "products_tested": 400, + "best_engine": "python", + "selection_reason": "hybrid-close-procedural:prefer-python", + "declarative_tie_break_applied": false, + "recommendation": "Procedural preference: rule is intricate (affine_field_comparison). Python migration is preferred under current evidence.", + "engines": { + "python": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.0446, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 22, + "mutation_score": 0.5, + "mutation_total": 2, + "mutation_killed": 1, + "verification_score": 0.5, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.0446, + "provider_factor": 1.0, + "real_llm_used": true, + "decision_score": 0.1546, + "conversion_provider": "groq", + "conversion_notes": "Converted via Groq (openai/gpt-oss-120b).", + "execution_mode": "", + "cloud_connected": false, + "cloud_scan_id": "", + "cloud_scan_url": "", + "conversion_artifact": "def check_energy_kj_mismatch_low(product):\n \"\"\"\n Returns the rule tag if energy_kj is less than (3.7 * energy_kcal - 2.0).\n Returns None for missing or non-numeric values or when the condition is false.\n \"\"\"\n tag = \"energy-value-in-kcal-does-not-match-value-in-kj-low\"\n left = product.get(\"energy_kj\")\n right = product.get(\"energy_kcal\")\n\n # Missing values\n if left is None or right is None:\n return None\n\n # Convert to float, treat conversion failures as non-numeric\n try:\n left_val = float(left)\n right_val = float(right)\n except (TypeError, ValueError):\n return None\n\n # Apply affine comparison\n if left_val < (3.7 * right_val - 2.0):\n return tag\n return None", + "conversion_lines": 24, + "failed_test_cases": [] + }, + "dbt": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.049, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 0, + "mutation_score": 1.0, + "mutation_total": 0, + "mutation_killed": 0, + "verification_score": 1.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.049, + "provider_factor": 1.0, + "real_llm_used": null, + "decision_score": 0.049, + "conversion_provider": "dbt_core", + "conversion_notes": "dbt tests executed through dbt-core. Command: dbt debug + dbt run-operation count_violations (per-rule x19) --project-dir C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\dbt\\dbt_project --profiles-dir C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\dbt\\dbt_project | Success: True | Return code: 0", + "execution_mode": "local", + "cloud_connected": false, + "cloud_scan_id": "", + "cloud_scan_url": "", + "conversion_artifact": "SELECT product_id\nFROM {{ source('off_source', 'nutrition_table') }}\nWHERE energy_kj < (3.7 * energy_kcal - 2.0)", + "conversion_lines": 3, + "failed_test_cases": [] + }, + "soda": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.049, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 0, + "mutation_score": 1.0, + "mutation_total": 0, + "mutation_killed": 0, + "verification_score": 1.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.049, + "provider_factor": 1.0, + "real_llm_used": null, + "decision_score": 0.049, + "conversion_provider": "soda_cloud", + "conversion_notes": "Soda Cloud scan executed successfully. Command: soda contract verify (per-rule x19) -ds C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\soda\\soda_cloud\\data_source.yml -sc C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\soda\\soda_cloud\\soda_cloud.yml -p | Success: True | Return code: 0", + "execution_mode": "cloud", + "cloud_connected": true, + "cloud_scan_id": "", + "cloud_scan_url": "https://cloud.us.soda.io/o/c9e7e376-1da2-49c5-93cb-78c6d95273ee/datasets/5e60cafe-18fc-4d01-8390-0057b49d7765", + "conversion_artifact": " - failed_rows:\n name: energy_kj_mismatch_low\n expression: energy_kj < (3.7 * energy_kcal - 2.0)", + "conversion_lines": 3, + "failed_test_cases": [] + } + } + }, + { + "rule_name": "energy_kj_over_3911", + "tag": "value-over-3911-energy", + "severity": "error", + "condition": "energy_kj > 3911", + "jurisdiction": "global", + "profile_tags": [ + "global", + "hybrid" + ], + "regulatory_type": "off_internal", + "legal_citation": "", + "source_url": "", + "effective_date": "", + "review_status": "reviewed", + "reviewer": "prototype", + "required_fields": [], + "exemption_logic": "none", + "rule_notes": "OFF-derived global rule: energy_kj_over_3911", + "rule_ir_hash": "abd124f391c9", + "condition_type": "field_threshold", + "complexity": "simple", + "declarative_friendly": true, + "products_tested": 400, + "best_engine": "soda", + "selection_reason": "hybrid-close-declarative:explicit-hash-tie-break-odd->soda", + "declarative_tie_break_applied": true, + "recommendation": "Declarative-friendly rule; prefer dbt/soda for readability and operations.", + "engines": { + "python": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.8599, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 22, + "mutation_score": 0.0, + "mutation_total": 1, + "mutation_killed": 0, + "verification_score": 0.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.8599, + "provider_factor": 1.0, + "real_llm_used": true, + "decision_score": 0.9099, + "conversion_provider": "groq", + "conversion_notes": "Converted via Groq (openai/gpt-oss-120b).", + "execution_mode": "", + "cloud_connected": false, + "cloud_scan_id": "", + "cloud_scan_url": "", + "conversion_artifact": "def check_energy_kj_over_3911(product):\n \"\"\"\n Returns the tag 'value-over-3911-energy' if product['energy_kj'] > 3911.\n Returns None for missing, None, empty, whitespace-only, or non-numeric values.\n \"\"\"\n tag = \"value-over-3911-energy\"\n value = product.get(\"energy_kj\", None)\n\n # Missing or None\n if value is None:\n return None\n\n # Empty or whitespace-only strings (treated as missing for this rule)\n if isinstance(value, str) and value.strip() == \"\":\n return None\n\n # Non-numeric values\n if not isinstance(value, (int, float)) or isinstance(value, bool):\n return None\n\n # Apply threshold condition\n if value > 3911:\n return tag\n return None", + "conversion_lines": 24, + "failed_test_cases": [] + }, + "dbt": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.8776, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 0, + "mutation_score": 1.0, + "mutation_total": 0, + "mutation_killed": 0, + "verification_score": 1.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.8776, + "provider_factor": 1.0, + "real_llm_used": null, + "decision_score": 0.9126, + "conversion_provider": "dbt_core", + "conversion_notes": "dbt tests executed through dbt-core. Command: dbt debug + dbt run-operation count_violations (per-rule x19) --project-dir C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\dbt\\dbt_project --profiles-dir C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\dbt\\dbt_project | Success: True | Return code: 0", + "execution_mode": "local", + "cloud_connected": false, + "cloud_scan_id": "", + "cloud_scan_url": "", + "conversion_artifact": "SELECT product_id\nFROM {{ source('off_source', 'nutrition_table') }}\nWHERE energy_kj > 3911", + "conversion_lines": 3, + "failed_test_cases": [] + }, + "soda": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.8776, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 0, + "mutation_score": 1.0, + "mutation_total": 0, + "mutation_killed": 0, + "verification_score": 1.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.8776, + "provider_factor": 1.0, + "real_llm_used": null, + "decision_score": 0.9126, + "conversion_provider": "soda_cloud", + "conversion_notes": "Soda Cloud scan executed successfully. Command: soda contract verify (per-rule x19) -ds C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\soda\\soda_cloud\\data_source.yml -sc C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\soda\\soda_cloud\\soda_cloud.yml -p | Success: True | Return code: 0", + "execution_mode": "cloud", + "cloud_connected": true, + "cloud_scan_id": "", + "cloud_scan_url": "https://cloud.us.soda.io/o/c9e7e376-1da2-49c5-93cb-78c6d95273ee/datasets/5e60cafe-18fc-4d01-8390-0057b49d7765", + "conversion_artifact": " - failed_rows:\n name: energy_kj_over_3911\n expression: energy_kj > 3911", + "conversion_lines": 3, + "failed_test_cases": [] + } + } + }, + { + "rule_name": "fat_over_105g", + "tag": "fat-value-over-105g", + "severity": "warning", + "condition": "fat > 105", + "jurisdiction": "global", + "profile_tags": [ + "global", + "hybrid" + ], + "regulatory_type": "off_internal", + "legal_citation": "", + "source_url": "", + "effective_date": "", + "review_status": "reviewed", + "reviewer": "prototype", + "required_fields": [], + "exemption_logic": "none", + "rule_notes": "OFF-derived global rule: fat_over_105g", + "rule_ir_hash": "c6f7c59ce9c9", + "condition_type": "field_threshold", + "complexity": "simple", + "declarative_friendly": true, + "products_tested": 400, + "best_engine": "dbt", + "selection_reason": "hybrid-close-declarative:explicit-hash-tie-break-even->dbt", + "declarative_tie_break_applied": true, + "recommendation": "Declarative-friendly rule; prefer dbt/soda for readability and operations.", + "engines": { + "python": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.6888, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 22, + "mutation_score": 1.0, + "mutation_total": 1, + "mutation_killed": 1, + "verification_score": 1.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.6888, + "provider_factor": 1.0, + "real_llm_used": true, + "decision_score": 0.7888, + "conversion_provider": "groq", + "conversion_notes": "Converted via Groq (openai/gpt-oss-120b).", + "execution_mode": "", + "cloud_connected": false, + "cloud_scan_id": "", + "cloud_scan_url": "", + "conversion_artifact": "def check_fat_over_105g(product):\n \"\"\"\n Returns the tag 'fat-value-over-105g' if the product's 'fat' field\n exceeds 105. Returns None for missing, empty, whitespace-only,\n or non-numeric values, or when the condition is not met.\n \"\"\"\n tag = \"fat-value-over-105g\"\n value = product.get(\"fat\")\n\n # Missing field or None\n if value is None:\n return None\n\n # Non-numeric values (including strings, bools, etc.)\n if not isinstance(value, (int, float)):\n return None\n\n # Apply the threshold condition\n if value > 105:\n return tag\n\n return None", + "conversion_lines": 22, + "failed_test_cases": [] + }, + "dbt": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.703, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 0, + "mutation_score": 1.0, + "mutation_total": 0, + "mutation_killed": 0, + "verification_score": 1.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.703, + "provider_factor": 1.0, + "real_llm_used": null, + "decision_score": 0.738, + "conversion_provider": "dbt_core", + "conversion_notes": "dbt tests executed through dbt-core. Command: dbt debug + dbt run-operation count_violations (per-rule x19) --project-dir C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\dbt\\dbt_project --profiles-dir C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\dbt\\dbt_project | Success: True | Return code: 0", + "execution_mode": "local", + "cloud_connected": false, + "cloud_scan_id": "", + "cloud_scan_url": "", + "conversion_artifact": "SELECT product_id\nFROM {{ source('off_source', 'nutrition_table') }}\nWHERE fat > 105", + "conversion_lines": 3, + "failed_test_cases": [] + }, + "soda": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.703, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 0, + "mutation_score": 1.0, + "mutation_total": 0, + "mutation_killed": 0, + "verification_score": 1.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.703, + "provider_factor": 1.0, + "real_llm_used": null, + "decision_score": 0.738, + "conversion_provider": "soda_cloud", + "conversion_notes": "Soda Cloud scan executed successfully. Command: soda contract verify (per-rule x19) -ds C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\soda\\soda_cloud\\data_source.yml -sc C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\soda\\soda_cloud\\soda_cloud.yml -p | Success: True | Return code: 0", + "execution_mode": "cloud", + "cloud_connected": true, + "cloud_scan_id": "", + "cloud_scan_url": "https://cloud.us.soda.io/o/c9e7e376-1da2-49c5-93cb-78c6d95273ee/datasets/5e60cafe-18fc-4d01-8390-0057b49d7765", + "conversion_artifact": " - failed_rows:\n name: fat_over_105g\n expression: fat > 105", + "conversion_lines": 3, + "failed_test_cases": [] + } + } + }, + { + "rule_name": "main_language_code_missing", + "tag": "main-language-code-missing", + "severity": "bug", + "condition": "missing(lc)", + "jurisdiction": "ca", + "profile_tags": [ + "canada", + "hybrid" + ], + "regulatory_type": "statutory", + "legal_citation": "SFCR 206(1); FDR B.01.012(2)", + "source_url": "https://laws-lois.justice.gc.ca/eng/regulations/SOR-2018-108/section-206.html", + "effective_date": "2019-01-15", + "review_status": "draft", + "reviewer": "pending-mentor-review", + "required_fields": [ + "lc", + "lang", + "language_code" + ], + "exemption_logic": "Not all products require bilingual labels; this prototype uses a conservative language-presence proxy.", + "rule_notes": "Canada pack: proxy check for missing primary language code in label metadata.", + "rule_ir_hash": "d6c3ad98509c", + "condition_type": "missing_field", + "complexity": "simple", + "declarative_friendly": true, + "products_tested": 400, + "best_engine": "dbt", + "selection_reason": "hybrid-close-declarative:explicit-hash-tie-break-even->dbt", + "declarative_tie_break_applied": true, + "recommendation": "Declarative-friendly rule; prefer dbt/soda for readability and operations.", + "engines": { + "python": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.0466, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 5, + "mutation_score": 1.0, + "mutation_total": 0, + "mutation_killed": 0, + "verification_score": 1.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.0466, + "provider_factor": 1.0, + "real_llm_used": true, + "decision_score": 0.1466, + "conversion_provider": "groq", + "conversion_notes": "Converted via Groq (openai/gpt-oss-120b).", + "execution_mode": "", + "cloud_connected": false, + "cloud_scan_id": "", + "cloud_scan_url": "", + "conversion_artifact": "def check_main_language_code_missing(product: dict) -> str | None:\n \"\"\"\n Returns the tag 'main-language-code-missing' if the 'lc' field is missing,\n None, empty, or contains only whitespace. Otherwise returns None.\n \"\"\"\n tag = \"main-language-code-missing\"\n lc = product.get(\"lc\")\n if lc is None:\n return tag\n if isinstance(lc, str) and lc.strip() == \"\":\n return tag\n return None", + "conversion_lines": 12, + "failed_test_cases": [] + }, + "dbt": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.049, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 0, + "mutation_score": 1.0, + "mutation_total": 0, + "mutation_killed": 0, + "verification_score": 1.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.049, + "provider_factor": 1.0, + "real_llm_used": null, + "decision_score": 0.084, + "conversion_provider": "dbt_core", + "conversion_notes": "dbt tests executed through dbt-core. Command: dbt debug + dbt run-operation count_violations (per-rule x19) --project-dir C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\dbt\\dbt_project --profiles-dir C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\dbt\\dbt_project | Success: True | Return code: 0", + "execution_mode": "local", + "cloud_connected": false, + "cloud_scan_id": "", + "cloud_scan_url": "", + "conversion_artifact": "SELECT product_id\nFROM {{ source('off_source', 'nutrition_table') }}\nWHERE lc IS NULL OR TRIM(lc) = ''", + "conversion_lines": 3, + "failed_test_cases": [] + }, + "soda": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.049, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 0, + "mutation_score": 1.0, + "mutation_total": 0, + "mutation_killed": 0, + "verification_score": 1.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.049, + "provider_factor": 1.0, + "real_llm_used": null, + "decision_score": 0.084, + "conversion_provider": "soda_cloud", + "conversion_notes": "Soda Cloud scan executed successfully. Command: soda contract verify (per-rule x19) -ds C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\soda\\soda_cloud\\data_source.yml -sc C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\soda\\soda_cloud\\soda_cloud.yml -p | Success: True | Return code: 0", + "execution_mode": "cloud", + "cloud_connected": true, + "cloud_scan_id": "", + "cloud_scan_url": "https://cloud.us.soda.io/o/c9e7e376-1da2-49c5-93cb-78c6d95273ee/datasets/5e60cafe-18fc-4d01-8390-0057b49d7765", + "conversion_artifact": " - failed_rows:\n name: main_language_code_missing\n expression: lc IS NULL OR TRIM(lc) = ''", + "conversion_lines": 3, + "failed_test_cases": [] + } + } + }, + { + "rule_name": "main_language_missing", + "tag": "main-language-missing", + "severity": "bug", + "condition": "missing(lang)", + "jurisdiction": "ca", + "profile_tags": [ + "canada", + "hybrid" + ], + "regulatory_type": "statutory", + "legal_citation": "SFCR 206(1); FDR B.01.012(2)", + "source_url": "https://laws-lois.justice.gc.ca/eng/regulations/C.R.C.,_c._870/section-B.01.012.html", + "effective_date": "2019-01-15", + "review_status": "draft", + "reviewer": "pending-mentor-review", + "required_fields": [ + "lang", + "language_code", + "lc" + ], + "exemption_logic": "Prototype proxy only; legal exemptions by product class must be modeled before strict enforcement.", + "rule_notes": "Canada pack: proxy check for missing primary language value.", + "rule_ir_hash": "342123898ecb", + "condition_type": "missing_field", + "complexity": "simple", + "declarative_friendly": true, + "products_tested": 400, + "best_engine": "dbt", + "selection_reason": "hybrid-close-declarative:explicit-hash-tie-break-even->dbt", + "declarative_tie_break_applied": true, + "recommendation": "Declarative-friendly rule; prefer dbt/soda for readability and operations.", + "engines": { + "python": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.0466, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 5, + "mutation_score": 1.0, + "mutation_total": 0, + "mutation_killed": 0, + "verification_score": 1.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.0466, + "provider_factor": 1.0, + "real_llm_used": true, + "decision_score": 0.1466, + "conversion_provider": "groq", + "conversion_notes": "Converted via Groq (openai/gpt-oss-120b).", + "execution_mode": "", + "cloud_connected": false, + "cloud_scan_id": "", + "cloud_scan_url": "", + "conversion_artifact": "def check_main_language_missing(product):\n \"\"\"\n Checks if the 'lang' field is missing (None, empty, or whitespace-only).\n Returns the rule tag 'main-language-missing' if the condition is met, otherwise None.\n \"\"\"\n tag = \"main-language-missing\"\n value = product.get(\"lang\")\n if value is None:\n return tag\n if isinstance(value, str) and value.strip() == \"\":\n return tag\n return None", + "conversion_lines": 12, + "failed_test_cases": [] + }, + "dbt": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.049, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 0, + "mutation_score": 1.0, + "mutation_total": 0, + "mutation_killed": 0, + "verification_score": 1.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.049, + "provider_factor": 1.0, + "real_llm_used": null, + "decision_score": 0.084, + "conversion_provider": "dbt_core", + "conversion_notes": "dbt tests executed through dbt-core. Command: dbt debug + dbt run-operation count_violations (per-rule x19) --project-dir C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\dbt\\dbt_project --profiles-dir C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\dbt\\dbt_project | Success: True | Return code: 0", + "execution_mode": "local", + "cloud_connected": false, + "cloud_scan_id": "", + "cloud_scan_url": "", + "conversion_artifact": "SELECT product_id\nFROM {{ source('off_source', 'nutrition_table') }}\nWHERE lang IS NULL OR TRIM(lang) = ''", + "conversion_lines": 3, + "failed_test_cases": [] + }, + "soda": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.049, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 0, + "mutation_score": 1.0, + "mutation_total": 0, + "mutation_killed": 0, + "verification_score": 1.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.049, + "provider_factor": 1.0, + "real_llm_used": null, + "decision_score": 0.084, + "conversion_provider": "soda_cloud", + "conversion_notes": "Soda Cloud scan executed successfully. Command: soda contract verify (per-rule x19) -ds C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\soda\\soda_cloud\\data_source.yml -sc C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\soda\\soda_cloud\\soda_cloud.yml -p | Success: True | Return code: 0", + "execution_mode": "cloud", + "cloud_connected": true, + "cloud_scan_id": "", + "cloud_scan_url": "https://cloud.us.soda.io/o/c9e7e376-1da2-49c5-93cb-78c6d95273ee/datasets/5e60cafe-18fc-4d01-8390-0057b49d7765", + "conversion_artifact": " - failed_rows:\n name: main_language_missing\n expression: lang IS NULL OR TRIM(lang) = ''", + "conversion_lines": 3, + "failed_test_cases": [] + } + } + }, + { + "rule_name": "saturated_fat_over_105g", + "tag": "saturated-fat-value-over-105g", + "severity": "warning", + "condition": "saturated_fat > 105", + "jurisdiction": "global", + "profile_tags": [ + "global", + "hybrid" + ], + "regulatory_type": "off_internal", + "legal_citation": "", + "source_url": "", + "effective_date": "", + "review_status": "reviewed", + "reviewer": "prototype", + "required_fields": [], + "exemption_logic": "none", + "rule_notes": "OFF-derived global rule: saturated_fat_over_105g", + "rule_ir_hash": "aafe1ceddbf5", + "condition_type": "field_threshold", + "complexity": "simple", + "declarative_friendly": true, + "products_tested": 400, + "best_engine": "soda", + "selection_reason": "hybrid-close-declarative:explicit-hash-tie-break-odd->soda", + "declarative_tie_break_applied": true, + "recommendation": "Declarative-friendly rule; prefer dbt/soda for readability and operations.", + "engines": { + "python": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.2148, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 22, + "mutation_score": 0.0, + "mutation_total": 1, + "mutation_killed": 0, + "verification_score": 0.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.2148, + "provider_factor": 1.0, + "real_llm_used": true, + "decision_score": 0.2648, + "conversion_provider": "groq", + "conversion_notes": "Converted via Groq (openai/gpt-oss-120b).", + "execution_mode": "", + "cloud_connected": false, + "cloud_scan_id": "", + "cloud_scan_url": "", + "conversion_artifact": "def check_saturated_fat_over_105g(product):\n \"\"\"\n Returns the tag \"saturated-fat-value-over-105g\" if product['saturated_fat'] > 105.\n Returns None if the field is missing, None, non\u2011numeric, or the condition is false.\n \"\"\"\n value = product.get(\"saturated_fat\")\n if value is None:\n return None\n\n # Determine if value is numeric\n if isinstance(value, (int, float)):\n num = float(value)\n else:\n try:\n num = float(value)\n except Exception:\n return None\n\n if num > 105:\n return \"saturated-fat-value-over-105g\"\n return None", + "conversion_lines": 21, + "failed_test_cases": [] + }, + "dbt": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.2193, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 0, + "mutation_score": 1.0, + "mutation_total": 0, + "mutation_killed": 0, + "verification_score": 1.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.2193, + "provider_factor": 1.0, + "real_llm_used": null, + "decision_score": 0.2543, + "conversion_provider": "dbt_core", + "conversion_notes": "dbt tests executed through dbt-core. Command: dbt debug + dbt run-operation count_violations (per-rule x19) --project-dir C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\dbt\\dbt_project --profiles-dir C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\dbt\\dbt_project | Success: True | Return code: 0", + "execution_mode": "local", + "cloud_connected": false, + "cloud_scan_id": "", + "cloud_scan_url": "", + "conversion_artifact": "SELECT product_id\nFROM {{ source('off_source', 'nutrition_table') }}\nWHERE saturated_fat > 105", + "conversion_lines": 3, + "failed_test_cases": [] + }, + "soda": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.2193, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 0, + "mutation_score": 1.0, + "mutation_total": 0, + "mutation_killed": 0, + "verification_score": 1.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.2193, + "provider_factor": 1.0, + "real_llm_used": null, + "decision_score": 0.2543, + "conversion_provider": "soda_cloud", + "conversion_notes": "Soda Cloud scan executed successfully. Command: soda contract verify (per-rule x19) -ds C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\soda\\soda_cloud\\data_source.yml -sc C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\soda\\soda_cloud\\soda_cloud.yml -p | Success: True | Return code: 0", + "execution_mode": "cloud", + "cloud_connected": true, + "cloud_scan_id": "", + "cloud_scan_url": "https://cloud.us.soda.io/o/c9e7e376-1da2-49c5-93cb-78c6d95273ee/datasets/5e60cafe-18fc-4d01-8390-0057b49d7765", + "conversion_artifact": " - failed_rows:\n name: saturated_fat_over_105g\n expression: saturated_fat > 105", + "conversion_lines": 3, + "failed_test_cases": [] + } + } + }, + { + "rule_name": "saturated_fat_vs_fat", + "tag": "saturated-fat-greater-than-fat", + "severity": "error", + "condition": "saturated_fat > (1.0 * fat + 0.001)", + "jurisdiction": "global", + "profile_tags": [ + "global", + "hybrid" + ], + "regulatory_type": "off_internal", + "legal_citation": "", + "source_url": "", + "effective_date": "", + "review_status": "reviewed", + "reviewer": "prototype", + "required_fields": [], + "exemption_logic": "none", + "rule_notes": "OFF-derived global rule: saturated_fat_vs_fat", + "rule_ir_hash": "3b10c7bc2547", + "condition_type": "affine_field_comparison", + "complexity": "simple", + "declarative_friendly": true, + "products_tested": 400, + "best_engine": "dbt", + "selection_reason": "hybrid-close-declarative:explicit-hash-tie-break-even->dbt", + "declarative_tie_break_applied": true, + "recommendation": "Declarative-friendly rule; prefer dbt/soda for readability and operations.", + "engines": { + "python": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.1993, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 22, + "mutation_score": 0.0, + "mutation_total": 3, + "mutation_killed": 0, + "verification_score": 0.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.1993, + "provider_factor": 1.0, + "real_llm_used": true, + "decision_score": 0.2493, + "conversion_provider": "groq", + "conversion_notes": "Converted via Groq (openai/gpt-oss-120b).", + "execution_mode": "", + "cloud_connected": false, + "cloud_scan_id": "", + "cloud_scan_url": "", + "conversion_artifact": "def check_saturated_fat_vs_fat(product: dict):\n tag = \"saturated-fat-greater-than-fat\"\n left = product.get(\"saturated_fat\")\n right = product.get(\"fat\")\n # Missing or empty values\n if left is None or right is None:\n return None\n if isinstance(left, str) and left.strip() == \"\":\n return None\n if isinstance(right, str) and right.strip() == \"\":\n return None\n # Convert to numeric\n try:\n left_val = float(left)\n right_val = float(right)\n except (TypeError, ValueError):\n return None\n # Affine comparison: saturated_fat > (1.0 * fat + 0.001)\n if left_val > (1.0 * right_val + 0.001):\n return tag\n return None", + "conversion_lines": 21, + "failed_test_cases": [] + }, + "dbt": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.2193, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 0, + "mutation_score": 1.0, + "mutation_total": 0, + "mutation_killed": 0, + "verification_score": 1.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.2193, + "provider_factor": 1.0, + "real_llm_used": null, + "decision_score": 0.2543, + "conversion_provider": "dbt_core", + "conversion_notes": "dbt tests executed through dbt-core. Command: dbt debug + dbt run-operation count_violations (per-rule x19) --project-dir C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\dbt\\dbt_project --profiles-dir C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\dbt\\dbt_project | Success: True | Return code: 0", + "execution_mode": "local", + "cloud_connected": false, + "cloud_scan_id": "", + "cloud_scan_url": "", + "conversion_artifact": "SELECT product_id\nFROM {{ source('off_source', 'nutrition_table') }}\nWHERE saturated_fat > (1.0 * fat + 0.001)", + "conversion_lines": 3, + "failed_test_cases": [] + }, + "soda": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.2193, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 0, + "mutation_score": 1.0, + "mutation_total": 0, + "mutation_killed": 0, + "verification_score": 1.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.2193, + "provider_factor": 1.0, + "real_llm_used": null, + "decision_score": 0.2543, + "conversion_provider": "soda_cloud", + "conversion_notes": "Soda Cloud scan executed successfully. Command: soda contract verify (per-rule x19) -ds C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\soda\\soda_cloud\\data_source.yml -sc C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\soda\\soda_cloud\\soda_cloud.yml -p | Success: True | Return code: 0", + "execution_mode": "cloud", + "cloud_connected": true, + "cloud_scan_id": "", + "cloud_scan_url": "https://cloud.us.soda.io/o/c9e7e376-1da2-49c5-93cb-78c6d95273ee/datasets/5e60cafe-18fc-4d01-8390-0057b49d7765", + "conversion_artifact": " - failed_rows:\n name: saturated_fat_vs_fat\n expression: saturated_fat > (1.0 * fat + 0.001)", + "conversion_lines": 3, + "failed_test_cases": [] + } + } + }, + { + "rule_name": "sugars_over_105g", + "tag": "sugars-value-over-105g", + "severity": "warning", + "condition": "sugars > 105", + "jurisdiction": "global", + "profile_tags": [ + "global", + "hybrid" + ], + "regulatory_type": "off_internal", + "legal_citation": "", + "source_url": "", + "effective_date": "", + "review_status": "reviewed", + "reviewer": "prototype", + "required_fields": [], + "exemption_logic": "none", + "rule_notes": "OFF-derived global rule: sugars_over_105g", + "rule_ir_hash": "f4924feaa2f8", + "condition_type": "field_threshold", + "complexity": "simple", + "declarative_friendly": true, + "products_tested": 400, + "best_engine": "dbt", + "selection_reason": "hybrid-close-declarative:explicit-hash-tie-break-even->dbt", + "declarative_tie_break_applied": true, + "recommendation": "Declarative-friendly rule; prefer dbt/soda for readability and operations.", + "engines": { + "python": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.8961, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 22, + "mutation_score": 1.0, + "mutation_total": 1, + "mutation_killed": 1, + "verification_score": 1.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.8961, + "provider_factor": 1.0, + "real_llm_used": true, + "decision_score": 0.9961, + "conversion_provider": "groq", + "conversion_notes": "Converted via Groq (openai/gpt-oss-120b).", + "execution_mode": "", + "cloud_connected": false, + "cloud_scan_id": "", + "cloud_scan_url": "", + "conversion_artifact": "def check_sugars_over_105g(product):\n \"\"\"\n Returns the tag 'sugars-value-over-105g' if the product's 'sugars' field\n exceeds 105. Returns None for missing, non-numeric, or non\u2011violating values.\n \"\"\"\n tag = \"sugars-value-over-105g\"\n value = product.get(\"sugars\")\n\n # Missing or None -> no violation\n if value is None:\n return None\n\n # Attempt to interpret numeric values\n try:\n numeric_value = float(value)\n except (TypeError, ValueError):\n return None\n\n # Apply threshold condition\n if numeric_value > 105:\n return tag\n\n return None", + "conversion_lines": 23, + "failed_test_cases": [] + }, + "dbt": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.9146, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 0, + "mutation_score": 1.0, + "mutation_total": 0, + "mutation_killed": 0, + "verification_score": 1.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.9146, + "provider_factor": 1.0, + "real_llm_used": null, + "decision_score": 0.9496, + "conversion_provider": "dbt_core", + "conversion_notes": "dbt tests executed through dbt-core. Command: dbt debug + dbt run-operation count_violations (per-rule x19) --project-dir C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\dbt\\dbt_project --profiles-dir C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\dbt\\dbt_project | Success: True | Return code: 0", + "execution_mode": "local", + "cloud_connected": false, + "cloud_scan_id": "", + "cloud_scan_url": "", + "conversion_artifact": "SELECT product_id\nFROM {{ source('off_source', 'nutrition_table') }}\nWHERE sugars > 105", + "conversion_lines": 3, + "failed_test_cases": [] + }, + "soda": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.9146, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 0, + "mutation_score": 1.0, + "mutation_total": 0, + "mutation_killed": 0, + "verification_score": 1.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.9146, + "provider_factor": 1.0, + "real_llm_used": null, + "decision_score": 0.9496, + "conversion_provider": "soda_cloud", + "conversion_notes": "Soda Cloud scan executed successfully. Command: soda contract verify (per-rule x19) -ds C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\soda\\soda_cloud\\data_source.yml -sc C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\soda\\soda_cloud\\soda_cloud.yml -p | Success: True | Return code: 0", + "execution_mode": "cloud", + "cloud_connected": true, + "cloud_scan_id": "", + "cloud_scan_url": "https://cloud.us.soda.io/o/c9e7e376-1da2-49c5-93cb-78c6d95273ee/datasets/5e60cafe-18fc-4d01-8390-0057b49d7765", + "conversion_artifact": " - failed_rows:\n name: sugars_over_105g\n expression: sugars > 105", + "conversion_lines": 3, + "failed_test_cases": [] + } + } + }, + { + "rule_name": "sugars_plus_starch_vs_carbohydrates", + "tag": "sugars-plus-starch-greater-than-carbohydrates", + "severity": "error", + "condition": "(sugars + starch) > (carbohydrates + 0.001)", + "jurisdiction": "global", + "profile_tags": [ + "global", + "hybrid" + ], + "regulatory_type": "off_internal", + "legal_citation": "", + "source_url": "", + "effective_date": "", + "review_status": "reviewed", + "reviewer": "prototype", + "required_fields": [], + "exemption_logic": "none", + "rule_notes": "OFF-derived global rule: sugars_plus_starch_vs_carbohydrates", + "rule_ir_hash": "7160c946ab45", + "condition_type": "sum_fields_comparison", + "complexity": "medium", + "declarative_friendly": true, + "products_tested": 400, + "best_engine": "dbt", + "selection_reason": "hybrid-close-declarative:explicit-hash-tie-break-even->dbt", + "declarative_tie_break_applied": true, + "recommendation": "Declarative-friendly rule; prefer dbt/soda for readability and operations.", + "engines": { + "python": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.0456, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 22, + "mutation_score": 0.0, + "mutation_total": 1, + "mutation_killed": 0, + "verification_score": 0.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.0456, + "provider_factor": 1.0, + "real_llm_used": true, + "decision_score": 0.0956, + "conversion_provider": "groq", + "conversion_notes": "Converted via Groq (openai/gpt-oss-120b).", + "execution_mode": "", + "cloud_connected": false, + "cloud_scan_id": "", + "cloud_scan_url": "", + "conversion_artifact": "def check_sugars_plus_starch_vs_carbohydrates(product):\n \"\"\"\n Returns the rule tag if (sugars + starch) > (carbohydrates + 0.001).\n Returns None if any required field is missing, non\u2011numeric, or the condition is false.\n \"\"\"\n tag = \"sugars-plus-starch-greater-than-carbohydrates\"\n # Helper to determine if a value is numeric (int or float, but not bool)\n def _is_numeric(v):\n return isinstance(v, (int, float)) and not isinstance(v, bool)\n\n sugars = product.get(\"sugars\")\n starch = product.get(\"starch\")\n carbohydrates = product.get(\"carbohydrates\")\n\n # Missing or non\u2011numeric values cause the rule to be ignored\n if not (_is_numeric(sugars) and _is_numeric(starch) and _is_numeric(carbohydrates)):\n return None\n\n if (sugars + starch) > (carbohydrates + 0.001):\n return tag\n return None", + "conversion_lines": 21, + "failed_test_cases": [] + }, + "dbt": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.049, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 0, + "mutation_score": 1.0, + "mutation_total": 0, + "mutation_killed": 0, + "verification_score": 1.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.049, + "provider_factor": 1.0, + "real_llm_used": null, + "decision_score": 0.084, + "conversion_provider": "dbt_core", + "conversion_notes": "dbt tests executed through dbt-core. Command: dbt debug + dbt run-operation count_violations (per-rule x19) --project-dir C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\dbt\\dbt_project --profiles-dir C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\dbt\\dbt_project | Success: True | Return code: 0", + "execution_mode": "local", + "cloud_connected": false, + "cloud_scan_id": "", + "cloud_scan_url": "", + "conversion_artifact": "SELECT product_id\nFROM {{ source('off_source', 'nutrition_table') }}\nWHERE (sugars + starch) > (carbohydrates + 0.001)", + "conversion_lines": 3, + "failed_test_cases": [] + }, + "soda": { + "status": "MATCH", + "mismatches": 0, + "parity_ci_lower": 0.9905, + "overall_confidence": 0.049, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_cases": 0, + "mutation_score": 1.0, + "mutation_total": 0, + "mutation_killed": 0, + "verification_score": 1.0, + "counterexample_repair_applied": false, + "equivalence_counterexamples": [], + "effective_confidence": 0.049, + "provider_factor": 1.0, + "real_llm_used": null, + "decision_score": 0.084, + "conversion_provider": "soda_cloud", + "conversion_notes": "Soda Cloud scan executed successfully. Command: soda contract verify (per-rule x19) -ds C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\soda\\soda_cloud\\data_source.yml -sc C:\\dev\\OFF_DataQuality_Prototype\\results\\declarative_runtime\\soda\\soda_cloud\\soda_cloud.yml -p | Success: True | Return code: 0", + "execution_mode": "cloud", + "cloud_connected": true, + "cloud_scan_id": "", + "cloud_scan_url": "https://cloud.us.soda.io/o/c9e7e376-1da2-49c5-93cb-78c6d95273ee/datasets/5e60cafe-18fc-4d01-8390-0057b49d7765", + "conversion_artifact": " - failed_rows:\n name: sugars_plus_starch_vs_carbohydrates\n expression: (sugars + starch) > (carbohydrates + 0.001)", + "conversion_lines": 3, + "failed_test_cases": [] + } + } + } + ], + "run_config": { + "llm_provider": "groq", + "llm_model": "openai/gpt-oss-120b", + "require_real_llm": true, + "groq_api_key_set": true, + "profile": "hybrid", + "dataset_size": 400, + "seed": 17, + "mode": "off", + "source_jsonl": "C:\\dev\\OFF_DataQuality_Prototype\\openfoodfacts-products.jsonl", + "soda_mode": "cloud", + "soda_cloud_credentials_set": true + } +} \ No newline at end of file diff --git a/OFF_DataQuality/results/migration_results.json b/OFF_DataQuality/results/migration_results.json new file mode 100644 index 0000000000000000000000000000000000000000..8ca07dabe3b19185152c3e4b713aac1c97ace7f9 --- /dev/null +++ b/OFF_DataQuality/results/migration_results.json @@ -0,0 +1,1183 @@ +{ + "generated_at_utc": "2026-03-19T04:59:26.835204+00:00", + "run_fingerprint": { + "run_id": "parity_20260319T045926835204p0000_27542d2d", + "generated_at_utc": "2026-03-19T04:59:26.835204+00:00", + "execution_engine": "soda", + "soda_mode": "cloud", + "llm_provider": "simulated", + "llm_model": "", + "code_commit": "028c181854202a3ea75c2d4fbd380afcb2385249", + "dataset_fingerprint": { + "source_mode": "off_jsonl", + "source_jsonl": "C:\\Users\\Administrator\\Downloads\\off_quality_migration_prototype\\openfoodfacts-products.jsonl", + "requested_size": 20, + "products_tested": 20, + "seed": null, + "product_id_first": "0000101209159", + "product_id_last": "0000141013129", + "sha256": "c562e5de6e6cfd70e0e5332d54454c472ad0815a03be0152f6c1aaf6135b8c4b" + }, + "rulepack_fingerprint": { + "profile": "global", + "rule_count": 12, + "rule_names_sha256": "2f2262fc9912fd4287ba7153b63ef2bc845a9129b1e185da528fa69ecaf05c07", + "rule_ir_sha256": "8b85ff9de926d2326112dcccd87b1ca3f4c060ae830d9d921f7148f1e6465c42" + } + }, + "dataset": { + "jsonl_path": "C:\\Users\\Administrator\\Downloads\\off_quality_migration_prototype\\data\\sample_products.jsonl", + "duckdb_path": "C:\\Users\\Administrator\\Downloads\\off_quality_migration_prototype\\off_quality.db", + "products_tested": 20, + "source_jsonl": "C:\\Users\\Administrator\\Downloads\\off_quality_migration_prototype\\openfoodfacts-products.jsonl", + "perl_rules_source": "inline_legacy_rules", + "execution_engine": "soda", + "soda_mode": "cloud", + "profile": "global", + "profile_rule_count": 12, + "dataset_fingerprint_sha256": "c562e5de6e6cfd70e0e5332d54454c472ad0815a03be0152f6c1aaf6135b8c4b", + "rulepack_fingerprint_sha256": "8b85ff9de926d2326112dcccd87b1ca3f4c060ae830d9d921f7148f1e6465c42" + }, + "migration_summary": { + "total_rules": 12, + "passed_rules": 12, + "rules_needing_review": 0, + "average_overall_confidence": 0.0609 + }, + "rule_results": [ + { + "rule_name": "energy_kcal_vs_kj", + "tag": "energy-value-in-kcal-greater-than-in-kj", + "severity": "error", + "condition": "energy_kcal > energy_kj", + "jurisdiction": "global", + "profile_tags": [ + "global", + "hybrid" + ], + "regulatory_type": "off_internal", + "legal_citation": "", + "source_url": "", + "effective_date": "", + "review_status": "reviewed", + "reviewer": "prototype", + "required_fields": [], + "exemption_logic": "none", + "rule_notes": "OFF-derived global rule: energy_kcal_vs_kj", + "rule_ir": { + "version": "1.0", + "rule_name": "energy_kcal_vs_kj", + "condition_type": "field_comparison", + "severity": "error", + "tag": "energy-value-in-kcal-greater-than-in-kj", + "left_operand": "energy_kcal", + "operator": ">", + "right_operand": "energy_kj" + }, + "rule_ir_hash": "413d25898535", + "condition_type": "field_comparison", + "complexity": "simple", + "declarative_friendly": true, + "products_tested": 20, + "perl_errors": 0, + "python_errors": 0, + "supporting_violations": 0, + "positive_matches": 0, + "positive_agreement": 0.5, + "positive_coverage": 0.0, + "parity_ci_lower": 0.8389, + "parity_ci_upper": 1.0, + "coverage_ci_lower": 0.0, + "coverage_ci_upper": 0.1611, + "evidence_alpha": 1.0, + "evidence_beta": 1.0, + "evidence_posterior_mean": 0.5, + "evidence_ci_lower": 0.05, + "evidence_ci_upper": 0.95, + "evidence_factor": 0.05, + "matches": 20, + "mismatches": 0, + "confidence": 1.0, + "llm_confidence": 0.92, + "overall_confidence": 0.0386, + "overall_method": "llm_confidence * parity_ci_lower_95 * evidence_ci_lower_95_beta_posterior", + "status": "MATCH", + "duckdb_query": "SELECT * FROM nutrition_table WHERE energy_kcal > energy_kj", + "duckdb_errors": 0, + "duckdb_condition": "energy_kcal > energy_kj", + "duckdb_example_rows": [], + "equivalence_cases": 0, + "equivalence_matches": 0, + "equivalence_mismatches": 0, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_counterexamples": [], + "mutation_total": 0, + "mutation_killed": 0, + "mutation_survived": 0, + "mutation_score": 1.0, + "mutation_survived_mutants": [], + "verification_score": 1.0, + "counterexample_repair_attempted": false, + "counterexample_repair_applied": false, + "counterexample_repair_error": "", + "mismatch_product_ids": [], + "failed_test_cases": [], + "perl_logic": "# RULE_NAME: energy_kcal_vs_kj\n# SEVERITY: error\n# COMPLEXITY: simple\n# DECLARATIVE_FRIENDLY: yes\nif ($energy_kcal > $energy_kj) {\n push @{$product_ref->{$data_quality_tags}}, \"energy-value-in-kcal-greater-than-in-kj\";\n}", + "python_conversion": " - failed_rows:\n name: energy_kcal_vs_kj\n expression: energy_kcal > energy_kj", + "conversion_notes": "Soda Cloud unavailable/failed; used SQL-equivalent declarative parity (fast fallback). Command: soda contract verify (per-rule x12) -ds C:\\Users\\Administrator\\Downloads\\off_quality_migration_prototype\\results\\declarative_runtime\\soda\\soda_cloud\\data_source.yml -sc C:\\Users\\Administrator\\Downloads\\off_quality_migration_prototype\\results\\declarative_runtime\\soda\\soda_cloud\\soda_cloud.yml -p | Success: True | Return code: 0", + "conversion_provider": "soda_core_sql_fallback", + "conversion_execution_mode": "cloud_sql_fallback", + "conversion_cloud_connected": false, + "conversion_cloud_scan_id": "", + "conversion_cloud_scan_url": "https://cloud.us.soda.io/o/c9e7e376-1da2-49c5-93cb-78c6d95273ee/datasets/5e60cafe-18fc-4d01-8390-0057b49d7765" + }, + { + "rule_name": "energy_kj_mismatch_low", + "tag": "energy-value-in-kcal-does-not-match-value-in-kj-low", + "severity": "error", + "condition": "energy_kj < (3.7 * energy_kcal - 2.0)", + "jurisdiction": "global", + "profile_tags": [ + "global", + "hybrid" + ], + "regulatory_type": "off_internal", + "legal_citation": "", + "source_url": "", + "effective_date": "", + "review_status": "reviewed", + "reviewer": "prototype", + "required_fields": [], + "exemption_logic": "none", + "rule_notes": "OFF-derived global rule: energy_kj_mismatch_low", + "rule_ir": { + "version": "1.0", + "rule_name": "energy_kj_mismatch_low", + "condition_type": "affine_field_comparison", + "severity": "error", + "tag": "energy-value-in-kcal-does-not-match-value-in-kj-low", + "left_operand": "energy_kj", + "operator": "<", + "right_operand": "energy_kcal", + "scale_factor": 3.7, + "offset": -2.0 + }, + "rule_ir_hash": "5a7e9e033cc8", + "condition_type": "affine_field_comparison", + "complexity": "intricate", + "declarative_friendly": false, + "products_tested": 20, + "perl_errors": 0, + "python_errors": 0, + "supporting_violations": 0, + "positive_matches": 0, + "positive_agreement": 0.5, + "positive_coverage": 0.0, + "parity_ci_lower": 0.8389, + "parity_ci_upper": 1.0, + "coverage_ci_lower": 0.0, + "coverage_ci_upper": 0.1611, + "evidence_alpha": 1.0, + "evidence_beta": 1.0, + "evidence_posterior_mean": 0.5, + "evidence_ci_lower": 0.05, + "evidence_ci_upper": 0.95, + "evidence_factor": 0.05, + "matches": 20, + "mismatches": 0, + "confidence": 1.0, + "llm_confidence": 0.92, + "overall_confidence": 0.0386, + "overall_method": "llm_confidence * parity_ci_lower_95 * evidence_ci_lower_95_beta_posterior", + "status": "MATCH", + "duckdb_query": "SELECT * FROM nutrition_table WHERE energy_kj < (3.7 * energy_kcal - 2.0)", + "duckdb_errors": 0, + "duckdb_condition": "energy_kj < (3.7 * energy_kcal - 2.0)", + "duckdb_example_rows": [], + "equivalence_cases": 0, + "equivalence_matches": 0, + "equivalence_mismatches": 0, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_counterexamples": [], + "mutation_total": 0, + "mutation_killed": 0, + "mutation_survived": 0, + "mutation_score": 1.0, + "mutation_survived_mutants": [], + "verification_score": 1.0, + "counterexample_repair_attempted": false, + "counterexample_repair_applied": false, + "counterexample_repair_error": "", + "mismatch_product_ids": [], + "failed_test_cases": [], + "perl_logic": "# RULE_NAME: energy_kj_mismatch_low\n# SEVERITY: error\n# COMPLEXITY: intricate\n# DECLARATIVE_FRIENDLY: no\nif ($energy_kj < (3.7 * $energy_kcal - 2)) {\n push @{$product_ref->{$data_quality_tags}}, \"energy-value-in-kcal-does-not-match-value-in-kj-low\";\n}", + "python_conversion": " - failed_rows:\n name: energy_kj_mismatch_low\n expression: energy_kj < (3.7 * energy_kcal - 2.0)", + "conversion_notes": "Soda Cloud unavailable/failed; used SQL-equivalent declarative parity (fast fallback). Command: soda contract verify (per-rule x12) -ds C:\\Users\\Administrator\\Downloads\\off_quality_migration_prototype\\results\\declarative_runtime\\soda\\soda_cloud\\data_source.yml -sc C:\\Users\\Administrator\\Downloads\\off_quality_migration_prototype\\results\\declarative_runtime\\soda\\soda_cloud\\soda_cloud.yml -p | Success: True | Return code: 0", + "conversion_provider": "soda_core_sql_fallback", + "conversion_execution_mode": "cloud_sql_fallback", + "conversion_cloud_connected": false, + "conversion_cloud_scan_id": "", + "conversion_cloud_scan_url": "https://cloud.us.soda.io/o/c9e7e376-1da2-49c5-93cb-78c6d95273ee/datasets/5e60cafe-18fc-4d01-8390-0057b49d7765" + }, + { + "rule_name": "energy_kj_mismatch_high", + "tag": "energy-value-in-kcal-does-not-match-value-in-kj-high", + "severity": "error", + "condition": "energy_kj > (4.7 * energy_kcal + 2.0)", + "jurisdiction": "global", + "profile_tags": [ + "global", + "hybrid" + ], + "regulatory_type": "off_internal", + "legal_citation": "", + "source_url": "", + "effective_date": "", + "review_status": "reviewed", + "reviewer": "prototype", + "required_fields": [], + "exemption_logic": "none", + "rule_notes": "OFF-derived global rule: energy_kj_mismatch_high", + "rule_ir": { + "version": "1.0", + "rule_name": "energy_kj_mismatch_high", + "condition_type": "affine_field_comparison", + "severity": "error", + "tag": "energy-value-in-kcal-does-not-match-value-in-kj-high", + "left_operand": "energy_kj", + "operator": ">", + "right_operand": "energy_kcal", + "scale_factor": 4.7, + "offset": 2.0 + }, + "rule_ir_hash": "13c3c72ed774", + "condition_type": "affine_field_comparison", + "complexity": "intricate", + "declarative_friendly": false, + "products_tested": 20, + "perl_errors": 0, + "python_errors": 0, + "supporting_violations": 0, + "positive_matches": 0, + "positive_agreement": 0.5, + "positive_coverage": 0.0, + "parity_ci_lower": 0.8389, + "parity_ci_upper": 1.0, + "coverage_ci_lower": 0.0, + "coverage_ci_upper": 0.1611, + "evidence_alpha": 1.0, + "evidence_beta": 1.0, + "evidence_posterior_mean": 0.5, + "evidence_ci_lower": 0.05, + "evidence_ci_upper": 0.95, + "evidence_factor": 0.05, + "matches": 20, + "mismatches": 0, + "confidence": 1.0, + "llm_confidence": 0.92, + "overall_confidence": 0.0386, + "overall_method": "llm_confidence * parity_ci_lower_95 * evidence_ci_lower_95_beta_posterior", + "status": "MATCH", + "duckdb_query": "SELECT * FROM nutrition_table WHERE energy_kj > (4.7 * energy_kcal + 2.0)", + "duckdb_errors": 0, + "duckdb_condition": "energy_kj > (4.7 * energy_kcal + 2.0)", + "duckdb_example_rows": [], + "equivalence_cases": 0, + "equivalence_matches": 0, + "equivalence_mismatches": 0, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_counterexamples": [], + "mutation_total": 0, + "mutation_killed": 0, + "mutation_survived": 0, + "mutation_score": 1.0, + "mutation_survived_mutants": [], + "verification_score": 1.0, + "counterexample_repair_attempted": false, + "counterexample_repair_applied": false, + "counterexample_repair_error": "", + "mismatch_product_ids": [], + "failed_test_cases": [], + "perl_logic": "# RULE_NAME: energy_kj_mismatch_high\n# SEVERITY: error\n# COMPLEXITY: intricate\n# DECLARATIVE_FRIENDLY: no\nif ($energy_kj > (4.7 * $energy_kcal + 2)) {\n push @{$product_ref->{$data_quality_tags}}, \"energy-value-in-kcal-does-not-match-value-in-kj-high\";\n}", + "python_conversion": " - failed_rows:\n name: energy_kj_mismatch_high\n expression: energy_kj > (4.7 * energy_kcal + 2.0)", + "conversion_notes": "Soda Cloud unavailable/failed; used SQL-equivalent declarative parity (fast fallback). Command: soda contract verify (per-rule x12) -ds C:\\Users\\Administrator\\Downloads\\off_quality_migration_prototype\\results\\declarative_runtime\\soda\\soda_cloud\\data_source.yml -sc C:\\Users\\Administrator\\Downloads\\off_quality_migration_prototype\\results\\declarative_runtime\\soda\\soda_cloud\\soda_cloud.yml -p | Success: True | Return code: 0", + "conversion_provider": "soda_core_sql_fallback", + "conversion_execution_mode": "cloud_sql_fallback", + "conversion_cloud_connected": false, + "conversion_cloud_scan_id": "", + "conversion_cloud_scan_url": "https://cloud.us.soda.io/o/c9e7e376-1da2-49c5-93cb-78c6d95273ee/datasets/5e60cafe-18fc-4d01-8390-0057b49d7765" + }, + { + "rule_name": "energy_kj_over_3911", + "tag": "value-over-3911-energy", + "severity": "error", + "condition": "energy_kj > 3911", + "jurisdiction": "global", + "profile_tags": [ + "global", + "hybrid" + ], + "regulatory_type": "off_internal", + "legal_citation": "", + "source_url": "", + "effective_date": "", + "review_status": "reviewed", + "reviewer": "prototype", + "required_fields": [], + "exemption_logic": "none", + "rule_notes": "OFF-derived global rule: energy_kj_over_3911", + "rule_ir": { + "version": "1.0", + "rule_name": "energy_kj_over_3911", + "condition_type": "field_threshold", + "severity": "error", + "tag": "value-over-3911-energy", + "left_operand": "energy_kj", + "operator": ">", + "right_operand": 3911.0 + }, + "rule_ir_hash": "abd124f391c9", + "condition_type": "field_threshold", + "complexity": "simple", + "declarative_friendly": true, + "products_tested": 20, + "perl_errors": 1, + "python_errors": 1, + "supporting_violations": 1, + "positive_matches": 1, + "positive_agreement": 1.0, + "positive_coverage": 0.05, + "parity_ci_lower": 0.8389, + "parity_ci_upper": 1.0, + "coverage_ci_lower": 0.0089, + "coverage_ci_upper": 0.2361, + "evidence_alpha": 2.0, + "evidence_beta": 1.0, + "evidence_posterior_mean": 0.6667, + "evidence_ci_lower": 0.2236, + "evidence_ci_upper": 0.9747, + "evidence_factor": 0.2236, + "matches": 20, + "mismatches": 0, + "confidence": 1.0, + "llm_confidence": 0.92, + "overall_confidence": 0.1726, + "overall_method": "llm_confidence * parity_ci_lower_95 * evidence_ci_lower_95_beta_posterior", + "status": "MATCH", + "duckdb_query": "SELECT * FROM nutrition_table WHERE energy_kj > 3911", + "duckdb_errors": 1, + "duckdb_condition": "energy_kj > 3911", + "duckdb_example_rows": [ + { + "product_id": "0000111301201", + "energy_kj": 19200.0, + "energy_kj_computed": NaN, + "energy_kcal": 4590.0, + "fat": 510.0, + "saturated_fat": 76.4, + "carbohydrates": 0.0, + "sugars": 0.0, + "starch": NaN, + "sodium": 5.1, + "ingredients_text": "CANOLA OIL, WATER, PALM OIL, PALM KERNEL OIL, SALT, WHEY POWDER (MILK), VEGETABLE MONO AND DIGLYCERIDES, SOYBEAN LECITHIN, POTASSIUM SORBATE (PRESERVATIVE), CITRIC ACID, ARTIFICIAL FLAVOR, VITAMIN E (DL-ALPHA-TOCOPHEROL ACETATE), VITAMIN A PALMITATE, BETA CAROTENE & VITAMIN D3.", + "ingredients_text_present": 1, + "contains_statement_present": 1, + "allergen_evidence_present": 1, + "fop_threshold_exceeded": 1, + "fop_symbol_present": 0, + "fop_exempt_proxy": 0, + "product_is_prepackaged_proxy": 1, + "lc": "en", + "lang": "en", + "language_code": "en" + } + ], + "equivalence_cases": 0, + "equivalence_matches": 0, + "equivalence_mismatches": 0, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_counterexamples": [], + "mutation_total": 0, + "mutation_killed": 0, + "mutation_survived": 0, + "mutation_score": 1.0, + "mutation_survived_mutants": [], + "verification_score": 1.0, + "counterexample_repair_attempted": false, + "counterexample_repair_applied": false, + "counterexample_repair_error": "", + "mismatch_product_ids": [], + "failed_test_cases": [], + "perl_logic": "# RULE_NAME: energy_kj_over_3911\n# SEVERITY: error\n# COMPLEXITY: simple\n# DECLARATIVE_FRIENDLY: yes\nif ($energy_kj > 3911) {\n push @{$product_ref->{$data_quality_tags}}, \"value-over-3911-energy\";\n}", + "python_conversion": " - failed_rows:\n name: energy_kj_over_3911\n expression: energy_kj > 3911", + "conversion_notes": "Soda Cloud unavailable/failed; used SQL-equivalent declarative parity (fast fallback). Command: soda contract verify (per-rule x12) -ds C:\\Users\\Administrator\\Downloads\\off_quality_migration_prototype\\results\\declarative_runtime\\soda\\soda_cloud\\data_source.yml -sc C:\\Users\\Administrator\\Downloads\\off_quality_migration_prototype\\results\\declarative_runtime\\soda\\soda_cloud\\soda_cloud.yml -p | Success: True | Return code: 0", + "conversion_provider": "soda_core_sql_fallback", + "conversion_execution_mode": "cloud_sql_fallback", + "conversion_cloud_connected": false, + "conversion_cloud_scan_id": "", + "conversion_cloud_scan_url": "https://cloud.us.soda.io/o/c9e7e376-1da2-49c5-93cb-78c6d95273ee/datasets/5e60cafe-18fc-4d01-8390-0057b49d7765" + }, + { + "rule_name": "energy_kj_computed_mismatch_low", + "tag": "energy-value-in-kj-does-not-match-value-computed-from-other-nutrients-low", + "severity": "error", + "condition": "energy_kj_computed < (0.7 * energy_kj - 5.0)", + "jurisdiction": "global", + "profile_tags": [ + "global", + "hybrid" + ], + "regulatory_type": "off_internal", + "legal_citation": "", + "source_url": "", + "effective_date": "", + "review_status": "reviewed", + "reviewer": "prototype", + "required_fields": [], + "exemption_logic": "none", + "rule_notes": "OFF-derived global rule: energy_kj_computed_mismatch_low", + "rule_ir": { + "version": "1.0", + "rule_name": "energy_kj_computed_mismatch_low", + "condition_type": "affine_field_comparison", + "severity": "error", + "tag": "energy-value-in-kj-does-not-match-value-computed-from-other-nutrients-low", + "left_operand": "energy_kj_computed", + "operator": "<", + "right_operand": "energy_kj", + "scale_factor": 0.7, + "offset": -5.0 + }, + "rule_ir_hash": "2845fdb42a7e", + "condition_type": "affine_field_comparison", + "complexity": "intricate", + "declarative_friendly": false, + "products_tested": 20, + "perl_errors": 0, + "python_errors": 0, + "supporting_violations": 0, + "positive_matches": 0, + "positive_agreement": 0.5, + "positive_coverage": 0.0, + "parity_ci_lower": 0.8389, + "parity_ci_upper": 1.0, + "coverage_ci_lower": 0.0, + "coverage_ci_upper": 0.1611, + "evidence_alpha": 1.0, + "evidence_beta": 1.0, + "evidence_posterior_mean": 0.5, + "evidence_ci_lower": 0.05, + "evidence_ci_upper": 0.95, + "evidence_factor": 0.05, + "matches": 20, + "mismatches": 0, + "confidence": 1.0, + "llm_confidence": 0.92, + "overall_confidence": 0.0386, + "overall_method": "llm_confidence * parity_ci_lower_95 * evidence_ci_lower_95_beta_posterior", + "status": "MATCH", + "duckdb_query": "SELECT * FROM nutrition_table WHERE energy_kj_computed < (0.7 * energy_kj - 5.0)", + "duckdb_errors": 0, + "duckdb_condition": "energy_kj_computed < (0.7 * energy_kj - 5.0)", + "duckdb_example_rows": [], + "equivalence_cases": 0, + "equivalence_matches": 0, + "equivalence_mismatches": 0, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_counterexamples": [], + "mutation_total": 0, + "mutation_killed": 0, + "mutation_survived": 0, + "mutation_score": 1.0, + "mutation_survived_mutants": [], + "verification_score": 1.0, + "counterexample_repair_attempted": false, + "counterexample_repair_applied": false, + "counterexample_repair_error": "", + "mismatch_product_ids": [], + "failed_test_cases": [], + "perl_logic": "# RULE_NAME: energy_kj_computed_mismatch_low\n# SEVERITY: error\n# COMPLEXITY: intricate\n# DECLARATIVE_FRIENDLY: no\nif ($energy_kj_computed < (0.7 * $energy_kj - 5)) {\n push @{$product_ref->{$data_quality_tags}}, \"energy-value-in-kj-does-not-match-value-computed-from-other-nutrients-low\";\n}", + "python_conversion": " - failed_rows:\n name: energy_kj_computed_mismatch_low\n expression: energy_kj_computed < (0.7 * energy_kj - 5.0)", + "conversion_notes": "Soda Cloud unavailable/failed; used SQL-equivalent declarative parity (fast fallback). Command: soda contract verify (per-rule x12) -ds C:\\Users\\Administrator\\Downloads\\off_quality_migration_prototype\\results\\declarative_runtime\\soda\\soda_cloud\\data_source.yml -sc C:\\Users\\Administrator\\Downloads\\off_quality_migration_prototype\\results\\declarative_runtime\\soda\\soda_cloud\\soda_cloud.yml -p | Success: True | Return code: 0", + "conversion_provider": "soda_core_sql_fallback", + "conversion_execution_mode": "cloud_sql_fallback", + "conversion_cloud_connected": false, + "conversion_cloud_scan_id": "", + "conversion_cloud_scan_url": "https://cloud.us.soda.io/o/c9e7e376-1da2-49c5-93cb-78c6d95273ee/datasets/5e60cafe-18fc-4d01-8390-0057b49d7765" + }, + { + "rule_name": "energy_kj_computed_mismatch_high", + "tag": "energy-value-in-kj-does-not-match-value-computed-from-other-nutrients-high", + "severity": "error", + "condition": "energy_kj_computed > (1.3 * energy_kj + 5.0)", + "jurisdiction": "global", + "profile_tags": [ + "global", + "hybrid" + ], + "regulatory_type": "off_internal", + "legal_citation": "", + "source_url": "", + "effective_date": "", + "review_status": "reviewed", + "reviewer": "prototype", + "required_fields": [], + "exemption_logic": "none", + "rule_notes": "OFF-derived global rule: energy_kj_computed_mismatch_high", + "rule_ir": { + "version": "1.0", + "rule_name": "energy_kj_computed_mismatch_high", + "condition_type": "affine_field_comparison", + "severity": "error", + "tag": "energy-value-in-kj-does-not-match-value-computed-from-other-nutrients-high", + "left_operand": "energy_kj_computed", + "operator": ">", + "right_operand": "energy_kj", + "scale_factor": 1.3, + "offset": 5.0 + }, + "rule_ir_hash": "ac2e3831ada8", + "condition_type": "affine_field_comparison", + "complexity": "intricate", + "declarative_friendly": false, + "products_tested": 20, + "perl_errors": 0, + "python_errors": 0, + "supporting_violations": 0, + "positive_matches": 0, + "positive_agreement": 0.5, + "positive_coverage": 0.0, + "parity_ci_lower": 0.8389, + "parity_ci_upper": 1.0, + "coverage_ci_lower": 0.0, + "coverage_ci_upper": 0.1611, + "evidence_alpha": 1.0, + "evidence_beta": 1.0, + "evidence_posterior_mean": 0.5, + "evidence_ci_lower": 0.05, + "evidence_ci_upper": 0.95, + "evidence_factor": 0.05, + "matches": 20, + "mismatches": 0, + "confidence": 1.0, + "llm_confidence": 0.92, + "overall_confidence": 0.0386, + "overall_method": "llm_confidence * parity_ci_lower_95 * evidence_ci_lower_95_beta_posterior", + "status": "MATCH", + "duckdb_query": "SELECT * FROM nutrition_table WHERE energy_kj_computed > (1.3 * energy_kj + 5.0)", + "duckdb_errors": 0, + "duckdb_condition": "energy_kj_computed > (1.3 * energy_kj + 5.0)", + "duckdb_example_rows": [], + "equivalence_cases": 0, + "equivalence_matches": 0, + "equivalence_mismatches": 0, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_counterexamples": [], + "mutation_total": 0, + "mutation_killed": 0, + "mutation_survived": 0, + "mutation_score": 1.0, + "mutation_survived_mutants": [], + "verification_score": 1.0, + "counterexample_repair_attempted": false, + "counterexample_repair_applied": false, + "counterexample_repair_error": "", + "mismatch_product_ids": [], + "failed_test_cases": [], + "perl_logic": "# RULE_NAME: energy_kj_computed_mismatch_high\n# SEVERITY: error\n# COMPLEXITY: intricate\n# DECLARATIVE_FRIENDLY: no\nif ($energy_kj_computed > (1.3 * $energy_kj + 5)) {\n push @{$product_ref->{$data_quality_tags}}, \"energy-value-in-kj-does-not-match-value-computed-from-other-nutrients-high\";\n}", + "python_conversion": " - failed_rows:\n name: energy_kj_computed_mismatch_high\n expression: energy_kj_computed > (1.3 * energy_kj + 5.0)", + "conversion_notes": "Soda Cloud unavailable/failed; used SQL-equivalent declarative parity (fast fallback). Command: soda contract verify (per-rule x12) -ds C:\\Users\\Administrator\\Downloads\\off_quality_migration_prototype\\results\\declarative_runtime\\soda\\soda_cloud\\data_source.yml -sc C:\\Users\\Administrator\\Downloads\\off_quality_migration_prototype\\results\\declarative_runtime\\soda\\soda_cloud\\soda_cloud.yml -p | Success: True | Return code: 0", + "conversion_provider": "soda_core_sql_fallback", + "conversion_execution_mode": "cloud_sql_fallback", + "conversion_cloud_connected": false, + "conversion_cloud_scan_id": "", + "conversion_cloud_scan_url": "https://cloud.us.soda.io/o/c9e7e376-1da2-49c5-93cb-78c6d95273ee/datasets/5e60cafe-18fc-4d01-8390-0057b49d7765" + }, + { + "rule_name": "saturated_fat_vs_fat", + "tag": "saturated-fat-greater-than-fat", + "severity": "error", + "condition": "saturated_fat > (1.0 * fat + 0.001)", + "jurisdiction": "global", + "profile_tags": [ + "global", + "hybrid" + ], + "regulatory_type": "off_internal", + "legal_citation": "", + "source_url": "", + "effective_date": "", + "review_status": "reviewed", + "reviewer": "prototype", + "required_fields": [], + "exemption_logic": "none", + "rule_notes": "OFF-derived global rule: saturated_fat_vs_fat", + "rule_ir": { + "version": "1.0", + "rule_name": "saturated_fat_vs_fat", + "condition_type": "affine_field_comparison", + "severity": "error", + "tag": "saturated-fat-greater-than-fat", + "left_operand": "saturated_fat", + "operator": ">", + "right_operand": "fat", + "scale_factor": 1.0, + "offset": 0.001 + }, + "rule_ir_hash": "3b10c7bc2547", + "condition_type": "affine_field_comparison", + "complexity": "simple", + "declarative_friendly": true, + "products_tested": 20, + "perl_errors": 0, + "python_errors": 0, + "supporting_violations": 0, + "positive_matches": 0, + "positive_agreement": 0.5, + "positive_coverage": 0.0, + "parity_ci_lower": 0.8389, + "parity_ci_upper": 1.0, + "coverage_ci_lower": 0.0, + "coverage_ci_upper": 0.1611, + "evidence_alpha": 1.0, + "evidence_beta": 1.0, + "evidence_posterior_mean": 0.5, + "evidence_ci_lower": 0.05, + "evidence_ci_upper": 0.95, + "evidence_factor": 0.05, + "matches": 20, + "mismatches": 0, + "confidence": 1.0, + "llm_confidence": 0.92, + "overall_confidence": 0.0386, + "overall_method": "llm_confidence * parity_ci_lower_95 * evidence_ci_lower_95_beta_posterior", + "status": "MATCH", + "duckdb_query": "SELECT * FROM nutrition_table WHERE saturated_fat > (1.0 * fat + 0.001)", + "duckdb_errors": 0, + "duckdb_condition": "saturated_fat > (1.0 * fat + 0.001)", + "duckdb_example_rows": [], + "equivalence_cases": 0, + "equivalence_matches": 0, + "equivalence_mismatches": 0, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_counterexamples": [], + "mutation_total": 0, + "mutation_killed": 0, + "mutation_survived": 0, + "mutation_score": 1.0, + "mutation_survived_mutants": [], + "verification_score": 1.0, + "counterexample_repair_attempted": false, + "counterexample_repair_applied": false, + "counterexample_repair_error": "", + "mismatch_product_ids": [], + "failed_test_cases": [], + "perl_logic": "# RULE_NAME: saturated_fat_vs_fat\n# SEVERITY: error\n# COMPLEXITY: simple\n# DECLARATIVE_FRIENDLY: yes\nif ($saturated_fat > (1 * $fat + 0.001)) {\n push @{$product_ref->{$data_quality_tags}}, \"saturated-fat-greater-than-fat\";\n}", + "python_conversion": " - failed_rows:\n name: saturated_fat_vs_fat\n expression: saturated_fat > (1.0 * fat + 0.001)", + "conversion_notes": "Soda Cloud unavailable/failed; used SQL-equivalent declarative parity (fast fallback). Command: soda contract verify (per-rule x12) -ds C:\\Users\\Administrator\\Downloads\\off_quality_migration_prototype\\results\\declarative_runtime\\soda\\soda_cloud\\data_source.yml -sc C:\\Users\\Administrator\\Downloads\\off_quality_migration_prototype\\results\\declarative_runtime\\soda\\soda_cloud\\soda_cloud.yml -p | Success: True | Return code: 0", + "conversion_provider": "soda_core_sql_fallback", + "conversion_execution_mode": "cloud_sql_fallback", + "conversion_cloud_connected": false, + "conversion_cloud_scan_id": "", + "conversion_cloud_scan_url": "https://cloud.us.soda.io/o/c9e7e376-1da2-49c5-93cb-78c6d95273ee/datasets/5e60cafe-18fc-4d01-8390-0057b49d7765" + }, + { + "rule_name": "sugars_plus_starch_vs_carbohydrates", + "tag": "sugars-plus-starch-greater-than-carbohydrates", + "severity": "error", + "condition": "(sugars + starch) > (carbohydrates + 0.001)", + "jurisdiction": "global", + "profile_tags": [ + "global", + "hybrid" + ], + "regulatory_type": "off_internal", + "legal_citation": "", + "source_url": "", + "effective_date": "", + "review_status": "reviewed", + "reviewer": "prototype", + "required_fields": [], + "exemption_logic": "none", + "rule_notes": "OFF-derived global rule: sugars_plus_starch_vs_carbohydrates", + "rule_ir": { + "version": "1.0", + "rule_name": "sugars_plus_starch_vs_carbohydrates", + "condition_type": "sum_fields_comparison", + "severity": "error", + "tag": "sugars-plus-starch-greater-than-carbohydrates", + "operator": ">", + "right_operand": "carbohydrates", + "left_operands": [ + "sugars", + "starch" + ], + "right_offset": 0.001 + }, + "rule_ir_hash": "7160c946ab45", + "condition_type": "sum_fields_comparison", + "complexity": "medium", + "declarative_friendly": true, + "products_tested": 20, + "perl_errors": 0, + "python_errors": 0, + "supporting_violations": 0, + "positive_matches": 0, + "positive_agreement": 0.5, + "positive_coverage": 0.0, + "parity_ci_lower": 0.8389, + "parity_ci_upper": 1.0, + "coverage_ci_lower": 0.0, + "coverage_ci_upper": 0.1611, + "evidence_alpha": 1.0, + "evidence_beta": 1.0, + "evidence_posterior_mean": 0.5, + "evidence_ci_lower": 0.05, + "evidence_ci_upper": 0.95, + "evidence_factor": 0.05, + "matches": 20, + "mismatches": 0, + "confidence": 1.0, + "llm_confidence": 0.92, + "overall_confidence": 0.0386, + "overall_method": "llm_confidence * parity_ci_lower_95 * evidence_ci_lower_95_beta_posterior", + "status": "MATCH", + "duckdb_query": "SELECT * FROM nutrition_table WHERE (sugars + starch) > (carbohydrates + 0.001)", + "duckdb_errors": 0, + "duckdb_condition": "(sugars + starch) > (carbohydrates + 0.001)", + "duckdb_example_rows": [], + "equivalence_cases": 0, + "equivalence_matches": 0, + "equivalence_mismatches": 0, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_counterexamples": [], + "mutation_total": 0, + "mutation_killed": 0, + "mutation_survived": 0, + "mutation_score": 1.0, + "mutation_survived_mutants": [], + "verification_score": 1.0, + "counterexample_repair_attempted": false, + "counterexample_repair_applied": false, + "counterexample_repair_error": "", + "mismatch_product_ids": [], + "failed_test_cases": [], + "perl_logic": "# RULE_NAME: sugars_plus_starch_vs_carbohydrates\n# SEVERITY: error\n# COMPLEXITY: medium\n# DECLARATIVE_FRIENDLY: yes\nif (($sugars + $starch) > ($carbohydrates + 0.001)) {\n push @{$product_ref->{$data_quality_tags}}, \"sugars-plus-starch-greater-than-carbohydrates\";\n}", + "python_conversion": " - failed_rows:\n name: sugars_plus_starch_vs_carbohydrates\n expression: (sugars + starch) > (carbohydrates + 0.001)", + "conversion_notes": "Soda Cloud unavailable/failed; used SQL-equivalent declarative parity (fast fallback). Command: soda contract verify (per-rule x12) -ds C:\\Users\\Administrator\\Downloads\\off_quality_migration_prototype\\results\\declarative_runtime\\soda\\soda_cloud\\data_source.yml -sc C:\\Users\\Administrator\\Downloads\\off_quality_migration_prototype\\results\\declarative_runtime\\soda\\soda_cloud\\soda_cloud.yml -p | Success: True | Return code: 0", + "conversion_provider": "soda_core_sql_fallback", + "conversion_execution_mode": "cloud_sql_fallback", + "conversion_cloud_connected": false, + "conversion_cloud_scan_id": "", + "conversion_cloud_scan_url": "https://cloud.us.soda.io/o/c9e7e376-1da2-49c5-93cb-78c6d95273ee/datasets/5e60cafe-18fc-4d01-8390-0057b49d7765" + }, + { + "rule_name": "fat_over_105g", + "tag": "fat-value-over-105g", + "severity": "warning", + "condition": "fat > 105", + "jurisdiction": "global", + "profile_tags": [ + "global", + "hybrid" + ], + "regulatory_type": "off_internal", + "legal_citation": "", + "source_url": "", + "effective_date": "", + "review_status": "reviewed", + "reviewer": "prototype", + "required_fields": [], + "exemption_logic": "none", + "rule_notes": "OFF-derived global rule: fat_over_105g", + "rule_ir": { + "version": "1.0", + "rule_name": "fat_over_105g", + "condition_type": "field_threshold", + "severity": "warning", + "tag": "fat-value-over-105g", + "left_operand": "fat", + "operator": ">", + "right_operand": 105.0 + }, + "rule_ir_hash": "c6f7c59ce9c9", + "condition_type": "field_threshold", + "complexity": "simple", + "declarative_friendly": true, + "products_tested": 20, + "perl_errors": 1, + "python_errors": 1, + "supporting_violations": 1, + "positive_matches": 1, + "positive_agreement": 1.0, + "positive_coverage": 0.05, + "parity_ci_lower": 0.8389, + "parity_ci_upper": 1.0, + "coverage_ci_lower": 0.0089, + "coverage_ci_upper": 0.2361, + "evidence_alpha": 2.0, + "evidence_beta": 1.0, + "evidence_posterior_mean": 0.6667, + "evidence_ci_lower": 0.2236, + "evidence_ci_upper": 0.9747, + "evidence_factor": 0.2236, + "matches": 20, + "mismatches": 0, + "confidence": 1.0, + "llm_confidence": 0.92, + "overall_confidence": 0.1726, + "overall_method": "llm_confidence * parity_ci_lower_95 * evidence_ci_lower_95_beta_posterior", + "status": "MATCH", + "duckdb_query": "SELECT * FROM nutrition_table WHERE fat > 105", + "duckdb_errors": 1, + "duckdb_condition": "fat > 105", + "duckdb_example_rows": [ + { + "product_id": "0000111301201", + "energy_kj": 19200.0, + "energy_kj_computed": NaN, + "energy_kcal": 4590.0, + "fat": 510.0, + "saturated_fat": 76.4, + "carbohydrates": 0.0, + "sugars": 0.0, + "starch": NaN, + "sodium": 5.1, + "ingredients_text": "CANOLA OIL, WATER, PALM OIL, PALM KERNEL OIL, SALT, WHEY POWDER (MILK), VEGETABLE MONO AND DIGLYCERIDES, SOYBEAN LECITHIN, POTASSIUM SORBATE (PRESERVATIVE), CITRIC ACID, ARTIFICIAL FLAVOR, VITAMIN E (DL-ALPHA-TOCOPHEROL ACETATE), VITAMIN A PALMITATE, BETA CAROTENE & VITAMIN D3.", + "ingredients_text_present": 1, + "contains_statement_present": 1, + "allergen_evidence_present": 1, + "fop_threshold_exceeded": 1, + "fop_symbol_present": 0, + "fop_exempt_proxy": 0, + "product_is_prepackaged_proxy": 1, + "lc": "en", + "lang": "en", + "language_code": "en" + } + ], + "equivalence_cases": 0, + "equivalence_matches": 0, + "equivalence_mismatches": 0, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_counterexamples": [], + "mutation_total": 0, + "mutation_killed": 0, + "mutation_survived": 0, + "mutation_score": 1.0, + "mutation_survived_mutants": [], + "verification_score": 1.0, + "counterexample_repair_attempted": false, + "counterexample_repair_applied": false, + "counterexample_repair_error": "", + "mismatch_product_ids": [], + "failed_test_cases": [], + "perl_logic": "# RULE_NAME: fat_over_105g\n# SEVERITY: warning\n# COMPLEXITY: simple\n# DECLARATIVE_FRIENDLY: yes\nif ($fat > 105) {\n push @{$product_ref->{$data_quality_tags}}, \"fat-value-over-105g\";\n}", + "python_conversion": " - failed_rows:\n name: fat_over_105g\n expression: fat > 105", + "conversion_notes": "Soda Cloud unavailable/failed; used SQL-equivalent declarative parity (fast fallback). Command: soda contract verify (per-rule x12) -ds C:\\Users\\Administrator\\Downloads\\off_quality_migration_prototype\\results\\declarative_runtime\\soda\\soda_cloud\\data_source.yml -sc C:\\Users\\Administrator\\Downloads\\off_quality_migration_prototype\\results\\declarative_runtime\\soda\\soda_cloud\\soda_cloud.yml -p | Success: True | Return code: 0", + "conversion_provider": "soda_core_sql_fallback", + "conversion_execution_mode": "cloud_sql_fallback", + "conversion_cloud_connected": false, + "conversion_cloud_scan_id": "", + "conversion_cloud_scan_url": "https://cloud.us.soda.io/o/c9e7e376-1da2-49c5-93cb-78c6d95273ee/datasets/5e60cafe-18fc-4d01-8390-0057b49d7765" + }, + { + "rule_name": "saturated_fat_over_105g", + "tag": "saturated-fat-value-over-105g", + "severity": "warning", + "condition": "saturated_fat > 105", + "jurisdiction": "global", + "profile_tags": [ + "global", + "hybrid" + ], + "regulatory_type": "off_internal", + "legal_citation": "", + "source_url": "", + "effective_date": "", + "review_status": "reviewed", + "reviewer": "prototype", + "required_fields": [], + "exemption_logic": "none", + "rule_notes": "OFF-derived global rule: saturated_fat_over_105g", + "rule_ir": { + "version": "1.0", + "rule_name": "saturated_fat_over_105g", + "condition_type": "field_threshold", + "severity": "warning", + "tag": "saturated-fat-value-over-105g", + "left_operand": "saturated_fat", + "operator": ">", + "right_operand": 105.0 + }, + "rule_ir_hash": "aafe1ceddbf5", + "condition_type": "field_threshold", + "complexity": "simple", + "declarative_friendly": true, + "products_tested": 20, + "perl_errors": 0, + "python_errors": 0, + "supporting_violations": 0, + "positive_matches": 0, + "positive_agreement": 0.5, + "positive_coverage": 0.0, + "parity_ci_lower": 0.8389, + "parity_ci_upper": 1.0, + "coverage_ci_lower": 0.0, + "coverage_ci_upper": 0.1611, + "evidence_alpha": 1.0, + "evidence_beta": 1.0, + "evidence_posterior_mean": 0.5, + "evidence_ci_lower": 0.05, + "evidence_ci_upper": 0.95, + "evidence_factor": 0.05, + "matches": 20, + "mismatches": 0, + "confidence": 1.0, + "llm_confidence": 0.92, + "overall_confidence": 0.0386, + "overall_method": "llm_confidence * parity_ci_lower_95 * evidence_ci_lower_95_beta_posterior", + "status": "MATCH", + "duckdb_query": "SELECT * FROM nutrition_table WHERE saturated_fat > 105", + "duckdb_errors": 0, + "duckdb_condition": "saturated_fat > 105", + "duckdb_example_rows": [], + "equivalence_cases": 0, + "equivalence_matches": 0, + "equivalence_mismatches": 0, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_counterexamples": [], + "mutation_total": 0, + "mutation_killed": 0, + "mutation_survived": 0, + "mutation_score": 1.0, + "mutation_survived_mutants": [], + "verification_score": 1.0, + "counterexample_repair_attempted": false, + "counterexample_repair_applied": false, + "counterexample_repair_error": "", + "mismatch_product_ids": [], + "failed_test_cases": [], + "perl_logic": "# RULE_NAME: saturated_fat_over_105g\n# SEVERITY: warning\n# COMPLEXITY: simple\n# DECLARATIVE_FRIENDLY: yes\nif ($saturated_fat > 105) {\n push @{$product_ref->{$data_quality_tags}}, \"saturated-fat-value-over-105g\";\n}", + "python_conversion": " - failed_rows:\n name: saturated_fat_over_105g\n expression: saturated_fat > 105", + "conversion_notes": "Soda Cloud unavailable/failed; used SQL-equivalent declarative parity (fast fallback). Command: soda contract verify (per-rule x12) -ds C:\\Users\\Administrator\\Downloads\\off_quality_migration_prototype\\results\\declarative_runtime\\soda\\soda_cloud\\data_source.yml -sc C:\\Users\\Administrator\\Downloads\\off_quality_migration_prototype\\results\\declarative_runtime\\soda\\soda_cloud\\soda_cloud.yml -p | Success: True | Return code: 0", + "conversion_provider": "soda_core_sql_fallback", + "conversion_execution_mode": "cloud_sql_fallback", + "conversion_cloud_connected": false, + "conversion_cloud_scan_id": "", + "conversion_cloud_scan_url": "https://cloud.us.soda.io/o/c9e7e376-1da2-49c5-93cb-78c6d95273ee/datasets/5e60cafe-18fc-4d01-8390-0057b49d7765" + }, + { + "rule_name": "carbohydrates_over_105g", + "tag": "carbohydrates-value-over-105g", + "severity": "warning", + "condition": "carbohydrates > 105", + "jurisdiction": "global", + "profile_tags": [ + "global", + "hybrid" + ], + "regulatory_type": "off_internal", + "legal_citation": "", + "source_url": "", + "effective_date": "", + "review_status": "reviewed", + "reviewer": "prototype", + "required_fields": [], + "exemption_logic": "none", + "rule_notes": "OFF-derived global rule: carbohydrates_over_105g", + "rule_ir": { + "version": "1.0", + "rule_name": "carbohydrates_over_105g", + "condition_type": "field_threshold", + "severity": "warning", + "tag": "carbohydrates-value-over-105g", + "left_operand": "carbohydrates", + "operator": ">", + "right_operand": 105.0 + }, + "rule_ir_hash": "7261087f016d", + "condition_type": "field_threshold", + "complexity": "simple", + "declarative_friendly": true, + "products_tested": 20, + "perl_errors": 0, + "python_errors": 0, + "supporting_violations": 0, + "positive_matches": 0, + "positive_agreement": 0.5, + "positive_coverage": 0.0, + "parity_ci_lower": 0.8389, + "parity_ci_upper": 1.0, + "coverage_ci_lower": 0.0, + "coverage_ci_upper": 0.1611, + "evidence_alpha": 1.0, + "evidence_beta": 1.0, + "evidence_posterior_mean": 0.5, + "evidence_ci_lower": 0.05, + "evidence_ci_upper": 0.95, + "evidence_factor": 0.05, + "matches": 20, + "mismatches": 0, + "confidence": 1.0, + "llm_confidence": 0.92, + "overall_confidence": 0.0386, + "overall_method": "llm_confidence * parity_ci_lower_95 * evidence_ci_lower_95_beta_posterior", + "status": "MATCH", + "duckdb_query": "SELECT * FROM nutrition_table WHERE carbohydrates > 105", + "duckdb_errors": 0, + "duckdb_condition": "carbohydrates > 105", + "duckdb_example_rows": [], + "equivalence_cases": 0, + "equivalence_matches": 0, + "equivalence_mismatches": 0, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_counterexamples": [], + "mutation_total": 0, + "mutation_killed": 0, + "mutation_survived": 0, + "mutation_score": 1.0, + "mutation_survived_mutants": [], + "verification_score": 1.0, + "counterexample_repair_attempted": false, + "counterexample_repair_applied": false, + "counterexample_repair_error": "", + "mismatch_product_ids": [], + "failed_test_cases": [], + "perl_logic": "# RULE_NAME: carbohydrates_over_105g\n# SEVERITY: warning\n# COMPLEXITY: simple\n# DECLARATIVE_FRIENDLY: yes\nif ($carbohydrates > 105) {\n push @{$product_ref->{$data_quality_tags}}, \"carbohydrates-value-over-105g\";\n}", + "python_conversion": " - failed_rows:\n name: carbohydrates_over_105g\n expression: carbohydrates > 105", + "conversion_notes": "Soda Cloud unavailable/failed; used SQL-equivalent declarative parity (fast fallback). Command: soda contract verify (per-rule x12) -ds C:\\Users\\Administrator\\Downloads\\off_quality_migration_prototype\\results\\declarative_runtime\\soda\\soda_cloud\\data_source.yml -sc C:\\Users\\Administrator\\Downloads\\off_quality_migration_prototype\\results\\declarative_runtime\\soda\\soda_cloud\\soda_cloud.yml -p | Success: True | Return code: 0", + "conversion_provider": "soda_core_sql_fallback", + "conversion_execution_mode": "cloud_sql_fallback", + "conversion_cloud_connected": false, + "conversion_cloud_scan_id": "", + "conversion_cloud_scan_url": "https://cloud.us.soda.io/o/c9e7e376-1da2-49c5-93cb-78c6d95273ee/datasets/5e60cafe-18fc-4d01-8390-0057b49d7765" + }, + { + "rule_name": "sugars_over_105g", + "tag": "sugars-value-over-105g", + "severity": "warning", + "condition": "sugars > 105", + "jurisdiction": "global", + "profile_tags": [ + "global", + "hybrid" + ], + "regulatory_type": "off_internal", + "legal_citation": "", + "source_url": "", + "effective_date": "", + "review_status": "reviewed", + "reviewer": "prototype", + "required_fields": [], + "exemption_logic": "none", + "rule_notes": "OFF-derived global rule: sugars_over_105g", + "rule_ir": { + "version": "1.0", + "rule_name": "sugars_over_105g", + "condition_type": "field_threshold", + "severity": "warning", + "tag": "sugars-value-over-105g", + "left_operand": "sugars", + "operator": ">", + "right_operand": 105.0 + }, + "rule_ir_hash": "f4924feaa2f8", + "condition_type": "field_threshold", + "complexity": "simple", + "declarative_friendly": true, + "products_tested": 20, + "perl_errors": 0, + "python_errors": 0, + "supporting_violations": 0, + "positive_matches": 0, + "positive_agreement": 0.5, + "positive_coverage": 0.0, + "parity_ci_lower": 0.8389, + "parity_ci_upper": 1.0, + "coverage_ci_lower": 0.0, + "coverage_ci_upper": 0.1611, + "evidence_alpha": 1.0, + "evidence_beta": 1.0, + "evidence_posterior_mean": 0.5, + "evidence_ci_lower": 0.05, + "evidence_ci_upper": 0.95, + "evidence_factor": 0.05, + "matches": 20, + "mismatches": 0, + "confidence": 1.0, + "llm_confidence": 0.92, + "overall_confidence": 0.0386, + "overall_method": "llm_confidence * parity_ci_lower_95 * evidence_ci_lower_95_beta_posterior", + "status": "MATCH", + "duckdb_query": "SELECT * FROM nutrition_table WHERE sugars > 105", + "duckdb_errors": 0, + "duckdb_condition": "sugars > 105", + "duckdb_example_rows": [], + "equivalence_cases": 0, + "equivalence_matches": 0, + "equivalence_mismatches": 0, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "equivalence_counterexamples": [], + "mutation_total": 0, + "mutation_killed": 0, + "mutation_survived": 0, + "mutation_score": 1.0, + "mutation_survived_mutants": [], + "verification_score": 1.0, + "counterexample_repair_attempted": false, + "counterexample_repair_applied": false, + "counterexample_repair_error": "", + "mismatch_product_ids": [], + "failed_test_cases": [], + "perl_logic": "# RULE_NAME: sugars_over_105g\n# SEVERITY: warning\n# COMPLEXITY: simple\n# DECLARATIVE_FRIENDLY: yes\nif ($sugars > 105) {\n push @{$product_ref->{$data_quality_tags}}, \"sugars-value-over-105g\";\n}", + "python_conversion": " - failed_rows:\n name: sugars_over_105g\n expression: sugars > 105", + "conversion_notes": "Soda Cloud unavailable/failed; used SQL-equivalent declarative parity (fast fallback). Command: soda contract verify (per-rule x12) -ds C:\\Users\\Administrator\\Downloads\\off_quality_migration_prototype\\results\\declarative_runtime\\soda\\soda_cloud\\data_source.yml -sc C:\\Users\\Administrator\\Downloads\\off_quality_migration_prototype\\results\\declarative_runtime\\soda\\soda_cloud\\soda_cloud.yml -p | Success: True | Return code: 0", + "conversion_provider": "soda_core_sql_fallback", + "conversion_execution_mode": "cloud_sql_fallback", + "conversion_cloud_connected": false, + "conversion_cloud_scan_id": "", + "conversion_cloud_scan_url": "https://cloud.us.soda.io/o/c9e7e376-1da2-49c5-93cb-78c6d95273ee/datasets/5e60cafe-18fc-4d01-8390-0057b49d7765" + } + ], + "declarative_engine_run": { + "command": "soda contract verify (per-rule x12) -ds C:\\Users\\Administrator\\Downloads\\off_quality_migration_prototype\\results\\declarative_runtime\\soda\\soda_cloud\\data_source.yml -sc C:\\Users\\Administrator\\Downloads\\off_quality_migration_prototype\\results\\declarative_runtime\\soda\\soda_cloud\\soda_cloud.yml -p", + "executed": true, + "success": true, + "return_code": 0, + "stdout_tail": "\nergy_kj_over_3911\\\\n expression: energy_kj > 3911\\\\n\\\",\\n \\\"token\\\": \\\"****\\\"\\n}\",\n \"timestamp\": \"2026-03-19T04:58:35+00:00\",\n \"index\": 27,\n \"thread\": 6576\n },\n {\n \"level\": \"debug\",\n \"message\": \"\\ud83d\\udc4c Soda Cloud command upload_contract_file OK | X-Soda-Trace-Id:5687728576962414806\",\n \"timestamp\": \"2026-03-19T04:58:36+00:00\",\n \"index\": 28,\n \"thread\": 6576\n }\n ],\n \"sourceOwner\": \"soda-core\",\n \"contract\": {\n \"fileId\": \"55051482-c315-4894-bfae-1d3a9a712e34\",\n \"metadata\": {\n \"source\": {\n \"type\": \"local\",\n \"filePath\": \"C:\\\\Users\\\\Administrator\\\\Downloads\\\\off_quality_migration_prototype\\\\results\\\\declarative_runtime\\\\soda\\\\soda_cloud\\\\contracts\\\\energy_kj_over_3911.yml\"\n }\n }\n },\n \"postProcessingStages\": [],\n \"resultsIngestionMode\": \"full\",\n \"type\": \"sodaCoreInsertScanResults\",\n \"token\": \"****\"\n}\n\ud83d\udc4c Soda Cloud command send_contract_verification_results OK | X-Soda-Trace-Id:3497840797341852655\n\ud83d\udc4c Results sent to Soda Cloud\nTo view the dataset on Soda Cloud, see https://cloud.us.soda.io/o/c9e7e376-1da2-49c5-93cb-78c6d95273ee/datasets/5e60cafe-18fc-4d01-8390-0057b49d7765\nExiting with code 1", + "stderr_tail": "", + "mode": "cloud_sql_fallback", + "real_execution": false, + "cloud_connected": false, + "cloud_scan_id": "", + "cloud_scan_url": "https://cloud.us.soda.io/o/c9e7e376-1da2-49c5-93cb-78c6d95273ee/datasets/5e60cafe-18fc-4d01-8390-0057b49d7765", + "cloud_config_source": "C:\\Users\\Administrator\\Downloads\\off_quality_migration_prototype\\sc_config.yml", + "failed_rules": [ + "energy_kcal_vs_kj", + "energy_kj_mismatch_low", + "energy_kj_mismatch_high", + "energy_kj_over_3911", + "energy_kj_computed_mismatch_low", + "energy_kj_computed_mismatch_high", + "saturated_fat_vs_fat", + "sugars_plus_starch_vs_carbohydrates", + "fat_over_105g", + "saturated_fat_over_105g", + "carbohydrates_over_105g", + "sugars_over_105g" + ] + } +} \ No newline at end of file diff --git a/OFF_DataQuality/rulepacks/__init__.py b/OFF_DataQuality/rulepacks/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..fb0010857ed4de3a7c1dc110cfe5a25755a4f324 --- /dev/null +++ b/OFF_DataQuality/rulepacks/__init__.py @@ -0,0 +1,2 @@ +"""Rule-pack and profile helpers for migration pipeline.""" + diff --git a/OFF_DataQuality/rulepacks/registry.py b/OFF_DataQuality/rulepacks/registry.py new file mode 100644 index 0000000000000000000000000000000000000000..04414e4af976261c6c038b988592fa4c7ec20cbf --- /dev/null +++ b/OFF_DataQuality/rulepacks/registry.py @@ -0,0 +1,208 @@ +"""Rule-pack registry for profile-aware migration runs. + +Profiles: +- global: OFF-derived generic checks. +- canada: Canada-focused checks with official-source traceability metadata. +- hybrid: union of global + canada (default for backward compatibility). +""" +from __future__ import annotations + +from dataclasses import dataclass +from typing import Dict, Iterable, List, Mapping, Sequence + +DEFAULT_PROFILE = "hybrid" +SUPPORTED_PROFILES = ("global", "canada", "hybrid") + +CANADA_RULES = ( + "main_language_code_missing", + "main_language_missing", + "ca_allergen_evidence_missing_ingredients_text", + "ca_contains_statement_without_allergen_evidence", + "ca_fop_required_but_symbol_missing", + "ca_fop_symbol_present_but_not_required", + "ca_fop_symbol_present_on_exempt_product", +) + + +@dataclass(frozen=True) +class RuleProfileMetadata: + jurisdiction: str + profile_tags: List[str] + regulatory_type: str + legal_citation: str + source_url: str + effective_date: str + review_status: str + reviewer: str + required_fields: List[str] + exemption_logic: str + notes: str + + +def _default_metadata(rule_name: str) -> RuleProfileMetadata: + return RuleProfileMetadata( + jurisdiction="global", + profile_tags=["global", "hybrid"], + regulatory_type="off_internal", + legal_citation="", + source_url="", + effective_date="", + review_status="reviewed", + reviewer="prototype", + required_fields=[], + exemption_logic="none", + notes=f"OFF-derived global rule: {rule_name}", + ) + + +RULE_PROFILE_METADATA: Dict[str, RuleProfileMetadata] = { + "main_language_code_missing": RuleProfileMetadata( + jurisdiction="ca", + profile_tags=["canada", "hybrid"], + regulatory_type="statutory", + legal_citation="SFCR 206(1); FDR B.01.012(2)", + source_url="https://laws-lois.justice.gc.ca/eng/regulations/SOR-2018-108/section-206.html", + effective_date="2019-01-15", + review_status="draft", + reviewer="pending-mentor-review", + required_fields=["lc", "lang", "language_code"], + exemption_logic="Not all products require bilingual labels; this prototype uses a conservative language-presence proxy.", + notes="Canada pack: proxy check for missing primary language code in label metadata.", + ), + "main_language_missing": RuleProfileMetadata( + jurisdiction="ca", + profile_tags=["canada", "hybrid"], + regulatory_type="statutory", + legal_citation="SFCR 206(1); FDR B.01.012(2)", + source_url="https://laws-lois.justice.gc.ca/eng/regulations/C.R.C.,_c._870/section-B.01.012.html", + effective_date="2019-01-15", + review_status="draft", + reviewer="pending-mentor-review", + required_fields=["lang", "language_code", "lc"], + exemption_logic="Prototype proxy only; legal exemptions by product class must be modeled before strict enforcement.", + notes="Canada pack: proxy check for missing primary language value.", + ), + "ca_allergen_evidence_missing_ingredients_text": RuleProfileMetadata( + jurisdiction="ca", + profile_tags=["canada", "hybrid"], + regulatory_type="statutory_proxy", + legal_citation="FDR B.01.010.1(2); FDR B.01.010.3", + source_url="https://laws-lois.justice.gc.ca/eng/regulations/C.R.C.,_c._870/section-B.01.010.1.html", + effective_date="2012-08-04", + review_status="draft", + reviewer="pending-mentor-review", + required_fields=["allergen_evidence_present", "ingredients_text_present", "ingredients_text"], + exemption_logic="Proxy check: flags records with allergen evidence but no ingredient text present.", + notes="Phase-1 Canada allergen rule using OFF-available proxy fields.", + ), + "ca_contains_statement_without_allergen_evidence": RuleProfileMetadata( + jurisdiction="ca", + profile_tags=["canada", "hybrid"], + regulatory_type="statutory_proxy", + legal_citation="FDR B.01.010.3(1)(b), (2)", + source_url="https://laws-lois.justice.gc.ca/eng/regulations/C.R.C.,_c._870/section-B.01.010.3.html", + effective_date="2012-08-04", + review_status="draft", + reviewer="pending-mentor-review", + required_fields=["contains_statement_present", "allergen_evidence_present"], + exemption_logic="Proxy check: 'contains' proxy without allergen evidence proxy.", + notes="Phase-1 Canada allergen consistency rule.", + ), + "ca_fop_required_but_symbol_missing": RuleProfileMetadata( + jurisdiction="ca", + profile_tags=["canada", "hybrid"], + regulatory_type="statutory_proxy", + legal_citation="FDR B.01.350(1)", + source_url="https://laws-lois.justice.gc.ca/eng/regulations/C.R.C.,_c._870/section-B.01.350.html", + effective_date="2026-01-01", + review_status="draft", + reviewer="pending-mentor-review", + required_fields=[ + "fop_threshold_exceeded", + "fop_symbol_present", + "fop_exempt_proxy", + "product_is_prepackaged_proxy", + ], + exemption_logic="Applies only when proxy not exempt and prepackaged proxy is true.", + notes="Phase-1 Canada FOP threshold-vs-symbol proxy.", + ), + "ca_fop_symbol_present_but_not_required": RuleProfileMetadata( + jurisdiction="ca", + profile_tags=["canada", "hybrid"], + regulatory_type="guidance_proxy", + legal_citation="FDR B.01.350; CFIA FOP guidance", + source_url="https://inspection.canada.ca/en/food-labels/labelling/industry/nutrition-labelling/fop-nutrition-symbol", + effective_date="2026-01-01", + review_status="draft", + reviewer="pending-mentor-review", + required_fields=[ + "fop_threshold_exceeded", + "fop_symbol_present", + "fop_exempt_proxy", + "product_is_prepackaged_proxy", + ], + exemption_logic="Proxy warning for symbol present when threshold proxy not exceeded and not exempt.", + notes="Phase-1 Canada FOP over-labelling consistency rule.", + ), + "ca_fop_symbol_present_on_exempt_product": RuleProfileMetadata( + jurisdiction="ca", + profile_tags=["canada", "hybrid"], + regulatory_type="guidance_proxy", + legal_citation="FDR B.01.350(5)-(15)", + source_url="https://laws-lois.justice.gc.ca/eng/regulations/C.R.C.,_c._870/section-B.01.350.html", + effective_date="2026-01-01", + review_status="draft", + reviewer="pending-mentor-review", + required_fields=["fop_symbol_present", "fop_exempt_proxy", "product_is_prepackaged_proxy"], + exemption_logic="Proxy warning on symbol presence for exempt categories.", + notes="Phase-1 Canada FOP exemption consistency rule.", + ), +} + + +def _build_profile_rule_names(all_rule_names: Iterable[str]) -> Dict[str, List[str]]: + names = list(all_rule_names) + canada_set = set(CANADA_RULES) + global_rules = [name for name in names if name not in canada_set] + canada_rules = [name for name in names if name in canada_set] + hybrid_rules = names + return { + "global": global_rules, + "canada": canada_rules, + "hybrid": hybrid_rules, + } + + +def validate_profile(profile: str) -> str: + normalized = profile.strip().lower() + if normalized not in SUPPORTED_PROFILES: + raise ValueError(f"Unsupported profile `{profile}`. Supported: {', '.join(SUPPORTED_PROFILES)}") + return normalized + + +def get_profile_rule_names(profile: str, all_rule_names: Sequence[str]) -> List[str]: + normalized = validate_profile(profile) + profile_map = _build_profile_rule_names(all_rule_names) + return list(profile_map[normalized]) + + +def attach_profile_metadata(rules: Sequence[Mapping[str, object]], profile: str) -> List[Dict[str, object]]: + validate_profile(profile) + out: List[Dict[str, object]] = [] + for rule in rules: + rule_name = str(rule.get("rule_name", "")) + meta = RULE_PROFILE_METADATA.get(rule_name, _default_metadata(rule_name)) + row = dict(rule) + row["jurisdiction"] = meta.jurisdiction + row["profile_tags"] = list(meta.profile_tags) + row["regulatory_type"] = meta.regulatory_type + row["legal_citation"] = meta.legal_citation + row["source_url"] = meta.source_url + row["effective_date"] = meta.effective_date + row["review_status"] = meta.review_status + row["reviewer"] = meta.reviewer + row["required_fields"] = list(meta.required_fields) + row["exemption_logic"] = meta.exemption_logic + row["rule_notes"] = meta.notes + out.append(row) + return out diff --git a/OFF_DataQuality/tests/test_declarative_runner.py b/OFF_DataQuality/tests/test_declarative_runner.py new file mode 100644 index 0000000000000000000000000000000000000000..a78f8f38730faec8829796e951ef7a6b547f15d0 --- /dev/null +++ b/OFF_DataQuality/tests/test_declarative_runner.py @@ -0,0 +1,35 @@ +from pathlib import Path + +from data.load_dataset import create_and_load_dataset +from declarative import check_runners +from extractor.perl_logic_extractor import extract_rules +from perl_checks.legacy_checks import LEGACY_RULES, get_perl_rule_snippets + + +def _run_engine(engine: str, tmp_path: Path, monkeypatch) -> None: + monkeypatch.setattr(check_runners.shutil, "which", lambda _: None) + db_path = tmp_path / f"{engine}_checks.db" + products = create_and_load_dataset(size=120, seed=17, db_path=db_path, source_jsonl=None) + rules = extract_rules(get_perl_rule_snippets(LEGACY_RULES)) + + result = check_runners.run_declarative_checks( + rules=rules, + products=products, + db_path=db_path, + engine=engine, + ) + + assert set(result["per_rule"].keys()) == {rule["rule_name"] for rule in rules} + assert set(result["conversion_metadata"].keys()) == {rule["rule_name"] for rule in rules} + first_rule = rules[0]["rule_name"] + provider = result["conversion_metadata"][first_rule]["provider"] + assert provider.endswith("_sql_fallback") + + +def test_declarative_dbt_runner_smoke(tmp_path, monkeypatch) -> None: + _run_engine("dbt", tmp_path=tmp_path, monkeypatch=monkeypatch) + + +def test_declarative_soda_runner_smoke(tmp_path, monkeypatch) -> None: + _run_engine("soda", tmp_path=tmp_path, monkeypatch=monkeypatch) + diff --git a/OFF_DataQuality/tests/test_deterministic_converter.py b/OFF_DataQuality/tests/test_deterministic_converter.py new file mode 100644 index 0000000000000000000000000000000000000000..5342dbcf258dd586f2c458323353014e27fd81a1 --- /dev/null +++ b/OFF_DataQuality/tests/test_deterministic_converter.py @@ -0,0 +1,84 @@ +from extractor.perl_logic_extractor import extract_rules +from migration.llm_converter import convert_rules +from perl_checks.legacy_checks import LEGACY_RULES, get_perl_rule_snippets +from python_checks.generated_checks import compile_generated_checks + + +def test_deterministic_conversion_behaves_like_expected_templates() -> None: + structured_rules = extract_rules(get_perl_rule_snippets(LEGACY_RULES)) + converted_rules = convert_rules(structured_rules, provider="simulated") + checks, metadata = compile_generated_checks(converted_rules) + + energy_tag = checks["energy_kcal_vs_kj"]({"energy_kcal": 200.0, "energy_kj": 100.0}) + assert energy_tag == "energy-value-in-kcal-greater-than-in-kj" + assert checks["energy_kcal_vs_kj"]({"energy_kcal": 50.0, "energy_kj": 100.0}) is None + + sugars_tag = checks["sugars_over_105g"]({"sugars": 106.0}) + assert sugars_tag == "sugars-value-over-105g" + assert checks["sugars_over_105g"]({"sugars": 104.9}) is None + + low_energy_tag = checks["energy_kj_mismatch_low"]({"energy_kj": 300.0, "energy_kcal": 100.0}) + assert low_energy_tag == "energy-value-in-kcal-does-not-match-value-in-kj-low" + assert checks["energy_kj_mismatch_low"]({"energy_kj": 380.0, "energy_kcal": 100.0}) is None + + high_energy_tag = checks["energy_kj_mismatch_high"]({"energy_kj": 500.0, "energy_kcal": 100.0}) + assert high_energy_tag == "energy-value-in-kcal-does-not-match-value-in-kj-high" + assert checks["energy_kj_mismatch_high"]({"energy_kj": 450.0, "energy_kcal": 100.0}) is None + + computed_low_tag = checks["energy_kj_computed_mismatch_low"]({"energy_kj_computed": 60.0, "energy_kj": 100.0}) + assert computed_low_tag == "energy-value-in-kj-does-not-match-value-computed-from-other-nutrients-low" + assert checks["energy_kj_computed_mismatch_low"]({"energy_kj_computed": 80.0, "energy_kj": 100.0}) is None + + computed_high_tag = checks["energy_kj_computed_mismatch_high"]({"energy_kj_computed": 150.0, "energy_kj": 100.0}) + assert computed_high_tag == "energy-value-in-kj-does-not-match-value-computed-from-other-nutrients-high" + assert checks["energy_kj_computed_mismatch_high"]({"energy_kj_computed": 130.0, "energy_kj": 100.0}) is None + + sugar_starch_tag = checks["sugars_plus_starch_vs_carbohydrates"]( + {"sugars": 12.0, "starch": 8.2, "carbohydrates": 20.0} + ) + assert sugar_starch_tag == "sugars-plus-starch-greater-than-carbohydrates" + assert ( + checks["sugars_plus_starch_vs_carbohydrates"]({"sugars": 8.0, "starch": 6.0, "carbohydrates": 20.0}) is None + ) + + missing_lc_tag = checks["main_language_code_missing"]({"lc": " "}) + assert missing_lc_tag == "main-language-code-missing" + assert checks["main_language_code_missing"]({"lc": "en"}) is None + + missing_lang_tag = checks["main_language_missing"]({"lang": ""}) + assert missing_lang_tag == "main-language-missing" + assert checks["main_language_missing"]({"lang": "en"}) is None + + ca_allergen_tag = checks["ca_allergen_evidence_missing_ingredients_text"]( + {"allergen_evidence_present": 1, "ingredients_text_present": 0} + ) + assert ca_allergen_tag == "ca-allergen-evidence-but-missing-ingredients-text" + assert ( + checks["ca_allergen_evidence_missing_ingredients_text"]( + {"allergen_evidence_present": 1, "ingredients_text_present": 1} + ) + is None + ) + + ca_fop_missing_tag = checks["ca_fop_required_but_symbol_missing"]( + { + "fop_threshold_exceeded": 1, + "fop_symbol_present": 0, + "fop_exempt_proxy": 0, + "product_is_prepackaged_proxy": 1, + } + ) + assert ca_fop_missing_tag == "ca-fop-required-but-symbol-missing" + assert ( + checks["ca_fop_required_but_symbol_missing"]( + { + "fop_threshold_exceeded": 1, + "fop_symbol_present": 1, + "fop_exempt_proxy": 0, + "product_is_prepackaged_proxy": 1, + } + ) + is None + ) + + assert metadata["energy_kcal_vs_kj"]["provider"] == "simulated" diff --git a/OFF_DataQuality/tests/test_engine_comparison.py b/OFF_DataQuality/tests/test_engine_comparison.py new file mode 100644 index 0000000000000000000000000000000000000000..0f40f18f1c848b42bacc143cafadd4f69824439a --- /dev/null +++ b/OFF_DataQuality/tests/test_engine_comparison.py @@ -0,0 +1,42 @@ +import json + +from validation.engine_comparison import ENGINES, run_engine_comparison + + +def test_engine_comparison_smoke(tmp_path) -> None: + results_path = tmp_path / "engine_comparison.json" + db_path = tmp_path / "engine_compare.db" + + report = run_engine_comparison( + dataset_size=100, + seed=17, + source_jsonl=None, + use_default_off_source=False, + llm_provider="simulated", + llm_model=None, + perl_rules_dir=None, + db_path=db_path, + results_path=results_path, + ) + + assert results_path.exists() + parsed = json.loads(results_path.read_text(encoding="utf-8")) + assert parsed["engines"] == list(ENGINES) + assert set(parsed["per_engine_summary"].keys()) == set(ENGINES) + assert len(parsed["rule_comparison"]) > 0 + assert "comparison_method" in parsed + assert "run_config" in parsed + assert "per_complexity_summary" in parsed + assert parsed["run_config"]["soda_mode"] == "local" + assert "comparison_fingerprint" in parsed + assert "engine_run_fingerprints" in parsed + assert parsed["comparison_fingerprint"]["dataset_fingerprint_consistent"] is True + assert parsed["comparison_fingerprint"]["rulepack_fingerprint_consistent"] is True + first_rule = parsed["rule_comparison"][0] + assert set(first_rule["engines"].keys()) == set(ENGINES) + assert "best_engine" in first_rule + assert "recommendation" in first_rule + assert "complexity" in first_rule + assert "effective_confidence" in first_rule["engines"]["python"] + assert "provider_factor" in first_rule["engines"]["python"] + assert report["engines"] == list(ENGINES) diff --git a/OFF_DataQuality/tests/test_extractor.py b/OFF_DataQuality/tests/test_extractor.py new file mode 100644 index 0000000000000000000000000000000000000000..3c1131f4962e847893180fd403ac4e7a8514c6cb --- /dev/null +++ b/OFF_DataQuality/tests/test_extractor.py @@ -0,0 +1,54 @@ +from pathlib import Path + +from extractor.perl_logic_extractor import extract_rules +from perl_checks.legacy_checks import RULE_FILES_DIR, load_rule_snippets_from_directory + + +def test_extract_rules_from_perl_files() -> None: + snippets = load_rule_snippets_from_directory(RULE_FILES_DIR) + rules = extract_rules(snippets) + + assert len(rules) >= 19 + names = {rule["rule_name"] for rule in rules} + assert "energy_kcal_vs_kj" in names + assert "main_language_code_missing" in names + assert "energy_kj_mismatch_low" in names + assert "energy_kj_computed_mismatch_low" in names + assert "energy_kj_computed_mismatch_high" in names + assert "sugars_plus_starch_vs_carbohydrates" in names + assert "ca_fop_required_but_symbol_missing" in names + assert "ca_contains_statement_without_allergen_evidence" in names + + missing_rule = next(rule for rule in rules if rule["rule_name"] == "main_language_code_missing") + assert missing_rule["condition_type"] == "missing_field" + assert missing_rule["duckdb_condition"] == "lc IS NULL OR TRIM(lc) = ''" + assert "rule_ir" in missing_rule + assert len(str(missing_rule.get("rule_ir_hash", ""))) == 12 + + affine_rule = next(rule for rule in rules if rule["rule_name"] == "energy_kj_mismatch_low") + assert affine_rule["condition_type"] == "affine_field_comparison" + assert affine_rule["complexity"] == "intricate" + assert affine_rule["declarative_friendly"] is False + assert affine_rule["scale_factor"] == 3.7 + assert affine_rule["offset"] == -2.0 + + sum_rule = next(rule for rule in rules if rule["rule_name"] == "sugars_plus_starch_vs_carbohydrates") + assert sum_rule["condition_type"] == "sum_fields_comparison" + assert sum_rule["left_operands"] == ["sugars", "starch"] + assert sum_rule["right_operand"] == "carbohydrates" + + computed_rule = next(rule for rule in rules if rule["rule_name"] == "energy_kj_computed_mismatch_low") + assert computed_rule["condition_type"] == "affine_field_comparison" + assert computed_rule["left_operand"] == "energy_kj_computed" + assert computed_rule["right_operand"] == "energy_kj" + assert computed_rule["scale_factor"] == 0.7 + assert computed_rule["offset"] == -5.0 + + ca_fop_rule = next(rule for rule in rules if rule["rule_name"] == "ca_fop_required_but_symbol_missing") + assert ca_fop_rule["condition_type"] == "compound_threshold_and" + assert ca_fop_rule["complexity"] == "medium" + + +def test_perl_rule_files_are_present() -> None: + rule_files = sorted(Path(RULE_FILES_DIR).glob("*.pl")) + assert len(rule_files) >= 8 diff --git a/OFF_DataQuality/tests/test_parity_smoke.py b/OFF_DataQuality/tests/test_parity_smoke.py new file mode 100644 index 0000000000000000000000000000000000000000..b1acd9e274edad43f41fa65f3ac08b4fefa4f9bb --- /dev/null +++ b/OFF_DataQuality/tests/test_parity_smoke.py @@ -0,0 +1,35 @@ +from pathlib import Path + +import validation.parity_validator as parity_validator +from perl_checks.legacy_checks import load_rule_snippets_from_directory + + +def test_parity_pipeline_smoke_simulated(tmp_path, monkeypatch) -> None: + monkeypatch.setattr(parity_validator, "DEFAULT_OFF_JSONL", tmp_path / "missing_off_source.jsonl") + results_path = tmp_path / "migration_results.json" + perl_rules_dir = Path(__file__).resolve().parent.parent / "perl_checks" / "rules" + + payload = parity_validator.run_pipeline( + dataset_size=100, + seed=17, + results_path=results_path, + source_jsonl=None, + use_default_off_source=False, + db_path=tmp_path / "off_quality_test.db", + llm_provider="simulated", + perl_rules_dir=perl_rules_dir, + ) + + summary = payload["migration_summary"] + expected_rules = len(load_rule_snippets_from_directory(perl_rules_dir)) + assert results_path.exists() + assert summary["total_rules"] == expected_rules + assert summary["passed_rules"] == expected_rules + assert summary["rules_needing_review"] == 0 + assert "run_fingerprint" in payload + assert payload["run_fingerprint"]["dataset_fingerprint"]["sha256"] + assert payload["run_fingerprint"]["rulepack_fingerprint"]["rule_ir_sha256"] + first_rule = payload["rule_results"][0] + assert "parity_ci_lower" in first_rule + assert "evidence_ci_lower" in first_rule + assert "overall_method" in first_rule diff --git a/OFF_DataQuality/tests/test_profiles.py b/OFF_DataQuality/tests/test_profiles.py new file mode 100644 index 0000000000000000000000000000000000000000..4a207397af02dad401c7a85c16385d0f8033a4ff --- /dev/null +++ b/OFF_DataQuality/tests/test_profiles.py @@ -0,0 +1,47 @@ +from pathlib import Path + +from rulepacks.registry import DEFAULT_PROFILE, SUPPORTED_PROFILES, get_profile_rule_names, validate_profile +from validation.parity_validator import run_pipeline + + +def test_profile_registry_basics() -> None: + assert DEFAULT_PROFILE in SUPPORTED_PROFILES + assert validate_profile("HYBRID") == "hybrid" + rule_names = [ + "energy_kcal_vs_kj", + "main_language_code_missing", + "main_language_missing", + "ca_fop_required_but_symbol_missing", + ] + assert get_profile_rule_names("global", rule_names) == ["energy_kcal_vs_kj"] + assert get_profile_rule_names("canada", rule_names) == [ + "main_language_code_missing", + "main_language_missing", + "ca_fop_required_but_symbol_missing", + ] + assert get_profile_rule_names("hybrid", rule_names) == rule_names + + +def test_canada_profile_pipeline_subset(tmp_path, monkeypatch) -> None: + import validation.parity_validator as parity_validator + + monkeypatch.setattr(parity_validator, "DEFAULT_OFF_JSONL", tmp_path / "missing_off_source.jsonl") + payload = run_pipeline( + dataset_size=120, + seed=17, + results_path=tmp_path / "migration_results_canada.json", + source_jsonl=None, + use_default_off_source=False, + db_path=tmp_path / "off_quality_canada.db", + llm_provider="simulated", + perl_rules_dir=Path(__file__).resolve().parent.parent / "perl_checks" / "rules", + execution_engine="python", + profile="canada", + ) + + assert payload["dataset"]["profile"] == "canada" + assert payload["migration_summary"]["total_rules"] == 7 + jurisdictions = {row["jurisdiction"] for row in payload["rule_results"]} + assert jurisdictions == {"ca"} + citations = [str(row.get("legal_citation", "")) for row in payload["rule_results"]] + assert all(citation != "" for citation in citations) diff --git a/OFF_DataQuality/tests/test_verification.py b/OFF_DataQuality/tests/test_verification.py new file mode 100644 index 0000000000000000000000000000000000000000..76c08dee07540cb917eb4af15d536adaec24d7ff --- /dev/null +++ b/OFF_DataQuality/tests/test_verification.py @@ -0,0 +1,27 @@ +from extractor.perl_logic_extractor import extract_rules +from migration.llm_converter import convert_rules +from perl_checks.legacy_checks import LEGACY_RULES, get_legacy_rule_map, get_perl_rule_snippets +from python_checks.generated_checks import compile_generated_checks +from validation.verification import run_rule_verification + + +def test_rule_verification_for_deterministic_conversion() -> None: + structured_rules = extract_rules(get_perl_rule_snippets(LEGACY_RULES)) + converted_rules = convert_rules(structured_rules, provider="simulated") + checks, metadata = compile_generated_checks(converted_rules) + legacy_map = get_legacy_rule_map(LEGACY_RULES) + + rule = next(rule for rule in structured_rules if rule["rule_name"] == "energy_kcal_vs_kj") + verification = run_rule_verification( + rule=rule, + perl_evaluator=legacy_map["energy_kcal_vs_kj"].evaluator, + check_fn=checks["energy_kcal_vs_kj"], + python_code=str(metadata["energy_kcal_vs_kj"]["python_code"]), + function_name=str(metadata["energy_kcal_vs_kj"]["function_name"]), + seed=17, + ) + + assert verification["equivalence_mismatches"] == 0 + assert verification["equivalence_status"] == "PASS" + assert verification["mutation_total"] >= 1 + assert 0.0 <= float(verification["mutation_score"]) <= 1.0 diff --git a/OFF_DataQuality/validation/__init__.py b/OFF_DataQuality/validation/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/OFF_DataQuality/validation/engine_comparison.py b/OFF_DataQuality/validation/engine_comparison.py new file mode 100644 index 0000000000000000000000000000000000000000..e205726f319f6914a06a9167532c460a8698af01 --- /dev/null +++ b/OFF_DataQuality/validation/engine_comparison.py @@ -0,0 +1,695 @@ +"""Compare python/dbt/soda execution engines against the same Perl baseline.""" +from __future__ import annotations + +import argparse +import hashlib +import json +import os +from datetime import datetime, timezone +from pathlib import Path +from statistics import mean +from typing import Dict, Iterable, List, Mapping, Sequence, Tuple +from uuid import uuid4 + +from data.load_dataset import DB_PATH, DEFAULT_OFF_JSONL +from rulepacks.registry import DEFAULT_PROFILE, SUPPORTED_PROFILES +from validation.parity_validator import RESULT_PATH, run_pipeline + +COMPARISON_PATH = Path(__file__).resolve().parent.parent / "results" / "engine_comparison.json" +ENGINES = ("python", "dbt", "soda") + + +def _line_count(text: object) -> int: + snippet = str(text or "").strip("\n") + if not snippet: + return 0 + return len(snippet.splitlines()) + + +def _comparison_fingerprint_payload( + engine_payloads: Mapping[str, Mapping[str, object]], + generated_at_utc: str, +) -> Dict[str, object]: + engine_run_ids: Dict[str, str] = {} + dataset_hashes: Dict[str, str] = {} + rulepack_hashes: Dict[str, str] = {} + commits: Dict[str, str] = {} + + for engine, payload in engine_payloads.items(): + run_fp = payload.get("run_fingerprint", {}) + engine_run_ids[engine] = str(run_fp.get("run_id", "")) + commits[engine] = str(run_fp.get("code_commit", "unknown")) + dataset_fp = run_fp.get("dataset_fingerprint", {}) + rulepack_fp = run_fp.get("rulepack_fingerprint", {}) + dataset_hashes[engine] = str(dataset_fp.get("sha256", "")) + rulepack_hashes[engine] = str(rulepack_fp.get("rule_ir_sha256", "")) + + dataset_unique = sorted({value for value in dataset_hashes.values() if value}) + rulepack_unique = sorted({value for value in rulepack_hashes.values() if value}) + commit_unique = sorted({value for value in commits.values() if value and value != "unknown"}) + + safe_timestamp = generated_at_utc.replace(":", "").replace("-", "").replace(".", "").replace("+", "p") + comparison_run_id = f"comparison_{safe_timestamp}_{uuid4().hex[:8]}" + comparison_sha_input = { + "engine_run_ids": engine_run_ids, + "dataset_hashes": dataset_hashes, + "rulepack_hashes": rulepack_hashes, + "generated_at_utc": generated_at_utc, + } + comparison_sha = hashlib.sha256( + json.dumps(comparison_sha_input, sort_keys=True, default=str, separators=(",", ":")).encode("utf-8") + ).hexdigest() + + return { + "comparison_run_id": comparison_run_id, + "comparison_sha256": comparison_sha, + "engine_run_ids": engine_run_ids, + "dataset_fingerprint_sha256_by_engine": dataset_hashes, + "rulepack_fingerprint_sha256_by_engine": rulepack_hashes, + "dataset_fingerprint_consistent": len(dataset_unique) <= 1, + "rulepack_fingerprint_consistent": len(rulepack_unique) <= 1, + "dataset_fingerprint_sha256": dataset_unique[0] if dataset_unique else "", + "rulepack_fingerprint_sha256": rulepack_unique[0] if rulepack_unique else "", + "code_commit": commit_unique[0] if len(commit_unique) == 1 else "mixed_or_unknown", + "code_commits_by_engine": commits, + } + + +def _is_fallback_provider(provider: str) -> bool: + return "fallback" in provider.lower() + + +def _python_provider_is_real_llm(provider: str) -> bool: + normalized = provider.strip().lower() + return normalized in {"groq"} + + +def _provider_factor(engine: str, provider: str) -> float: + normalized = provider.strip().lower() + if engine == "python": + if normalized == "groq": + return 1.0 + if normalized == "simulated_fallback": + return 0.55 + return 0.75 + if engine == "dbt": + if normalized == "dbt_core": + return 1.0 + if normalized == "dbt_core_sql_fallback": + return 0.85 + return 0.9 + if engine == "soda": + if normalized == "soda_cloud": + return 1.0 + if normalized == "soda_core": + return 1.0 + if normalized == "soda_core_sql_fallback": + return 0.85 + return 0.9 + return 0.8 + + +def _effective_confidence(engine: str, row: Mapping[str, object]) -> float: + overall = float(row.get("overall_confidence", 0.0)) + provider = str(row.get("conversion_provider", "unknown")) + return overall * _provider_factor(engine, provider) + + +def _is_declarative_friendly(condition: str) -> bool: + text = condition.strip().lower() + if not text: + return False + if text.startswith("missing("): + return True + return any(op in text for op in (">", "<", ">=", "<=", "==", "!=")) + + +def _decision_score(engine: str, row: Mapping[str, object], declarative_friendly: bool) -> float: + score = _effective_confidence(engine, row) + status = str(row.get("status", "REVIEW")) + mismatches = int(row.get("mismatches", 0)) + equivalence_rate = float(row.get("equivalence_match_rate", 1.0)) + mutation_score = float(row.get("mutation_score", 1.0)) + + if status != "MATCH": + score -= 0.25 + score -= mismatches * 1.0 + if engine == "python": + score += 0.05 * equivalence_rate + score += 0.05 * mutation_score + if str(row.get("equivalence_status", "PASS")) != "PASS": + score -= 0.10 + + if declarative_friendly and engine in {"dbt", "soda"}: + score += 0.035 + if (not declarative_friendly) and engine == "python": + score += 0.035 + return score + + +def _status_rank(row: Mapping[str, object]) -> int: + return 1 if str(row.get("status", "REVIEW")) == "MATCH" else 0 + + +def _declarative_tie_break( + rule_name: str, + declarative_friendly: bool, + dbt_row: Mapping[str, object], + soda_row: Mapping[str, object], +) -> Tuple[str, str, bool]: + """Pick best declarative engine with an explicit, balanced tie-break.""" + dbt_score = _decision_score("dbt", dbt_row, declarative_friendly) + soda_score = _decision_score("soda", soda_row, declarative_friendly) + dbt_effective = _effective_confidence("dbt", dbt_row) + soda_effective = _effective_confidence("soda", soda_row) + dbt_overall = float(dbt_row.get("overall_confidence", 0.0)) + soda_overall = float(soda_row.get("overall_confidence", 0.0)) + dbt_mismatches = int(dbt_row.get("mismatches", 0)) + soda_mismatches = int(soda_row.get("mismatches", 0)) + dbt_status = _status_rank(dbt_row) + soda_status = _status_rank(soda_row) + + # Primary deterministic comparison. + dbt_tuple = (dbt_status, -dbt_mismatches, dbt_score, dbt_effective, dbt_overall) + soda_tuple = (soda_status, -soda_mismatches, soda_score, soda_effective, soda_overall) + if dbt_tuple != soda_tuple: + if dbt_tuple > soda_tuple: + return "dbt", "declarative-rank:dbt>soda", False + return "soda", "declarative-rank:soda>dbt", False + + # Explicit tie case: keep correctness identical, distribute ties fairly. + # Stable rule-name hash parity avoids always preferring dbt. + hash_int = int(hashlib.sha1(rule_name.encode("utf-8")).hexdigest(), 16) + chosen = "dbt" if hash_int % 2 == 0 else "soda" + reason = "explicit-hash-tie-break-even->dbt" if chosen == "dbt" else "explicit-hash-tie-break-odd->soda" + return chosen, reason, True + + +def _engine_summary(engine: str, payload: Mapping[str, object]) -> Dict[str, object]: + rule_results = list(payload.get("rule_results", [])) + if not rule_results: + empty = { + "rules": 0, + "passed": 0, + "avg_overall_confidence": 0.0, + "avg_effective_confidence": 0.0, + "avg_parity_ci_lower": 0.0, + "fallback_rules": 0, + "avg_equivalence_rate": 0.0, + "avg_mutation_score": 0.0, + } + if engine == "python": + empty["real_llm_rules"] = 0 + empty["real_llm_rate"] = 0.0 + empty["repairs_applied"] = 0 + return empty + + summary = { + "rules": len(rule_results), + "passed": sum(1 for row in rule_results if row.get("status") == "MATCH"), + "avg_overall_confidence": round(mean(float(row.get("overall_confidence", 0.0)) for row in rule_results), 4), + "avg_effective_confidence": round(mean(_effective_confidence(engine, row) for row in rule_results), 4), + "avg_parity_ci_lower": round(mean(float(row.get("parity_ci_lower", 0.0)) for row in rule_results), 4), + "avg_equivalence_rate": round(mean(float(row.get("equivalence_match_rate", 1.0)) for row in rule_results), 4), + "avg_mutation_score": round(mean(float(row.get("mutation_score", 1.0)) for row in rule_results), 4), + "fallback_rules": sum( + 1 for row in rule_results if _is_fallback_provider(str(row.get("conversion_provider", ""))) + ), + } + if engine == "python": + real_llm_rules = sum( + 1 for row in rule_results if _python_provider_is_real_llm(str(row.get("conversion_provider", ""))) + ) + summary["real_llm_rules"] = real_llm_rules + summary["real_llm_rate"] = round(real_llm_rules / len(rule_results), 4) + summary["repairs_applied"] = sum(1 for row in rule_results if bool(row.get("counterexample_repair_applied"))) + return summary + + +def _best_engine_for_rule(per_engine_rows: Mapping[str, Mapping[str, object]]) -> Tuple[str, str, bool]: + candidate_rows: List[Tuple[str, Mapping[str, object]]] = [(engine, row) for engine, row in per_engine_rows.items()] + reference_row = next(iter(per_engine_rows.values())) + if reference_row.get("declarative_friendly") is None: + declarative_friendly = _is_declarative_friendly(str(reference_row.get("condition", ""))) + else: + declarative_friendly = bool(reference_row.get("declarative_friendly")) + ranked = sorted( + candidate_rows, + key=lambda item: ( + _decision_score(item[0], item[1], declarative_friendly), + _effective_confidence(item[0], item[1]), + float(item[1].get("overall_confidence", 0.0)), + ), + reverse=True, + ) + + rows = {engine: row for engine, row in candidate_rows} + python_row = rows.get("python", {}) + python_match = str(python_row.get("status", "")) == "MATCH" + python_effective = _effective_confidence("python", python_row) if python_row else 0.0 + + dbt_row = rows.get("dbt", {}) + soda_row = rows.get("soda", {}) + declarative_best_engine = None + declarative_best_effective = 0.0 + declarative_reason = "declarative-unavailable" + declarative_tie_applied = False + if dbt_row and soda_row: + declarative_best_engine, declarative_reason, declarative_tie_applied = _declarative_tie_break( + rule_name=str(reference_row.get("rule_name", "")), + declarative_friendly=declarative_friendly, + dbt_row=dbt_row, + soda_row=soda_row, + ) + declarative_best_effective = _effective_confidence(declarative_best_engine, rows[declarative_best_engine]) + elif dbt_row: + declarative_best_engine = "dbt" + declarative_best_effective = _effective_confidence("dbt", dbt_row) + declarative_reason = "only-dbt-available" + elif soda_row: + declarative_best_engine = "soda" + declarative_best_effective = _effective_confidence("soda", soda_row) + declarative_reason = "only-soda-available" + + declarative_candidates = [ + (engine, row) + for engine, row in candidate_rows + if engine in {"dbt", "soda"} and str(row.get("status", "")) == "MATCH" + ] + if declarative_candidates and declarative_best_engine is None: + declarative_best_engine, declarative_best_row = max( + declarative_candidates, + key=lambda item: _effective_confidence(item[0], item[1]), + ) + declarative_best_effective = _effective_confidence(declarative_best_engine, declarative_best_row) + declarative_reason = "fallback-declarative-selection" + + closeness_threshold = 0.20 + if declarative_friendly and python_match and declarative_best_engine is not None: + if abs(python_effective - declarative_best_effective) <= closeness_threshold: + return ( + declarative_best_engine, + f"hybrid-close-declarative:{declarative_reason}", + declarative_tie_applied, + ) + if (not declarative_friendly) and python_match and declarative_best_engine is not None: + if abs(python_effective - declarative_best_effective) <= closeness_threshold: + return "python", "hybrid-close-procedural:prefer-python", False + + top_engine = ranked[0][0] + if top_engine in {"dbt", "soda"} and declarative_tie_applied and declarative_best_engine in {"dbt", "soda"}: + return declarative_best_engine, f"explicit-declarative-tie:{declarative_reason}", True + return top_engine, "top-decision-score", False + + +def _rule_recommendation(rule_row: Mapping[str, object], best_engine: str) -> str: + mismatches = int(rule_row.get("mismatches", 0)) + condition = str(rule_row.get("condition", "")) + condition_type = str(rule_row.get("condition_type", "")) + complexity = str(rule_row.get("complexity", "unknown")) + equivalence_status = str(rule_row.get("equivalence_status", "PASS")) + if rule_row.get("declarative_friendly") is None: + declarative_friendly = _is_declarative_friendly(condition) + else: + declarative_friendly = bool(rule_row.get("declarative_friendly")) + provider = str(rule_row.get("conversion_provider", "")) + if mismatches > 0: + return "Needs manual review; parity mismatches exist." + if _is_fallback_provider(provider): + return ( + f"{best_engine} currently wins, but provider is fallback. " + "Enable real engine execution to confirm this choice." + ) + if best_engine == "python" and equivalence_status != "PASS": + return "Python rule failed equivalence checks; inspect counterexamples before accepting." + if best_engine in {"dbt", "soda"} and declarative_friendly: + return "Declarative-friendly rule; prefer dbt/soda for readability and operations." + if best_engine == "python" and "fallback" in provider.lower(): + return "Use python path with caution; conversion fell back and needs prompt/model tuning." + if best_engine == "python" and complexity in {"medium", "intricate"}: + return ( + f"Procedural preference: rule is {complexity} ({condition_type}). " + "Python migration is preferred under current evidence." + ) + if best_engine == "python": + return "Keep procedural Python migration path for this rule." + return f"Prefer {best_engine} for this rule under current evidence." + + +def _build_complexity_summary(rule_comparison: Sequence[Mapping[str, object]]) -> Dict[str, Dict[str, object]]: + summary: Dict[str, Dict[str, object]] = {} + for tier in ("simple", "medium", "intricate", "unknown"): + tier_rows = [row for row in rule_comparison if str(row.get("complexity", "unknown")) == tier] + if not tier_rows: + continue + wins = {"python": 0, "dbt": 0, "soda": 0} + for row in tier_rows: + wins[str(row.get("best_engine", "python"))] += 1 + summary[tier] = { + "rules": len(tier_rows), + "python_wins": wins["python"], + "dbt_wins": wins["dbt"], + "soda_wins": wins["soda"], + "avg_best_effective_confidence": round( + mean( + float(row.get("engines", {}).get(str(row.get("best_engine")), {}).get("effective_confidence", 0.0)) + for row in tier_rows + ), + 4, + ), + } + return summary + + +def _build_rule_comparison(engine_payloads: Mapping[str, Mapping[str, object]]) -> List[Dict[str, object]]: + rows_by_engine_and_rule: Dict[str, Dict[str, Mapping[str, object]]] = {} + for engine, payload in engine_payloads.items(): + row_map: Dict[str, Mapping[str, object]] = {} + for row in payload.get("rule_results", []): + row_map[str(row["rule_name"])] = row + rows_by_engine_and_rule[engine] = row_map + + rule_names = sorted(set().union(*(set(m.keys()) for m in rows_by_engine_and_rule.values()))) + results: List[Dict[str, object]] = [] + + for rule_name in rule_names: + per_engine: Dict[str, Mapping[str, object]] = { + engine: rows_by_engine_and_rule[engine][rule_name] + for engine in ENGINES + if rule_name in rows_by_engine_and_rule[engine] + } + if not per_engine: + continue + best_engine, selection_reason, tie_break_applied = _best_engine_for_rule(per_engine) + reference = next(iter(per_engine.values())) + + rule_out: Dict[str, object] = { + "rule_name": rule_name, + "tag": reference.get("tag"), + "severity": reference.get("severity"), + "condition": reference.get("condition"), + "jurisdiction": reference.get("jurisdiction", "global"), + "profile_tags": list(reference.get("profile_tags", [])), + "regulatory_type": reference.get("regulatory_type", ""), + "legal_citation": reference.get("legal_citation", ""), + "source_url": reference.get("source_url", ""), + "effective_date": reference.get("effective_date", ""), + "review_status": reference.get("review_status", ""), + "reviewer": reference.get("reviewer", ""), + "required_fields": list(reference.get("required_fields", [])), + "exemption_logic": reference.get("exemption_logic", ""), + "rule_notes": reference.get("rule_notes", ""), + "rule_ir_hash": reference.get("rule_ir_hash"), + "condition_type": reference.get("condition_type", "unknown"), + "complexity": reference.get("complexity", "unknown"), + "declarative_friendly": ( + _is_declarative_friendly(str(reference.get("condition", ""))) + if reference.get("declarative_friendly") is None + else bool(reference.get("declarative_friendly")) + ), + "products_tested": reference.get("products_tested"), + "best_engine": best_engine, + "selection_reason": selection_reason, + "declarative_tie_break_applied": tie_break_applied, + "recommendation": _rule_recommendation(per_engine[best_engine], best_engine), + "engines": {}, + } + for engine, row in per_engine.items(): + conversion_text = row.get("python_conversion", "") + provider = str(row.get("conversion_provider", "unknown")) + provider_factor = _provider_factor(engine, provider) + effective = _effective_confidence(engine, row) + rule_out["engines"][engine] = { + "status": row.get("status"), + "mismatches": row.get("mismatches"), + "parity_ci_lower": row.get("parity_ci_lower"), + "overall_confidence": row.get("overall_confidence"), + "equivalence_match_rate": row.get("equivalence_match_rate", 1.0), + "equivalence_status": row.get("equivalence_status", "PASS"), + "equivalence_cases": row.get("equivalence_cases", 0), + "mutation_score": row.get("mutation_score", 1.0), + "mutation_total": row.get("mutation_total", 0), + "mutation_killed": row.get("mutation_killed", 0), + "verification_score": row.get("verification_score", 1.0), + "counterexample_repair_applied": row.get("counterexample_repair_applied", False), + "equivalence_counterexamples": row.get("equivalence_counterexamples", []), + "effective_confidence": round(effective, 4), + "provider_factor": round(provider_factor, 4), + "real_llm_used": _python_provider_is_real_llm(provider) if engine == "python" else None, + "decision_score": round(_decision_score(engine, row, rule_out["declarative_friendly"]), 4), + "conversion_provider": provider, + "conversion_notes": row.get("conversion_notes", ""), + "execution_mode": row.get("conversion_execution_mode", ""), + "cloud_connected": bool(row.get("conversion_cloud_connected", False)), + "cloud_scan_id": row.get("conversion_cloud_scan_id", ""), + "cloud_scan_url": row.get("conversion_cloud_scan_url", ""), + "conversion_artifact": conversion_text, + "conversion_lines": _line_count(conversion_text), + "failed_test_cases": row.get("failed_test_cases", []), + } + results.append(rule_out) + return results + + +def _run_for_engines( + dataset_size: int, + seed: int, + source_jsonl: Path | None, + use_default_off_source: bool, + llm_provider: str, + llm_model: str | None, + perl_rules_dir: Path | None, + db_path: Path, + profile: str, + soda_mode: str, +) -> Dict[str, Dict[str, object]]: + engine_payloads: Dict[str, Dict[str, object]] = {} + temp_results_dir = RESULT_PATH.parent / "tmp_engine_runs" + temp_results_dir.mkdir(parents=True, exist_ok=True) + + for engine in ENGINES: + engine_results_path = temp_results_dir / f"migration_results_{engine}.json" + payload = run_pipeline( + dataset_size=dataset_size, + seed=seed, + results_path=engine_results_path, + source_jsonl=source_jsonl, + use_default_off_source=use_default_off_source, + db_path=db_path, + llm_provider=llm_provider, + llm_model=llm_model, + perl_rules_dir=perl_rules_dir, + execution_engine=engine, + soda_mode=soda_mode, + profile=profile, + ) + engine_payloads[engine] = payload + return engine_payloads + + +def run_engine_comparison( + dataset_size: int = 300, + seed: int = 17, + source_jsonl: Path | None = None, + use_default_off_source: bool = True, + llm_provider: str = "groq", + llm_model: str | None = None, + perl_rules_dir: Path | None = None, + db_path: Path = DB_PATH, + results_path: Path = COMPARISON_PATH, + require_real_llm: bool = False, + profile: str = DEFAULT_PROFILE, + soda_mode: str = "local", +) -> Dict[str, object]: + """Run all engines and emit a rule-by-rule comparison report.""" + engine_payloads = _run_for_engines( + dataset_size=dataset_size, + seed=seed, + source_jsonl=source_jsonl, + use_default_off_source=use_default_off_source, + llm_provider=llm_provider, + llm_model=llm_model, + perl_rules_dir=perl_rules_dir, + db_path=db_path, + profile=profile, + soda_mode=soda_mode, + ) + if require_real_llm: + python_rows = list(engine_payloads.get("python", {}).get("rule_results", [])) + non_llm_rules = [ + str(row.get("rule_name")) + for row in python_rows + if not _python_provider_is_real_llm(str(row.get("conversion_provider", ""))) + ] + if non_llm_rules: + raise RuntimeError( + "Real LLM mode is enabled, but python engine used fallback/non-LLM providers " + f"for rules: {', '.join(non_llm_rules)}. " + "Set GROQ_API_KEY and verify model access." + ) + + dataset_meta = engine_payloads["python"].get("dataset", {}) + per_engine_summary = {engine: _engine_summary(engine, payload) for engine, payload in engine_payloads.items()} + rule_comparison = _build_rule_comparison(engine_payloads) + complexity_summary = _build_complexity_summary(rule_comparison) + generated_at_utc = datetime.now(timezone.utc).isoformat() + comparison_fingerprint = _comparison_fingerprint_payload( + engine_payloads=engine_payloads, + generated_at_utc=generated_at_utc, + ) + + report = { + "generated_at_utc": generated_at_utc, + "comparison_fingerprint": comparison_fingerprint, + "comparison_method": { + "best_engine_ranking": ( + "Prefer MATCH status, then fewer mismatches, then higher effective_confidence. " + "effective_confidence = overall_confidence * provider_factor." + ), + "decision_score": ( + "decision_score = effective_confidence " + "+ architecture_bonus(declarative for simple rules / python for complex rules) " + "- mismatch_penalty - review_penalty." + ), + "hybrid_tie_break": ( + "If python and best declarative engine are close (within 0.20 effective confidence): " + "prefer declarative for declarative-friendly rules, prefer python for non-declarative rules." + ), + "declarative_tie_break": ( + "When dbt and soda are exactly tied on status/mismatches/scores for a rule, " + "use a stable hash of rule_name to select dbt or soda explicitly." + ), + "provider_factor_notes": { + "python_real_llm": 1.0, + "python_simulated_fallback": 0.55, + "dbt_sql_fallback": 0.85, + "soda_cloud": 1.0, + "soda_sql_fallback": 0.85, + }, + }, + "dataset": dataset_meta, + "engines": list(ENGINES), + "engine_run_fingerprints": { + engine: payload.get("run_fingerprint", {}) + for engine, payload in engine_payloads.items() + }, + "per_engine_summary": per_engine_summary, + "per_complexity_summary": complexity_summary, + "rule_comparison": rule_comparison, + "run_config": { + "llm_provider": llm_provider, + "llm_model": llm_model, + "require_real_llm": require_real_llm, + "groq_api_key_set": bool(os.getenv("GROQ_API_KEY")), + "profile": profile, + "dataset_size": dataset_size, + "seed": seed, + "mode": "off" if use_default_off_source else "synthetic", + "source_jsonl": str(source_jsonl) if source_jsonl else "", + "soda_mode": soda_mode, + "soda_cloud_credentials_set": bool( + os.getenv("SODA_CLOUD_API_KEY_ID") + and os.getenv("SODA_CLOUD_API_KEY_SECRET") + and os.getenv("SODA_CLOUD_HOST") + ), + }, + } + + results_path.parent.mkdir(parents=True, exist_ok=True) + with results_path.open("w", encoding="utf-8") as handle: + json.dump(report, handle, indent=2) + return report + + +def parse_args() -> argparse.Namespace: + parser = argparse.ArgumentParser(description="Compare python/dbt/soda engines for rule migration parity.") + parser.add_argument("--size", type=int, default=300, help="Number of products to test.") + parser.add_argument("--seed", type=int, default=17, help="Seed for synthetic mode.") + parser.add_argument( + "--mode", + choices=["off", "synthetic"], + default="off" if DEFAULT_OFF_JSONL.exists() else "synthetic", + help="Dataset source mode: off (JSONL) or synthetic.", + ) + parser.add_argument( + "--source-jsonl", + type=Path, + default=DEFAULT_OFF_JSONL if DEFAULT_OFF_JSONL.exists() else None, + help="OFF JSONL path (used when --mode off).", + ) + parser.add_argument( + "--llm-provider", + choices=["simulated", "groq"], + default="groq", + help="LLM provider for python execution engine.", + ) + parser.add_argument("--llm-model", default=None, help="Optional model override for selected LLM provider.") + parser.add_argument("--perl-rules-dir", type=Path, default=None, help="Optional directory of .pl snippets.") + parser.add_argument( + "--profile", + choices=list(SUPPORTED_PROFILES), + default=DEFAULT_PROFILE, + help="Rule-pack profile to compare: global, canada, or hybrid.", + ) + parser.add_argument("--results-path", type=Path, default=COMPARISON_PATH, help="Output comparison JSON path.") + parser.add_argument( + "--require-real-llm", + action="store_true", + help="Fail if python engine did not use real LLM providers (no simulated fallback allowed).", + ) + parser.add_argument( + "--soda-mode", + choices=["local", "cloud"], + default="local", + help="Soda execution mode for soda engine runs.", + ) + return parser.parse_args() + + +def main() -> None: + args = parse_args() + use_off_mode = args.mode == "off" + source_jsonl = args.source_jsonl if use_off_mode else None + + report = run_engine_comparison( + dataset_size=args.size, + seed=args.seed, + source_jsonl=source_jsonl, + use_default_off_source=use_off_mode, + llm_provider=args.llm_provider, + llm_model=args.llm_model, + perl_rules_dir=args.perl_rules_dir, + results_path=args.results_path, + require_real_llm=args.require_real_llm, + profile=args.profile, + soda_mode=args.soda_mode, + ) + print(f"Engines compared: {', '.join(report['engines'])}") + for engine, summary in report["per_engine_summary"].items(): + print( + f"{engine}: passed {summary['passed']}/{summary['rules']}, " + f"avg_overall={summary['avg_overall_confidence']:.2%}, " + f"avg_effective={summary['avg_effective_confidence']:.2%}, " + f"fallback_rules={summary['fallback_rules']}" + ) + if report.get("run_config"): + print( + "LLM key status: " + f"GROQ_API_KEY={report['run_config']['groq_api_key_set']}" + ) + if report.get("dataset"): + print(f"Profile: {report['dataset'].get('profile', DEFAULT_PROFILE)}") + print(f"Soda mode: {args.soda_mode}") + if report.get("comparison_fingerprint"): + fingerprint = report["comparison_fingerprint"] + print(f"Comparison run ID: {fingerprint.get('comparison_run_id', 'n/a')}") + print( + "Fingerprints: " + f"dataset={str(fingerprint.get('dataset_fingerprint_sha256', ''))[:16]} | " + f"rulepack={str(fingerprint.get('rulepack_fingerprint_sha256', ''))[:16]}" + ) + print(f"Comparison written to: {args.results_path}") + + +if __name__ == "__main__": + main() diff --git a/OFF_DataQuality/validation/parity_validator.py b/OFF_DataQuality/validation/parity_validator.py new file mode 100644 index 0000000000000000000000000000000000000000..79533e7d627ec3418664aa9f38d8687234b48227 --- /dev/null +++ b/OFF_DataQuality/validation/parity_validator.py @@ -0,0 +1,706 @@ +"""Back-to-back validation engine for Perl-to-Python rule migration.""" +from __future__ import annotations + +import argparse +import hashlib +import json +import math +import subprocess +from datetime import datetime, timezone +from pathlib import Path +from statistics import mean +from typing import Dict, List, Mapping, Sequence, Set +from uuid import uuid4 + +from declarative.check_runners import run_declarative_checks +from data.load_dataset import ( + DB_PATH, + DEFAULT_OFF_JSONL, + SAMPLE_FILE, + create_and_load_dataset, +) +from duckdb_utils.create_tables import count_violations, sample_violations +from extractor.perl_logic_extractor import extract_rules +from migration.llm_converter import convert_rules, repair_conversion_with_counterexamples +from perl_checks.legacy_checks import LEGACY_RULES, get_legacy_rule_map, get_perl_rule_snippets, run_perl_checks +from python_checks.generated_checks import compile_generated_checks +from rulepacks.registry import DEFAULT_PROFILE, SUPPORTED_PROFILES, attach_profile_metadata, get_profile_rule_names, validate_profile +from validation.verification import run_rule_verification + +RESULT_PATH = Path(__file__).resolve().parent.parent / "results" / "migration_results.json" +TABLE_NAME = "nutrition_table" + + +def _sha256_text(text: str) -> str: + return hashlib.sha256(text.encode("utf-8")).hexdigest() + + +def _sha256_json(payload: object) -> str: + normalized = json.dumps(payload, sort_keys=True, default=str, separators=(",", ":")) + return _sha256_text(normalized) + + +def _resolve_git_commit() -> str: + try: + completed = subprocess.run( + ["git", "rev-parse", "HEAD"], + capture_output=True, + text=True, + encoding="utf-8", + errors="replace", + check=False, + timeout=5, + ) + if completed.returncode == 0: + value = (completed.stdout or "").strip() + if value: + return value + except Exception: + pass + return "unknown" + + +def _dataset_fingerprint_payload( + products: Sequence[Mapping[str, object]], + source_path: Path | None, + dataset_size: int, + seed: int, +) -> Dict[str, object]: + normalized_products = [ + {key: product.get(key) for key in sorted(product.keys())} + for product in sorted(products, key=lambda row: str(row.get("product_id", ""))) + ] + product_ids = [str(product.get("product_id", "")) for product in normalized_products if product.get("product_id")] + source_mode = "off_jsonl" if source_path else "synthetic" + payload = { + "source_mode": source_mode, + "source_jsonl": str(source_path) if source_path else "synthetic", + "requested_size": int(dataset_size), + "products_tested": len(normalized_products), + "seed": int(seed) if source_mode == "synthetic" else None, + "product_id_first": product_ids[0] if product_ids else None, + "product_id_last": product_ids[-1] if product_ids else None, + "sha256": _sha256_json(normalized_products), + } + return payload + + +def _rulepack_fingerprint_payload(structured_rules: Sequence[Mapping[str, object]], profile_name: str) -> Dict[str, object]: + rule_names = sorted(str(rule.get("rule_name", "")) for rule in structured_rules) + ir_hashes = sorted(str(rule.get("rule_ir_hash", "")) for rule in structured_rules) + payload = { + "profile": profile_name, + "rule_count": len(structured_rules), + "rule_names_sha256": _sha256_json(rule_names), + "rule_ir_sha256": _sha256_json(ir_hashes), + } + return payload + + +def _wilson_interval(successes: int, trials: int, z: float = 1.96) -> tuple[float, float]: + """Return two-sided Wilson score interval for a binomial proportion.""" + if trials <= 0: + return 0.0, 1.0 + p = successes / trials + z2 = z * z + denom = 1.0 + (z2 / trials) + center = (p + (z2 / (2.0 * trials))) / denom + margin = (z * (((p * (1.0 - p)) + (z2 / (4.0 * trials))) / trials) ** 0.5) / denom + lower = max(0.0, center - margin) + upper = min(1.0, center + margin) + return lower, upper + + +def _beta_continued_fraction(a: float, b: float, x: float, max_iter: int = 400, eps: float = 3e-12) -> float: + """Continued fraction helper for incomplete beta evaluation.""" + qab = a + b + qap = a + 1.0 + qam = a - 1.0 + c = 1.0 + d = 1.0 - (qab * x / qap) + if abs(d) < 1e-30: + d = 1e-30 + d = 1.0 / d + h = d + + for m in range(1, max_iter + 1): + m2 = 2 * m + aa = (m * (b - m) * x) / ((qam + m2) * (a + m2)) + d = 1.0 + aa * d + if abs(d) < 1e-30: + d = 1e-30 + c = 1.0 + aa / c + if abs(c) < 1e-30: + c = 1e-30 + d = 1.0 / d + h *= d * c + + aa = (-(a + m) * (qab + m) * x) / ((a + m2) * (qap + m2)) + d = 1.0 + aa * d + if abs(d) < 1e-30: + d = 1e-30 + c = 1.0 + aa / c + if abs(c) < 1e-30: + c = 1e-30 + d = 1.0 / d + delta = d * c + h *= delta + if abs(delta - 1.0) < eps: + break + + return h + + +def _regularized_incomplete_beta(a: float, b: float, x: float) -> float: + """Regularized incomplete beta I_x(a,b) in [0,1].""" + if x <= 0.0: + return 0.0 + if x >= 1.0: + return 1.0 + + bt = math.exp( + math.lgamma(a + b) + - math.lgamma(a) + - math.lgamma(b) + + a * math.log(x) + + b * math.log(1.0 - x) + ) + + if x < (a + 1.0) / (a + b + 2.0): + return bt * _beta_continued_fraction(a, b, x) / a + return 1.0 - (bt * _beta_continued_fraction(b, a, 1.0 - x) / b) + + +def _beta_ppf(probability: float, alpha: float, beta: float, tol: float = 1e-7, max_iter: int = 200) -> float: + """Inverse CDF for Beta(alpha, beta) using monotonic bisection.""" + p = min(1.0, max(0.0, probability)) + lo = 0.0 + hi = 1.0 + for _ in range(max_iter): + mid = (lo + hi) / 2.0 + cdf_mid = _regularized_incomplete_beta(alpha, beta, mid) + if abs(cdf_mid - p) < tol: + return mid + if cdf_mid < p: + lo = mid + else: + hi = mid + return (lo + hi) / 2.0 + + +def _run_python_checks( + products: Sequence[Mapping[str, object]], + structured_rules: Sequence[Dict[str, object]], + python_checks: Dict[str, object], +) -> Dict[str, Dict[str, object]]: + rule_names = [str(rule["rule_name"]) for rule in structured_rules] + per_rule_products: Dict[str, Set[str]] = {rule_name: set() for rule_name in rule_names} + per_product_tags: Dict[str, List[str]] = {} + + for product in products: + product_id = str(product.get("product_id")) + tags: List[str] = [] + for rule in structured_rules: + rule_name = str(rule["rule_name"]) + check_fn = python_checks[rule_name] + tag = check_fn(product) + if tag: + tags.append(str(tag)) + per_rule_products[rule_name].add(product_id) + per_product_tags[product_id] = tags + + return { + "per_product": per_product_tags, + "per_rule": {name: sorted(ids) for name, ids in per_rule_products.items()}, + } + + +def _run_python_verification( + structured_rules: Sequence[Dict[str, object]], + python_checks: Mapping[str, object], + conversion_metadata: Mapping[str, Mapping[str, object]], + seed: int, + legacy_rules: Sequence[object], +) -> Dict[str, Dict[str, object]]: + legacy_map = get_legacy_rule_map(legacy_rules) + verification_by_rule: Dict[str, Dict[str, object]] = {} + for rule in structured_rules: + rule_name = str(rule["rule_name"]) + legacy_rule = legacy_map.get(rule_name) + if legacy_rule is None: + verification_by_rule[rule_name] = { + "equivalence_cases": 0, + "equivalence_matches": 0, + "equivalence_mismatches": 0, + "equivalence_match_rate": 1.0, + "equivalence_status": "PASS", + "counterexamples": [], + "mutation_total": 0, + "mutation_killed": 0, + "mutation_survived": 0, + "mutation_score": 1.0, + "mutation_survived_mutants": [], + "verification_score": 1.0, + } + continue + verification_by_rule[rule_name] = run_rule_verification( + rule=rule, + perl_evaluator=legacy_rule.evaluator, + check_fn=python_checks[rule_name], + python_code=str(conversion_metadata[rule_name]["python_code"]), + function_name=str(conversion_metadata[rule_name]["function_name"]), + seed=seed, + ) + return verification_by_rule + + +def _build_failed_case_rows( + mismatch_ids: Sequence[str], + product_map: Dict[str, Mapping[str, object]], + perl_ids: Set[str], + python_ids: Set[str], + limit: int = 10, +) -> List[Dict[str, object]]: + rows: List[Dict[str, object]] = [] + for product_id in mismatch_ids[:limit]: + product = dict(product_map[product_id]) + rows.append( + { + "product_id": product_id, + "perl_triggered": product_id in perl_ids, + "python_triggered": product_id in python_ids, + "energy_kj": product.get("energy_kj"), + "energy_kj_computed": product.get("energy_kj_computed"), + "energy_kcal": product.get("energy_kcal"), + "fat": product.get("fat"), + "saturated_fat": product.get("saturated_fat"), + "carbohydrates": product.get("carbohydrates"), + "sugars": product.get("sugars"), + "starch": product.get("starch"), + "sodium": product.get("sodium"), + "ingredients_text_present": product.get("ingredients_text_present"), + "contains_statement_present": product.get("contains_statement_present"), + "allergen_evidence_present": product.get("allergen_evidence_present"), + "fop_threshold_exceeded": product.get("fop_threshold_exceeded"), + "fop_symbol_present": product.get("fop_symbol_present"), + "fop_exempt_proxy": product.get("fop_exempt_proxy"), + "product_is_prepackaged_proxy": product.get("product_is_prepackaged_proxy"), + "lc": product.get("lc"), + "lang": product.get("lang"), + "language_code": product.get("language_code"), + } + ) + return rows + + +def _compute_rule_result( + rule: Dict[str, object], + perl_rule_products: Sequence[str], + python_rule_products: Sequence[str], + product_map: Dict[str, Mapping[str, object]], + conversion_meta: Dict[str, object], + verification_meta: Mapping[str, object] | None = None, + db_path: Path = DB_PATH, +) -> Dict[str, object]: + product_ids = set(product_map) + perl_ids = set(perl_rule_products) + python_ids = set(python_rule_products) + supporting_ids = perl_ids | python_ids + + matching_products = { + product_id + for product_id in product_ids + if (product_id in perl_ids) == (product_id in python_ids) + } + mismatch_ids = sorted(product_ids - matching_products) + total_tests = len(product_ids) + supporting_violations = len(supporting_ids) + positive_matches = len(perl_ids & python_ids) + positive_coverage = (supporting_violations / total_tests) if total_tests else 0.0 + + parity_confidence = (len(matching_products) / total_tests) if total_tests else 1.0 + parity_ci_lower, parity_ci_upper = _wilson_interval(len(matching_products), total_tests) + coverage_ci_lower, coverage_ci_upper = _wilson_interval(supporting_violations, total_tests) + positive_agreement = (positive_matches / supporting_violations) if supporting_violations else 0.5 + evidence_alpha = positive_matches + 1.0 + evidence_beta = (supporting_violations - positive_matches) + 1.0 + # Posterior mean for reference. + evidence_posterior_mean = evidence_alpha / (evidence_alpha + evidence_beta) + # Conservative 95% lower credible bound. + evidence_ci_lower = _beta_ppf(0.05, evidence_alpha, evidence_beta) + evidence_ci_upper = _beta_ppf(0.95, evidence_alpha, evidence_beta) + llm_confidence = float(conversion_meta["llm_confidence"]) + overall_confidence = llm_confidence * parity_ci_lower * evidence_ci_lower + status = "MATCH" if not mismatch_ids else "REVIEW" + + duckdb_condition = str(rule["duckdb_condition"]) + duckdb_error_count = count_violations(duckdb_condition, db_path=db_path) + duckdb_examples = sample_violations(duckdb_condition, limit=5, db_path=db_path) + verification = dict(verification_meta or {}) + + return { + "rule_name": rule["rule_name"], + "tag": rule["tag"], + "severity": rule["severity"], + "condition": rule["condition"], + "jurisdiction": rule.get("jurisdiction", "global"), + "profile_tags": list(rule.get("profile_tags", [])), + "regulatory_type": rule.get("regulatory_type", ""), + "legal_citation": rule.get("legal_citation", ""), + "source_url": rule.get("source_url", ""), + "effective_date": rule.get("effective_date", ""), + "review_status": rule.get("review_status", ""), + "reviewer": rule.get("reviewer", ""), + "required_fields": list(rule.get("required_fields", [])), + "exemption_logic": rule.get("exemption_logic", ""), + "rule_notes": rule.get("rule_notes", ""), + "rule_ir": rule.get("rule_ir"), + "rule_ir_hash": rule.get("rule_ir_hash"), + "condition_type": rule.get("condition_type", "unknown"), + "complexity": rule.get("complexity", "unknown"), + "declarative_friendly": rule.get("declarative_friendly"), + "products_tested": total_tests, + "perl_errors": len(perl_ids), + "python_errors": len(python_ids), + "supporting_violations": supporting_violations, + "positive_matches": positive_matches, + "positive_agreement": round(positive_agreement, 4), + "positive_coverage": round(positive_coverage, 4), + "parity_ci_lower": round(parity_ci_lower, 4), + "parity_ci_upper": round(parity_ci_upper, 4), + "coverage_ci_lower": round(coverage_ci_lower, 4), + "coverage_ci_upper": round(coverage_ci_upper, 4), + "evidence_alpha": round(evidence_alpha, 4), + "evidence_beta": round(evidence_beta, 4), + "evidence_posterior_mean": round(evidence_posterior_mean, 4), + "evidence_ci_lower": round(evidence_ci_lower, 4), + "evidence_ci_upper": round(evidence_ci_upper, 4), + # Back-compat alias for old dashboards/scripts. + "evidence_factor": round(evidence_ci_lower, 4), + "matches": len(matching_products), + "mismatches": len(mismatch_ids), + "confidence": round(parity_confidence, 4), + "llm_confidence": round(llm_confidence, 4), + "overall_confidence": round(overall_confidence, 4), + "overall_method": "llm_confidence * parity_ci_lower_95 * evidence_ci_lower_95_beta_posterior", + "status": status, + "duckdb_query": f"SELECT * FROM {TABLE_NAME} WHERE {duckdb_condition}", + "duckdb_errors": duckdb_error_count, + "duckdb_condition": duckdb_condition, + "duckdb_example_rows": duckdb_examples, + "equivalence_cases": int(verification.get("equivalence_cases", 0)), + "equivalence_matches": int(verification.get("equivalence_matches", 0)), + "equivalence_mismatches": int(verification.get("equivalence_mismatches", 0)), + "equivalence_match_rate": round(float(verification.get("equivalence_match_rate", 1.0)), 4), + "equivalence_status": verification.get("equivalence_status", "PASS"), + "equivalence_counterexamples": list(verification.get("counterexamples", [])), + "mutation_total": int(verification.get("mutation_total", 0)), + "mutation_killed": int(verification.get("mutation_killed", 0)), + "mutation_survived": int(verification.get("mutation_survived", 0)), + "mutation_score": round(float(verification.get("mutation_score", 1.0)), 4), + "mutation_survived_mutants": list(verification.get("mutation_survived_mutants", [])), + "verification_score": round(float(verification.get("verification_score", 1.0)), 4), + "counterexample_repair_attempted": bool(verification.get("counterexample_repair_attempted", False)), + "counterexample_repair_applied": bool(verification.get("counterexample_repair_applied", False)), + "counterexample_repair_error": str(verification.get("counterexample_repair_error", "")), + "mismatch_product_ids": mismatch_ids, + "failed_test_cases": _build_failed_case_rows( + mismatch_ids=mismatch_ids, + product_map=product_map, + perl_ids=perl_ids, + python_ids=python_ids, + limit=10, + ), + "perl_logic": rule["perl_logic"], + "python_conversion": conversion_meta["python_code"], + "conversion_notes": conversion_meta["conversion_notes"], + "conversion_provider": conversion_meta.get("provider", "unknown"), + "conversion_execution_mode": conversion_meta.get("execution_mode", ""), + "conversion_cloud_connected": bool(conversion_meta.get("cloud_connected", False)), + "conversion_cloud_scan_id": conversion_meta.get("cloud_scan_id", ""), + "conversion_cloud_scan_url": conversion_meta.get("cloud_scan_url", ""), + } + + +def run_pipeline( + dataset_size: int = 300, + seed: int = 17, + results_path: Path = RESULT_PATH, + source_jsonl: Path | None = None, + use_default_off_source: bool = True, + db_path: Path = DB_PATH, + llm_provider: str = "groq", + llm_model: str | None = None, + perl_rules_dir: Path | None = None, + execution_engine: str = "python", + soda_mode: str = "local", + profile: str = DEFAULT_PROFILE, +) -> Dict[str, object]: + """Run the full migration prototype pipeline and persist JSON results.""" + if execution_engine not in {"python", "dbt", "soda"}: + raise ValueError("execution_engine must be one of: python, dbt, soda") + + profile_name = validate_profile(profile) + selected_rule_names = set(get_profile_rule_names(profile_name, [rule.rule_name for rule in LEGACY_RULES])) + selected_legacy_rules = [rule for rule in LEGACY_RULES if rule.rule_name in selected_rule_names] + if not selected_legacy_rules: + raise ValueError(f"No legacy rules selected for profile `{profile_name}`.") + + source_path = source_jsonl + if source_path is None and use_default_off_source and DEFAULT_OFF_JSONL.exists(): + source_path = DEFAULT_OFF_JSONL + + products = create_and_load_dataset(size=dataset_size, seed=seed, db_path=db_path, source_jsonl=source_path) + product_map = {str(product["product_id"]): product for product in products} + + perl_output = run_perl_checks(products, selected_legacy_rules) + if perl_rules_dir is None: + structured_rules_raw = extract_rules(get_perl_rule_snippets(selected_legacy_rules, rules_dir=None)) + else: + all_structured = extract_rules(get_perl_rule_snippets(LEGACY_RULES, rules_dir=perl_rules_dir)) + structured_rules_raw = [rule for rule in all_structured if str(rule["rule_name"]) in selected_rule_names] + structured_rules = attach_profile_metadata(structured_rules_raw, profile=profile_name) + if not structured_rules: + raise ValueError(f"No structured rules extracted for profile `{profile_name}`.") + + engine_run: Dict[str, object] | None = None + verification_by_rule: Dict[str, Dict[str, object]] = {} + + if execution_engine == "python": + converted_rules = convert_rules(structured_rules, provider=llm_provider, model=llm_model) + converted_by_name = {str(item["rule_name"]): dict(item) for item in converted_rules} + repair_flags: Dict[str, Dict[str, object]] = { + str(rule["rule_name"]): { + "counterexample_repair_attempted": False, + "counterexample_repair_applied": False, + "counterexample_repair_error": "", + } + for rule in structured_rules + } + + python_checks, conversion_metadata = compile_generated_checks( + [converted_by_name[str(rule["rule_name"])] for rule in structured_rules] + ) + initial_verification = _run_python_verification( + structured_rules=structured_rules, + python_checks=python_checks, + conversion_metadata=conversion_metadata, + seed=seed, + legacy_rules=selected_legacy_rules, + ) + + if llm_provider == "groq": + for rule in structured_rules: + rule_name = str(rule["rule_name"]) + verification = initial_verification.get(rule_name, {}) + provider = str(conversion_metadata[rule_name].get("provider", "")) + if provider != "groq": + continue + if int(verification.get("equivalence_mismatches", 0)) <= 0: + continue + + repair_flags[rule_name]["counterexample_repair_attempted"] = True + try: + repaired = repair_conversion_with_counterexamples( + rule=rule, + converted_rule=converted_by_name[rule_name], + counterexamples=list(verification.get("counterexamples", [])), + provider=llm_provider, + model=llm_model, + ) + if str(repaired.get("python_code", "")) != str(converted_by_name[rule_name].get("python_code", "")): + converted_by_name[rule_name] = repaired + repair_flags[rule_name]["counterexample_repair_applied"] = True + except Exception as exc: # noqa: BLE001 + repair_flags[rule_name]["counterexample_repair_error"] = f"{exc.__class__.__name__}: {exc}" + + python_checks, conversion_metadata = compile_generated_checks( + [converted_by_name[str(rule["rule_name"])] for rule in structured_rules] + ) + verification_by_rule = _run_python_verification( + structured_rules=structured_rules, + python_checks=python_checks, + conversion_metadata=conversion_metadata, + seed=seed, + legacy_rules=selected_legacy_rules, + ) + for rule in structured_rules: + rule_name = str(rule["rule_name"]) + verification_by_rule.setdefault(rule_name, {}).update(repair_flags.get(rule_name, {})) + + candidate_output = _run_python_checks(products, structured_rules, python_checks) + else: + declarative_result = run_declarative_checks( + rules=structured_rules, + products=products, + db_path=db_path, + engine=execution_engine, + soda_mode=soda_mode, + ) + candidate_output = { + "per_product": declarative_result["per_product"], + "per_rule": declarative_result["per_rule"], + } + conversion_metadata = declarative_result["conversion_metadata"] + engine_run = declarative_result["engine_run"] + + rule_results: List[Dict[str, object]] = [] + for rule in structured_rules: + rule_name = str(rule["rule_name"]) + rule_result = _compute_rule_result( + rule=rule, + perl_rule_products=perl_output["per_rule"][rule_name], + python_rule_products=candidate_output["per_rule"][rule_name], + product_map=product_map, + conversion_meta=conversion_metadata[rule_name], + verification_meta=verification_by_rule.get(rule_name), + db_path=db_path, + ) + rule_results.append(rule_result) + + passed_rules = sum(1 for row in rule_results if row["status"] == "MATCH") + total_rules = len(rule_results) + avg_confidence = mean([row["overall_confidence"] for row in rule_results]) if rule_results else 0.0 + generated_at_utc = datetime.now(timezone.utc).isoformat() + dataset_fingerprint = _dataset_fingerprint_payload( + products=products, + source_path=source_path, + dataset_size=dataset_size, + seed=seed, + ) + rulepack_fingerprint = _rulepack_fingerprint_payload(structured_rules=structured_rules, profile_name=profile_name) + safe_timestamp = ( + generated_at_utc.replace(":", "").replace("-", "").replace(".", "").replace("+", "p") + ) + run_id = f"parity_{safe_timestamp}_{uuid4().hex[:8]}" + git_commit = _resolve_git_commit() + + result_payload: Dict[str, object] = { + "generated_at_utc": generated_at_utc, + "run_fingerprint": { + "run_id": run_id, + "generated_at_utc": generated_at_utc, + "execution_engine": execution_engine, + "soda_mode": soda_mode, + "llm_provider": llm_provider, + "llm_model": llm_model or "", + "code_commit": git_commit, + "dataset_fingerprint": dataset_fingerprint, + "rulepack_fingerprint": rulepack_fingerprint, + }, + "dataset": { + "jsonl_path": str(SAMPLE_FILE), + "duckdb_path": str(db_path), + "products_tested": len(products), + "source_jsonl": str(source_path) if source_path else "synthetic", + "perl_rules_source": str(perl_rules_dir) if perl_rules_dir else "inline_legacy_rules", + "execution_engine": execution_engine, + "soda_mode": soda_mode, + "profile": profile_name, + "profile_rule_count": len(structured_rules), + "dataset_fingerprint_sha256": dataset_fingerprint["sha256"], + "rulepack_fingerprint_sha256": rulepack_fingerprint["rule_ir_sha256"], + }, + "migration_summary": { + "total_rules": total_rules, + "passed_rules": passed_rules, + "rules_needing_review": total_rules - passed_rules, + "average_overall_confidence": round(avg_confidence, 4), + }, + "rule_results": rule_results, + } + if engine_run is not None: + result_payload["declarative_engine_run"] = engine_run + + results_path.parent.mkdir(parents=True, exist_ok=True) + with results_path.open("w", encoding="utf-8") as handle: + json.dump(result_payload, handle, indent=2) + return result_payload + + +def parse_args() -> argparse.Namespace: + parser = argparse.ArgumentParser(description="Run Perl/Python parity validation prototype.") + parser.add_argument("--size", type=int, default=300, help="Number of products to generate.") + parser.add_argument( + "--seed", + type=int, + default=17, + help="Random seed for synthetic data generation (ignored when --source-jsonl is set).", + ) + parser.add_argument( + "--source-jsonl", + type=Path, + default=DEFAULT_OFF_JSONL if DEFAULT_OFF_JSONL.exists() else None, + help="OFF JSONL source path. Defaults to ./openfoodfacts-products.jsonl when present.", + ) + parser.add_argument( + "--llm-provider", + choices=["simulated", "groq"], + default="groq", + help="Rule conversion provider.", + ) + parser.add_argument( + "--llm-model", + default=None, + help="Optional model override (for selected LLM provider).", + ) + parser.add_argument( + "--perl-rules-dir", + type=Path, + default=None, + help="Optional directory containing .pl rule snippets for extractor input.", + ) + parser.add_argument( + "--execution-engine", + choices=["python", "dbt", "soda"], + default="python", + help="Check execution engine for parity target: python (LLM converted), dbt, or soda.", + ) + parser.add_argument( + "--profile", + choices=list(SUPPORTED_PROFILES), + default=DEFAULT_PROFILE, + help="Rule-pack profile to execute: global, canada, or hybrid.", + ) + parser.add_argument( + "--soda-mode", + choices=["local", "cloud"], + default="local", + help="Soda execution mode when --execution-engine soda: local or cloud.", + ) + return parser.parse_args() + + +def main() -> None: + args = parse_args() + results = run_pipeline( + dataset_size=args.size, + seed=args.seed, + source_jsonl=args.source_jsonl, + llm_provider=args.llm_provider, + llm_model=args.llm_model, + perl_rules_dir=args.perl_rules_dir, + execution_engine=args.execution_engine, + soda_mode=args.soda_mode, + profile=args.profile, + ) + summary = results["migration_summary"] + print(f"Rules analyzed: {summary['total_rules']}") + print(f"Passed rules: {summary['passed_rules']}") + print(f"Rules needing review: {summary['rules_needing_review']}") + print(f"Dataset source: {results['dataset']['source_jsonl']}") + print(f"Execution engine: {results['dataset'].get('execution_engine', 'python')}") + if results["dataset"].get("execution_engine") == "soda": + print(f"Soda mode: {results['dataset'].get('soda_mode', 'local')}") + print(f"Profile: {results['dataset'].get('profile', DEFAULT_PROFILE)}") + print(f"Run ID: {results.get('run_fingerprint', {}).get('run_id', 'n/a')}") + print( + "Fingerprints: " + f"dataset={str(results.get('run_fingerprint', {}).get('dataset_fingerprint', {}).get('sha256', ''))[:16]} | " + f"rulepack={str(results.get('run_fingerprint', {}).get('rulepack_fingerprint', {}).get('rule_ir_sha256', ''))[:16]}" + ) + print(f"Results written to: {RESULT_PATH}") + + +if __name__ == "__main__": + main() diff --git a/OFF_DataQuality/validation/verification.py b/OFF_DataQuality/validation/verification.py new file mode 100644 index 0000000000000000000000000000000000000000..2c6b24ba11bac17d7cf31e4b8f135f8cdcb56f14 --- /dev/null +++ b/OFF_DataQuality/validation/verification.py @@ -0,0 +1,387 @@ +"""Verification utilities for migrated rule quality. + +This module adds: +- rule-level equivalence checks (Perl evaluator vs generated check), +- mutation testing for generated Python checks. +""" +from __future__ import annotations + +import json +import random +from typing import Callable, Dict, List, Mapping, Sequence + + +def _to_float(value: object) -> float | None: + if value is None: + return None + try: + return float(value) + except (TypeError, ValueError): + return None + + +def _comparison_pairs(operator: str) -> tuple[tuple[float, float], tuple[float, float]]: + pairs = { + ">": ((2.0, 1.0), (1.0, 2.0)), + "<": ((1.0, 2.0), (2.0, 1.0)), + ">=": ((2.0, 2.0), (1.0, 2.0)), + "<=": ((2.0, 2.0), (3.0, 2.0)), + "==": ((2.0, 2.0), (2.0, 3.0)), + "!=": ((2.0, 3.0), (2.0, 2.0)), + } + return pairs.get(operator, ((2.0, 1.0), (1.0, 2.0))) + + +def _threshold_values(operator: str, threshold: float) -> tuple[float, float]: + if operator == ">": + return threshold + 1.0, threshold + if operator == "<": + return threshold - 1.0, threshold + if operator == ">=": + return threshold, threshold - 1.0 + if operator == "<=": + return threshold, threshold + 1.0 + if operator == "==": + return threshold, threshold + 1.0 + if operator == "!=": + return threshold + 1.0, threshold + return threshold + 1.0, threshold + + +def _dedupe_cases(cases: Sequence[Mapping[str, object]]) -> List[Dict[str, object]]: + deduped: List[Dict[str, object]] = [] + seen: set[str] = set() + for case in cases: + payload = dict(case) + key = json.dumps(payload, sort_keys=True, default=str) + if key in seen: + continue + seen.add(key) + deduped.append(payload) + return deduped + + +def generate_equivalence_cases( + rule: Mapping[str, object], + seed: int = 17, + random_cases: int = 18, +) -> List[Dict[str, object]]: + rng = random.Random(seed + (sum(ord(ch) for ch in str(rule.get("rule_name", ""))) % 997)) + condition_type = str(rule.get("condition_type", "")) + cases: List[Dict[str, object]] = [] + + if condition_type == "field_comparison": + left = str(rule.get("left_operand")) + right = str(rule.get("right_operand")) + operator = str(rule.get("operator")) + true_pair, false_pair = _comparison_pairs(operator) + cases.extend( + [ + {left: true_pair[0], right: true_pair[1]}, + {left: false_pair[0], right: false_pair[1]}, + {left: true_pair[1], right: true_pair[1]}, + {left: None, right: true_pair[1]}, + {left: true_pair[0], right: None}, + ] + ) + for _ in range(random_cases): + cases.append({left: round(rng.uniform(-10, 200), 3), right: round(rng.uniform(-10, 200), 3)}) + + elif condition_type == "field_threshold": + left = str(rule.get("left_operand")) + operator = str(rule.get("operator")) + threshold = float(rule.get("right_operand", 0.0)) + true_value, false_value = _threshold_values(operator, threshold) + cases.extend([{left: true_value}, {left: false_value}, {left: None}, {left: "nan_text"}]) + for _ in range(random_cases): + cases.append({left: round(rng.uniform(threshold - 100, threshold + 100), 3)}) + + elif condition_type == "missing_field": + field = str(rule.get("left_operand")) + cases.extend( + [ + {field: None}, + {field: ""}, + {field: " "}, + {field: "en"}, + {field: "xx"}, + ] + ) + + elif condition_type == "scaled_field_comparison": + left = str(rule.get("left_operand")) + right = str(rule.get("right_operand")) + operator = str(rule.get("operator")) + factor = float(rule.get("scale_factor", 1.0)) + right_value = 10.0 + target = right_value * factor + true_value, false_value = _threshold_values(operator, target) + cases.extend( + [ + {left: true_value, right: right_value}, + {left: false_value, right: right_value}, + {left: None, right: right_value}, + {left: true_value, right: None}, + ] + ) + for _ in range(random_cases): + random_right = round(rng.uniform(0.1, 150), 3) + random_target = random_right * factor + delta = rng.uniform(-10, 10) + cases.append({left: round(random_target + delta, 3), right: random_right}) + + elif condition_type == "affine_field_comparison": + left = str(rule.get("left_operand")) + right = str(rule.get("right_operand")) + operator = str(rule.get("operator")) + factor = float(rule.get("scale_factor", 1.0)) + offset = float(rule.get("offset", 0.0)) + right_value = 10.0 + target = (factor * right_value) + offset + true_value, false_value = _threshold_values(operator, target) + cases.extend( + [ + {left: true_value, right: right_value}, + {left: false_value, right: right_value}, + {left: None, right: right_value}, + {left: true_value, right: None}, + ] + ) + for _ in range(random_cases): + random_right = round(rng.uniform(0.1, 150), 3) + random_target = (factor * random_right) + offset + delta = rng.uniform(-10, 10) + cases.append({left: round(random_target + delta, 3), right: random_right}) + + elif condition_type == "sum_fields_comparison": + left_operands = list(rule.get("left_operands", [])) + if len(left_operands) >= 2: + left_a = str(left_operands[0]) + left_b = str(left_operands[1]) + right = str(rule.get("right_operand")) + operator = str(rule.get("operator")) + right_offset = float(rule.get("right_offset", 0.0)) + right_value = 20.0 + target = right_value + right_offset + true_sum, false_sum = _threshold_values(operator, target) + cases.extend( + [ + {left_a: true_sum / 2.0, left_b: true_sum / 2.0, right: right_value}, + {left_a: false_sum / 2.0, left_b: false_sum / 2.0, right: right_value}, + {left_a: None, left_b: 2.0, right: right_value}, + {left_a: 2.0, left_b: None, right: right_value}, + ] + ) + for _ in range(random_cases): + random_right = round(rng.uniform(0.1, 120), 3) + random_target = random_right + right_offset + left_sum = random_target + rng.uniform(-20, 20) + left_part = round(rng.uniform(0, max(left_sum, 0.1)), 3) + cases.append( + { + left_a: left_part, + left_b: round(left_sum - left_part, 3), + right: random_right, + } + ) + + elif condition_type == "compound_threshold_and": + clauses = list(rule.get("clauses", [])) + passing: Dict[str, object] = {} + failing: Dict[str, object] = {} + for idx, clause in enumerate(clauses): + field = str(clause.get("left_operand")) + operator = str(clause.get("operator")) + threshold = float(clause.get("right_operand", 0.0)) + true_value, false_value = _threshold_values(operator, threshold) + passing[field] = true_value + failing[field] = true_value + if idx == 0: + failing[field] = false_value + if passing: + cases.append(passing) + if failing: + cases.append(failing) + + return _dedupe_cases(cases) + + +def evaluate_rule_equivalence( + rule: Mapping[str, object], + perl_evaluator: Callable[[Mapping[str, object]], bool], + check_fn: Callable[[Mapping[str, object]], object], + seed: int = 17, + cases: Sequence[Mapping[str, object]] | None = None, + max_counterexamples: int = 5, +) -> Dict[str, object]: + sample_cases = list(cases) if cases is not None else generate_equivalence_cases(rule, seed=seed) + tag = str(rule.get("tag")) + matches = 0 + mismatches = 0 + counterexamples: List[Dict[str, object]] = [] + + for case in sample_cases: + product = dict(case) + expected = tag if bool(perl_evaluator(product)) else None + try: + actual = check_fn(product) + except Exception as exc: # noqa: BLE001 + actual = f"EXCEPTION:{exc.__class__.__name__}" + if actual == expected: + matches += 1 + else: + mismatches += 1 + if len(counterexamples) < max_counterexamples: + counterexamples.append({"input": product, "expected": expected, "actual": actual}) + + total = len(sample_cases) + rate = (matches / total) if total else 1.0 + return { + "equivalence_cases": total, + "equivalence_matches": matches, + "equivalence_mismatches": mismatches, + "equivalence_match_rate": round(rate, 4), + "equivalence_status": "PASS" if mismatches == 0 else "FAIL", + "counterexamples": counterexamples, + } + + +def _mutate_once(code: str, old: str, new: str) -> str | None: + if old not in code: + return None + mutated = code.replace(old, new, 1) + if mutated == code: + return None + return mutated + + +def build_mutants(rule: Mapping[str, object], python_code: str) -> List[Dict[str, object]]: + mutants: List[Dict[str, object]] = [] + condition_type = str(rule.get("condition_type", "")) + operator = str(rule.get("operator", "")) + operator_swap = {">": ">=", "<": "<=", ">=": ">", "<=": "<", "==": "!=", "!=": "=="} + swapped = operator_swap.get(operator) + if swapped: + mutated = _mutate_once(python_code, f" {operator} ", f" {swapped} ") + if mutated is not None: + mutants.append({"name": f"operator_{operator}_to_{swapped}", "code": mutated}) + + if condition_type == "missing_field": + mutated = _mutate_once(python_code, 'or str(value).strip() == ""', 'and str(value).strip() == ""') + if mutated is not None: + mutants.append({"name": "missing_logic_or_to_and", "code": mutated}) + + if condition_type == "sum_fields_comparison": + mutated = _mutate_once(python_code, "left_sum = left_a_value + left_b_value", "left_sum = left_a_value - left_b_value") + if mutated is not None: + mutants.append({"name": "sum_to_difference", "code": mutated}) + + scale_factor = rule.get("scale_factor") + if isinstance(scale_factor, (int, float)): + old = str(float(scale_factor)) + new = str(round(float(scale_factor) + 0.3, 6)) + mutated = _mutate_once(python_code, old, new) + if mutated is not None: + mutants.append({"name": "scale_factor_perturbed", "code": mutated}) + + offset = rule.get("offset") + if isinstance(offset, (int, float)): + old = str(float(offset)) + new = str(round(float(offset) + 1.0, 6)) + mutated = _mutate_once(python_code, old, new) + if mutated is not None: + mutants.append({"name": "offset_perturbed", "code": mutated}) + + threshold = rule.get("right_operand") + if condition_type == "field_threshold" and isinstance(threshold, (int, float)): + old = str(float(threshold)) + new = str(round(float(threshold) + 1.0, 6)) + mutated = _mutate_once(python_code, old, new) + if mutated is not None: + mutants.append({"name": "threshold_perturbed", "code": mutated}) + + deduped: List[Dict[str, object]] = [] + seen: set[str] = set() + for mutant in mutants: + code = str(mutant["code"]) + if code in seen: + continue + seen.add(code) + deduped.append(mutant) + return deduped[:8] + + +def evaluate_mutation_suite( + rule: Mapping[str, object], + perl_evaluator: Callable[[Mapping[str, object]], bool], + python_code: str, + function_name: str, + seed: int = 17, +) -> Dict[str, object]: + cases = generate_equivalence_cases(rule, seed=seed) + mutants = build_mutants(rule, python_code) + total = 0 + killed = 0 + survived: List[str] = [] + + for mutant in mutants: + namespace: Dict[str, object] = {} + try: + exec(str(mutant["code"]), {}, namespace) + fn = namespace.get(function_name) + if not callable(fn): + continue + except Exception: + continue + + total += 1 + result = evaluate_rule_equivalence( + rule=rule, + perl_evaluator=perl_evaluator, + check_fn=fn, + seed=seed, + cases=cases, + max_counterexamples=1, + ) + if int(result["equivalence_mismatches"]) > 0: + killed += 1 + else: + survived.append(str(mutant["name"])) + + score = (killed / total) if total else 1.0 + return { + "mutation_total": total, + "mutation_killed": killed, + "mutation_survived": total - killed, + "mutation_score": round(score, 4), + "mutation_survived_mutants": survived, + } + + +def run_rule_verification( + rule: Mapping[str, object], + perl_evaluator: Callable[[Mapping[str, object]], bool], + check_fn: Callable[[Mapping[str, object]], object], + python_code: str, + function_name: str, + seed: int = 17, +) -> Dict[str, object]: + equivalence = evaluate_rule_equivalence( + rule=rule, + perl_evaluator=perl_evaluator, + check_fn=check_fn, + seed=seed, + ) + mutation = evaluate_mutation_suite( + rule=rule, + perl_evaluator=perl_evaluator, + python_code=python_code, + function_name=function_name, + seed=seed, + ) + verification_score = float(equivalence["equivalence_match_rate"]) * float(mutation["mutation_score"]) + return { + **equivalence, + **mutation, + "verification_score": round(verification_score, 4), + }