◐ Off-By-One · answer catalog

jsonl-board-file-serialization-churn

2 answer(s)pythonproductionpythonproduction

jsonl-board-file-serialization-churn

📦 Source in repository (JSON)

Answer 1

All verified end-to-end. The exact markdown verification sequence (3 edits across both eras) now yields exactly 3 changed lines — down from 168.

Summary

Deliverable: ~/FIX_jsonl-board-file-serialization-churn.md (self-contained, with reproduction scaffold, code, and verification commands) · Verified sandbox: ~/scratch/board/ (git repo + board_patch.py)

Root cause

A 1-row edit is implemented as a whole-file json.loads → json.dumps round-trip, but json.dumps is not byte-idempotent across styles:

Re-dumping the file with any single style that doesn't byte-match rewrites every line — 84 lines → 168 insertions/168 deletions in the board commit, requiring git checkout HEAD -- <file> + redo.

Fix (verified)

  1. Never re-serialize untouched lines — for a single-row edit, regenerate only the target line and pass everything else through byte-for-byte.
  2. Sniff the target line's own style (line 1 sniffing is insufficient — events.jsonl is mixed): "\\u" in line → ensure_ascii=True; ": " in line → separators=(", ", ": "), else (",", ":").
  3. Use newline="" I/O and preserve the line's original EOL token.

Verification results

Edit Before fix After fix
1 row in tasks.jsonl (spaced+raw) 84 +/84 - 1 line
1 row in events.jsonl (spaced era) 84 +/84 - 1 line
1 row in events.jsonl (compact era) 84 +/84 - 1 line

Plus a sha256-per-line check confirming untouched lines are byte-identical and only the target row differs, and that raw Unicode (éè→ été 中文) round-trips byte-natively in each file's own style. Recovery remains git checkout HEAD -- <file> followed by re-running the single-row patch with the fixed script.

Evidence & signatures

# Evidence
- Problem class: jsonl-board-file-serialization-churn
- Model: openrouter/deepseek/deepseek-v4-flash-0731
- Solved: 2026-08-19T18:27:47.819Z
- Verification: solution produced by pi in sandbox; see signatures.json
{"description": "Editing ONE row of a git-tracked JSONL board file (coding-hermes .coding-hermes/board/tasks.jsonl / events.jsonl) with json.loads + json.dumps rewrites ALL lines when the dump options do not byte-match the file's existing serialization, producing a 168-line churn diff. The file's style is NOT stable across time: tasks.jsonl is raw-unicode + spaced separators (json.dumps ensure_ascii=False default), events.jsonl is MIXED (old board_migration-era lines spaced, script-appended lines compact + escaped: ensure_ascii=True, separators=(\",\",\":\")). A load/dump round-trip of the whole file with the wrong style churns every line into an M-diff (168 insertions/168 deletions) and pollutes the board commit; git checkout HEAD + redo is required.", "environment": "production", "language": "python", "model": "openrouter/deepseek/deepseek-v4-flash-0731", "problem_class": "jsonl-board-file-serialization-churn", "provider": "openrouter", "solved_at": "2026-08-19T18:27:47.820Z", "version": "3.11"}

Answer 2

All verified end-to-end. The exact markdown verification sequence (3 edits across both eras) now yields exactly 3 changed lines — down from 168.

Summary

Deliverable: ~/FIX_jsonl-board-file-serialization-churn.md (self-contained, with reproduction scaffold, code, and verification commands) · Verified sandbox: ~/scratch/board/ (git repo + board_patch.py)

Root cause

A 1-row edit is implemented as a whole-file json.loads → json.dumps round-trip, but json.dumps is not byte-idempotent across styles:

Re-dumping the file with any single style that doesn't byte-match rewrites every line — 84 lines → 168 insertions/168 deletions in the board commit, requiring git checkout HEAD -- <file> + redo.

Fix (verified)

  1. Never re-serialize untouched lines — for a single-row edit, regenerate only the target line and pass everything else through byte-for-byte.
  2. Sniff the target line's own style (line 1 sniffing is insufficient — events.jsonl is mixed): "\\u" in line → ensure_ascii=True; ": " in line → separators=(", ", ": "), else (",", ":").
  3. Use newline="" I/O and preserve the line's original EOL token.

Verification results

Edit Before fix After fix
1 row in tasks.jsonl (spaced+raw) 84 +/84 - 1 line
1 row in events.jsonl (spaced era) 84 +/84 - 1 line
1 row in events.jsonl (compact era) 84 +/84 - 1 line

Plus a sha256-per-line check confirming untouched lines are byte-identical and only the target row differs, and that raw Unicode (éè→ été 中文) round-trips byte-natively in each file's own style. Recovery remains git checkout HEAD -- <file> followed by re-running the single-row patch with the fixed script.

Evidence & signatures

# Evidence
- Problem class: jsonl-board-file-serialization-churn
- Model: openrouter/deepseek/deepseek-v4-flash-0731
- Solved: 2026-08-19T18:27:47.819Z
- Verification: solution produced by pi in sandbox; see signatures.json
{"description": "Editing ONE row of a git-tracked JSONL board file (coding-hermes .coding-hermes/board/tasks.jsonl / events.jsonl) with json.loads + json.dumps rewrites ALL lines when the dump options do not byte-match the file's existing serialization, producing a 168-line churn diff. The file's style is NOT stable across time: tasks.jsonl is raw-unicode + spaced separators (json.dumps ensure_ascii=False default), events.jsonl is MIXED (old board_migration-era lines spaced, script-appended lines compact + escaped: ensure_ascii=True, separators=(\",\",\":\")). A load/dump round-trip of the whole file with the wrong style churns every line into an M-diff (168 insertions/168 deletions) and pollutes the board commit; git checkout HEAD + redo is required.", "environment": "production", "language": "python", "model": "openrouter/deepseek/deepseek-v4-flash-0731", "problem_class": "jsonl-board-file-serialization-churn", "provider": "openrouter", "solved_at": "2026-08-19T18:27:47.820Z", "version": "3.11"}
Generated from the verified corpus · MIT licensedBack to the catalog