Skip to content

Commit e35b564

Browse files
fix(clone): honour skip strategy in _clone_verified_data at runtime
_plan_children already forecasts verified-data as skipped under file_strategy=skip, but the runtime path lacked the matching guard: on a re-run where documents reached the target by other means, it would create verified rows the plan said it would skip. Add the early-return guard, mirroring _clone_documents. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011ja9H1rnSXmPUgQtHm8TNS
1 parent 22e9d93 commit e35b564

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

src/unstract/clone/phases/agentic_studio.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,17 @@ def _clone_verified_data(
559559
if not src_rows:
560560
return
561561

562+
# Verified data FKs a document; under 'skip' no documents are copied,
563+
# so skip the rows too — matching the plan and _clone_documents.
564+
if self.ctx.options.file_strategy == "skip":
565+
with lock:
566+
result.skipped += len(src_rows)
567+
result.warnings.append(
568+
f"agentic {name}: {len(src_rows)} verified-data row(s) not "
569+
"copied (file_strategy=skip)"
570+
)
571+
return
572+
562573
# Verified data FKs a document; map source rows to target docs by
563574
# filename, the only identity stable across orgs.
564575
try:

tests/clone/test_agentic_studio_phase.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,29 @@ def test_documents_not_copied_under_file_strategy_skip():
676676
assert result.skipped == 1
677677

678678

679+
def test_verified_data_not_copied_under_skip_even_if_doc_on_target():
680+
# Docs reached the target by other means (prior non-skip run / manual
681+
# upload), so doc-by-name maps. Under skip, verified data must still be
682+
# skipped at runtime — matching the plan, not created off the stray doc.
683+
src = FakeClient(
684+
projects=[_src_project("src-p", "Receipts")],
685+
documents={"src-p": [{"id": "d1", "original_filename": "report.pdf"}]},
686+
document_blobs={"d1": b"%PDF-r"},
687+
verified_data={
688+
"src-p": [{"document_name": "report.pdf", "document": "d1", "data": {}}]
689+
},
690+
)
691+
tgt = FakeClient()
692+
tgt.projects.append({"id": "tgt-proj-0001", "name": "Receipts"})
693+
tgt.documents["tgt-proj-0001"] = [{"id": "t-d1", "original_filename": "report.pdf"}]
694+
ctx = _ctx(src, tgt, file_strategy="skip")
695+
696+
result = AgenticStudioPhase(ctx).run(CloneReport())
697+
698+
assert tgt.created_verified_data == []
699+
assert any("verified-data" in w for w in result.warnings)
700+
701+
679702
def test_dry_run_skip_strategy_counts_docs_and_verified_as_skipped():
680703
# Verified data FKs a document; under skip no docs land on target, so the
681704
# plan must forecast verified as skipped too — not as un-creatable creates.

0 commit comments

Comments
 (0)