Skip to content

feat(pm-console): keep the signed Android build at the edge - #12723

Merged
dezren39 merged 6 commits into
mainfrom
claude/pm-apk-edge
Nov 23, 2026
Merged

dezren39 merged 6 commits into
mainfrom
claude/pm-apk-edge

Conversation

@dezren39

@dezren39 dezren39 commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Why

The signed Android build was downloaded from the laptop alone (/console/pm-console.apk), so with the laptop away the download failed (#12521, second item).

What changes

  • The laptop's report describes its build: fingerprint, size, date. The fingerprint is worked out again only when the file changes.
  • The edge asks for a build it does not have; the next report carries it, once. The edge keeps it only if its size and SHA-256 are the ones described.
  • The download is served from the edge's copy when that copy is the laptop's newest build, or when the laptop has not reported for a minute. Otherwise it is passed to the laptop, which has the newest.
  • The app says when the copy it would hand out is older than the laptop's newest build.
  • Still only for the signed-in owner.

Also in this PR: the design record and the living plan are brought up to date with this session's changes and what is still open.

Checks

  • bun test: 150 pass. New: no build, nothing asked; described, asked for, sent once, not sent again; served from the edge byte for byte without asking the laptop; served after an edge restart with the laptop away; a newer build makes the copy say it is older, the download goes to the laptop meanwhile, and the next report replaces the copy; a build that does not match its fingerprint is not kept and is asked for again; a build too large to carry is never read to be sent; the laptop's description of the file, with the fingerprint worked out separately.
  • Six planted faults; five are caught. The sixth removes the laptop's size check, which the edge's own check of the description duplicates, so the outcome is the same.
  • wrangler deploy --dry-run bundles (140 KiB); bun run src/server.ts --check passes.

Not checked

  • In a deployed Worker: a 512 KiB binary value in the Durable Object's storage. It is under the documented 2 MB limit for SQLite-backed objects, and the existing mirror already stores values of that order as text. The first real report after this merges will show it: the copy's presence is visible to the owner as androidBuild in /console/api/me.

Refs #12521.


Generated by Claude Code


Proof this PR
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

The download came from the laptop alone, so with the laptop away it
failed. The laptop's report now describes its build (fingerprint, size,
date); the edge asks for a build it does not have, the next report
carries it, and the edge keeps it only if it is the build described.
Nothing is sent again until the build changes.

The edge serves its copy when it is the laptop's newest build or when
the laptop is not there to ask, and otherwise passes the download to
the laptop. The app says when the copy it would hand out is older than
the laptop's newest.

Five of six planted faults are caught; the sixth removes one of two
size checks that each stop an oversized build on their own.

Refs #12521.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YLT5K1QVuzZjfWGFhXSSNF
…still open

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YLT5K1QVuzZjfWGFhXSSNF
@dezren39
dezren39 requested a review from a team as a code owner November 23, 2026 00:04
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 40 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 145ba7ae-9ce5-4169-ba1d-04fb8491f54e
Commits

Reviewing files that changed from the base of the PR and between 7e3c3bd and d7078f0.

Files selected for processing: 9

  • doc/2026-11-22T11-10-00Z_architecture_pm_console_edge/2026-11-22T11-10-00Z_architecture_pm_console_edge.md
  • planning/plans/2026-11-21_results-first.md
  • pm-stack/console/edge/src/edge.ts
  • pm-stack/console/public/app.js
  • pm-stack/console/src/edge-proto.ts
  • pm-stack/console/src/server.ts
  • pm-stack/console/src/sync.ts
  • pm-stack/console/test/edge.test.ts
  • pm-stack/console/test/signin.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T00:13:28.667476Z 29c7497 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.

… build

So that the copy's arrival at the deployed Worker can be checked from
outside, like the laptop's commit.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YLT5K1QVuzZjfWGFhXSSNF

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 29c74971db

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread pm-stack/console/src/sync.ts Outdated
sha256: build.sha256,
size: build.size,
at: build.at,
...(this.want.has("apk") ? { data: Buffer.from(await build.read()).toString("base64") } : {}),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Budget the APK against the complete sync payload

When an APK-requested report also contains large changed sections, adding the APK can permanently stall synchronization. A permitted 5 MiB APK becomes about 6.67 MiB of base64, leaving less than 1.34 MiB for everything else under the edge's 8 MiB SYNC_LIMIT. Large sections are supported—the existing large-section test constructs roughly 3.2 MB of questions. After the resulting 413, once() retains both want('apk') and the unacknowledged section hashes, so subsequent reports repeat the oversized combination rather than making progress. Budget the complete encoded request and send the APK and sections in separate reports when necessary.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Real. Fixed in the next commit: when the build and the changed sections would together pass what a report may carry (REPORT_ROOM, 7.5 MiB, under the edge's 8 MiB), the build goes alone and the sections, which are not marked sent, follow in the next report. Tested with a 4.9 MB build and three megabytes of questions changed in the same turn: every report is accepted, the build is kept, and the questions arrive whole one report later. Removing the check fails that test with the 413 loop you describe. A separate commit also stops a build the edge cannot keep from being re-sent with every report, and stops a wanted build from putting the laptop on its half-second cadence.


Generated by Claude Code

Comment on lines +894 to +895
const quiet = this.now() - (this.hostSeen ?? 0) >= HOST_QUIET_MS;
if (kept && (kept.sha256 === latest?.sha256 || quiet)) return this.serveApk(kept);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Restore the host timestamp before choosing the APK

If the Durable Object restarts after the laptop announces a newer build but before that build is copied, an APK request can incorrectly receive the older build even while the laptop is available. hostSeen starts as null and is restored from storage only by ready(), but this route returns before the general ready() call below it. Consequently, the quiet check uses zero and bypasses the newer build on the laptop despite a recent persisted report. Call ready() before evaluating this gate.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Real. Fixed in the next commit: ready() runs before the gate, so when the laptop last reported is read back before deciding it is away. Tested: a newer build is announced, the edge restarts before it has a copy, and the download goes to the laptop instead of handing out the older copy. Removing the call fails that test.


Generated by Claude Code

…ry report

If a build did not match its description, or could not be stored, the
edge asked for it again at once, and a missing piece made the laptop
report every half second: half a megabyte, twice a second, for as long
as it kept failing. The edge now asks again no sooner than ten minutes
later, and being asked for the build no longer hurries the laptop.

Three planted faults are each caught.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YLT5K1QVuzZjfWGFhXSSNF
…edge reads back the laptop's last report first

Two review findings on the build kept at the edge:

- A report carrying the build and large changed sections could pass
  what the edge takes in one report; refused as too large, it would be
  built the same way again. The build now goes alone when the two
  would not fit, and the sections follow in the next report.
- After a restart the edge chose which build to serve before reading
  back when the laptop last reported, so a laptop that was there looked
  absent and the older copy was served. It reads that back first.

Both faults, planted again, fail the new tests.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YLT5K1QVuzZjfWGFhXSSNF
@dezren39
dezren39 merged commit e95f556 into main Nov 23, 2026
1 check passed
@dezren39
dezren39 deleted the claude/pm-apk-edge branch November 23, 2026 00:16
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.

2 participants