-
Notifications
You must be signed in to change notification settings - Fork 0
fix: use deep merge for update operations to preserve statics #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d2b11c8
fix: handle nested range→non-range transitions correctly
adnaan 90827e8
fix: use deep merge for update operations to preserve statics
adnaan 900d977
fix: use stdout for uncaughtException to maintain JSON protocol
adnaan 8ef8f3c
fix: address PR review comments
adnaan 04edb69
fix: address review comments
adnaan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| #!/usr/bin/env node | ||
| /** | ||
| * Persistent Oracle Server for Go fuzz testing framework. | ||
| * | ||
| * Unlike cross-validate.ts which handles a single request and exits, | ||
| * this server stays alive and handles multiple requests via line-delimited JSON. | ||
| * | ||
| * Protocol: | ||
| * - Each line of stdin is a JSON request: {"oldTree": ..., "diff": ...} | ||
| * - Each request gets a JSON response on stdout: {"html": ..., "tree": ..., "error": ...} | ||
| * - Server exits when stdin closes | ||
| * | ||
| * This reduces per-request overhead from ~300ms (process spawn) to ~20-50ms (IPC only). | ||
| */ | ||
|
|
||
| const readline = require("readline"); | ||
| const { TreeRenderer } = require("./dist/state/tree-renderer"); | ||
| const { createLogger } = require("./dist/utils/logger"); | ||
|
|
||
| // Create a silent logger to avoid console output | ||
| const logger = createLogger({ level: "error" }); | ||
|
|
||
| // Create readline interface for line-by-line processing | ||
| const rl = readline.createInterface({ | ||
| input: process.stdin, | ||
| output: process.stdout, | ||
| terminal: false, | ||
| }); | ||
|
|
||
| // Process each line as a separate request | ||
| rl.on("line", (line) => { | ||
| try { | ||
| const data = JSON.parse(line); | ||
|
|
||
| // Create a fresh renderer for each request to avoid state leakage | ||
| const renderer = new TreeRenderer(logger); | ||
|
|
||
| // Apply the old tree first (initial state) | ||
| if (data.oldTree) { | ||
| renderer.applyUpdate(data.oldTree); | ||
| } | ||
|
|
||
| // Apply the diff | ||
| const result = renderer.applyUpdate(data.diff); | ||
|
|
||
| // Get the current tree state from renderer | ||
| const finalTree = renderer.getTreeState(); | ||
|
|
||
| const output = { | ||
| html: result.html, | ||
| tree: finalTree, | ||
| error: null, | ||
| }; | ||
|
|
||
| // Write response as single line | ||
| console.log(JSON.stringify(output)); | ||
| } catch (err) { | ||
| const output = { | ||
| html: "", | ||
| tree: null, | ||
| error: err instanceof Error ? err.message : String(err), | ||
| }; | ||
| console.log(JSON.stringify(output)); | ||
| } | ||
| }); | ||
|
|
||
| // Handle stdin close | ||
| rl.on("close", () => { | ||
| process.exit(0); | ||
| }); | ||
|
|
||
| // Handle errors gracefully - use stdout to maintain JSON protocol | ||
| // Exit after uncaught exception as process state may be corrupted | ||
| process.on("uncaughtException", (err) => { | ||
| console.log(JSON.stringify({ html: "", tree: null, error: err.message })); | ||
| rl.close(); | ||
| process.exit(1); | ||
| }); |
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests validate the
shouldFullReplacelogic for range-to-non-range transitions, but they don't test the actual bug described in the PR summary. The PR describes a bug where UPDATE operations (the "u" differential operation) on range items lose statics when using shallow spread instead of deep merge. These tests should include a scenario that uses differential operations like["u", "item-key", {"5": {"0": "new text"}}]to verify that statics are preserved when updating a nested field within a range item. Without this, the core fix inapplyDifferentialOpsToRangeandapplyDifferentialOpsToRangeMap(lines 353-361 and 676-682 in state/tree-renderer.ts) remains untested.