Repository navigation
feat(stream-of-record): durable message parts as chat record-of-truth (dark-shipped) - #3698
Merged
Merged
Conversation
Contributor
🧪 BenchmarkShould we run the Virtual MCP strategy benchmark for this PR? React with 👍 to run the benchmark.
Benchmark will run on the next push after you react. |
…rage adapter Append-only thread_message_parts table (migration 098) with version/progress columns on threads; pure foldParts read model; SqlThreadMessagePartStorage (append/window/backfill) with real-Postgres integration tests (C1, C2, C5, R14, R18). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Pure isRunStuck (A1, A2), detectGap/reconcileDurable (B4, R5, R6), and the throttled progress-bump helper — all unit-tested. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…ges) Memory.loadHistory and the COLLECTION_THREAD_MESSAGES_LIST UI reader branch on message_storage_version: v2 folds thread_message_parts, v1 reads the frozen thread_messages table. Org predicate preserved (R23). Includes the e2e read-path spec. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
… reaper PartEmitter persists only final parts (idempotent, monotonic created_at) at the dispatcher hooks; new threads pinned v2 on first message behind STREAM_OF_RECORD_V2_PERCENT (default 0); the run reaper is now progress-based via last_progress_at. Dark-shipped: with the flag off the v1 path is unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Toxiproxy scenario proving result survival across a NATS fault (B1/B2/B4, C1). Runnable wiring + the self-heal proof gated behind harness scaffolding (mock-AI + studio-v2 service), documented in the README. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Migrations are an explicit manifest (apps/mesh/migrations/index.ts), not filesystem-discovered, so the new 098 file was never run by 'bun run migrate' — the thread_message_parts table + threads.{message_storage_version,last_progress_at} columns were never created in CI, failing storage-integration and e2e (the progress bump runs on every turn). Register 098 and re-run biome format on threads.ts.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…tool, not UI render The e2e seeded a v2 thread and asserted the browser transcript, but rendering a real chat needs model/credential onboarding the read-path fork is orthogonal to (the sibling decopilot specs exercise the API/MCP front door for the same reason). Rewrite to call COLLECTION_THREAD_MESSAGES_LIST directly — the exact reader we forked — and assert the folded message. typecheck + fmt clean. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…by the link ingest Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…d accessors Adds the Phase A fence substrate: nullable `run_fence_token` column on `threads` (migration 099), the pure `fenceMatches` predicate with unit tests, and `getRunFence`/`setRunFence` accessors on SqlThreadStorage. The fence is inert until minted in a later phase (null => accept all). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
… parts via an emitter Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
… and de-dups onError Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…ndpoint Wires the cluster-side HTTP ingest for the pull-inverted local link: checks the run fence token (409 on mismatch), parses the daemon's SSE body via parseDispatchSSEStream, commits parts to thread_message_parts through PartEmitter/consumePartStream, and pumps the JetStream live edge. Also delegates getRunFence from OrgScopedThreadStorage to the inner SqlThreadStorage. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…mp-sole-consumer Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
The link-ingest e2e built its dispatch SSE body with `textDelta`/non-standard chunk fields; ai@6 text deltas use `delta` and text parts key on `id`. Mirror the exact UIMessageChunk sequence the consume-part-stream unit test proved assembles, so the happy-path test actually lands a text part in CI. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…n plans Adds the axis-b "Desktop-as-pull-worker inversion" design (companion to the stream-of-record spec) and bite-sized TDD implementation plans for Phases A–F: A (SoR ingest, implemented), B (WorkQueue + work long-poll + DBOS gate change + fence minting), C (control long-poll: cancel/HITL + sandbox lifecycle), D (cut codex/claude-code to pull), E (decopilot harness portability), F (delete the reverse-WS NATS middle-man). Everything is gated behind a link_transport flag (pull ⊆ v2) so the live push path is untouched; shipped-daemon tasks are flagged for human review. Includes the report/proposals/stream-of-record design corpus. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…ating Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…transport work delivery Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…e-poll work loss) Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…resh Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
… poll threads.status until terminal Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
… flag latent work-item gap - Import and pass `pullDispatch` + `linkWorkQueue` into `setThreadGateRuntime` in app.ts, making the `pullDispatch` export reachable and fixing the knip unused-export failure. `linkWorkQueue` is null when NATS is absent; the gate's `pullDispatchFn != null && workQueue != null` guard keeps the ws path active in that case — no behavior change. - Gate the `threads.get()` fetch in `dispatchRunAndWaitStep` behind `isPullCapable` (only fetch when runtime is pull-wired), eliminating a redundant DB read on every ws-path dispatch when pull is not configured. - Add prominent PHASE B INCOMPLETE comments at the work-item publish site and `pullDispatch` JSDoc flagging that `harnessInput` is raw DispatchRunInput, not the full HarnessStreamInput the daemon requires (Phase D must resolve this). - Add minor latent-edge-case notes at `setRunFence`: DBOS-replay token mismatch and failed-pull-run fence token lifecycle. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…eamInput (closes work-item gap) Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…releases the gate poll) Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…ew already local; one-method rehome; go/no-go pending)
…andmines, 9 stages (adversarial review)
… pull reverse-proxy channel (dormant) Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…tached per-reqId, duplex reply, reqId cancel) [⚠️ shipped daemon] Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…+ base64-unified binary-safe DispatchChunk + probeHealth repoint Unify DispatchChunk.data as base64 across BOTH transports (landmine #9): - WS daemon side (cluster-connection.ts): stop the TextDecoder→UTF-8 conversion for /_sandbox streaming + base64-encode the lifecycle res.body so chunk.data is base64 on the wire for both paths. - createProxyDispatch: already base64 (pass-through, unchanged). - runner.ts: decode base64→bytes when building the Response body (binary-safe; fixes the historical UTF-8 lossy-ness for vm-tools file reads) via a 4-char carry-buffer stream decoder that survives the WS payload-chunking splitter cutting a base64 string mid-group; dispatchJson concatenates-then-decodes. Provider transport swap behind LINK_PROXY_TRANSPORT (default OFF → WS stays default, pull dormant): buildDesktopProvider injects createProxyDispatch (getProxyDispatch, wired off the same NATS connection in app.ts) when LINK_PROXY_TRANSPORT=pull, else getDispatch (WS). selectDesktopTransport is the pure, unit-tested gate. Daemon proxy path-routing: buildReplyBody routes /api/sandboxes* (ensure / delete / liveness) → controlHandler.handle (wrapped as headers+chunk+end) and /_sandbox/* → handleStream, so ensure/delete/probeHealth ride the SAME proxy channel. Deviation from the plan doc: ensure/delete go THROUGH the proxy channel via handle() rather than the doc's separate control-poll frames (simpler, correct). probeHealth (landmine #4): kept on the dispatch fast path (no presence-claim round-trip) — the proxy round-trip is near-zero-gap (continuous-overlap GETs) + a synchronous in-memory handle() check; cap raised 1500→3000ms to absorb the per-probe reply-POST establishment. Tests: base64 round-trip uniformity (both transports + runner, incl. 0x80/0xff and mid-group splits), daemon path-routing (/api/sandboxes→handle, /_sandbox/*→handleStream), provider-flag selection. Heavy real-NATS e2e deferred to S5 (S5 owns the e2e per the plan). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…(pure computeHandle); preview-URL site keeps ensure Add `computeDesktopSandboxHandle` (pure, sync, no I/O) that derives the sandbox handle via composeSandboxRef → computeClaimHandle, mirroring the formula used by ensureSandbox/provisionSandbox. Replace the two redundant `resolveRemoteCliSandboxHandle` (warm-ensure) calls: - prepareRun (runsIn=user-desktop branch): pure computeDesktopSandboxHandle - pullDispatch (sandboxConfig resolution): pure computeDesktopSandboxHandle The daemon self-ensures from WorkItem.sandbox on dequeue (cluster-connection-pull.ts:214 input.provider.ensureSandbox), so the cluster-side warm-ensure was redundant on both pull paths and is now severed. resolveRemoteCliSandboxUrl (the preview-URL path) still calls resolveRemoteCliSandboxHandle — it has no daemon self-ensure backstop, so pure handle derivation there would return a potentially-unspawned handle → 502. That site is intentionally unchanged. Unit tests: 7 new tests for computeDesktopSandboxHandle (determinism, shape, sensitivity to each input dimension). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…y e2e (round-trip, SSE, cancel, no-gap, fail-fast) Part A (landmine #8): createProxyDispatch now watches the user's link-claim presence (the cross-pod port of ws-gateway.ts's WS-close fanout — the claim, re-armed by the daemon's work/control/proxy polls, IS the liveness signal). Any `null` watcher fire (claim expired/deleted) aborts the in-flight await and throws a 502-equivalent so runner.ts rejects promptly instead of hanging on a reply that never arrives. No new idle timeout (the /events SSE body has legitimate long gaps). Wired via linkClaimRegistry.watch in app.ts; the POST/GET-drop error-frame path (S1) is untouched and still backstops. Part B: apps/mesh/e2e/tests/link-proxy.spec.ts drives a real createProxyDispatch round-trip over real NATS + the real /links/proxy routes via a non-production test-trigger route (mounted only when NODE_ENV!=="production"). A proxy-daemon simulator does continuous-overlap GET /links/proxy + duplex NDJSON POST replies + a /links/control cancel poll. Asserts: byte-exact round-trip (incl. a non-UTF-8 byte for base64 fidelity), incremental SSE relay, cancel reaches the simulator + ends the caller's stream, a request issued mid-handling is not dropped, and daemon-vanished mid-stream makes the caller fail fast (not hang). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…ktop' + v2); rehome chat e2e specs to pull presence The gate now keys off the POST-time-resolved dispatch target (request.target.runsIn === 'user-desktop') instead of link_transport, keeping the v2 conjunct as belt-and-suspenders. Cloud/cluster threads and undefined targets fall back to the in-cluster ws path — the fix for the reverted NATS-gated cutover (40562b3) that routed every chat to a pull work-queue nobody drains. decidePullDispatch extracted as a pure helper + unit-tested. decopilot- messages and chat-locked-thread e2e specs swapped from connectToCluster WS links to claimPullPresence (shared fixture). link-dispatch-pull drops the link_transport seed, keeps message_storage_version=2. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…ber fail-fast) + hang-proof link-proxy e2e + playwright globalTimeout backstop Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…ll (hard break: re-run bunx decocms@latest link) Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
… dispatcher, dispatch-frames, cluster-connection, reconnect-backoff); pure-pull [⚠️ shipped daemon] Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…sed by CLI preflight + pull-presence e2e helpers)
…S (pure-pull is the only transport) Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…coped — daemon hard-required it but the CLI never passed one) The reverse-WS endpoint /api/links/connect was unscoped, so deco link never needed an org. The pull transport polls /api/:org/links/* and the daemon exits with 'requires an org slug' without one. Resolve it: --org flag → DECO_ORG_SLUG → auto-resolve the user's single org from the cluster. Found by running 'bun run dev --local-sandbox-provider' (daemon looped on the error). Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…ewPort on the pull path The pull connectToClusterPull call never passed the daemon's identity/capabilities, so the cluster minted a presence claim with empty capabilities + placeholder machineId/cliVersion/previewPort=0. Capability-gated dispatch then 409'd with user_desktop_link_capability_missing even though presence showed 'linked'. The WS hello frame carried these before S8 deleted it; the pull path must too. Wire detectCapabilities() + loadOrCreateMachineId() + ingress.port into the call. Verified live: claim now advertises [decopilot-sandbox, body-offload, claude-code, codex]. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
… plans + spec, brainstorm docs)
tlgimenes
force-pushed
the
tlgimenes/chat-message-dataflow
branch
from
June 7, 2026 22:02
2225107 to
0e174a8
Compare
tlgimenes
enabled auto-merge (squash)
June 7, 2026 22:04
decocms Bot
pushed a commit
that referenced
this pull request
Jun 7, 2026
PR: #3698 feat(stream-of-record): durable message parts as chat record-of-truth (dark-shipped) Bump type: minor - decocms (apps/mesh/package.json): 2.396.1 -> 2.397.0 - @decocms/sandbox (packages/sandbox/package.json): 0.6.4 -> 0.7.0
This was referenced Jun 8, 2026
tlgimenes
added a commit
that referenced
this pull request
Jun 8, 2026
…#3702) * test(dispatch): push path must ensure the sandbox before dispatch (red) * fix(link): ensure the desktop sandbox on the remoteDispatch push path The push (remoteDispatch) dispatch site stopped ensuring the sandbox in C-bis S4 (#3698), on the rationale that the daemon self-ensures from the work item — but that backstop exists only on the pull/work-queue path. On the push path the link daemon's control-handler 404s "unknown handle" for an unspawned handle, surfacing as [remoteDispatch] dispatch failed (404). Restore the warm-ensure via ensurePushDispatchSandboxHandle and dispatch the provisioned handle (also closing the thread-vs-input branch drift). Pull site unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * docs(dispatch): update test header for ensurePushDispatchSandboxHandle Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
3 of 4 tasks
tlgimenes
added a commit
that referenced
this pull request
Jun 8, 2026
…rtion (#3703) * fix(tests/resilience): wait out the 60s presence TTL in the link-offline assertion The daemon↔studio transport flipped from reverse-WS to pure pull (#3698), so the link claim is now a `studio_links` KV entry with a 60s TTL re-armed on every work/control/proxy poll — not a socket whose close releases the claim in a few seconds. The ws-partition scenario still polled `/api/links/me === null` with a 30s budget, so it timed out deterministically once the WS transport was gone (every run since #3698 failed on `WS severed → link offline`). Raise the offline-poll budget past the TTL (30s → 80s), bump the affected sub-test timeouts, and correct the now-misleading "WS close" comments to describe the pull-transport presence model. Apply the same TTL fix to the skipped log-replay scenario so it doesn't re-break when un-skipped. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * fix(e2e): resolve flaky test timeouts and unreachable connection URLs Two e2e test failures due to timing/infrastructure issues: 1. chat-input-draft.spec.ts (line 48): typeInComposer's toHaveText() was timing out at 5s before Tiptap had time to render the full text under CI load. Increase timeout to 15s to accommodate Tiptap's DOM updates. 2. clonable-agent-logo.spec.ts (line 22): HTTP connection creation was failing with a 500 error because the backend now validates HTTP endpoints, and the test was using an intentionally unreachable URL (127.0.0.1:1). Use the actual test server at localhost:3000 instead — we only need the connection ID for the test, not a functional endpoint. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
tlgimenes
added a commit
that referenced
this pull request
Jun 8, 2026
…st-leg republish (TDD, all gates green) Fixes #3698-follow: cluster-daemon proxy channel now tolerant of transient subscriber gaps. PART #1 — Per-slot backoff (proxy-poller.ts) - Root cause: shared errorStreak across proxy concurrency slots. One systemic error (e.g. Cloudflare 520 on the 28s long-poll) backed off BOTH slots → 1–30s zero-subscriber gap → dispatch publish to links.proxy.req.<userSub> dropped → proxy_no_first_frame 15s later. - Fix: move errorStreak into each slot(). Each slot backs off only its own failures; one recovering slot re-polls immediately while another retries, keeping ≥1 live subscriber through intermittent errors. - Test: new "per-slot backoff" test with concurrency:2 asserts seenStreaks=[0,0] not [0,1]. PART #2 — Request-leg tolerance (link-proxy-routes.ts, proxy-poller.ts) - Root cause: fire-and-forget core-NATS publish with no buffer. A single blind publish is lost if it lands in a daemon poll/backoff gap; no retry, no durability. - Fix: cluster-side bounded republish + daemon reqId dedup. (A) proxy-abort-registry.register() now returns AbortController|null; null if reqId already in-flight (duplicate delivery dedup). handleProxyRequest bails on null before try/finally, so duplicate copy doesn't unregister the original. (B) createProxyDispatch republishes RequestFrame every 1s (injectable republishIntervalMs, 0=off) until first reply frame. Stopped by markFirstFrame/cleanup/first-frame-timeout (never outlives dispatch, bounded by 15s window). Daemon dedup makes double-execution impossible (emits first frame only after upstream responds). - Tests: registry dedup test + "re-publishes...then stops" cluster test. Verification: 36 affected-test pass, 110 link tests pass, fmt/lint/typecheck clean.⚠️ Daemon caveat: proxy-abort-registry.ts marked "SHIPPED DAEMON — needs human review before merge." Small change, well-tested, but shipped in `decocms` CLI. Remaining: #3 tie proxy-readiness to claim (doc-vs-code defect), infra fix for CF 520, plus this dedup safety pattern may apply elsewhere (runAbortRegistry in thread-gate-workflow). Co-Authored-By: Claude Haiku 4.5 <[email protected]>
tlgimenes
added a commit
that referenced
this pull request
Jun 8, 2026
…st-leg republish (TDD, all gates green) (#3704) Fixes #3698-follow: cluster-daemon proxy channel now tolerant of transient subscriber gaps. PART #1 — Per-slot backoff (proxy-poller.ts) - Root cause: shared errorStreak across proxy concurrency slots. One systemic error (e.g. Cloudflare 520 on the 28s long-poll) backed off BOTH slots → 1–30s zero-subscriber gap → dispatch publish to links.proxy.req.<userSub> dropped → proxy_no_first_frame 15s later. - Fix: move errorStreak into each slot(). Each slot backs off only its own failures; one recovering slot re-polls immediately while another retries, keeping ≥1 live subscriber through intermittent errors. - Test: new "per-slot backoff" test with concurrency:2 asserts seenStreaks=[0,0] not [0,1]. PART #2 — Request-leg tolerance (link-proxy-routes.ts, proxy-poller.ts) - Root cause: fire-and-forget core-NATS publish with no buffer. A single blind publish is lost if it lands in a daemon poll/backoff gap; no retry, no durability. - Fix: cluster-side bounded republish + daemon reqId dedup. (A) proxy-abort-registry.register() now returns AbortController|null; null if reqId already in-flight (duplicate delivery dedup). handleProxyRequest bails on null before try/finally, so duplicate copy doesn't unregister the original. (B) createProxyDispatch republishes RequestFrame every 1s (injectable republishIntervalMs, 0=off) until first reply frame. Stopped by markFirstFrame/cleanup/first-frame-timeout (never outlives dispatch, bounded by 15s window). Daemon dedup makes double-execution impossible (emits first frame only after upstream responds). - Tests: registry dedup test + "re-publishes...then stops" cluster test. Verification: 36 affected-test pass, 110 link tests pass, fmt/lint/typecheck clean.⚠️ Daemon caveat: proxy-abort-registry.ts marked "SHIPPED DAEMON — needs human review before merge." Small change, well-tested, but shipped in `decocms` CLI. Remaining: #3 tie proxy-readiness to claim (doc-vs-code defect), infra fix for CF 520, plus this dedup safety pattern may apply elsewhere (runAbortRegistry in thread-gate-workflow). Co-authored-by: Claude Haiku 4.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Introduces the stream-of-record: a durable, append-only
thread_message_partstable as the chat record-of-truth, folded into messages on read. New ("v2") threads write message parts (text/tool_call/tool_result/finish) instead of upsertingthread_messages; old ("v1") threads are untouched. Dark-shipped behindSTREAM_OF_RECORD_V2_PERCENT(default0) — nothing changes for existing traffic until the flag is raised.This is Phase 1 of the design in
stream-of-record-spec.md(kept as a working note): the durable core + v1/v2 read & write paths + progress-based liveness.What it does
thread_message_parts(append-only, idempotentON CONFLICT (id) DO NOTHING,finish-anchor pagination) +threads.message_storage_version/last_progress_at(migration 098).Memory.loadHistoryand theCOLLECTION_THREAD_MESSAGES_LISTUI tool fold v2 parts; v1 reads the frozenthread_messages. The org/thread auth predicate is preserved (R23).PartEmitterpersists only final parts at the dispatcher hooks (idempotent across the cumulative AI-SDK stream, monotoniccreated_at). New threads are pinned v2 on first message via a deterministic canary bucket.last_progress_at, throttled bump) consumed byisRunStuck.Bugs fixed (from the architecture report)
seq/created_atfinish-anchor window + deterministic ids58 unit tests pass;
bun run checkclean across all workspaces.Safety / rollout
Default-OFF (
STREAM_OF_RECORD_V2_PERCENT=0) → thePartEmitteris never constructed and the v1 path runs byte-for-byte unchanged. Before raising the percent: an e2e must confirm a multi-step tool-calling v2 transcript folds identically to v1 (validates the part-index-stability assumption), and the resilience self-heal needs the harness changes in the scenario README. Per-thread rollback is instant (hash-bucketed; only new threads are pinned).Out of scope (follow-ups, per the spec)
Claim-check / object-storage offload (E3), NATS per-org sharding (B3), the H1 ownership change, R24 metrics.
🤖 Generated with Claude Code
Summary by cubic
Replaces the desktop WS link with a pure pull transport and adds a durable stream‑of‑record for chat (append‑only parts), dark‑shipped by default. Introduces work/control/proxy long‑polls, an ingest return path, and progress‑based liveness so user‑desktop runs route and cancel reliably.
New Features
thread_message_partswith fold‑on‑read;PartEmitterpersists only final parts; progress‑based reaper vialast_progress_at. Dark‑shipped (STREAM_OF_RECORD_V2_PERCENT=0); v1 remains default.POST /api/:org/links/runs/:runId/streamparses SSE, checksrun_fence_token, rejects canceled or stale runs (409), commits parts, and transitions the run terminal.GET /api/:org/links/worklong‑poll delivers work from a JetStream WorkQueue and refreshes presence; claims include capabilities and identity (x-link-capabilities,x-link-machine-id,x-link-cli-version,x-link-preview-port). Stops JetStream fetch on client disconnect; offloads large inputs viamessagesRef.GET /api/:org/links/controllong‑poll servescancelframes (also published via NATS); reverse‑proxy channel (GET /api/:org/links/proxy+POST /api/:org/links/proxy/:reqId/stream) streams NDJSON base64 with a first‑frame timeout andcancel_reqvia control.decidePullDispatchroutes v2runsIn:'user-desktop'to pull; the daemon runs work/control/proxy pollers and advertises capabilities/identity;/api/links/mere‑homed; WS gateway/dispatcher removed.globalTimeout; migrations 098 (parts), 099 (run fence), 100 (link transport), 101 (cancel flag).Migration
deco linkdaemon and desktop provider; the old WS path is removed.deco linknow needs an org slug for org‑scoped pull routes: pass--org, setDECO_ORG_SLUG, or rely on auto‑resolution.STREAM_OF_RECORD_V2_PERCENTat0until ready; raising it pins only new threads to v2.Written for commit 0e174a8. Summary will update on new commits.
➕ Local-link pull-inversion (axis b) — COMPLETE
The cluster-pushed reverse-WebSocket is replaced by desktop-pulled long-polls; the two-pod NATS middle-man + the reverse-WS are deleted. Pull is now the only transport (hard break — see Migration). All phases landed and CI-green (build, daemon-e2e, e2e, multi-pod, typecheck, lint, test, storage-integration).
Design docs (repo root):
local-link-pull-inversion-spec.md+ per-phase planslocal-link-pull-inversion-phase-{a,b,c,c-bis,d,e,f}-plan.md(each has a landing-status section).What landed:
POST /api/:org/links/runs/:runId/streamparses the harness SSE, commits parts via the v2PartEmitter, fenced bythreads.run_fence_token(migration 099).LinkWorkQueue+GET /api/:org/links/worklong-poll + presence; the DBOS thread-gate publishes a fullHarnessStreamInputwork item and pollsthreads.status.threads.cancel_requested_at(migration 101) +GET /api/:org/links/control+ ingest 409-on-cancel + the daemon reqId/runId abort registries./_sandboxcontrol RPC, and decopilot vm-tools (all funneling throughDesktopSandboxProvider.proxyDaemonRequest) move to a pull reverse-proxy channel —GET /api/:org/links/proxy(queue-group request leg) +POST /api/:org/links/proxy/:reqId/stream(NDJSON reply leg), correlated by two id-derived NATS subjects (no per-pod inbox), base64-framed, with a first-frame timeout + presence-watch fail-fast. Desktop preview was already served by the daemon's local-ingress — it never rode the WS, so it needed no change.work-poller.ts/control-poller.ts/proxy-poller.ts/handle-local-dispatch.ts/cluster-connection-pull.ts; the work item carries the full sandbox config + orgSlug +messagesRefoffload so the daemon provisions cold.apps/mesh/src/harnesses/decopilot-desktop/(aDesktopToolCtxsevers the Better-AuthStudioContexttype;provider-from-secretmaps providerId→@ai-sdk/*), registered in the daemon bundle.ws-gateway.ts,dispatcher.ts,dispatch-frames.ts,cluster-connection.ts,reconnect-backoff.tsremoved;app.ts/index.ts/lifecycle.tsgutted.decidePullDispatchroutes v2runsIn:'user-desktop'to pull; daemon + desktop provider default to pull.GET /api/links/mere-homed toapp.ts(CLI preflight + presence helpers).Routing:
isPull = pullCapable && target.runsIn === 'user-desktop' && message_storage_version === 2. Cloud/in-cluster chats (incl. decopilot, which is dual-homed to cluster) take the unchanged in-cluster path; only CLI harnesses on a linked desktop go pull.bunx decocms@latest link— the old WS daemon can no longer connect.Testing: unit tests cover the framing/scheduler/abort/fail-fast logic; CI e2e exercises the cluster routes against a simulated daemon (
link-dispatch-pull,link-proxy,link-control,link-ingest). CI does not run a realdeco linkdaemon — validate the real end-to-end pull flow withbun run dev --local-sandbox-provider(auto-spawns a real daemon in pull mode) and at deploy.apps/mesh/src/link-daemon/*changes ship in thedeco linkbinary — review accordingly.