Skip to content

Add public S3 access for git-annex on publication - #102

Merged
neuromechanist merged 2 commits into
devfrom
101-configure-git-annex-public-s3-remote-on-dataset-publication
Feb 7, 2026
Merged

neuromechanist merged 2 commits into
devfrom
101-configure-git-annex-public-s3-remote-on-dataset-publication

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

Summary

  • Add s3_public_read step to publication orchestrator that applies public GetObject bucket policy via addPublicReadPolicy()
  • Extend generate-archive.yml workflow to set public=yes on the nemar-s3 remote, enabling credential-free git annex get after publication
  • Push updated git-annex branch so clones discover the public remote config

After publication, consumers can:

git clone https://github.com/nemarDatasets/nm000XXX.git
cd nm000XXX
git annex get .   # downloads via anonymous S3 HTTPS

Details

Backend (admin.ts): New s3_public_read step inserted after repo_public, before tag_protect (publication orchestrator now has 14 steps). Calls the existing addPublicReadPolicy() which is idempotent and resume-safe.

Workflow (github.ts): Two new steps appended to the generate-archive.yml template: git annex enableremote nemar-s3 public=yes and git push origin git-annex. The public=yes flag tells git-annex to use unsigned S3 requests for downloads. The bucket policy (GetObject only) prevents anonymous uploads.

Test plan

  • All 221 tests pass (bun test)
  • Biome lint/format clean (pre-existing warnings only)
  • Deploy backend, run nemar admin publish approve nm099999 -y --sandbox
  • Verify S3 bucket policy includes PublicReadDataset_nm099999
  • Clone repo without AWS credentials, verify git annex get . works

Closes #101

Add s3_public_read step to publication orchestrator
that applies public GetObject bucket policy. Extend
generate-archive workflow to set public=yes on the
nemar-s3 remote so git-annex uses unsigned requests,
enabling credential-free downloads after publication.

Closes #101
Gate public=yes with client_payload.public parameter
so it only runs during publication, not all archive
generations. Add fetch-depth: 0 for git-annex branch
access. Combine enableremote and push into single step.
Add console.error in s3_public_read catch block. Fix
step comment numbering (duplicate Step 4, wrong 5/13).
@neuromechanist

Copy link
Copy Markdown
Contributor Author

PR Review Summary

Reviewed by: code-reviewer, silent-failure-hunter, comment-analyzer

Critical Issues (1 found, addressed)

  • [error-handler] enableremote public=yes ran unconditionally in the async fire-and-forget workflow. If triggered outside publication (e.g., re-generating archive for private dataset), it would incorrectly mark the remote as public.
    • Fix: Gated with if: github.event.client_payload.public == true. The orchestrator now passes { public: true } in the dispatch payload.

Important Issues (4 found, addressed)

  • [code-reviewer] Shallow clone (fetch-depth: 1 default) may not fetch the git-annex branch needed by enableremote.

    • Fix: Added fetch-depth: 0 to the checkout step.
  • [error-handler] Two separate workflow steps created a partial-failure window (enableremote succeeds, push fails).

    • Fix: Combined into a single step.
  • [error-handler] No console.error in the s3_public_read catch block for server-side observability.

    • Fix: Added console.error with [publish] prefix.
  • [code-reviewer] git push origin git-annex permissions with GITHUB_TOKEN.

    • Note: GITHUB_TOKEN has write permissions by default in GitHub Actions. Branch protection applies to main only (tag protection is separate). No action needed.

Suggestions (3 found, partially addressed)

  • [comment-analyzer] Duplicate "Step 4" and misnumbered steps (5 should be 12, 13 should be 14).

    • Fix: Corrected all step comment numbers.
  • [error-handler] Consider read-back verification after addPublicReadPolicy.

    • Note: Deferred. S3 bucket policy propagation is near-instant in same-region. The function already throws on HTTP failure.
  • [comment-analyzer] Missing AWS_DEFAULT_REGION in enableremote step.

    • Note: Not needed. Region is stored in git-annex remote config from initremote.

Strengths

  • s3_public_read step follows the exact orchestrator pattern
  • addPublicReadPolicy is idempotent and resume-safe
  • Three-way consistency between PublicationStep type, allSteps array, and JSDoc

@neuromechanist
neuromechanist merged commit 9f7f73c into dev Feb 7, 2026
7 checks passed
@neuromechanist
neuromechanist deleted the 101-configure-git-annex-public-s3-remote-on-dataset-publication branch February 7, 2026 18:45
@neuromechanist neuromechanist mentioned this pull request Feb 11, 2026
2 of 5 tasks
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