You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
refactor(server): drop comments the code can say, part 1 of 8 - #4054
Part 1 of 8 for server/ in the repo-wide comment pass. This part covers:
access and authentication: access.ts, auth.ts, account/
the agent catalog, identity, launch and task code, and agy
alert-webhook.ts, bridge.ts, background-*
the Claude store, input, settings, plan, subagents and transcript readers
cliproxy.ts, cmd.ts
the Codex daemon, images, queue and steering code
the tests of all of these, contract tests included (comments only)
About 4,800 comment lines go. What stays:
The public HTTP/WS contract: doc comments that define /api/* requests and answers, the Authorization: Device header, and the bridge descriptor's fields that older bridges wrote without.
Machine-read comments: the // fixed wait: markers.
Behaviour we cannot change:
herdr and herdr-core
Claude Code's transcript, store and option formats, Codex's daemon and screen, omp's blob store, Command Code, senpi/OmO, Agy, Grok, Letta
Tailscale serve's headers and Portal's proof header
PowerShell and cmd.exe quoting, macOS sysctl and /proc layouts, Windows Restart Manager and file ids
SQLite, Bun and Node behaviour
Each was checked against fixtures, the installed tool or its source where one was available.
Every comment-only change was checked against origin/main by syntax tree. No test, script or doc reads a deleted comment.
This PR touches authentication files (access.ts, auth.ts, account/), with comments and no code changed there, so it waits for a real review (AGENTS.md).
Code changes (mechanical, no behaviour change)
server/claude-store.ts: the sysctl MIBs [1, 8] and [1, 49, pid] are CTL_KERN, KERN_ARGMAX and KERN_PROCARGS2.
server/codex.test.ts: the clock ids 3 and 16 are CLOCK_THREAD_CPUTIME_ID_LINUX and _DARWIN.
Rules that only a comment stated (deleted, not enforced yet)
Security
auth.ts: recordPresentedTokenFailure must run in the same synchronous step as presentedToken, or concurrent guesses pass the check. Its only caller, dispatch.ts, still says so. The re-read of the wait after the body arrives is covered by auth.test.ts.
access.ts:
A token is required of everything but a paired device.
A Portal identity alone is never the owner.
Invite roles are stored server-side, never read from headers.
relayPeer is never derived from headers or cookies.
decideAccess checks Portal before the token gate and the token gate before the login header.
The public internet is never "open".
cliproxy.ts:
Only fixed messages cross to clients, because CLIProxyAPI's errors can echo management credentials.
A revoked key must cause one refusal, not one per account (the proxy bans after five), so Hub requests go one at a time.
alert-webhook.ts:
A message never carries what the agent asked or answered.
The stored secret is only ever answered masked.
Redirects are never followed.
loopbackHttp is for the tests' fake destination only.
client-connection-log.ts: the endpoint never invokes herdr or accepts input, and diagnostics never affect the app's connection.
codex-daemon.ts:
It never starts a daemon and uses only an existing socket.
It sends only initialize (experimental API off), initialized and skills/list, and connects to nothing else. The REQUESTS/NOTIFICATIONS sets hold part of this.
codex-steering.ts: only Send now may interrupt, and only for text. The caller rechecks identity, lease, authority and prompts in the same read.
Order and state
adopt-legacy-env.ts is imported first by every server entry point.
account/routes.ts: the enrollment barrier is written to disk first, and a refused link never lifts it.
account/mailbox.ts: records are written to disk before an acknowledgement, and every record read is acknowledged.
bridge.ts registerBridge: a guard that could not be released fails the start.
agent-catalog-install.ts: the command check runs again right before typing.
agent-catalog-detect.ts: only absolute PATH entries count.
Kept in step
claude-store.ts: an option a later Claude Code adds goes into the CLAUDE_* option sets.
claude-input.ts: BOX_LABELED_RULE_RE is used only by the box reader.
claude-settings-file.ts: the folder stays out of the server's state dir. docs/agent-commands.md covers the choice.
Left open (redesigns, not done here)
Access and authentication:
decideAccess and observedIngress carry security meaning in their order and could be named, ordered rules.
auth.ts:
the check and the record could be one call
sharedKey parses " via " out of a partly client-made string (authClient could return {address, peer})
the eviction-order delete-before-set needs a name
claude-artifacts.ts PAGE is a security allow-list and could be named so.
Account: the mailbox's drain order and eviction policy, applyEnrollment's order, and the barrier lift in AccountHolds.
Startup and single flight:adopt-legacy-env.ts as a side-effect import (lazy readers), the catalog's hand-rolled single flight, and the install state machine.
Agent tasks and Agy:
agent-tasks.ts's retry state machine has a known limit.
agy-store.ts relies on a read order for pid-reuse safety and tangles cache, backoff and proof in windowsHeldPaths.
bun run check fast: passed (18,574 unit tests, typecheck, build, generated files).
Unit tests of every touched non-contract test file and of the modules that import a touched one: 1,042 + 751 + 1,321 + 738 + 625 pass. server/claude-store.test.ts (110) and server/codex.test.ts (125) pass with the two code changes.
Contract tests were edited (comments only) but not run here. CI's integration job runs them.
The first server/ slice of the repo-wide comment pass: access, account,
the agent catalog and launch code, agy, alert-webhook, auth, bridge,
background-agent, the Claude store, input, settings, subagents and
transcript readers, cliproxy, cmd, and the Codex daemon, images, queue
and steering code with their tests. About 4,800 comment lines go; the
doc comments that define the HTTP and WebSocket API, the `fixed wait:`
markers, and notes on herdr, Claude Code, Codex, omp, Tailscale, Portal,
PowerShell, macOS sysctl and /proc stay. Named instead of explained: the
sysctl MIBs in claude-store.ts and the thread CPU clock ids in
codex.test.ts.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Auto incremental reviews are disabled on this repository.
Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Summary
Summary by CodeRabbit
Tests
Expanded regression and contract coverage for access controls, account flows, agent installation and status, transcript and image handling, process identity, and persistence.
Added checks for Windows command execution, loopback host handling, Tailscale identity, and edge cases involving file and process changes.
Documentation
Revised or removed explanatory comments across server components. No user-facing behavior changes are indicated.
The pull request updates server tests and comments across access control, account handling, agent management, transcript processing, CLIProxy, and Codex conversation matching. It also adds a foreground-process recheck to Agy store resolution and updates the AccessInput interface.
Changes: Server regression coverage and maintenance
Layer / File(s)
Summary
Access, account, and process identity checks server/access.ts, server/access.test.ts, server/access-authority.contract.test.ts, server/account/*, server/agy-store.ts, server/agy-store.test.ts
Access tests add host and Tailscale-login cases. Account tests add assertions for removal persistence, link preservation, and sign-in retry timing. Agy store resolution rechecks the foreground process before reading held paths.
Agent and Claude coverage server/agent-*, server/agents-routes.*, server/agent-tasks.*, server/claude-*
Tests add or adjust cases for Windows command shims, task lookups, Claude store selection, session resolution, image and history reads, and system-reminder parsing. Many implementation comments are removed or revised; most shown logic remains unchanged.
CLIProxy and API contracts server/cliproxy*, server/api.contract.test.ts, server/auth*, server/bridge*, server/attach-*, server/client-connection-log*
CLIProxy tests expand hidden-account coverage across identity changes, restarts, partial persistence, and Hub changes. API contract tests retain and adjust broad endpoint, WebSocket, authentication, and preference assertions.
Codex matching and image coverage server/codex-*
Tests expand conversation-binding cases for competing threads, process identity, rendered answers, short answers, and changing loaded rollouts. Codex image tests add output-matching and event-loop assertions. Most Codex implementation changes shown are comment updates.
This is mostly a comment-removal pass with a small, defensive Agy process-identity check. No concrete merge-blocking risk was identified.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title "refactor(server): drop comments the code can say, part 1 of 8" matches the changeset, which removes comments across server/ files. It names the scope and the intent. The changeset also incl…
Description check
The description follows the repository template. It has a Change section that describes the problem and resulting behavior, and a Validation section that lists the checks run and their results. The Ch…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title "refactor(server): drop comments the code can say, part 1 of 8" matches the changeset, which removes comments across server/ files. It names the scope and the intent. The changeset also includes two small code changes: named sysctl MIBs in server/claude-store.ts and named clock IDs in server/codex.test.ts. The title does not mention these, which is acceptable because they are minor.
Full details: Description check
Explanation
The description follows the repository template. It has a Change section that describes the problem and resulting behavior, and a Validation section that lists the checks run and their results. The Change section does not link an issue, but the template asks for one only for features, and this PR is a refactor. The Validation section notes that contract tests were edited but not run. The description also records the security and ordering rules that the removed comments stated, so reviewers can check them.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Reviewing files that changed from the base of the PR and between d56104e and 96267f0.
Files selected for processing: 101
server/access-authority.contract.test.ts
server/access.test.ts
server/access.ts
server/account/account.contract.test.ts
server/account/holds.ts
server/account/introductions.ts
server/account/mailbox.ts
server/account/records.ts
server/account/routes.ts
server/adopt-legacy-env.ts
server/agent-catalog-detect.test.ts
server/agent-catalog-detect.ts
server/agent-catalog-install.test.ts
server/agent-catalog-install.ts
server/agent-catalog-routes.test.ts
server/agent-catalog-routes.ts
server/agent-identity.test.ts
server/agent-identity.ts
server/agent-launch.test.ts
server/agent-launch.ts
server/agent-name.ts
server/agent-process.test.ts
server/agent-process.ts
server/agent-tasks.test.ts
server/agent-tasks.ts
server/agent-version.test.ts
server/agent-version.ts
server/agents-routes.test.ts
server/agents-routes.ts
server/agy-store.test.ts
server/agy-store.ts
server/agy.test.ts
server/agy.ts
server/alert-webhook.test.ts
server/alert-webhook.ts
server/api.contract.test.ts
server/app-revision.test.ts
server/app-revision.ts
server/attach-held.contract.test.ts
server/attach-output.test.ts
server/attach-output.ts
server/auth.test.ts
server/auth.ts
server/background-agent.contract.test.ts
server/background-agent.test.ts
server/background-agent.ts
server/background-wait.test.ts
server/background-wait.ts
server/bridge.test.ts
server/bridge.ts
server/catalog-sources.test.ts
server/catalog-sources.ts
server/catalog.conventions.test.ts
server/chat-history.test.ts
server/chat-read-timeout.test.ts
server/claude-api-error.test.ts
server/claude-artifacts.test.ts
server/claude-artifacts.ts
server/claude-command-history.test.ts
server/claude-command-history.ts
server/claude-host-tools.test.ts
server/claude-images.test.ts
server/claude-incremental.test.ts
server/claude-input.ts
server/claude-plan.test.ts
server/claude-plan.ts
server/claude-senpi-notices.test.ts
server/claude-session.contract.test.ts
server/claude-settings-file.test.ts
server/claude-settings-file.ts
server/claude-store.test.ts
server/claude-store.ts
server/claude-subagents.test.ts
server/claude-subagents.ts
server/claude-task-scan.test.ts
server/claude-task-scan.ts
server/claude-transcript.ts
server/client-connection-log.contract.test.ts
server/client-connection-log.test.ts
server/client-connection-log.ts
server/cliproxy-routes.ts
server/cliproxy.fake.ts
server/cliproxy.test.ts
server/cliproxy.ts
server/cmd.test.ts
server/cmd.ts
server/codex-binding.contract.test.ts
server/codex-composer-regression.test.ts
server/codex-daemon.contract.test.ts
server/codex-daemon.test.ts
server/codex-daemon.ts
server/codex-images.test.ts
server/codex-images.ts
server/codex-linked-completion.test.ts
server/codex-process-lock-store.test.ts
server/codex-process-store.test.ts
server/codex-processes.test.ts
server/codex-queue.ts
server/codex-steering.ts
server/codex.contract.test.ts
server/codex.test.ts
Files with no reviewable changes: 72
server/access-authority.contract.test.ts
server/access.test.ts
server/access.ts
server/account/account.contract.test.ts
server/account/holds.ts
server/account/records.ts
server/account/routes.ts
server/adopt-legacy-env.ts
server/agent-catalog-detect.test.ts
server/agent-catalog-install.ts
server/agent-catalog-routes.test.ts
server/agent-catalog-routes.ts
server/agent-identity.test.ts
server/agent-identity.ts
server/agent-launch.test.ts
server/agent-launch.ts
server/agent-name.ts
server/agent-process.test.ts
server/agent-process.ts
server/agent-tasks.test.ts
server/agent-version.test.ts
server/agent-version.ts
server/agents-routes.test.ts
server/agents-routes.ts
server/agy-store.test.ts
server/agy.test.ts
server/agy.ts
server/alert-webhook.test.ts
server/app-revision.test.ts
server/app-revision.ts
server/attach-held.contract.test.ts
server/attach-output.test.ts
server/attach-output.ts
server/auth.test.ts
server/auth.ts
server/background-agent.contract.test.ts
server/background-agent.test.ts
server/background-agent.ts
server/background-wait.test.ts
server/background-wait.ts
server/bridge.test.ts
server/catalog-sources.test.ts
server/catalog-sources.ts
server/catalog.conventions.test.ts
server/chat-read-timeout.test.ts
server/claude-api-error.test.ts
server/claude-artifacts.test.ts
server/claude-artifacts.ts
server/claude-host-tools.test.ts
server/claude-images.test.ts
server/claude-incremental.test.ts
server/claude-plan.test.ts
server/claude-plan.ts
server/claude-senpi-notices.test.ts
server/claude-session.contract.test.ts
server/claude-settings-file.test.ts
server/claude-task-scan.test.ts
server/claude-task-scan.ts
server/client-connection-log.test.ts
server/cliproxy-routes.ts
server/cliproxy.fake.ts
server/cliproxy.test.ts
server/cliproxy.ts
server/cmd.test.ts
server/cmd.ts
server/codex-composer-regression.test.ts
server/codex-daemon.contract.test.ts
server/codex-images.ts
server/codex-linked-completion.test.ts
server/codex-process-lock-store.test.ts
server/codex-process-store.test.ts
server/codex-steering.ts
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.
Merged head c5c6176b20a5 as cde429438895 on GitHub's checks, with no unresolved review threads.
Reviewer
Verdict
Note
machine-proof
CLEAR
rule3
CLEAR
The owner's refactor (server, part 1 of 8), merged by the merge pass on his word under rule 3. A machine proof removed comments and compared the merge base with the owner's head: 99 of the 101 files are identical. The two that differ were read by a fresh reviewer and by Codex: server/claude-store.ts names its macOS sysctl constants (CTL_KERN 1, KERN_ARGMAX 8, KERN_PROCARGS2 49; the calls still pass [1, 8] and [1, 49, pid]), and server/codex.test.ts names its thread clock ids (3 on Linux, 16 on macOS).
The deleted comments were searched for the five kinds the owner keeps (892 distinct hit lines); a fresh reviewer kept 92 blocks, put back word for word by the merge pass's worker: mostly security notes in server/auth.ts and server/access.ts (constant-time token comparison, the cookie's flags, the guessing budgets, reading the peer from the end of the forwarded header, counting a wrong token in the same step as the check), plus Windows, Linux and macOS facts and measured numbers.
Low note: server/darwin-process.ts still writes [1, 8] as a raw literal (not part of this pull request).
)
## What
#4054 (`server/`, part 1 of 8) was part of the repo-wide comment pass
and merged before the owner's rule for comment-removal PRs: security
notes, platform facts, measured values, third-party attribution, Rust
SAFETY notes and traps that name a concrete breakage stay. This PR puts
back what it dropped of those, word for word where the code is
unchanged, on today's `main`.
How the notes were picked: a Codex adversarial review (gpt-6.2-sol,
reasoning high) of the merged commit against its parent listed every
deleted comment it took for a kept kind; each finding was checked
against the code before the pass and today's file, and put back only
when it is one of those kinds. A trap came back only when it names what
the obvious change would break. Notes whose code has since moved sit on
that code now; notes whose code is gone, or that are no longer true,
stay out.
Comments only: no code changes. The refactor-merge kit's `proof.sh`
checks that every file is identical once comments are removed; lint
directives (which it counts as code) stay out.
## Details
### Lines restored per kind
Approximate: a mixed block counts under its main kind.
| Kind | Findings accepted | Lines |
|---|---|---|
| Security | 402 | ~720 |
| Platform fact | 211 | ~445 |
| Measured value (size, timing) | 24 | ~60 |
| Attribution: mulberry32 in claude-images.test, "#362 by @WOULDU-pres"
in api.contract.test | 2 | 3 |
| Trap (names a concrete breakage) | 80 | ~205 |
There are 783 HIGH/MEDIUM findings: 719 accepted, 42 traps declined, 9
rejected, 13 about the PR body (ignored).
Of the 13 LOW findings, three were fixed: the kept comment had been cut
mid-sentence (claude-store.ts:148, claude-input.ts:247,
codex.test.ts:1621). The other ten keep the same meaning in other words,
so they were left.
14 notes Codex did not flag came back under the rule:
- in this slice:
- access.ts: "the request's Host header, as sent"
- introductions.ts: the 30-day `INTRODUCTION_TTL_MS` reason
- background-agent.ts: "throws herdr's pane_not_found"
- background-agent.contract.test.ts: the 30 s `FRAME_WAIT_MS` reason
- app-revision.ts: `atStart`, "a dist/ rebuilt since"
- in the Claude files:
- claude-store.ts: the 2 s `PROCESS_MISS_TTL_MS` reason; three inline
`catch` notes ("gone, or not ours")
- claude-subagents.ts: the `BUSY_HOLD_MS` reason; the `busy()` note
"Claude writes a turn's prompt to its transcript as the turn begins"
- claude-subagents.test.ts: the 16 MiB window and 5.5 MB agents sizes
- agent-identity.ts: hc's `Foreground.pid`
### Declined, rejected, skipped
42 trap findings were declined: they give a design reason, describe the
code, or name a test target or regression. Examples:
- api.contract.test.ts 3419, 3532, 3573 and six more: "regression (fails
on main): ..."
- bridge.test.ts 58, 67, 125, 195, 260: regression notes on PID reuse
and EPERM, and the test's tunnel and buffering setup
- account.contract.test.ts:1393 "a stop right then keeps only that";
mailbox.ts:364 "before this page is acknowledged ... keep the rest on
disk"; attach-held.contract.test.ts:214 "the pane itself prints herdr's
refusal"
- claude-input.ts:194 "Positive proof of an ordinary empty input box";
claude-settings-file.ts:54 "a `--` there included"; codex-images.ts:172
"never holds the bridge for more than a window's work"
9 findings were rejected:
- claude-store.ts 294 and 296: the `CTL_KERN` / `KERN_PROCARGS2` notes;
#4054 turned the numbers into named constants.
- claude-transcript.ts:14: describes the parser.
- codex-daemon.test.ts 182 and 256: "Then" lines that restate the
assertion.
- agent-launch.ts:1, bridge.ts:37, api.contract.test.ts 3306 and 3526:
about our own code, or the test's probe.
Left out on purpose:
- Narration in mixed blocks, for example "Tests pass a temp one." and
the opening sentences of several doc blocks.
- One case where only the note's later sentence came back:
claude-transcript.ts `claudeTranscriptStart`, which starts "null while
...".
### Security notes put back
- **access.ts**:
- field docs:
- loopback forms
- shared token (cookie or bearer)
- the device the cookie belongs to
- the tagged node names no owner
- the sole login `tailscale status` proves
- MagicDNS name and tailnet IPv4
- OVIS_TAILSCALE_SERVE_ONLY
- `gated` closes the gate
- Portal proof, and X-Portal-User / X-Portal-Auth "as sent"
- Host "as sent"
- "127.devbox.example may point anywhere"
- `lanExposed`: who is let in as open, and the bind scope
- `bindScope`: a name is never resolved
- `inTailnet`
- no-login requests
- Host-only proxy
- `forwardingHeaders` versus `cameThroughProxy`
- `machineForwardingHeaders`
- PROXY_HEADERS
- the trailing dot
- `addressesNode`
- `isServeOwnerRequest`
- in `decideAccess`: a rebound page's Host; the sole-login proof and
Funnel; the open grant refuses rebound names
- **access.test.ts**: 31 case notes:
- forged headers off loopback
- tagged nodes pair
- no owner known yet
- the serve-only declaration
- Tailscale proving nothing
- unknown names
- rebinding and public domains
- a staged foreign login
- Funnel
- token precedence
- LAN clients claiming the proxy
- a named owner who does not match
- a login header alone
- a visitor's copied header against the token
- URL-parser authorities
- Portal proof versus X-Portal-User
- loopback bind exposure
- token and paired device close the gate
- the serve ingress shape and unverified headers
- **access-authority.contract.test.ts**: a rebound page is let in by
neither the open grant nor a typed login; a tagged owner counts only at
the tailnet name; controls for the PC's own names
- **auth.ts**:
- device cookie flags
- legacy cookie names accepted for a year, and cleared on a fresh
credential
- a bearer header outlives sign-out
- the open pre-auth routes
- clearing the device cookie
- no budget for an unknown address
- shared hold for admitted addresses
- the shared-budget bound
- `admit`
- a held Bearer never compared
- the budget spent first
- sign-out drops both credentials
- the right token spends both waits
- **auth.test.ts**:
- a held request never reaches the comparison
- per-address budgets
- only the proxy-appended forwarded entry believed
- the origin check: either cookie is session-bearing; the custom header
is the non-browser proof; the exemption is the path; a missing Origin is
refused
- **account/holds.ts**:
- the header: on disk, a stop lifts neither, an unparsable file holds
every add
- `ACCOUNT_HELD_MAX`
- read errors hold every add
- a confirmed barrier is not taken over
- each file read separately
- `stale` take-over
- first successful link wins
- `enrollingMember`
- held keys
- `overflow`
- `holds` and `full` reasons
- **account/introductions.ts**: ids derive from keys; an introduction is
only a hint
- **account/records.ts**:
- `AddGates` docs
- self-removal
- held key or held signer
- a waiting remove gates later adds in the batch
- undecided keys
- enrollment order
- `applyLink`: the session is its authority
- **account/mailbox.ts**:
- admission TTL
- pull floors for joins and refused sign-ins
- `PENDING_MAX`
- an unparsable queue is not empty
- `pendingError`
- `gates`
- `holdsEveryAdd`
- `waitingRemoveKeys` as `blocked`
- one retry run at a time
- `admitted`: 10 min and 10 s limits
- `pullForRefusedSignIn` budget
- `freshen` proof
- `wait`: a relayed record never pushes one out
- a full queue makes the remove undecided
- nowhere to keep it
- on disk before ack
- stop on a local registry error
- an add later in the page meets the remove
- refused records acknowledged too
- `trim` latch
- the latch on disk first
- **account/routes.ts**:
- drive access and mutation guard
- the watcher's one route
- `?fresh=1` removals
- who names the relay-pass account
- the enrollment barrier on disk, never lifted by a refused link
- a stale barrier taken over
- the first successful link keeps the wait
- only a member's session may leave a removal waiting
- the caller is a member
- held keys before any add
- overflow
- only the linking member hands over adds or ends the wait
- **account/account.contract.test.ts**:
- session authority
- account key from the next sign-in
- a local pairing wins
- a damaged record dropped
- the barrier survives restart
- remove applied between rounds
- a full queue latches
- adds do not hold others
- restart keeps a re-pairing
- sign-in pull budget and equal timing
- introduction scope
- the old key's rights
- relayed records push none out
- the start-up repair keeps a newer row
- **alert-webhook.ts**:
- the secret field
- who saved it
- generation scoping
- loopback http only for tests
- `canDeliver` before each try
- a loopback or relay link base never replaces a reachable one
- a watching device refused before the routes
- **alert-webhook.test.ts**: an ntfy topic is the whole secret; a save
keeps the URL; open-LAN alerts last only while open
- **attach-held.contract.test.ts**:
- nothing typed through the waiting bridge, nor A's half-typed command
- an observer may not take over
- keys refused past the exit budget
- **background-agent.contract.test.ts**: an agent whose files are links
is none of this session's
- **claude-store.ts**:
- unreadable PID records
- only a complete environment read proves "none exported"
- ambiguous or unreadable records are never the default store
- copied stores prove neither holder
- a process gone or not ours
- `claudeStoreOf` never substitutes the default store
- an unreadable store is an error
- background-job transcript matching, with state.json agreeing
- bounded job-state read with no FIFO or link (#1876)
- the `/branch` parent: non-blocking, no symlinks
- a torn write gives no identity
- attach clients
- two stores claiming a process
- walk proofs not shared
- HERDR_PANE_ID inheritance
- `lastEntrypoint`
- `ownSessionInstead`
- only a `claude-<uid>` folder this user owns
- **claude-store.test.ts**: an unreadable environment gives no session;
no links followed; a base this user owns is not another uid's
- **claude-subagents.ts**:
- header: only plain files read, ids are plain words, prompts and
answers stay here
- `AGENT_ID`
- a quoted block is not a tool result
- `openPlain`: FIFO or link swaps
- another session's rows
- linked or swapped folders list nothing
- folder chain identity
- `validDetailId` length
- `stillThere`
- `foreign` answers nothing
- a replaced file or ancestor taints the read
- a new Claude session cannot read it
- **claude-subagents.test.ts**:
- linked agent files and folders
- linked parent transcript
- another session's id
- refusing to follow links
- file identity
- one foreign record taints the file
- no prompt, event or argument leaks
- **claude-transcript.ts**: terminal controls stripped in one pass; only
a message's first block can be a header
- **claude-input.ts**: Send anyway goes only over exactly that box; a
restored draft counts only on a verified viewport
- **claude-images.test.ts**: no picture from a rejected scan's boundary;
the other picture is not served; a read vouches only for earlier lookups
- **claude-settings-file.ts**:
- %LOCALAPPDATA%, not %TEMP%
- directories made without traversing a link
- only a regular non-linked file with matching identities
- an entry turned into a link is refused
- **cliproxy.ts**, 38 notes on hidden Hub accounts:
- identities widened only from shown rows
- the hidden list must be the user's own regular file under the cap
- only fixed messages cross the boundary (upstream errors echo
credentials)
- hidden or removed accounts' credentials never used
- partial reads fail closed (blind)
- a Hub or key change drops rows
- an oversize save fails
- `checkCovered`
- both views must allow a read
- a reused file name carries no rows
- **cliproxy.test.ts**:
- hidden accounts never read
- ambiguity reads nothing
- an uncovered key blinds, and the way out survives restart
- Bob under Alice's file name
- no older list
- the hidden key alone
- **cliproxy.fake.ts**: never reads credentials or calls a provider
- **cliproxy-routes.ts**: pending OAuth sessions belong to this app
- **codex-steering.ts**:
- `fresh` re-asked, stale write withheld
- the live composer only
- only Send now interrupts, only for `text`
- the caller rechecks identity, lease, authority and prompts
- **codex-daemon.ts**:
- only initialize, initialized and skills/list
- experimentalApi false
- never start a daemon
- one provider per home
- the home read from /proc only
- **codex-daemon.contract.test.ts**: the pane's own home's daemon, never
the server's
- **codex-images.ts**:
- the store anchor is taken once and blobs are read only from it
- links inside or above the store
- the blob must be a regular file hashing to its digest, the same file
after the read
- a tool picture refuses remote URLs, paths and svg
- hash refs keep base64 and paths out
- held attachment, no FIFO wait
- bound history only
- **codex-images.test.ts**: later opens meet the other folder
- **codex-binding.contract.test.ts**: no other rollout stands in; the id
alone ties nothing
- **codex-process-store.test.ts** and
**codex-process-lock-store.test.ts**: no inferred store across a
descriptor change; ownership rechecked
- **codex-processes.test.ts**:
- no weaker fall-through
- remote-resumed thread
- shared daemon on pane A
- another user's process
- a rename before the stat
- a screen match proves no file
- **codex.test.ts**:
- name without UUID needs agreeing ids
- the name proves integrity, not parenthood
- a link's own name contradicts the header
- outside the store stays out
- an unrelated later rollout is not the base
- **api.contract.test.ts**:
- unheld locks select nothing
- bridge token: GET only, `/api/access` its own, wrong token opens
nothing
- same-origin gate first
- other PC's bridge and browser token
- cross-site pages make no folders and read no repo contents
- prompt files not written through symlinks
- an observer must not resize or seed the pty
- no-token gate sources
- rebinding page pairs
- a rejected identity is not an absent one
- mutation guard
- first pairing closes the gate, and revoking never reopens it
- plugin `.env` token
- a visitor's login header meets the token
- open-LAN warning only for that state; Funnel never open
- watcher prompt redacted and capped at 1 MiB
- named store never falls back
- watchers cannot write preferences
- no secrets in the diagnostics facts
- first cookie use confirms pairing
- move badge needs the bridge token
- a damaged registry is not a first install
- proxy and rebound-name ingress
- **bridge.ts**:
- `registered` conditions
- never overwrite a live bridge
- fails closed without the guard
- relay client-ahead cap
- **bridge.test.ts**: a malformed birth once overwrote the live
descriptor; a host name may resolve elsewhere
- **cmd.ts**: each cwd is only a candidate; the session must validate
inside it
- **client-connection-log.ts**:
- a trickling body gives up its slot, with one deadline for the whole
body
- only allow-listed fields logged
- the quota is charged after validation
- **agent-catalog-install.ts**: other fields refused, no command or
platform
- **agent-catalog-detect.ts**: where another program has the binary's
name, nothing is looked up or run
- **agent-catalog-routes.ts** and **agents-routes.ts**: read-only GET,
access gate first
- **agent-catalog-routes.test.ts**: a watching device never reruns the
user's shell
- **agy.ts**: a renamed-over file waits for the next read to authorize
it
- **agy-store.ts**:
- only paths the selected process holds
- a failed holder query proves nothing
- only a fresh complete scan is singleton evidence
- **catalog-sources.ts**:
- providers only read
- the asking server's stores, never a process-wide default
- builtin rows never removed or added
- **catalog.conventions.test.ts**: only the terminal attachment may take
over, after an explicit user request
## Validation
- `bun run check fast`: passed (18,593 unit tests, typecheck, build,
generated themes and types).
- `proof.sh` (comments only), `ready.sh` (required checks, threads,
CodeRabbit, main) before the merge.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Part 1 of 8 for
server/in the repo-wide comment pass. This part covers:access.ts,auth.ts,account/agyalert-webhook.ts,bridge.ts,background-*cliproxy.ts,cmd.tsAbout 4,800 comment lines go. What stays:
The public HTTP/WS contract: doc comments that define
/api/*requests and answers, theAuthorization: Deviceheader, and the bridge descriptor's fields that older bridges wrote without.Machine-read comments: the
// fixed wait:markers.Behaviour we cannot change:
/proclayouts, Windows Restart Manager and file idsEach was checked against fixtures, the installed tool or its source where one was available.
Every comment-only change was checked against
origin/mainby syntax tree. No test, script or doc reads a deleted comment.This PR touches authentication files (
access.ts,auth.ts,account/), with comments and no code changed there, so it waits for a real review (AGENTS.md).Code changes (mechanical, no behaviour change)
server/claude-store.ts: the sysctl MIBs[1, 8]and[1, 49, pid]areCTL_KERN,KERN_ARGMAXandKERN_PROCARGS2.server/codex.test.ts: the clock ids3and16areCLOCK_THREAD_CPUTIME_ID_LINUXand_DARWIN.Rules that only a comment stated (deleted, not enforced yet)
Security
auth.ts:recordPresentedTokenFailuremust run in the same synchronous step aspresentedToken, or concurrent guesses pass the check. Its only caller,dispatch.ts, still says so. The re-read of the wait after the body arrives is covered byauth.test.ts.access.ts:relayPeeris never derived from headers or cookies.decideAccesschecks Portal before the token gate and the token gate before the login header.cliproxy.ts:alert-webhook.ts:loopbackHttpis for the tests' fake destination only.client-connection-log.ts: the endpoint never invokes herdr or accepts input, and diagnostics never affect the app's connection.codex-daemon.ts:initialize(experimental API off),initializedandskills/list, and connects to nothing else. TheREQUESTS/NOTIFICATIONSsets hold part of this.codex-steering.ts: only Send now may interrupt, and only for text. The caller rechecks identity, lease, authority and prompts in the same read.Order and state
adopt-legacy-env.tsis imported first by every server entry point.account/routes.ts: the enrollment barrier is written to disk first, and a refused link never lifts it.account/mailbox.ts: records are written to disk before an acknowledgement, and every record read is acknowledged.bridge.ts registerBridge: a guard that could not be released fails the start.agent-catalog-install.ts: the command check runs again right before typing.agent-catalog-detect.ts: only absolute PATH entries count.Kept in step
claude-store.ts: an option a later Claude Code adds goes into theCLAUDE_*option sets.claude-input.ts:BOX_LABELED_RULE_REis used only by the box reader.claude-settings-file.ts: the folder stays out of the server's state dir.docs/agent-commands.mdcovers the choice.Left open (redesigns, not done here)
decideAccessandobservedIngresscarry security meaning in their order and could be named, ordered rules.auth.ts:sharedKeyparses" via "out of a partly client-made string (authClientcould return{address, peer})claude-artifacts.ts PAGEis a security allow-list and could be named so.applyEnrollment's order, and the barrier lift inAccountHolds.adopt-legacy-env.tsas a side-effect import (lazy readers), the catalog's hand-rolled single flight, and the install state machine.agent-tasks.ts's retry state machine has a known limit.agy-store.tsrelies on a read order for pid-reuse safety and tangles cache, backoff and proof inwindowsHeldPaths.claude-subagents.ts:Parent's ~15 fieldsreadLinesprotocolselfResumedbackgroundAgentDetailclaude-transcript.ts's handback pairing (Subagent markdown output in chat mode regression #3658).cliproxy.ts: its hidden-account and fail-closed "blind" logic could be its own module with named states.claude-store.ts:claudeStoreOf's return typeunreadablemode switchclaudeTranscriptFile's out-parameterfollow's flagsdarwinEnvironmentduplicatesdarwin-process.tsclaude-input.ts:colorsmust be a verified live-screen read (a type could say so), and its row walk copiesclaudeGreyInput's.claude-settings-file.ts:cacheDirectory/holdshide their checks.codex-daemon.ts:ownershipmixes keep-or-close with backoff.codex-images.ts:>= 32limit could come from the prefix regexStepsyields two meaningsCODEX_TOOL_IMAGE_REFhas unnamed groupsimagePartref keeps paths out of responsesbridge.ts relayTarget'snullmeans two things.background-wait.ts runningtakes positional booleans.claude-command-history.tshas scheduling rules in long functions.app-revision.ts's desktop branch.client-connection-log.ts's quotas and deadlines.codex-binding.contract.test.ts's stand-in script modes.Validation
bun run check fast: passed (18,574 unit tests, typecheck, build, generated files).server/claude-store.test.ts(110) andserver/codex.test.ts(125) pass with the two code changes.🤖 Generated with Claude Code