Repository navigation
Phase 1: Tree-batched commit helper - #412
Merged
neuromechanist merged 2 commits intoMay 10, 2026
Merged
neuromechanist merged 2 commits into
neuromechanist merged 2 commits into
Conversation
📦 Package PreviewYour package is ready to test! bun install -g nemar-cli@PR412Version: 🤖 Updated on each push. |
Contributor
Author
|
Pushed review fixes in 8d1a234. Addresses all 13 findings from the multi-agent review. Production-code fixes
Test fixes
Comment fixes
Verification
|
neuromechanist
merged commit May 10, 2026
db04d9f
into
feature/issue-406-epic-rate-limit-hardening
1 check passed
4 tasks
This was referenced May 11, 2026
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Introduces
commitFilesAsTree()inbackend/src/services/github.ts, a Git Data API primitive that commits N files in 4 REST calls instead ofcreateOrUpdateFile()'s 2N. Rewrites the three highest-leverage callers and keepscreateOrUpdateFile()for the genuine single-file paths.Closes #407
Part of epic #406
Changes
commitFilesAsTree(repo, branch, files, message, pat)inbackend/src/services/github.ts. Resolves branch head -> creates tree -> creates commit -> fast-forwards ref. 4 calls regardless of N. Retries up to 3 times on 422 ref-conflict (refetching base each attempt).deployWorkflows()rewritten to batch all workflow templates into one commit. Previous cost: 12 REST calls (2 per file x 6 templates) + 6 separate commits. New cost: 4 calls + 1 commit.admin.ts) pickscommitFilesAsTreewhen both.nemar/metadata.jsonand.bidsignorechange, falls back tocreateOrUpdateFilewhen only metadata changes (per the N=1 crossover analysis in the plan).webhooks.ts) does the same. Preserves the existing partial-success error reporting (a failed batched commit reports the same error on bothcommitErrorandbidsignoreErrorso existing API consumers stay compatible).NEMAR_GITHUB_API_URLglobal override so the Bun.serve fake GitHub can stand in forapi.github.com. Read at call time viaglobalThis, no Nodeprocesstypes required, no production behavior change.Tests
test/tree-batched-commit.test.ts(7 tests, all passing, no mocks; uses a realBun.servefake GitHub via the newtest/helpers/fetch-counter.ts):filesarray short-circuits to current SHA with zero writes.deployWorkflowsshape) still makes exactly 4 calls.deployWorkflowsend-to-end: success path, all workflow names returned, exactly 4 calls.deployWorkflowsfailure path: error propagated, emptydeployedlist.Test plan
bun test test/tree-batched-commit.test.ts-> 7/7).tsc --noEmitclean.bun run lint) clean apart from a pre-existing warning insrc/lib/git-annex.ts:120unrelated to this PR.bun test test/admin-restructure.test.ts test/bids-ci.test.ts test/datacite.test.ts-> 144/144 pass).nm099999(nemar admin e2e-test --verbose) — run as part of epic finalization, not per-phase, since the publish flow path is also touched by Phase 3.Out of scope (deferred to later phases per the epic)
admin.ts:3238,admin.ts:3307) — Phase 3 restructures the publish flow itself.getTreeAtRef+getBlobContentwith a single Contents API read — separate optimization, no rate-limit impact.