Skip to content

fix(sync): read a payload's gzip as exactly one member with no flags - #1847

Open
A-EDev wants to merge 1 commit into
mainfrom
fix/sync2-payload-one-gzip-member
Open

A-EDev wants to merge 1 commit into
mainfrom
fix/sync2-payload-one-gzip-member

Conversation

@A-EDev

@A-EDev A-EDev commented Nov 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

Follows flow-sync #102, spec/crypto.md: a payload's body is exactly one gzip member, starting 1f 8b 08 00, with a correct CRC-32 and length and nothing after it.

GZIPInputStream reads through further members and accepts optional header fields, so decodePayload no longer uses it. It now checks the first four bytes of the fixed 10-byte header, inflates with Inflater(nowrap = true), computes the CRC32, checks the stream ended exactly where the 8-byte trailer starts, and checks the trailer. The 64 MiB stop stays.

Hand-rolled framing, as AGENTS.md asks me to say: I checked java.util.zip and the other libraries on the classpath, and none reads gzip this strictly. Only the fixed header and trailer are read by hand; inflating and the CRC stay in the library. flow-sync's spec and the approved design ask for this shape.

Vectors: payload.json comes byte for byte from flow-sync #102 (345a836), with its README row. FLOW-SYNC/1's sync/protocol/SyncCodec.kt isn't part of this and keeps GZIPInputStream.

Related issue

None. Follows flow-sync #102, which should land first.

Change type

  • Bug fix
  • Feature
  • Refactor or maintenance
  • Build, packaging, or CI
  • Documentation

Validation

All Gradle commands ran with --offline -Dorg.gradle.jvmargs="-Xmx4096m -XX:MaxMetaspaceSize=1024m -Dfile.encoding=UTF-8 -Djava.net.preferIPv6Addresses=true".

  • :app:testGithubDebugUnitTest --tests 'io.github.aedev.flow.sync2.*': 307 tests, 0 failed, three runs on nearly this code. An earlier run had one failure, LanSyncTest.a_device_that_is_not_a_member_is_refused_at_the_hello, a one-minute wait that ran out while other builds ran on this machine. It passed in all the runs after it. I don't know the cause.

  • ktlintCheck: exit 0.

  • Before the change, VectorsTest.payloads failed on the new vectors.

  • New PayloadTest (6): the encoder's output reads back, including empty and 1 MiB of random bytes; its header starts 1f 8b 08 00, which proves FLG 0 from this JVM's GZIPOutputStream; 64 MiB reads and one byte more is refused; short bodies, a stream that isn't deflate and a stream cut off are refused.

  • Each of these made a test fail when tried: header start, short body, stream end, CRC, length, the 64 MiB stop, a stalled inflate, and corrupt deflate not mapped to the payload error.

  • ./gradlew :app:assembleGithubDebug: not run locally, CI builds it.

  • ./gradlew :app:testGithubDebugUnitTest: full suite not run locally, CI runs it.

  • I ran any additional flavor-specific build or test tasks affected by this change.

  • I manually tested the affected behavior on an Android device or emulator: not done.

Test device and Android version: none. The tests use the JVM's java.util.zip, not Android's. Whether Android's GZIPOutputStream also writes FLG 0 hasn't been run; flow-sync's design says so from reading. If it didn't, this device's own objects would be refused, so a device run before a release is worth it.

Risk and compatibility

Anything an honest app writes still reads. No nightly note: nothing an honest group sees changes. The vector README also changes in the other open PRs that follow flow-sync.

  • The change does not introduce secrets, private data, or unexpected telemetry.
  • New user-facing text uses Android string resources. (None added.)
  • Dependency and lockfile changes are intentional and limited to this PR.
  • Room schema changes include the required version bump and migration, or this PR does not change the Room schema.
  • Breaking changes and upgrade steps are clearly documented. (None.)

Copilot AI balanced review requested due to automatic review settings November 7, 2026 18:23

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Nov 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants