Skip to content

fix(remote): bind client artifact destinations to capture identity - #5301

Closed
thymikee wants to merge 13 commits into
fix/daybreak-android-helper-boundariesfrom
fix/daybreak-client-artifact-destinations
Closed

thymikee wants to merge 13 commits into
fix/daybreak-android-helper-boundariesfrom
fix/daybreak-client-artifact-destinations

Conversation

@thymikee

@thymikee thymikee commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

Closed as superseded by #5338 on the 0.22 remediation line. Continue review and implementation there. Historical validation below remains attributed to its original commits; closure does not claim the replacements are merge-ready.

Summary

Bind remote trace and native perf destinations to the caller's capture ID. Daemon confirmation orders overlapping starts. A confirmed stop retires its capture under the record lock, even if the start reply is still pending. Tenant isolation uses the daemon's session naming rule. This client artifact layer was split from #5246 and is stacked on #5245.

Before / after

  • When a stop completed before its start reply, the late reply could restore the stopped capture. A matching stop confirmation now retires that generation before artifact download.
  • Under tenant isolation, capture and tenant-a:capture used separate records. Start, stop, and close now share a record.
  • Unnamed downloads receive unique filenames. Reusing a saved destination requires a matching capture ID.

Validation

f3f5575200 passed merge-tree and the changed declaration digests matched. Hosted checks pending.

At 55c76abacb, the build and all 54 focused tests passed. The reordered-start regression failed at 1082b8b351. Auth-hook aliases, the protocol-3 decision, and final-head live receipts remain open.

The previous guard job failed Fallow after passing wire compatibility. At 908766ae0b, all 11 perf runtime tests passed. All 20 hosted checks passed at that SHA.

Live HTTP at 27edb93b1c670ca2dec5f1d79595567244e52ea7 passed all four cases on iPhone Duo, iOS 27.1. Built CLI and XCTest runner, loopback proxy with isolated daemon state, and separate client-a and client-b state directories and working directories. Snapshots supplied fixture activity. The first xctrace stop failed. A fresh daemon and a recording interval produced the verified archive.

A: trace start ./saved.adtrace → trace stop
   {"trace":"stopped","outPath":"cwd-a/saved.adtrace"} 174463 bytes
A: trace start → trace stop (twice)
   {"trace":"stopped","outPath":"cwd-a/<unique>.log"} 5143 and 5144 bytes, distinct files
A: perf cpu profile start --kind xctrace --template "Time Profiler" --out ./native.trace
   perf cpu profile stop --kind xctrace
   {"perf":"stopped","outPath":"cwd-a/native.trace"} 1429171 bytes, valid gzip tar
A: trace start ./a.adtrace
B: trace stop ./first.adtrace → trace start ./b.adtrace
A: trace stop → exit 1, {"code":"INVALID_ARGS","details":{"reason":"capture-identity-mismatch"}}
B: trace stop → {"trace":"stopped","outPath":"cwd-b/b.adtrace"} 5386 bytes
Successful capture pairs returned matching clientCaptureId values.

@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 6.78 MB 6.79 MB +8.8 kB
Package (unpacked) 6.78 MB 6.79 MB +8.8 kB
Package (download) 2.07 MB 2.08 MB +3.9 kB

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 27.7 ms 25.6 ms -2.1 ms
CLI --help 51.2 ms 70.0 ms +18.8 ms

Affected plugins

Plugin Installed (including dependencies) Unpacked Download
@agent-device/revyl 181.2 kB → 181.2 kB (0 B) 180.8 kB → 180.8 kB (0 B) 58.6 kB → 58.6 kB (-1 B)
@agent-device/testmu 26.5 kB → 26.5 kB (0 B) 26.2 kB → 26.2 kB (0 B) 9.6 kB → 9.6 kB (0 B)
@agent-device/tizen 99.5 kB → 99.5 kB (0 B) 99.1 kB → 99.1 kB (0 B) 34.9 kB → 34.9 kB (0 B)
@agent-device/webos 98.5 kB → 98.5 kB (0 B) 98.1 kB → 98.1 kB (0 B) 34.6 kB → 34.6 kB (+1 B)

@apex-sentinel-staging

This comment has been minimized.

@thymikee
thymikee force-pushed the fix/daybreak-android-helper-boundaries branch from 114df0f to 7214c93 Compare December 1, 2026 08:03
@apex-sentinel-staging

This comment has been minimized.

@thymikee
thymikee force-pushed the fix/daybreak-android-helper-boundaries branch 2 times, most recently from 278fdec to 65f4412 Compare December 1, 2026 08:34
@thymikee
thymikee force-pushed the fix/daybreak-client-artifact-destinations branch from 0633a50 to 92fab3a Compare December 1, 2026 08:36
@apex-sentinel-staging

This comment has been minimized.

@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: 3 new findings on 92fab3a. The verdict and the full list are in the summary comment.

@thymikee
thymikee force-pushed the fix/daybreak-android-helper-boundaries branch 2 times, most recently from ac0eadf to b6e9bb3 Compare December 1, 2026 09:10
@thymikee
thymikee force-pushed the fix/daybreak-client-artifact-destinations branch from 92fab3a to 887e399 Compare December 1, 2026 09:15
@blacksmith-sh

This comment has been minimized.

@apex-sentinel-staging

This comment has been minimized.

@thymikee
thymikee force-pushed the fix/daybreak-android-helper-boundaries branch from b6e9bb3 to ee8075e Compare December 1, 2026 09:40
@thymikee
thymikee force-pushed the fix/daybreak-client-artifact-destinations branch from 887e399 to 460a8df Compare December 1, 2026 09:43
@thymikee

thymikee commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

At 460a8df, the capture-identity change still has defects in how saved destinations are retired and how downloaded files are written, and the live evidence is missing.

An interrupted start can disable path reuse for the rest of the session. sendCaptureStart adds a pending entry under one lock and removes it under a second lock. If the CLI dies between them (Ctrl-C during a slow trace start, a CI step timeout, or a second lock timeout), the entry stays. Every later stop requires an empty pending list, a later confirmed start removes only its own entry, and only a successful close removes the record. On the base branch, a pathless trace stop or perf ... stop used the start destination. Here, later cycles silently write to a <name>-<uuid> file in the working directory, so the help text is no longer true. A pending entry should block reuse only while it can still settle ahead of the active capture. Can a confirmed start drop all lower-order pending entries, and a confirmed or mismatch-settled stop clear those older than the active one? Please add a test with a start whose send never resolves, followed by a confirmed start and a pathless stop that returns the saved path. The smaller design below removes this state completely. Not verified here: a reproduction; this comes from reading the code.

Live evidence is required before merge, because this change affects the capture start and stop route and remote delivery of trace and native perf artifacts. Against a remote daemon over an HTTP baseUrl, with the built binary at this head: (1) trace start ./t/a.trace, then a pathless trace stop --json, should report the absolute path of ./t/a.trace as outPath, and the file should have bytes; a trace start without a path, then a pathless stop, should write a trace-<uuid> style file in the working directory; (2) a native perf start with --out (Apple perf cpu profile start --kind xctrace --out ./a/app.trace, or Android perfetto perf trace start), then a pathless stop, should land at the --out path; (3) after a client's capture is stopped and restarted from a second state dir, the first client's pathless stop should return capture-identity-mismatch. Please record the commands, device, state dir, and SHA.

A second independent pass found that a remote test archive may replace an existing file. If the requested artifacts root already holds a regular file, the daemon can return a test-artifacts directory archive with an entry of the same name. The tar reader accepts it, and the downloader renames the staged entry over the file on POSIX. The caller chose only the root; the daemon chose the file. Can every archive be extracted inside a new, exclusively created, client-owned suite directory under that root, with entry names confined to it and the new local path reported in the response?

A second independent pass found that generated download names are opened with replacement semantics. A screenshot without an output path registers a millisecond-based name as if the caller had chosen it, so two requests can hit the same file, and an existing symlink is followed. The UUID fallback truncates and, on a failed fetch, removes the destination, and the recording fallback publishes with a replacing rename. Symlinked parent directories are not refused. Can every generated destination, found by tracing each fallback name from preparation to publication, be kept distinct from caller paths, created exclusively without following links under the admitted output directory, retried on collision, and cleaned up only when the download owns it?

A second independent pass found that capture records follow symlinks. A symlinked record file is read through its target, a dangling one counts as absent and is replaced on start, and a symlinked record directory redirects locking, reads, writes and close cleanup. Can every record operation first admit and pin a private directory ancestry, open only regular files without following links, create new records exclusively, and replace or remove only a verified record under the lock?

A second independent pass found that two overlapping pathless stops can both use one saved path. Neither stop reserves the generation at dispatch. If the daemon confirms both, both can read the path before either retires it, and the second download can replace the first artifact. Can the ID check, destination read, and retirement happen in one locked step, so only one caller gets the path?

A second independent pass found that a successful stop can leave its pending start reusable. If a stop is sent while capture A's start reply is delayed, the stop goes unbound and only clears a foreign marker, then the late reply promotes A to a settled record. An active record also survives a successful stop after an uncertain duplicate start made the record unknown. Can reuse stay off while a start is pending, while any successful stop that confirms a tracked ID retires it and a late reply cannot restore it?

A second independent pass found that a killed start process disables reuse for later captures. A process that dies after saving its entry but before dispatch leaves it with no owner or expiry; a later successful start removes only its own entry, so pathless stops ignore the saved path until close or manual cleanup. This is a second route into the interrupted-start problem above. Can dead owners' entries be reclaimed, or capture changes be serialized so a confirmed replacement supersedes abandoned ones?

A second independent pass found that a successful close can leave a capture record behind. If a pending start settles after close takes its snapshot and before the close reply, the changed record survives even though the session is gone. A start registered after the directory scan can also be missed. Can close retire every generation it actually closed, including unconfirmed ones, or serialize the session's capture changes through close, while keeping starts accepted after the old session closed?

A second independent pass found that equivalent session names get different record keys. Under tenant isolation, capture and tenant-a:capture resolve to one daemon session, but the client reads separate records. A pathless stop under the other spelling then downloads to a generated path, where the base branch used the start path, and close misses the original record. Can every supported alias of a session map to one client capture scope?

A second independent pass found that a failed close can leave a retired session's destination live. For a session without a device claim, a cleanup error during close still retires the session, but the client settles only on success, and a later no-active-capture answer does not clear the record either. Can terminal errors carry typed evidence that the session or capture is retired, so the client settles it, and keeps the destination when both are confirmed live for retry?

Would a smaller client design meet the same goal? Keep the daemon half. Keep one record per endpoint, tenant, run, lease, session and family holding {captureId, destination?}. A start mints the ID and overwrites the record under the lock before sending. A pathless stop attaches the ID and reuses the destination only when response.data.clientCaptureId matches, otherwise it uses a unique name. Any successful stop, mismatch refusal, failed or already-active start, or successful close deletes the record if it still holds that ID. This drops the pending list, order counter, certainty states and client-side foreign refusal; concurrent starts become last-writer-wins and fail closed at the daemon, and the interrupted-start problem cannot occur. It could take roughly 100-150 production lines instead of about 430, after the lock, write and key helpers move from script-publication-record.ts into a shared client-record module. The questions above about locking, links, aliases and close would need checking against it too.

Not blocking, so take or leave: share the lock, write and key helpers with script-publication-record.ts; simplify the client state as described above; let close retire an invalid record instead of failing before it is sent; keep the removed security sentence about remote script delivery memory caps and shorten the new lines instead; sweep stale records as the script records do; add a provider-scenario test for a remote trace start with a path and a pathless stop through the HTTP transport; and make the error reason row say the client refuses when its record names another client's live capture, with the help line noting that the daemon must confirm the capture ID.

These earlier threads do not apply and can be resolved: legacy captures, because the client sends an ID only from its own settled record and the daemon compares only a present ID; perf report path, because the base branch never passed it the start destination and report --out still works; report capture matching, because report is a separate plan that is rejected during an active capture and the trace branch matches start/stop parsing.

CI is still pending: 19 checks passed at this head, and the one queued check is not a test job. An earlier failure in the platform-apple native-build/toolchain-identity.test.ts probe was on an earlier head, and this diff does not touch that Apple toolchain probe. Not verified here: test runs, range-diff equivalence, the earlier 94-test claim, CI job logs, and whether a native perf capture re-adopted after a daemon restart keeps clientCaptureId (if it is lost, the first pathless stop would return capture-identity-mismatch once).

Before merge, the interrupted-start problem needs a fix, ideally through the single-record design, the other defects above need to be resolved, and the live remote trace and native perf results need to be attached.

@apex-sentinel-staging

This comment has been minimized.

@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 460a8df. The verdict and the full list are in the summary comment.

Comment thread docs/agents/security.md Resolved
@apex-sentinel-staging

This comment has been minimized.

@thymikee
thymikee marked this pull request as ready for review December 1, 2026 11:06

@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 22 files

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

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

Comment thread website/docs/docs/remote-proxy.md Resolved
Comment thread docs/agents/security.md Resolved
Comment thread packages/daemon-client/src/index.ts Resolved
Comment thread website/docs/docs/remote-proxy.md Resolved
@thymikee

thymikee commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

At ed7b418, one problem from the earlier review still needs a code fix, and the live evidence is still incomplete. The delta since 460a8df changes only security.md and restores the sentence about remote script delivery limits. The code problems remain.

capture-destination-record.ts:283: An interrupted start still disables saved destinations. sendCaptureStart writes a pending {generation, order} under one lock (lines 325-335) and removes it under a second lock after the reply (lines 346-353). Ctrl-C during a slow trace start, a CI step timeout or a lock timeout can leave that entry forever. A later confirmed start removes only its own entry (line 194), while pathless stops require an empty pending list (283, 384). Until a successful close, every later cycle silently writes to a <name>-<uuid> file in the current directory. On the base branch, a pathless trace stop or perf ... stop used the start path. This also makes the CLI help and remote-proxy.md statements false for that session. The rule: an unsettled start may suppress reuse only while it can still settle ahead of the active capture. The preferred fix is one {captureId, destination?} record per scope, overwritten under the lock before send. A pathless stop reuses it only when response.data.clientCaptureId matches, and any terminal outcome deletes it if it still holds that ID. At minimum, a confirmed start should drop all lower-order pending entries, and a confirmed or mismatch-settled stop should clear entries older than the active order. Either way, please add a test where one start send never resolves, a later start is confirmed, and a pathless stop returns the saved path.

capture-destination-record.ts:242: Live evidence is required before merge. The PR body summarizes an iOS simulator run through an isolated HTTP proxy, with returned capture IDs, a trace downloaded into client state and perf at the caller path. It has no commands, device name, state dir or JSON output, and it does not show the pathless trace stop landing at the start path or the second-state-dir mismatch. Please run the built binary at the final head against a remote daemon over an HTTP baseUrl, and record commands, device, state dir and SHA for each case. (1) trace start ./t/a.trace, then a pathless trace stop --json: outPath equals the absolute path of ./t/a.trace and the file has bytes. Then a start and stop without paths: a trace-<uuid> style file appears in the current directory. (2) perf cpu profile start --kind xctrace --out ./a/app.trace (or the Android perfetto trace start with --out), then a pathless stop: the file lands at the --out path. (3) Stop and restart the capture from a second state dir: the first client's pathless stop returns capture-identity-mismatch.

capture-destination-record.ts:330: Please confirm this likely second route into the same problem. A start process killed after it saves the pending entry and before dispatch leaves an entry with no owner or expiry, so reuse stays disabled until close. The single-record design removes this case.

capture-destination-record.ts:55: Please confirm this likely defect. The record key hashes the raw req.session. Under tenant isolation, capture and tenant-a:capture resolve to one daemon session (request-admission.ts:55) but two client records. A pathless stop under the other spelling writes to a generated path instead of the start path, and close misses the original record. Every supported session alias must map to one client capture scope.

A second independent pass found the same interrupted-start regression at capture-destination-record.ts:283. After the abandoned start, a later confirmed start with an explicit destination still leaves the old entry. The next pathless stop sends no saved ID and downloads to a generated filename (daemon-artifacts.ts:765-786). A confirmed start should supersede older pending entries. Keep the generation check on late settlement so a superseded start cannot restore its record.

For a follow-up issue, not for this PR:

  • daemon-artifacts.ts:620: a test-artifacts directory archive can replace an existing file under the requested root, so each archive should extract into a new client-owned directory with names confined to it.
  • daemon-artifacts.ts:364: generated fallback destinations can truncate, replace or remove existing files and follow symlinked parents, so they should be created exclusively.
  • capture-destination-record.ts:429: a start that settles or appears after close takes its snapshot can leave a record behind after a successful close.
  • capture-destination-record.ts:265: a close that retires a session but returns a cleanup error keeps the client records.

These open threads still apply and can be handled without holding the merge: help omits confirmation, proxy docs omit condition, test downloads nothing, mismatch test naming and lock wait abort. One lower-priority thread also still applies. These can be resolved:

CI is green: all 29 checks pass.

Not verified here: the code problems above were not reproduced; they come from reading code that is unchanged since 460a8df, as checked with a diff. The 94-test claim and other local tests were not run. The commands, device, state dir and outputs of the live run could not be checked without a transcript. It also remains unchecked whether a native perf capture re-adopted after a daemon restart keeps clientCaptureId.

Before merge, fix the interrupted-start regression with its test and add the live evidence.

@blacksmith-sh

This comment has been minimized.

@apex-sentinel-staging

This comment has been minimized.

@thymikee thymikee left a comment

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.

Follow-up on the maintainer review at ed7b418. At 27edb93b1c, a start confirmed by the daemon drops lower-order pending entries and retains higher-order attempts. Settlement still requires the pending generation to exist, so a late reply cannot restore a retired path. Tenant-isolated start, stop, and close use the same session naming rule as daemon admission. A tenant label alone does not establish isolation, and the client cannot infer isolation imposed only by the server's auth hook.

The focused capture-record file failed three cases on the previous implementation and passes all 38 tests on this head. It covers explicit paths, state-directory and credential separation, lease scope, cancellation, and tenant alias isolation. The historical archive and generated-file publication and concurrent or failed close handling remain follow-ups from the maintainer review.

Final-head live receipts remain open. On the built CLI through an isolated HTTP daemon, record:

  • trace start ./t/a.trace, an interaction, then trace stop --json. Assert absolute outPath and nonempty output. Repeat without a start path and assert a unique file in the client working directory.
  • perf cpu profile start --kind xctrace --template "Time Profiler" --out ./a/app.trace, then perf cpu profile stop --kind xctrace --json. Assert the absolute caller path and a materialized artifact.
  • Start trace from state directory A. Stop A's capture from B with B's own explicit destination, then start a replacement from B on the same daemon and session. A's pathless stop must return capture-identity-mismatch. Stop from B to confirm its replacement remained active.

The assigned simulator worker should attach commands, device, state directories, exact SHA, JSON and artifact checks. The older live run and hosted smoke results do not cover these final-head cases.

@apex-sentinel-staging

This comment has been minimized.

@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 27edb93. The verdict and the full list are in the summary comment.

@apex-sentinel-staging

This comment has been minimized.

@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 finding moved to a new line on da91932. The verdict and the full list are in the summary comment.

Comment on lines 49 to 57
fs.appendFileSync(outPath, '');
session.trace = {
outPath,
clientCaptureId: req.meta?.captureId,
startedAt: Date.now(),
clientOutPath: req.meta?.clientArtifactPaths?.outPath,
clientOutPath: req.meta?.captureId ? req.meta.clientArtifactPaths?.outPath : undefined,
...(req.internal?.publicNetworkOnly ? { remoteCaptureOutputPath: outPath } : {}),
remoteCaptureTenantId: session.lease?.tenantId ?? req.meta?.tenantId,
};

@apex-sentinel-staging apex-sentinel-staging Bot Dec 1, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No longer raised on 1adba76.

🟡 Minor · Old client's pathless trace stop now receives the daemon's own path as its destination

A released client (no meta.captureId) sends trace start ./saved.adtrace then a pathless trace stop; the stop response returns the daemon's own outPath as artifacts[].localPath instead of the client's destination. clientOutPath is stored only when meta.captureId is present, so for old clients it is never recorded and the fallback falls through to the daemon's path.

Suggested change
fs.appendFileSync(outPath, '');
session.trace = {
outPath,
clientCaptureId: req.meta?.captureId,
startedAt: Date.now(),
clientOutPath: req.meta?.clientArtifactPaths?.outPath,
clientOutPath: req.meta?.captureId ? req.meta.clientArtifactPaths?.outPath : undefined,
...(req.internal?.publicNetworkOnly ? { remoteCaptureOutputPath: outPath } : {}),
remoteCaptureTenantId: session.lease?.tenantId ?? req.meta?.tenantId,
};
session.trace = {
outPath,
clientCaptureId: req.meta?.captureId,
startedAt: Date.now(),
clientOutPath: req.meta?.clientArtifactPaths?.outPath,
...(req.internal?.publicNetworkOnly ? { remoteCaptureOutputPath: outPath } : {}),
remoteCaptureTenantId: session.lease?.tenantId ?? req.meta?.tenantId,
};

Suggested change

Record clientOutPath unconditionally on start and gate only its reuse on capture identity, or add a released-client fallback so a pathless stop still receives its start destination rather than a daemon-host path.

Details

persona: senior-developer, maintainability, javascript

Useful? Reply @apex-sentinel-staging like, or @apex-sentinel-staging dislike <why> if it is not.

Reply @apex-sentinel-staging note ... to add context, or @apex-sentinel-staging pivot ... if it is wrong — I will re-check the cited code.

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.

Checked at 1adba76871 against released v0.21.46. Both advertise RPC protocol 3. The released trace and native perf stop handlers reused the named start destination on a pathless stop. At this head a legacy start lacks the capture ID, so a pathless stop still completes but drops the saved destination. On the public HTTP trace route localPath is omitted, with a filename available for fallback. The destination change remains observable even though the path field is optional. Saving the old path alone would not restore the behavior under the new identity check. Leaving this thread open for a maintainer decision on a typed protocol-3 refusal before finalizing a named capture or a protocol version bump.

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.

55c76abacb fixes start settlement when daemon execution order differs from client reservation order. The protocol-3 case still drops the saved destination for released clients. I left this thread open for the maintainer’s choice between a typed pre-finalization refusal and a protocol bump.

@thymikee

thymikee commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

Fixed the delayed start reply finding at 1adba768715d3789a48e4aafc4775e5ae7ad94ef. A successful stop that names a tracked capture retires it under the record lock before downloading artifacts. A late start reply can no longer restore that generation. The focused regression failed on da91932a13 and all 35 tests in the owning file passed on the fix. The four live receipts in the PR body are from 27edb93b1c.

@apex-sentinel-staging

This comment has been minimized.

@thymikee

thymikee commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

The review of 1adba76 found remaining issues. The earlier review's identity checks, client scoping, documentation and loopback coverage have been addressed.

An auth hook can force tenant isolation even when the client requests none. Starting on capture and stopping or closing on tenant-a:capture reaches the same daemon session but uses different client directories, so a pathless stop falls back to the current directory and close leaves the original record behind. Can the destination key use the daemon's effective session address, including admission's tenant and isolation, for start, stop and close, with both spellings exercised through the HTTP auth-hook route? Destination key

Reservation order can differ from daemon execution order. If A reserves first but arrives after B has started and stopped, B can prune A's reservation before A starts successfully, so A loses its destination and a pathless stop uses a generated filename. Can settlement distinguish a later admitted start from a generation retired by stop or close, using daemon ordering or an equivalent lifecycle rule? Reservation pruning

The four live receipts support the examples at 27edb93, but the later change affects successful stop settlement before download. Before merge, run the built final SHA through the isolated HTTP proxy and record commands, device, state directories and stop JSON for named trace reuse with bytes, two distinct unnamed trace files, named xctrace reuse with a readable archive, and a two-client mismatch. Also delay a dispatched trace start reply until a second client sharing its state directory successfully stops it, then show that releasing the reply leaves no saved record for the stopped ID. Stop settlement

A second independent pass found that released clients without capture IDs lose their named start destination on pathless trace and perf stops against this daemon. Trace can write to the daemon path or fall back to the current directory, and perf also loses the saved path. Can start retain the client path regardless of ID and stop reuse it only when the requested and stored IDs match, including when both are absent, or can the alternative typed refusal or protocol change be settled before merge? Trace path

The released-client path thread still stands; no lower-priority threads still apply. The following threads can be resolved: trace identity now checks the ID; CLI help requires confirmation; remote docs require confirmation; security guidance scopes pathless reuse; artifact coverage checks downloads and retirement; perf identity couples the path to an ID; stale trace coverage checks refusal; interruption reaches the pre-dispatch wait; client scope includes state and credentials; malformed names are documented and recorded.

Body rules was cancelled and checks the PR title and body rather than capture routes; the reason for cancellation was not supplied. There are no known conflicts. Before merge, resolve the tenant alias and reordered start regressions, settle the released-client protocol concern, and attach final-SHA HTTP evidence.

Not verified here: the tenant and request-order scenarios were traced statically and were not reproduced on a running daemon. Not verified here: raw command transcripts, exact ID pairs and final-head test output were not supplied.

@thymikee
thymikee force-pushed the fix/daybreak-client-artifact-destinations branch from 1adba76 to 55c76ab Compare December 2, 2026 09:41
@apex-sentinel-staging

This comment has been minimized.

@thymikee

thymikee commented Dec 2, 2026

Copy link
Copy Markdown
Member Author

Follow-up to the auth-hook alias review, traced at 908766ae0bd8262b26a88cf14a0a7a1c01c9a6af.

The alias split still applies when HTTP admission forces tenant isolation. stampAdmittedIdentity stamps the hook-attested tenant and isolation before daemon session scoping. The client record key uses the submitted scope. It selects the saved capture ID before sending stop and snapshots records before sending close. The stop receipt confirms the stopped capture ID, and the ordinary close result can return the session name. Both arrive after those decisions. The existing tenant-alias test covers isolation present on the outgoing request.

For transparent aliasing, the client needs an authenticated scope before record lookup, with the capture or close request revalidating that scope against its own admission. A smaller deployment contract is to configure the client with the matching tenant and explicit tenant isolation, which the current key already supports. That option requires client configuration for hook-managed endpoints. Either choice is separate from the open released-client protocol-3 decision. This was a source trace. No patch or live run accompanies it.

@thymikee

thymikee commented Dec 2, 2026

Copy link
Copy Markdown
Member Author

The review of 908766a still finds destination regressions. The updated base accounts for the Android helper and fill changes raised earlier; the current patch has neither change.

The client record key uses the submitted scope before HTTP admission, although admission can force tenant isolation and map an unqualified session and its qualified alias to the same daemon session. A pathless stop under the alias can write to a generated filename instead of the named start destination, and close can leave the original record behind. Use the authenticated effective session address for start, stop and close, and revalidate it at admission before dispatch. Record scope

The native perf route discards a named start destination from a released protocol-3 client that sends no capture ID, then permits a pathless stop without returning that destination. Settle the released-client compatibility decision and preserve the destination for the agreed legacy pairing or provide the agreed typed refusal or protocol transition before the destination can be lost. Native perf route

The record compares receipt order across daemon instances, even though the order comes from a process-local counter and wall-clock origin. A replacement daemon with a lower value can have a successful start discarded, so the first pathless stop sends the predecessor's ID and leaves the new capture running. Scope order to the admitted daemon instance, accept its first valid receipt and prevent late retired-instance responses from replacing current state. Receipt ordering

A close reply can delete a retained reservation after an older start reaches a reopened session but before that start reply settles. The successful capture then loses its named destination, and its pathless stop uses a generated name. Retire only capture generations belonging to the session lifetime that closed, and cover the close reply settling before the reopened start reply. Close retirement

The live HTTP receipts cover 27edb93, before changes to start receipts, settlement and stop eligibility. Before merge, attach a built final-SHA HTTP proxy run with the device, state directories, commands, IDs and stop JSON for a named trace, two distinct unnamed traces, a named readable xctrace archive and a typed two-client mismatch. Include an admitted trace start whose reply arrives after a confirmed stop from a second process sharing client state, and show that the stopped ID stays retired. Exercise alternate session spellings with hook-forced tenant isolation for stop and close. Start settlement

A second independent pass found that hook-forced tenant isolation still splits records by session spelling. Could the maintainer choose either a documented contract requiring matching client tenant configuration and explicit tenant isolation, or transparent aliasing using an authenticated effective session address revalidated at admission? Add a test that sends both spellings through the HTTP auth-hook route. Session key

The open released-client trace thread still applies; no lower-priority open threads were reported.

CI is pending: Body rules was cancelled for an unknown reason and checks the title and body rather than capture behavior; another check is queued and covers the changed trace and remote record route, while its earlier approval was for a different commit. No conflicts are known. Not verified here: the reported local test passes, prior guard logs, raw live transcripts and exact live capture ID pairs were unavailable. Not verified here: daemon replacement, close overlap and auth-hook aliases were traced in source but were not run live; the ordering test uses a send double. Before merge, fix the tenant alias, daemon instance ordering and close retirement regressions, settle and implement the released-client protocol decision, and attach the final-SHA HTTP receipts.

@apex-sentinel-staging

This comment has been minimized.

@thymikee

thymikee commented Dec 2, 2026

Copy link
Copy Markdown
Member Author

I traced the daemon replacement and close/reopen findings at 908766ae0bd8262b26a88cf14a0a7a1c01c9a6af against base 88af7a669c549dae09050c58a865b6202efd379a.

  • Daemon replacement. captureStartOrder comes from a process-local counter seeded by the daemon's clock. Health-first RPC can prove the admitting daemon through its conditional headers. A proxy forwards the upstream pin and a safe retry can refresh it. The checked route can dispatch without either pin, and a successful start receipt carries only the capture ID and order. The existing record therefore has no authoritative way to tell a replacement's first receipt from a late receipt from its predecessor. The smallest transition is to scope the existing order to the daemon that admitted the call, reset the comparison on a verified successor, and ignore retired-instance receipts. This needs admission-bound instance identity on every capture route and evidence of the current successor. A bare instance UUID or a cached health answer alone cannot establish that transition.
  • Close/reopen. SessionStore retires the exact SessionRef.lifetime, but that lifetime is local to the daemon. A regular close reply names the session, and post-retirement errors can still occur. The client's byte-for-byte comparison with a pre-send snapshot cannot distinguish a pending start admitted before retirement from one admitted after reopen. The smallest ordering change would be to stamp actual retirement in the existing daemon order domain, at SessionStore.retire for that close, and compare the close cutoff with start receipts under the existing record lock. Keep unresolved reservations until their receipts identify which side of that boundary they belong to. This needs a retirement receipt bound to the admitting daemon and effective session, including failures that occur after retirement.

Both fixes need evidence beyond the current contracts, so this pass produced no code or test changes. The live HTTP receipts remain attributed to 27edb93b1c670ca2dec5f1d79595567244e52ea7.

@thymikee
thymikee force-pushed the fix/daybreak-client-artifact-destinations branch from 908766a to f3f5575 Compare December 2, 2026 16:57
@thymikee
thymikee force-pushed the fix/daybreak-android-helper-boundaries branch from 88af7a6 to 7e9c0c4 Compare December 2, 2026 16:57
@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of f3f5575

Since the review of 908766a: 0 new · 0 still open · 0 no longer raised

No open findings.

1 finding below minor hidden (user_settings.min_severity).

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

💬 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.

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