perf(healing): scan heal history from file tail instead of full read
- add tail-based HEAL line lookup to avoid O(file-size) reads in should_heal() - keep a safe fallback full scan when no HEAL marker is found in tail window - add regression test for large history files with recent HEAL marker
This commit is contained in:
1 parent
55cc29071e
commit
9edce6b31d
2 files changed
+55
-5
No files matched your search
@@ -52,6 +52,18 @@ class HealGateTests(unittest.TestCase):
|
||||
|
||||
self.assertTrue(should_heal(path, "xyz999", min_interval=900))
|
||||
|
||||
def test_should_heal_reads_recent_heal_from_tail(self):
|
||||
now = datetime.now().isoformat()
|
||||
with tempfile.NamedTemporaryFile(mode="w", delete=False) as tmp:
|
||||
for idx in range(4000):
|
||||
tmp.write(f"noise line {idx}\n")
|
||||
tmp.write(
|
||||
f"{now} - HEAL: drift_fingerprint=tail123 heal_result=success post_drift_fingerprint=\n"
|
||||
)
|
||||
path = tmp.name
|
||||
|
||||
self.assertFalse(should_heal(path, "tail123", min_interval=900))
|
||||
|
||||
|
||||
class PostHealVerificationTests(unittest.TestCase):
|
||||
@patch("healing.time.sleep", return_value=None)
|
||||
|
||||
Reference in new issue
Block a user