Repository navigation
Memory reads and approval hashes preserve complete JSON objects - #2224
yorkhellen wants to merge 2 commits into
Conversation
Read persisted object text before native JSON rendering so omitted members remain part of verification and approval. Preserve refusal matches against both persisted representations during upgrade and rollback. Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com>
…view-baseline Signed-off-by: zhangxiaoyu.york <zhangxiaoyu.york@bytedance.com> # Conflicts: # tests/analyzer/shapes.txt
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
zlareb1
left a comment
There was a problem hiding this comment.
An unchanged object must keep a usable verification and proposal approval token while N-1 and N serve together.
| # Object text preserves null and empty members. Imports may keep their object only | ||
| # in value_json beside a scalar value. | ||
| SERVED_VALUE = ( | ||
| "if(isValidJSON(loom.memory.value) AND startsWith(trimLeft(loom.memory.value), '{'), " |
There was a problem hiding this comment.
P1 — This projection changes the content hash for existing objects with null or empty members. A read on either build can return a token that the other build rejects for the same unchanged row. The compatibility notes reproduce the mismatch with the untouched previous build. Keep the token usable across the rollout and add a two-build test against that untouched baseline.
zlareb1
left a comment
There was a problem hiding this comment.
The dependency review fails because its missing-snapshot fallback includes Rust files that changed on main. Replaying the same failure without this PR reproduces it on the tested base and current main. The existing repair passes the replay against this PR’s tested merge. Failed job · Repair #2053
zlareb1
left a comment
There was a problem hiding this comment.
The worklist order test reproduces the same reversed results on the clean CI base with no changes from this PR. Both rows can receive the same whole-second timestamp, so the tie breaks on the key. The fixture in #2235 gives the first row an explicit earlier timestamp. The same test passed three times on current main. Failed job · Merged fix
Related: #2064
Related: #2063
Part of issue #2063: this repairs the persisted-object read and hash behavior. The MCP response shaping work remains in #2064; merging this prerequisite does not close the issue.
Remaining review requirement
The cross-build token requirement remains unresolved. Real HTTP requests against unchanged main
d65505001and this exact head confirm that an unchanged object can produce a token the other receiver rejects. The successful prototype probe uses a repaired baseline and does not satisfy this requirement. A change confined to the new receiver cannot change the untouched receiver's projection-hash comparison. Accepting the projection hash would not bind an attestation to omitted members.Changelog category
Changelog entry
Memory reads preserve null and empty object members from persisted JSON object text. Verification and proposal approval compare the hash of that complete value.
Why
Native JSON rendering omits null and empty object members. A caller can read
{"keep":1}for stored{"keep":1,"omitted":null,"nested":{}}, while another replica verifies the complete object. This makes unchanged content fail verification or proposal approval across replicas.Object text is authoritative when present. Native-only objects beside scalar import values remain readable. The version projection selects the qualified stored text column so the served-value alias cannot replace the bytes a version write carries.
Scope and risk
Three production files change: the memory SQL projection, the shared persisted-value decoder and refusal policy capture/admission. Regression tests cover point, ID and bulk reads, Verify/revoke, omitted-member edits, proposal approval, native-only imported content, stored byte preservation and snapshot refusal across the read upgrade. The generated SQL corpus changes with the projection.
Refusal hashes can name either persisted representation. Capture records both when their canonical hashes differ, and admission inspects both, preserving matches against existing projection-based policies and through rollback. This comparison distinguishes integers, booleans and floats even when Python considers their decoded objects equal.
Reading and parsing complete object text adds work proportional to its length; this change makes no performance claim. No migration or content rewrite is required.
Compatibility, rollout and rollback
This is a prerequisite for #2064, not completion of its remaining review threads. The dependent PR still needs the complete-content token rule and durable bidirectional gate cases against the repaired baseline. Public documentation will be updated after the repair is released.
Tests
LOOM_ENV_FILE= make format lint typecheckpasses, and the SQL corpus is regenerated on that baseline.d65505001and exact head7646bac888execute 24 cross-build Verify/revoke requests for one unchanged object, covering point, by-ID and bulk reads and either writer. Twenty return HTTP 409 without changing the row version; four old-bulk reads provide the full hash that the new receiver accepts. Four new-receiver full-hash controls succeed.Reproduce the affected units with:
Against a private server and ClickHouse, reproduce the integration scope with:
AI assistance in the code
AI-generated (TRAE): an agent wrote the production change and regression tests; validation runs and independent review are recorded separately. Human review is pending.
I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist