Skip to content

fix(workbook): refresh only rows created by its own sourcing - #92

Merged
debpalash merged 1 commit into
mainfrom
fix/refresh-precise-sourced-rows
Oct 13, 2026
Merged

debpalash merged 1 commit into
mainfrom
fix/refresh-precise-sourced-rows

Conversation

@debpalash

Copy link
Copy Markdown
Owner

Follow-up to #74.

Problem

refresh.py found "newly sourced" rows by snapshotting row ids before sourcing and diffing afterward. Rows inserted concurrently by another writer (CSV import, API insert, another job) were treated as sourced, so the scheduled refresh ran all their non-output runnable columns, including paid enrichments. The #74 ADR called this out as a limitation.

Change

  • materialize_source summaries now include an additive added_row_ids key, the ids that run inserted. It covers the ICP path (source_engine), crm_import and people_search. Existing keys are unchanged. Early-error returns leave the key out, so callers use .get("added_row_ids") or [].
  • refresh.py collects added_row_ids from each source column run and uses them in place of the snapshot diff. Both row-id snapshot queries are removed.
  • ADR docs/adr/20261012-refresh-dependent-and-new-row-cells.md now marks the limitation as resolved.

Tests

  • New: test_concurrently_inserted_row_is_not_treated_as_sourced. The stubbed source inserts its own row (202) and a "concurrent" row (303), and reports only [202]. The test asserts that 202 gets every non-output runnable column, 303 and the existing row stay untouched, and nothing is dispatched. Fails on main (row 303 got formula/http/agent/research cells). Passes here.
  • The existing new-row test shares a setup helper with the new test, and its stub now returns added_row_ids.
  • CRM import tests that compare the whole summary dict now account for added_row_ids and assert it equals the inserted rows ([] on a dedup re-run).
  • Full uv run pytest -q: 2215 passed, 139 skipped, 0 failed.

🤖 Generated with Claude Code

Refresh detected "newly sourced" rows by snapshotting row ids before
sourcing and diffing afterward, so any row inserted concurrently by
another writer (CSV import, API insert, another job) was treated as
sourced and had every non-output runnable column run, including paid
enrichments.

materialize_source (ICP, crm_import and people_search paths) now
returns the ids it inserted as an additive `added_row_ids` key, and
refresh uses those instead of the snapshot diff, dropping both row-id
queries. Follow-up to #74.

Signed-off-by: debpalash <debash67@outlook.in>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@debpalash
debpalash merged commit 6f0de08 into main Oct 13, 2026
4 checks passed
@debpalash
debpalash deleted the fix/refresh-precise-sourced-rows branch October 13, 2026 04:16
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.

1 participant