Skip to content

Phase 4 (B): flip S3 public early + propagation gate - #744

Merged
neuromechanist merged 2 commits into
feature/issue-736-epic-publish-robustnessfrom
feature/issue-741-phase4-public-gate
Jun 11, 2026
Merged

neuromechanist merged 2 commits into
feature/issue-736-epic-publish-robustnessfrom
feature/issue-741-phase4-public-gate

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

Summary

Phase 4 (B) of epic #736. Defense-in-depth for the public-flip race that broke nm000111. Two changes in the publish orchestrator:

  1. Flip S3 public early. Move s3_public_read to be the first mutation after the validation gates (ci_check, enrichment_check), ahead of repo_public, so the bucket-policy (deny-list) change has the most time to propagate before create_tag fires version-doi -> generate-archive (~5 steps later). Per the maintainer directive: "the deny list should be removed very early in the publication cascade." Safe: s3_public_read and repo_public are independent, steps are idempotent, and the resume filter is order-tolerant.

  2. Non-fatal propagation gate. After markDatasetPublic, waitForPublicPropagation lists one real blob under <id>/objects/ and polls an unsigned HEAD until 200 (bounded: 6 attempts x 2s), so a stuck/slow propagation is surfaced in the publish log instead of silently advancing while blobs still 403 to the public. Non-fatal — on timeout it warns and proceeds: blocking a publish on AWS eventual consistency is the wrong tradeoff, and Phase 1's signed reads already removed the hard dependency. Unsigned by design (a signed HEAD would always 200 and wouldn't test public access).

Closes #741
Part of epic #736

Files

  • backend/src/services/s3.ts — firstObjectKeyFromListXml (pure) + waitForPublicPropagation. Reuses listObjectPages, the <Contents>…<Key> parse from getArchiveSize, and the encoded-key/anonymous-URL shape from headArchive.
  • backend/src/routes/admin.ts — reorder allSteps (s3_public_read before repo_public); call the gate in the s3_public_read step (non-fatal, logged, never 500s the publish).

Test plan

bun test backend/test/public-propagation.test.ts — 4 tests, no mocks: firstObjectKeyFromListXml against real S3 ListBucketResult XML (multi-object page -> first key; empty/<Contents>-less page -> null; single-object page -> key verbatim; unrelated XML -> null). Typecheck (tsc --noEmit) clean; Biome clean; no existing test depends on the step order.

The anonymous-403-then-200 transition the gate detects was demonstrated empirically this session: nm000111's blob returned 403 anonymously while private and 200 after the public flip. The full early-flip + gate exercises during a real publish at epic finalization (dev deploy).

@github-actions

github-actions Bot commented Jun 11, 2026 •

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR744

Version: 0.8.53-PR744.c6ed3f4
Commit: c6ed3f4


🤖 Updated on each push.

@neuromechanist

Copy link
Copy Markdown
Contributor Author

Sonnet /review-pr addressed:

  • Critical: fixed. The reviewer correctly caught that reordering the allSteps array does NOT change execution order — steps run in the order of their if (stepsToRun.includes(...)) blocks in source. The array is only the membership set for the resume filter. I've now moved the s3_public_read execution block to before repo_public, so the actual order is ci_check → enrichment_check → s3_public_read → repo_public → tag_protect (verified by grep). This is what makes the deny-list removal the first mutation, achieving the propagation lead time that is the whole point of the phase.
  • Important (stale comments): fixed. Updated the JSDoc step list (s3_public_read now Optimize KV usage to stay within free tier limits #2, repo_public CLI shows success then failure on admin approve #3) and replaced the hard "Step N" inline comments on both blocks with functional comments that can't go stale on a reorder.
  • All other points (unsigned HEAD, encodedKey, setTimeout-in-Workers, non-fatal in all paths, regex, single-blob representativeness, idempotent-when-already-public) confirmed sound. Typecheck/Biome clean; 4 tests pass.

@neuromechanist
neuromechanist merged commit 7cf6689 into feature/issue-736-epic-publish-robustness Jun 11, 2026
1 check passed
@neuromechanist
neuromechanist deleted the feature/issue-741-phase4-public-gate branch June 11, 2026 21:37

This branch was previously deployed

1 inactive deployment
npm — c6ed3f4c Deployed Jun 11, 2026 by neuromechanist via publish #1387
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