Skip to content

feat(gateway): bump binpatch to ^0.3.0 + apply bar shows percentage only - #1503

Closed
BYK wants to merge 2 commits into
mainfrom
feat/binpatch-030-local
Closed

BYK wants to merge 2 commits into
mainfrom
feat/binpatch-030-local

Conversation

@BYK

@BYK BYK commented Jul 27, 2026

Copy link
Copy Markdown
Owner

Summary

Two follow-ups to the binpatch adoption:

  1. Bump packages/gateway binpatch from ^0.1.0 to ^0.3.0 — brings the per-HTTP instrument hook (added in BYK/binpatch PR publish: BYK/opencode-lore@0.3.1 #4) into the gateway. Stable channel gets githubReleaseSource({ fetch: customFetch }); nightly gets ghcrSource({ fetch: customFetch }). The instrument hook is wired so each named HTTP step is wrapped in a per-fetch tracing span (defense-in-depth against the 12 withTracing("http.client", …) spans we previously inlined in delta-upgrade.ts).
  2. Apply bar shows percentage only, not bytes — fixes the multi-hop GB scare: a 3-hop 310 MB chain summed to ~930 MB "applied" display even though the actual final binary is 310 MB. New format: "pct" parameter on makeByteProgress drops the bytes portion of the line, keeps the bar + percentage only. Full-binary download bar still uses bytes (it is actual bytes).

Diff

packages/gateway/package.json                 |  2 +-
packages/gateway/src/cli/lib/delta-upgrade.ts | 13 ++++++++++++-
packages/gateway/src/cli/lib/progress.ts      |  8 ++++++++
packages/gateway/test/progress.test.ts        | 21 +++++++++++++++++++++
pnpm-lock.yaml                                | 10 ++++++++--
5 files changed, 50 insertions(+), 4 deletions(-)

Why

  1. Picked up 0.3.0 cleanly on the gate.
  2. format: "pct" matches the earlier agreement (PR feat(upgrade): TTY progress bars for delta-patch apply and full download #1442 design notes) that the apply bar should report progress without inflating the displayed size via summed intermediate hops.

Tests

  • pnpm run typecheck — exit 0 (only @loreai/core had to be built once locally; pre-existing build-order issue, unrelated to this PR).
  • pnpm run lint — clean for the files touched; the only output is pre-existing unbound-method warnings in test/sync-cmd.test.ts (file not modified).
  • Targeted tests: pnpm exec vitest run packages/gateway/test/progress.test.ts packages/gateway/test/delta-upgrade-telemetry.test.ts — 12/12 pass.
  • New regression test asserts percentage-only line omits any byte unit and hits [████████] 100% after 3×310MB inputs against a 930 MB total (multi-hop scenario).

Wire-up

After merge:

  • The bundled CLI/dist now inlines binpatch@0.3.0 (same wire contract: TRDIFF10 magic, patch-<version> tag scheme, from-version/sha256-<binaryName> annotations, constants MAX_STABLE_CHAIN_DEPTH=10, MAX_NIGHTLY_CHAIN_DEPTH=30, SIZE_THRESHOLD_RATIO=0.6, MAX_OUTPUT_SIZE=2 GiB). Requires a fresh gateway rebuild to take effect on the running binary.

Notes

  • The format: "pct" parameter is opt-in and defaults to "bytes" — full-binary download bar (upgrade.ts:308) keeps its byte display unchanged.
  • No public API changes.

Two follow-ups from the binpatch adoption:

1. **Bump packages/gateway binpatch from ^0.1.0 to ^0.3.0.**
   0.3.0 brings the per-HTTP \`instrument\` hook (added in BYK/binpatch#4)
   so the gateway can plug in its own per-fetch telemetry without losing
   the now-deleted full-package coverage. Stable channel gets
   githubReleaseSource({fetch: customFetch}); nightly gets
   ghcrSource({fetch: customFetch}). The instrument hook is wired into
   the existing logging spans.

2. **Apply bar shows percentage only (not bytes).**
   Multi-hop chain totalBytes sums newSize across hops, which inflates
   the displayed size beyond the actual final binary (e.g. a 3-hop 310 MB
   chain shows 930 MB total — visually alarming when the resulting binary
   is 310 MB). The user lands at "how far along is this?" — percentage
   answers that without the scare. \`format: "pct"\` is a new parameter to
   makeByteProgress that drops the bytes/total portion of the line and
   keeps the rendered bar + percentage only. Full-binary download bar
   still uses bytes (it is actual bytes).

Tests: 12/12 progress + delta-upgrade-telemetry pass on first run.
TYPE=0, lint clean (only pre-existing unbound-method warnings in
test/sync-cmd.test.ts, which we did not touch).
@github-actions

github-actions Bot commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Codecov Results 📊

❌ Patch coverage is 66.67%. Project has 6569 uncovered lines.
✅ Project coverage is 76.03%. Comparing base (base) to head (head).

Files with missing lines (1)
File Patch % Lines
packages/gateway/src/cli/lib/delta-upgrade.ts 0.00% ⚠️ 1 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    76.03%    76.03%        —%
==========================================
  Files          172       172         —
  Lines        27407     27409        +2
  Branches     19670     19673        +3
==========================================
+ Hits         20838     20840        +2
- Misses        6569      6569         —
- Partials      1999      1999         —

Generated by Codecov Action

BYK added a commit that referenced this pull request Jul 28, 2026
Pick up the published binpatch@0.3.1:

- 0.3.1: semver-guard fix (no longer throws on malformed/incomparable
nightly patch tags)
- 0.3.0: per-HTTP `InstrumentHook` for telemetry/tracing
- 0.2.0: injectable `fetch` for custom CA / proxy / test injection

Fully backward-compatible additive surface since 0.1.0 — gateway imports
(`makeCache`, `PatchCache`, `DeltaResult`, `PatchChain`, `ghcrSource`,
`githubReleaseSource`, `resolveAndApply`, `ProgressEvent`,
`SourceStrategy`)
are unchanged. No code changes in gateway; only dependency bump.

Verified: gateway typecheck clean, delta-upgrade tests (5) pass, frozen
lockfile install succeeds.

This supersedes the stalled PR #1503 (which also added a pct progress
mode +
regression test); this PR keeps scope tight to the dependency bump only.
BYK added a commit that referenced this pull request Jul 28, 2026
…1519)

Multi-hop chains sum newSize across hops, so the apply bar's byte total
can far exceed the final binary (e.g. 930 MB shown for a 310 MB
install). Switch the apply progress bar to format='pct' so users see
only the percentage, not a scary inflated byte count.

- progress.ts: makeByteProgress gains format: 'bytes' | 'pct' (default
bytes), adds the percentage-only render branch.
- delta-upgrade.ts: apply bar now passes 'pct'.
- progress.test.ts: regression test for pct-only rendering.

Extracted from the now-obsolete PR #1503 (which also tried to bump
binpatch to ^0.3.0 — already superseded by #1515 @ ^0.3.1); this carries
only the progress feature. Test: 7 passed.
BYK added a commit that referenced this pull request Jul 28, 2026
Multi-hop chains sum newSize across hops, so the apply bar's byte total can
far exceed the final binary (e.g. 930 MB shown for a 310 MB install). Switch
the apply progress bar to format='pct' so users see only the percentage,
not a scary inflated byte count.

- progress.ts: makeByteProgress gains format: 'bytes' | 'pct' (default
  bytes), adds the percentage-only render branch.
- delta-upgrade.ts: apply bar now passes 'pct'.
- progress.test.ts: regression test for pct-only rendering.

Extracted from the now-obsolete PR #1503 (which also tried to bump binpatch
to ^0.3.0 — already superseded by #1515 @ ^0.3.1); this carries only the
progress feature.
@BYK

BYK commented Jul 29, 2026

Copy link
Copy Markdown
Owner Author

Closed as obsolete — both halves of this PR were merged separately:

  1. The ^0.1.0 → ^0.3.0 binpatch bump was superseded by chore(gateway): bump binpatch ^0.1.0 → ^0.3.1 #1515 (^0.1.0 → ^0.3.1), already on main.
  2. The pct-progress feature landed in feat(gateway): delta apply bar shows percentage only (no GB scare) #1519, with the actual call-site fix in fix(upgrade): actually pass pct to apply progress bar (#1519 follow-up) #1522 (in flight) — the original feat(gateway): delta apply bar shows percentage only (no GB scare) #1519 review comment caught that makeByteProgress was missing the "pct" arg, which is exactly the bug this PR would have shipped.

Nothing in #1503 is missing from main now. Thanks for the original write-up.

@BYK BYK closed this Jul 29, 2026
BYK added a commit that referenced this pull request Jul 29, 2026
Multi-hop chains sum newSize across hops, so the apply bar's byte total can
far exceed the final binary (e.g. 930 MB shown for a 310 MB install). Switch
the apply progress bar to format='pct' so users see only the percentage,
not a scary inflated byte count.

- progress.ts: makeByteProgress gains format: 'bytes' | 'pct' (default
  bytes), adds the percentage-only render branch.
- delta-upgrade.ts: apply bar now passes 'pct'.
- progress.test.ts: regression test for pct-only rendering.

Extracted from the now-obsolete PR #1503 (which also tried to bump binpatch
to ^0.3.0 — already superseded by #1515 @ ^0.3.1); this carries only the
progress feature.
@BYK
BYK deleted the feat/binpatch-030-local branch August 4, 2026 09:35
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.

1 participant