Skip to content

fix(csvim): change detection spans the referenced CSV files (#6686) - #6697

Merged
delchev merged 1 commit into
masterfrom
fix/csvim-csv-change-detection
Aug 13, 2026
Merged

fix(csvim): change detection spans the referenced CSV files (#6686)#6697
delchev merged 1 commit into
masterfrom
fix/csvim-csv-change-detection

Conversation

@delchev

@delchev delchev commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Fixes #6686 — the sequel to #6676 / #6683: that one fixed the UPDATE binding so a re-import can apply a changed value; this one makes the re-import actually trigger when only a referenced .csv changes.

The defect

SynchronizationProcessor.checkAndCollect computed the definition checksum from the .csvim file's own bytes alone. The referenced CSVs were opened only inside importCsvim, well after the MODIFIED decision — so editing only a CSV left the artefact CREATED, both inner switches fell through, and nothing was imported. No error, no warning. Since the .csvim is a stable pointer that stays byte-identical when a seed value changes, the ordinary editing path could never reach the re-import.

The fix

  • Synchronizer.checksumContent(location, content) — a new default hook returning the content whose checksum decides whether the definition is MODIFIED. Default: the file's own bytes (no behavior change for any other synchronizer).
  • SynchronizationProcessor.checkAndCollect calls the hook and, when it extends the content, updates the definition checksum with the extended bytes. The definition's content (what parse receives) stays the .csvim's own bytes.
  • CsvimSynchronizer overrides the hook to append each referenced CSV's content to the .csvim bytes, so an edited CSV yields MODIFIED and the existing UPDATE path runs unchanged (which, with fix(csvim): bind the UPDATE's WHERE key at the table's column count #6683 merged, now applies values correctly). A CSV that does not exist yet contributes nothing — its later appearance changes the checksum and triggers the import, closing a second silent gap for free. A parse failure falls back to the original bytes (the definition then breaks in parse as before).

Test

CsvimReimportIT.editingOnlyTheCsvTriggersReimport drives the full synchronizer path: writes .table + .csv + .csvim registry fixtures, forces a sync, then rewrites only the CSV (the .csvim stays byte-identical — per the issue's warning, a fixture that also touches the .csvim passes while missing the bug) and asserts the row's value after the second sync.

  • Verified red on unfixed code: expected: <Varna> but was: <Sofia>
  • Green with the fix; the two pre-existing CsvimReimportIT tests stay green
  • Unit tests of the three touched modules green; formatter:validate and the release-profile javadoc check pass

Not touched (deliberately)

The switch (flow) fall-through in CsvimSynchronizer.completeImpl that the issue flags under "worth the implementer's attention" is left as-is — this fix rides the existing UPDATE/MODIFIED path and does not depend on the fall-through's behavior; changing lifecycle-transition semantics is out of scope here.

🤖 Generated with Claude Code

A .csvim artefact re-imported only when its own content changed - the
referenced CSVs were read during the import but took no part in change
detection, so editing only a CSV re-imported nothing, silently. The
.csvim is a stable pointer that stays byte-identical when a seed value
changes, so the ordinary editing path never reached the (now correct,
after #6683) UPDATE re-import.

The Synchronizer interface gains a checksumContent(location, content)
hook - by default the definition file's own bytes - which
SynchronizationProcessor.checkAndCollect uses for the definition's
checksum. CsvimSynchronizer overrides it to append each referenced
CSV's content, so an edited CSV yields MODIFIED and the existing
UPDATE path runs unchanged. A CSV that does not exist yet contributes
nothing, so its later appearance also triggers the import.

The new IT drives the full synchronizer path over registry fixtures,
edits ONLY the .csv, and asserts the row's value - verified red
without the fix (expected Varna, was Sofia) and green with it.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@delchev
delchev merged commit 515d534 into master Aug 13, 2026
10 checks passed
@delchev
delchev deleted the fix/csvim-csv-change-detection branch August 13, 2026 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

csvim: change detection ignores the referenced CSVs, so editing only a .csv re-imports nothing (silently)

1 participant