Skip to content

Preserve stored JSON in memory reads and MCP replies - #2064

Open
yorkhellen wants to merge 42 commits into
ClickHouse:mainfrom
yorkhellen:fix/mcp-user-payload
Open

yorkhellen wants to merge 42 commits into
ClickHouse:mainfrom
yorkhellen:fix/mcp-user-payload

Conversation

@yorkhellen

@yorkhellen yorkhellen commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Closes: #2063
Related: #2224

Merge dependency and remaining review work

Prerequisite: #2224. Merge #2224 first, then synchronize this branch with main and complete the dependent changes before merging #2064. This is a merge dependency; no separate release or deployment is required between the two merges.

The prerequisite makes memory reads and approval hashes use complete persisted JSON objects, including null and empty-object members. It also keeps snapshot refusal policies effective across that read upgrade and rollback. An untouched preceding build reads the native projection and cannot verify the complete-content token. Accepting its projected token would miss changes confined to omitted members.

This split separates the shared read and hash repair from the dependent changes in this PR. The reviewers require successful cross-build Verify/revoke and proposal approval; they did not prescribe a separate PR. After #2224 merges, its code supplies the baseline for the dependent implementation and tests.

This PR still needs to use the same complete-content token rule and commit bidirectional mixed-version gate cases against that repaired baseline. Untouched-baseline Verify/revoke and proposal approval remain unresolved; the scalar-null repair does not complete those cross-build requirements. Review requirements Verify/revoke and proposal approval remain open. Creating or merging the prerequisite does not complete them.

Local two-server probes pass ten scenarios with the repaired baseline and a prototype dependent build: Verify/revoke, omitted-member stale-token rejection, proposal approval and snapshot refusal in both directions. That prototype includes changes beyond this PR's current pushed head; those results do not establish compatibility of the current head or of an untouched preceding verifier. The scope and tests below describe the current pushed implementation.

Changelog category

Bug Fix

Changelog entry

Memory reads retain stored null and empty-object members. HTTP and MCP replies preserve caller payloads through response shaping and idempotency replay. Conditional-write read tokens remain valid across rolling builds.

Why

The native JSON projection omits members present in stored text. Recursive response shaping also removes diagnostic-named keys and meaningful empty values inside caller content. Read stored text and mark opaque payload boundaries so returned content matches written content.

Conditional writes keep the native-projection token both rolling builds accept. Stored content and approval attestations use the full canonical hash. Using a projected token for proposal approval would accept changes to omitted members that the reviewer never saw.

Scope and risk

  • Memory projections retain stored value text and native value_json for conditional-write tokens. Point lookups, bulk lookups and report citations use the same token input. The SQL analyzer corpus is regenerated.
  • Mark memory values, record content, conflict values, schemas, procedure fields, learnings, profile overrides, task brief/outcome, run metadata, knowledge metadata and conversation metadata as opaque.
  • Apply task payload boundaries to projected task.list dictionaries while retaining their wire schema and selected columns.
  • Preserve typed dictionary keys and marked payloads through diagnostic trimming, integer conversion and epoch cleanup, including annotated union containers.
  • Cache the first full HTTP-normalized receipt with its request feedback so preceding HTTP readers keep ignored_args. Record handler-owned names in the existing cached response headers. Current readers restore those names and attach the retry's feedback; preceding unmarked HTTP receipts cannot distinguish first-request names from handler names and retain both. MCP receipts retain string encoding for large server version IDs.
  • Conditional set, update, update_by_id and move accept the read token or the full hash returned by writes. Definition and proposal approval require the complete canonical content hash.
  • Point, by-ID and bulk reads compare the attestation with the full returned value. List compares against a complete stored preview before applying the caller's preview cap. Recency previews cap hydrated values without decoding JSON-looking strings again. Stored truncated previews and high-sensitivity placeholders cannot confirm an attestation. A full attestation stays confirmed when the stored content column holds a projected digest; a projected attestation does not verify omitted members. Present stored scalar null uses the canonical JSON null hash. Missing or raw-empty content has no canonical hash and cannot be verified or revoked; decoded populated content remains available even without raw text. Missing previews remain unconfirmed, and legacy projected null read tokens remain empty.
  • The dashboard resolves a proposal's identity with memory.get_by_id, then reads its complete value and approval hash from memory.history scoped to that identity and memory_id. Identity scoping also works when the preceding build ignores the id filter.
  • Local mixed-version runs default to the merge base of HEAD and origin/main; explicit --base and CI's pinned bases remain unchanged.
  • The dependency review accepts modifications of the exact generated Rust wire and registry-contract fixture files when complete committed trees prove both remain regular files and cannot be reached through a repository alias. Other snapshot inputs and advisory checks still refuse incomplete scans.
  • The mixed-version gate checks review through either build, another identity's newer tombstone, omitted-member replacement refusal and fresh full-content attestation. Its event-view leg excludes that old build's hashless stub from hashed-copy repair while retaining the event assertions and the new build's repair proof.

Replies can be larger because meaningful caller content remains present. Conditional-write read tokens retain the native projection's limitation: changes confined to omitted members cannot be distinguished. A full write hash retains that limit when it equals the current projection token. Stored content and attestation hashes cover the complete value. Authorization, reviewer independence and tenant scoping remain enforced.

Compatibility, rollout and rollback

  • memory.history accepts an optional memory_id filter before the version limit. memory.get, memory.get_by_id and the rows in memory.bulk_get add canonical_content_sha256, computed from the full returned value. memory.verify.if_match_sha256 takes that full hash; the dashboard disables verification and definition Share before confirmation when a server does not supply it. No operations are added or removed.
  • Caller payloads retain JSON types, empty values and epoch-like strings. MCP server version fields retain their string conversion.
  • Read content_sha256 tokens hash the native JSON projection when populated, else stored text, matching the preceding build. Conditional writes across builds use the token from a read. The preceding build can reject a full write hash when its projection differs.
  • Proposal clients send the full canonical hash from memory.history as approved_sha256. Either build can supply the complete reviewed value. The untouched preceding build refuses a full hash when its native JSON projection omits members; the dependent fix remains required on this head. Sending the projected hash would let an omitted-member replacement pass review.
  • Default MCP shaping omits empty server fields, including normalized null timestamps; HTTP and explain=true retain those null fields.
  • New writers store full normalized cache entries so a preceding HTTP reader returns null timestamps consistently. The cache retains diagnostic fields for retries with explain=true.
  • Verification and revocation of unchanged JSON with omitted native-projection members still return 409 across the two builds. The full hash guard remains enforced. The preceding dashboard cannot supply a full digest, and the preceding verifier cannot accept it; this head has not yet completed the required cross-build fix.
  • Merge dependency: Memory reads and approval hashes preserve complete JSON objects #2224 must merge first. Synchronize this branch with main, complete the full-content token rule and bidirectional gate, then merge Preserve stored JSON in memory reads and MCP replies #2064 after its checks and review pass. No separate release or deployment is required between the two merges.
  • Operator steps: no migration, backfill or new setting.
  • Rollback restores the preceding response transformations and approval limitation; no stored memory data needs cleanup.
  • Public documentation will be updated after the next release. Architecture pages describe the token and rollout limits in this change.

Tests

At 63bd8e7, after repair 8eb1f9e and the signed-off merge of main 2c66869, the complete affected backend union passes 4712 tests across 110 files, with 31 skips and 320 passing subtests. This includes every file in the prior 98-file batch, the recency regressions and merged-main affected tests. Format, lint, type checks and all generator checks pass. Generated Go and Rust merge conflicts are regenerated from merged sources; the SQL corpus has no tracked drift.

The recency SQL-row and HTTP/MCP result-shaping regression first fails in 16 cases with 56 passing controls. Valid string writes through the live HTTP boundary first fail in nine cases with eight passing neighbors. Both sort orders preserve the values and types of JSON-looking strings, empty strings, null, booleans, numbers and containers; recency truncation distinguishes strings from containers. Raw-empty or missing content first fails two unit cases and one live case; decoded native content with empty raw text is a passing control. Unguarded verification first fails two cases with two passing guarded controls, then refuses unavailable content before any version write.

The full persistent files test_read_verify_full_hash.py, test_memory_delete_list.py, test_memory_verify.py and the merged-main test_assigned_source_ch.py pass 45 tests without skips. The memory files cover legal set inputs, both list sorts, stored values and hashes, full-hash verification, scalar-null verify/revoke and repeat no-ops, replacement refusal and raw-empty refusal. Scalar-null cases seed a valid value and write serialized null through the real version-row and head-write helpers; no null set input is introduced. In-process HTTP tests and MCP result shaping preserve literal values; this is not a full MCP transport session. Cut and high previews remain unconfirmed. Legacy projected null tokens, not-found and unchanged defaults, omitted-high hashes and empty-attestation rejection remain unchanged.

The final package, transport, wire/SDK, read-hash, schema, MCP shaping, docs, code.review_brief and assigned-source contract batch passes 672 tests with one skip. The earlier broader contract batch at fa50499 passes 824 tests with one skip, including MCP budgets. The analyzer passes 12 tests at the final head. The corpus has 2447 shapes, 2443 checked, four intentionally unchecked and none rejected; its existing unfiltered recall drive error remains reported.

Merged main changes frontend sources, so the full dashboard suite is rerun at 63bd8e7: 4128 tests pass across 339 files under verified Node 22 with the en-US locale. Build and bundle budget pass. The earlier supplied dashboard evidence at d90ef4e remains 4126 tests in 339 files; it is separate provenance. The prior backend evidence at that head is 4254 tests across 98 files, 30 skips and 320 passing subtests. Its null-specific regression first fails in 24 cases with 24 passing controls, then the focused files pass 119 tests and the full persistent read/verify file passes nine.

Earlier results have separate provenance: the affected backend run after the 3575e78 gate correction passed 4152 tests and 320 subtests with 30 skips; live verification at the resolved 5910d05 tree passed 63 tests across seven complete integration files. The earlier dashboard run passed 4099 tests in 338 files. These earlier results do not establish behavior of the scalar-null repair.

The complete affected backend run exposes two connected-source fixture failures that also reproduce on clean main when the registration module is imported before the fixture. The fixture explicitly supplies its ClickHouse fake to that module's imported getter; it keeps the fleet check and access-rule assertions intact.

The mixed-version receipt gate seeds a pinned row and uses the same memory.unpin request across builds. It requires HTTP 200, the replay header, an identical receipt and an unchanged row version in both directions; HTTP 409 fails the test.

Independent review of 5910d05 identifies a missing reverse direction in that committed receipt gate. Commit 3575e78 adds both writer/reader pairs with separate keys. Ten cases first fail on the preceding gate, then pass; either reader's conflict, missing replay confirmation, feedback change or version change fails the gate. The complete gate and cross-transport unit files pass 74 tests. Fresh independent review of 5910d05..3575e78 finds no defects in that gate correction, independently passes all 34 gate unit tests and ten direction-specific fault probes. This verdict covers the gate correction only.

Two real servers exercise all four HTTP/MCP pairings in both directions. All 24 replays preserve the stored version; all eight same-field retries retain the receipt feedback. Changed/clean argument retries return stale first-request names in 12 cases: eight when the receiver is the preceding build and four when the preceding HTTP receipt has no ownership marker. The preceding MCP writer's six retries through current readers report current feedback. The probe's zero exit checks replay identity and version, not complete feedback correctness; it is not a fully passing mixed-version feedback result.

Full mixed-version Verify/revoke and proposal approval still require #2224 to merge and the dependent implementation and durable gate to be completed. Public attestation and definition-approval guides remain in the post-release documentation draft. These limits remain open review work.

Hosted CI, the complete mixed-version matrix, full backend coverage, package matrix and browser end-to-end checks remain required. Local results do not establish hosted CI success or whole-PR approval.

AI assistance in the code

AI-generated (TRAE). The agent wrote the fix and regression tests and ran the checks listed above. Human review is pending.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • Local format, lint, type checks and focused tests pass.
  • Applicable generators run without drift.
  • Repair commits are signed off.
  • Synchronize with current main and rerun focused checks.
  • Hosted CI passes.
  • Fresh independent fixing-delta review completes on the current pushed head.

Note

Medium Risk
Changes content-hash semantics for verify, promotion, and proposal approval and expands rolling-upgrade gates; mistakes could allow wrong content to be attested or accepted across build pairs.

Overview
Memory reads now expose both content_sha256 (native JSON projection token for conditional writes across N/N−1) and canonical_content_sha256 (full stored value). memory.verify, definition promote/share, and proposal approved_sha256 must use the canonical hash so attestations and human review cannot be satisfied with a projection that hides null or empty-object changes.

memory.history gains an optional memory_id filter; the admin proposals flow loads identity via memory.get_by_id (omit_high_value) then fetches the complete proposed revision and approval hash from scoped history. The memory inspector disables verify/share when the server omits the full hash.

API models mark caller-owned JSON (Payload) so HTTP/MCP shaping does not strip meaningful empty fields or diagnostic keys. History rows hash the parsed full value; move/update preconditions accept either the read token or the full write hash. SDKs, ops registry, and docs are regenerated/updated accordingly.

CI runs mixed-version as a matrix (previous commit, event-views pin, legacy shared-copy pin), extends mixed_version.py with receipt replay, content-precondition, attestation, proposal-review, and shared-stub repair cases, and tightens dependency-review snapshot checks with Git tree proofs for generated Rust fixtures.

Reviewed by Cursor Bugbot for commit 63bd8e7. Bugbot is set up for automated code reviews on this repo. Configure here.

Stop response shaping at declared payload fields so diagnostic names and
empty values in stored content survive reads and idempotent replays.
Read stored JSON text because native JSON rendering omits null and empty
object members.

Add regression tests for payload boundaries, replay consistency and
stored-value roundtrips through HTTP and MCP.

Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>
Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>
@vercel

vercel Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
loom-docs Ready Ready Preview Dec 5, 2026 10:26am UTC
loom-telemetry Ready Ready Preview Dec 5, 2026 10:26am UTC

Request Review

Task list rows keep their dictionary contract while response shaping uses the task model's payload boundaries.

Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>
@zlareb1 zlareb1 self-assigned this Dec 3, 2026

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stored text now supplies the memory value and its served hash. The MCP response models preserve marked payloads through normal replies and idempotency replays, while server diagnostics still trim. The added tests cover both reply channels, projected task rows, and a tags-only memory update.

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unit part 3 fails on the old memory projection assertion.

Comment thread server/memory/store/sql.py Resolved
Check the raw value projection and its version-write alias, and keep byte and hash round trips for hydrated rows.

Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The projection test checks the stored value, the version-write alias and the separate native JSON projection. The round-trip tests check the stored bytes and hash. The focused memory and MCP suite passes (113 tests).

Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new response-shaping branches put server/operations/ below its CI coverage floor. Coverage job

Comment thread server/operations/payloads.py Resolved
Mark profile schemas, structured profiles, procedure metadata and learning
candidates as payloads so MCP encoding keeps their stored JSON values.
Cache the full handler result and encode each replay for its destination
transport and toolset.

Cover payload reads, cross-transport replay, audit rows and authenticated
assistant calls with regression tests. Assistant probes use the real
operation input models so accepted arguments reach the handler.

Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new replay cache format needs to work with a replica running the previous build. Coverage from the previous head is recorded in the existing thread. The new head needs its own CI result.

Comment thread server/transport/mcp_outcome.py Resolved
Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>
Store large server integers as decimal strings in full MCP replay answers.
Older readers replay the cache without bigint encoding; storing numbers
loses precision when a JavaScript client parses the response.

Keep HTTP integer restoration and opaque payload values intact. Cover
the preceding reader's replay conversion at the safe integer boundary
and with large positive and negative versions.

Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The MCP cache preserves large version IDs for older MCP replicas. HTTP replay still exposes the raw zero date when a newer replica writes the cache and an older replica answers the retry.

Comment thread server/transport/http.py Resolved
Store the full result after epoch cleanup so an older HTTP replica replays the same timestamp. Keep payload boundaries through annotated containers and cover both reply channels and previous-build readers.

Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>
An epoch string in a preceding writer's cache must produce the same default and explained reply as a fresh result.

Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>
@yorkhellen

Copy link
Copy Markdown
Contributor Author

@zlareb1 The requested fixes are pushed at cf32bc2, with details in the original threads:

  • c549aeb stores large server version IDs as strings for previous MCP readers.
  • ab20db2 covers plain Annotated and union container selection through both rendered MCP channels. payloads.py branch coverage is 100%; combined server/operations/ coverage is 96.36% against the unchanged 96% floor.
  • ab20db2 stores HTTP-normalized full cache entries. cf32bc2 normalizes preceding cache entries before MCP lean shaping, so retries match fresh replies while preserving caller payloads.

The final focused suite passes 236 tests with one environment skip. Format, lint, type and generator checks pass. Fresh independent review of the full diff found no code defects; hosted Actions still need maintainer approval. Please recheck this head.

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conditional writes can fail during a rolling upgrade even when the memory revision has not changed. Cover both directions of the read and write across builds.

Comment thread server/memory/store/sql.py Resolved

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pinned Biome rejects the same assertion in Chat.test.tsx on the PR merge and clean main. The check passes with the formatting repair. PR job · Main job · Repair #2107

Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>
Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The read token now agrees across builds for the original fixture. Proposal approval can still attest content the reviewer did not see. The shared embedding repair finding also still applies because the repair compares the shared projection with the full source value.

Comment thread server/memory/app/proposals.py Resolved
Projection tokens omit null and empty-object members and can approve a replacement the reviewer has not read. Read the complete proposal revision and hash through memory.history, and reject projection tokens during approval.

Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>
Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread frontend/src/views/admin/Proposals.tsx Resolved

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Proposal approval now compares the full stored hash. The shared embedding repair still refuses an N-1 promotion whose native projection omitted fields. The bulk read and namespace report also return different hashes from point reads of the same row.

Comment thread server/memory/app/query.py Resolved
Comment thread server/memory/store/reads.py Resolved
Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scoping history by the proposal’s identity fixes the tombstone case. The event-view leg keeps its assertions and runs hashed-stub repair on the new build. The approval path across builds still needs a rollout path. The new mixed-version test expects the preceding server to reject the canonical hash for a proposal with null members. Keep that hash check and give clients a supported way to complete or safely defer the approval while both builds serve.

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The isolation test cannot build the worker approval and enrollment requests on this run or on its clean base. The merged fix supplies those request fields and keeps the refusal assertion. PR job · Base job · Fix #2156

Read receipts record stored content separately from read precondition tokens. Proposal review uses identity-scoped history while retaining address navigation, rejection reasons and retries.

Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>
The generated contracts include run.reliance and the proposal history revision filter. Run metadata retains its opaque payload marker, and read receipts retain their full-content hash binding.

Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The combined wire models retain the full-value hash binding. The proposal approval thread remains open. The rollout guide requires calls to reach an upgraded server, but the dashboard still sends them through its ordinary endpoint.

Comment thread scripts/gates/mixed_version.py Resolved
Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>
Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread server/memory/app/get_output.py Resolved
Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verification can fail across builds or display a full value as verified when only its projection was attested. Definition approval and MCP replay have separate regressions. The existing proposal acceptance finding still applies on the preceding build.

const r = await verifyMemory(rowIdentity(identity, detail), memoryKey, {
revoke: live,
ifMatchSha256: detail.content_sha256,
ifMatchSha256: detail.canonical_content_sha256,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 — Verification and revocation of unchanged JSON can return 409 during a rolling deploy. For a value with a null member, this dashboard sends the full digest and the preceding replica compares it with the native projection's digest. The preceding dashboard can send the projected digest to a current replica and get the same failure. Preserve full-content verification in the rollout path and exercise both directions in the mixed-version gate.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zlareb1 Cross-build Verify/revoke remains unresolved. The untouched preceding verifier derives a different hash when its native JSON projection omits members and returns 409 for the complete-content token. Accepting the projected token would attest to content that the reviewer did not see; the full-hash guard remains enforced.

The dependency is merge-only: merge #2224 first, synchronize this branch with main, then complete the dependent full-content token rule and bidirectional gate before merging #2064. No separate release or deployment is required between those merges. The prerequisite and prototype probes do not establish compatibility of the untouched preceding verifier.

ec562d1, pushed at d90ef4e, repairs canonical hashing of present stored scalar null on this build. Its read/verify/revoke tests pass against private ClickHouse, but that result does not complete the requested mixed-version fix.

Comment thread server/memory/app/get_output.py Outdated
verified_at=row.verified_at,
verification=_trust.verification_state(row.verified_by, row.verified_sha256, sha),
verification=_trust.verification_state(
row.verified_by, row.verified_sha256, _trust.row_content_sha256(row)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 — A preceding replica can verify the projected JSON and store its digest in both hash columns while retaining the full value. This read returns the full value and marks it verified because the stored projected digests agree. Compare the attestation to the full served value here and in the by-ID path. Cover an old-replica verification followed by current point and bulk reads.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zlareb1 Fixed in 670aad7: point, by-ID and bulk reads derive verification from the full served value. Matching projected stored digests no longer mark omitted members as verified.

Unit and persistent ClickHouse regressions cover full and projected attestations. The mixed-build gate checks the preceding verifier's attestation against a fixture retaining the full stored bytes; that build can also rewrite the raw column through its projection alias, so this fixture isolates the attestation state. The real two-build probe passes these read cases. This does not fix the separate cross-build verify/revoke 409.

Comment thread server/memory/app/promote.py Outdated
current = served_content_sha256(src.value)
if current != approved_sha256:
current = served_sha256(src)
if approved_sha256 not in (current, served_content_sha256(src.value)):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 — An edit to a member omitted by the native JSON projection can leave the projected digest unchanged. A definition approval with that digest then publishes full JSON that differs from the version the caller approved. Bind the approval to the full published value and test an intervening edit to an omitted member.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zlareb1 Fixed in 670aad7: definition promotion accepts only the full canonical hash. The dashboard sends canonical_content_sha256, and the SDK comments, MCP instructions and generated reference name that field.

The persistent regression rejects a projected approval and an old full approval after an omitted member changes, writes no shared row for either refusal, then publishes the complete replacement after a fresh full approval. The two-build probe checks full history review and projected approval refusal. The merged head's 88 integration tests pass (13 skipped).

elapsed_ms=elapsed_ms,
response_body=result_dict,
response_body=recorded_body,
cache_body=recorded_body,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 — This caches the first request's argument feedback. A memory.set with an extra field zzzz, retried with the same idempotency key and an extra field qqqq, returns both names on either transport even though the retry only sent qqqq. Store the handler's result and attach transport-generated argument feedback to the request that receives it. Cover replay through HTTP and MCP.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zlareb1 Fixed in 670aad7: both transports cache the handler result before adding the current request's argument feedback. Replays attach only the receiving request's unknown arguments and retain handler-owned ignored_args. HTTP replay also supplies the receiving request's ignored-args header.

Regressions exercise HTTP→HTTP, HTTP→MCP, MCP→HTTP and MCP→MCP with zzzz, then qqqq, then no unknown argument. They assert one handler execution and retain the original version. Both unit and persistent ClickHouse tests pass on merged head 49388f2.

…e current request

Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>
Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>

# Conflicts:
#	sdk/go/wire/models.gen.go
#	sdk/rust/src/wire_models.rs

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

why("memory.verify") ||
(!detail?.canonical_content_sha256
? "This server did not supply a full content hash. Verification is unavailable."
: null);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verification fails across mixed replicas

High Severity

Verification and revocation now send only canonical_content_sha256. During a rolling deploy, that full digest does not match a preceding replica's native-projection token, and a preceding client still sends the projection token to a current replica. For JSON with null or empty-object members, both directions return 409 even though the stored value is unchanged. full_attestation_reads only verifies each build with the hash that same build already accepts.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 49388f2. Configure here.

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current head fixes the point, by-ID, and bulk attestation reads, the definition hash check, and replay feedback between current replicas.

memory.list still reports human for the projected digest in the new persisted fixture because server/memory/app/query.py:405 trusts the stored digest. The same row returns stale from memory.get. Derive the list result from the content it serves, and extend the fixture to cover the list. The attestation guide and the definition approval guide also still instruct callers to use content_sha256. For a value whose projection omits a member, both requests can return 409 on the current server. Update both examples to use canonical_content_sha256.

The verify and revoke and proposal approval rollout findings still apply.

try {
// A definition's promotion names the text it approves: the one shown.
const approved = detail.memory_type === "definition" ? detail.content_sha256 : undefined;
const approved = detail.memory_type === "definition" ? detail.canonical_content_sha256 : undefined;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 — Read an active namespace-wide definition from the preceding server with this dashboard. The row qualifies for Share, but the response has no canonical_content_sha256, so this sends no approval hash and both builds refuse it. This also affects definitions whose projection preserves every field. Read a full-value hash through a path both builds serve or make Share unavailable before confirmation. Cover the preceding-server read in a dashboard test.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zlareb1 Fixed in a4a11df, pushed at 5910d05. Definition Share is disabled before confirmation when the read lacks canonical_content_sha256; the action handler also refuses that case. The dashboard regression feeds serialized preceding-server reads for both omitted-member and lossless objects, asserts no confirmation or promotion request, and checks that a supplied full hash reaches approved_sha256 unchanged. The complete dashboard suite passes 4099 tests in 338 files after synchronization with main.

Comment thread server/transport/http.py
input_obj=payload,
elapsed_ms=elapsed_ms,
response_body=response_body,
cache_body=cache_body,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 — Send an HTTP write with an unknown non-typo field to this build, then retry the same request and idempotency key on the preceding build. The first reply names the field in ignored_args. The preceding HTTP replay returns the cached body unchanged, so this cache write drops the receipt on retry. Preserve the receipt across builds while keeping request-specific feedback on current replies, and add this direction to the mixed-version test.

@yorkhellen yorkhellen Dec 5, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zlareb1 The receipt repair is in a4a11df; 3575e78 completes its durable reverse-direction gate. The cache keeps the first normalized receipt, including ignored_args, for preceding HTTP readers. Cached response headers record handler-owned names so current HTTP/MCP readers can preserve them and attach the retry's feedback. Unmarked preceding HTTP receipts retain their names because their ownership cannot be recovered.

The mixed-version regression seeds memory.pin, writes memory.unpin with an unknown field, then replays it through the other build. Both directions require HTTP 200, X-Idempotent-Replay: true, an identical receipt and an unchanged stored version; a 409 fails the case.

Independent review found that the committed gate covered only the first direction. The correction runs both pairs and adds ten cases that first fail on the preceding gate. Either reader's 409, missing replay flag, changed feedback or changed version fails its case. The two complete gate/transport files pass 74 tests; the complete affected backend files pass 4152 tests and 320 subtests, with 30 existing skips.

Two real servers pass all eight same-field receipt checks and preserve the stored version in all 24 replays. Changed/clean retries retain first-request names in 12 cases: eight on preceding readers and four from unmarked preceding HTTP receipts on current readers. Those limitations remain explicit in the PR body; the complete hosted mixed-version matrix is not verified.

Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>
The source registration module binds its ClickHouse getter at import. Its unit world must patch that getter even when another test imports the module first.

Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>
@yorkhellen

yorkhellen commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor Author

@zlareb1 The memory.list correction is in a4a11df, pushed at 5910d05. List derives verification from the complete stored preview before the caller's preview cap is applied. A projected attestation is stale, a full attestation remains human, and stored truncated previews or high-sensitivity placeholders cannot confirm an attestation. The persisted read-to-verify fixture includes list alongside point and bulk reads and passes all seven cases against a private server and ClickHouse. The complete affected backend unit files pass 4146 tests and 320 subtests, with 30 existing skips; seven complete integration files pass 63 tests without skips.

The attestation and definition-approval guide corrections to canonical_content_sha256 are saved in the post-release documentation draft, following the requested publication order. The public guides are not corrected on this head. The #2224 merge dependency and the remaining cross-build Verify/revoke and proposal-approval requirements remain explicit in the PR body.

@cursor cursor Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

Comment thread server/memory/app/query.py Resolved
Each build must preserve the other build\u0027s first receipt. Exercise reverse-only conflicts, missing replay confirmation, feedback changes and version changes.

Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>
Complete nullable values hash as canonical JSON. Missing, truncated and high-sensitivity previews still cannot confirm attestations; projected read tokens retain their existing null convention.

Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>
Regenerate Go and Rust wire files from the merged operation models. Connect and disconnect the private ClickHouse test client for persisted scalar-null coverage.

Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>
Regenerate SDK wire files and the analyzer corpus from the merged namespace models.

Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

Reviewed by Cursor Bugbot for commit d90ef4e. Configure here.

Comment thread server/memory/app/get_output.py Resolved
Recency previews cap decoded values without parsing strings again. Canonical hashes distinguish stored null from unavailable content, and verification refuses rows without complete content.

Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>
Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>

# Conflicts:
#	sdk/go/wire/models.gen.go
Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>

# Conflicts:
#	sdk/go/wire/models.gen.go
#	sdk/rust/src/wire_models.rs

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Memory reads and MCP replies omit members of stored JSON

2 participants