Skip to content

Fix CLI exit and error reporting, runtime discovery ownership, task errors and hosted OAuth hardening - #210

Open
harshsaver wants to merge 31 commits into
mainfrom
maint/verified-main
Open

harshsaver wants to merge 31 commits into
mainfrom
maint/verified-main

Conversation

@harshsaver

@harshsaver harshsaver commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

Fixes and documentation corrections found while reviewing the repository for a public release. Each commit is self-contained and has its own tests where behaviour changes.

Bugs

  • attachment upload printed null and exited 0 when the server rejected the upload (shadowed error).
  • agent run exited 1 for any failing child and 0 after an interrupt; it now passes the child's exit status through.
  • Completing or releasing an unknown task returned CONFLICT; the state-machine specification requires NOT_FOUND.
  • A human could not answer a pending escalation once the scope held 10,000 active messages. Answers now get bounded headroom of their own.
  • Committing an expired inbox reservation released already-expired messages before expiring them.
  • Concurrent hosted sign-in checks that share one Auth lookup failed together when the first caller cancelled.
  • The npm launcher force-killed the native process on Windows Ctrl+C before it could shut down. It also exited 0 when the child died from SIGPIPE, and re-raising SIGUSR1 started Node's inspector.
  • A failed or cancelled pullInbox/PullInbox commit left messages reserved for 30 seconds. The clients now release the reservation.

Security hardening

  • Without XDG_RUNTIME_DIR, the runtime directory falls back to the shared temporary directory. Clients now ignore a bus.json that another local user owns or could have replaced, and the daemon refuses a runtime directory owned by another user. Before this change, a planted discovery file could receive scope tokens.
  • Hosted OAuth: unauthenticated dynamic registration could permanently fill the 50,000-client cap. At capacity, the oldest clients that are over a day old and hold no request or token are now evicted.
  • Hosted OAuth: authorization responses send the RFC 9207 iss parameter, and the server metadata advertises it.
  • Hosted workspaces: admins can revoke only the member invitations they are allowed to issue.

Documentation

  • The changelog lists what landed after the 0.2.0 candidate. The guides note that the task claim/progress, question and downloadAttachment features need a source build until the next release.
  • The Desktop integration guide now uses the current binary and archive names.
  • The README connection-options link is fixed. The CLI messaging example now shows the daemon and workspace setup. The MCP spec's receipt authorization matches the runtime. The security policy covers the hosted service.
  • Added a bug report form and a link to private vulnerability reporting.

Verification

  • go test -race ./..., go vet ./..., and the Postgres hosted tests.
  • The TypeScript SDK checks and integration test, and the workspace UI Playwright suite.
  • The npm 0.2.0 quickstart in a clean container with Claude Code and Codex installed.
  • The CLI messaging and task walkthrough against a freshly built binary.

A shadowed error variable meant a rejected upload printed null and
exited successfully. Return the upload error instead.
When XDG_RUNTIME_DIR is unset the runtime directory lives under the
shared temporary directory. Clients now read bus.json only when it and
its directory belong to the current user and are not group or world
writable, and the daemon refuses a runtime directory owned by another
user instead of failing with a permission error.
Dynamic client registration is unauthenticated and clients were never
removed, so filling the 50,000-client cap blocked new connections
permanently. At capacity, evict the oldest clients that are over a day
old and hold no pending request or token.
Advertise and send the RFC 9207 iss parameter so MCP clients that talk
to several authorization servers can detect mix-up attacks.
Admins can issue member invitations but could revoke any pending
invitation, including admin invitations from the owner. Apply the same
role rule to revocation as to issuance.
Concurrent requests with the same session token share one Auth lookup.
It ran on the first caller's context, so a cancelled request failed
every other request waiting on it.
The README installs agentintercom-cli@0.2.0, but several documented
commands landed later. List them in the changelog and note in each guide
that they need a source build until the next release.
The state-machine specification requires NOT_FOUND for an unknown task,
as claim already returns. Complete and release reported CONFLICT for any
task they could not change.
Resolving a pending escalation sends the answer as a message, which was
refused with BACKPRESSURE once the scope held 10,000 active messages,
leaving the question unanswerable. Give answers bounded headroom of
their own and accept archives within that limit.
Committing an expired reservation released its messages without first
materializing message expiry, so an already-expired message was
reported as released before it was reported as expired.
A failing child made agent run exit 1, and an interrupted run exited 0.
Exit with the child's status, and report a failure after an interrupt.
Receipts are readable by the sender or recipient agent only, as the HTTP
specification and the runtime already state.
…cher

On Windows the launcher forwarded Ctrl+C with child.kill(), which
terminates the native process before the daemon can shut down; the
console already delivers the interrupt to it. Report signal exits as
128 + signal, and stop re-raising SIGPIPE (ignored by Node) and SIGUSR1
(which starts Node's inspector).
PullInbox reserves and then commits. A failed or cancelled commit left
the messages reserved and invisible until the 30-second reservation
expired. Release the reservation on a best-effort basis before
returning the error; a reservation that did commit is unaffected.
Replace the internal service codename and references to private
repositories, pull requests and commits in the managed-connection,
remote-integration, release-notes and verification records with neutral
descriptions of October Desktop and the hosted service. Drop hosting
provider details and unrelated planning items from the pilot report and
point its links at the current repository name.
RFC 6749 section 4.1.2 asks the authorization server to revoke tokens
issued from an authorization code that is presented again. A replayed
code now retires its connection the same way a replayed refresh token
does. The replay must carry the code's PKCE verifier, so a party that
only observed the code cannot use it to revoke the legitimate client's
connection.
Requests that fail before the runtime responds now throw BusNetworkError,
BusTimeoutError or BusAbortError, subclasses of a new BusTransportError
that records the failure kind and the underlying cause. They still extend
BusError with code INTERNAL, so existing handlers keep working.
The unauthenticated OAuth registration, authorization and device pairing
endpoints only had global rate limits, so one client could exhaust them
for everyone. hosted serve --client-ip-header names the forwarding header
the TLS proxy sets; each client then gets its own bucket, checked before
the global one so excess requests do not drain shared capacity. The
client is the rightmost untrusted entry in the header, proxies are
trusted from loopback unless listed with --trusted-proxy, and IPv6
clients are grouped by /64. The per-client table is bounded. Limits stay
global-only unless the header is configured.
@harshsaver

Copy link
Copy Markdown
Member Author

🤖 Agentbox PR audit: approved, but the branch got new commits after the audit

What this PR changes

  • What it does: Repairs command failures, message pickup, shared tasks and hosted sign-in; closes a local credential-discovery hole and updates release documentation.
  • What changes in the product:
    • Failed file uploads display an error and fail the command.
    • Programs wrapped by agent run or session start return their actual nonzero exit status to scripts.
    • Windows Ctrl+C through the npm command lets the native service handle shutdown.
    • Failed message pickup attempts try to return reserved messages immediately.
    • Human answers get room beyond a full message backlog; unknown tasks report that they were not found.
    • Hosted administrators can revoke only invitations their role permits. One canceled sign-in check no longer fails other callers sharing its lookup.
    • The hosted service can recover registration space from old unused app registrations, and identifies itself in authorization responses.
  • Why it exists: These failures were found during the author's public-release review. The discovery flaw lets another account on a shared machine direct clients to a fake service and capture their credentials.
  • Why merge (or why not yet): The implementation addresses those failures without a blocking regression found in this review. CI is green across Linux, macOS, Windows, the SDK and hosted database tests.
  • What to expect after merging: Scripts can distinguish wrapped-program exit codes. Service-management commands also pass through the underlying tool's failure code. Linux and macOS refuse discovery owned by another user; a pre-created shared temporary folder may require choosing a private runtime directory. Inbox cleanup remains best effort and can delay a canceled call by up to five seconds. Add branch-specific launch evidence as a follow-up.
Full audit (Claude (claude-opus-5-5, xhigh) × Codex (gpt-6.1-sol, xhigh), 2 turns, commit 6e611cb)

PR audit: #210 — Fix CLI exit and error reporting, runtime discovery ownership, task errors and hosted OAuth hardening

Head: 6e611cb

Sign-off

  • Claude (claude-opus-5-5, xhigh): ✅ satisfied — every change is a bug fix, security fix or doc correction that I checked against the code. I found nothing blocking. The remaining items are non-blocking follow-ups.
  • Codex (gpt-6.1-sol, xhigh): ✅ satisfied — independently checked all changes and the existing findings; no blocking regression found. Corrections and added coverage notes are non-blocking.

Decision

merge — no blocking findings; the changes address concrete failures, and all 11 CI checks pass at 6e611cb. Merge remains conditional on the final checks passing.

Should this exist?

  • Verdict: yes — the PR description documents concrete release-preparation bugs and security failures. Unknown-task errors contradict spec/0.1/state-machines.md:105-106; untrusted local discovery can disclose credentials; anonymous OAuth registrations otherwise occupy capacity permanently. The PR has no discussion comments or linked issue supplying additional requirements.
  • Product-rule issues: None blocking. The existing local message cap is relaxed for escalation answers, using the existing pending-escalation count (bus/store.go:26-32,851-859). No periodic work or automatic deletion of local user work is added. OAuth eviction runs only during registration at capacity, deletes at most 100 old unused registrations, and protects the hosted server (bus/hosted_oauth.go:345-363). Its one-day horizon also appears in existing OAuth retention (bus/hosted_maintenance.go:18-19). The five-second inbox cleanup follows existing cleanup budgets (cmd/agentintercom/main.go:1024-1027, sdk/typescript/src/session.ts:129). The new 64 KiB read bound covers the app's generated discovery metadata (bus/daemon.go:122,125-130), not messages or user history. Bundling remains a process note below.
  • Simpler alternative: No required redesign. The small task-existence query is reasonable: the existing taskFrom also decodes the task and loads dependencies and progress (bus/store.go:1293-1322), so substituting it is not an unqualified simplification.
  • Real-launch evidence: missing — the description reports a fresh-binary CLI walkthrough and an npm 0.2.0 quickstart in a clean container, but supplies no startup log from this branch or hand check of Windows Ctrl+C. Existing CI includes macOS tests and distribution smoke checks; it does not establish those manual paths. Under Harsh's 2026-11-14 rule, this is non-blocking.

What changes (plain language)

  • What it does: Repairs command failures, message pickup, shared tasks and hosted sign-in; closes a local credential-discovery hole and updates release documentation.
  • What changes in the product:
    • Failed file uploads display an error and fail the command.
    • Programs wrapped by agent run or session start return their actual nonzero exit status to scripts.
    • Windows Ctrl+C through the npm command lets the native service handle shutdown.
    • Failed message pickup attempts try to return reserved messages immediately.
    • Human answers get room beyond a full message backlog; unknown tasks report that they were not found.
    • Hosted administrators can revoke only invitations their role permits. One canceled sign-in check no longer fails other callers sharing its lookup.
    • The hosted service can recover registration space from old unused app registrations, and identifies itself in authorization responses.
  • Why it exists: These failures were found during the author's public-release review. The discovery flaw lets another account on a shared machine direct clients to a fake service and capture their credentials.
  • Why merge (or why not yet): The implementation addresses those failures without a blocking regression found in this review. CI is green across Linux, macOS, Windows, the SDK and hosted database tests.
  • What to expect after merging: Scripts can distinguish wrapped-program exit codes. Service-management commands also pass through the underlying tool's failure code. Linux and macOS refuse discovery owned by another user; a pre-created shared temporary folder may require choosing a private runtime directory. Inbox cleanup remains best effort and can delay a canceled call by up to five seconds. Add branch-specific launch evidence as a follow-up.

Findings

Blocking

  • None

Non-blocking

  • Launch evidence and platform coverage: sdk/typescript/cli/agentintercom.cjs:47-49 changes Windows console handling, but its new test uses a fake host (sdk/typescript/test/cli.mjs:76-89). test:errors runs on Ubuntu, including the Node 20/22 jobs (.github/workflows/ci.yml:62-102). The distribution smoke test runs on all three operating systems but does not exercise Ctrl+C (scripts/test-npm-install.mjs:79-91). Ask the author to record a startup log and Windows Ctrl+C using a package built from this branch. On macOS, with a running daemon and an existing workspace named audit, a valid check is agentintercom agent run --scope audit --id exit-probe --name 'Exit probe' -- sh -c 'exit 7', followed by echo $?. An unpinned npm install or the published 0.2.0 package would not verify this branch. The Windows change agrees with Node's documented forceful termination behavior.
  • Foreign-owner rejection is not exercised by ordinary CI: the actual foreign-file/foreign-directory assertions are gated on effective UID 0 (bus/run_file_unix_test.go:51-65); hosted runners execute these tests without root. A small unit test can supply an os.FileInfo with a foreign syscall.Stat_t.Uid to ownedByCurrentUser (bus/file_lock_unix.go:28-30), without adding a production seam. Keep the root-only filesystem checks as additional integration coverage. The symlink and permission cases do run normally.
  • Ownership diagnostics need the relevant path and setting: secureDirectory checks the runtime directory, data directory and scope-credential directory (bus/daemon.go:176-177,195,230; bus/local_credentials.go:31,77,80), but always suggests runtime settings. Suggest OCTOBER_BUS_DATA_DIR for a data-path failure. Client discovery rejection names neither the offending path nor a remedy (bus/daemon.go:95). The check also changes root behavior: a root process previously could chmod and use another UID's directory; it now refuses it. No documented deployment relies on that arrangement, and the hosted unit uses its own service account (deploy/hosted/october-bus.service:7-14).
  • OAuth recovery is narrower than the comment promises: bus/hosted_oauth.go:343-344 says MCP clients register again when a client ID becomes unknown. The MCP TypeScript SDK's authorization code invalidates stored client information after invalid_client or unauthorized_client; constructing a new browser authorization does not first validate an existing registration. A previously registered client with no remaining request/token can therefore reach the 400 page at bus/hosted_oauth.go:195 after eviction and need its saved registration cleared. Reword the comment to avoid guaranteeing automatic recovery. Existing active grants are excluded by the SQL. The existing global registration limiter still permits sustained registration denial; this PR removes permanent occupation by abandoned registrations, not every denial-of-service path (bus/hosted_http.go:145).
  • OAuth coverage misses old clients holding grants: the new capacity test checks an old unused client and a recent client (bus/hosted_oauth_test.go:334-356). It does not test old clients protected by an oauth_requests or oauth_tokens row, so neither NOT EXISTS exclusion is directly tested. The approval helper checks iss, but the denial test does not assert it and metadata support has no dedicated assertion (bus/hosted_oauth_test.go:109,310-314). These are useful security regression cases; the implementation includes the required protections.
  • Exit-status passthrough reaches other subprocesses: exitCode unwraps every *exec.ExitError, not only managed agents (cmd/agentintercom/main.go:1237-1243). Service operations return or wrap systemctl/launchctl failures (cmd/agentintercom/service.go:148-159,173-174,197-198), so their statuses also propagate. This is reasonable but undocumented in the changelog. Signal termination maps to 1 in Go because ExitCode() is negative; the npm launcher reports 128 + signal (sdk/typescript/cli/agentintercom.cjs:62-66). The new Go test exercises the helper, not an end-to-end agent run, session start or interrupt (cmd/agentintercom/exit_code_unix_test.go:12-20).
  • Cancellation has observable cleanup latency: both inbox clients await best-effort release without the caller's cancellation, for up to five additional seconds (bus/client.go:200-209; sdk/typescript/src/client.ts:686-693). The original error is preserved and successful delivery is not undone, but callers with a shorter timeout may return later than that timeout. The new tests cover a failed HTTP commit, not cancellation, release failure or a lost successful commit response (bus/client_test.go:103-127; sdk/typescript/test/inbox.mjs:7-28). Add those cases when extending coverage.
  • Shared sign-in cancellation and its test: singleflight.Do plus context.WithoutCancel keeps a canceled handler waiting until the shared lookup finishes, bounded by the existing eight-second client timeout (bus/hosted_identity.go:60,126-129). It also holds a hosted request slot during that wait (bus/hosted_http.go:219-228), so the old audit's statement that this cannot affect users was too broad. DoChan plus selection on the caller's cancellation could release individual handlers while preserving the shared lookup. The regression test uses a 20 ms sleep, ignores the first result and does not count upstream requests (bus/hosted_identity_test.go:82-108). It can pass without exercising a shared lookup, and releasing the server immediately after canceling also races cancellation processing. Prefer deterministic synchronization and an upstream-call assertion.
  • Escalation headroom is finite: the change helps at the existing 10,000-message cap, but an inbox with 11,000 active messages still blocks answers (bus/store.go:854-859). AskHuman counts pending questions independently (bus/store.go:1681-1692), so prior unacknowledged answers can consume the extra room before another accepted question is answered. This improves existing behavior; it does not guarantee that every future accepted question remains answerable. Keep product wording bounded to the extra headroom. Archive import correctly accepts the expanded backlog (bus/archive.go:684).
  • Residual local denial of service: another user who pre-creates the default shared-temp runtime directory can still prevent startup; the ownership check prevents credential capture and gives a daemon-side remedy (bus/daemon.go:53-64,176-177). The checks apply to both Linux and macOS; the previous blanket statement that macOS is unaffected was too broad. Windows intentionally relies on its per-user directory rather than enforcing Unix ownership (bus/file_lock_windows.go:40-42).
  • Scope/process: this release sweep bundles CLI, storage, hosted authentication, launcher and documentation changes. The rules call for separating unrelated themes; keep future fixes separate. Here the description explicitly presents the release sweep, and its commits are individually reviewable and revertible. This remains a non-blocking process note.
  • Minor: the unreleased changelog omits the UI changes in Fix workspace dialog accessibility and keyboard focus #192/Workspace UI: paginate session directory (#183) and preserve composer drafts (#185) #199 and the bridge message correction in fix(mcp): make the ended-bridge message neutral about its cause #194, confirmed in history after the 0.2.0 bump. hostedOAuthClientLimit is mutable only to let a test lower the cap (bus/hosted_oauth.go:338; bus/hosted_oauth_test.go:343-345). The Desktop guide's old command names occur in a dated historical evidence table and can remain (docs/desktop-remote-integration.md:185-194).

Fix plan

n/a

Message to the developer

n/a

Questions for Harsh

n/a

Verification

  • Local review: read the PR description, all 21 commit descriptions, the complete 39-file diff and relevant surrounding code. The requested gh pr view ... --comments hit GitHub's deprecated Projects-classic GraphQL field; an explicit JSON query successfully retrieved the body, comments, reviews, commits and checks. There are no comments or reviews. No dependencies were installed; no build, typecheck, lint or tests were run. Implementation files remain unchanged; only this untracked audit document was written.
  • Runtime discovery: traced directory creation, run-file writes, owner/mode checks and all discovery callers, including CLI administration, gateway, local scope setup and MCP bridges. The generated file is owner-only and atomically replaced (bus/daemon.go:125-159); the new reader rejects symlinks and checks that the opened file matches the inspected file (:96-122). Reviewed local credential callers and dedicated-user deployment settings.
  • Inbox/store reasoning: release only touches matching reserved messages; committed messages lose their reservation and remain available for redelivery until acknowledged (bus/store.go:980-1008,1067,1173-1178). Per-scope PostgreSQL transactions serialize competing commit/release operations (bus/scope_authority.go:33-47). Expiry now occurs before release in an expired commit (bus/store.go:1144-1156), and the new test checks that no false release event is emitted. Task unknown/state/ownership branches, escalation accounting and archive limits were checked against their surrounding code and specification.
  • Hosted reasoning: checked invitation roles and transaction locking; OAuth client/request/token foreign keys, grant storage and cleanup; registration locking; and issuer handling on both consent outcomes. The foreign keys preserve integrity if concurrent authorization races deletion, although such a race can fail an authorization attempt. The metadata and returned issuer agree, including denial, as required by RFC 9207. No issuer is required on the internal browser-consent redirect because that is not the response to the OAuth client.
  • External API checks: verified Node signal handling, Windows subprocess termination, MCP SDK registration recovery and Go cancellation detachment against primary documentation/source. Corrected the audit's taskFrom reuse claim after reading its dependency/progress queries.
  • Documentation/history: checked source-build feature notes against the 0.2.0 bump at 7575c4c and subsequent commits; release archive/SBOM names against .github/workflows/release.yml:120-148; and receipt authorization against bus/store.go:966-968 and the HTTP specification.
  • Existing CI at the exact head: 11/11 checks SUCCESS: runtime on Ubuntu/macOS/Windows, npm-platforms, TypeScript SDK, Node 20/22, interoperability, hosted PostgreSQL, workspace UI and vulnerabilities. These are CI results, not locally rerun checks.
  • Final checks that matter: Go tests on Linux/macOS/Windows; Linux race tests; go vet ./...; formatting and CLI builds. Run the PostgreSQL hosted suite, especially OAuth capacity and invitation authorization. For the SDK, typecheck, build, test:errors and integration against a fresh native binary. Build/package the npm distribution and run test:distribution on supported operating systems. Existing green CI covers these functional suites; the ownership and coverage gaps above remain outside it.
  • Not exercised in this read-only turn: foreign-UID filesystem checks, real Windows Ctrl+C through a branch-built npm launcher, and a macOS end-to-end managed-command exit check. Missing hand-launch evidence is non-blocking under the supplied rule.

Audit log

  • Turn 1 (Claude (claude-opus-5-5, xhigh)): First audit from scratch.
    • Scope: read the PR body, the full diff and the surrounding code for every change. Traced every ReadRunFile/secureDirectory caller and the hosted deploy units.
    • External sources checked: RFC 9207 (iss rules), Node's subprocess.kill Windows semantics, the MCP TS SDK's re-registration behaviour.
    • Repo facts confirmed: OAuth table foreign keys, the order of the referenced PRs against the 0.2.0 bump, release artifact names, CI status at head.
    • Result: no blocking findings; decision merge. Non-blocking notes cover missing launch evidence, the root-only ownership test, the data-dir error message and the root behaviour change, the OAuth comment accuracy, exit-code reach into service, taskFrom reuse, singleflight cancellation latency, and PR bundling.
  • Turn 2 (Codex (gpt-6.1-sol, xhigh)): Independently reviewed the full diff, PR metadata and each prior finding. Kept merge with no blocking findings. Corrected the task-reader simplification claim, macOS and cancellation-impact wording, test line references and invalid launch-check examples; added non-blocking coverage gaps and the finite escalation-headroom caveat. No material decision or requested-fix changes; no builds or tests run.

Final checks (run once, after both agents agreed)

go mod download: PASS
SDK npm ci: PASS
Web npm ci --ignore-scripts: PASS in isolated copy
Changed-file lint: PASS (patch whitespace, gofmt, JavaScript, JSON and YAML syntax)
go test -count=1 ./...: PASS with PostgreSQL enabled, including hosted regressions
go test -race -count=1 ./...: unavailable on this host (ThreadSanitizer: unsupported VMA range; Found 47, Supported 48)
Base go test -race -count=1 ./...: identical host failure
go vet ./...: PASS
CLI build: PASS
Conformance CLI build: PASS
CLI demo: PASS
Ownership test binary build: PASS
Foreign-owner filesystem test as root: PASS
SDK npm run typecheck: PASS
SDK npm run build: PASS
SDK npm run test:errors: PASS
SDK npm run test:release: PASS
Node 20 build, error tests and release tooling: PASS
Node 22 build, error tests and release tooling: PASS
SDK npm audit --audit-level=high: PASS
Default govulncheck: analyzer/toolchain mismatch; identical on base
Govulncheck with Go 1.27.0: 13 standard-library findings
Base govulncheck with Go 1.27.0: same 13 findings; none introduced by PR
Govulncheck with Go 1.27.4: PASS, no vulnerabilities found
Web npm run build: PASS
Generated web assets comparison: PASS, matches tracked assets
Headless Chromium browser suite: PASS, 28 tests
PostgreSQL identity lifecycle script: PASS
npm run build:native -- --all: PASS, all six platform targets
npm run pack:distribution -- --all: PASS
npm run test:integration: PASS against freshly built native binary
npm run test:distribution: PASS on Linux arm64
Real Linux launcher smoke check: PASS (startup, exit code 7, interrupted command failure, clean daemon shutdown)
macOS/Windows execution and Windows Ctrl+C: unavailable on Linux; cross-builds passed
Tracked-file integrity: PASS, unchanged
Isolated PostgreSQL: stopped after checks
Logs: /home/harshsaver/pr-audit-checks/pr210-20261127T191944Z/logs

Automated review by Harsh's agentbox: two AI reviewers audited this PR against the project ruleset and agreed on it.

…romise

uploadAttachment threw synchronously for data over 16 MiB, so callers
that attached a rejection handler to the promise never saw the error.
Deleting an attachment took the process-wide maintenance lock
exclusively and waited for every running read, export and backup. Go
queues new readers behind a waiting writer, so a long export plus a
deletion in one workspace blocked file access in all of them, and
exports also held the global file mutex while reading every file.

Deletion now commits its tombstone without that lock and unlinks the
file only if no reader is running; otherwise garbage collection removes
it later, as it already does after a backup. Reads and exports no longer
hold the file mutex once the directory is open.
@harshsaver harshsaver added the agentbox: needs your input Claude and Codex need a decision from Harsh label Nov 27, 2026
@harshsaver

Copy link
Copy Markdown
Member Author

🤖 Agentbox PR audit: needs Harsh's input

Questions

  1. Should the per-visitor rate limit for the hosted service exist, and in this PR? Commit 49a4f19 adds an optional limit on how often a single visitor (by IP address) can register an app, start a sign-in or connect a device. Our own server does not turn it on. Nothing shows the problem it guards against has happened, and the hosted service has not been offered publicly yet.
    • a) Drop it from this PR (recommended). Revisit in its own PR after the roadmap's load and limit measurements, or after real abuse. The existing shared limits stay exactly as they are.
    • b) Keep it as an off-by-default option. No user is affected until an operator turns it on. If kept, change the fallback for a missing or misconfigured header so it doesn't throttle everyone together.
    • c) Keep it and turn it on for our own server. Add --client-ip-header X-Forwarded-For to the hosted unit (Caddy sets that header), fix the fallback, and give a source for the per-visitor numbers (e.g. 1 app registration per 10 seconds per address).
  2. OK to keep the other six commits added after the last audit? These are: revoking a connection when its one-time sign-in code is reused with its secret (follows the OAuth standard), clearer SDK errors for timeouts, cancellations and connection failures, the SDK upload fix, and the doc clean-ups.
    • a) Keep them in this PR (recommended). They are small, tested and listed in the changelog, apart from the upload fix.
    • b) Move them to a separate PR.

What this PR changes

  • What it does: Fixes a batch of command-line, message-service, SDK and hosted-service bugs found while preparing the public release. Closes a local security hole and two hosted sign-in weaknesses, and cleans up docs. It now also adds an optional per-visitor speed limit to the hosted sign-up and device-connect pages.
  • What changes in the product:
    • A failed file upload now reports an error.
    • Wrapped commands return their real success or failure code.
    • On Windows, Ctrl+C through the npm-installed command shuts the service down cleanly.
    • Messages from a failed pickup return to the inbox immediately.
    • Humans can still answer agent questions in a jammed workspace.
    • Hosted admins can no longer cancel owner-only invitations.
    • Hosted app connections recover when the app-registration table fills up.
    • If someone reuses a one-time hosted sign-in code (with its matching secret), that connection is now revoked for safety.
    • The SDK says whether a failed request timed out, was cancelled or could not connect.
    • The new per-visitor limit does nothing unless a server operator turns it on with a flag.
  • Why it exists: Release-readiness review. The security fixes stop another account on a shared Linux machine from capturing workspace keys, and follow the OAuth standard on reused sign-in codes. The per-visitor limit is meant to stop one visitor from using up shared sign-up capacity, but there is no evidence this has happened.
  • Why merge (or why not yet): Everything except the per-visitor limit is ready: checked against the code and green in CI on Linux, macOS, Windows and the hosted database tests. The per-visitor limit adds new limits and settings that nothing asked for and our own server doesn't use, so Harsh should decide whether it stays.
  • What to expect after merging:
    • Scripts see real exit codes.
    • agentintercom service status passes through systemd/launchd codes.
    • On a shared Linux machine, a pre-created temporary runtime folder makes the service refuse to start, with a message saying how to fix it.
    • A hosted app that retries a sign-in code after a lost response gets its connection revoked and must reconnect.
    • Follow-up: add a macOS/Windows hand check.

Answer in a comment on this PR; the next daily audit reads it.

Full audit (Claude (claude-opus-5-5, xhigh) × Codex (gpt-6.1-sol, xhigh), 1 turns, commit 7eaa418)

PR audit: #210 — Fix CLI exit and error reporting, runtime discovery ownership, task errors and hosted OAuth hardening

Head: 7eaa418

Sign-off

  • Claude (claude-opus-5-5, xhigh): ✅ satisfied with this audit. Only Harsh can decide whether the new per-client rate-limit feature belongs here, so the decision is needs-input. Everything else in the PR is ready.
  • Codex (gpt-6.1-sol, xhigh): (pending)

Decision

needs-input — after the earlier merge-approved audit (at 6e611cb), the branch gained an opt-in per-client rate-limit feature for the hosted service. Product rules say to ask Harsh when a PR adds limits. The feature has no evidence of need, no issue, no mention in the PR description, and our own deployment does not turn it on.

Should this exist?

  • Verdict: partly.
    • The original 21 commits are fine. They are content-identical to the 6e611cb audit; only the author email was rewritten. They are concrete bug, security and doc fixes.
    • Six of the seven new commits are fine too: a standards-backed OAuth code-replay revocation, an SDK error improvement, an SDK upload bug fix and doc clean-ups.
    • The new per-client rate limiter (49a4f19) is speculative protective machinery. No issue, plan or recorded decision asks for it. Nothing shows that one client has exhausted the global limits. The hosted service has not been offered yet (ROADMAP.md:17-22 says measure load and limits first; docs/release-notes-0.2.0.md:6 says public signup is a separate step).
  • Product-rule issues:
    • Adds limits: per-client throttles on OAuth registration/authorization and device pairing (bus/hosted_http.go:155-158), so per the rules this goes to Harsh.
    • Numbers without a source: if the feature is turned on, these new figures change what users see. Registration 1 per 10 s (burst 5), authorization 1/s (burst 10), pairing creation 1 per 5 s (burst 5), polling 2/s (burst 10), a 10,000-entry table and a 10-minute idle time (bus/hosted_client_limits.go:100-101). None has a source.
    • Speculative configuration: two new hosted serve flags (cmd/agentintercom/hosted.go:41-43) that our own unit does not use (deploy/hosted/october-bus-hosted.service:16).
    • Unrelated themes: the new commits were added without updating the PR description.
    • Background cost: none. There is no timer; idle entries are evicted only when a new client arrives at capacity.
  • Simpler alternative: drop 49a4f19 from this PR and revisit it in its own PR once load measurements or observed abuse justify it. The existing global limits are unchanged.
  • Real-launch evidence: missing. The description lists hand walkthroughs (CLI on a fresh binary, npm 0.2.0 quickstart in a container) but no startup log from this branch and no macOS or Windows hand check. This is non-blocking under Harsh's 2026-11-14 rule.

What changes (plain language)

  • What it does: Fixes a batch of command-line, message-service, SDK and hosted-service bugs found while preparing the public release. Closes a local security hole and two hosted sign-in weaknesses, and cleans up docs. It now also adds an optional per-visitor speed limit to the hosted sign-up and device-connect pages.
  • What changes in the product:
    • A failed file upload now reports an error.
    • Wrapped commands return their real success or failure code.
    • On Windows, Ctrl+C through the npm-installed command shuts the service down cleanly.
    • Messages from a failed pickup return to the inbox immediately.
    • Humans can still answer agent questions in a jammed workspace.
    • Hosted admins can no longer cancel owner-only invitations.
    • Hosted app connections recover when the app-registration table fills up.
    • If someone reuses a one-time hosted sign-in code (with its matching secret), that connection is now revoked for safety.
    • The SDK says whether a failed request timed out, was cancelled or could not connect.
    • The new per-visitor limit does nothing unless a server operator turns it on with a flag.
  • Why it exists: Release-readiness review. The security fixes stop another account on a shared Linux machine from capturing workspace keys, and follow the OAuth standard on reused sign-in codes. The per-visitor limit is meant to stop one visitor from using up shared sign-up capacity, but there is no evidence this has happened.
  • Why merge (or why not yet): Everything except the per-visitor limit is ready: checked against the code and green in CI on Linux, macOS, Windows and the hosted database tests. The per-visitor limit adds new limits and settings that nothing asked for and our own server doesn't use, so Harsh should decide whether it stays.
  • What to expect after merging:
    • Scripts see real exit codes.
    • agentintercom service status passes through systemd/launchd codes.
    • On a shared Linux machine, a pre-created temporary runtime folder makes the service refuse to start, with a message saying how to fix it.
    • A hosted app that retries a sign-in code after a lost response gets its connection revoked and must reconnect.
    • Follow-up: add a macOS/Windows hand check.

Findings

Blocking

  • bus/hosted_client_limits.go:1-171, bus/hosted_http.go:155-158, cmd/agentintercom/hosted.go:41-43,128-148, docs/hosted-workspaces.md:117-132: commit 49a4f19 adds per-client rate limits and two configuration flags. Needs Harsh's "should this exist?" decision; see Questions for Harsh.
    • Rules: "Protective machinery (guards, limits, throttles...) needs evidence that the problem actually happens", and "a PR [that] adds limits ... don't approve it: ask Harsh". The ruleset also says to avoid speculative configuration.
    • Evidence: the commit message gives a hypothetical ("one client could exhaust them for everyone"). There is no issue, measurement or incident.
    • Unused by us: our deployment's hosted serve line passes no --client-ip-header (deploy/hosted/october-bus-hosted.service:16), so the feature is dead code for the product as shipped.
    • Hosted service not yet offered: the roadmap's pre-launch list says to "Measure load, storage growth, resource limits ... on the host" first (ROADMAP.md:17,22).
    • Origin: it appears to answer the earlier audit's explicitly out-of-scope residual note about the global registration limiter. That note was not a request to build this.
    • Design and tests: the design itself is sound (rightmost untrusted hop, loopback-only default trust, IPv6 /64 grouping, bounded table) and tested (bus/hosted_client_limits_test.go). Caddy's documented default ignores client-supplied X-Forwarded-* values, which matches the doc's claim.

Non-blocking

  • If the per-client limiter is kept, a misconfigured header puts everyone in one bucket: when the configured header is missing or a hop is malformed, the key falls back to the proxy's own address (bus/hosted_client_limits.go:62-95, especially :81-83). The tests assert this intentionally (bus/hosted_client_limits_test.go:37-38).
    • Impact: with a wrong --client-ip-header name, or a proxy that doesn't set it, every visitor shares one bucket. Registration for the whole service drops to 1 per 10 s (burst 5), instead of the global 1/s.
    • Fix: when no address can be attributed, skip the per-client check (return ok=false) and let the global limit apply.
    • Docs gap: the supplied deploy/hosted/nginx.conf.example:14-15 doesn't set X-Forwarded-For, and nginx passes client headers through. An nginx operator who follows the doc would let clients choose their own key. The doc warns only in general terms.
  • Code-replay revocation (0b75dd0) re-implements a library helper: pkceVerifierMatches (bus/hosted_oauth_tokens.go:177-183) hand-rolls the S256 check.
    • Simpler: go-oauth2 v4.6.0, already a dependency, provides oauth2.CodeChallengeMethod.Validate(cc, ver) (module const.go:65-78). oauth2.CodeChallengeMethod(token.CodeChallengeMethod) == oauth2.CodeChallengeS256 && oauth2.CodeChallengeS256.Validate(token.CodeChallenge, verifier) would do. Constant-time comparison is unnecessary because the challenge is public: it travels in the authorization URL.
    • Behaviour itself is correct: RFC 6749 §4.1.2 says a reused code SHOULD revoke the tokens issued from it. Requiring the verifier stops a mere observer of the code from revoking someone's connection. The test covers both cases (bus/hosted_oauth_test.go:200-223).
    • Behaviour change: a client that retries a code exchange after a lost response now gets its device revoked. It already had to reconnect, and docs/hosted-mcp.md now says so.
  • The new TypeScript transport errors (99d7175) are a new public SDK API that no issue or plan asks for:
    • What it adds: four exported classes (sdk/typescript/src/errors.ts:49-90), whose subclasses duplicate the transport field they also set. A single BusTransportError carrying transport would be simpler to keep as public API.
    • Comment wording: the comment justifies keeping code: 'INTERNAL'/status: 500 "for compatibility" (:45), which runs against the ruleset's no-compatibility rule. The real reason is that BusErrorCode mirrors the protocol's error list (spec/0.1/README.md:253).
    • Value: it fixes a lost cause and lets callers tell timeout from abort (sdk/typescript/src/client.ts:125-157), and it is documented (docs/clients.md:197-217).
  • Two small CHANGELOG/description gaps:
  • Doc clean-up (eb2485b, 643f508, 7eaa418) has small wording issues:
    • docs/desktop-remote-integration.md renames "Required Desktop follow-ups" to "Controller integration requirements" and says to pin the runtime manifest "in the controller". The items listed are still Desktop/Core work (writer, hooks, installer, Settings cards), so "controller" is ambiguous next to the "October hosted service" row.
    • deploy/hosted/STANDALONE.md:55-57 documents the agentintercom/october-bus executable-name mismatch instead of resolving it, while deploy/hosted/migrations/README.md:15-16 now uses agentintercom.
  • Launch evidence and platform coverage:
    • Windows Ctrl+C: the launcher's Windows branch (sdk/typescript/cli/agentintercom.cjs:47-49) is tested only with a fake host, and test:errors runs only on Ubuntu (.github/workflows/ci.yml:62-102).
    • Ask the author to record: a startup log from a branch-built package and a Windows Ctrl+C check. On macOS, with a running daemon and workspace audit, run agentintercom agent run --scope audit --id exit-probe --name 'Exit probe' -- sh -c 'exit 7'; echo $?.
  • The foreign-owner check is never exercised in CI: those assertions only run as root (bus/run_file_unix_test.go:51). A unit test that feeds ownedByCurrentUser an os.FileInfo with a foreign Stat_t.Uid would cover it without a production seam.
  • Ownership diagnostics:
    • Data-dir message: secureDirectory also guards the data and scope-credential directories (bus/daemon.go:230; bus/local_credentials.go:31,77,80), but its message always suggests runtime variables (bus/daemon.go:177).
    • Client message: the client-side refusal names no path or remedy (bus/daemon.go:95).
    • Root behaviour change: root can no longer chmod and use another UID's directory. No documented deployment relies on that.
  • The OAuth eviction comment overstates recovery: bus/hosted_oauth.go:344 says MCP clients re-register when their ID is unknown. The MCP TS SDK only does that after a token-endpoint invalid_client. A browser authorization that reuses an evicted ID lands on the 400 at :195. This happens only at the 50,000-client cap.
  • Exit-status passthrough reaches service too: exitCode (cmd/agentintercom/main.go:1237) unwraps any *exec.ExitError, so service commands now pass through systemctl/launchctl codes. A child killed by a signal exits 1, while the npm launcher reports 128+N.
  • Cancellation latency:
    • Inbox release: both inbox clients wait up to 5 s for the best-effort release after a failed or cancelled commit (bus/client.go:205; sdk/typescript/src/client.ts:698).
    • Hosted sign-in: a cancelled sign-in caller waits up to the 8 s Auth timeout inside singleflight.Do and holds a request slot (bus/hosted_identity.go:60,129; bus/hosted_http.go:233). DoChan with a select would release it.
    • Timing-dependent test: the sign-in regression test relies on a 20 ms sleep.
  • Escalation headroom is finite: answers get 1,000 extra slots (bus/store.go:856), and earlier unacknowledged answers can use them up. It improves the old behaviour without guaranteeing every answer.
  • Residual local denial of service: another local user who pre-creates the shared-temp runtime directory can still stop startup. Credential capture is prevented and the daemon names the fix (bus/daemon.go:53-64,176-177).
  • Scope/process: the PR bundles CLI, store, hosted auth, launcher, SDK and doc themes. The rules prefer separate PRs. The commits are individually revertible.

Fix plan

n/a

Message to the developer

n/a

Questions for Harsh

  1. Should the per-visitor rate limit for the hosted service exist, and in this PR? Commit 49a4f19 adds an optional limit on how often a single visitor (by IP address) can register an app, start a sign-in or connect a device. Our own server does not turn it on. Nothing shows the problem it guards against has happened, and the hosted service has not been offered publicly yet.
    • a) Drop it from this PR (recommended). Revisit in its own PR after the roadmap's load and limit measurements, or after real abuse. The existing shared limits stay exactly as they are.
    • b) Keep it as an off-by-default option. No user is affected until an operator turns it on. If kept, change the fallback for a missing or misconfigured header so it doesn't throttle everyone together.
    • c) Keep it and turn it on for our own server. Add --client-ip-header X-Forwarded-For to the hosted unit (Caddy sets that header), fix the fallback, and give a source for the per-visitor numbers (e.g. 1 app registration per 10 seconds per address).
  2. OK to keep the other six commits added after the last audit? These are: revoking a connection when its one-time sign-in code is reused with its secret (follows the OAuth standard), clearer SDK errors for timeouts, cancellations and connection failures, the SDK upload fix, and the doc clean-ups.
    • a) Keep them in this PR (recommended). They are small, tested and listed in the changelog, apart from the upload fix.
    • b) Move them to a separate PR.

Verification

  • Review was read-only, per the audit rules. I installed nothing and did not build, typecheck, lint or run tests.
  • What I compared:
    • Range-diffed the old head 6e611cb against the new head on the same base, 4efe404. Commits 1–11 changed only author metadata; commits 12–21 are identical. Seven commits are new.
    • Read every new diff in full: the limiter and its wiring, the CLI flags, the OAuth token endpoint around the replay branch, the TS errors/client/tests and all doc changes.
  • What I re-verified for carried-over findings: line numbers and behaviour at the new head.
  • Facts checked against code and sources:
    • Our hosted unit passes no --client-ip-header (deploy/hosted/october-bus-hosted.service:16).
    • The CLI polls pairing every 5 s (cmd/agentintercom/hosted_login.go:156-157), within the per-client polling limit.
    • go-oauth2 v4.6.0 already has CodeChallengeMethod.Validate (module cache const.go:65-78).
    • Caddy's documentation says reverse_proxy ignores incoming X-Forwarded-* values unless the sender is a trusted proxy, and that no proxies are trusted by default.
    • The nginx example sets no forwarding header.
    • The roadmap and release notes place the hosted launch after load measurement.
  • Not available: gh issue list was denied in this sandbox, so I could not search issues for a per-client-limit request. ROADMAP and docs mention none.
  • CI at 7eaa418: 11/11 checks SUCCESS: runtime on ubuntu/macos/windows, npm-platforms, typescript-sdk, node 20/22, interoperability, hosted (Postgres), workspace-ui, vulnerabilities.
  • Final checks that matter, once Harsh decides:
    • Go: go test ./... on Linux, macOS and Windows; go test -race -count=1 ./... on Linux; go vet ./...; gofmt -l.
    • Hosted Postgres suite: OAuth capacity, code replay, invitations, and the per-client limiter tests if it is kept.
    • TypeScript SDK: npm run typecheck && npm run build && npm run test:errors (covers the new errors, attachments and inbox tests), plus test:integration against a fresh binary.
    • npm distribution: build:native --all, pack:distribution, test:distribution.
    • Not covered by CI: a foreign-UID filesystem check run as root, and a real Windows Ctrl+C and macOS exit-code hand check.

Audit log

  • Turn 1 (Claude (claude-opus-5-5, xhigh)): Re-audit after the branch was rewritten (6e611cb → 7eaa418).
    • History check: confirmed by range-diff that the 21 previously audited commits are content-identical (only the author email changed).
    • New commits: read all 7 in full.
    • Decision: changed from merge to needs-input. The new opt-in per-client rate limiter (49a4f19) adds limits and config flags with no evidence, issue or description entry, and our own deployment doesn't use it. Recommend dropping it from this PR.
    • Accepted: the RFC-backed code-replay revocation, the TS transport errors, the TS upload fix and the doc clean-ups. Non-blocking notes cover reusing go-oauth2's PKCE validator, simplifying the TS error classes, the limiter's fallback to a single shared bucket and the nginx gap, and doc wording.
    • Carried over: the prior round's non-blocking findings, with line numbers re-verified.

Automated review by Harsh's agentbox: an AI reviewer questioned whether this PR should exist, so it went to Harsh before any detailed review. A second reviewer has not checked it; a full review follows once Harsh answers.

Replacing a connection reset revoked_at, so a member could undo an
owner's or admin's revocation and get the connection's sessions and
inbox back. Revocations of another member's connection now record the
revoker in a new hosted_devices.revoked_by column, and replacement
refuses such connections. Owners can still replace connections they
revoked themselves.
Maintenance selects workspaces and then prunes each one. A workspace
deleted between those steps made pruning fail with no rows, so the run
reported an error even though nothing was left to prune.
@harshsaver

Copy link
Copy Markdown
Member Author

🤖 Agentbox PR audit: needs Harsh's input

Questions

  1. Should the per-visitor rate limit for the hosted service exist, and in this PR? (Still open from the 19:46 audit.) Commit 49a4f19 adds an optional limit on how often one visitor (by IP address) can register an app, start a sign-in or connect a device. Our own server doesn't turn it on, nothing shows the problem has happened, and the hosted service isn't public yet.
    • a) Drop it from this PR (recommended). Revisit with load measurements or real abuse. The existing shared limits stay as they are.
    • b) Keep it off by default. Also fix the fallback so a misconfigured header can't throttle everyone together.
    • c) Keep it and turn it on for our server. Add --client-ip-header X-Forwarded-For to the hosted unit, fix the fallback, and give a source for each per-visitor number.
  2. Keep the nine other commits added after the first audit, and freeze the branch?
    • What they are: the six from last round, plus three new bug fixes:
      • Accepted last round: reused sign-in codes revoke their connection; clearer SDK error types; the SDK upload fix; doc clean-ups.
      • File deletion: one workspace's file deletion no longer freezes the others.
      • Admin revocations: members can't bring back a connection an admin revoked. This needs a small hosted database migration.
      • Maintenance: no false error when a workspace is deleted mid-run.
    • a) Keep them here, and ask the developer to put any further fixes in new PRs (recommended). They are small, tested and mostly in the changelog. The PR is now 31 commits, and its description covers only the first 21.
    • b) Move them to separate PRs.

What this PR changes

  • What it does: A release-readiness bundle. It fixes command-line, messaging, SDK and hosted-service bugs, closes a local key-capture hole and several hosted permission gaps, and cleans up docs. It also still adds an optional per-visitor speed limit on hosted sign-up and device connection.
  • What changes in the product:
    • Everyday fixes:
      • A failed file upload now shows an error.
      • Wrapped commands return their real exit code.
      • On Windows, Ctrl+C shuts the service down cleanly.
      • Messages from a failed pickup return to the inbox immediately.
      • Humans can still answer agent questions in a jammed workspace.
    • Hosted access and sign-in:
      • Admins can no longer cancel owner-only invitations.
      • A member can no longer bring back a connection an admin revoked; they must create a new one.
      • Reusing a one-time sign-in code with its secret revokes that connection.
    • File handling: a long export or download in one workspace no longer freezes file access in other workspaces when someone deletes a file.
    • SDK: errors now say whether a request timed out, was cancelled or could not connect.
    • Per-visitor limit: does nothing unless an operator turns it on.
  • Why it exists: Fixes found while preparing the public release. The per-visitor limit guards against a risk that has not been observed.
  • Why merge (or why not yet): Everything except the per-visitor limit is ready: I checked it against the code, and CI is green on Linux, macOS, Windows and the hosted database tests. The limit adds limits and settings nobody asked for and our own server doesn't use, so Harsh has to decide.
  • What to expect after merging:
    • The hosted database needs migration 015_connection_revoker.sql.
    • Revocations made before the migration can still be undone by the member.
    • A deleted file's bytes can stay on disk for up to about an hour if someone was reading files at that moment. The file is hidden immediately.
    • Scripts see real exit codes, and service status passes systemd/launchd codes through.
    • Follow-up: add a macOS/Windows hand check.

Answer in a comment on this PR; the next daily audit reads it.

Full audit (Claude (claude-opus-5-5, xhigh) × Codex (gpt-6.1-sol, xhigh), 1 turns, commit af89cad)

PR audit: #210 — Fix CLI exit and error reporting, runtime discovery ownership, task errors and hosted OAuth hardening

Head: af89cad

Sign-off

  • Claude (claude-opus-5-5, xhigh): ✅ satisfied with this audit. Harsh has not yet answered the open question on the per-client rate limiter, which is still on the branch. The three newest commits are sound bug fixes.
  • Codex (gpt-6.1-sol, xhigh): (pending)

Decision

needs-input — the opt-in per-client rate limiter (49a4f19) is still in the PR, and the 19:46 question asking whether it should exist is unanswered (no reply on the PR). Product rules say not to approve a PR that adds limits without Harsh's say. Three more unrelated commits have landed since, and the PR description still covers none of the ten commits added after the first audit.

Should this exist?

  • Verdict: partly.
    • Fine: the original 21 release-review fixes, unchanged; the six later commits accepted last round; and the three new ones. The new ones cover a file-locking stall across workspaces, members undoing an admin's connection revocation, and a false error in hosted maintenance.
    • Not justified: the per-client rate limiter is still speculative protective machinery. No issue, plan or decision asks for it. There is no evidence one client has exhausted the global limits. Our own deployment doesn't turn it on (deploy/hosted/october-bus-hosted.service:16), and the roadmap says to measure load before the hosted launch (ROADMAP.md:17,22).
  • Product-rule issues:
    • Adds limits and settings: two hosted serve flags (cmd/agentintercom/hosted.go:41-43) and per-client throttles (bus/hosted_http.go:155-158).
    • Numbers with no source: 1 registration per 10 s (burst 5), 1 authorization/s (burst 10), 1 pairing per 5 s (burst 5), 2 polls/s (burst 10), a 10,000-entry table and 10-minute idle expiry (bus/hosted_client_limits.go:100-101).
    • Unrelated themes keep accumulating: 31 commits in total, 10 of them missing from the description.
    • Background cost: nothing new. The file-deletion change relies on the existing hourly cleanup (bus/maintenance.go:17-30).
  • Simpler alternative: drop 49a4f19 from this PR. Freeze the branch, and send any further fixes as new PRs.
  • Real-launch evidence: missing. No startup log from this branch and no macOS or Windows hand check. Non-blocking under Harsh's 2026-11-14 rule.

What changes (plain language)

  • What it does: A release-readiness bundle. It fixes command-line, messaging, SDK and hosted-service bugs, closes a local key-capture hole and several hosted permission gaps, and cleans up docs. It also still adds an optional per-visitor speed limit on hosted sign-up and device connection.
  • What changes in the product:
    • Everyday fixes:
      • A failed file upload now shows an error.
      • Wrapped commands return their real exit code.
      • On Windows, Ctrl+C shuts the service down cleanly.
      • Messages from a failed pickup return to the inbox immediately.
      • Humans can still answer agent questions in a jammed workspace.
    • Hosted access and sign-in:
      • Admins can no longer cancel owner-only invitations.
      • A member can no longer bring back a connection an admin revoked; they must create a new one.
      • Reusing a one-time sign-in code with its secret revokes that connection.
    • File handling: a long export or download in one workspace no longer freezes file access in other workspaces when someone deletes a file.
    • SDK: errors now say whether a request timed out, was cancelled or could not connect.
    • Per-visitor limit: does nothing unless an operator turns it on.
  • Why it exists: Fixes found while preparing the public release. The per-visitor limit guards against a risk that has not been observed.
  • Why merge (or why not yet): Everything except the per-visitor limit is ready: I checked it against the code, and CI is green on Linux, macOS, Windows and the hosted database tests. The limit adds limits and settings nobody asked for and our own server doesn't use, so Harsh has to decide.
  • What to expect after merging:
    • The hosted database needs migration 015_connection_revoker.sql.
    • Revocations made before the migration can still be undone by the member.
    • A deleted file's bytes can stay on disk for up to about an hour if someone was reading files at that moment. The file is hidden immediately.
    • Scripts see real exit codes, and service status passes systemd/launchd codes through.
    • Follow-up: add a macOS/Windows hand check.

Findings

Blocking

  • 49a4f19 — per-client rate limits still need Harsh's "should this exist?" decision. Code: bus/hosted_client_limits.go:1-171, bus/hosted_http.go:155-158, cmd/agentintercom/hosted.go:41-43,128-148, docs/hosted-workspaces.md:117-132. The question went to Harsh at 19:46 and is unanswered.
    • Rules: "Protective machinery ... needs evidence that the problem actually happens", and a PR that "adds limits ... don't approve it: ask Harsh".
    • Evidence: the commit message offers a hypothetical only.
    • Unused by us: our unit passes no --client-ip-header, so this is dead code for the product as shipped.
    • Origin: it appears to answer an earlier audit note that was explicitly out of scope.
    • Design: sound (rightmost untrusted hop, loopback-only default trust, IPv6 /64 grouping, bounded table) and tested.

Non-blocking

  • New since 7eaa418: f0ccbf8 (file locking across workspaces). A correct fix for a real stall. Go's sync.RWMutex makes new readers wait behind a waiting writer, so the old exclusive lock on delete queued every workspace's reads behind one long export.
    • Verified safe:
      • Reads now take the opened root without the file mutex (bus/attachments.go:150-162). Go documents os.Root methods as "safe to be used from multiple goroutines simultaneously".
      • close() now waits for readers (bus/attachments.go:166).
      • Every reader path already holds the maintenance read lock: ReadAttachment at :475, export at bus/archive.go:465, backup at bus/backup.go:102.
      • Lock order stays maintenance, then mutex.
    • Side effects:
      • Deletion now unlinks only if no reader is active (bus/attachments.go:583). Otherwise bytes stay until the hourly cleanup (bus/maintenance.go:17-30). That matches the docs' "removes stored bytes when possible" (docs/share-files.md:48-50).
      • The hourly cleanup still takes the blocking exclusive lock (bus/attachments.go:601), so the same stall pattern can briefly recur once an hour behind a long export.
    • Tests: cover cross-workspace reads, uploads and exports during a deletion, deferred collection, and immediate unlink when idle (bus/attachments_test.go:371-454).
  • New: cf80eda (admin revocations, migration 015). A correct permission fix.
    • The bug: replacement reset revoked_at for the owner's own device even after an admin revoked it.
    • The fix: revoked_by is recorded for non-owner revocations, including on already-revoked rows (bus/hosted_devices.go:326-334), and replacement refuses them (:238-240). Tested (bus/hosted_connection_revocation_test.go).
    • UI papercut: Devices() doesn't return revoked_by (bus/hosted_devices.go:275), so the consent screens still list "Reconnect/Replace X · revoked" for admin-revoked connections (web/src/app.js:217-218,233-234). Choosing one fails with the clear permission error. Filtering those out would be cleaner.
    • Pre-migration rows: revocations made before the migration stay restorable, as the migration README states.
  • New: af89cad (maintenance). Swallows sql.ErrNoRows from PruneScope for workspaces deleted mid-run (bus/hosted_maintenance.go:83-86). Today only the scope lookup (bus/storage.go:256) can produce it, so the broad check is acceptable. No test.
  • If the per-client limiter is kept, fix two things:
    • Everyone shares one bucket on a bad header: a missing or malformed header falls back to the proxy's address (bus/hosted_client_limits.go:81-83), so a wrong --client-ip-header throttles all visitors together, e.g. registration at 1 per 10 s. Skip the per-client check when no client address can be attributed.
    • nginx gap: the supplied deploy/hosted/nginx.conf.example:14-15 sets no X-Forwarded-For, and nginx passes client-supplied headers through, so clients could pick their own key. Caddy's documented default ignores client-supplied X-Forwarded-*, so the Caddy setup is fine.
  • Code-replay revocation (0b75dd0) hand-rolls PKCE S256: bus/hosted_oauth_tokens.go:177-183 reimplements the check, but go-oauth2 v4.6.0 already provides oauth2.CodeChallengeMethod.Validate. Constant-time comparison isn't needed, because the challenge is public. The behaviour matches RFC 6749 §4.1.2 and is tested.
  • TS transport errors (99d7175) add public SDK API that nothing asked for:
    • Four classes whose subclasses duplicate the transport field (sdk/typescript/src/errors.ts:49-90).
    • Keeping code: 'INTERNAL' "for compatibility" (:45) cuts against the no-compatibility rule. The honest reason is that BusErrorCode mirrors the protocol's error list.
    • It does fix a lost cause, and it is documented.
  • Changelog and description:
  • Doc wording:
    • docs/desktop-remote-integration.md calls Desktop's work "controller" work, which is ambiguous next to the hosted-service row.
    • deploy/hosted/STANDALONE.md:55-57 documents the agentintercom/october-bus name mismatch rather than resolving it.
  • Launch evidence and platform coverage:
    • The Windows launcher branch (sdk/typescript/cli/agentintercom.cjs:47-49) is only tested with a fake host, and test:errors runs on Ubuntu only.
    • Ask for a startup log from a branch-built package, a Windows Ctrl+C check, and a macOS agent run ... -- sh -c 'exit 7'; echo $? check.
  • Untested security branch: the foreign-owner check runs only as root (bus/run_file_unix_test.go:51). A unit test that feeds ownedByCurrentUser a foreign Stat_t.Uid would cover it.
  • Ownership messages:
    • The data-dir failure suggests runtime variables (bus/daemon.go:177), and the client-side refusal names no path or remedy (bus/daemon.go:95).
    • Root can no longer adopt another user's directory.
  • OAuth eviction comment overstates recovery: bus/hosted_oauth.go:344 says clients re-register automatically. The MCP TS SDK re-registers only after a token-endpoint invalid_client. A browser authorization with an evicted ID gets the 400 at :195. This only happens at the cap.
  • Exit status reaches other subprocesses: exitCode (cmd/agentintercom/main.go:1237) also passes systemctl/launchctl codes through service. A child killed by a signal exits 1, while the npm launcher reports 128+N.
  • Cancellation latency:
    • The inbox release can delay a cancelled call by up to 5 s (bus/client.go:205; sdk/typescript/src/client.ts:698).
    • A cancelled hosted sign-in waits up to 8 s in singleflight.Do and holds a request slot (bus/hosted_identity.go:60,129). Its test relies on a 20 ms sleep.
  • Escalation headroom is finite: 1,000 extra slots (bus/store.go:856).
  • Residual local denial of service: another user can pre-create the shared-temp runtime directory and stop startup. Credential capture is prevented (bus/daemon.go:53-64,176-177).

Fix plan

n/a

Message to the developer

n/a

Questions for Harsh

  1. Should the per-visitor rate limit for the hosted service exist, and in this PR? (Still open from the 19:46 audit.) Commit 49a4f19 adds an optional limit on how often one visitor (by IP address) can register an app, start a sign-in or connect a device. Our own server doesn't turn it on, nothing shows the problem has happened, and the hosted service isn't public yet.
    • a) Drop it from this PR (recommended). Revisit with load measurements or real abuse. The existing shared limits stay as they are.
    • b) Keep it off by default. Also fix the fallback so a misconfigured header can't throttle everyone together.
    • c) Keep it and turn it on for our server. Add --client-ip-header X-Forwarded-For to the hosted unit, fix the fallback, and give a source for each per-visitor number.
  2. Keep the nine other commits added after the first audit, and freeze the branch?
    • What they are: the six from last round, plus three new bug fixes:
      • Accepted last round: reused sign-in codes revoke their connection; clearer SDK error types; the SDK upload fix; doc clean-ups.
      • File deletion: one workspace's file deletion no longer freezes the others.
      • Admin revocations: members can't bring back a connection an admin revoked. This needs a small hosted database migration.
      • Maintenance: no false error when a workspace is deleted mid-run.
    • a) Keep them here, and ask the developer to put any further fixes in new PRs (recommended). They are small, tested and mostly in the changelog. The PR is now 31 commits, and its description covers only the first 21.
    • b) Move them to separate PRs.

Verification

  • Read-only review: nothing installed, built or tested, per the audit rules.
  • What changed since 7eaa418: confirmed it is an ancestor of the new head, on the same base 4efe404. Only three commits were added (f0ccbf8, cf80eda, af89cad, touching 11 files); everything audited before is unchanged.
  • New code read in full, with its surroundings:
    • The attachment store's locks and every reader path (ReadAttachment, export, import, backup, GC, close).
    • Runtime and hosted maintenance loops.
    • Device revocation and replacement.
    • The UI consent dropdowns.
    • PruneScope's error sources.
    • Go's os.Root and sync.RWMutex documentation.
  • Facts checked:
    • The limiter wiring is unchanged (bus/hosted_http.go:155-158).
    • The hosted unit still has no --client-ip-header.
    • The PR has two comments, both automation, and no reply from Harsh.
    • Migrations are embedded (deploy/hosted/migrations/migrations.go).
    • Hosted tables exist only in the Postgres schema.
  • CI at af89cad: 11/11 SUCCESS: runtime on ubuntu/macos/windows, npm-platforms, typescript-sdk, node 20/22, interoperability, hosted (Postgres), workspace-ui, vulnerabilities.
  • Final checks that matter once Harsh decides:
    • go test ./... on all three OSes, go test -race -count=1 ./... on Linux, go vet, gofmt -l.
    • The hosted Postgres suite, including migration 015, connection revocation, OAuth capacity/replay, invitations and the attachment concurrency test.
    • The workspace-UI suite (consent dropdowns).
    • TS: typecheck, build, test:errors, and test:integration against a fresh binary.
    • npm: build:native --all, pack:distribution, test:distribution.
    • Not covered by CI: a root-only ownership check, and real Windows Ctrl+C and macOS exit-code hand checks.

Audit log

  • Turn 1 (Claude (claude-opus-5-5, xhigh)): Re-audit at af89cad.
    • History and comments: the branch fast-forwarded from 7eaa418 with 3 commits. There is no answer from Harsh on the open questions.
    • New commits: read the attachment-locking, admin-revocation/migration and maintenance commits with their surrounding code. Verified their concurrency and permission logic. Added non-blocking notes: deferred unlink and the still-blocking hourly GC, the UI still listing admin-revoked connections, and the broad ErrNoRows check.
    • Decision: needs-input stays, because the per-client limiter question is open. Q2 now covers all nine other post-audit commits and adds a request to freeze the branch.
    • Carried over: earlier findings, re-checked against the unchanged files.

Automated review by Harsh's agentbox: an AI reviewer questioned whether this PR should exist, so it went to Harsh before any detailed review. A second reviewer has not checked it; a full review follows once Harsh answers.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agentbox: needs your input Claude and Codex need a decision from Harsh

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant