Skip to content

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

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

yorkhellen wants to merge 47 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 checks complete previews directly and reads full content for selected attested truncated rows at their exact version and writer identity. Returned values remain capped. High-sensitivity placeholders and missing full content cannot confirm an attestation. The full-value batch has fixed 32 MiB result and 256 MiB ClickHouse memory ceilings plus caller-shaped work limits; exhaustion returns a validation error asking for a smaller list limit, not a false stale badge. Recency previews cap hydrated values without decoding JSON-looking strings again. 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. 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

Head 2800d41 adds repair 415286c and a signed-off merge of main 2cb2a43. The independent list review confirmed that a reconnect or replica retry hitting a result cap returned an internal error. Caller-cap classification runs at the shared retry-ladder exit, so both list sorts return HTTP 422 or MCP isError with VALIDATION_FAILED and smaller-limit guidance on initial and retried attempts. Shared server/user memory exhaustion remains a retryable 503.

Persistent regressions first fail 18 cases with four initial-attempt controls passing. The two complete regression files pass 69 tests after the repair. The complete merged CH, list, transport, SDK/skill, CLI and documentation contract batch passes 1061 tests without failures or skips. Format, lint, types and all generator checks pass. Generated Go/Rust merge conflicts are regenerated from merged sources. These checks run on the prepared merged source tree before its commit; this batch starts no live server and does not rerun the earlier live integration or dashboard suites. Fresh independent review approves this fixing delta with no new findings. Its completed head batches pass 654, 254 and 66 tests, followed by a 135-test randomized repeat; these are test executions with overlap. Reversing only the classifier relocation independently reproduces 18 failures and four passing controls. All 11 affected generator checks pass. Private probes execute the real query/reconnect ladder and verify shared-memory refusals, cancellation and both-sort HTTP/MCP semantics. This does not establish whole-PR approval, live or mixed-build behavior, or hosted Actions success. The 17 current-head Actions workflows require approval; cross-build P1 remains unresolved.

Pushed head 7dbf946 contains the truncated-list attestation fix and one signed-off merge of main 0d9cb85. Gates run on that prepared merged source tree before its commit: 4920 backend tests across 116 files, 34 skips and 320 passing subtests; 106 tests across the five complete live files listed below; 12 analyzer tests; 2455 corpus shapes, 2451 checked, four intentionally unchecked, none rejected and one existing drive error. Format, lint, types and all generator checks pass. The full merged dashboard passes 4128 tests across 339 files under Node 22 with the English locale; build and bundle budget pass.

Four large-string/object live cases first return stale after successful set/verify in both sorts. The repair confirms unchanged full content without expanding the response; edits beyond the preview remain stale. Durable tests cover projected hashes, missing/raced versions, page limits, exact identities, high withholding and omitted verification. A real two-row batch exceeds a forced 4096-byte result ceiling with ClickHouse code 396; each smaller one-row batch succeeds. The exact server exception is ValidationError. Real ASGI tests verify HTTP 422 and MCP isError with VALIDATION_FAILED and smaller-limit guidance. Fixed ceilings bound full-result materialization, not exact process RSS; canonical decode can amplify one value. Query-log fixture maxima across 26 successful lookups are 73 read rows, 22333 read bytes, 7368105 ClickHouse memory bytes and 10 ms. These small-fixture measurements are not a production performance claim. Postgres runtime and a transaction-wide authority snapshot remain unverified.

The following results retain their earlier-head provenance.

Pushed head 533ee34 contains repair 8eb1f9e, signed-off merge fffe171 of main cdb93e8 and the generated corpus commit. Its merged source-tree verification passes 4808 backend tests across 112 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. Unit gates run while preparing the merge; live tests run on fffe171 with the regenerated corpus present. The final commit only records that corpus, with no further production changes. Format, lint, type checks and all generator checks pass. Generated merge conflicts are regenerated from merged sources.

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, test_assigned_source_ch.py and merged-main test_code_plane.py pass 101 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/listing budget, docs, code.review_brief, code-lead and assigned-source contract batch passes 937 tests with one skip. The analyzer passes 12 tests. The regenerated corpus has 2447 shapes, 2443 checked, four intentionally unchecked and none rejected; its existing unfiltered recall drive error remains reported.

The full dashboard suite at 63bd8e7 passes 4128 tests across 339 files under verified Node 22 with the en-US locale. Build and bundle budget pass. Frontend files are unchanged from that head through 533ee34; this is not a new dashboard run at the final head. Backend evidence at 63bd8e7 is 4712 tests across 110 files, 31 skips and 320 subtests; its four-file live batch passes 45 tests and its contract batch passes 672 with one skip. Earlier fa50499 evidence is 4575 backend tests across 107 files, 43 live tests and 824 contract tests with one skip.

The earlier supplied dashboard evidence at d90ef4e remains 4126 tests in 339 files; it is separate provenance. Its backend evidence 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

High Risk
Changes memory hashing, attestation, proposal approval, and cross-version write semantics—areas where a mismatch could allow stale approvals or broken rolling upgrades.

Overview
Introduces canonical_content_sha256 on memory reads for attestation, definition share/promote approval, and memory.verify preconditions, while content_sha256 stays the cross-build conditional-write token (native JSON projection when present). memory.history gains an optional memory_id filter so the admin UI loads the complete proposed value and approval hash via identity-scoped history, not a lossy id lookup alone.

Memory and related API surfaces mark values/metadata with opaque Payload typing so HTTP/MCP shaping and idempotency replay keep null, empty objects, and other caller content intact. The dashboard disables Verify and definition Share when no full hash is returned; tests cover proposal refusal paths and projected-vs-full hash behavior.

CI runs mixed-version checks in a matrix of pinned bases; mixed_version.py adds gates for idempotency receipts, content preconditions, full attestations, proposal review, and shared-embedding stub repair. Dependency review can prove generated Rust fixtures unchanged via commit tree walks when compare API alone is insufficient. SDKs, ops registry, and architecture docs are updated to match.

Reviewed by Cursor Bugbot for commit 7dbf946. 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 11:35am UTC
loom-telemetry Ready Ready Preview Dec 5, 2026 11:35am 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>
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.

@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.

Comment thread server/transport/http.py Resolved
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
…user-payload

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

# Conflicts:
#	sdk/go/wire/models.gen.go

@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 Share button refuses rows whose server omitted a full hash, and HTTP preserves the previous build's replay receipt. The mixed-version verification thread still applies when a dashboard read and its follow-up verification reach different builds. The list has a separate attestation regression below. GitHub confirms a conflict with main.

Comment thread server/memory/app/query.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.

The latest commit refreshes the code lead statement shapes. The list attestation failure and mixed-version verification failure still apply to the unchanged memory code. GitHub confirms a conflict with main, and Actions lists no runs for this head.

Read selected page versions within result and query ceilings while retaining capped previews. Merge the current upstream baseline and regenerate its wire and SQL contracts.

Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>
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.

Both list sorts now match the attestation against the full value of the exact visible revision. The cross-build verification and proposal approval findings still apply.

with (
caller_shaped("a smaller memory.list limit"),
statement_ceilings(
max_result_bytes=_LIST_FULL_RESULT_BYTES,

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 — A single verified value can exceed this 32 MiB result cap, so memory.list fails even at limit=1. For example, a JSON object with a string of three million supplementary Unicode characters fits in a 12 MB UTF-8 request. The write path stores over 36 MB after escaping the string. Keep the preview available when one value exceeds the attestation budget, and test the single-row case alongside multirow overflow.

@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 Postgres restore drills refuse because the shared test deployment retains source-worker history. The same drills fail on clean main with the same refusal, and the storage jobs pass after the fixture cleanup in #2279. PR job · Clean main job · Merged fix

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