35 lines
1.8 KiB
Python
Executable File
35 lines
1.8 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Source-only hot-cache safety guards; NOT a Rust compile, concurrency test or RPS result."""
|
|
from pathlib import Path
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
read = lambda path: (ROOT / path).read_text()
|
|
hot = read("src/cache/lookup/hot.rs")
|
|
entry = read("src/cache/model/cache.rs")
|
|
model = read("src/cache/model/maintenance.rs")
|
|
inv = read("src/cache/invalidation/invalidate.rs")
|
|
dash = read("src/cache/dashboard.rs")
|
|
assert 'headers: Arc<HeaderMap>' in entry
|
|
assert 'Arc::clone(&entry.headers)' in hot
|
|
assert 'drop(store);' in hot
|
|
assert hot.index('drop(store);\n\n let mut response') < hot.index('headers.as_ref().clone()')
|
|
assert 'self.domain_stats.saved_body_hit(&ticket.scope, &ticket.domain, body_bytes)' in hot
|
|
assert 'store.lru.remove(&old_sequence)' in hot and 'store.lru.insert(sequence, storage_key)' in hot
|
|
assert '.sweep()' not in hot
|
|
assert 'fn sweep(' not in entry
|
|
stats = read('src/cache/stats.rs')
|
|
assert 'fn saved_body_hit(' in stats
|
|
assert 'const DOMAIN_STATS_LIMIT: usize = 4096' in stats
|
|
assert 'ArcSwap<PublishedDomains>' in stats
|
|
assert 'fn record_reason(&self, reason:' in stats
|
|
assert 'self.store.lock()' not in stats
|
|
assert 'if self.ban_rule_count.load(Ordering::Acquire) == 0' in inv
|
|
assert 'bans.iter().any(|rule| rule.matches_hot' in inv
|
|
assert 'fn matching_hot_key(' in model and 'entry.vary.is_empty()' in model
|
|
assert 'self.domain_stats.clear()' in dash
|
|
assert 'self.domain_stats.record(scope, domain, outcome, reason);' in dash
|
|
assert 'include!("tests/hot_hit_034_tests.rs")' in read('src/cache/tests.rs')
|
|
for path in (ROOT / 'src').rglob('*.rs'):
|
|
if '/tests/' not in path.as_posix() and path.name != 'tests.rs':
|
|
assert len(path.read_text().splitlines()) <= 500, path
|
|
print('PASS HOT path static invariants (no Rust compilation or throughput claim)')
|