Skip to content

fix(training): guard HF dataset snapshots with parent-commit CAS - #195

Draft
DrAbdulmalek wants to merge 12 commits into
feat/training-delivery-concurrency-followupfrom
feat/hf-dataset-cas-parent-commit
Draft

DrAbdulmalek wants to merge 12 commits into
feat/training-delivery-concurrency-followupfrom
feat/hf-dataset-cas-parent-commit

Conversation

@DrAbdulmalek

Copy link
Copy Markdown
Owner

Summary

  • Pins the remote dataset read to one verified Hub commit SHA.
  • Uses HfApi.create_commit(parent_commit=...) to make the snapshot replacement conditional on the remote head still matching the baseline.
  • Fails closed when the baseline SHA is missing or the repository data layout is not exactly one supported Parquet shard under data/; multi-shard and non-Parquet layouts remain unsupported rather than risking data loss.
  • Adds offline tests for baseline pinning, unsupported layouts, parent SHA propagation, and stale-parent conflict propagation.

Safety / validation

  • Draft follow-up stacked on PR feat(training): record append-only export delivery outcomes #194 branch feat/training-delivery-concurrency-followup.
  • No live Hugging Face upload; tests use mocks.
  • No changes to main; no merge.
  • CAS conflicts are propagated without automatic retry. Recovery must re-read the latest baseline, re-run deduplication, and start a new attempt.
  • This PR only supports single-Parquet-shard datasets. It deliberately blocks export on multi-shard or alternate data layouts until those formats have explicit CAS-safe handling.
  • Keep Draft until CI and independent review complete.

Copy link
Copy Markdown
Owner Author

Follow-up hardening at head 756d6e50dddc6047344c6d004119d4c817d7d5bc:

  • Added an offline fixture to the existing service integration tests so they exercise consent/ledger/staging/archive behavior through a mocked CAS boundary instead of accidentally calling the real Hub API.
  • Exposed HfApi at the module seam for deterministic mocking and retained the prior remote-read error wording for existing assertions.
  • The dedicated tests/test_hf_dataset_cas.py tests still exercise the CAS helper itself with fake API objects.

Live CI has restarted for this head. At the last read, Docker and Secret Gate were still in progress and HF Space Drift Gate was queued. No Python test pass is claimed yet; PR remains Draft. No HF upload or merge was performed.

Copy link
Copy Markdown
Owner Author

Independent CI re-check at head 756d6e50dddc6047344c6d004119d4c817d7d5bc (2026-10-12): the three runs associated with this SHA completed successfully: Secret Gate, HF Space Drift Gate, and Docker. However, this does not establish that Python tests passed. The repository's .github/workflows/lint-test.yml runs Unit Tests on pull_request only when the base is main/master, while this stacked PR targets feat/training-delivery-concurrency-followup; its push filter is feature/**, which does not match this branch's feat/** name. Therefore no Python test workflow was triggered for this head. Keep this PR Draft / WAITING_ON_TESTS until targeted tests run on this exact head.

Additional review note: get_verified_dataset_baseline() currently filters data/ entries to a predefined suffix allowlist before counting them. An unexpected data file with an unlisted suffix could be silently excluded from layout validation. Please make layout validation fail closed for any non-directory payload under data/ that is not the single supported Parquet shard, and add a regression test for an unknown extension. No merge, no main changes, and no live HF upload.

Copy link
Copy Markdown
Owner Author

Follow-up commits on the PR branch only:

  • 602ce25b70996aafa6a22d1469747f08d319f7e4 — fail closed for all non-directory files under data/, including unknown extensions, rather than filtering them out before validation.
  • eebab596535143a35b6c5926e5a1697a006b0515 — regression coverage for data/unexpected.bin and directory entries.
  • 286ce31a3cd7a411452a0af6b740697572c5637b — added .github/workflows/hf-dataset-cas-tests.yml to run focused CAS/export-integrity tests on feat/** / feature/** pushes and relevant PRs.

Fresh runs for head 286ce31a3cd7a411452a0af6b740697572c5637b are now present: HF Dataset CAS Tests 38221593922, Docker 38221594010, Secret Gate 38221594115, HF Space Drift Gate 38221593910. At the latest poll, the targeted Python job had started but had not yet reached test execution; no test result is claimed. PR remains Draft. No live HF upload, no merge, and no main changes.

Copy link
Copy Markdown
Owner Author

CI re-check complete for head 286ce31a3cd7a411452a0af6b740697572c5637b (2026-10-12): the new HF Dataset CAS Tests job passed. I inspected its job log; pytest collected 40 tests across test_hf_dataset_cas.py, test_hf_dataset_integrity_ledger.py, and test_training_integrity_ledger.py, with 40 passed in 0.88s. Secret Gate, HF Space Drift Gate, and Docker workflow runs also completed successfully. These tests run with HF_HUB_OFFLINE=1 and HF_DATASETS_OFFLINE=1; no live HF upload occurred.

Independent review remains required before changing Draft status. The service integration tests deliberately monkeypatch the CAS boundary, while the dedicated CAS tests exercise the helper itself; this is documented and useful separation, but does not replace a final review of the integration wiring and upstream stacked PRs. PR #191's observed workflow runs are green; PR #194's observed Secret Gate, HF Space Drift Gate, and Docker runs are green. PR #194 and #195 remain stacked and open, so no merge action has been taken. No changes to main.

@DrAbdulmalek DrAbdulmalek left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent review of PR #195 at head 286ce31a3cd7a411452a0af6b740697572c5637b:

Verified: the focused offline CI job ran 40 tests across CAS, export-integrity, and training-integrity suites; all 40 passed. Secret Gate, HF Space Drift Gate, and Docker workflow runs also completed successfully. The baseline is pinned to a SHA, the same SHA is passed as parent_commit, and stale-parent errors are propagated without retry. Unknown files under data/ are now included in layout validation, and the .bin regression is covered.

Residual review limits: the service integration fixture intentionally mocks get_verified_dataset_baseline and push_parquet_snapshot_with_cas; therefore the 40 passing tests do not prove the real service-to-Hub integration end-to-end. They do prove the dedicated CAS helper with fake API objects, and service ledger/staging behavior with a mocked boundary. No live Hub write should be used as a CI test.

Disposition: keep Draft pending review of the stacked dependency chain (#191 → #194 → #195) and confirmation that the parent PRs remain on the intended heads. This is a COMMENT review, not approval or merge authorization. No main-branch change or live HF upload.

Copy link
Copy Markdown
Owner Author

Independent follow-up audit — 2026-10-12

Re-checked the live PR chain and the workflow job logs. This is an audit comment, not an approval.

Verified on current heads

Code-path checks

  • The service obtains a verified baseline SHA, calls load_dataset(..., revision=baseline_sha), and passes that same SHA as parent_commit.
  • The baseline tree is enumerated at that revision; unsupported/multi-file data layouts fail closed.
  • CAS conflicts are not retried automatically. A client exception is conservatively logged as push_ambiguous; staged rows are not cleared on that failure path.
  • Delivery events are metadata-only and protected against ordinary UPDATE/DELETE statements; this is not filesystem-level tamper-proof storage.
  • No live HF upload was performed, and no production branch was changed.

Remaining limitation / follow-up

The writer currently hard-codes revision="main". This is consistent with the current baseline lookup's default revision, but the assumption should remain explicit: if the dataset's intended write branch changes, baseline discovery and commit target must be configured together and tested. Do not enable export or merge based solely on the offline tests.

Disposition: CAS_TESTS_PASSED — REVIEW_PENDING. Keep this PR Draft. Do not merge this stacked chain until the base PR and the full chain have received independent review.

@DrAbdulmalek
DrAbdulmalek force-pushed the feat/training-delivery-concurrency-followup branch from 4cef8a9 to 7e78ec6 Compare October 12, 2026 10:22
@DrAbdulmalek
DrAbdulmalek force-pushed the feat/hf-dataset-cas-parent-commit branch from d4ec14d to 747acd5 Compare October 12, 2026 10:23
@DrAbdulmalek
DrAbdulmalek force-pushed the feat/training-delivery-concurrency-followup branch from 34ab1be to d9dd336 Compare October 12, 2026 10:26
@DrAbdulmalek
DrAbdulmalek force-pushed the feat/hf-dataset-cas-parent-commit branch from aa6f719 to 77a9a5c Compare October 12, 2026 10:26
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.

1 participant