Skip to content

feat(data ingest): preflight parity — the dry-run's promise becomes a checked contract#147

Merged
saadqbal merged 1 commit into
feat/ingest-guard-and-extensionfrom
feat/preflight-parity
Jul 7, 2026
Merged

feat(data ingest): preflight parity — the dry-run's promise becomes a checked contract#147
saadqbal merged 1 commit into
feat/ingest-guard-and-extensionfrom
feat/preflight-parity

Conversation

@LukasWodka

Copy link
Copy Markdown
Contributor

Summary

P3 of backend#828 — closes cli#69, cli#71, cli#72, cli#73 (+1 rule no ticket had). Stacked on #145#142; retargets down the stack as they merge.

Every local check now previews a named data-ingestors validator with matching semantics, so preflight passed ⇒ in-cluster validation passes — failures land before the upload, not after. And the claim isn't taken on faith: a parity harness pins it against the real Python validators.

The previews (internal/push/preflight.go, each cites its source rule)

🚨 Fixes a pre-existing ship-blocker

The adversarial pass empirically proved spec.go's [H,W] swap on target_size emission wrong (the schema + ImageResolutionValidator compare PIL's (W,H) verbatim) — every non-square dataset failed in-cluster post-upload, 100%. Emission is now [W,H], pinned end-to-end by the imgc-nonsquare / imgc-nonsquare-swapped parity pair (8×4 images: [8,4] passes both sides, [4,8] rejects both sides — verified against the real validator).

The parity harness (the durable part)

  • 23 fixture cases + goldens.json generated from the real Python validators (scripts/gen-validator-goldens.py, sync-validator-goldens.sh --check for verdict-level drift)
  • parity_golden_test.go runs push.PreflightDatasetthe production dispatch, shared with runDataIngest, so test and reality cannot drift (deleting/rewiring a check fails parity)
  • Deliberate divergences (read-/transfer-time failures the ingestor's preflight can't see but the CLI previews) are explicit manifest notes — e.g. imgc-dup-header where the real validators accept and the rejection is read-time-only
  • When the ingestor's rules change: regenerate goldens → the Go test fails until manifest + preview are consciously reconciled

Verification

23/23 parity green · full go test ./... green · live dry-runs on a real cluster (missing file / bad label column / single-class / Latin-1 all caught pre-upload; a 320×200 non-square dataset — previously doomed — sails through) · adversarial review (2 lenses): all findings folded, including de-masked fixtures and a vacuous kubeconfig test revived with decodable fixtures.

Refs: backend#828 (P3) · backend#879 · data-ingestors#338.

🤖 Generated with Claude Code

… checked contract

backend#828 P3; closes cli#69, cli#71, cli#72, cli#73.

Every local check now previews a NAMED data-ingestors validator with
matching semantics, so 'preflight passed' means the in-cluster
validation passes too — failures land BEFORE the upload, not after.

New previews (internal/push/preflight.go, each cites its source rule):
- label column exists (LabelColumnValidator: exact, then
  case-insensitive+trimmed — never stricter than the cluster) (#69)
- BOM: tabular rejected pre-upload (the in-cluster stdlib schema probe
  falsely rejects BOM'd CSVs — data-ingestors#338); image/text BOM
  accepted+stripped, matching the pandas paths (#71)
- every image decoded (header-only, cheap): zero-byte, corrupt,
  resolution vs target — plus the labels↔images cross-check with the
  ingestor's _has_extension naming semantics (dotted stems!) (#72)
- duplicate headers (stripped, case-SENSITIVE like the probe), zero
  data rows, --schema columns ⊆ header, CSV encoding gate
  (check_csv_encoding preview: UTF-8 + no NUL) (#73 + gaps found)
- label diversity (LabelDiversityValidator: >=2 classes; NA-sentinel
  drop + numeric collapse for schema-typed tabular labels; empty
  string IS a class for image/text) — discovered BY the harness's
  first run, was in no ticket
- object_detection images↔annotations stem pairing
  (FilePairingValidator preview)

FIXES A PRE-EXISTING SHIP-BLOCKER found by the adversarial pass:
spec.go swapped target_size to [H,W] on emit (mistaken review note) —
but the schema + ImageResolutionValidator compare PIL's (W,H) verbatim,
so EVERY non-square dataset failed in-cluster post-upload. Emission is
now [W,H]; the parity pair imgc-nonsquare / imgc-nonsquare-swapped pins
the orientation end-to-end against the real validator.

THE PARITY HARNESS (the durable part):
- internal/push/testdata/parity: 23 fixture cases + goldens.json
  GENERATED from the real Python validators
  (scripts/gen-validator-goldens.py; scripts/sync-validator-goldens.sh
  --check for drift, verdict-level)
- parity_golden_test.go asserts the PRODUCTION dispatch
  (push.PreflightDataset — shared by runDataIngest and the test, so
  the two cannot drift) reaches the manifest's verdict per case, and
  that committed goldens match the manifest — an ingestor rule change
  fails the test until consciously reconciled
- deliberate divergences (read-/transfer-time failures the ingestor's
  preflight can't see but the CLI previews) are explicit manifest
  notes, never silent

Verified: 23/23 parity green; full go test green; live dry-runs on a
real cluster (missing file, bad label column, single-class, latin-1,
non-square 320x200 accept). Adversarial review (2 lenses, high
effort): all findings folded incl. the [W,H] bug, value-semantics
divergences in diversity/cross-check, the encoding gate, de-masked
fixtures, the shared dispatch, and a vacuous kubeconfig test revived
with decodable fixtures.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@LukasWodka

Copy link
Copy Markdown
Contributor Author

👋 Heads-up — Code review queue is at 35 / 30

Above the WIP limit. The team convention is to review existing PRs before opening new work.

Open PRs currently in Code review (oldest first):

Pull from review before opening new work. (This is a nudge from the kanban WIP check, not a block.)

@saadqbal saadqbal merged commit 5b8e27d into feat/ingest-guard-and-extension Jul 7, 2026
5 checks passed
saadqbal added a commit that referenced this pull request Jul 7, 2026
…] emit (#153)

The TargetSize field NOTE still described the old #25/[H,W] behavior
("EMITTED as [height, width] ... buildImage does the swap"), which #147
(landed via #149) deliberately reverted. buildImage now emits
[TargetSize[0], TargetSize[1]] = [width, height] with no swap — the order
ingest.v1.json documents ("matches PIL.Image.size and what
ImageResolutionValidator expects") and the order image_validator.py
compares against verbatim.

Rewrite the NOTE to state stored-and-emitted [width, height], no swap,
and warn against re-introducing the swap (which failed every non-square
dataset). Comment-only; rolls up under #145/#147.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants