Repository navigation
fix(remote): answer a repeated script delivery from the publication record - #4744
Conversation
Size Report
Startup median (7 runs, lower is better):
|
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Apex Sentinel: 1 new finding on 456a81e. The verdict and the full list are in the summary comment.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Apex Sentinel: 3 new findings on 3bf4a96. The verdict and the full list are in the summary comment.
|
The repeat-from-record design is the right shape, and the review of 3bf4a96 found nothing blocking. An independent second pass over 60812c9 found four gaps. Each one keeps writes inside the authorized destination, but they report a wrong path or skip a check, so please fix them before merge.
Not blocking:
Both ledger digests and acknowledgements match 60812c9, and RPC protocol 3 is unchanged. No conflicts are known. |
This comment has been minimized.
This comment has been minimized.
|
Thanks. All four gaps are fixed in 333c999, each with a test that fails when the fix is reverted.
Non-blocking items:
#4746 is rebased onto this head and stays move-only. |
…ecord A version no newer than the committed revision is now answered from the client's own record: it reports the entry the commit created and adds a warning that the file is not checked again, with the recovery to use if it is missing. The repeat path no longer downloads, reads, hashes or re-walks the destination. This removes the per-version content digest, the bounded verified read, the script_entry_changed and script_entry_unverified causes, and host-kit's judgeScriptDestination. First commits, interrupted-commit settlement and the record lock are kept. A record that still carries a digest parses, and the field is ignored. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ersion When a re-offered revision is the one an interrupted commit names, the client settles that commit under the record lock before it stages or downloads. A version the commit already renamed into place is answered from the record, so an expired artifact no longer turns it into a delivery failure. A version that never reached the entry downloads as before. No digest and no file read: one confirmation walk and one lstat. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…eded version The record keeps the committed entry together with the revision that created it, and a repeat uses it only while that revision is still the committed one; otherwise it answers the destination, like a record without an entry. A released client that advances the revision can no longer make the client report an older path for a newer version. A version older than the committed one is now reported as superseded, naming the revision the file holds. The replay guide, ADR 0016 and the ledger acknowledgements describe this and when interrupted-commit settlement runs. Tests cover the legacy and stale-entry fallbacks, a held download that loses to a newer commit, an entry that is only reported, the cleanup and reread sharing one lock, and fs.promises in the no-filesystem spy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Interrupted-commit settlement records the promoted revision before it removes the interrupted version's staging. That removal is now best effort, through the existing quiet release, so a failure such as a dropped Windows share no longer turns a recorded commit into a download failure. The directory stays listed for retirement or the sweep. A comment and the replay guide also say that a repeat answered from a record without an entry for the committed revision names the destination as the caller spelled it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…staged-file checks - A repeat is decided from a fresh read under the record lock, and the decision is rechecked at staging allocation, so a commit that lands in between is answered instead of staged and fetched again. - A failed fetch settles an interrupted commit that names the version before it reports the fetch error. - A recorded entry is reported only when the record ties it to this publication: the committed revision, an absolute normalized path, and the destination's own entry name. Otherwise the destination is reported. - Before a new version is committed, its staged file must be a regular file within the 8 MiB cap that stays unchanged while it is read through one verified descriptor. Nothing is stored and repeats read nothing. - A legacy committedDigest is dropped when a record is parsed, and the recovery hint names the destination. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This comment has been minimized.
This comment has been minimized.
333c999 to
abfa16f
Compare
|
I rebased this onto
|
This comment has been minimized.
This comment has been minimized.
|
The four gaps from the earlier review (#4744 (comment)) are fixed at abfa16f, each with a regression test, and all 19 checks pass. One defect remains, and there are no conflicts. When a click fetches revision 2 after revision 1 is saved, a concurrent close can fail to download revision 3 and still retire the same publication (session-script-destination.ts:486, retire at lines 260-264 and 561-575). If the click fetch then fails, readRecord returns undefined, and settledRepeat turns that into the truthy { published: undefined } outcome (lines 698-699). The fetch catch returns it as if settlement had answered the call. The click then succeeds with no savedScript and no scriptDeliveryFailure or warning, while the recording on disk is still revision 1. ADR 0016 requires that disclosure, and both 7b6500c and 60812c9 propagated the fetch error here. Please make the failed-fetch catch return the locked result only when it has a defined published path, and rethrow the original fetch error when the record vanished. The absent-record outcome before staging should stay as it is. A test that fails revision 2 after a concurrent close retires the record would prove it. The earlier inline threads on re-offering an installed version, the stale-entry fallback, the replay-e2e.md wording and the committed answer after ECONNRESET are fixed at this head, so the author can resolve them: #4744 (comment), #4744 (comment), #4744 (comment), #4744 (comment). CI is green. Windows behavior of the basename tie check is not exercised. Before merge, the fetch error and the three items below need fixes. An independent second pass over abfa16f confirms that defect, and finds three more. All of them affect what the response reports. None writes outside the destination.
Not blocking: edited The wire-ledger digests match this head. |
…s disclosed - A failed fetch is reported as script_download_failed unless locked settlement answers it with a published path; a record a concurrent close retired no longer turns it into a silent success. - The record no longer keeps the committed entry. A repeat reports the destination as the caller spelled it; a record that still carries an entry parses and the field is dropped. - The record read, the repeat decision, destination preparation and staging allocation are one locked operation, so a version committed meanwhile is answered before the destination is judged. - The superseded warning names the revision the record last confirmed, and discloses an interrupted newer save that may have replaced the file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks. All four are fixed in 13e45cb, each with a test that fails when its fix is reverted.
Ledger: both acknowledgements are updated for the moved digests. Earlier threads: the four inline threads you listed were already resolved after their fixes. Not changed: edited #4746 is rebased onto this head and stays move-only. |
This comment has been minimized.
This comment has been minimized.
|
The production fixes at 13e45cb look correct and fix the problems from the earlier review (#4744 (comment)). One regression test still does not cover the bug it was written for. All 18 checks pass, and there are no conflicts. The fix 3 test in daemon-artifacts-script-concurrency.test.ts:266 commits revision 2 and makes the parent 0777 on the first read of the record file. For a click, that first read is the unlocked snapshot Not blocking, and you can take or leave it: Of the four earlier inline threads, all four are fixed at this head, so you can resolve them: the re-offer of an installed version is now settled under the lock (#4744 (comment)); the stale-entry fallback is gone because the entry field and Windows behavior is not exercised, because the fix 3 test skips on win32 and when running as root. Before merge, the fix 3 test needs to land its commit after the first record lock releases, so it fails when the fix is reverted. |
The regression test for the single locked stage-or-answer operation now commits revision 2 and shares the parent after the first record lock releases, the window where two locks would let preparation refuse a version the record already committed. It fails on the two-lock shape and passes with one lock. The snapshot-window test lands its commit on the unlocked first read instead of inside the lock. stageOrAnswer reads the record once and answers from that read. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks. The fix-3 test is reworked in 64fb12a.
Validation: the remote, host-kit, wire-compat and eager-closure suites passed (1947 tests). Typecheck, lint, #4746 is rebased onto this head and stays move-only, with the ADR line commit on top. |
This comment has been minimized.
This comment has been minimized.
|
At 64fb12a the fix 3 test blocker from the previous review is resolved: the commit and the parent permission change now land after the first record lock releases, and the test fails against the abfa16f source. The single record read in One user-facing problem remains, so no label yet: The close recovery hint selects a different destination. When a duplicate close or a closing batch reports a caller-chosen Not blocking:
CI is still finishing at this head. |
Move the sentence that the publication record is owner-private client state, and that cleanup trusts its staging list, from docs/agents/security.md into ADR 0016's staging paragraph, so the agent guidance stays within its size budget. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
At ae1127a both items from the previous review are in: cleanup is main's trusted-record behavior again, ADR 0016 says the record is owner-private client state, and the It also found four places where the docs or a rendered hint still say something the code does not do. They are small, but each can mislead a caller recovering a recording, so no label yet:
Not blocking, and already true on main: fresh POSIX publication directories and files are created 0700 and 0600, but the recursive The thread about a non-own staging path being re-swept forever no longer applies and can be resolved: #4744 (comment). |
This comment has been minimized.
This comment has been minimized.
… docs - A record-again hint for a path with a newline or another control character names <path> instead of the path, so a rendered text line cannot turn it into a command for a different file. - The next-action recovery applies while the session is still recording. - The replay guide and scripting help scope the repeat warning to an active record, describe the reported path as the stored absolute destination added by client-side materialization, and give the original open destination as the general close recovery. - ADR 0016 scopes the trusted-record sentence to an owner-only state directory. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks. All four gaps are fixed in 79a97c8. I also took the simple option for the state directory.
State directory (optional): ADR 0016 now reads "When the state directory is owner-only, the record is owner-private client state, so cleanup trusts its staging list." The creation code is unchanged. Review-bot thread (discussion_r4631120964): already resolved, with a reply saying the check was reverted per the maintainer review. Ledger: no digest moved. Validation: the remote, host-kit, #4746 is rebased onto this head and stays move-only, with the ADR line commit on top. |
This comment has been minimized.
This comment has been minimized.
|
At 79a97c8 the four items from the previous review are in. The guide describes the stored absolute destination, the repeat warning is scoped to an active record, close-failure recovery points at the original
Not blocking:
|
…he repeat docs - The record-again hint names <path> for a C1 control character too, and says to reuse the original open command, since its app, URL and device arguments are needed again. - The replay guide limits the silent case to offers whose record is already retired at the staging decision; a failed in-flight download still reports its delivery failure. - ADR 0016, the ledger rationale and a doc comment describe repeats as reporting the stored absolute destination. - The control-character destination tests skip off POSIX, and the CLI close text test that passed on the old rendering is dropped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks. Both gaps and all four recommended items are in 1925845.
Recommended:
Validation: the remote, host-kit, #4746 is rebased onto this head and stays move-only, with the ADR line commit on top. |
This comment has been minimized.
This comment has been minimized.
|
At 1925845 both items from the previous review are in: the record-again hint uses The first sentence of the repeat warning prints the raw destination. At session-script-destination.ts:335, Not blocking:
|
- The repeat warning shows C0, DEL and C1 characters in the destination escaped (for example \x1b), so a name with an escape sequence cannot hide the recovery hint; savedScript keeps the exact path. - The staged-file check refuses a file already over the cap from its size, before reading it. - ADR 0016 and the check's comment say no content digest is kept and the pending file identity is recorded until the commit settles. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks. The gap and both recommendations are in da315b7.
Ledger: no digest moved. Validation: the remote, host-kit, #4746 is rebased onto this head and stays move-only, with the ADR line commit on top. |
|
At da315b7 the repeat warning escapes control characters in the destination, The same raw-path problem still shows up on other text surfaces, so no label yet:
Escaping each message as it is found keeps missing sites. Please do it once at the CLI output boundary instead. Have the warning and error text renderer ( Not blocking: the control-character table skips every row on Windows, but entry-name.ts:80-83 only rejects characters below U+0020 there, so the U+0085 and U+009B rows could still run on Windows. |
This comment has been minimized.
This comment has been minimized.
- The CLI warning and error renderer shows C0 (except newline and tab), DEL and C1 characters as \xNN, so any message that names a path, including delivery failures and host-kit preflight refusals, cannot drive the terminal. - The CLI JSON writer escapes DEL and C1 as \uNNNN, which JSON.stringify leaves raw; output stays valid JSON and parses to the exact values. close --level full uses the same writer for its text. - The remote repeat warning no longer escapes its own path: structured fields keep the exact value and the boundary does the escaping. - The replay guide says close --level full prints savedScript, and describes the boundary escaping. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks. Escaping now happens once at the CLI output boundary, in 52bde73.
Ledger: no digest moved, and the eager-closure check stays green. Validation: the #4746 is rebased onto this head and stays move-only, with the ADR line commit on top. |
|
At 52bde73 escaping lives in one shared renderer: Some CLI formatters still write warning text without going through it, so no label yet:
Each round has found another formatter that skips the renderer, so please close this at the one point every formatter shares: the CLI's stdout and stderr write. Escape C0 (except newline and tab), DEL and C1 there, and every formatter, current and future, is covered. Keep the renderer only for the warning folding and layout it already does. If text output must keep some control characters on purpose, add a narrow raw-write escape hatch for that call. Add one end-to-end test per surface above (default Not blocking:
|
…ion change Terminal-safe CLI output is an independent invariant for every command, so it moves to its own change. This restores the CLI warning and error renderer, the CLI JSON writer and their tests, and drops the replay guide sentences about CLI-wide escaping and close --level full. The remote warning keeps the exact path, and the record-again hint keeps its <path> placeholder for control characters. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This comment has been minimized.
This comment has been minimized.
|
At b673232 the CLI output-layer escaping is gone, and the remote, host-kit and docs scope matches what was reviewed before: exact One docs line needs to go back to its earlier scope before the label:
Not blocking: the comment at daemon-artifacts-script-entry.test.ts:590 still says the CLI output boundary escapes control characters, and the PR body still has the CLI output boundary paragraph, the old file count and validation at 52bde73. Updating both, and linking the terminal-safe-output PR once it is open, would keep the record straight. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Apex Sentinel · ✅ Approve · review of
|
| 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.
|
This PR is ready at 81fbe88. The delta from b673232 is the two lines asked for: Terminal-safe CLI output (escaping control characters in what the CLI prints) is tracked in a separate PR, so this one keeps |
|
Thanks. Per our review scope rule, terminal-safe output for every CLI command is an independent invariant that predates this PR, so I've split it out:
#4746 is rebased onto 81fbe88 and stays move-only, with the ADR line commit on top. |
Summary
A repeated or late-duplicate script delivery (revision ≤ the committed revision) is answered from the client's publication record. It reports the stored absolute destination as
savedScript, and adds a warning to the existingwarningsarray. The warning says the version was already saved, or that it is superseded and names the revision the record last confirmed. It also discloses an interrupted newer save, says the file is not checked again, and gives the recovery: the next recorded action, or after close reusing the originalopencommand with--save-script=<path> --force. The repeat path never downloads, reads, hashes, or re-walks the destination.Removed: the per-version digest, the bounded verified read,
CommittedVersionUnverified, thescript_entry_changedandscript_entry_unverifiedcauses, the repeat judgement, and host-kit'sjudgeScriptDestination(isWindowsShareUnavailableis now module-private). Old records that carry a digest or anentrystill parse, and those fields are dropped.Kept: first commits and interrupted-commit settlement, under one locked operation that reads the record, decides repeat or stage, prepares the destination, and allocates staging. A failed fetch or a re-offer of an interrupted version settles under the lock first. A failed fetch stays
script_download_failedunless that settlement answers with a published path. A new commit still requires a verified staged file: regular, ≤ 8 MiB, and unchanged through one verified read. Nothing is stored. A failing cleanup after a failed artifact download is reported as a warning instead of an unhandled rejection. The close recovery hint names the file: reuse the originalopencommand with--save-script=<path> --force.16 files, +695/−1031. Docs:
replay-e2e.mdand ADR 0016. The wire-compat ledger acknowledgespublishScriptVersionandPublishOutcome(local shape only). There are no wire changes and no protocol bump.Security: the daemon and other local users are untrusted. The change writes nowhere new, and no path comes from the daemon. A committed repeat does no filesystem work. Settling an interrupted version does one confirmation walk and one lstat, the same steps a first commit takes.
Terminal-safe CLI output for every command, including the paths this change reports, is handled separately in #4778.
Validation
At
81fbe880c4(on main after #4745 and #4747): the remote, host-kit,command-output, wire-compat and eager-closure suites passed. Typecheck, lint,fallow audit --base origin/main, andcheck:production-exportsare clean. Each new test fails under a targeted mutation. CI validates the head.🤖 Generated with Claude Code
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.