~bigbes/sr-ht-dolt · parade

main · last commit 5 hours ago · ti41arbu

← Back to the parade

sr-ht-dolt-cwl Add Flush hook to mcpsrv cacheWriter so MCP answers keep Cache-Control/Vary Lined Up

status: open P0 bug
bd update sr-ht-dolt-cwl --claim bd close sr-ht-dolt-cwl
Created byEugene Blikh
Ownerbigbes@gmail.com
Created2026-08-17T20:38:41Z
Updated2026-08-17T20:38:41Z
Description
What is wrong: `mcpsrv/mcpsrv.go::cacheWriter` stamps `Cache-Control: private, no-store, no-transform` and `Vary` at commit time by hooking `WriteHeader` and `Write`, but not `Flush`. A response committed through a flush never reaches `commit()` and ships with neither header; because `cacheWriter` embeds the `http.ResponseWriter` interface, a `w.(http.Flusher)` assertion in the MCP SDK also fails outright.

Why it matters: this is a security defect, not a style issue. dolt's MCP surface can answer with data scoped to the caller, and without `Vary` a shared/intermediate cache keys the answer on the URL alone and can hand a flushed response to the next caller regardless of credentials. `httptest.ResponseRecorder`-based tests structurally cannot catch this — it needs a real-socket, flush-before-write test.

Sibling that already does it correctly: `sr-ht-ecore/mcphttp/cache.go::cacheWriter` (commit 3bd158f) fixes this with a proper Flush hook; artifacts (6c44e03) and bench (7173a3e, test `TestHeadersLandOnAFlush`) and specs (824788a) and curator carry the fix locally.

Fix: replace dolt's private `cacheWriter`/`privateCache` with `mcphttp.PrivateCache` from the ecore revision dolt already pins (see the related D10 issue on adopting mcphttp generally); failing that, add a `Flush` method that calls `commit()` then `http.NewResponseController(w.ResponseWriter).Flush()`, and add a real-socket flush test, not a recorder test.

Status: verified — cacheWriter has 0 Flush methods in dolt's mcpsrv package (confirmed by counting method sets across all six mcpsrv packages).

Audit: D02 (cross-repo audit, 2026-08-17)

Depends on

No outgoing dependencies.

Depended on by

Nothing depends on this issue.

No comments.

  • Eugene Blikh created the issue · 2026-08-17T23:38:41Z
Stored rows — what this pane was built from, as read
issues 1 row
id sr-ht-dolt-cwl
content_hash fc963bcde32da1ecdf6bc96463f664c2b27ff45930d14191a0b114968526d744
title Add Flush hook to mcpsrv cacheWriter so MCP answers keep Cache-Control/Vary
description What is wrong: `mcpsrv/mcpsrv.go::cacheWriter` stamps `Cache-Control: private, no-store, no-transform` and `Vary` at commit time by hooking `WriteHeader` and `Write`, but not `Flush`. A response committed through a flush never reaches `commit()` and ships with neither header; because `cacheWriter` embeds the `http.ResponseWriter` interface, a `w.(http.Flusher)` assertion in the MCP SDK also fails outright. Why it matters: this is a security defect, not a style issue. dolt's MCP surface can answer with data scoped to the caller, and without `Vary` a shared/intermediate cache keys the answer on the URL alone and can hand a flushed response to the next caller regardless of credentials. `httptest.ResponseRecorder`-based tests structurally cannot catch this — it needs a real-socket, flush-before-write test. Sibling that already does it correctly: `sr-ht-ecore/mcphttp/cache.go::cacheWriter` (commit 3bd158f) fixes this with a proper Flush hook; artifacts (6c44e03) and bench (7173a3e, test `TestHeadersLandOnAFlush`) and specs (824788a) and curator carry the fix locally. Fix: replace dolt's private `cacheWriter`/`privateCache` with `mcphttp.PrivateCache` from the ecore revision dolt already pins (see the related D10 issue on adopting mcphttp generally); failing that, add a `Flush` method that calls `commit()` then `http.NewResponseController(w.ResponseWriter).Flush()`, and add a real-socket flush test, not a recorder test. Status: verified — cacheWriter has 0 Flush methods in dolt's mcpsrv package (confirmed by counting method sets across all six mcpsrv packages). Audit: D02 (cross-repo audit, 2026-08-17)
design
acceptance_criteria
notes
status open
priority 0
issue_type bug
assignee NULL
estimated_minutes NULL
created_at 2026-08-17T20:38:41Z
created_by Eugene Blikh
owner bigbes@gmail.com
updated_at 2026-08-17T20:38:41Z
closed_at NULL
closed_by_session
external_ref NULL
spec_id
compaction_level 0
compacted_at NULL
compacted_at_commit NULL
original_size NULL
sender
ephemeral 0
wisp_type
pinned 0
is_template 0
mol_type
work_type
source_system
metadata �{}
source_repo
close_reason
event_kind
actor
target
payload
await_type
await_id
timeout_ns 0
waiters
hook_bead
role_bead
agent_state
last_activity NULL
role_type
rig
due_at NULL
defer_until NULL
no_history 0
started_at NULL
is_blocked 0
events 1 row
id 01a01172-a5ee-721e-bbd2-4e4633fce58d
issue_id sr-ht-dolt-cwl
event_type created
actor Eugene Blikh
old_value
new_value
comment NULL
created_at 2026-08-17T23:38:41Z