WikifitaGitHub live67e8de5
pesquisa · kaggle/pokemon_tcg_data_oracle_etl

Pokémon TCG — Dataset, Oracle and ETL Contract

Replay ingestion, semantic validation, off-by-one repair, engine-backed would-KO labels, telescoping rewards, Parquet materialization and zero-trust audit boundaries.

Baixar raw

Pokémon TCG — Dataset, Oracle and ETL Contract

Pipeline shape

The repository's data documents describe a staged transformation, not a single “dataset download” step:

flowchart LR
    Z[Raw replay ZIPs] --> J[JSON member extraction]
    J --> S[Semantic validation]
    S --> A[Episode/action realignment]
    A --> O[Engine-backed oracle]
    O --> R[Telescoping rewards and targets]
    R --> P[Day-partitioned Parquet]
    P --> T[MLX training / TBPTT]
    Z --> D[SQLite catalog and tournament metadata]
    D --> Q[Quality audit and provenance joins]

Every transition needs an auditable count, source identity and failure policy. A row that is dropped, shifted, imputed or synthesized must not silently look like an observed replay row.

Current snapshot used by the August 14 audit

The direct local read and the Antigravity survey disagree in ways that matter for later ETL work:

LayerDirect/current observationProvenance note
Replay ZIPs30 archives, from 2026-07-14 through 2026-08-12Direct filesystem inventory
ZIP JSON members138,138Direct re-read; not accepted as the only corpus count
Antigravity surveyed members140,511Survey artifact; unresolved delta of 2,373
SQLite schemaversion 2.0.0Direct database read
SQLite matches139,783Includes a history that is not identical to current ZIP members
Parquet partitions30 files, 30 manifestsDirect dataset inventory
Parquet schema90 columnsDirect schema read
Parquet rows24,177,852Direct row-count observation
Latest Parquet day2026-08-12, 806,653 rowsDirect row-count observation
Direct remote/local split138,023 / 1,760Current source metadata; not a complete provenance proof

These numbers are not interchangeable. A larger SQLite match count does not prove that missing ZIP members were recovered, and a Parquet row count does not prove every row is semantically valid.

Semantic and temporal normalization

The compiler performs several different kinds of repair or interpretation:

  • Semantic validation: required fields, action legality and episode shape are checked before materialization.
  • Off-by-one realignment: replay observations and decisions are aligned to the state at which an action was selected. This is a transformation with a failure count, not a harmless index adjustment.
  • Engine oracle: the rules engine computes would-KO and related prospective labels from a state/action context. The oracle is a label generator, not an observation source.
  • Telescoping rewards: per-step rewards are derived so that the sum reflects terminal or prize changes without inventing independent outcomes.
  • Parquet materialization: day partitions and row groups provide streaming units for the trainer and hierarchical cache.

The current and target schema proposals add fields such as match_step, meta_epoch, time_remaining, inferred opponent Elo, team hash and vehicle deck-card IDs. These fields are useful for RoPEND/MoE and data augmentation only if their temporal availability is explicit. The distinction between replay-derived auxiliary targets and future synthetic vehicle drafting is maintained in pokemon_tcg_data_augmentation_vehicle_draft.

Data-quality hazards

Day metadata versus imported data

The August 14 audit found divergent declared, database and ZIP counts on several days:

DayDeclared metadataSQLite observationZIP observation
2026-08-056,2294,7294,740
2026-08-0610,4514,6294,631
2026-08-078,7164,6364,639
2026-08-105,1394,5994,603
2026-08-117,6324,6214,622
2026-08-1220,3256,3614,604

The differences must remain as reconciliation work. Selecting the largest number would turn metadata into false evidence.

Foreign-key integrity

The current snapshot exposed 2,946,336 child rows violating declared foreign-key relationships. The largest groups include orphaned match_steps and their dependent options, events, board snapshots and field rows, plus orphaned match-card usage. No purge, destructive rebuild or silent repair was run during the audit.

This is why the ETL design emphasizes zero trust: the database is a catalog and evidence source, not automatically the ground truth for every replay lineage.

Target validity and sparsity

The Parquet audit recorded complete deck-list shape in the sampled schema and current auxiliary statistics including approximately 100% valid auxiliary rows, 9.39% KO labels, 1.52% terminal labels, 8.91% non-zero prize outcomes, 99.99% return coverage and 27.31% attack coverage. These are descriptive snapshot metrics. They do not establish that the sparse-head denominators were used correctly by the trainer, which is the separate Stage 3/4 incident.

Zero-trust ETL rules

The ETL architecture documents establish several operational rules:

  • physical ZIP contents and SQLite imports are reconciled rather than assumed equivalent;
  • rebuild_db=false is an offline promise and must not unexpectedly invoke network or destructive rebuild behavior;
  • download and import vectors are separate from local idempotent delta builders;
  • build_card_stats and replay population should be safe to rerun as local deltas;
  • source enums, receipts and manifests must preserve where every row came from;
  • entity-resolution candidates must remain additive mappings with their rule, episode distance and confidence; the original team/agent observation is not overwritten;
  • no future-derived Elo, tournament result or generated deck may enter ordinary replay rows without an explicit source and timestamp.

Data augmentation contract

The future vehicle-draft design extends this ETL rather than bypassing it. A generated deck or synthetic trajectory must carry:

source = synthetic_vehicle_draft
generator_checkpoint
generator_version
sampling_policy
deck_legality_result
engine_version
rating_snapshot
tournament_cohort
seed

Synthetic examples may be valuable for exploration, but they must remain separable from replay-derived behavior cloning until a controlled experiment demonstrates that their inclusion improves a declared target without hiding source drift.

Audit sequence for the next ETL pass

  1. Recount raw ZIP members by archive and day.
  2. Reconcile ZIP, SQLite, Parquet, manifest and declared metadata counts.
  3. Validate episode and action alignment with explicit drop/shift counts.
  4. Recompute oracle coverage and sparse target denominators.
  5. Check foreign keys and orphan-root lineage without deleting anything.
  6. Verify train/validation/tournament split identity and future-field availability.
  7. Only then add synthetic vehicle-draft records to a separate source cohort.

This sequence is analysis and documentation work. It does not authorize implementation of the target schema or a database rebuild.

Primary sources

  • docs/dataset_compilation_and_oracle_pipeline.md — compiler stages and future context fields.
  • docs/etl_architecture_and_auditing.md — zero-trust database and import behavior.
  • docs/database_schema.md — current physical table topology.
  • docs/schema-evolution.md — target relational design under review.
  • docs/normalization_heuristics.md — entity resolution and residual ghosts.
  • docs/technical_handoff_rfc.md — database, replay and run inventory assertions.

Cross-references