Repository navigation
fix(trajectory): track nested edits and safe diagnostic lineage - #85
Merged
Merged
Conversation
Collaborator
Author
Code reviewPR 能修好嵌套原地编辑和"文本相同导致继承别人诊断信息"这两个问题,但引入了几个性能和健壮性问题。下面按严重程度列出,均位于 性能
诊断信息归属
健壮性
设计
修复已推送到本分支,见下一条提交:
|
- Compare the spool prefix by reference on routine snapshots. Detect nested in-place edits by digesting redacted rendered lines, only after a compactor run, a context-compacted/compaction notice, or on forced snapshots, so raw history and inline base64 are no longer serialized on every flush. - Key response metadata by message id instead of scanning a list per turn. - Replace content fingerprints with copy lineage: a replacement inherits diagnostics only when it shares content objects with exactly one vanished assistant, so equal text never transfers another turn's details and in-place edits before a copy no longer drop them. - Keep unencodable messages (cycles, non-string keys) in the snapshot with a trace_error instead of failing every later flush. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #84 fixing stale trajectory snapshots and incorrect diagnostic attribution after history rewrites.
Routine snapshots reuse the spool prefix by reference. A compactor run, context-compacted/compaction notice, or forced completion/cancellation snapshot also compares redacted rendered lines to detect nested in-place edits. This avoids serializing raw history and hashing inline image base64 on every flush. Unannounced nested edits by arbitrary observers are reflected at the next deep check or final snapshot; replacing a message or top-level field is detected during routine snapshots.
Store diagnostic entries in a dictionary keyed by message identity. Preserve direct identity bindings first; transfer diagnostics to a replacement only when it shares mutable content/tool-call containers or blocks with exactly one vanished assistant and no other replacement claims that source. Scalar identities, including cached single-character JSON strings and reasoning strings, are excluded. Deduplicate sources using
id(entry)dictionaries without comparing message contents, so cyclic metadata cannot cause recursive comparisons before rendering.Ambiguous, deep-copied and scalar-only copied assistants retain their message content without guessed JSON annotations; original diagnostics remain available in JSONL when enabled. Unique mutable shallow-copy lineage and real signed-thinking resets retain diagnostics. Unencodable host metadata degrades to a message with
trace_errorrather than freezing all later snapshots. Snapshot work remains synchronous but coalesced; observer failures are logged and isolated by the loop.Regression coverage includes nested text/argument/image-metadata/usage edits, copied and resumed histories, compactor/rollback deep-check scheduling, unregistered replacement replies, cached scalar strings, cyclic metadata during source deduplication, and JSONL diagnostic preservation. Documentation and the independent release fragment describe the final behavior.
Validation:
uv build: source distribution and wheel built.