Skip to content

fix(daemon): cancel artifact preparation and refresh failed builds - #4175

Merged
thymikee merged 9 commits into
mainfrom
fix/artifact-download-followups
Nov 3, 2026
Merged

thymikee merged 9 commits into
mainfrom
fix/artifact-download-followups

Conversation

@thymikee

@thymikee thymikee commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Summary

Follow up on #4165: directory archives count inventory and download waiters together, so a client disconnect preserves another caller's build. Cleanup/expiry now aborts an inventory-only build once no active download remains, retaining its source until tar settles and then removing it from inventory.

Share typed HTTP disconnect handling across downloads, human-control and RPC; retain observable completion/retry coverage and the maintainer ledger rationales. Thirteen files changed; scope includes the requested helper consumers. Re-registration ownership is unchanged.

Validation

  • Base 47d1ac7e0a76b1c35690b0d3b126b6a05257c2a4 plus final resource tests: 2 failed/17 passed (cleanup and expiry left tar un-aborted); fixed: 19 passed.
  • Tested head 9e4deaeb4d816fb00023755c5006295839bee11e: 99 focused tests passed (57 functional + 42 wire). Mutations detect missing abort, wrong expiry reason and stale cache reuse. Live inventory-only cleanup confirms process exit, deferred deletion, empty listing and 404/RESOURCE_EXPIRED.
  • pnpm format, pnpm check:quick, and foreground affected gate passed. Receipt run-KWPr58: exact commit, unchanged checkout; 17,019 unit passed/1 skipped and 304 related passed.
  • The ledger expiry sentence is verified by the fix; no digest changed. Cubic/Sentinel threads have replies and are resolved.
  • Hosted CI, Coverage, Integration Tests and Apple / Smoke Tests remain GitHub obligations. New-head checks/reviews pending; no known unresolved local defect.

Regression, mutation and live evidence.

@vercel

vercel Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
agent-device-website Ready Ready Preview Nov 2, 2026 8:37pm UTC

Request Review

@thymikee

thymikee commented Nov 2, 2026 •

Copy link
Copy Markdown
Member Author

Validation and regression evidence for 3e079476de2a84b55c8544802a884cbbecd851f0 (follow-up to #4165).

Base: bb960da517cd4e58421b7e144ea1d33da985c164 (origin/main at branch creation). Both checkouts received pnpm install --frozen-lockfile && pnpm build. The base experiment received only the three changed test files. No production fix was present during the red run.

Same focused command for base, fixed source, and each isolated mutation:

pnpm exec vitest run --project unit-core \
  packages/daemon/src/resources/artifact-tracking.test.ts \
  packages/daemon/src/server/downloadable-artifact-http.test.ts \
  packages/daemon/src/server/__tests__/request-diagnostics-http.test.ts \
  packages/daemon/src/server/__tests__/http-server-artifacts.test.ts \
  packages/daemon/src/server/http/daemon-runtime-artifacts.test.ts
  • Base plus regressions: 5 failed, 42 passed. The lone disconnect left the tar signal un-aborted; the disconnected shared waiter created a second stream; a new download inherited RESOURCE_EXPIRED or the already-failed tar error; diagnostics retained application/x-ndjson on a pre-header failure.
  • Fixed source: 47 passed.
  • Remove only res.once('close', cancel): 2 failed, 45 passed (both disconnect regressions).
  • Remove only the aborted-controller check before joining directoryArchivePromise: 2 failed, 45 passed (live-artifact retries inherited RESOURCE_EXPIRED or the previous tar failure).
  • Restore the old failStreamedHttpResponse: 4 failed, 43 passed (pre-header error shape/framing, including the new diagnostics case).
  • Restore all fixes: 47 passed.

The replacement client-abort test waits for source-stat admission and server-side response close. It observes the tar signal, validates the surviving archive contents/length, and counts actual file streams. It does not spy on openDownloadableArtifact or select timers by position. The deadline test captures the download timer by its duration after registration, while the tar seam is held without timers.

The dead post-tar cleanup condition was removed. Sentinel thread r4441374093 remains out of scope: registration describes the source's current owner.

All mutations ran sequentially in one disposable checkout outside app-managed worktrees. That checkout was removed. The implementation checkout was not mutated by the experiments. Test patch SHA-256: f1f7349a03ef9663a3118a62f5cd7e29cfea0baeb7b182e5b1182081ea091bcd; production patch: 31dce091dfb63a4a7afd05ff4a907e2165fe90afbc802cab041f3e2eb530e662.

A cold read of the full diff found no additional issue. No independent sub-agent review was started because this is the implementation sub-agent; Sentinel and Cubic review results are handled below. These edits change artifact HTTP/resource ownership, not device dispatch, capture, interaction, app lifecycle, or native execution.

The first exact-head run run-ONdWL1 at 01c9c43b96402aa86fb6e5a3335d0a16de1ce0c6 failed two wire-ledger assertions (three changed declarations and their stale acknowledgements); 17,003 other unit tests passed. The final gate-only commit updates exactly those three digests and compatibility rationales. ADR 0006 permits implementation-only changes without a protocol bump: released diagnostics clients reject non-200 responses, and artifact clients reject >=400 before treating the body as downloaded bytes. The focused wire suites then passed 42/42.

Live probe at the same production source (Node strip-types, real daemon HTTP server and subprocess runner, an executable tar wrapper that pauses before exec): closed the sole client while preparation was pending; observed the process exited, its archive directory disappeared, and the source remained. A new HTTP download returned 200 with 1,049,363 compressed bytes, its Content-Length matched, the decompressed 1 MiB payload matched, and the source was removed after completion. Probe-owned server, processes and files were cleaned up. No device/session was opened.

Cold review also exercised ordinary tar failure while the original opener was settling. The initial abort-only guard still handed that rejected promise to a new waiter (1 failed, 13 passed in the resource suite). Requiring the shared controller to exist and remain un-aborted fixes both terminal states. The final regressions were repeated on the unchanged base and with individual mutations as counted above. Before/after status and patch snapshots of the implementation checkout matched during the experiments. A passed intermediate receipt run-976nWE belongs only to c80c92ddc85f2722b6422b306ccc3d2c62bd3557, before this extra case; it is not the final head receipt.

Final foreground gate: pnpm check:affected --run --head HEAD passed at 3e079476de2a84b55c8544802a884cbbecd851f0. Receipt run-iEKiPr: status=passed, exitCode=0, exactCommit=true, checkoutChanged=false. All runnable checks passed: format, lint, typecheck, layering, Fallow, build, related tests, full unit suite, released-surface compatibility, docs links and prose. GitHub-authoritative and parked platform lanes remain explicitly skipped locally.

Final receipt counts: 17,006 unit tests passed, 1 skipped; 304 related tests passed. These counts come from the receipt, rather than selection estimates.

Repeated the live probe at the pushed head 3e079476de2a84b55c8544802a884cbbecd851f0: lone preparation cancellation killed the process and removed its archive while preserving the source; retry returned 200 and 1,049,362 matching compressed bytes. A separate two-client shared-build probe observed the first response close while tar stayed alive for the survivor; the survivor returned 200 and 1,049,359 matching compressed bytes. Both sources and probe-owned files/processes were cleaned up. Compression sizes differ because each probe uses a fresh random 1 MiB payload.

Publication status: the remote PR head matches the exact-head receipt. Sentinel and Cubic are in progress; neither has posted review findings or threads yet. Hosted CI is also in progress and is not claimed passed.

@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 5.70 MB 5.70 MB +352 B
Package (unpacked) 5.70 MB 5.70 MB +352 B
Package (download) 1.74 MB 1.74 MB +200 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 31.7 ms 30.4 ms -1.3 ms
CLI --help 59.1 ms 59.4 ms +0.3 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 9 files

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

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

Comment thread test/wire-compat/ledger.json Resolved
@apex-sentinel-staging

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

Copy link
Copy Markdown

Apex Sentinel

Verdict: approve

Since the last review: 3 new · 1 still open · 5 no longer raised

4 finding(s): 2 minor, 2 nit. Verdict: approve.

🟡 Minor (2)

Where Finding
packages/daemon/src/resources/artifact-tracking.ts:386 🆕 An aborted shared build still clears the cached archive a concurrent download is streaming
packages/daemon/src/server/http/response-disconnect-signal.ts:10 🆕 responseDisconnectSignal leaks a caller-supplied abort reason onto the artifact download path
🔵 Nit (2)
Where Finding
packages/daemon/src/server/http-errors.ts:47 🆕 failStreamedHttpResponse now changes content-type to JSON without clearing content-disposition semantics for its other caller
packages/daemon/src/server/http/http-server.ts:454 beginRpcRequestLifetime keeps disconnect state that release() only partially clears

Reply under an inline comment with @apex-sentinel-staging note ... or @apex-sentinel-staging pivot ... to re-check that finding.
Comment @apex-sentinel-staging review on this conversation to run a full review.

Earlier reviews

Review of 47d1ac7e · 02.11.2026 20:24 UTC

Apex Sentinel

Verdict: approve

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

6 finding(s): 2 minor, 4 nit. Verdict: approve.

🟡 Minor (2)

Where Finding
packages/daemon/src/resources/artifact-tracking.ts:425 🆕 A cancelled last waiter can leave a stale directoryArchive in an entry still in the registry
packages/daemon/src/resources/artifact-tracking.ts:489 🆕 HTTP disconnect no longer aborts an in-flight tar: requestArtifactCleanup dropped the abort of the shared archive build
🔵 Nit (4)
Where Finding
packages/daemon/src/server/http/http-server.ts:457 🆕 Removed comment left no replacement for the disconnect-vs-normal-close rule
packages/daemon/src/resources/artifact-tracking.ts:186 🆕 Duplicate already-aborted guard in openDownloadableArtifact is unreachable
packages/daemon/src/resources/artifact-tracking.ts:348 🆕 A cached directoryArchive whose temporary archive is missing is never invalidated, so every later download keeps failing
packages/daemon/src/server/request-diagnostics-http.ts:155 🆕 failStreamedHttpResponse answers a client disconnect as 500 for the diagnostics route
Review of 3d9cacf0 · 02.11.2026 19:03 UTC

Apex Sentinel

Verdict: approve

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

1 finding(s): 1 nit. Verdict: approve.

🔵 Nit (1)
Where Finding
packages/daemon/src/server/downloadable-artifact-http.ts:86 The new res.once('close', cancel) fires on a normal successful close too
Review of 3e079476 · 02.11.2026 18:26 UTC

Apex Sentinel

Verdict: approve

4 finding(s): 1 minor, 3 nit. Verdict: approve.

🟡 Minor (1)

Where Finding
packages/daemon/src/resources/artifact-tracking.ts:338 A build aborted just after its tar succeeds can leave a dead archiveAbortController that blocks every later download
🔵 Nit (3)
Where Finding
packages/daemon/src/resources/artifact-tracking.ts:338 The "build still alive" decision in ensureDirectoryArchive is inferred from an unrelated entry field
packages/daemon/src/resources/artifact-tracking.ts:199 cancelArtifactDownload now forwards caller-supplied abort reasons to the client response
packages/daemon/src/resources/artifact-tracking.ts:199 Client cancellation is reported as RESOURCE_EXPIRED (HTTP 404) because signal?.reason is the only reason passed

@apex-sentinel-staging apex-sentinel-staging 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.

Apex Sentinel: 4 new findings on 3e07947. The verdict and the full list are in the summary comment.

@thymikee

thymikee commented Nov 2, 2026

Copy link
Copy Markdown
Member Author

Final bot round at 57f7ab526c42c70cf657ae269425564969221e86 (implementation 3f1f5c1b215d5ed250cdc5ca1b2c0b79744528e3), following reviewed head 3e079476de2a84b55c8544802a884cbbecd851f0 and #4165.

All four Cubic findings are fixed: successful response close no longer aborts the pipeline, the #2198 compatibility rationale is preserved, the new diagnostics test has its loopback guard, and the shared-download test waits on HTTP request events instead of source stat counts.

Sentinel: the suspected dead-controller blockage was not reproduced. The late-abort test passes on the reviewed artifact-tracking source, and confirms a fresh download and disposal cleanup. The related ownership nit is addressed with one promise/controller build object and identity-checked settlement. Caller abort reasons are normalized to the existing typed request_canceled error before opening or during preparation. Node's default AbortError was not RESOURCE_EXPIRED; tests also prove a caller-supplied RESOURCE_EXPIRED reason/private message cannot be forwarded.

Regression proof in disposable checkouts (each installed with frozen dependencies and built):

  • Reviewed head plus the completed-download regression, same one-file HTTP Vitest command: 1 failed, 14 passed, due to AbortError after a valid 200 archive; fixed 15 passed.
  • Remove normal-completion guard: 1 failed, 14 passed. Remove response-close cancellation: 2 failed, 13 passed. Abort a shared tar on any waiter cancellation: 1 failed, 14 passed. Restored: 15 passed.
  • With final resource regressions on base 44b726bb7b34d2ac18e343740f5ebd23f8de6744 (artifact-tracking source identical to reviewed head), same five-file focused command: 2 failed, 50 passed (raw caller reasons); fixed 52 passed. The late-abort and setup-retry cases already pass on this base.
  • Restore raw caller reasons: 2 failed, 50 passed. Remove failure terminal-state handling: 1 failed, 51 passed. Join aborted builds: 3 failed, 49 passed. Restored: 52 passed.
  • Focused wire suites: 42 passed. pnpm format and pnpm check:quick passed.

Commands:

pnpm exec vitest run --project unit-core packages/daemon/src/server/downloadable-artifact-http.test.ts
pnpm exec vitest run --project unit-core packages/daemon/src/resources/artifact-tracking.test.ts packages/daemon/src/server/downloadable-artifact-http.test.ts packages/daemon/src/server/__tests__/request-diagnostics-http.test.ts packages/daemon/src/server/__tests__/http-server-artifacts.test.ts packages/daemon/src/server/http/daemon-runtime-artifacts.test.ts
pnpm exec vitest run --project unit-core test/wire-compat/wire-compat.test.ts test/wire-compat/wire-mutations.test.ts

All mutations were confined to disposable checkouts, before/after implementation snapshots matched, and the disposable checkouts were removed. A cold read of the final diff found no additional issue; no independent sub-agent was started in this implementation sub-agent. The autosquash preserved the final tree; its range-diff was reviewed. Intermediate passed receipt run-j4kADl belongs only to 44b726bb7b34d2ac18e343740f5ebd23f8de6744, before Sentinel changes.

Final foreground gate: pnpm check:affected --run --head HEAD passed at 57f7ab526c42c70cf657ae269425564969221e86, receipt run-g9UudG (exactCommit=true, checkoutChanged=false, exit 0). 17,011 unit tests passed, 1 skipped; 304 related tests passed. Format, lint, typecheck, layering, Fallow, build, released-surface compatibility, docs links and prose passed. GitHub-owned/parked platform lanes remain explicitly skipped locally.

Live HTTP probes at this head passed: disconnecting during lone preparation exited the subprocess and removed its temporary archive while preserving the source; retry returned 200 with a complete matching 1 MiB payload (1,049,358 compressed bytes). During a shared preparation, the first client disconnected while tar stayed alive for the second; the survivor returned 200 with matching payload/length (1,049,363 bytes). Both probes observed source removal after completion and cleaned up their servers and owned files.

This is the single push for the final bot round. All eight existing review threads have fix commits or evidence-backed dispositions and are resolved. No labels or merge action. New-head hosted CI and automatic bot rechecks remain separate from the local pass. Later nits will receive reasons without another push, as requested.

@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 6 files (changes from recent commits).

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

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

Comment thread test/wire-compat/ledger.json Resolved

@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 1 file (changes from recent commits).

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

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

Comment thread test/wire-compat/ledger.json Resolved
@thymikee

thymikee commented Nov 2, 2026

Copy link
Copy Markdown
Member Author

The code at 3d9cacf has no blocking problem. The Apple / Smoke Tests check is still running and has not failed. That check drives iOS and macOS commands through the local daemon, and this diff only touches the artifact download route, the diagnostics HTTP error path and artifact tracking, so a failure would likely be unrelated. I read the code paths and did not run tests locally. I also did not check the live lone/shared HTTP probes or the check:affected receipt in the PR body. No conflicts.

Not blocking, and fine to take or leave: https://github.com/callstack/agent-device/blob/3d9cacf/packages/daemon/src/resources/artifact-tracking.ts#L235 counts waiters by scanning activeDownloads, but the inventory path (listDownloadableArtifacts -> ensureDirectoryArchive) also joins the same build and is not counted, so a download disconnect during a listing can abort the tar and drop that artifact from the listing. By code trace only, not reproduced. The rule would be: abort the build only when no caller of ensureDirectoryArchive still awaits it. A waiter count on DirectoryArchiveBuild would enforce that. https://github.com/callstack/agent-device/blob/3d9cacf/packages/daemon/src/server/downloadable-artifact-http.ts#L86 is the third inline copy of "abort when res closes before writableFinished" (also in human-control-http.ts and http-server.ts), and this copy already omits the req 'aborted' listener and the typed request_canceled reason. Three mechanisms mark a build as not joinable (https://github.com/callstack/agent-device/blob/3d9cacf/packages/daemon/src/resources/artifact-tracking.ts#L422, the finally in createDirectoryArchive, and the finally in ensureDirectoryArchive). The same-tick "failed" cases in artifact-tracking.test.ts#L88 pin a window the HTTP route cannot reach, while the aborted variants cover a real one. The completion test at downloadable-artifact-http.test.ts#L357 asserts internal pipeline state, and asserting no destroy and no extra release after a 200 would be more observable. The second paragraph of the handleArtifactDownload rationale in test/wire-compat/ledger.json#L261 repeats the "disconnected client receives no new payload" point.

Would it be simpler to give DirectoryArchiveBuild { promise, controller, waiters } and make ensureDirectoryArchive(artifactId, entry, hostEnv, signal?) the only code that counts waiters and clears entry.directoryArchiveBuild? Then cancelArtifactDownload only aborts its own controller, and the activeDownloads scan and the abort-on-failure marker go away. One responseDisconnectSignal(req, res) helper in server/http could also replace the three inline detectors.

Before merge, the Apple / Smoke Tests run needs to finish green.

The earlier inline threads are addressed at this head: cubic-dev-ai's ledger rationale, diagnostics test, request-count gate, writableFinished and failStreamedHttpResponse threads, and the other bot's aborted-build, liveness and request-cancel threads, and they are already resolved: #4175 (comment), #4175 (comment), #4175 (comment), #4175 (comment), #4175 (comment), #4175 (comment), #4175 (comment), #4175 (comment), #4175 (comment). The close-during-final-flush thread does not apply: that close is a real disconnect and nothing reads the outer abort reason, #4175 (comment).

@thymikee

thymikee commented Nov 2, 2026

Copy link
Copy Markdown
Member Author

Maintainer review follow-up to the 2026-11-02 review, based on 3d9cacf0bb1f102b4863c10b3225c49ab8626f3c. Both maintainer ledger commits are preserved. Implementation 6a835090fc05337e4084f352ed4af0fb2ecff12f; tested/pushed head 47d1ac7e0a76b1c35690b0d3b126b6a05257c2a4.

DirectoryArchiveBuild now holds promise, controller, and waiters. ensureDirectoryArchive alone counts callers, cancels a build after its last waiter leaves, and clears its build state. Inventory and downloads both count. Download cancellation only aborts its own controller; the active-download waiter scan, builder finally, and abort-on-failure marker are removed. Cleanup waits for the build to settle before removing its source.

responseDisconnectSignal(req, res) now supplies typed request_canceled cancellation for request aborts and unfinished response closes in artifact downloads, human-control HTTP, and RPC. RPC retains its handler-completed guard and request context. Human-control cancellation behavior is retained.

Same-tick failed-build cases were removed; aborted variants remain, and a real HTTP 500-then-200 test covers retry after tar failure. The completion test observes a valid 200/body, no response destruction and exactly one artifact cleanup before/after expiry/disposal, without pipeline internals. The helper's public signal has separate completed-response coverage. Only the changed handleArtifactDownload wire declaration digest/ack was updated; the repeated disconnected-client sentence was removed while preserving the maintainer rationales.

Red/green and mutations (sequential disposable checkout, frozen install and build):

  • At 3d9cacf with only the new HTTP overlap case: 1 failed, 15 passed. After the download disconnects while inventory waits, the old route returns artifacts: [] instead of the registered artifact.
  • Fixed focused HTTP/resource/helper/human-control/RPC suites: 54 passed. Wire suites: 42 passed.
  • Omit inventory waiters: 1 failed, 53 passed (listing loses the artifact).
  • Cancel the build when any waiter leaves: 3 failed, 51 passed (download/shared/inventory preservation).
  • Abort completed responses: 1 failed, 53 passed (helper public contract).
  • Remove request aborted handling: 1 failed, 53 passed.
  • Replace the typed cancellation with identical plain error text: 4 failed, 50 passed.
  • Restore all fixes: 54 passed.

The regression command on base was pnpm exec vitest run --project unit-core packages/daemon/src/server/downloadable-artifact-http.test.ts. The fixed/mutation command additionally selected artifact-tracking.test.ts, response-disconnect-signal.test.ts, human-control-http.test.ts, http-server-disconnect.test.ts, http-server-rpc-lifetime.test.ts, http-server-boundary-cancellation.test.ts, http-server-rpc-admission.test.ts, and http-server-rpc-handler-failure.test.ts at their owning module paths. The wire command selected test/wire-compat/wire-compat.test.ts and test/wire-compat/wire-mutations.test.ts.

Implementation HEAD/status/patch snapshots were unchanged by the mutations. The disposable checkout was removed. A cold read of the final diff found no additional issue; no independent sub-agent was started in this implementation sub-agent.

Final foreground gate: pnpm check:affected --run --head HEAD passed at 47d1ac7e0a76b1c35690b0d3b126b6a05257c2a4. Receipt run-ZqE42G: status=passed, exit 0, exactCommit=true, checkoutChanged=false. 17,016 unit tests passed, 1 skipped; 304 related tests passed. Format, lint, typecheck, layering, Fallow, build, released-surface compatibility, docs links and prose passed. The runner waited for the live host validation-lock owner; no lock was removed or bypassed.

Live HTTP probes at this head: inventory retained one artifact while the overlapping download disconnected and the real tar process stayed alive; the resulting 1 MiB payload downloaded with matching contents/Content-Length (1,049,365 compressed bytes). Lone cancellation exited tar and removed its temporary archive while retaining the source, then retry succeeded (1,049,361 bytes). A shared download survived its peer disconnect (1,049,367 bytes). Source cleanup was observed after the successful downloads, and all probe-owned servers/files were cleaned up. No device/session was opened.

This is the single push for this maintainer round. No labels or merge action. Hosted CI (including Apple / Smoke Tests, Coverage and Integration Tests) and automatic bot rechecks are pending at the new head; skipped GitHub-owned/parked local lanes are not claimed passed. Later bot nits receive a reason without another push.

@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 9 files (changes from recent commits).

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

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

Comment thread test/wire-compat/ledger.json Resolved

@apex-sentinel-staging apex-sentinel-staging 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.

Apex Sentinel: 5 new findings on 47d1ac7. The verdict and the full list are in the summary comment.

@thymikee

thymikee commented Nov 2, 2026

Copy link
Copy Markdown
Member Author

Inventory cleanup/expiry follow-up at 9e4deaeb4d816fb00023755c5006295839bee11e, based on 47d1ac7e0a76b1c35690b0d3b126b6a05257c2a4.

requestArtifactCleanup preserves active-download deferral. With no active download, it aborts an existing archive build using expiredTenantOwnedEntryError and returns. The source stays until tar settles; the waiter finalizer then clears the build and retries cleanup. Inventory-only cleanup and expiry no longer keep tar/source alive until the build timeout.

Same regression command on base plus final tests, fixed source, and isolated mutations:

pnpm exec vitest run --project unit-core packages/daemon/src/resources/artifact-tracking.test.ts
  • Base 47d1ac7 plus tests: 2 failed, 17 passed, both because cleanup/expiry left tar's signal un-aborted.
  • Fixed: 19 passed. Both trigger cases assert prompt RESOURCE_EXPIRED cancellation, source and partial archive retained before tar settles, removal of source/temp directory after settlement, and an empty inventory.
  • Remove the cleanup abort: 2 failed, 17 passed.
  • Replace the expiry reason with request_canceled: 2 failed, 17 passed.
  • Make cache hits unconditional: 1 failed, 18 passed (missing-archive rebuild).
  • Restore fixes: 19 passed.

The disposable checkout was installed with frozen dependencies and built before the experiment. Before/after HEAD/status/patch state of the implementation was preserved, and the disposable checkout was removed.

Expanded focused validation: 99 passed across resource/download, disconnect-helper, human-control, RPC and wire suites (57 functional + 42 wire tests). pnpm format and pnpm check:quick passed.

The ledger expiry sentence is correct again with the restored canonical reason; no ledger/digest edit was required. The missing-cache contract already passes on 47d1ac7 and proves the existing existsSync/rebuild path. The re-raised publication/cancellation interleaving has no await between the post-tar check and publication; existing late-abort coverage remains green, while a completed cache for a live artifact is intentionally reusable. Diagnostics writes nothing from failStreamedHttpResponse after res.destroyed, so its shared HTTP status mapping is retained. Added the finished-response close comment in the helper and removed the redundant caller-abort guard.

A cold read of the final diff found no additional issue; no independent sub-agent was started in this implementation sub-agent.

Foreground exact-head gate: pnpm check:affected --run --head HEAD passed at 9e4deaeb4d816fb00023755c5006295839bee11e. Receipt run-KWPr58: exit 0, exactCommit=true, checkoutChanged=false. 17,019 unit tests passed, 1 skipped; 304 related tests passed. Format, lint, typecheck, layering, Fallow, build, released-surface compatibility, docs links and prose passed. GitHub-owned/parked platform checks remain explicitly skipped locally.

Live HTTP/subprocess probe: held an inventory-only directory build in a real subprocess tar wrapper, requested cleanup, and observed the source retained until process exit, followed by source/temp archive directory removal. The listing returned artifacts: []; fetching the retired artifact returned 404 / RESOURCE_EXPIRED. Probe-owned server/files were cleaned up. No device/session was opened.

This is the single push for this cleanup round. Both Cubic threads and all six requested Sentinel findings have replies with the fix commit or evidence-backed reasons and are resolved. No labels or merge action. New-head hosted CI and bot rechecks are pending; later bot nits receive reasons without another push.

@apex-sentinel-staging apex-sentinel-staging 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.

Apex Sentinel: 1 new finding on 9e4deae. The verdict and the full list are in the summary comment.

@thymikee

thymikee commented Nov 2, 2026

Copy link
Copy Markdown
Member Author

The code looks good at 9e4deae. The cancelled-build fix and the inventory cleanup/expiry abort from the earlier review are now in place, and the checks show 21 passing, including Apple / Smoke Tests, which was pending before. There are no conflicts. I did not run any tests, and I did not reproduce your live inventory-only cleanup run or the check:affected receipt.

Not blocking, and you can take or leave these: artifact-tracking.ts:346 and :368 add abort guards that cannot fire, because the only caller with a signal already checks it at :208 with no await in between, so one of them can go; no test pins that cleanup or expiry while a download waits on the build must not abort it, so a 'download' variant in the test.each at artifact-tracking.test.ts:20 would guard activeDownloads.size > 0 || at :488; 'a failed archive build permits a later HTTP download to retry' also passes on the base commit, so it is a guard and the fix is really a fresh build after a cancelled build that is still settling; and the ./response-disconnect-signal.ts import in http-server.ts:8 sits above the package imports instead of with the other relative ones.

Of the earlier inline threads, the inventory abort, the ledger sentence, the cleanup root cause and the redundant abort check are fixed at this commit. These do not apply and are already resolved: listener lifetime, because release() removes the listener; missing cached archive, because the existsSync check falls through to a rebuild; disconnected diagnostics 500, because failStreamedHttpResponse returns early on a destroyed response; and abort reason mix-up, because both signals abort only with the request-canceled error. One low-priority doc-wording thread about the failStreamedHttpResponse comment still applies and does not block.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 2, 2026
@thymikee
thymikee merged commit 9fb4584 into main Nov 3, 2026
21 checks passed
@thymikee
thymikee deleted the fix/artifact-download-followups branch November 3, 2026 07:03
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