1
0
Fork 0
Code Issues Pull requests Projects Releases 2 Packages Wiki Activity Actions Pages

Avoid rewriting warm extraction cache

This commit is contained in:
Andraxion 2026-07-25 20:00:21 -04:00
parent 4a8980110d
commit 9fcafc290c
2 changed files with 21 additions and 18 deletions

View file

@ -483,14 +483,7 @@ class AdapterProject:
if source.source_id in invalidated:
contribution = loader.extract_source(source)
reparsed.append(source.source_id)
else:
record = cached[source.source_id]
contribution = source_projection(record.payload)
hits.append(source.source_id)
validate_source_projection(source, contribution)
contributions.append(contribution)
cache_records.append(
CachedSource(
cache_record = CachedSource(
source_id=source.source_id,
source_path=source.source_path,
fingerprint=source.fingerprint,
@ -498,7 +491,13 @@ class AdapterProject:
dependencies=source.dependencies,
payload=source_payload(contribution),
)
)
else:
cache_record = cached[source.source_id]
contribution = source_projection(cache_record.payload)
hits.append(source.source_id)
validate_source_projection(source, contribution)
contributions.append(contribution)
cache_records.append(cache_record)
projection = AdapterProjection(
project_id=manifest.project_id,
title=manifest.title,
@ -542,15 +541,16 @@ class AdapterProject:
raise DocForgeError(
"source_changed", "Adapter sources changed during incremental extraction"
)
write_extraction_cache(
self._cache_path,
ExtractionCache(
project_id=manifest.project_id,
adapter_id=manifest.adapter_id,
adapter_version=manifest.adapter_version,
sources=tuple(cache_records),
),
)
if cache is None or invalidated or deleted:
write_extraction_cache(
self._cache_path,
ExtractionCache(
project_id=manifest.project_id,
adapter_id=manifest.adapter_id,
adapter_version=manifest.adapter_version,
sources=tuple(cache_records),
),
)
self._last_logic = logic_projections
self._last_build_report = {
"mode": "incremental",

View file

@ -303,11 +303,14 @@ class AdapterContractTests(unittest.TestCase):
self.assertEqual(2, first["build"]["reparsed_sources"])
self.assertEqual(0, first["build"]["cache_hits"])
loader.extract_calls.clear()
cache_path = root / ".cache" / "incremental" / "extractions.json"
cache_modified = cache_path.stat().st_mtime_ns
second = index.build()
self.assertEqual([], loader.extract_calls)
self.assertEqual(0, second["build"]["reparsed_sources"])
self.assertEqual(2, second["build"]["cache_hits"])
self.assertEqual(cache_modified, cache_path.stat().st_mtime_ns)
loader.sources["guide.foundation"] = "Changed foundation."
loader.extract_calls.clear()