Skip to content

feat(commit): make createTree chunking payload-size aware - #35

Merged
c-vigo merged 1 commit into
mainfrom
feature/22-createtree-payload-chunking
Jul 14, 2026
Merged

c-vigo merged 1 commit into
mainfrom
feature/22-createtree-payload-chunking

Conversation

@c-vigo

@c-vigo c-vigo commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Summary

createTreeChained chunked by entry count only (TREE_ENTRY_CHUNK_SIZE = 100), so a chunk of many large inline text files could approach GitHub's ~100 MB request-body limit. This adds payload-size awareness and a per-file blob-fallback.

Closes #22.

Changes

  • Byte-aware chunking — new exported TREE_ENTRY_BYTE_LIMIT = 6 MiB. createTreeChained rewritten from a fixed-stride slice loop to an accumulating loop with a flush() helper: a chunk ends when adding the next entry would breach either the count cap or the byte budget (whichever first). Empty-chunk guard ensures a single oversized entry still makes progress. Chaining semantics (each chunk's tree SHA → next base_tree) unchanged.
  • Per-file threshold — new exported INLINE_CONTENT_SIZE_LIMIT = 1 MiB. Text files larger than this go through createBlob (base64) instead of inline content.
  • estimateEntrySize — safe over-approximation (64 B overhead + path + content/sha bytes).

Tests

  1. 4× 2.5 MiB text files (under the count cap) split at 2 entries/chunk purely on the byte budget → 2 createTree calls, correct base_tree chaining, createBlob never called.
  2. One text file at INLINE_CONTENT_SIZE_LIMIT + 1 → routed through createBlob, tree entry carries sha not content.

Verification

  • npm test: 82 passed (3 suites); tsc + ncc build ok, dist/ committed; pre-commit green.

⚠️ Merge sequencing (conflicts with #34)

Both this and #34 (retry granularity, issue #24) rewrite createTreeChained. Recommend merging #34 first, then rebasing this branch and re-threading the retry? param so the createTree call inside the new flush() is wrapped via callWithRetry. No overlap outside createTreeChained/createTree.

Refs: #22

Chunk tree entries by approximate serialized byte size in addition to
the existing entry-count cap, starting a new createTree request once a
chunk nears TREE_ENTRY_BYTE_LIMIT (6 MiB) so many large inline text
files cannot produce an oversized request body. Route text files above
INLINE_CONTENT_SIZE_LIMIT (1 MiB) through createBlob instead of inlining
their content, further bounding request size.

Refs: #22
@c-vigo
c-vigo force-pushed the feature/22-createtree-payload-chunking branch from 2ad2dd7 to d2b2541 Compare July 14, 2026 08:25
@c-vigo
c-vigo merged commit a5631ca into main Jul 14, 2026
7 checks passed
@c-vigo
c-vigo deleted the feature/22-createtree-payload-chunking branch July 14, 2026 08:25
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.

Enhance createTree chunking: payload-size awareness and per-file threshold

1 participant