Skip to content

CEX: atomically publish USD-M reference artifacts - #254

Merged
proerror77 merged 1 commit into
mainfrom
codex/cex-usdm-reference-artifact-222
Jul 23, 2026
Merged

CEX: atomically publish USD-M reference artifacts#254
proerror77 merged 1 commit into
mainfrom
codex/cex-usdm-reference-artifact-222

Conversation

@proerror77

@proerror77 proerror77 commented Jul 23, 2026

Copy link
Copy Markdown
Owner

Change contract

Atomically publish one complete Binance USD-M reference batch as a canonical NDJSON/manifest/SHA/_SUCCESS directory and strictly read it back using external data and manifest SHA trust anchors.

Part of #222. This PR does not close the issue.

Out of scope

Dependency or merge order

Depends on merged PR #253. Merge this PR before the CLI/health and deployment-gate layers.

Focused validation

  • TDD red: canonical publish/readback test failed with not implemented
  • cargo test -p hft-collector binance_usdm_reference_artifact::tests — 5 passed
  • cargo test -p hft-collector — 200 library + 39 archiver + 8 other tests passed; 2 existing tests ignored
  • cargo clippy -p hft-collector --all-targets -- -D warnings
  • scoped rustfmt check and git diff --check
  • independent Spec and Standards reviews: no blockers

Counterexamples cover stale batches, non-official sources, wrong external SHA anchors, tampered content, symlinked triplet members, and injected mid-publication failure with clean retry.

Rollout / rollback impact

Rollout: library-only artifact contract; no service or production host changes. Rollback: revert this PR without changing the already-merged source collector or any research/snapshot path.

Summary by CodeRabbit

  • New Features
    • Added support for publishing Binance USD-M reference data as complete, partitioned artifact batches.
    • Added manifest generation with coverage, timestamps, row counts, and SHA-256 integrity details.
    • Added strict artifact verification, including content, completeness, freshness, and metadata checks.
    • Artifacts are written atomically and durably, preventing partially published batches.
    • Added protection against tampering, invalid digests, symlinked files, stale data, and incomplete sources.

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a886baf4-8f68-4d4b-a1ef-01e9fb3e5859

📥 Commits

Reviewing files that changed from the base of the PR and between 4d2c229 and 626501c.

📒 Files selected for processing (2)
  • rust_hft/tools/collector/src/binance_usdm_reference_artifact.rs
  • rust_hft/tools/collector/src/lib.rs

📝 Walkthrough

Walkthrough

Adds a public Binance USD-M reference artifact module that serializes complete batches into partitioned NDJSON, manifest, and _SUCCESS files, publishes them atomically, and strictly verifies their paths, digests, metadata, and reconstructed contents.

Changes

Binance USD-M reference artifacts

Layer / File(s) Summary
Artifact contract and verification
rust_hft/tools/collector/src/binance_usdm_reference_artifact.rs, rust_hft/tools/collector/src/lib.rs
Defines public configuration and publication result types, exposes the module, and validates artifact files, manifests, partitions, digests, and reconstructed reference batches.
Atomic publication and filesystem primitives
rust_hft/tools/collector/src/binance_usdm_reference_artifact.rs
Serializes complete batches, writes staged artifact files, computes SHA-256 digests, fsyncs filesystem state, and atomically renames the staging directory without clobbering existing output.
Publication and verification tests
rust_hft/tools/collector/src/binance_usdm_reference_artifact.rs
Covers successful round trips, injected publication failures, invalid batches and sources, digest mismatches, tampering, and symlink rejection.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant publish_reference_batch
  participant ArtifactStorage
  participant verify_reference_artifact

  Caller->>publish_reference_batch: CompleteReferenceBatch and configuration
  publish_reference_batch->>ArtifactStorage: Write staged NDJSON, manifest, and _SUCCESS
  publish_reference_batch->>ArtifactStorage: Atomic no-clobber directory rename
  ArtifactStorage-->>Caller: PublishedReferenceArtifact with digests
  Caller->>verify_reference_artifact: Published artifact and expected digests
  verify_reference_artifact->>ArtifactStorage: Read and validate artifact members
  ArtifactStorage-->>verify_reference_artifact: File contents and metadata
  verify_reference_artifact-->>Caller: Reconstructed CompleteReferenceBatch
Loading

Possibly related PRs

  • proerror77/monday#110: Both publishers compute and expose SHA-256 digests for NDJSON and manifest artifacts.
  • proerror77/monday#251: Provides the CompleteReferenceBatch contract and validation logic used by this publisher and verifier.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/cex-usdm-reference-artifact-222

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@proerror77
proerror77 merged commit eab83cd into main Jul 23, 2026
15 of 16 checks passed
Comment on lines +326 to +334
if unsafe {
libc::renameat2(
libc::AT_FDCWD,
source.as_ptr(),
libc::AT_FDCWD,
target.as_ptr(),
libc::RENAME_NOREPLACE,
)
} != 0
Comment on lines +346 to +354
if unsafe {
libc::renameatx_np(
libc::AT_FDCWD,
source.as_ptr(),
libc::AT_FDCWD,
target.as_ptr(),
libc::RENAME_EXCL,
)
} != 0
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