Skip to content

fix(desktop): retain ZIP contents with extended Zip64 records - #9173

Closed
wunianze666-netizen wants to merge 1 commit into
morluto:mainfrom
wunianze666-netizen:codex/fix-desktop-zip64-locator
Closed

wunianze666-netizen wants to merge 1 commit into
morluto:mainfrom
wunianze666-netizen:codex/fix-desktop-zip64-locator

Conversation

@wunianze666-netizen

Copy link
Copy Markdown
Contributor

Summary

A valid Zip64 archive with an extensible end record can lose its entire desktop state view, or appear empty when extension bytes resemble another end record. Follow the locator's declared frame before the existing fixed-record fallback in both REA and the generated Python reader. This also lets an exported task grade the retained archive correctly.

Found independently through the production readers and a compiled CLI control. No issue was opened only to link the fix.

Problem and expected behavior

On frozen main 98c589e42019b4cc2c3c6aee1f6d2031e2de2441, a 218-byte authored archive containing settings.json is readable by the unwrapped ZIP library, but both desktop readers return not a readable zip archive. The compiled inspect-desktop-application-state reports unreadable seed/end views; export-desktop-application --task exits 1 because the captured end has no view. A fixed-size Zip64 control passes.

The Zip64 end record has a 56-byte fixed header followed by optional opaque extension bytes. Both readers instead assumed the record began exactly 56 bytes before its locator. A record-looking tail inside an extension was consequently treated as the end record and silently reduced a nonempty archive to zero entries. Four regressions fail on the frozen production files: deferred/classic end fields, each with a short extension or a misleading tail.

PKWARE APPNOTE 4.3.14-4.3.15 defines the variable extensible sector, the size excluding the leading 12 bytes, and the locator's record offset. Unknown extension contents must not replace the located directory frame.

Change and scope

Read the fixed fields at the declared Zip64 offset when the complete record fits and ends at its locator. Keep 64-bit pointer/length checks exact before conversion or seeking. The extension stays opaque: no scan or allocation proportional to its length. Retain the existing fixed-record fallback when the declared pointer cannot be used. Reject undersized or overrun frames rather than selecting an unrelated signature.

Both the TypeScript directory owner and exported Python counterpart use the same framing rule; the downstream bounded-directory representation remains unchanged. Existing entry/byte/ratio limits, CRC checks, encryption/compression refusals and cleanup remain in place. The Python test driver now carries the generated program over UTF-8 stdin and preserves its separate JSON input, avoiding the Windows argument-length limit; it uses the installed python command on Windows instead of a Store python3 alias. No production timeout or validation policy changes.

Ordinary passive format correction within the existing desktop view/export boundary; a separate maintainer scope decision is not applicable.

Follow the contribution scope.
Unresolved scope, authority, side effects, or required verification block
integration. Link the required maintainer scope decision for new providers or
capabilities involving target execution, injection, mutation, or protection
recovery; ordinary fixes within existing boundaries may state "not applicable".
Draft PRs may leave the scope decision pending and the readiness and merge checklists
unchecked. Maintainers can help resolve open questions.

Contract and boundary impact

  • Semantic owner and earliest changed stage: zipDirectory.ts and generated _zip_end, before either bounded reader normalizes the directory. The fixed-size-only interpretation is replaced at those owners.
  • Contribution scope fit and linked maintainer decision: ordinary passive parsing fix, not applicable.
  • CLI and MCP/tool-catalog contract: existing CLI state/export shapes, selectors and named inputs remain unchanged; valid archive contents become available. These desktop state/export operations are CLI-only; no new named MCP qualification is claimed.
  • Provider, bridge, target-format, or platform compatibility: Zip64 V1 frame metadata; Windows Node 24.22.1/Python 3.11 exercised. Existing fixed-end and fallback controls remain covered.
  • Evidence, artifact, provenance, or reconstruction contract: exact archive/entry digests, entry order/count and seed bytes retained. Malformed framing keeps the existing unreadable-view outcome.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): caller-selected captured bytes and output directory; no app startup, target execution or new mutation authority. Export still writes only its requested bundle.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs and skills/; edit authored instructions in .agents/skills/reverse-engineer-anything/ and never commit build outputs): no catalog, package, version or dependency change in this PR.

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Four new archive variants assert one exact JSON member in both readers, with the unwrapped ZIP library as a readable-input control. Restoring the frozen production files gives four failed tests; helper/fixture setup remains fixed so failures are the missing/wrong view, not process setup.
  • Additional controls reject three invalid frame lengths, preserve the unusable-pointer fallback, and retain the full existing ZIP suite's damaged CRC, unsupported/encrypted entries, size/ratio/count/depth and structured-document checks.
  • Clean frozen-main compiled CLI: state inspection exits 0 with both views unreadable; task export exits 1 with invalid_request naming the unreadable captured end.
  • Rebuilt fix, same retained bytes: state inspection exposes zoom 1/2 and a complete value change; task export exits 0 and reports failing_on_seed: ["changed"]. The exact newly emitted stdlib reader/evaluator yields seed false / final true with archive bytes unchanged.
  • Limits: authored capture data, no real GUI capture or installed AgentEnv service/container. Executing emitted helpers omits only framework imports and the Notes app class; the original helper/evaluator code is used. No new provider or live-app qualification.

For boundary fixes, identify the applicable boundary regressions
and lifecycle regressions
covered by the evidence above, and explain relevant gaps.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

Revision 9d46ff2216753c5993bbef53f013145025fbdcbc, parent/frozen main 98c589e42019b4cc2c3c6aee1f6d2031e2de2441:

  • node scripts/run-exact-tests.mjs run tests/boundary/providers/desktopZipPython.test.ts src/domain/desktop/appExport.test.ts: 36 passed across the full ZIP and export-producer suites. Four new cases were rechecked after the final test type-narrowing correction; not added to that total. The baseline filter gives 4 failed / 16 name-filtered, not platform skips.
  • npm run build:cached: 3 successful tasks, 1 cached in the final build. Actual compiled state inspection and task export plus exact generated-helper execution pass as above; actual CLI-advertised args/options/globals validate with Ajv2020.
  • npm run check:fast: 2 successful tasks, 0 cached. The first check caught a new raw-control fixture's Entry/FileEntry narrowing error; the explicit file guard corrected it without removing assertions.
  • npm run docs:check: passed, including 9 README consistency cases.
  • npm run verify:test-discovery: all 3,154 test files discovered exactly once. Touched formatting and git diff --check pass.
  • Normal pre-commit format/lint and pre-push check:fast ran; the latter restored 2 matching cached results. Upstream CI for this new revision has not yet been qualified; no earlier head or sibling run is borrowed.

Local source dependencies match the frozen lock, including its already-present GraphQL dependency; the shared older checkout's dependencies were not changed. This PR adds no dependency or package metadata.

Compatibility, safety, and release

  • Breaking changes or migration steps: none; valid Zip64 metadata is accepted and malformed record framing is rejected as unreadable.
  • Real Hopper/Ghidra, browser, or OS coverage: actual Windows compiled CLI, generated stdlib Python and bounded ZIP readers with authored data. No live desktop, architecture host or real provider run.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: unchanged captured-input authority, bounded entry reads, CRC checks and output ownership. No archive member extraction to disk, target startup, decryption, installer or runtime-setting change.

Author readiness

Human owner: @wunianze666-netizen

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-06T17:15:33.279783Z
We couldn’t complete this review. Comment @codex review to try again.
9d46ff2 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@greptile-apps

greptile-apps Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The reviewed changes appear safe to merge.

Summary

Both desktop ZIP readers now follow the declared Zip64 record before trying the existing fixed-record fallback.

  • Desktop ZIP readers keep files in Zip64 archives with extensions.
  • The Python test helper runs generated code through UTF-8 stdin.

No actionable issues were found. Review was source-only; tests were not run. Checking whether another PR supersedes this one was blocked by missing GitHub authentication.

Reviews (2) · Last reviewed commit: "fix(desktop): retain ZIP contents with e..." · Reviewed by Greptile

@CassieFox23

Copy link
Copy Markdown
Contributor

TL;DR: On head 9d46ff2, all 20 tests in the changed test file passed on Node 22.23.4, 24.22.1 and 26.12.1. With the old source files put back, 5 of the 20 tests failed on each Node version. On the head, CI shows PR readiness as completed/failure.

Check Node 22.23.4 Node 24.22.1 Node 26.12.1
Head, tests/boundary/providers/desktopZipPython.test.ts pass: Test Files 1 passed (1); Tests 20 passed (20) pass: Test Files 1 passed (1); Tests 20 passed (20) pass: Test Files 1 passed (1); Tests 20 passed (20)
Red run (old source files put back) fail: Test Files 1 failed (1); Tests 5 failed, 15 passed (20) fail: Test Files 1 failed (1); Tests 5 failed, 15 passed (20) fail: Test Files 1 failed (1); Tests 5 failed, 15 passed (20)

The red run keeps the head's tests/boundary/providers/desktopZipPython.test.ts. It swaps src/domain/desktop/appExportPythonZip.ts, src/domain/desktop/zipDirectory.ts and tests/support/desktopExportPython.ts back to merge base 98c589e.

The same five tests failed on all three Node versions. All five are in tests/boundary/providers/desktopZipPython.test.ts:

  • zip directories in the exported module > reads the located Zip64 extensible record (classic shadow)
  • zip directories in the exported module > reads the located Zip64 extensible record (classic)
  • zip directories in the exported module > reads the located Zip64 extensible record (deferred shadow)
  • zip directories in the exported module > reads the located Zip64 extensible record (deferred)
  • zip directories in the exported module > rejects a Zip64 frame size that does not reach its locator

The PR changes 7 files against the merge base. One is the test file. The other six are docs/desktop-application-export.md, docs/desktop-application-state.md, src/domain/desktop/appExportPythonZip.ts, src/domain/desktop/zipArchive.fixture.ts, src/domain/desktop/zipDirectory.ts and tests/support/desktopExportPython.ts.

CI on the head, read live with gh: GitHub shows mergeable true, state unstable, and not a draft.

  • Workflow runs: CI is completed/success, CodeQL production is completed/skipped, PR readiness is completed/failure, and PR title is completed/success.
  • Check runs: 19 succeeded, including Source tests, Portable tests, Static checks, Build package, CI required and Test shard (1/8) through Test shard (8/8).
  • 24 check runs were skipped.
  • 1 check run failed: Validate author declaration.
  • The commit status PR readiness is failure.

The head is 118 commits behind main c78c8ae.

Not run

  • I did not run the other drivers in tests/support/desktopExportPython.ts against the sys.stdin to StringIO change. Both read stdin only with json.load(sys.stdin).
  • I did not test the sentinels=false fall-through path in zipDirectory.ts and appExportPythonZip.ts. The reject test only uses sentinels=true.
  • I did not merge with current main, c78c8ae.
Test setup
  • Box: Fedora 44 VM (4 vCPUs, 8 GB) on my Nobara 44 PC, Linux 7.2.11
  • Node: 22.23.4, 24.22.1, 26.12.1
  • Head / base: 9d46ff2 / 98c589e (merge base with main)
  • Red run: 9d46ff2 with the changed source files from 98c589e
  • Install: npm ci --offline and npm run test:prepare on Node 24.22.1
Commands
npm ci --offline
npm run test:prepare
xvfb-run -a npm run test:focused -- tests/boundary/providers/desktopZipPython.test.ts

🤖 Written and tested with Claude Code (Sonnet 5.5, verified by Opus 5.5), posted with my OK 🦊

@morluto

morluto commented Nov 19, 2026

Copy link
Copy Markdown
Owner

The declared Zip64 record span now takes precedence over the fixed-record fallback in the host and generated Python readers through #12157. Thanks for the extended-record regression.

@morluto morluto closed this Nov 19, 2026
@morluto morluto added the bug Something isn't working label Nov 22, 2026
@morluto morluto added the area: runtime Process capture and runtime observation label Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: runtime Process capture and runtime observation bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants