fix(journal): re-publish only changed declarations

topoSortAffected followed declared dependencies even when they were not in the affected set, so reevaluateDependents re-evaluated and re-published variables that had not changed. This could also overwrite a value just set via /set with the declaration's own expression.
This commit is contained in:
hyper
2026-09-12 23:44:06 +08:00
parent f17f09a8c4
commit 3532be2335
3 changed files with 28 additions and 4 deletions
+5 -3
View File
@@ -109,14 +109,16 @@ The items below are still open.
(#1) for declarations/modifiers and through `dispatchError` for `/set` and
`/roll`.
### 7. `topoSortAffected` re-evaluates untouched declarations — low
### 7. `topoSortAffected` re-evaluates untouched declarations — ✅ fixed
- **Where:** in `var-reactivity.ts`, the visit condition
`affected.has(dep) || declExprs.has(dep)` pulls declared dependencies that are
not in `affected` into the result.
- **Symptom:** `reevaluateDependents` re-evaluates and re-publishes variables
that did not change. Mostly harmless, but noisy.
- **Fix:** only visit/topologically order keys in `affected`.
that did not change. Mostly harmless, but noisy — and a re-evaluated
declaration could overwrite a value that had just been `/set`.
- **Fixed:** the visit condition now only follows dependencies in `affected`,
so a cascade re-evaluates exactly the changed variable's dependents.
### 8. Failed `initReactivity` leaves partial state — ✅ fixed