Skip to content

fix(proxy): bound transfer phases and join owned cleanup - #4613

Open
thymikee wants to merge 4 commits into
mainfrom
t3/4441-proxy-forwarding
Open

thymikee wants to merge 4 commits into
mainfrom
t3/4441-proxy-forwarding

Conversation

@thymikee

@thymikee thymikee commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Summary

Bound proxy-owned transfer forwarding with the adopted 600-second aggregate and 30/30/120-second phases. Preserve early responses, resume offsets, cancellation, owned cleanup and validated transfer-only error details. Covers 10 files and 2,496 gross lines for the proxy layer of #4441; daemon ingress and source-install remain separate.

Transfer classification now shares the proxy admission owner. RPC, health and diagnostics avoid loading transfer mechanics. A later abort or timer during cleanup cannot replace the first failure. The independent foreign-preflight null-body repair is deferred by Decision6930011679; the wire ledger matches base.

Validation

Head f7e0be4925b359639f5a9295d4824fb3cb367792, base ea414582b7faa5153f601180057b07c001e1e37d: pinned setup/build, full format, typecheck and wire scan passed; 165 focused tests passed on Node22.12 and26.11. Six isolated mutants discriminated; prior production fails four of five new regression controls. Claude reviewed the production delta; its ledger/premise findings were corrected.

Exact check:affected --run --base ea414582b7faa5153f601180057b07c001e1e37d --head f7e0be4925b359639f5a9295d4824fb3cb367792 --json: 9 passed/7 CI-owned or parked skips, 385 related and20,211 unit passed/10 skipped; exactCommit=true, checkoutChanged=false, failOpen=false. #4050 retained.

Earlier real-daemon rollback/normal completion and runtime evidence retain their original heads. One intermediate focused operator-cap socket failure remains cause-unproven; unchanged base passed. Old failures remain preserved. New CI is pending; no merge authorization.

@thymikee

Copy link
Copy Markdown
Member Author

Validation receipt for 2d85dcd8e24234310357eedd0ca43dccdf9ce2aa, base ea414582b7faa5153f601180057b07c001e1e37d.

pnpm check:affected --base ea414582b7faa5153f601180057b07c001e1e37d --head 2d85dcd8e24234310357eedd0ca43dccdf9ce2aa --run --json passed with pnpm11.17.0 on macOS/Node26.11.1:9checks passed/7skipped, exactCommit=true, checkoutChanged=false, failOpen=false. Related385tests/83files; full unit20,213passed/10skipped/2,131files. Format, lint, typecheck, layering, Fallow, build and released wire compatibility passed. Wire217declarations, one reviewed compatible preflight change, no added/removed/moved declarations and no protocol bump. Skips retain GitHub/parked-lane authority, including coverage/integration/native obligations; they are not local passes. #4050 full-unit fallback remains.

The focused transport/proxy/shared-owner/real-daemon set passed167tests on Node26.11.1 and Node22.12.0 (explicit --experimental-strip-types for source tests). The corrected import-boundary focused+closure set passed1,070tests. Real HTTP client→actual proxy→actual daemon cases independently prove interrupted-prefix rollback/resume/finalization and a separately preflighted uninterrupted transfer. Tests observe actual persisted bytes/truncation and final ABCDEF, plus308offset semantics.

Nine isolated production counterfactuals fail at intended assertions: remove each of pump/iterator-stop/request-close joins; dispose before owned stop; count drain as byte progress; remove empty-upload or empty-custom-read fairness; extend aggregate; refresh aggregate on a phase change. Every restore matches all11source hashes and passing controls. Three independently held cleanup rows prove settlement/disposal ordering. The drain-only row checks destruction at its original deadline before advancing any rearmed cleanup deadline.

Public built-package probes on Node22.12.0, Node26.11.1 and Bun1.4.2 returned the expected body in60HTTP/HTTPS deliveries. Three Bun route comparisons differ without NODE_USE_ENV_PROXY=1: Fetch uses configured proxies and the default Node adapter goes direct. The README discloses this measured migration; parity is not claimed. Opt-in and NO_PROXY=127.0.0.1 were tested. Eight real-loopback callback-lifecycle probes per runtime cover typed phase/aggregate failures, caller reason identity, early401/413 without input cancellation,204and timer disposal. These deliver actual timer callbacks after I/O boundaries; they do not measure30/120/600elapsed seconds. The final rebuilt package's10dist files match hashes before/after these probes. General runtime/environment compatibility is not inferred.

Independent source/smaller-design, proof, runtime-disclosure and lazy-boundary reviews report no concrete findings at their recorded snapshots. The final candidate matches the accepted source manifest.

Preserved history: earlier controlled-cleanup5000ms failure and weak iterator mutant survival; initial type/setup failures; wrong-base Fallow; corrected complexity/colocation prerequisites; and the exact d3bff gate's eager-closure failure (20,212unitpassed/1failed/10skipped). The latter is fixed by function-scoped transport loading, with no gate waiver. Later receipts do not relabel old failures or prove historical Linux/#4512 causes. No timeout widening, retry, fallback or gate weakening.

This is only the proxy layer of #4441. Ingress/ticket lifetimes and source-install/download propagation remain separate. No device run is required for this HTTP-only change. CI remains authoritative; no merge is requested.

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 6.33 MB 6.33 MB +6.1 kB
Package (unpacked) 6.33 MB 6.33 MB +6.1 kB
Package (download) 1.92 MB 1.92 MB +2.4 kB

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 20.6 ms 26.7 ms +6.1 ms
CLI --help 45.1 ms 62.3 ms +17.2 ms

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 11 files

You’re at about 97% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact contact@cubic.dev.

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread packages/proxy/README.md Resolved
Comment thread packages/proxy/README.md Resolved
Comment thread packages/proxy/README.md Resolved
@apex-sentinel-staging

apex-sentinel-staging Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve

Since the last review: 0 new · 0 still open · 0 no longer raised

No open findings.

Reviewed with this repository's own Sentinel configuration (a30accf38081).

💬 Talking to Sentinel

In a finding's thread, reply with:

Command What it does
@apex-sentinel-staging note <context> Adds context; Sentinel re-checks the cited code
@apex-sentinel-staging pivot <why> Says the finding is wrong; Sentinel re-checks the cited code
@apex-sentinel-staging like Marks the finding as useful
@apex-sentinel-staging dislike <why> Marks it as not useful, so it is not raised again

On this conversation, comment @apex-sentinel-staging review to run a full review once again.

Earlier reviews

Review of 607b3bbc · 16.11.2026 20:29 UTC

Apex Sentinel · ✅ Approve

Since the last review: 0 new · 0 still open · 0 no longer raised

No open findings.

Reviewed with this repository's own Sentinel configuration (ea414582b7fa).

Review of 2d85dcd8 · 16.11.2026 20:11 UTC

Apex Sentinel · ✅ Approve

No open findings.

1 finding below minor hidden (user_settings.min_severity).

Reviewed with this repository's own Sentinel configuration (ea414582b7fa).

@thymikee

Copy link
Copy Markdown
Member Author

Review-round validation at 607b3bbc7fcd68b528f634f99b31bd7723c20ffa (base ea414582b7faa5153f601180057b07c001e1e37d).

Accepted all five Cubic findings. The correction changes only the rollback test and README: standard loopback capability guard before setup; the same two cases via test.for; require a nonempty client error list; qualify preflight response consumption; clarify Bun transfer routing and the separate health limit. Production proxy source is byte-identical to2d85. Claude independently reviewed the exact607b delta and found no new regression.

With AGENT_DEVICE_REQUIRE_LOOPBACK_TESTS=1, typecheck and the two real HTTP cases pass on Node26.11.1, and both cases also pass on Node22.12.0 with --experimental-strip-types. Both focused runs have zero skips. The ECONNRESET is produced by the test client's intentional destroy before a response, not by a proxy reset. Real persisted-prefix rollback,308offset, final bytes and the independent uninterrupted transfer remain separate assertions.

The exact command AGENT_DEVICE_REQUIRE_LOOPBACK_TESTS=1 pnpm check:affected --base ea414582b7faa5153f601180057b07c001e1e37d --head 607b3bbc7fcd68b528f634f99b31bd7723c20ffa --run --json passed9checks/7skips: exactCommit=true, checkoutChanged=false, failOpen=false;385relatedtests;20,213unitpassed/10skipped/2,131files. Full #4050 selection is retained. Old failed receipts and earlier-head runtime/mutation evidence retain their original SHA attribution; no broader cross-runtime replay is claimed for this test/doc-only change. CI at this new head is pending. No merge requested.

@thymikee

Copy link
Copy Markdown
Member Author

The code at 607b3bb has one change to make before merge. CI is green (19 checks, none failing), and there are no conflicts.

The route check in transfer-transport.ts:19 copies the branches of isSupportedUploadRoute and the /artifacts GET branches of isSupportedDaemonRoute (daemon-proxy.ts:588-589, :611-617). Then daemon-proxy.ts:546-548 and :890-891 dynamically import that module only to run the predicate. If someone adds an upload route to isSupportedUploadRoute, the proxy would accept it but forward it over unbounded global fetch, with no phase limits, no aggregate limit and no wire details, and no test would notice. The proxy route table should be the only place that classifies routes. Please define isTransferRoute in daemon-proxy.ts as isSupportedUploadRoute(route, method) or a GET on /artifacts and /artifacts/*, and import transfer-transport.ts lazily only when that is true or when the error is a transfer error.

Not blocking, and you can take or leave these: the preflight 204/205/304 null-body repair is a second fix that the transfer bounds do not need, and it re-spells NULL_BODY_STATUSES inline at daemon-proxy.ts:417, so share the constant or split it out; the HEAD branch at transfer-transport.ts:213 is unreachable in production because only GET is admitted for /artifacts; the mismatch branches in transferWireDetails at transfer-transport.ts:80 cannot fire because this module and the host-kit watchdog always produce those exact values; and fail() at transfer-transport.ts:181-184 classifies, then joins close, then the outer catch at :34 classifies again, so a late caller abort or phase timer during the join could replace an already-classified upstream failure, which classifying once would avoid.

The five inline threads (four on tests and README, one on Bun guidance) all look fixed at this head, so please resolve them: #4613 (comment), #4613 (comment), #4613 (comment), #4613 (comment), #4613 (comment).

The 600s aggregate is a policy choice with no recorded decision on #4441, and it newly caps proxied uploads that the client does not bound in total, so please confirm that choice.

@thymikee

thymikee commented Nov 16, 2026 •

Copy link
Copy Markdown
Member Author

Addressed in f7e0be4925b359639f5a9295d4824fb3cb367792 (one review-round push):

  • Transfer classification now belongs to the proxy admission table. Both forwarding and transfer error projection check that predicate before loading the transport; RPC, health and diagnostics avoid that load.
  • The first classified failure survives later phase expiry/caller abort during joined cleanup.
  • The independent foreign-preflight204/205/304 rewriting repair is split out under #4441 Decision6930011679. Its six dedicated rows and acknowledgment are removed; the entire wire ledger matches base. The existing foreign-preflight bug remains an explicit Align artifact transfer deadlines and stall budgets #4441 residual. Adapter HEAD/null-body handling remains under the adopted contract.
  • Validated transfer detail checks remain: custom transport/authentication errors can reach them. The five earlier inline threads remain resolved.

The600s policy is unchanged and your confirmation6930427053 is noted. Its authority remains Decision6827686874 items3–4 and proxy Decision6876352959.

Claude independently reviewed the production delta without blocking findings. Root corrected its low-severity ledger-byte finding and added the lazy-mock premise. Final focused165/165 pass on both Node22.12.0 and26.11.1, zero skips. All6 isolated routing/loading/precedence mutants are detected and restored; new control5pass, prior production4fail/1pass,49notselected. Real-loopback and earlier runtime receipts retain their original SHA authority.

Exact check:affected --run --base ea414582b7faa5153f601180057b07c001e1e37d --head f7e0be4925b359639f5a9295d4824fb3cb367792 --json, pinnedpnpm11.17 with REQUIRE_LOOPBACK=1:9passed/7CI-owned-or-parkedskips,385related,20,211unitpassed/10skipped; exactCommit=true, checkoutChanged=false, failOpen=false, #4050retained. Wire scan217declarationsunchanged;10files2496gross. Skips are not passes. New CI/review is pending.

One intermediate6873 focused run failed the existing10ms operator-cap socket test (164passed/1failed). Unchanged607b base passed167 and an instrumented candidate passed165; cause remains unproven. The failed receipt remains preserved and no timing, assertion, worker or gate policy changed. New-head passes do not diagnose it. No merge/release/tag is authorized.

Keep transfer selection with proxy admission and load transfer mechanics only for transfer routes. Preserve the first classified failure while owned cleanup joins. Keep the independent foreign-preflight null-body repair outside this layer.
Verify transfer mechanics cannot load in the lazy-boundary control and restore the wire ledger byte-for-byte to base after splitting the independent preflight repair.
@thymikee

Copy link
Copy Markdown
Member Author

Thanks, that settles the 600 s aggregate: the #4441 decision covers it, so no change is needed there. The route-classification change (one owner for transfer routes in the proxy route table) is still the one item before merge at 607b3bb.

@thymikee

Copy link
Copy Markdown
Member Author

This PR is ready at f7e0be4. The findings from the earlier review at 607b3bb (#4613 (comment)) are fixed, and I found nothing new that blocks the merge. Not blocking: the probe at https://github.com/callstack/agent-device/blob/f7e0be4/packages/proxy/src/daemon-proxy-transfer.test.ts#L370 uses a bare .rejects.toThrow(), so any rejection from proxy.handle on /artifacts/x passes it. Asserting .rejects.toThrow('transfer mechanics loaded') would prove the mock is active, and you can take or leave this.

All 19 checks at f7e0be4 pass, and there are no conflicts. The PR body mentions an intermediate operator-cap socket failure with an unproven cause. That is outside this change.

All five open inline threads are fixed at this head, so please resolve them: #4613 (comment) (the test file is not touched by this change), #4613 (comment) (README now says preflight bodies are consumed and a timeout returns HTTP 500), #4613 (comment) (README upstreamTimeoutMs row names the separate five-second /health limit), #4613 (comment) (the errors.length > 0 assertion now precedes the per-error check), and #4613 (comment) (README now matches the opt-in for env proxies). Nothing else needs to happen before merge.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 16, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant