Repository navigation
Conversation
Size Report
Startup median (7 runs, lower is better):
|
a5bc98a to
b77b6eb
Compare
A saved connection was stored under a file whose name sanitized the session, replacing every character a filename cannot hold. Two names that differ only in case produce the same name, so on a case-insensitive filesystem both sessions opened one file and one session read and overwrote another session's record. A session name that is a filename on its own keeps it. Any other name is stored under its SHA-256. A record at the old path is used only when its contents name that session, and a record that names another session is refused with the typed reason connection_session_mismatch instead of being read, overwritten, or removed. The active-session pointer is never a session record.
The child polls the gate file and reads it whole. A plain write left a window where the file existed with no contents yet, so the child reported an empty phase and the test lost a receipt. Publishing it means the child sees a phase name or no file at all.
…ort audit connectionSessionIdentity is the published name for the hash a session maps to in its saved-connection file name. Production derives it inside the module, and the package test reads it, which the production export audit cannot see.
b77b6eb to
29fd24a
Compare
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Apex Sentinel: 2 new findings on 29fd24a. The verdict and the full list are in the summary comment.
|
Reviewed 29fd24a. Six problems remain, and the first one breaks the stated invariant that each remote session owns its saved-connection file. All 22 code checks pass, and the only non-passing check is the cancelled 'Body rules' run, which is likely unrelated because the diff changes no workflow or body-rule input. There are no conflicts. The first problem must be fixed before merge. remote-connection-state.ts:541: After an upgrade on macOS or Windows, a legacy A second independent pass found remote-connection-state.ts:533 has the same shape on a case-sensitive filesystem. At base, A second independent pass found remote-connection-state.ts:268 can let a stale legacy write or removal destroy another session's record. On a case-insensitive filesystem, start with legacy A second independent pass found remote-connection-state.ts:571 can lose a lease record at the legacy pointer filename. The base writer commits a full record before it updates the pointer (d6767e0:packages/remote/src/remote-connection-state.ts:260-262). If it is interrupted between those writes for session A second independent pass found remote-connection-state.ts:558 lets distinct config session names share one canonical digest. Two explicit JSON CLI configs can supply session strings containing a lone U+D800 or U+D801 code unit (parsed at packages/command-surface/src/schema/cli-config.ts:90-106). Node's UTF-8 hash input encodes both as U+FFFD. After the first session connects, the second reaches the same file and cannot connect because of the owner check. If both pass the check while the file is absent, their replacing publishes can overwrite each other. The rule: canonical filenames hash a lossless encoding of the exact JavaScript string, such as UTF-16LE, while the eight-character suffix for legacy lookup keeps the old UTF-8 digest. A second independent pass found remote-connection-state.ts:244 deletes an identifiable record that belongs to another session. On a case-insensitive filesystem, take a legacy Simplicity question: would it be the same size or smaller to make the legacy branch a one-time migration that renames a matching legacy file to its canonical path, instead of a permanent second live location? The mismatch refusal would then guard only true conflicts, and the lockout above and the missing recovery hint would go away without new error surface. No smaller design was found for the plain/hashed split itself, since hashing every name would move every existing lowercase record for no gain. The open inline threads still apply: the legacy path resolving to the same file is raised to the invariant in the first problem above, and the unhelpful mismatch error still holds. Disconnecting the owning session recovers, but nothing tells the caller that. Not blocking, and each can be taken or left: Not verified here: the tests were not run, and the base-failure and lockout claims come from reading base Before merge, the legacy sanitized-name records need a one-time migration to their canonical path, with an upgrade-route test that covers a legacy 'Demo' record next to a new 'demo' session. |
On a case-insensitive filesystem, the record an older build wrote for `Demo` opens when `demo` asks for its own plain name, so every remote command for `demo` answered `connection_session_mismatch` and the only way out was deleting the file by hand. Path resolution trusted a name; contents decide ownership. A session now resolves to the next path its own name answers for when a record there proves it belongs to another session: the case-variant reads no state, writes its own hashed record, and the other session's file is left alone. `connection status` and `disconnect --session demo` answer that demo has no connection instead of failing. The contents check stays as the last guard for a record that still disagrees after resolution, and it now names the refused path and how to clear it.
Apex Sentinel · ✅ Approve · review of
|
| Where | Finding |
|---|---|
packages/remote/src/remote-connection-state.ts:248 |
Mismatch hint tells the user to run a disconnect that cannot reach the record |
Reviewed with this repository's own Sentinel configuration (d6767e0910fc).
💬 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.
|
Sentinel findings addressed in 1b11290. Path resolution now answers with contents rather than with a file name: when the plain |
|
At 1b11290, the upgrade-route lockout from the earlier review is fixed, but a session's saved-connection file can still change under it or be overwritten by another session. Checks are green (22 reported, none failing) and there are no conflicts. The first item below must be fixed before merge. A plain-name session's path still depends on another session's file (remote-connection-state.ts#L556). Take an upgrade on macOS or Windows with a legacy A hashed-name session whose legacy record names it still publishes to the shared legacy pathname (#L568). This was in the earlier review and is unchanged. The publish at Two session names that differ only in a lone surrogate still share one hashed file (#L598). This was in the earlier review and is unchanged. A second independent pass found that an upgraded legacy record stays at the shared filename (#L568). Reads for the legacy owner leave A second independent pass found that deleting the legacy owner strands the other session's hashed record (#L557). Connect A second independent pass found that a stale legacy write or unlink can destroy a newly connected session (#L275). Pause a A second independent pass found that an interrupted legacy writer can leave the only lease record at the pointer path (#L611). At base, a writer interrupted after the record publish and before the pointer publish leaves a complete, readable and disconnectable record at A second independent pass found that an unreadable legacy record is treated as available and deleted (#L585). On a case-insensitive volume, take a valid Could this be simpler? Resolve by name only: plain-category names to Not blocking, and these can be taken or left: the new hint at #L257 says to run For a follow-up issue, not for this PR: the pointer exclusion at remote-connection-state.ts#L611 compares only the exact The mismatch-hint thread still applies, as the non-blocking note above. The upgrade-route lockout thread no longer applies, because the plain branch at lines 555-559 no longer reaches the throw, and the remaining guard at 253-257 now carries Not verified here: no tests were run, and the first, second and fourth items are traced from the head code and the CLI handlers, not reproduced on a case-insensitive volume. The race in the second item needs three concurrent processes. No cross-process lock was found in Before merge, fix the path flip in the first item, which leaves a live lease unreachable after the other session disconnects. Then fix the rest and push. |
Summary
A saved remote connection was stored in
remote-connections/<name>.json, where<name>sanitized the session name. On a case-insensitive filesystemDemoanddemonamed one file, so one session read and then overwrote another session's saved connection.A record's contents, not its file name, decide who owns it. A name that is a filename keeps it; any other name uses
~<sha256(session)>.json, exported asconnectionSessionIdentity. When the record at the path a name answers for names another session, that session resolves to its next path, reads no state, and writes its own record — the other session's file is left untouched.connection_session_mismatchstays as the last guard and names the refused path and its owner. The.active-sessionpointer stays a pointer.The startup-budget test now publishes its phase gate file atomically.
Before / after
Value
--forceincluded: 4 at the previous head, 0 at headValidation
Validated at head 1b11290:
pnpm format,typecheck,lint,check:layeringandcheck:fallowpass; theunit-corevitest project passes (20,583 tests), coveringpackages/remoteandsrc/cli. Each new test fails at 29fd24a for its own reason. The case fold is made real in tests (hard link where the host volume is case-sensitive), so it holds on Linux. CI owns the device, replay and coverage lanes.