Repository navigation
Preserve stored JSON in memory reads and MCP replies - #2064
yorkhellen wants to merge 28 commits into
Conversation
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
Unit part 3 fails on the old memory projection assertion.
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
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
The new response-shaping branches put server/operations/ below its CI coverage floor. Coverage job
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
left a comment
There was a problem hiding this comment.
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.
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
left a comment
There was a problem hiding this comment.
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.
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>
|
@zlareb1 The requested fixes are pushed at cf32bc2, with details in the original threads:
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
left a comment
There was a problem hiding this comment.
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.
zlareb1
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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.
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>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 8f86f55. Configure here.
zlareb1
left a comment
There was a problem hiding this comment.
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.
Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>
A newer tombstone from another identity can hide a pending proposal in key-wide history. Filter both history reads by the proposal ID so the dashboard reviews the complete value and hash from the selected revision. Cover identity collisions, tenant and read scopes, target changes, missing history and the dashboard request. Regenerate the optional SDK field and the SQL analyzer corpus. Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>
The bulk projection omits native JSON and citation reads hash stored text, so an unchanged object containing null or empty members gets a different token from memory.get. Select the native projection and use the shared token input while keeping complete values in responses. Cover actual SELECT columns, authority heads, citation disclosure limits and conditional writes through HTTP and across rolling builds. Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>
zlareb1
left a comment
There was a problem hiding this comment.
Bulk reads and report citations now agree with the point-read token. The shared embedding repair still compares the preceding build’s projected promotion with the current build’s full source value. A promotion of a value with an omitted null member can still leave an embedding stub that repair rejects. Existing finding
zlareb1
left a comment
There was a problem hiding this comment.
GitHub reports a merge conflict with main in sdk/go/wire/models.gen.go. Please reconcile the Go wire models from the combined registry.
Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>
Match the saved copy against the complete source or its recorded native projection. Carry the original source and candidate heads through the provider call, then bind publication to the saved copy's hash. Verification requires a current attestation of the complete value and an identical copy. Serialize promotion, repair and demotion across models with a target lease. Lock missing candidate scopes on Postgres, retain uncertain sends and keep the retry stub when a cross-model fill is withheld. Cover worker interleavings, cleanup cancellation and retries, Postgres authority checks and an actual preceding-build promotion in the mixed gate. Saved lineage cannot reveal historical edits confined to omitted fields. Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>
Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>
Keep legacy projection recovery required on its pinned build and preserve full-copy compatibility for other bases. Answer the shared-vector version read in the retirement fixture. Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>
zlareb1
left a comment
There was a problem hiding this comment.
Proposal review can fail when the dashboard and server are on different builds during a rolling upgrade.
| setReview({ proposal }); | ||
| try { | ||
| const row = await getMemoryById(identity.org, proposal.memory_id); | ||
| const { rows } = await memoryHistory({ ...scope, agent: "*" }, proposal.memory_key, 1, proposal.memory_id); |
There was a problem hiding this comment.
P1 — An older server ignores the new memory_id filter. With a newer tombstone for another identity sharing this key, limit 1 returns the tombstone and the dashboard makes the pending proposal unavailable. Approval can also reach an older server that compares the new full-value digest against its normalized value, rejecting valid JSON with explicit nulls. Preserve review across both build combinations and cover them in the rolling-upgrade test.
There was a problem hiding this comment.
@zlareb1 Fixed the history lookup in 32c1ce9b7: the dashboard resolves the proposal's identity by id, then scopes history by agent, user and session before the one-row limit. The regression covers a preceding server ignoring memory_id, more than 500 newer rows from other identities, and another user's newer tombstone.
Full JSON acceptance must still reach an upgraded replica. The unchanged preceding server compares against its lossy native projection; sending that projected hash would allow an omitted-member replacement to pass review. The full hash remains required, and the architecture page and PR body state this rollout boundary.
All three complete mixed-version legs passed before the final main merge, including full text/JSON review through either reader, omitted-member replacement refusal, and fresh full-content attestation. After the merge, 523 backend tests and 22 dashboard approval tests passed; the complete matrix was not repeated on the final head. Hosted Actions still require approval.
zlareb1
left a comment
There was a problem hiding this comment.
The tunable constant test flags the worker approval bigint bound on the clean CI base and this merge. The same test passes with the existing bound fix. The mixed-version failure is separate. Failed job · Bound fix #2138.
Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>
Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>
Resolve the proposal identity before reading history so preceding builds cannot select another identity’s newer revision. Keep full-content approval binding and cover omitted-member replacements across builds. The event-view base writes hashless stubs outside the hashed-copy repair proof. Retain its event checks and the new build’s hashed repair, and remove temporary container volumes on exit. Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>
zlareb1
left a comment
There was a problem hiding this comment.
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.
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
left a comment
There was a problem hiding this comment.
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.
| ap.add_argument( | ||
| "--base", default="", help="the N-1 revision (default: merge base with origin/main)" | ||
| "--base", | ||
| default="HEAD~1", |
There was a problem hiding this comment.
P2 — Plain make test-mixed-version now compares a branch with its own previous commit. On a two-commit branch, a compatibility break in the first commit is present on both sides and the gate can miss it. Keep the documented merge-base default for local runs. CI already passes its tested base explicitly.

Closes: #2063
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
valuetext and nativevalue_jsonfor conditional-write tokens. Point lookups, bulk lookups and report citations use the same token input. The SQL analyzer corpus is regenerated.task.listdictionaries while retaining their wire schema and selected columns.memory.get_by_id, then reads its complete value and approval hash frommemory.historyscoped to that identity andmemory_id. Identity scoping also works when the preceding build ignores the id filter.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.historyaccepts an optionalmemory_idfilter before the version limit. No operations are added or removed.content_sha256tokens 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.memory.historyasapproved_sha256. Either build can supply the complete reviewed value. Acceptance requests must reach an upgraded replica: the preceding build refuses a full hash when its native JSON projection omits members. Sending the projected hash would let an omitted-member replacement pass review.explain=trueretain those null fields.explain=true.Tests
The latest review repair was tested before the final main synchronization:
After the final main synchronization, 523 focused backend tests and 22 dashboard approval tests pass. Format, lint, type checks, every generator check, the dashboard build and its bundle budget pass. The three complete mixed-version legs above were run before that final merge; they have not been repeated afterward.
Fresh independent review of
32c1ce9b7approves the eight-file fixing delta and the inspected main-merge effects, with no verified P0–P3 findings. It independently passes 138 backend tests, 25 frontend tests, Go generation and reach-census checks. This is not a full-PR or merge-ready approval; final-head runtime behavior was not independently rerun.The full backend unit and browser end-to-end suites were not rerun for this fixing pass. The new head's 17 hosted workflows report
action_required, with no CI jobs executed. Hosted CI and human re-review remain pending.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.
Checklist
Note
High Risk
Changes conditional-write semantics, proposal approval hashing, shared promotion admission, and HTTP response shaping across memory and transport—areas that affect data integrity and rolling upgrades.
Overview
Memory reads and writes now distinguish a rolling-upgrade read precondition token from full canonical content hashes. Reads return stored JSON (including null/empty-object members);
content_sha256on gets hashes the native JSON projection when present so N and N−1 agree forif_match_sha256, while history, attestations, and write responses use the complete value hash. Conditional set/update/move/promote accept either token.HTTP/MCP responses preserve caller-owned JSON by marking memory values, metadata, and similar fields as opaque
Payloads and reshaping only non-payload fields (integers, diagnostics). Idempotency replay applies per-request ignored-arg feedback to cached full bodies.Proposal review in the dashboard resolves identity via
memory.get_by_id, then loads the full proposed revision and approval hash frommemory.historyscoped with optional newmemory_id(also in SDKs). Accept/reject uses the history hash so omitted-projection tokens cannot approve unseen changes.Shared promotion/repair adds per-target leases, stricter saved-copy vs source checks, and embedding-worker proofs so stub recovery embeds the saved excerpt without altering the canonical copy or borrowing attestation.
CI mixed-version gate runs as a three-scenario matrix (previous commit, event-views build, lossy-promotion build) with new cross-build checks for content preconditions, proposal approval, and shared embedding repair.
Reviewed by Cursor Bugbot for commit 8162036. Bugbot is set up for automated code reviews on this repo. Configure here.