3 Commits
Author SHA1 Message Date
zsviczian d53f039ad0 fix(settings): preserve native JSON values before canonicalization 2026-10-21 18:47:31 +02:00
The.D 10d6c1f7de fix(settings): bound toJSON unwrapping with the recursion depth cap
An independent review pass flagged that a self-returning toJSON recursed
without incrementing depth, so the depth cap never engaged and the stack
overflowed. Increment depth when unwrapping; the payload now terminates
at the cap and serializes like native JSON.stringify. Regression test
added (npm run test:settings, 10 tests).
2026-10-15 11:01:46 +08:00
The.D 6b6cd06586 fix(settings): address review — queue-safe suppression, force repair, JSON semantics
Review feedback on the first revision:

1. Queued A -> B -> A could lose the final A: the unchanged-write check
   ran at request time, before preceding writes settled. The comparison
   now happens inside the serialized queue, after all earlier writes
   complete, against the cache value at execution time.
2. The suppression cache could block corruption recovery: repairing an
   invalid externally synchronized data.json with content equal to the
   cache was skipped. persistSnapshot() gained a force path used by the
   invalid-data write-back and the startup recovery choice.
3. Canonicalization now preserves native JSON.stringify value semantics:
   toJSON results are serialized instead of the source object (Date ->
   ISO string), and objects accumulate into a null-prototype map so an
   own __proto__ key stays data instead of hitting the prototype setter.
4. Added committed regression tests (npm run test:settings): key-order
   equivalence, array order, Date/toJSON, __proto__ safety, unchanged
   skip, queued A -> B -> A, failed-write retry, force repair, cache
   seeding.
5. Restored the 2.29.1 release-note line about script input suggesters
   that the previous revision dropped.

The canonical serializer moved into SerializedSettingsWriter.ts so the
node:test suite can import one module without bundler resolution.
2026-10-15 10:49:39 +08:00