fix(evidence): stabilize real Pi authoring

This commit is contained in:
2026-08-25 15:21:59 +02:00
parent 610ae8c85a
commit 8ba87b68dc
7 changed files with 486 additions and 23 deletions
+35
View File
@@ -1,4 +1,5 @@
import hashlib
import threading
import unicodedata
import pytest
@@ -348,6 +349,40 @@ def test_prepare_changed_source_uses_one_model_call_and_applies_a_valid_batch(tm
assert validate_workspace_evidence(tmp_path).publishable is True
def test_prepare_can_issue_independent_source_calls_concurrently(tmp_path):
source_text = "I pazienti sotto i 18 anni sono pediatrici."
_write_workspace(tmp_path, _evidence(source_text), source_text)
source_root = tmp_path / "evidence" / "source" / "domain"
changed_text = source_text + "\nRegola revisionata.\n"
(source_root / "patient.md").write_text(changed_text, encoding="utf-8")
(source_root / "second.md").write_text(changed_text, encoding="utf-8")
barrier = threading.Barrier(2)
class ConcurrentRestructurer:
def __init__(self):
self.requests = []
def restructure(self, request):
self.requests.append(request)
barrier.wait(timeout=2)
return (_candidate(title=f"Unit {request.source_file}"),)
restructurer = ConcurrentRestructurer()
report = prepare_workspace_evidence(
tmp_path,
restructurer=restructurer,
git_status=lambda _: (),
max_workers=2,
)
assert report.model_calls == 2
assert sorted(request.source_file for request in restructurer.requests) == [
"source/domain/patient.md",
"source/domain/second.md",
]
def test_prepare_unchanged_source_skips_model_and_does_not_write(tmp_path):
source_text = "I pazienti sotto i 18 anni sono pediatrici."
_write_workspace(tmp_path, _evidence(source_text), source_text)