Repository navigation
refactor(remote): save a remote script from memory with the local publisher - #4802
Conversation
Size Report
Startup median (7 runs, lower is better):
|
Apex Sentinel · ✅ Approve · review of
|
| Where | Finding |
|---|---|
packages/remote/src/script-publication-record.ts:76 |
Records an older client left retired parse as active again |
packages/remote/src/session-script-destination.ts:98 |
A receipt close the submitted plan disproves now retires a still-recording publication |
Reviewed with this repository's own Sentinel configuration (74771e19193d).
💬 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.
There was a problem hiding this comment.
Apex Sentinel: 2 new findings on dd70add. The verdict and the full list are in the summary comment.
|
This PR is ready at f11402c. The review at 1ae09ba found nothing that needs a code change, and the only change since is docs: The two resolved threads on the retired:true record (#4802 (comment)) and on closesSubmittedPlan (#4802 (comment)) do not apply any more. The maintainer accepted both as scope decisions, so the author can resolve them. Not blocking, and fine to take or leave: drop prepareScriptDestination and type ScriptDestination from the export list in packages/host-kit/src/file.ts (no package imports them now); add a test where the v1 fetch fails, a file appears at the destination, and v2 arrives, expecting script_target_exists with the file unchanged, so the first saved version (record.revision === 0) stays exclusive whatever its artifact revision; reword the test comments that still describe staging directories and the ledger rationale that still describes draining error answers (the client now stops reading once 65,536 characters are held); assert details.reason === "artifact_too_large" in the bare rejects at packages/remote/src/tests/artifact-download.test.ts:285; and split settle at packages/remote/src/artifact-download.ts:153 into resolve and fail so the result as T cast goes away. |
f11402c to
4aa5e92
Compare
…lisher
The remote client fetched each script version into a staging directory
beside the destination, confirmed the directory after the download, and
kept an inode anchor and a pending-commit entry in its record so an
interrupted commit could be settled later. That defended a directory
replaced during a download, which the ownership rule already excludes,
and a crash between the rename and the record write, which the next
version repairs.
A version is now fetched into memory, capped at 8 MiB as the bytes
arrive, and committed under the record lock with publishScriptFileSync,
the call the local route makes. The record is { destination, force,
revision }; extra fields an older client wrote are ignored. A close
removes its record. A version that is not newer is answered from the
record with no warning. A batch receipt that names a close retires the
record without reconciling it against the submitted plan.
host-kit loses confirmScriptDestination and the parent_replaced
exposure, so script_ancestry_replaced is no longer emitted.
Accepted: after a crash between the publish and the record write, the
next version of a first-version recording without --force reports that
the file exists, with the --force hint.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The artifact request moved into requestRemoteArtifact and gained an in-memory consumer, so the wire surface lists the new declarations, the tenant-header mutation case targets the function that now builds the request, and the ledger carries the new digests with a rationale for each changed declaration. No request, header, route or response framing changed, so the protocol version stays at 3. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The in-memory fetch kept every chunk and then concatenated them, so a body at the cap held twice the cap and a body in tiny chunks kept one buffer per chunk. It now collects into one buffer that doubles up to the cap. A non-200 answer was read to its end or to the 90-second timeout while only the first 65,536 characters were kept. The request now fails with the HTTP status as soon as that much is read and drops the response. The file and directory downloads share the handler and report the same error shape. Also removes a settlement field and an export nothing reads, and corrects ADR 0016, the website, the CLI help and the security notes where they said more than the code does. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The artifact sink is local I/O plumbing with no wire shape, so the request function spells it inline and the surface no longer lists it. The ledger carries the digests of the bounded fetch and of the unexported publish outcome, and the materialize rationale says the wire fields are unchanged. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The two sentences on script publishing are shorter than the ones they replace, and the exact error-answer length moves to ADR 0016. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
host-kit stops exporting the ScriptDestination type, which has no importer left; prepareScriptDestination stays for the Swift cache. The artifact request settles through separate succeed and fail paths, so the result cast is gone. A new test pins that the first version saved stays exclusive when an earlier fetch failed. Test comments and one ledger rationale no longer describe staging or reading an error answer to its end. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
4aa5e92 to
0c39f0a
Compare
|
Thanks. All optional notes are applied at 0c39f0a, on top of a rebase onto current
The rebase picked up #4799: its group rule, |
|
Still ready at 0c39f0a. The rebase over #4799 keeps its group rule and |
* origin/main: test: remove five timing races from CI (callstack#4800) refactor(remote): save a remote script from memory with the local publisher (callstack#4802)
* origin/main: feat(gesture): hold before the move with gesture pan --hold-ms (#4767) docs: clarify device verification and security proposals (#4805) fix(daemon-client): say that a hung daemon is stopped before ensureDaemon starts a new one (#4803) test: remove five timing races from CI (#4800) refactor(remote): save a remote script from memory with the local publisher (#4802) refactor(apple-runner): one RUNNER_ERROR_CODES row per runner error code with parity/docs gates (#4774) fix(android): require acknowledgements for test IME typing (#4722) feat(scroll): add scroll refresh for pull-to-refresh (#4770) refactor(host-kit): add request Scope and use it for the wait capture deadline (#4794) fix(android): let permission all change nothing on an app that declares no permissions (#4796) fix(cli): replace the CLI session and generated remote config instead of rewriting them in place (#4797) fix(host-kit): accept a group-writable script directory the user owns (#4799)
Summary
The remote client staged each script version on disk beside the destination, confirmed the directory after the download, and kept an inode anchor, a pending-commit entry, a staging list and a retired flag so an interrupted commit could be settled. That defended a directory replaced mid-download (the ownership rule already excludes it) and a crash mid-commit (the next version repairs it).
Now a version is fetched into memory and committed under the record lock by
publishScriptFileSync, the call the local route makes. 29 files, no scope expansion.Removed: staging and settlement,
confirmScriptDestination,parent_replaced/script_ancestry_replaced,privateFile, repeat warnings, and receipt reconciliation against the submitted plan. The record is{ destination, force, revision }.Guarantees, each test seen failing against broken code:
only a newer version of a recorded publication writes(endpoint, tenant, session and ID each dropped from the record key),a peer value for savedScript never reaches the caller.a version one byte over the cap…,an in-memory fetch returns a body of exactly its cap…(cap doubled; limiter removed). The fetch holds one buffer that grows to the cap, and an error answer is dropped after 65,536 characters:…very small chunks unchanged,an error answer… is dropped once its diagnostic is full.--force:the first version never replaces…(alwaysreplace).Accepted: after a crash between the publish and the record write, the next version of a first-version, no-
--forcerecording reports "file exists" with the--forcehint.Security pass, against the three guarantees and the local path rule: the destination comes only from the locked record; the publication ID reaches the filesystem only as a hash; fetched bytes are counted as they arrive; walk and commit are one synchronous call; a receipt close can only remove a record.
Validation
Head 0c39f0a: typecheck, lint, format, layering, production-exports,
fallow audit --base origin/main,check:daemon-wire-compat(protocol stays 3), eager-closure and repo guards pass. Unit suites forpackages/remote,host-kit,host-swift,daemon-client,test/wire-compatand theremote-script-publicationprovider scenario pass.check:affectedwas not run; CI owns the full run. Not device-facing. Self-review was a cold re-read of the diff, with no independent reviewer.🤖 Generated with Claude Code