feat(wire,client-core): chunked attachment upload and read protocol - #514
feat(wire,client-core): chunked attachment upload and read protocol#514Zerlight wants to merge 11 commits into
Conversation
|
Your Claude subscription has hit its usage limit. It resets at 11:30am (UTC). Re-trigger Pullfrog after the reset, or add an Add repo secret → · Model settings → · Setup docs → · Ask in Discord →
|
Greptile SummaryThis PR introduces a chunked, content-addressed attachment protocol across the shared wire schema, client core, host engine, daemon persistence, and development mock.
Confidence Score: 0/5The PR is not safe to merge until cross-session mock authorization, cross-client upload replay, abandoned-stage cleanup, and malformed mock chunk handling are corrected. The shared upload service can expose or abort another client's active upload through an operation-ID collision, the dev mock can grant attachment access from an arbitrary prompt reference, abandoned begins can exhaust staging resources, and malformed chunks can leave client requests permanently pending. Files Needing Attention: packages/host/engine/src/attachment/upload-service.ts, packages/client/workbench/src/mock/dev-mock-host.ts, packages/client/core/src/client/attachment-channel.ts
|
| Filename | Overview |
|---|---|
| packages/host/engine/src/attachment/upload-service.ts | Implements upload staging, deduplication, validation, reads, and replay, but globally scoped replay capabilities and unbounded live-stage lifecycle require attention. |
| packages/client/workbench/src/mock/dev-mock-host.ts | Adds dev-mock attachment parity, but prompt rooting permits cross-session reads and malformed chunks can strand pending requests. |
| packages/client/core/src/client/attachment-channel.ts | Adds windowed uploads and cached paginated reads; later read pages should be checked for identity and size consistency. |
| packages/foundation/schema/src/wire/attachment.ts | Defines bounded additive upload and read frames with protocol capability constants. |
| apps/daemon/src/attachment-store.ts | Adds session-scoped reachability checks through persisted prompt and resource roots. |
| packages/host/engine/src/attachment/blob-store.ts | Adds positional immutable-blob reads and supplies the retained staging handles involved in upload lifecycle management. |
Sequence Diagram
sequenceDiagram
participant Client
participant Wire as Shared wire transport
participant Engine as Attachment service
participant Stage as Staging blob
participant Store as Attachment store
participant Blob as Immutable blob store
Client->>Wire: attachment.upload.begin(hash, size, metadata)
Wire->>Engine: validated begin
Engine->>Store: create upload lease
alt Blob already exists
Engine-->>Client: "begun(state=exists)"
else New blob
Engine->>Stage: open staging file
Engine-->>Client: "begun(state=ready, chunkBytes)"
loop Credit-windowed chunks
Client->>Engine: chunk(uploadId, offset, base64)
Engine->>Stage: positional write
Engine-->>Client: cumulative acknowledgement
end
end
Client->>Engine: commit(uploadId)
Engine->>Engine: verify size, MIME, and SHA-256
Engine->>Blob: atomically publish immutable bytes
Engine->>Store: commit attachment and release lease
Engine-->>Client: attachmentId and blobId
Client->>Engine: read(sessionId, attachmentId, offset)
Engine->>Store: verify session reachability
Engine->>Blob: positional read
Engine-->>Client: immutable blob page
Reviews (1): Last reviewed commit: "fix(workbench): gate dev-mock attachment..." | Re-trigger Greptile
4d09b99 to
68e9f61
Compare
There was a problem hiding this comment.
Greptile has paused reviews on this repository — it used its 100 free open-source review credits for this billing period. Reviews resume automatically on September 23. To continue before then, an organization admin can keep reviews running past the free credits — those bill as normal usage.
There was a problem hiding this comment.
Greptile has paused reviews on this repository — it used its 100 free open-source review credits for this billing period. Reviews resume automatically on September 23. To continue before then, an organization admin can keep reviews running past the free credits — those bill as normal usage.
|
Your Claude subscription has hit its usage limit. It resets at 11:30am (UTC). Re-trigger Pullfrog after the reset, or add an Add repo secret → · Model settings → · Setup docs → · Ask in Discord →
|
Additive kinds at wire 80: begin/chunk/commit/abort/read, 256 KiB chunks, and a feature-detect constant. The payload field is attachmentKind so it does not collide with the frame discriminator.
…bility Positional BlobStore.read, session-scoped isReachable (prompt refs or session resources), and a missing-file stat so a vanished CAS object is not treated as a dedupe hit.
Begin/chunk/commit/abort with a credit window and SHA-256 dedupe, MIME sniff at commit, and reachability-gated reads. Typed request errors for offset, hash, size, and missing ids.
Wrong offset/hash/size, missing blob files, path-shaped ids, and cross-session reads fail typed. Dedupe exists and resource-rooted reads go through the engine.
Feature-detects wire 80, pipelines chunks in a two-chunk credit window, and caches decoded bytes by blobId.
Begin/chunk/commit/abort/read run in memory so showcase and mock E2E exercise the new protocol instead of silently dropping the kinds.
… abandoned stages
…upload, bound the blob cache
…n the chunk budget
…sniff its commits
68e9f61 to
d3351d3
Compare
|
Your Claude subscription has hit its usage limit. It resets at 11:30am (UTC). Re-trigger Pullfrog after the reset, or add an Add repo secret → · Model settings → · Setup docs → · Ask in Discord →
|
|
Review round on this PR (Greptile, five inline threads), fixes on the top of the stack: fdda262 — a replayed |

Summary
Phase 3 of CODE-627 — Conversation turn graph & immutable attachment store. Linear: https://linear.app/arcbox/issue/CODE-636/featwireclient-core-chunked-attachment-upload-and-read-protocol
Stack: #513 ← this PR (
ruocheng/code-636, baseruocheng/code-635) ← #515. Merge bottom-up; this PR's diff is only its own commits.Additive chunked upload/read frames sized for the tunnel:
begincarries the client SHA-256 for a zero-chunk dedupe short-circuit, credit-window flow control accepts pipelined chunks,commitverifies size, coverage, hash, and sniffed MIME before the atomic rename, andattachment.readis reachability-checked against the session's graph. client-core gains upload/read plumbing and a bounded blob cache; the mime sniff moves to the schema so clients validate too; the dev mock implements the frames.Commits
Verification
Every commit passed
pnpm check:ciandpnpm testat its own tip; the stack tip (1d942a62; the same tree as the originally gated73fc5ff2plus the two review fixes below on 628/629) is atpnpm check:ci0 errors,pnpm test3408 passed / 1 skipped. Adversarial reviewers (one per axis, isolated read-only worktrees) reviewed the branch; each P1/P2 was reproduced with a failing test or a probe step before its fix — the round-by-round record is in the Linear issue's comments. Tests pin the chunk budget and cover the reject paths (wrong offset/hash/size, cross-session reads) on the engine and the dev mock.Checklist
pnpm check:ciandpnpm testboth pass (no Rust changes)AGENTS.mdand module docs in this branch)