Skip to content

Robustness: post-publish artifact cascade (archive/zarr/records) is fragile and non-self-healing #736

Closed
5 of 5 issues completed

Description

@neuromechanist

Incident: nm000111 publish produced an incomplete archive, no Zarr, no records.json

Approving the long-blocked nm000111 (ISRUC-Sleep) on 2026-06-10 minted the version DOI (v1.0.1) but the downstream serving artifacts silently did not materialize: the archive zip is incomplete, no Zarr store exists, and records.json is absent. This is a robustness post-mortem plus the fixes to make the post-publish cascade self-healing.

What actually happened (timeline, 2026-06-10)

  • 16:22:43 run-version-doi succeeded -> minted v1.0.1.
  • 16:23:26 run-generate-archive FAILED: all 126 annexed EDF blobs returned HTTP 403 from nemar.s3.us-east-2.amazonaws.com/nm000111/objects/.... Log: 126 annexed files were not found in S3; archive is incomplete / Archive complete: 0 annexed + 639 regular + 126 skipped / Uploaded to s3://nemar/nm000111/archives/v1.0.1.zip / exit code 1.
  • The exact blob that 403'd during the job now returns HTTP 200 anonymously. The data was never missing; the dataset's S3 prefix was still private (deny-list carve-out not yet propagated) at the moment the archive job read it.

Root causes

  1. Archive reads blobs anonymously + public-flip race (primary). run-generate-archive.yml streams annexed blobs via unauthenticated https.get against the public S3 URL, even though the job already has AWS_ACCESS_KEY_ID/SECRET in its env (used only for the multipart upload). The orchestrator flips S3 public (s3_public_read, step 4) before the tag push that fires the archive (create_tag, step 9), but S3 bucket-policy propagation lags, so the blob GETs 403'd. Reading with signed requests would have been immune.
  2. Sticky partial archive. The incomplete zip is uploaded to the canonical key even on failure, and the head-object skip-if-exists idempotency guard then makes every re-dispatch a no-op. A broken archive is self-perpetuating; only force=true clears it.
  3. No auto-retry. /webhooks/archive-ready records status=failed in D1, but nothing re-dispatches. Terminal until a human notices.
  4. Zarr not generated. Autodispatch is off (Hallu cron owns conversion); nm000111 is not converted (zarr index 404). Same public-timing fragility applies if/when it reads blobs during a private window.
  5. records.json never wired. generate-records.yml's S3 upload + callback are a documented TODO skeleton and the orchestrator never dispatches generate-records. So records.json 404s for ALL datasets, not just this one. (summary.json is also absent for this version.)

Robustness fixes

  • A. Signed S3 reads in run-generate-archive.yml (and audit the Zarr converter for the same). Use the creds already in env; removes the public-access dependency entirely, works for private datasets too. Highest leverage.
  • B. Flip public early + gate on propagation. Move the deny-list removal as early as possible in the publish cascade, then poll a known blob's anonymous HEAD until 200 (bounded) before advancing. Belt-and-suspenders with A.
  • C. Never leave a partial archive at the canonical key. Stream to a temp/staging key; promote (server-side copy) to archives/v<X>.zip only when skipped == 0; delete the temp on failure. Makes re-dispatch self-healing without force=true.
  • D. Auto-retry failed archive/zarr. On archive-ready/zarr-ready status=failed, re-dispatch with capped backoff, or a sweep that re-dispatches failed/missing artifacts.
  • E. Finish records.json wiring. Enable the upload + callback in generate-records.yml, add a records-ready webhook handler, and dispatch generate-records from the orchestrator (or the version-doi workflow, like archive).

Immediate remediation (nm000111)

  • Force-rebuild archive (run-generate-archive.yml force=true; blobs public now).
  • Trigger Zarr conversion.
  • records.json pending fix E.

Repos touched: nemarOrg/nemar-cli (orchestrator order, retry sweep, webhook handlers) and nemarDatasets/.github (archive signed reads, partial-key promotion, zarr audit, records wiring).

Sub-issues

Sub-issues

5 of 5 Issues completed
Loading 5 sub-issues

Activity

  1. added
    bug
    on Jun 11, 2026
  2. neuromechanist commented on Jun 11, 2026

    @neuromechanist
    ContributorAuthor

    Recovery + two refinements after live testing

    Archive: recovered and root cause confirmed. Re-dispatched run-generate-archive.yml with force=true (to bypass the sticky partial-zip guard) now that the dataset is public. It succeeded and rebuilt a complete v1.0.1.zip. This confirms root cause #1: the only thing that changed is the blobs are now publicly readable; with signed reads the original run would have succeeded regardless of visibility timing.

    Refinement to fix A: no new credential needed (do NOT push the Hallu key). The Zarr workflow already configures the same org secret AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY and reads blobs with authenticated aws s3 cp (scripts/zarr/generate_zarr.py line 20: "authenticated aws s3 cp (works for [private datasets])"), and it has many successful runs. So the CI key already holds s3:GetObject on the objects/ prefix. Fix A is purely: switch run-generate-archive.yml's stream-archive.js from anonymous https.get(<public S3 URL>) to a signed read (SDK GetObjectCommand / aws s3 cp) using the creds it already configures for the multipart upload. No secret rotation, no Hallu key.

    New finding (separate bug): the Zarr converter cannot handle mixed-sampling-rate EDF. A forced Zarr re-run on the now-public dataset still failed, but for an unrelated reason: all 126 EDFs error with Length of values (N) does not match length of index (16*N). ISRUC-Sleep is polysomnography with heterogeneous per-channel rates (EEG/EOG/EMG ~200 Hz, respiratory/SpO2 ~12.5 Hz; 200/12.5 = 16). The converter builds a single time index at the max rate and the slow channels' value arrays don't align. This is a converter robustness gap in generate_zarr.py, independent of the publish cascade — track as its own fix (call it F).

    Updated fix list: A (signed reads), B (flip public early + propagation gate), C (no sticky partial), D (auto-retry/visibility), E (records.json wiring), F (Zarr converter: support mixed-rate EDF).

  3. neuromechanist commented on Jun 11, 2026

    @neuromechanist
    ContributorAuthor

    Split out fix F (Zarr mixed-rate EDF/BDF) to #737 — handled separately (likely a biosigIO issue). This epic is scoped to A–E.

  4. neuromechanist commented on Jun 11, 2026

    @neuromechanist
    ContributorAuthor

    Follow-up surfaced in Phase 2 review (deferred, not blocking): if a runner is killed mid-stream before CompleteMultipartUpload, the archive streaming script may leave an incomplete multipart upload that delete-on-failure (aws s3 rm) won't clean. Pre-existing, narrow. Options: (a) catch SIGTERM/SIGINT in stream-archive.js and AbortMultipartUpload; (b) ensure an S3 lifecycle rule reaps incomplete MPUs on the nemar bucket. Low priority.

  5. added a commit that references this issue on Jun 11, 2026
  6. neuromechanist commented on Jun 11, 2026

    @neuromechanist
    ContributorAuthor

    Epic finalized to dev (prod held)

    All 5 phases merged + cross-phase reviewed. PR #746 (epic -> dev) merged (merge commit cab2395, regular merge preserving the phase commits).

    Dev finalization verified:

    • Migrations 0040 (archive_retry_count) + 0041 (records_status/records_checked_at) applied to dev D1 — all three columns confirmed present.
    • Dev Worker deploy: deploy-backend.yml succeeded on the merge commit.
    • New route live: nemar-api-dev.sccn-org.workers.dev/webhooks/records-ready returns 401 (auth required) = route exists.

    Status by surface:

    Held per maintainer: dev -> main (prod deploy + prod-D1 migrations + release tag). Will ship on your go.

    Keeping this issue open until prod ships. #737 (Zarr mixed-rate EDF/BDF) tracked separately.

  7. neuromechanist commented on Jun 17, 2026

    @neuromechanist
    ContributorAuthor

    Shipped to prod as part of the v0.8.53 release (2026-06-16). D/B/E (archive auto-retry, early S3-public flip + propagation gate, records-ready webhook) rode along on the dev->main release of epic #749 and deployed + verified green; the #736<->#749 archive seam (retry_count reset on skip) was fixed in #767.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions