Skip to content

A ZIP or an Office document cut short loses the share of its files asked for - #239

Merged
donislawdev merged 2 commits into
mainfrom
cut-share-archives
Nov 13, 2026
Merged

donislawdev merged 2 commits into
mainfrom
cut-share-archives

Conversation

@donislawdev

@donislawdev donislawdev commented Nov 13, 2026 •

Copy link
Copy Markdown
Owner

What changes

--damage truncate now cuts the files inside a ZIP, and the parts of a Word, Excel or PowerPoint document, by the percentage asked for. Before, a large archive or document was mostly padding behind its content, so a cut of any share took only padding and every file inside survived.

A file a damage will cut is laid out so the cut lands at the same share of the content as of the whole file:

  • ZIP: an entry of padding, tfg-padding.bin, stands in front of the files (behind any directory entries), and the rest of the padding goes behind them, into the archive comment or a second entry, tfg-padding-end.bin. A compressed archive is laid out as it is written, after a pass that compresses its files into a counter. The writing pass has to free the same number of bytes or it stops with an internal error.
  • Office documents: a padding part, tfg/padding.bin, comes first in the package, and the rest goes behind the parts (tfg/padding-end.bin or the comment).

The files inside are marked with their length, so the manifest's cut always states content_bytes when the cut falls inside them.

Files nothing cuts are byte for byte unchanged.

Measured

  • Share lost at 1 MiB, asked 1 / 50 / 90%: 1.000-1.014%, 50.000-50.006%, 90.001-90.024%. Settings covered: stored, deflate (default and best), AES-256, ZipCrypto, nested directories with directory entries, 5 entries, DOCX entries. Office documents from 4 KiB to 10 MiB: 1.01-1.09%, 50.00-50.05%, 90.00-90.07%.
  • Uncut ZIPs against main: 88 of 88 cases, across 11 settings, give the same bytes.
  • Readers of the whole file laid out for a cut give back what they give back for the uncut file: Python zipfile, 7-Zip 26.05 and bsdtar 3.8.9. For Office documents, also python-docx, openpyxl, python-pptx and LibreOffice. Python's zipfile has no AES, so it refuses AES archives of both kinds alike. A cut file is refused by all of them, which is what an interrupted upload looks like. tar -xf gives back the first half of the file inside a ZIP cut by 50%.

Limits

In a small archive or document, a cut of a few percent can fall in the central directory at the end. The directory is longer than what the cut takes, and the ZIP format puts it last, so every file is kept and the manifest says in: end. The share guard accepts this only for ZIP-based formats, and only when nothing but that end stands behind the content.

Guards

  • zip, docx, xlsx and pptx leave the ratchet of formats that do not yet cut at the share.
  • The map guard allows the smallest padding part at byte 0 when the content would otherwise start the file. Behind the content of a file cut before its last byte, it allows one padding region holding exactly the file's label: a ZIP keeps its label in the archive comment, which closes the file. Each new check has canaries.
  • Broken by hand, each turned the guards red: zip without the split, a compressed archive without the measuring pass, a content mark one byte long, an Office package without the split, docx left out of the formats whose end closes the file, and the map reader without the new padding names.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • ZIP archives and Word, Excel, and PowerPoint documents now better honor requested truncation percentages by removing content from their files or document parts, rather than only adjusting padding.
    • Files unaffected by truncation remain unchanged.
  • Notes
    • For small files, a cut near the end may leave all content intact; this is reported as in: end.

donislawdev and others added 2 commits November 13, 2026 09:52
A package truncate will cut opens with a padding part in front of every
other part, and keeps the rest of its padding behind them as before, so the
cut falls in the parts at the share asked for. Readers find parts through
the central directory, and Python, 7-Zip, bsdtar, python-docx, openpyxl,
python-pptx and LibreOffice read such a package as they read it uncut.

The share guard accepts a cut in the end of a ZIP or a package when nothing
but the central directory stands behind the content: at 1% of a few
kilobytes the directory is longer than what the cut takes. The map guard's
layout for a cut after the first byte allows the smallest padding part
where the content would otherwise start the file.

Uncut packages are byte for byte the same.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An archive a damage will cut is laid out so that the cut takes the share of
the files inside it takes of the archive: an entry of padding in front of the
files, behind the directories, and the rest behind them in the comment or a
second entry, tfg-padding-end.bin. A squeezed archive is laid out as it is
written, after a pass that squeezes its files into a counter, and the
writing pass has to free the same or it stops with a defect. The files are
marked with their length, so a cut inside them always says how much of them
there was.

The map guard allows, behind the content of a file cut before its last byte,
one padding region holding the file's label and nothing else: a ZIP keeps its
label in the archive comment, which closes the file. zip leaves the ratchet
of formats that do not yet cut at the share.

Measuring an archive moves out of zip.go into size.go, and what the
compressor freed out of build into a method of its own. Three mutation
entries the Office cut left without their text point at it again.

Files nothing cuts are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Explain Change →

Walkthrough

ZIP and Office package generators now arrange padding around file content based on the requested cut position. ZIP writing marks content regions and uses distinct trailing filler entries. Guard tests check cut-share behavior and end-region layouts.

Changes: Archive content cuts

Layer / File(s) Summary
Package region mapping
internal/format/archive/streammap.go, internal/format/opc/opc.go
StreamMap supports explicit region lengths. OPC package measurements and writes track content regions and support front and trailing padding parts.
Office package cut settlement
internal/format/opc/cut.go, internal/format/docx/docx.go, internal/format/xlsx/xlsx.go, internal/format/pptx/pptx.go
SettleForACut measures package content and padding overhead to position padding for eligible cuts. Office package planners pass the requested cut position.
ZIP cut measurement and planning
internal/format/zip/zip.go, internal/format/zip/size.go, internal/format/zip/cut.go, internal/format/zip/compress.go
ZIP planning measures archive structure and file regions, records cut and split data, and calculates padding placement. Squeezed archives derive freed-byte counts from child sizes and compressed output.
ZIP cut writing and padding
internal/format/zip/zip.go, internal/format/zip/filler.go, internal/oracle/layout.py
ZIP writing marks file regions and selects front or trailing filler entries. The layout oracle recognizes the added trailing filler names.
Cut layout validation and documentation
internal/guard/*, internal/guard/mutation/entries.py, CHANGELOG.md
Guard tests check cut shares, end-region layouts, and filler labels. Mutation patterns and context roots are updated, and the changelog describes the cut behavior.

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant ZIPPlanner
  participant settleForACut
  participant archiveSize
  participant ZIPWriter
  participant StreamMap
  ZIPPlanner->>settleForACut: settle requested cut position
  settleForACut->>archiveSize: measure archive and content region
  ZIPWriter->>ZIPWriter: settle squeezed archive before build
  ZIPWriter->>StreamMap: mark file content region
Loading

Possibly related PRs

Suggested labels: bug

Merge Risk: Minimal · up to acead

This PR changes how ZIP and Office files are truncated by a requested share. No concrete merge-blocking risk was identified. The only open point is a minor question about how strictly one test guard checks the end-region exception.

Pre-merge checks: Passed 14

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title states the main change: a cut ZIP or Office document now keeps the requested share of its files, which matches the objectives that add share-based truncation for ZIP, DOCX, XLSX, and PPTX. I…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Tests For Changed Behavior Passed The PR changes runtime behavior in Go code under internal/format (zip, opc, docx, xlsx, pptx). It also updates tests that cover that behavior. Test evidence: - Four guard tests changed: cutshare_test.…
No Secrets Or Debug Leftovers Passed The check looks for private AI-agent files, .env files, hardcoded credentials or secrets, private URLs, local absolute paths, machine or user names, internal hosts or IPs, personal e-mails, and left…
No Hardcoded Ui Styling Passed The check applies only when the PR adds or changes GUI code (XAML, Slint, Fyne, Tkinter, WPF). The changed-file inventory for refs/coderabbit/pre-merge-check/base..head lists 18 files. They are Go for…
No Obvious Performance Problems Passed No clear, concrete performance problem found in the changed code. Checked evidence (base refs/coderabbit/pre-merge-check/base, head refs/coderabbit/pre-merge-check/head): - `internal/format/zip/si…
Desktop Robustness Passed The "Desktop robustness" check targets desktop application behavior. This repository is a Go and Python command-line generator of test files. The changed files (internal/format/zip, opc, docx, xlsx, p…
Safe File Parsing Passed The check targets code that reads, imports or exports untrusted files in unsafe ways. This PR changes a test-file generator. It does not add parsing of external input. Evidence: - The changed-file lis…
System Changes Are Reversible Passed The check applies only when the PR adds or changes code that modifies system state (network filters or rules, proxy, firewall, system time, process hooking or injection, Windows services, registry, dr…
Clear User-Facing Text Passed The check applies only when the PR adds or changes user-facing text. This PR does change some, so the check was evaluated. Changed text reviewed: - CHANGELOG.md adds one entry: "truncate cuts the fi…
No Resource Leaks Passed Checked the reviewed diff (base..head, 19 files) for the resource categories named in the check: event handlers, timers, files, streams, processes, handles, HTTP responses, native memory, goroutines/t…
Scope, Duplication And Docs Passed The PR scope matches its title and description. The changed files cover ZIP and Office truncation (format/zip, format/opc, docx/xlsx/pptx planning), with supporting guard tests, mutation entries and t…
Full details: Title check

Explanation

The title states the main change: a cut ZIP or Office document now keeps the requested share of its files, which matches the objectives that add share-based truncation for ZIP, DOCX, XLSX, and PPTX. It is specific and descriptive, and it is within the length limit. The title does not name the change as an addition of a feature, but it still conveys the user-facing behavior clearly.

Full details: Tests For Changed Behavior

Explanation

The PR changes runtime behavior in Go code under internal/format (zip, opc, docx, xlsx, pptx). It also updates tests that cover that behavior. Test evidence: - Four guard tests changed: cutshare_test.go, filemap_test.go, branching_test.go, contextroots_test.go. - cutshare_test.go adds the onlyTheEndBehind helper, the wholeMap helper, and canaries for both the padding and the end-only cases. - filemap_test.go replaces the end-cut check with a layout check and adds canaries for invalid first-end layouts and last-end label mismatches. - No test file was deleted. No t.Skip or equivalent was added. - internal/format has no unit tests at head. The changed behavior is exercised through the guard sweep tests, which were updated. Relaxations of existing assertions: - zip, docx, xlsx and pptx were removed from notYetCutAtTheShare and listedBeforeTheRule. The PR description states this explicitly ("zip, docx, xlsx and pptx leave the ratchet of formats that do not yet cut at the share"). - A cut-in-end exception now applies to ZIP-based formats. The PR description documents it under "Limits", with the justification that the central directory is longer than the cut. - These relaxations are explained in the PR description, so they are not unjustified weakening. Residual gap: the new ZIP/Office logic in cut.go, size.go and cut.go's counterparts has no direct unit tests in the format packages. Coverage relies on guard-level sweeps. This is a design observation, not a violation of the stated criteria.

Full details: No Secrets Or Debug Leftovers

Explanation

The check looks for private AI-agent files, .env files, hardcoded credentials or secrets, private URLs, local absolute paths, machine or user names, internal hosts or IPs, personal e-mails, and leftover debug code. Evidence from the reviewed range (refs/coderabbit/pre-merge-check/base to head, 926 added lines across 18 files): - Changed files: none is a private AI-agent file (CLAUDE.md, CLAUDE.local.md, AGENTS.md, .claude/) or a .env file. - Credentials and secrets: searches for password, secret, token, api_key, private-key headers and AWS-style key IDs found no matches. - URLs, hosts and paths: no added http(s):// URLs, IP addresses, localhost references, or local absolute paths (/home/, /Users/, C:\). The only path-like strings are repository doc references in comments (docs/TRUNCATE-2026-11-11.md), which are not private URLs or local paths. - E-mail and identity: no personal e-mail addresses or machine or user names were added. - Debug leftovers: no fmt.Print*, println!, dbg!, console.log, Console.Write, Debug.Write, breakpoint(), pdb, debugger, pprint, or Python print( calls were added. The added test code uses t.Errorf and t.Fatalf assertions and canary fixtures written to a temp dir, which are not debug output. - Commented-out code and markers: no TODO, FIXME, XXX or HACK markers were added. The added comments are design and rationale notes, not leftover code. The entries.py and layout.py changes only update mutation patterns and filler names. They add no secrets or debug code. The CHANGELOG adds prose only. The PR description's "Generated with Claude Code" line is text, not an agent file, so it is outside this check's failure conditions.

Full details: No Hardcoded Ui Styling

Explanation

The check applies only when the PR adds or changes GUI code (XAML, Slint, Fyne, Tkinter, WPF). The changed-file inventory for refs/coderabbit/pre-merge-check/base..head lists 18 files. They are Go format, guard and test files, plus CHANGELOG.md, internal/guard/mutation/entries.py and internal/oracle/layout.py. None is GUI code. The two Python hits matched only the substring "ui" in "layout" and "mutation" paths. The PR touches no UI, so the check is inapplicable and passes.

Full details: No Obvious Performance Problems

Explanation

No clear, concrete performance problem found in the changed code. Checked evidence (base refs/coderabbit/pre-merge-check/base, head refs/coderabbit/pre-merge-check/head): - internal/format/zip/size.go: archiveSize builds the ZIP structure (headers, names, comment, central directory) and adds file sizes as numbers. It no longer generates file contents. The PR comment reports that this lowers --dry-run cost from 960 ms to 56 ms on a 256 MB archive. This is a performance improvement over the previous behaviour. - internal/format/zip/size.go loops over m.children once, which is linear in entries. internal/format/zip/cut.go measureCut calls archiveSize three times. Each call is linear and is not nested inside a per-entry loop. - internal/format/zip/cut.go settleSqueezedForACut generates every file twice, once in a counting pass and once when writing. This happens only for a squeezed (compressed) ZIP that a damage cuts. The code comment documents it as intended. The second pass is needed because the writer must free the same byte count that the counting pass measured. It is a bounded constant-factor cost on one path, not an O(n²) pattern or a per-item external call. - internal/format/opc/cut.go SettleForACut runs Settle and then measureCut. This is a constant number of passes over the parts. It does not add per-item nesting. - internal/format/archive/streammap.go: the diff only changes the MarkEntry signature and adds MarkNext. The backward byte scans in lastLocalHeader and endRecord are unchanged by this PR. - Office format Plan functions call SettleForACut once per request. No new loops over UI or collections exist. The PR has no UI code. - Guard and test changes add canaries and property checks. These are test-side and are outside the scope of the product performance check. No blocking UI-thread work, unvirtualized collections, per-item expensive queries or processes, or polling was found in the diff. The double compression pass on squeezed cut archives is a known, documented cost. It does not meet the check's "clear, concrete" threshold.

Full details: Desktop Robustness

Explanation

The "Desktop robustness" check targets desktop application behavior. This repository is a Go and Python command-line generator of test files. The changed files (internal/format/zip, opc, docx, xlsx, pptx, archive, and guard/oracle test and mutation files) add truncation layout logic for ZIP and Office files. Checking the diff against each listed concern: - Asset loading relative to the working directory: no asset loading is added. - Settings or data files written non-atomically, or crashes on missing or corrupted settings: no settings or config file handling is added. The only added os.WriteFile call is in internal/guard/filemap_test.go, a test that writes test fixture data. - Culture-sensitive number or date parsing or saving: no such parsing is added. - Long operations without progress or cancel, or without double-execution protection: the added context.Context parameters are plumbing for the existing generator flow. No goroutines or progress UI are added. - Destructive actions without confirmation: none. The new code writes generated output files only. - Background work left running after the window closes: no window or background goroutine is added. - Admin rights, or undisclosed network calls: none found in the added lines. The check does not apply to this change, so it passes.

Full details: Safe File Parsing

Explanation

The check targets code that reads, imports or exports untrusted files in unsafe ways. This PR changes a test-file generator. It does not add parsing of external input. Evidence: - The changed-file list (git diff --name-status) covers internal/format/{zip,opc,docx,xlsx,pptx,archive}, internal/guard and internal/oracle. None of these changes adds a reader for external files. - A grep of added lines for file reads, XML/JSON/YAML/CSV decoding, exec, reflect, gob, unsafe and filepath found only two hits. Both are in internal/guard test code: os.ReadFile(m.path) reads a generated output file, and filepath.Join plus os.WriteFile write a fixed canary name canary-last-end to a temp directory. Neither is product code, and neither takes external input. - Archive entry names are fixed constants (tfg-padding.bin, tfg-padding-end.bin, tfg/padding.bin, tfg/padding-end.bin, the generated txt_0001.txt style names). The new code does not take names from input, so no path-traversal surface is introduced. - The generator writes XML parts through the existing opc writer. The diff adds no new formula-like values to CSV or XLSX, and no new escaping logic. - internal/format/zip/size.go archiveSize measures the archive by counting bytes through a counter writer. It does not allocate the file contents, so it does not add memory pressure on large inputs. - The new panic(...) calls in minimumBytes (size.go) fire on a registration or import-order invariant at startup. They do not fire on input data. The new core.Defect returns in cut.go and filler.go are error returns, not crashes. Nothing in the PR matches the explicit failure conditions. The check does not apply to this generator change beyond the absence of new unsafe parsing.

Full details: System Changes Are Reversible

Explanation

The check applies only when the PR adds or changes code that modifies system state (network filters or rules, proxy, firewall, system time, process hooking or injection, Windows services, registry, drivers). This PR changes file-format generation for --damage truncate. The changed-file inventory covers CHANGELOG.md, internal/format/{archive,docx,opc,pptx,xlsx,zip}, internal/guard/*, and internal/oracle/layout.py. None of these modify system state. A search of the added diff lines for registry, service, systemd, iptables, netsh, proxy, firewall, system time, ptrace, injection, driver, network dial, and os/exec returned no hits. The check is inapplicable, so it passes.

Full details: Clear User-Facing Text

Explanation

The check applies only when the PR adds or changes user-facing text. This PR does change some, so the check was evaluated. Changed text reviewed: - CHANGELOG.md adds one entry: "truncate cuts the files inside a ZIP, and the parts of a Word, Excel or PowerPoint document, by the percentage you set." It names the flag (--damage truncate:missing=50), gives a concrete effect, and states that files nothing cuts stay unchanged. It reuses existing manifest vocabulary (in: end, content_bytes, documented in the base CHANGELOG line 79 and README line 530). It does not add a control, button, icon or tooltip. - The new error text is in core.Defect(fmt.Errorf(...)) calls in internal/format/zip and internal/format/opc, and in panic(...) calls in zip/size.go. These are internal-consistency messages that only a program fault can produce. They follow the repo's existing defect style (e.g. internal/core/records.go). The panic in size.go names the fix ("Check the import order in internal/format/all"). None of these is a raw user-facing failure message that the PR newly exposes. Minor clarity note (non-blocking): the CHANGELOG calls the ZIP end region "the index at its end". The ZIP term is "central directory", and the manifest value is in: end. The term "index" is not used elsewhere in the user docs. Suggested replacement: "In a small file a cut of a few percent can fall in the ZIP central directory at its end, and then every file inside is kept - the manifest says in: end." No failure condition in the custom check is met.

Full details: No Resource Leaks

Explanation

Checked the reviewed diff (base..head, 19 files) for the resource categories named in the check: event handlers, timers, files, streams, processes, handles, HTTP responses, native memory, goroutines/tasks, and unbounded caches, logs or queues. - No goroutines, channels, timers, tickers, subscriptions, process launches, HTTP calls, or registry/SCM/native handles were added. A search of the added Go lines found no such primitives. - No new file handles are opened. The only os. hits are in test code (os.ReadFile, os.WriteFile in internal/guard tests), and those files are closed by the os helpers. - Buffering is bounded. StreamMap.Hold/Release in openFile (zip/zip.go and zip/cut.go), startTheFiles (zip/cut.go), writeStoredFiller (zip/filler.go) and writePaddingPart (opc/opc.go) hold only a local header and release it before file content is written. Padding is streamed through writeFiller, not materialised. The comment padding is capped by commentPaddingLimit. - The new squeezedFiles pass and the extra archiveSize and measureCut calls add CPU and time, but they use a local counter and a per-call MapRecorder. They leave no state that accumulates across calls. - The shut closure from openEntry is skipped on some error returns in openFile. This is an error-path observation only. It holds no OS handle. The write aborts, and the in-memory writer is garbage-collected. The check targets long-running desktop apps. This is a one-shot CLI generator, so the hours-long accumulation concern does not apply. No explicit leak condition from the check is introduced by this PR.

Full details: Scope, Duplication And Docs

Explanation

The PR scope matches its title and description. The changed files cover ZIP and Office truncation (format/zip, format/opc, docx/xlsx/pptx planning), with supporting guard tests, mutation entries and the oracle layout update that the description names ("Each new check has canaries", guard and mutation notes). I found no unrelated refactor mixed in. Docs: the user-visible change is documented in CHANGELOG.md. The diff adds a 7-line "truncate cuts the files inside a ZIP ... and the parts of a Word, Excel or PowerPoint document" entry, which states the new behavior and the in: end case. README.md was not changed. Its damage section (README.md lines 31-35) still says generically that "in some formats a large file is mostly padding beside its content", and does not name ZIP or Office. That wording is hedged and does not state the old ZIP/Office behavior, so it is stale but not false. This is a soft documentation gap, not a clear "not updated" failure, because the CHANGELOG was updated. Duplication: the new opc.SettleForACut sits beside opc.Settle as a layered extension, and the new zip cut/size files extend existing ZIP planning. I found no clear duplicate of existing repository functionality. Breaking changes: MarkEntry gains a length argument and opc.Package gains fields. Both are in internal/ packages, so they are not public API. The manifest gains reporting fields, which the README already describes (content_bytes, in: end). No backward-incompatible public or persisted format change is evident, so no "Breaking changes" section is required. Suggested follow-up (not a failure): in README.md lines 31-35, name the ZIP and Office formats as now cut by share, so the README matches the CHANGELOG.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@coderabbitai coderabbitai Bot added the bug Something isn't working label Nov 13, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional comments: 1

internal/guard/cutshare_test.go-145-145: 1

145-145: Minor · Functional Correctness · Quick win

Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.

Check the cut offset before applying the end-region exception.

onlyTheEndBehind checks the regions after content, not the location of the cut. If an archive incorrectly reports Cut.In == "end" for a cut inside content, this branch clears the failure whenever only end regions follow content. The share calculation is then skipped.

Require the actual cut offset to fall within a positive-length RoleEnd region in the regenerated map. Add a canary with a cut inside content that incorrectly reports "end".

As per path instructions, tests must “check real behavior” and convention guards “must not be weakened or narrowed.”

Source: Path instructions

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI (base), Organization UI (inherited)
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 444c6fe6-c38e-4b7a-928a-008ed425deb8
Commits

Reviewing files that changed from the base of the PR and between b382178 and acead9b.

Files selected for processing: 18

  • CHANGELOG.md
  • internal/format/archive/streammap.go
  • internal/format/docx/docx.go
  • internal/format/opc/cut.go
  • internal/format/opc/opc.go
  • internal/format/pptx/pptx.go
  • internal/format/xlsx/xlsx.go
  • internal/format/zip/compress.go
  • internal/format/zip/cut.go
  • internal/format/zip/filler.go
  • internal/format/zip/size.go
  • internal/format/zip/zip.go
  • internal/guard/branching_test.go
  • internal/guard/contextroots_test.go
  • internal/guard/cutshare_test.go
  • internal/guard/filemap_test.go
  • internal/guard/mutation/entries.py
  • internal/oracle/layout.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Review details

Context from checks skipped due to timeout: 8

  • GitHub Check: part 0
  • GitHub Check: CodeRabbit
  • GitHub Check: test on ubuntu-latest
  • GitHub Check: test on windows-latest
  • GitHub Check: test on macos-latest
  • GitHub Check: reference tools actually installed
  • GitHub Check: coverage gate
  • GitHub Check: linters
Additional context used

Path-based instructions: 13

Applies to text shown to the user (labels, buttons, tooltips, placeholders, dialogs, errors, status messages, empty states, translations).

CodeRabbit configuration file

Files:

  • internal/format/archive/streammap.go
  • internal/format/docx/docx.go
  • internal/format/opc/cut.go
  • internal/format/opc/opc.go
  • internal/format/pptx/pptx.go
  • internal/format/xlsx/xlsx.go
  • internal/format/zip/compress.go
  • internal/format/zip/cut.go
  • internal/format/zip/filler.go
  • internal/format/zip/size.go
  • internal/format/zip/zip.go
  • internal/guard/branching_test.go
  • internal/guard/contextroots_test.go
  • internal/guard/cutshare_test.go
  • internal/guard/filemap_test.go
  • internal/guard/mutation/entries.py
  • internal/oracle/layout.py
Verify tests check real behavior and would fail if the implementation were broken.

CodeRabbit configuration file

Files:

  • internal/guard/branching_test.go
  • internal/guard/contextroots_test.go
  • internal/guard/cutshare_test.go
  • internal/guard/filemap_test.go
These are end-user desktop applications.

CodeRabbit configuration file

Files:

  • internal/format/archive/streammap.go
  • internal/format/docx/docx.go
  • internal/format/opc/cut.go
  • internal/format/opc/opc.go
  • internal/format/pptx/pptx.go
  • internal/format/xlsx/xlsx.go
  • internal/format/zip/compress.go
  • internal/format/zip/cut.go
  • internal/format/zip/filler.go
  • internal/format/zip/size.go
  • internal/format/zip/zip.go
  • internal/guard/branching_test.go
  • internal/guard/contextroots_test.go
  • internal/guard/cutshare_test.go
  • internal/guard/filemap_test.go
  • internal/guard/mutation/entries.py
  • internal/oracle/layout.py
Performance is a known weak spot of these projects.

CodeRabbit configuration file

Files:

  • internal/format/archive/streammap.go
  • internal/format/docx/docx.go
  • internal/format/opc/cut.go
  • internal/format/opc/opc.go
  • internal/format/pptx/pptx.go
  • internal/format/xlsx/xlsx.go
  • internal/format/zip/compress.go
  • internal/format/zip/cut.go
  • internal/format/zip/filler.go
  • internal/format/zip/size.go
  • internal/format/zip/zip.go
  • internal/guard/branching_test.go
  • internal/guard/contextroots_test.go
  • internal/guard/cutshare_test.go
  • internal/guard/filemap_test.go
  • internal/guard/mutation/entries.py
  • internal/oracle/layout.py
Applies only to code that builds or styles a GUI.

CodeRabbit configuration file

Files:

  • internal/format/archive/streammap.go
  • internal/format/docx/docx.go
  • internal/format/opc/cut.go
  • internal/format/opc/opc.go
  • internal/format/pptx/pptx.go
  • internal/format/xlsx/xlsx.go
  • internal/format/zip/compress.go
  • internal/format/zip/cut.go
  • internal/format/zip/filler.go
  • internal/format/zip/size.go
  • internal/format/zip/zip.go
  • internal/guard/branching_test.go
  • internal/guard/contextroots_test.go
  • internal/guard/cutshare_test.go
  • internal/guard/filemap_test.go
  • internal/guard/mutation/entries.py
  • internal/oracle/layout.py
User-facing changelog.

CodeRabbit configuration file

Files:

  • CHANGELOG.md
Domain: test file generator (Go; `tfg` CLI and `tfg-gui` Fyne window over one engine).

CodeRabbit configuration file

Files:

  • internal/format/archive/streammap.go
  • internal/format/docx/docx.go
  • internal/format/opc/cut.go
  • internal/format/opc/opc.go
  • internal/format/pptx/pptx.go
  • internal/format/xlsx/xlsx.go
  • internal/format/zip/compress.go
  • internal/format/zip/cut.go
  • internal/format/zip/filler.go
  • internal/format/zip/size.go
  • internal/format/zip/zip.go
  • internal/guard/branching_test.go
  • internal/guard/contextroots_test.go
  • internal/guard/cutshare_test.go
  • internal/guard/filemap_test.go
  • internal/guard/mutation/entries.py
  • internal/oracle/layout.py
SECURITY, HIGH PRIORITY.

CodeRabbit configuration file

Files:

  • internal/format/archive/streammap.go
  • internal/format/docx/docx.go
  • internal/format/opc/cut.go
  • internal/format/opc/opc.go
  • internal/format/pptx/pptx.go
  • internal/format/xlsx/xlsx.go
  • internal/format/zip/compress.go
  • internal/format/zip/cut.go
  • internal/format/zip/filler.go
  • internal/format/zip/size.go
  • internal/format/zip/zip.go
  • internal/guard/branching_test.go
  • internal/guard/contextroots_test.go
  • internal/guard/cutshare_test.go
  • internal/guard/filemap_test.go
  • internal/guard/mutation/entries.py
  • internal/oracle/layout.py
These apps are QA/developer tools.

CodeRabbit configuration file

Files:

  • internal/format/archive/streammap.go
  • internal/format/docx/docx.go
  • internal/format/opc/cut.go
  • internal/format/opc/opc.go
  • internal/format/pptx/pptx.go
  • internal/format/xlsx/xlsx.go
  • internal/format/zip/compress.go
  • internal/format/zip/cut.go
  • internal/format/zip/filler.go
  • internal/format/zip/size.go
  • internal/format/zip/zip.go
  • internal/guard/branching_test.go
  • internal/guard/contextroots_test.go
  • internal/guard/cutshare_test.go
  • internal/guard/filemap_test.go
  • internal/guard/mutation/entries.py
  • internal/oracle/layout.py
Go code.

CodeRabbit configuration file

Files:

  • internal/format/archive/streammap.go
  • internal/format/docx/docx.go
  • internal/format/opc/cut.go
  • internal/format/opc/opc.go
  • internal/format/pptx/pptx.go
  • internal/format/xlsx/xlsx.go
  • internal/format/zip/compress.go
  • internal/format/zip/cut.go
  • internal/format/zip/filler.go
  • internal/format/zip/size.go
  • internal/format/zip/zip.go
  • internal/guard/branching_test.go
  • internal/guard/contextroots_test.go
  • internal/guard/cutshare_test.go
  • internal/guard/filemap_test.go
Check that documentation matches the actual code in this PR: commands, flags, config keys, file paths, build steps and examples must exist.

CodeRabbit configuration file

Files:

  • CHANGELOG.md
Python code.

CodeRabbit configuration file

Files:

  • internal/guard/mutation/entries.py
  • internal/oracle/layout.py
All code in this repository is written by an AI coding agent (Claude Code).

CodeRabbit configuration file

Files:

  • CHANGELOG.md
  • internal/format/archive/streammap.go
  • internal/format/docx/docx.go
  • internal/format/opc/cut.go
  • internal/format/opc/opc.go
  • internal/format/pptx/pptx.go
  • internal/format/xlsx/xlsx.go
  • internal/format/zip/compress.go
  • internal/format/zip/cut.go
  • internal/format/zip/filler.go
  • internal/format/zip/size.go
  • internal/format/zip/zip.go
  • internal/guard/branching_test.go
  • internal/guard/contextroots_test.go
  • internal/guard/cutshare_test.go
  • internal/guard/filemap_test.go
  • internal/guard/mutation/entries.py
  • internal/oracle/layout.py
Learnings: 3

Common learnings

Learnt from: CR
Repo: donislawdev/TestingFilesGenerator PR: 0
File: coderabbit-custom-pre-merge-checks-unique-id-file-non-traceable-F7F2B60C-1728-4C9A-8889-4F2235E186CA.txt:0-0
Timestamp: 2026-10-27T20:10:07.154Z
Learning: Source excerpt:
Scope, duplication and docs: Warn if any of these is true:
- user-facing behavior, CLI arguments, configuration, build steps or requirements changed
  but README / docs / CHANGELOG (if the project has one) were not updated;
Learning: 2026-11-11T19:16:58.022Z

Learnt from: CR
Repo: donislawdev/TestingFilesGenerator PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2026-11-11T19:16:58.022Z
Learning: Source excerpt:
# Contributing

## What a change has to satisfy

- **Words a user reads are English, with a flat hyphen and no semicolons.** That
  covers the README, the changelog, `--help`, every message, and every comment
  in the code. A test enforces the punctuation.

Applied to files:

  • internal/format/opc/opc.go
  • internal/guard/branching_test.go
Learning: 2026-10-20T18:12:35.072Z

Learnt from: CR
Repo: donislawdev/TestingFilesGenerator PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2026-10-20T18:12:35.072Z
Learning: Source excerpt:
# Contributing

## What a change has to satisfy

- **A file is the size that was asked for, to the byte, or it is an error.**
  Never a size close to it, never a quiet rounding. A batch of ten thousand
  files is not something anybody checks by hand.

Applied to files:

  • internal/format/zip/size.go
Additional comments: 1

internal/format/opc/cut.go: 1

41-42: Data Integrity & Integration

The early return does not omit content_bytes for a cut inside content.

The claim needs an unresolved -1 content region. The no-front branch writes content from byte 0 with length -1. Map fills that length from the next recorded region. The writer marks the central directory and comment after the parts, so the content region has a later mark. The cut is computed over the full recorded map, not the truncated file. A cut inside the content therefore still gets a known content length, and the manifest reports content_bytes.

The early return does drop the measured c.content value, but the map supplies the same length. The proposed change to use Package.Content in the no-front branch would not alter the manifest result.

@donislawdev
donislawdev merged commit 4a725fe into main Nov 13, 2026
34 checks passed
@donislawdev
donislawdev deleted the cut-share-archives branch November 13, 2026 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant