Repository navigation
M5: merge main 114e1d98b into sam/selfhost-pass-2 (L18, L21, L20) - #2899
simple-agent-manager[bot] merged 62 commits into
Conversation
…ete-smallest-safe-1dtgz3
Resolve admin settings registry union conflict (keep library multipart and account linking settings). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merge origin/main into the Codex Security branch and keep the route changes to one-line middleware insertions. Add a worker test that posts a forged library upload through the real worker with a session cookie and a same-site workspace Origin, document the boundary, and file the sibling text/plain JSON CSRF class as a backlog task. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review findings on the origin guard: with BASE_DOMAIN=localhost:8787 the derived app origin is the API's, so the Vite app on :5173 got 403 for uploads, library writes and voice input. Admit loopback origins only when BASE_DOMAIN is itself local, as appFrameAncestors and credentialed CORS already do. Add worker-level attack cases for the file-proxy and transcription sinks, Fetch Metadata cases without Origin, and correct the docs claim that CORS stops every JSON write. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The single per-isolate boolean permit refused every overlapping Library transfer. The Library page uploads selected files in parallel and chat document cards fetch previews together, so all but one of them got 429 in a shared isolate. Reserve file bytes instead: uploads reserve their declared Content-Length (now enforced while streaming), previews reserve the stored file size and refuse a larger replacement object with 409, and unknown sizes still take the whole budget, so a maximum-size file keeps the measured exclusive peak. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…713626c3b0fb948f323e9e2bb27bb5
…batch limit Merge origin/main into the Codex Security branch. The count used a template expression the SQL quality check rejects, and counted every non-task anchor kind instead of the kinds the ranking reads. Build it from parameterized conditions over STORED_COMMENT_ANCHOR_KINDS, and test more readable task ids than one bind batch with a status filter. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Address the adversarial re-review: every reservation now adds 256 KiB for the two fixed 64 KiB upload buffers and per-request objects, capping concurrency at about 200 and keeping each transfer's peak within twice its reservation. Downloads reserve the stored file size (one getFile) instead of the whole budget. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review findings: skipping hidden task threads after ranking cost one statement per limit+1 hidden rows (a member could pass limit=1), and the count ran one non-index-seeking statement per 100 readable ids. Bind the readable ids once as a JSON array and match them on the indexed scope_key in both the ranking and the count, so the statement count no longer depends on hidden or readable task volume. Tests: omitted ids fail closed; twelve newer hidden threads with limit 2 read one window. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…laim CodeRabbit review: an empty Origin skipped the guard because the check was truthiness, not presence. A JSON body sent as text/plain needs no preflight, so the docs now say which requests CORS stops, and the backlog task covers typed and indirect JSON parsers and requires an explicit media-type check. Adds local-dev look-alike origin cases. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Main already rejects message.send on browser sockets (the viewer-write half of the finding). The draft's remaining approach added a D1 query on every client ping and dropped broadcasts without a project id; the revocation gap is fixed with a smaller change in the next commit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The project WebSocket upgrade checks membership once, so a member who was offboarded or suspended kept receiving project and transcript events in any tab left open. The upgrade route now tags each socket with the user it authenticated (a header it sets, replacing any browser value); the DO refuses an untagged upgrade; offboarding and admin suspension close that user's sockets with code 4403. Main already rejects message.send on these sockets, so the viewer-write half of the finding needed no change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review findings on the socket revocation: - sockets admitted before sockets carried their user have no actor tag; a revocation now closes every untagged socket too (its client reconnects through the membership check); - an offboarding apply that throws after its membership write still closes the member's sockets; - a failed suspension close answers 503 so suspending again retries it; - actor ids are limited to printable ASCII so a tag never exceeds the hibernation byte limit; - tests: suspended reconnect refused, legacy socket closed, failure branches; docs name the remaining gaps. Follow-ups filed: the reconcile sweep for the admission race and sibling sockets, and the empty session a cancelled dispatch leaves (found confirming #2868). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…agent (#2862) * fix(inbox): archive questions from chats whose workspace is gone Archiving a marker-era inbox question always tried to deliver a "the person archived your question" prompt to the chat's live agent. For a chat whose workspace was deleted (task cancelled, session stopped), the live-agent resolver returned 404, the archive claim was released, and the inbox UI treats 404 as "already handled elsewhere", so it silently refetched and the item came back. Such items could never be archived. archiveAttention now checks for a live workspace bridging the chat (the same liveSessionWorkspaceCondition the delivery uses; sleeping workspaces still count as live) and, when there is none, closes the marker with reason 'archived' without notifying anyone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(inbox): archive a question or review without telling the agent Raphaël (2026-11-17) revised inbox spec decision 4: archiving should leave the agent where it is. A person who wants the agent to act answers or engages in the chat; archive just closes the item. - archiveAttention (marker-era questions) no longer prepares or sends a live-agent prompt. It checks the caller is a writer of the chat, claims and resolves the marker with reason `archived`, and completes an archive claim an earlier build left staged. This also removes the dependency on a live agent that made items from finished chats impossible to archive. - Asks (questions, reviews) close with `notified_at` set in the same write, as error items already do, so the notice sweep never sends one later. The agent-wake grant is no longer needed to archive, since nothing wakes. - Permissions, approvals and secret requests still archive as deny/decline, and human tasks still wake their watchers. - Receipt reads "Archived"; Connector tool text and docs updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(inbox): release the archive claim if completing it fails Nothing is sent on archive any more, so a failed complete can always release the staged claim; leaving it would make every answer to the question 409. From security review of #2862. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(inbox): clear an archived question from open chat views From review of #2862. Archiving a question in D1 asks used to clear it live only as a side effect of delivering the agent notice, so with the notice gone an open chat kept showing the question until it refetched. Archive now calls ProjectData.recordQuestionArchived, which broadcasts attention.resolved (reason 'archived'). Unlike a withdrawal it keeps SAM's check-in hold until the question's deadline, so archiving does not nudge the agent. Never throws. Also: the inbox Archive button's accessible name no longer says it tells the agent, and the API reference / noticeRetryMinutes descriptions match. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(inbox): no notice or delivery item for questions an earlier build archived Questions and reviews archived before silent archive, whose notice was never queued, still had notified_at NULL, so the notice sweep would have told their agents after deploy and the error sweep could have reported the omitted notice as undelivered. Both sweeps now skip archived questions and reviews. From the Codex review of #2862. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * style: format inbox operations test Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(inbox): share the closed-question fixture in the delivery-item test Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(inbox): hold SAM's check-ins off a chat whose question was archived From the Codex review of #2862 (P2): archiving resolved the only thing that kept SAM's silent-agent reconciliation off the chat (the unresolved needs_input marker, or the open ask's deadline hold), so an idle task chat became a check-in candidate and the agent got a "[SAM Orchestrator Check-In]" despite archive telling it nothing. - Archiving a question (asks-era or marker-era) now holds the chat's reconciliation gate (questionHold) until a person writes in the chat, for at most inbox.archiveCheckinHoldHours (new admin setting, default 168). holdReconciliationAfterArchive keeps a permanent task exclusion and a pending check-in intent, and never shortens a longer hold. - Any person's chat message now releases a question hold, not only one that closed an open question, so the archive hold ends when the person engages. Tests: reconciliation candidates exclude the chat after an archive hold and include it again after the release (real SQLite); worker tests assert the gate after archiving through the real route (asks and marker) and its release by a real human message. Each guard was removed once and its test went red. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(inbox): record the check-in hold read in the ingest-cost profile A human message now releases an archive check-in hold, which reads the chat's reconciliation gate: one primary-key do_meta lookup per user message batch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(inbox): archive releases only a claim it staged itself When completing a marker archive fails, release the shared answer/archive claim only if this request staged it. A claim found already staged may belong to another request still in progress (an earlier build during a rolling deploy), so it is left alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(inbox): archiving a result tells the agent nothing either #2881 added result asks. Archive was already silent for every agent ask kind; the two sweeps now also skip results an earlier build archived without a notice, as they do for questions and reviews. The question archived notice text had no caller left and is removed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(inbox): a chat message between an archive and its hold ends the hold The archive closes its record, then installs SAM's check-in hold through a separate ProjectData call. A person's message persisted in between released a hold that did not exist yet, and the hold was then installed anyway. The archive now reads archivedAt before the closing write and carries it with the hold; ProjectData skips the hold when a person wrote in the chat after it (humanMessageSince). A call without archivedAt (an earlier build) installs the hold as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Raphaël Titsworth-Morin <raphael@raphaeltm.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
CodeRabbit review on #2867: - Major: an upgrade whose route check passed before a revocation and that reached the DO after its close survived. The DO now re-reads membership and account status from D1 right after admitting a socket and closes it if access is gone (one read per socket opened, never per frame). Covers both orders; proven red without it. - Suspension pages memberships by project_id and bounds concurrent close RPCs; a failed membership read answers the same retryable 503. - Exact 403 assertion for a suspended reconnect; docs qualify the remaining failed-close gap; backlog tasks gain the sign-out and persistMessage-rejection criteria. Tests that open DO sockets directly now seed a real member (helpers/socket-member.ts), since the re-check closes non-members. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…903d79442e57bb4b720f3899f207af
…713626c3b0fb948f323e9e2bb27bb5
* chore(deps): bump ai from 7.0.137 to 7.0.173 Bumps [ai](https://github.com/vercel/ai/tree/HEAD/packages/ai) from 7.0.137 to 7.0.173. - [Release notes](https://github.com/vercel/ai/releases) - [Changelog](https://github.com/vercel/ai/blob/main/packages/ai/CHANGELOG.md) - [Commits](https://github.com/vercel/ai/commits/ai@7.0.173/packages/ai) --- updated-dependencies: - dependency-name: ai dependency-version: 7.0.173 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * fix(deps): pair ai 7.0.173 with @mastra/core 1.84.0 ai 7.0.173 depends on @ai-sdk/provider 4.0.38, so workers-ai-provider's peer resolved to 4.0.38 while @mastra/core 1.81.0 pins 4.0.34. The two LanguageModelV4 declarations are nominally distinct, which broke tts-text.ts (WorkersAIChatLanguageModel not assignable to Mastra's model config). @mastra/core 1.84.0 pins exactly @ai-sdk/provider 4.0.38 and provider-utils 5.0.81, matching ai 7.0.173, so one provider copy remains. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(api): control secret submit transaction arrival order (cherry picked from commit 0277830) Carried over from #2797 (superseded by this PR's @mastra/core 1.84.0 bump) so the fixture fix lands with the Mastra update it was written for. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Raphaël Titsworth-Morin <raphael@raphaeltm.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* test(cloud-init): pin Cloudflare boot output recorded on main before L18 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(cloud-init): L18 reverse-tunnel frpc boot mode for self-hosted control planes Ports packages/cloud-init reverse-tunnel files byte-identical from sam/selfhost-pass-2 (942d2c0): reverse-tunnel.ts, template-reverse-tunnel.ts, and the tunnel.ts / template-ingress.ts / variables.ts / index.ts seams. A non-empty reverseTunnelCredential selects the mode; Cloudflare nodes never set it and render byte-identical output (pinned by the snapshot test recorded on main in the previous commit). Accepts the frpc_install boot-failure reason the frpc install block reports. Adds a vertical slice: real provisionNode -> self-host driver -> real renderer -> provider user-data. Documents the boot mode in the self-hosting guide. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(cloud-init): document reverse-tunnel ingress; pin two more Cloudflare tunnel shapes Validator follow-ups: security.md no longer ties isTunnelMode to the Cloudflare token only, and gains a reverse-tunnel ingress section; cloud-init AGENTS.md and rule 06 list the frpc blocks. Snapshots for a Cloudflare Tunnel task node and deployment node were recorded against main's cloud-init src (bfa8cc5) and pass unchanged with L18. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * task: record L18 review outcomes; defer security LOWs to backlog Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(cloud-init): fail closed when frpc install fails or the control plane URL is unusable CodeRabbit review on #2885: - the frpc install block ignored install's exit status, so a failed install booted the agent with no connector and never reported frpc_install; - reverse mode rendered serverAddr="" for a control plane URL that passes the shared character check but not new URL() (e.g. port 65536); it now fails validation instead (also security-review LOW-1); - the boot-render slice compares whole port lines and its Cloudflare control now runs the Cloudflare Tunnel path with a liveness assertion. Cloudflare output is unchanged: all 8 byte-identity snapshots pass. Each new guard was removed once and exactly its test went red. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(cloud-init): canonical reverse-mode numbers, Type=exec frpc unit, read-only CF baselines CodeRabbit review on #2885: - reverse mode renders validated ports and listener timings in canonical decimal (frpc TOML rejects leading zeros; dash reads them as octal), with a test that executes the rendered wait script under /bin/sh; - sam-frpc.service is Type=exec so a non-executable binary fails 'systemctl enable --now' and reports tunnel_connector; - the Cloudflare byte-identity test compares committed baselines byte for byte and fails when one is missing (no snapshot update mode). Cloudflare output is unchanged: all 8 baselines match. The write_files credential race applies equally to every node's callback token, so it is tracked with the Cloudflare parity items in the backlog task. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * task: archive L18 with staging and BOX evidence Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Raphaël Titsworth-Morin <raphael@raphaeltm.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
ci-suite-selection requires every file a suite reads to be in its filter; analytics-d1-sink.test.ts imports scripts/selfhost/observability-migrations.ts (and through it selfhost-migrations.ts). Also files two backlog bugs found during L20 staging verification. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…348ca3a4026bc4f8bb26ab [Codex Security] Project WebSockets are not bound to actor capabilities, allowing viewer writes and post-revocation access
The visual audit caught LogViewer mounting under the assumed "every service present" default and sending one log query on an installation without log search. Both pages now render nothing until the capabilities query has answered (a failed query still counts as known and keeps the viewers). Unit test holds the answer open and asserts neither the viewer nor the stream mounts (red without the gate). The audit spec also runs an explicit desktop layout so CI produces mobile and desktop evidence. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ace is on top; add evidence The first local capture showed the first-run onboarding wizard covering both pages while every element assertion passed (rule 62). The spec now marks onboarding dismissed before boot and asserts the notice (and the Cloudflare viewer) is the topmost element at its own centre. Reviewed mobile and desktop screenshots, both themes, are kept in .pr-evidence/2889/. Also files a backlog item for a window-boundary flake in mcp-project-insights.test.ts seen on this PR's CI. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* docs(www): journal post on connecting GitHub to an email account Daily SAM journal entry about PR #2830: email-code users can now connect GitHub from Settings, and each link needs a one-time emailed proof bound to the user, session and provider, consumed atomically and rechecked at the OAuth callback. Implicit same-email linking and Google linking are refused. Includes two dark/light UI renders of the Connected accounts card with mock data, a Mermaid sequence diagram, and the 1200x675 X card. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(www): correct account-linking post per accuracy review - The user's OAuth token checks repository access; the agent's git credential is a short-lived GitHub App token. - Callback refusals send you back to Settings for a new email; the quoted message applies only to a proof mismatch. - Suspended applies to the account; unverified email is also refused. - Error descriptions are paraphrased; 503 covers SAM's own check too. - Staging gap stated precisely; alert email is best-effort; explain hash. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(www): shorten account-linking post excerpt under 160 chars Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Raphaël Titsworth-Morin <raphael@raphaeltm.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* feat(selfhost): port SMTP sign-in and self-host inbound email from integration (L21) Lands from sam/selfhost-pass-2 at 942d2c0: the agent-email SMTP transport (smtp-client/config/message, emailTransportKind, systemEmailTransportFor), SMTP sign-in codes and owner security alerts, the self-host inbound on-switch, the loopback gateway route POST /api/self-host/gateway/inbound-email, and the sam-mx Go receiver. Cloudflare's AGENT_EMAIL binding still wins whenever it exists. Capabilities without consumers are not landed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(selfhost): probe the SMTP relay before setup closes on email, and send account-link mail over SMTP (L21, F13) - emailSignInReadiness probes the relay for SMTP (EHLO, TLS, AUTH, MAIL FROM, RCPT TO owner, RSET): a refusing or unreachable relay makes email sign-up unavailable, so first-run setup asks for a provider instead of locking the owner out. Cloudflare readiness is unchanged. - Test that a code request answers before a hung SMTP send finishes, the same way for every address. - Account-link confirmation uses the system email transport (Cloudflare or SMTP); the explicit /link-social owner alert over SMTP is covered. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ci(selfhost): run sam-mx and the SMTP path in CI on self-host email paths and nightly (L21, F12) - Self-host Email Tests workflow (called from CI for deploy/selfhost/sam-mx, agent-email and self-host email paths, never the cloud-init filter; also nightly and on demand): go vet + go test -race for sam-mx, the inbound vertical test against the real receiver binary (SAM_MX_RECEIVER_TESTS=1 fails instead of skipping without Go), SMTP sign-in/setup/link tests. - SMTP client in real workerd through Miniflare: plaintext loopback delivery, probe, refusal, deadline, and workerd refusing untrusted STARTTLS and implicit-TLS relays before AUTH. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * docs(selfhost): SMTP email and inbound agent email on a single-box build (L21) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(selfhost): review fixes for sam-mx authentication and the SMTP paths (L21) sam-mx (security-auditor MEDIUM, go-specialist M1-M3, L3, L8): - strict SPF/DKIM alignment by default; SAM_MX_RELAXED_ALIGNMENT=true opts into relaxed, and a DMARC adkim/aspf=s record still keeps strict. DMARC is read only in relaxed mode, and a DNS failure other than not-found is a 451 instead of 'no record'. - a DKIM-only pass must sign From, To, Subject, Message-ID and Date, name the agent address in a signed To or Cc, and be dated within SAM_MX_DKIM_MAX_AGE (7 days): a signed message cannot be replayed. - the gateway call stops when its connection closes (lifetime, shutdown); SAM_MX_MAX_SESSION must outlast read + DNS + gateway timeouts. - SIGTERM drains in-flight deliveries (SAM_MX_SHUTDOWN_GRACE) before closing. - drop the ignored Content-Length header. TypeScript (security-auditor LOWs): - the SMTP client refuses envelope addresses it cannot put on the wire, so the readiness probe reports an unusable owner address as unavailable. - a transport failure on a self-host agent reply reaches the agent as 'SMTP relay unavailable'; the detail goes to the operator log. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test: registry includes agentEmail.smtpTimeoutMs (L21) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(sam-mx): one To, Cc and Date per message, and no far-future Date, for DKIM-only passes (review) An unsigned To or Date prepended above the signed one could rebind a replayed DKIM message to the agent address or make it look fresh. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(sam-mx): wait for the shutdown drain before exiting (go-specialist HIGH) Serve returns as soon as Shutdown closes the listener, so main exited with deliveries still in flight. serveUntil returns only after the drain; a test holds a delivery in the gateway across SIGTERM and fails without the wait. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * task: L21 BOX evidence so far Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(selfhost): validator follow-ups for L21 - log once when SMTP is the transport and the runtime gives no waitUntil (codes would be sent inline) - Self-host Email CI filter covers the setup, auth, admin-agent-email routes, env.ts and their tests - assert the exact owner-alert subject for an explicit link over SMTP - task file: decisions and the agent's SMTP reply on the box Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * style: import order in routes/auth.ts Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * task: L21 BOX done and restored Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ci: Dependabot coverage and reviewed gitleaks entries for sam-mx (L21) - Dependabot gomod and docker updates for deploy/selfhost/sam-mx; the dependency-governance test lists its Dockerfile. - Reviewed baseline entries for the three non-secret findings the slice adds (the agent address alphabet, a test address key and a test-only gateway secret), as on the integration branch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ci: dependency evidence for sam-mx Go modules; reviewed digest for the port commit (L21) - direct-dependency-evidence: go-smtp, go-msgauth, blitiri spf and golang.org/x/net for deploy/selfhost/sam-mx. - gitleaks: the address-alphabet line at its earlier position in the port commit (PR-range scan), same reviewed classification. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: SonarCloud security findings on new code (L21) - Self-host Email workflow installs with --ignore-scripts and rebuilds only the lockfile-pinned better-sqlite3 and esbuild, as other CI jobs do. - sam-mx image runs as uid 7102 even without compose's user setting. - the SMTP test helper runs openssl from a fixed path, not a PATH lookup. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * task: archive L21 with staging evidence Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * task: L21 staging evidence Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * task: backlog the staging agent-email loopback gap (L21) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Raphaël Titsworth-Morin <raphael@raphaeltm.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…-slice-txnjj1 # Conflicts: # .github/workflows/ci.yml # scripts/quality/runtime-tunables-baseline.json
…xnjj1 Self-host L20: observability and storage seams
Main's landed L21 files win (SMTP client/config/probe, sam-mx, inbound-email gateway route, email-sign-in readiness, tests, docs). Branch keeps its unlanded self-host Dockerfiles in Dependabot/governance, its runtime-tunables entries, hasInboundAgentEmail (used by the unlanded inboundAgentEmail capability) and the hosted-git CI job in the job-count ceiling (33). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…M5 step 3) Main's landed L20 wins: analytics sink seam (services/analytics-sink.ts, selfhost/analytics/), shared R2 presign client with a required operator region, ASSETS dispatch, Admin Logs/Stream notice. The branch keeps its unlanded capabilities (re-attached onto main's platform-capabilities shape) and its own self-host files. L20 follow-ups handed to this merge: - remove the branch's shared-dir observability 0002 copy and its services/analytics-d1-sink.ts (superseded by selfhost/analytics/) - withSelfHostBuild installs the D1 sink; celld-project appends SELFHOST_OBSERVABILITY_MIGRATIONS to OBSERVABILITY_DATABASE's projection - presignVars passes R2_S3_REGION (auto for gs://, required for s3://) - operations.analyticsD1* removed; analytics.d1.* come from the sink installer Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cument the region rule (M5) Main's L20 resolver refuses an operator store without a signing region, so the branch's build-context and compose-artifact presign tests set it. The self-host README and .env.example say gs:// defaults to auto and s3:// must set it. Adds the M5 task file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
Merging this PR will not alter performance
Comparing Footnotes
|
- runtime-tunables and direct-dependency-evidence baselines: drop the branch's pre-landing duplicate keys that auto-merged next to main's L20/L21 entries (the stale ANALYTICS_SINK text still named operations.analyticsD1*) - drop the analyticsIngest capability (no consumer; writes decide through resolveAnalyticsSink) and re-add main's LOG_TAIL_AVAILABLE pin - remove worker-core's operator-endpoint module, orphaned once main's L20 r2-presign-config took over endpoint validation - move the presignVars -> resolveR2PresignConfig test into the API's self-host tests: importing Worker env types from scripts/selfhost pulled the whole API into that package's typecheck (CI Validate Deploy Scripts) - README names R2_S3_ENDPOINT; monthlyCostCap comment says who reads it; celld-config.ts back to its pre-merge length Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@coderabbitai review |
Action not completed
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
|
Coordinator review (task 01M7JMXS2JRW6QQMB1356ENPM3): approved, merging into Checked at head
Accepted, to be carried into L22: an The owner task was paused on a provider limit when I merged. |
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
2f61cea
into
sam/selfhost-pass-2



Summary
M5 merges current main into the self-host integration branch in three staged real merges, pushed after each. PR base
sam/selfhost-pass-2. No rebase, no cherry-picks, no force-push to the integration branch. Do not merge: coordinator task 01M7JMXS2JRW6QQMB1356ENPM3 reviews and merges. Model: M4 #2884.Rule: code that landed on main takes main's version; the branch keeps only what has not landed. Where main's shape differs, main wins and only the unlanded remainder is re-attached.
Steps
5834e9be00c5fd10e786534969a86534969a4cc8f01987a05dac117a05dac11114e1d98bf46fc9119After step 3:
d4297e1d7(README /.env.exampleregion rule, task file),4e2e43509(review fixes, below) and6d8126d75(task file: box evidence only). The first push replaced the main commit that branch creation left on this PR's own output branch (forced update ofsam/m5-merge-current-main-hz576gonly).Landing progress (
git diff --shortstat origin/main...<head>)5834e9be0, merge base096db08db): 640 files, +70036 / -1034 (measured after step 1, which was conflict-free and left cloud-init identical to main).Conflict table: step 1 (
0c5fd10e7, L18, 0 conflicts)Clean. The branch already carried L18's review fixes (#2886), so after the merge
packages/cloud-inithas no diff against main.Conflict table: step 2 (
4cc8f0198, L21, 29 conflicted files)deploy/selfhost/sam-mx/*(8 files, add/add)packages/agent-email/src/smtp-client.ts,smtp-config.ts(add/add),definitions.ts,provider.tsprobeSmtpRelay,EmailTransport.probe)apps/api/src/services/email-sign-in.tsreadyuncheckedapps/api/src/selfhost/reverse-tunnel/gateway.ts,inbound-email.ts(add/add)apps/api/src/services/agent-email/self-host-inbound.ts(add/add)hasInboundAgentEmailhasInboundAgentEmailre-attached (the branch's unlandedinboundAgentEmailcapability uses it)apps/api/tests/helpers/fake-smtp-server.ts,tests/integration/email-sign-in-smtp.test.ts,selfhost-inbound-email.test.ts,tests/unit/services/smtp-client.test.ts(add/add),tests/unit/routes/setup-email.test.tsemailSending,inboundAgentEmail) moved totests/unit/services/platform-capabilities.test.tsin step 3apps/api/src/env.ts,apps/api/.env.exampleAGENT_EMAIL_INBOUND_SMTPexampleapps/www/.../admin-settings.md,self-hosting.mdx.github/dependabot.yml,scripts/quality/dependency-governance.test.tsscripts/quality/runtime-tunables-baseline.jsonscripts/quality/ci-suite-selection.test.ts#2888's create-account guard (
scripts/selfhost/create-account.ts,account-sql.ts, tests) and the sam-mx compose passthrough are untouched: byte-identical to5834e9be0. The sam-mx and SMTP files are byte-identical to main.Conflict table: step 3 (
114e1d98b, L20 + tip, 26 conflicted files)lib/analytics-config.ts,middleware/analytics.ts,routes/admin-analytics{,-query}.ts,routes/analytics-ingest.ts,scheduled/observability-purge.ts,services/analytics-forward.tsactiveLocalAnalyticsSink, isolated purges) / branchservices/analytics-d1-sink.tsservices/analytics-d1-sink.ts(branch-only, no conflict)selfhost/analytics/services/r2-presign-config.ts(add/add), its testautodefault,isAcceptableOperatorEndpointservices/build-context-upload.ts,packages/app-deployment/src/compose-image-artifacts.ts,build-context-presign.test.tsservices/platform-capabilities.tsactiveLocalAnalyticsSink/ branch 18 capabilities,isAnalyticsD1SinkEnabledaiGateway,monthlyCostCap,cloudflareAccountApi,analyticsIngest,artifacts,containerRuntime,guidedCredentialSetup,emailSending,inboundAgentEmail,cloudflareDns,appDeployments,r2Presign) and the analytics ones moved ontoactiveLocalAnalyticsSinktests/unit/services/platform-capabilities.test.tsANALYTICS,ANALYTICS_DATASET,OBSERVABILITY_DATABASE), plus main's three local-sink cases and the two email cases from step 2tests/unit/routes/platform-capabilities-route.test.tstoEqualon 5 fieldstoMatchObjecton main's 5 fields (the branch addsmonthlyCostCap,appDeployments)apps/web/src/lib/api/platform-capabilities.tsapps/web/src/pages/AdminLogs.tsx,AdminStream.tsx,components/admin/BoxLogsNotice.tsx(add/add),admin-box-logs-notice.test.tsx(add/add)tests/unit/selfhost/analytics-and-log-search-unavailable.test.ts,analytics-d1-sink.test.ts(add/add)apps/api/src/env.tsAI: Ai+ ASSETS comment / branchAI?: Ai,CONTAINER_RUNTIME_AVAILABLE,SANDBOX_CONTAINER_RUNTIME_AVAILABLEAIand container declarations (unlanded celld runtime), main's comments elsewhereapps/api/src/index.ts,apps/api/.env.exampleBoolean(), R2_S3 docsscripts/quality/gitleaks-reviewed-baseline.jsonL20 follow-ups handed to this merge
apps/api/src/db/migrations/observability/0002_analytics_events.sqlf46fc9119(main's copy lives inapps/api/src/selfhost/migrations/observability/, same filename, so a box's ledger row still matches)appendSelfhostObservabilityMigrationsandinstallAnalyticsD1Sinkinto celldf46fc9119:scripts/selfhost/celld-project.tsappendsSELFHOST_OBSERVABILITY_MIGRATIONSto OBSERVABILITY_DATABASE's flat projection;apps/api/src/selfhost/build.tswithSelfHostBuildcallsinstallAnalyticsD1Sink(). Tests:celld-project.test.ts(goes red with the call removed), newtests/unit/selfhost/selfhost-build.test.ts(enters throughwithSelfHostBuild, with a before-install control)R2_S3_REGIONf46fc9119:presignVarssetsautofor ags://bucket, passes an explicit value, and refuses ans3://store without one (deploy error, not a silent presign-off). Test runs the vars through main's realresolveR2PresignConfig, with a no-region control.d4297e1d7: README and.env.exampleoperations.analyticsD1*→analytics.d1.*viainstallAdminSettingDefinitionsf46fc9119: the branch's two entries removed fromoperations-telemetry-defaults.ts(now byte-identical to main);analytics.d1.*are installed byinstallAnalyticsD1Sink()through follow-up 2Places I was unsure which side should win
r2-presign-config.tsendpoint check: main's localvalidEndpoint(classifyHost) replaced the branch'sisAcceptableOperatorEndpoint(worker-core). The task-completion validator compared them: identical logic. The branch's worker-coreoperator-endpoint.tshad no other consumer and is removed in4e2e43509.s3://box withoutR2_S3_REGION: the deploy now stops with an error. Before, the branch silently signed withauto. An existings3://box must add the setting before upgrading.platform-capabilities.test.ts: kept the branch's file (as M4 did), so main's "every capability key, exactly" pin is not enforced on the branch. Main'sLOG_TAIL_AVAILABLEnormalisation case and its local-sink cases were added to it. The route test usestoMatchObjecton main's five public fields.operations.analyticsD1*rows on an existing box: the settings are gone from the registry; a box that saved a value keeps an orphan row. Checked on the box below.Post-merge fixes
d4297e1d7.env.example:gs://defaults toauto,s3://must setR2_S3_REGION. Task file.4e2e43509runtime-tunables-baseline.json(ANALYTICS_SINK,LOG_TAIL_AVAILABLE,R2_S3_*; the stale copy still namedoperations.analyticsD1*) anddirect-dependency-evidence.json(sam-mx Go modules); the branch copies were removed and every merged JSON file was re-scanned for duplicate keys (none). Dropped theanalyticsIngestcapability (no consumer; writes decide through main'sresolveAnalyticsSink). Re-added main'sLOG_TAIL_AVAILABLEpin. Removed the orphaned worker-coreoperator-endpoint.ts. Moved thepresignVars→resolveR2PresignConfigtest toapps/api/tests/unit/selfhost/presign-vars-resolver.test.ts: importing Worker env types fromscripts/selfhostpulled the whole API into that package's typecheck (CI run 44421000122, Validate Deploy Scripts). README/comment wording.Checks run
Local, on the merged tree (before
4e2e43509, then the affected packages again after it):pnpm install --frozen-lockfile;pnpm build19/19;pnpm typecheck38/38;pnpm lint23/23;pnpm format:check(ratchet) passes.turbo run test --continue: 41/41 tasks. API 1200 files passed / 3 skipped, 18292 tests passed, 5 skipped. Web 433 files, 5463 passed. Every other package passed.pnpm selfhost:test: 38 files, 593 passed, 2 skipped.4e2e43509:turbo run typecheck lint testfor worker-core, api and web and their dependents: 38/38.tsc -p scripts/selfhostandtsc -p scripts/deployclean.quality:scripts:test1530 passed, installer-engine 199 passed.migration-safety,do-migration-safety,wrangler-bindings,no-secret-readback,shared-flight-joins,runtime-tunables,direct-dependency-evidence,file-sizespass.celld-project.test.tsgoes red withappendSelfhostObservabilityMigrationsremoved;selfhost-build.test.tshas a before-install control;presign-vars-resolver.test.tshas a no-region control that returns null.CI (
ci.ymlonly triggers for PRs into main, so dispatched withworkflow_dispatch):d4297e1d7: failed Validate Deploy Scripts (fixed in4e2e43509, see above).4e2e43509: PASS, 25 jobs succeeded, 8 skipped (path-filtered or PR-only: devcontainer, VM agent, Pulumi, Go vuln diff, PR Evidence, Playwright visual). Self-host Email (sam-mx + SMTP) and Hosted git conformance ran and passed. run6d8126d75(task-file-only change after the box run): dispatched for the final head.Staging Verification Evidence
N/A by task instruction: this PR targets the integration branch and deploys nothing to staging. The self-host box smoke below is this PR's live gate, and it passed.
Box smoke (app.vmtest.sam2.party): PASS
Claimed on feature.selfhost-landing at 23:55Z; BOX FREE posted at 00:27Z. In-place upgrade of sam-box
ba35d4905→4e2e43509(the code head;6d8126d75adds only the task file) withpnpm selfhost:upgrade --to 4e2e435090a6…: "253 files, compose inputs changed, D1 migrations none", backup 11402 objects, celld down 19.3 s, "upgraded to 4e2e435…; healthy".4e2e43509, clean tree; 7 containers up;api/health200, app 2000002_analytics_events.sql(applied 2026-11-15 from the old shared copy) not re-run.analytics_eventsand both indexes present. The projection'sobservability-dev/0002_analytics_events.sqlnow links toapps/api/src/selfhost/migrations/observability/; the primary projection still links the self-host0255POST /api/twith eventm5_box_smoke_001617→ 204; row in OBSERVABILITY_DATABASEanalytics_eventsat 00:16:17 (name, app host, signed-in user id).GET /api/admin/analytics/events?period=24h→ 200 from the D1 sink (the single event is outside the machine-traffic top 50)opencode/deepseek-v4.1-flash-free, conversation task01M7RJN986N81GEM3VCTQAGDMJ: submitted 00:17:47Z, assistant "pong" 00:22:42Z (VM boot included)01M7RJNCZH225672TPWRFYGNC3created 00:17:50Z; lease port 20010 at 00:17:51Z; frps client login and proxy on 20010 at 00:19:00Z; heartbeats loggedheartbeat.ip_backfill_skipped_tunnel_node; node healthy (heartbeat 00:22:06Z);GET /api/nodes/:id/system-info200 in 2.6 s through the gateway. No error-level celld events since the upgradeUnsure item 4 checked: the box had no
operations.analyticsD1*rows, so there are no orphans. The box has noR2_S3_ENDPOINT, so the new region rule has no live effect there (covered bypresign-vars-resolver.test.ts).Cleanup: session stop 200 (
workspaceDeleted), node DELETE 200, lease releasedruntime_terminated, VM gone at GCP (only sam-box), 0 active nodes or workspaces, both sessions signed out, the 1.1 GB pre-upgrade backup (plaintext secrets) and my scratch directory deleted, temporary SSH key and firewall rule removed (the next SSH attempt is refused). The box stays on4e2e43509.Specialist Review Evidence
runtime-tunables-baseline.jsonanddirect-dependency-evidence.json, deadanalyticsIngestcapability: fixed in4e2e43509. LOW: README referent,monthlyCostCapcomment: fixed. LOW orphanoperations.analyticsD1*rows on an existing box: checked on the box (below).r2Presignand the other consumer-less re-attached capabilities are the M4 "unlanded capability inputs", unchanged by this mergeoperations.analyticsD1*text: fixed in4e2e43509. MEDIUM droppedLOG_TAIL_AVAILABLEtest: re-added. MEDIUM orphanedoperator-endpoint.ts: removed. LOWtoMatchObject: documented (unsure item 3). Box orphan-row check added to the smokeCodeRabbit Review Evidence
coderabbit-reviewlabel (itspull_request_targetrun skipped, as it does on a draft) and the trusted workflow dispatched from main (run 44424196163, success).Review skipped: Too many files!(229 files, limit 100; "sufficient usage credits or metered capacity aren't available"). Per rule 25 the wait ended there; no re-trigger, no waiver requested. A merge PR of this size cannot get a CodeRabbit review on the current plan.Agent Preflight (Required)
Classification
External References
N/A: merge of reviewed repository implementations; no new external API integration. M4 #2884 and L20 #2889 bodies read before merging.
Codebase Impact Analysis
apps/api(analytics sink seam, presign client, capabilities, SMTP/inbound email),apps/web(Admin Logs/Stream notice, capability fields),packages/agent-email,packages/app-deployment,deploy/selfhost(sam-mx, README),scripts/selfhost(celld project, build entry, box settings),scripts/qualitybaselines. The generated celld entry (withSelfHostBuild) is where self-host-only extensions are installed.Documentation & Specs
deploy/selfhost/README.mdanddeploy/selfhost/.env.example(region rule); main's docs merged. The task file records the plan.Constitution & Risk Check
Principles X and XI: no new runtime constants beyond
GCS_SIGNING_REGION(a fixed protocol value for GCS's S3 API, not a tunable). Migration safety: no migration renumbered; one branch-only shared-dir migration file removed (observability/0002_analytics_events.sql), its content now ships from main's self-host directory under the same filename, so boxes that applied it keep a matching ledger row. Main risk is a silent merge incompatibility, covered by build, typecheck, the full test suite, the self-host suite, CI and the box smoke.🤖 Generated with Claude Code