fix(discovery): preserve uncached fallback for unverifiable projects
This commit is contained in:
1 parent
260e270be8
commit
4194c011e3
2 files changed
+25
No files matched your search
@@ -109,6 +109,10 @@ class DiscoveryCache:
|
||||
and (not collect_components or has_components)):
|
||||
self._entries[key] = entry
|
||||
return deepcopy(discovery)
|
||||
# Fingerprinting is an optimization: an initially unverifiable
|
||||
# project still gets fresh native discovery, with no cache reuse.
|
||||
if before is None:
|
||||
return loader()
|
||||
# Native first-open may normalize an old database. Discard that
|
||||
# discovery and reopen once; only a verified stable pass is usable.
|
||||
for attempt in range(2):
|
||||
|
||||
@@ -307,3 +307,24 @@ def test_unstable_rediscovery_never_falls_back_to_cached_negative_matches(tmp_pa
|
||||
preparer._discover_project_sheets = stable
|
||||
assert preparer.discover_project(project, ('old',)).matched_old_parts[('MAIN', '1')] == frozenset({'old'})
|
||||
assert len(calls) == 4
|
||||
|
||||
|
||||
def test_initially_unverifiable_project_uses_fresh_discovery_without_cache(tmp_path):
|
||||
project, preparer, calls = prepared(tmp_path)
|
||||
# A project within the explicit evidence root has no reusable fingerprint.
|
||||
clone = preparer.for_data_root(project.parent)
|
||||
clone._discover_project_sheets = preparer._discover_project_sheets
|
||||
assert clone.discover_project(project, ('old',)).sheets == (('MAIN', '1'),)
|
||||
assert len(calls) == 1
|
||||
assert clone.discover_project(project, ('old',)).sheets == (('MAIN', '1'),)
|
||||
assert len(calls) == 2
|
||||
|
||||
|
||||
def test_unverifiable_retry_after_known_churn_still_fails_closed(tmp_path, monkeypatch):
|
||||
from dx_productivity.trial_task_center import discovery_cache as module
|
||||
project, preparer, calls = prepared(tmp_path)
|
||||
fingerprints = iter([('before',), ('changed',), None, None])
|
||||
monkeypatch.setattr(module, 'project_fingerprint', lambda *args: next(fingerprints))
|
||||
with pytest.raises(TaskCenterError, match='changed'):
|
||||
preparer.discover_project(project, ('old',))
|
||||
assert len(calls) == 2
|
||||
Reference in new issue
Block a user