Title: fix(fleet): /files/write reports offset+len instead of durable size on overlapping replay; fake oracle truncates the temp tail · Issue #14601 · developing-today/code · GitHub
Open Graph Title: fix(fleet): /files/write reports offset+len instead of durable size on overlapping replay; fake oracle truncates the temp tail · Issue #14601 · developing-today/code
X Title: fix(fleet): /files/write reports offset+len instead of durable size on overlapping replay; fake oracle truncates the temp tail · Issue #14601 · developing-today/code
Description: Problem /files/write is documented as offset-idempotent (pkgs/fleet/crates/fleet-proxy/src/files.rs:14-17: "Writes are idempotent at a given offset, so retries are safe"). Both sides of that contract mishandle a write fully interior to t...
Open Graph Description: Problem /files/write is documented as offset-idempotent (pkgs/fleet/crates/fleet-proxy/src/files.rs:14-17: "Writes are idempotent at a given offset, so retries are safe"). Both sides of that contra...
X Description: Problem /files/write is documented as offset-idempotent (pkgs/fleet/crates/fleet-proxy/src/files.rs:14-17: "Writes are idempotent at a given offset, so retries are safe"). Both sides of t...
Opengraph URL: https://github.com/developing-today/code/issues/14601
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"fix(fleet): /files/write reports offset+len instead of durable size on overlapping replay; fake oracle truncates the temp tail","articleBody":"## Problem\n\n`/files/write` is documented as offset-idempotent (`pkgs/fleet/crates/fleet-proxy/src/files.rs:14-17`: \"Writes are idempotent at a given offset, so retries are safe\"). Both sides of that contract mishandle a write fully interior to the existing temp (offset \u003c have, offset+len \u003c have) — i.e. a retry/replay of an already-durable chunk:\n\n1. **Real daemon under-reports** (`pkgs/laptop-agent/src/laptop_agent.py:1505`): `size = offset + len(data)` is the end of *this* write, not the durable temp length `max(have, offset+len)`. Replaying 10 identical bytes at offset 0 of a 100-byte temp returns `{\"size\": 10}` while 100 bytes remain durable. Worse, the client's strict check (`files.rs:516-522`, `written != offset + len`) *passes* on the wrong number (10 == 0+10), so the divergence is silent.\n2. **Fake oracle destroys data** (`files.rs:1242-1248`): `slot.truncate(offset + overlap)` shrinks a 100-byte slot to 10 bytes on the same replay, then reports 10. The oracle that is supposed to pin the daemon's semantics corrupts the transfer it models.\n3. **Fixing (1) alone breaks the client**: once the daemon returns the durable size (100), the strict `written != offset+len` check rejects a benign identical replay (100 != 10). The check must accept the durable size on overlap.\n\n## Repro (file-backed sim of both code paths)\n\nhave=100 temp, replay identical bytes [0,10):\n- real daemon logic: returns 10, durable 100 → MISREPORT (and client check passes)\n- fake oracle logic: returns 10, durable 10 → tail destroyed\n\nNormal sequential/appending writes are unaffected on both sides; the existing `write_idempotency_and_conflict` test only replays the *full* temp (where truncate is a no-op), so neither bug is covered.\n\n## Reachability today\n\nThe shipped `put_stream` never re-sends an interior chunk (resume restarts at temp size, no retry loop), so this is latent in production — but the design explicitly blesses retries, and any retry added on top of this contract hits silent size divergence (daemon) or temp corruption (any harness using the fake).\n\n## Fix shape (suggested, not prescribed)\n\n- daemon `_files_write`: return the durable length (`max(have, offset + len(data))`, e.g. via `f.tell()`/stat after the write) instead of `offset + len(data)`.\n- fake `FakeDaemon` write: only grow — replace unconditional `truncate(offset+overlap)` with extend-only logic (`new_end = max(len, offset+data.len())`), keeping the conflict check.\n- client `put_stream` write check: accept `written == max(offset+len, pre-existing durable)` — at minimum, tolerate `written >= offset+len` when the overlapping bytes matched (the daemon cannot prove the match to the client, so document why >= is safe: a conflicting rewrite is still refused with an error).\n- tests: interior-replay case on both sides (identical replay is a no-op success preserving length; conflicting interior rewrite is refused and preserves the temp).\n\n## Acceptance\n\n- [ ] Identical interior replay returns the durable temp size on the daemon and leaves all bytes intact.\n- [ ] Fake oracle interior replay preserves the slot tail and reports `slot.len()`.\n- [ ] `put_stream` accepts a benign identical replay without failing the transfer.\n- [ ] New regression tests cover interior replay (identical + conflicting) against both daemon and fake.\n- [ ] Full-file replay and resume-from-temp-size behavior unchanged (existing tests still pass).\n\n## Dedupe\n\nSearched open/all issues for `files/write size offset fleet-part`, `put_stream`, `laptop-agent files`: only #5759 (design), #10355 (build verbs), #12193, #11714 (framing) — no duplicate of this size-reporting defect.\n\n\u003c!-- pm-metadata:start -->\n```json\n{\n \"direct_parent\": null,\n \"links\": [],\n \"lineage\": {\n \"design\": null,\n \"roadmap_item\": null,\n \"priority\": null\n },\n \"pm_meta\": 1,\n \"provenance\": {\n \"queue_id\": null,\n \"scheduled_start\": null,\n \"picked_up_at\": null,\n \"work_started_at\": null,\n \"created_at\": \"2026-11-24T20:54:37Z\",\n \"session_id\": \"ses_e5df0bfb09affe4Q17SgmJVueH\",\n \"lane\": null,\n \"host\": \"amd\",\n \"worktree\": \"/home/user/git/code\",\n \"model\": null,\n \"lane_start_issues\": [],\n \"workspace_ref\": {\n \"kind\": \"worktree\",\n \"id\": \"/home/user/git/code\",\n \"repo\": \"developing-today/code\",\n \"branch\": \"main\",\n \"sha\": \"6fd30c93b62a4b6fba19e6444c7d69f343fb93a1\"\n },\n \"auth_subject\": \"oc-code-06\",\n \"stamped_by\": \"fleet 0.1.0 (native)\"\n }\n}\n```\n\u003c!-- pm-metadata:end -->\n","author":{"url":"https://github.com/dezren39","@type":"Person","name":"dezren39"},"datePublished":"2026-11-24T20:54:42Z","url":"https://github.com/developing-today/code/issues/14601"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:25a670b6-7a16-6102-7c08-30d74ad456c6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E2F2:C802B:116D1:17D6E:6B060AD0 |
| html-safe-nonce | 4fe9dcc4572fed255aef68e79c4e7d2c73e91d39b647e0fcb61d9ec10d5289dc |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMkYyOkM4MDJCOjExNkQxOjE3RDZFOjZCMDYwQUQwIiwidmlzaXRvcl9pZCI6IjMwMTg3MjE1MTUyOTU2MDc1MDQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 170fb41f4de27a9bf96ce6dd357d0e8cc87b0265d05b16b98f10c95a1e71cbd4 |
| hovercard-subject-tag | issue:6591210728 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/developing-today/code/14601/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5d67f7b2c2012f0d872e9f31ee46ed0a89fa8bc4265ac200ae8625670611d3af/developing-today/code/issues/14601 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5d67f7b2c2012f0d872e9f31ee46ed0a89fa8bc4265ac200ae8625670611d3af/developing-today/code/issues/14601 |
| og:image:alt | Problem /files/write is documented as offset-idempotent (pkgs/fleet/crates/fleet-proxy/src/files.rs:14-17: "Writes are idempotent at a given offset, so retries are safe"). Both sides of that contra... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dezren39 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 47127d2f2009e000f3401193f8b4163109ac669adad0804de1ee0e6333ca7b9e |
| turbo-cache-control | no-preview |
| go-import | github.com/developing-today/code git https://github.com/developing-today/code.git |
| octolytics-dimension-user_id | 26439447 |
| octolytics-dimension-user_login | developing-today |
| octolytics-dimension-repository_id | 627308783 |
| octolytics-dimension-repository_nwo | developing-today/code |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 627308783 |
| octolytics-dimension-repository_network_root_nwo | developing-today/code |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 0760ea46a027ba5099cdef7abd54f27865eb4f44 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width