0ef5fcb1c5
Security / Dependency audit (pip-audit) (push) Has been cancelled
Security / CodeQL (javascript-typescript) (push) Has been cancelled
Security / CodeQL (python) (push) Has been cancelled
Security / Secret scan (gitleaks) (push) Has been cancelled
rust / test (ubuntu) (push) Has been cancelled
rust / simulator e2e (macos-latest) (push) Has been cancelled
rust / simulator e2e (ubuntu-latest) (push) Has been cancelled
rust / simulator e2e (windows-latest) (push) Has been cancelled
rust / wheels (aarch64-apple-darwin) (push) Has been cancelled
rust / wheels (x86_64-unknown-linux-gnu) (push) Has been cancelled
rust / wheels (x86_64-apple-darwin) (push) Has been cancelled
rust / audit (push) Has been cancelled
rust / parity (nightly, allowed to fail during Phase 0) (push) Has been cancelled
CI / commitlint (push) Has been skipped
Dev Containers / validate (.devcontainer/devcontainer.json, default) (push) Failing after 0s
Dev Containers / validate (.devcontainer/memory-stack/devcontainer.json, memory-stack) (push) Failing after 0s
Dev Containers / validate-worktree (push) Failing after 0s
CI / changes (push) Failing after 4s
Deploy Documentation / validate (push) Has been skipped
Deploy Documentation / deploy (push) Failing after 1s
Init Native E2E / init-native (ubuntu-latest, claude) (push) Failing after 1s
Init Native E2E / init-native (ubuntu-latest, codex) (push) Failing after 1s
Install Native E2E / install-native (ubuntu-latest) (push) Failing after 1s
OpenCode Plugin / typecheck + build + test (push) Failing after 1s
Init Native E2E / init-native (ubuntu-latest, copilot) (push) Failing after 1s
Release Please / release-please (push) Failing after 1s
Wrap E2E / docker-wrap-e2e (push) Failing after 1s
Wrap Native E2E / wrap-native (ubuntu-latest) (push) Failing after 1s
Init E2E / docker-init-e2e (push) Failing after 4s
Merge Conflicts / merge-conflicts (push) Failing after 4s
CI / lint (push) Has been cancelled
CI / build-wheel (push) Has been cancelled
CI / build-wheel-windows (push) Has been cancelled
CI / prefetch-model (push) Has been cancelled
CI / test-dashboard-ui (push) Has been cancelled
CI / test (1) (push) Has been cancelled
CI / test (2) (push) Has been cancelled
CI / test (3) (push) Has been cancelled
CI / test (4) (push) Has been cancelled
CI / test-extras (push) Has been cancelled
CI / test-agno (push) Has been cancelled
CI / build (push) Has been cancelled
CI / workflow-validation (push) Has been cancelled
CI / docker-native-e2e (push) Has been cancelled
CI / windows-native-wrapper (push) Has been cancelled
CI / macos-native-wrapper (push) Has been cancelled
Docker / docker-build (map[name:arm64 platform:linux/arm64 runs_on:ubuntu-24.04-arm], map[bake_target:runtime-code-nonroot name:code-nonroot]) (push) Has been cancelled
Docker / docker-build (map[name:arm64 platform:linux/arm64 runs_on:ubuntu-24.04-arm], map[bake_target:runtime-code-slim name:code-slim]) (push) Has been cancelled
Docker / docker-build (map[name:arm64 platform:linux/arm64 runs_on:ubuntu-24.04-arm], map[bake_target:runtime-code-slim-nonroot name:code-slim-nonroot]) (push) Has been cancelled
Docker / docker-build (map[name:arm64 platform:linux/arm64 runs_on:ubuntu-24.04-arm], map[bake_target:runtime-nonroot name:nonroot]) (push) Has been cancelled
Docker / docker-build (map[name:arm64 platform:linux/arm64 runs_on:ubuntu-24.04-arm], map[bake_target:runtime-slim name:slim]) (push) Has been cancelled
Docker / docker-build (map[name:arm64 platform:linux/arm64 runs_on:ubuntu-24.04-arm], map[bake_target:runtime-slim-nonroot name:slim-nonroot]) (push) Has been cancelled
Docker / docker-manifest (map[bake_target:runtime name:]) (push) Has been cancelled
Docker / docker-manifest (map[bake_target:runtime-code name:code]) (push) Has been cancelled
Docker / docker-manifest (map[bake_target:runtime-code-nonroot name:code-nonroot]) (push) Has been cancelled
Docker / docker-manifest (map[bake_target:runtime-code-slim name:code-slim]) (push) Has been cancelled
Docker / docker-manifest (map[bake_target:runtime-code-slim-nonroot name:code-slim-nonroot]) (push) Has been cancelled
Docker / docker-manifest (map[bake_target:runtime-nonroot name:nonroot]) (push) Has been cancelled
Docker / docker-manifest (map[bake_target:runtime-slim name:slim]) (push) Has been cancelled
Docker / docker-manifest (map[bake_target:runtime-slim-nonroot name:slim-nonroot]) (push) Has been cancelled
Docker / docker-build (map[name:amd64 platform:linux/amd64 runs_on:ubuntu-24.04], map[bake_target:runtime name:]) (push) Has been cancelled
Docker / docker-build (map[name:amd64 platform:linux/amd64 runs_on:ubuntu-24.04], map[bake_target:runtime-code name:code]) (push) Has been cancelled
Docker / docker-build (map[name:amd64 platform:linux/amd64 runs_on:ubuntu-24.04], map[bake_target:runtime-code-nonroot name:code-nonroot]) (push) Has been cancelled
Docker / docker-build (map[name:amd64 platform:linux/amd64 runs_on:ubuntu-24.04], map[bake_target:runtime-code-slim name:code-slim]) (push) Has been cancelled
Docker / docker-build (map[name:amd64 platform:linux/amd64 runs_on:ubuntu-24.04], map[bake_target:runtime-code-slim-nonroot name:code-slim-nonroot]) (push) Has been cancelled
Docker / docker-build (map[name:amd64 platform:linux/amd64 runs_on:ubuntu-24.04], map[bake_target:runtime-nonroot name:nonroot]) (push) Has been cancelled
Docker / docker-build (map[name:amd64 platform:linux/amd64 runs_on:ubuntu-24.04], map[bake_target:runtime-slim name:slim]) (push) Has been cancelled
Docker / docker-build (map[name:amd64 platform:linux/amd64 runs_on:ubuntu-24.04], map[bake_target:runtime-slim-nonroot name:slim-nonroot]) (push) Has been cancelled
Docker / docker-build (map[name:arm64 platform:linux/arm64 runs_on:ubuntu-24.04-arm], map[bake_target:runtime name:]) (push) Has been cancelled
Docker / docker-build (map[name:arm64 platform:linux/arm64 runs_on:ubuntu-24.04-arm], map[bake_target:runtime-code name:code]) (push) Has been cancelled
Docker / promote-latest (push) Has been cancelled
Init Native E2E / init-native (macos-latest, claude) (push) Has been cancelled
Init Native E2E / init-native (macos-latest, codex) (push) Has been cancelled
Init Native E2E / init-native (macos-latest, copilot) (push) Has been cancelled
Install Native E2E / install-native (macos-latest) (push) Has been cancelled
Wrap Native E2E / wrap-native (macos-latest) (push) Has been cancelled
86 lines
2.9 KiB
Python
86 lines
2.9 KiB
Python
"""Issue #816: Rust search/diff/log CCR markers must be retrievable.
|
|
|
|
The Rust side embeds ``MD5(original)[:24]`` in the emitted
|
|
``Retrieve more: hash=...`` marker, but since PR #395
|
|
``CompressionStore.store()`` defaults to ``SHA-256(original)[:24]``.
|
|
PR #395 fixed the SmartCrusher path by passing ``explicit_hash``
|
|
(see ``test_ccr_row_drop_store_bridge.py``); the three
|
|
``_persist_to_python_ccr`` shims on the Rust-accelerated transforms
|
|
were never migrated, so every marker they emitted dangled —
|
|
retrieval returned "Entry not found or expired" inside any TTL.
|
|
|
|
These tests pin the cross-language contract at the shim layer: the
|
|
store entry must be keyed by the exact hash the marker embeds.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import hashlib
|
|
|
|
import pytest
|
|
|
|
from headroom.cache.compression_store import (
|
|
get_compression_store,
|
|
reset_compression_store,
|
|
)
|
|
from headroom.transforms.diff_compressor import DiffCompressor
|
|
from headroom.transforms.log_compressor import LogCompressor
|
|
from headroom.transforms.search_compressor import SearchCompressor
|
|
|
|
pytest.importorskip("headroom._core", reason="Rust extension required")
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def _fresh_store():
|
|
reset_compression_store()
|
|
yield
|
|
reset_compression_store()
|
|
|
|
|
|
def _rust_marker_key(original: str) -> str:
|
|
"""The hash the Rust side embeds in emitted markers."""
|
|
return hashlib.md5(original.encode()).hexdigest()[:24]
|
|
|
|
|
|
def _assert_round_trip(original: str) -> None:
|
|
"""Entry must be retrievable under the marker's key, not SHA-256."""
|
|
marker_key = _rust_marker_key(original)
|
|
store = get_compression_store()
|
|
|
|
entry = store.retrieve(marker_key)
|
|
assert entry is not None, (
|
|
f"store has no entry under the Rust marker key {marker_key!r}; "
|
|
f"the marker dangles (issue #816)"
|
|
)
|
|
assert entry.original_content == original
|
|
|
|
sha_key = hashlib.sha256(original.encode()).hexdigest()[:24]
|
|
assert store.retrieve(sha_key) is None, (
|
|
"entry stored under the SHA-256 default key instead of the "
|
|
"marker's MD5 key — explicit_hash was not passed through"
|
|
)
|
|
|
|
|
|
def test_search_compressor_shim_stores_under_marker_key() -> None:
|
|
original = "src/app.py:12: def handle_request(payload):\n" * 40
|
|
SearchCompressor()._persist_to_python_ccr(
|
|
original, "compressed search output", _rust_marker_key(original)
|
|
)
|
|
_assert_round_trip(original)
|
|
|
|
|
|
def test_diff_compressor_shim_stores_under_marker_key() -> None:
|
|
original = "+added line of code\n-removed line of code\n" * 40
|
|
DiffCompressor()._persist_to_python_ccr(
|
|
original, "compressed diff output", _rust_marker_key(original)
|
|
)
|
|
_assert_round_trip(original)
|
|
|
|
|
|
def test_log_compressor_shim_stores_under_marker_key() -> None:
|
|
original = "2026-06-11T09:00:00Z INFO worker heartbeat ok seq=1\n" * 40
|
|
LogCompressor()._persist_to_python_ccr(
|
|
original, "compressed log output", _rust_marker_key(original)
|
|
)
|
|
_assert_round_trip(original)
|