v0.34.0_7

This commit is contained in:
Mateusz Gruszczyński committed 2026-10-18 07:48:59 +02:00
1 parent 47ce1f18c2
commit b6a3e12225
21 files changed
+471 -84

No files matched your search

+58
View File
@@ -0,0 +1,58 @@
#!/usr/bin/env python3
"""OPT5 invariants, static-only. Does not compile or benchmark Rust."""
from pathlib import Path
root = Path(__file__).resolve().parents[2]
def read(path):
return (root / path).read_text(encoding='utf-8')
assert 'version = "0.34.0"' in read('Cargo.toml')
identifier = read('src/proxy/request_id.rs')
assert 'rand::random()' in identifier
assert 'let mut token: [u8; 32]' in identifier
assert 'sequence.to_be_bytes()' in identifier
assert '*byte ^= sequence_byte;' in identifier
assert 'request_id_hex(&token)' in identifier
assert 'let mut encoded = vec![0u8; digest.len() * 2]' in identifier
assert 'Sha256::new()' not in identifier
forwarding = read('src/forwarding.rs')
assert 'self.context_with_original_url(incoming, peer, local, tls, authority, uri, true)' in forwarding
assert forwarding.count('if include_original_url {') == 2
assert 'let mut ips = chain(incoming).unwrap_or_default();' in forwarding
assert 'crate::config::request_host(authority_text)?;' in forwarding
assert 'frontend.is_some_and(|frontend| frontend.tinyauth.is_some())' in read('src/proxy/forward_entry.rs')
assert '&context.original_url' in read('src/tinyauth.rs')
lease = read('src/balance/lease_runtime.rs')
assert 'let failure_detail = is_5xx.then(|| format!("status={status}"));' in lease
assert 'let detail = failure_detail.as_deref().unwrap_or(reason);' in lease
assert 'observe_passive_with_detail(' in lease
assert 'lease.response(' in read('src/proxy/forward/upstream.rs') or 'lease.response(' in read('src/proxy/forward/success_prepare.rs')
analytics = read('src/traffic.rs')
for literal in ['mpsc::channel::<Sample>(QUEUE_CAPACITY)', 'recv_many(&mut batch, 64)',
'for sample in batch.drain(..)', 'get_mut(sample.vhost.as_str())',
'state.vhosts.len() < MAX_VHOSTS', 'try_reserve()',
'self.dropped.fetch_add(1, Ordering::Relaxed)',
'candidate.eq_ignore_ascii_case(needle.as_bytes())',
'2 => self.statuses.add("2xx", 1)', 'map(Counters::view)']:
assert literal in analytics, literal
assert 'let lower = value.to_ascii_lowercase();' not in analytics
helpers = read('src/proxy/upstream_helpers.rs')
assert 'preferred_encoding(&original_headers, global_compression).is_some()' in helpers
assert 'compression.resolve(' not in helpers
assert 'compression::encode(' in helpers
assert 'wrap_observed_request(body, &exchange' in helpers
for rel, case in [
('src/traffic/tests.rs', 'batched_worker_keeps_exact_counts_and_bounded_vhosts'),
('src/traffic/tests.rs', 'status_top_list_preserves_common_and_extension_family_names'),
('src/forwarding/tests.rs', 'original_url_is_omitted_only_when_unneeded_and_forwarding_is_identical'),
('src/compression/tests.rs', 'unaccepted_codecs_cannot_be_reenabled_by_scoped_overrides'),
('src/balance/tests.rs', 'successful_lease_response_keeps_passive_observability_and_failure_detail'),
('src/proxy/request_id/tests.rs', 'independent_sequential_ids_keep_full_length_and_unique_values'),
]:
assert case in read(rel), (rel, case)
for path in (root / 'src').rglob('*.rs'):
if path.name == 'tests.rs' or '/tests/' in path.as_posix():
continue
assert len(path.read_text(encoding='utf-8').splitlines()) <= 500, path
assert not read('src/cache/stats.rs').startswith('//!')
print('PASS OPT5 static source checks; Rust build and runtime acceptance still required')
+6 -4
View File
@@ -14,12 +14,14 @@ def source(path):
return (ROOT / path).read_text(encoding="utf-8")
# Random request identifiers retain CSPRNG entropy, SHA-256, format and sequence.
# Random request identifiers still use the OS-seeded thread-local CSPRNG,
# preserve a 256-bit unpredictable 64-hex token and mix the per-process sequence.
# OPT5 removes the extra SHA-256 operation, not the entropy or correlation ID.
identifier = source("src/proxy/request_id.rs")
assert "rand::random()" in identifier
assert "hash.update(sequence.to_be_bytes());" in identifier
assert "hash.update(nonce);" in identifier
assert "request_id_hex(&hash.finalize())" in identifier
assert "sequence.to_be_bytes()" in identifier
assert "*byte ^= sequence_byte;" in identifier
assert "request_id_hex(&token)" in identifier
assert "SysRng.try_fill_bytes" not in identifier
# Compiled/validated target authority survives request URI construction.