feat(hrr): ephemeral-path auto-disable for HRR persistence (#695) - #701
Conversation
There was a problem hiding this comment.
Sorry @robotrocketscience, you have reached your weekly rate limit of 2500000 diff characters.
Please try again later or upgrade to continue using Sourcery
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
PR-size soft capThis PR is over the advisory size threshold:
Bigger PRs collide with more open work, which under the parallel-session workflow tends to produce repeated This is advisory only — nothing is blocked. If the size is intentional (large refactor, module removal, generated code), apply the |
|
[claim:review:Pascal:2026-05-12T00:03:50Z] |
|
Review verdict (Pascal): BLOCK — Linux CI regression on pre-existing tests. The ephemeral-path auto-disable logic is correct, but the new
Root cause: `tmp_path` on Linux resolves to `/tmp/pytest-of-runner/pytest-N/...` which matches the new `/tmp/` prefix → persistence auto-disabled → these tests fail because no `struct.npy` is ever written. On macOS `/tmp` is a symlink so `tmp_path.resolve()` → `/private/tmp/...` and the literal `/tmp/` prefix never matches → tests pass locally. The macOS quirk you correctly noted for your new tests bites the existing tests in reverse on Linux. Discretion grep clean, 2 atomic signed commits look right, your 8 new tests pass on macOS. Just need to set `AELFRICE_HRR_PERSIST=1` in the 4 affected #693 tests (or migrate them to a non-tmp_path fixture path) so they exercise the persistence code path regardless of platform. CI evidence: https://github.com/robotrocketscience/aelfrice/actions/runs/25704599892/job/75471873893 — `4 failed, 3609 passed, 53 skipped, 75 xfailed in 62.50s`. Releasing claim — back to author for the fix. |
|
[release:review:Pascal:2026-05-12T00:05:07Z] |
|
[claim:review:noether:2026-05-12T00:16:05Z] |
Verdict: BLOCKED — pre-existing #693 tests now fail under the new auto-disablePR #701 logic is sound: prefixes Real merge blocker — 4 CI failures on Python 3.13: These are #693's persist tests. They use pytest's Fix: add Other (non-blocking) notes:
Holding [release:review:noether:2026-05-12T00:17:54Z] |
|
[release:review:noether:2026-05-12T00:17:55Z] |
|
[claim:review:noether:2026-05-12T00:26:24Z] |
|
Holding — pytest (3.13) red on Linux runner. 4 failures, all same root cause. Captured log says it plainly: Root cause: the new The macOS-quirk note in the body is correct as far as it goes — Fix shape (your call):
Either fix wants a sister consideration: this same blind spot bit PR #704 ( Other CI: staging-gate, codeql, calibration, deptry, vulture, sourcery, coderabbit — green. pytest 3.12 cancelled (cascade from 3.13 failure). Releasing review claim. |
|
[release:review:noether:2026-05-12T00:27:30Z] |
|
[claim:review:faraday:2026-05-12T00:32:12Z] |
Request changes — CI regressionThe new auto-disable triggers on
Root cause: the new tests in this PR work around the prefix check by monkey-patching Fix options (author's call)
Option 1 is the most surgical; option 2 future-proofs. Either works. Holding the claim release for now — re-ping |
|
[release:review:faraday:2026-05-12T00:33:30Z] |
|
[claim:review:pascal:2026-05-12T00:37:14Z] |
…p_path The new ephemeral-path auto-disable (added in this PR) matches `/tmp/` prefix on Linux CI, where `tmp_path` resolves to `/tmp/pytest-of-runner/...`. Six pre-existing PR #693 substrate tests previously used `delenv` and relied on default-on persistence; under the new behavior they either hard-fail (assert struct.npy exists) or pass vacuously (compare two in-memory builds that both auto-disabled). Switch each to `setenv("AELFRICE_HRR_PERSIST", "1")` so they continue to exercise the persistence substrate independently of the ephemeral-path heuristic. Fixes pytest (3.13) regression on PR #701 (#695).
8f55fe3 to
5a6cde6
Compare
|
Reviewed by pascal session. Found + fixed a regression in this PR; rebased and pushed. Regression
Hard failures (4):
Silent vacuous passes (2 — bigger concern because they'd ship green):
These two would have passed CI without actually exercising the persistence path. Worth catching now. FixAdded a single test commit RebaseBranch was BEHIND main. Rebased Verifications
Re-adding Design note (non-blocking)The macOS quirk in the PR body is accurate — |
|
[release:review:pascal:2026-05-12T00:41:41Z] |
5a6cde6 to
f094ced
Compare
) Add module-level _HRR_BUILD_STATS dict updated by HRRStructIndex.build() with wall-clock duration. Expose last_build_seconds() and persist_disk_bytes() as module-level helpers for doctor. Add resolve_persist_state() method on HRRStructIndexCache that returns a doctor-facing dict {enabled, dir, on_disk_bytes, reason} without firing any one-shot WARNING logs. Add log_on_ephemeral parameter (no-op on main) to _resolve_persist_dir() as a slot for PR #701.
resolve_persist_state's ephemeral-path check was a method-local tuple, so the test that exercises the enabled=True path on Linux (where pytest tmp_path lives under /tmp/) had no monkeypatch surface to override the predicate. Hoisting to module scope adds the surface and aligns shape with PR #701's _EPHEMERAL_PATH_PREFIXES (will collapse onto a single constant when #701 rebases through). Signed-off-by: rrs <276464689+robotrocketscience@users.noreply.github.com>
|
CI green on the rebased SHA — all 21 required checks pass ( Filed #707 as a v3.0 Adding |
|
merge-train: blocked FF push to The |
Add _EPHEMERAL_PATH_PREFIXES frozenset and _ephemeral_disable_logged module flag. Update _resolve_persist_dir() to resolve symlinks before prefix matching and return None (with a one-shot WARNING) when the store root falls under /tmp/, /var/tmp/, /dev/shm/, or /run/. AELFRICE_HRR_PERSIST=1 overrides; AELFRICE_HRR_PERSIST=0 still wins.
Cover all four prefix families (tmp, var/tmp, dev/shm, run), env=1 force-on override, env=0 supersedes ephemeral, one-shot WARNING guard, and non-ephemeral path persists normally. Linux-only paths (dev/shm, run) skip on macOS via skipif. All tests use monkeypatch to set _EPHEMERAL_PATH_PREFIXES to the resolved platform prefix, making them hermetic across macOS (/private/tmp) and Linux (/tmp).
Linux CI pytest tmp_path resolves under /tmp/...; the new ephemeral-path auto-disable feature correctly identifies that prefix and suppresses persistence. Four pre-existing tests that explicitly verify persistence on disk were not rewritten to opt out of the new behavior and broke on Linux while passing on macOS (where tmp_path resolves under /var/folders/). Fix mirrors the pattern in test_cache_non_ephemeral_path_persists_normally: monkeypatch _EPHEMERAL_PATH_PREFIXES to the empty set so tmp_path is treated as non-ephemeral. Leaves the env-var unset path intact so the legacy semantics (default-on persistence) are still under test. Signed-off-by: rrs <276464689+robotrocketscience@users.noreply.github.com>
f094ced to
22eb548
Compare
) Add module-level _HRR_BUILD_STATS dict updated by HRRStructIndex.build() with wall-clock duration. Expose last_build_seconds() and persist_disk_bytes() as module-level helpers for doctor. Add resolve_persist_state() method on HRRStructIndexCache that returns a doctor-facing dict {enabled, dir, on_disk_bytes, reason} without firing any one-shot WARNING logs. Add log_on_ephemeral parameter (no-op on main) to _resolve_persist_dir() as a slot for PR #701.
resolve_persist_state's ephemeral-path check was a method-local tuple, so the test that exercises the enabled=True path on Linux (where pytest tmp_path lives under /tmp/) had no monkeypatch surface to override the predicate. Hoisting to module scope adds the surface and aligns shape with PR #701's _EPHEMERAL_PATH_PREFIXES (will collapse onto a single constant when #701 rebases through). Signed-off-by: rrs <276464689+robotrocketscience@users.noreply.github.com>
|
merge-train: merged 22eb548 → |
) Add module-level _HRR_BUILD_STATS dict updated by HRRStructIndex.build() with wall-clock duration. Expose last_build_seconds() and persist_disk_bytes() as module-level helpers for doctor. Add resolve_persist_state() method on HRRStructIndexCache that returns a doctor-facing dict {enabled, dir, on_disk_bytes, reason} without firing any one-shot WARNING logs. Add log_on_ephemeral parameter (no-op on main) to _resolve_persist_dir() as a slot for PR #701.
resolve_persist_state's ephemeral-path check was a method-local tuple, so the test that exercises the enabled=True path on Linux (where pytest tmp_path lives under /tmp/) had no monkeypatch surface to override the predicate. Hoisting to module scope adds the surface and aligns shape with PR #701's _EPHEMERAL_PATH_PREFIXES (will collapse onto a single constant when #701 rebases through). Signed-off-by: rrs <276464689+robotrocketscience@users.noreply.github.com>
) Add module-level _HRR_BUILD_STATS dict updated by HRRStructIndex.build() with wall-clock duration. Expose last_build_seconds() and persist_disk_bytes() as module-level helpers for doctor. Add resolve_persist_state() method on HRRStructIndexCache that returns a doctor-facing dict {enabled, dir, on_disk_bytes, reason} without firing any one-shot WARNING logs. Add log_on_ephemeral parameter (no-op on main) to _resolve_persist_dir() as a slot for PR #701.
resolve_persist_state's ephemeral-path check was a method-local tuple, so the test that exercises the enabled=True path on Linux (where pytest tmp_path lives under /tmp/) had no monkeypatch surface to override the predicate. Hoisting to module scope adds the surface and aligns shape with PR #701's _EPHEMERAL_PATH_PREFIXES (will collapse onto a single constant when #701 rebases through). Signed-off-by: rrs <276464689+robotrocketscience@users.noreply.github.com>
Mirrors PR #701's pattern for the other 4 persist tests in this file: neutralise _EPHEMERAL_PATH_PREFIXES under monkeypatch so tmp_path on Linux CI (where it resolves under /tmp/) traverses the persistence path. Without this, the prior commit's struct.npy / np.memmap assertions fail loudly on Linux because persistence auto-disables.
) Add module-level _HRR_BUILD_STATS dict updated by HRRStructIndex.build() with wall-clock duration. Expose last_build_seconds() and persist_disk_bytes() as module-level helpers for doctor. Add resolve_persist_state() method on HRRStructIndexCache that returns a doctor-facing dict {enabled, dir, on_disk_bytes, reason} without firing any one-shot WARNING logs. Add log_on_ephemeral parameter (no-op on main) to _resolve_persist_dir() as a slot for PR #701.
resolve_persist_state's ephemeral-path check was a method-local tuple, so the test that exercises the enabled=True path on Linux (where pytest tmp_path lives under /tmp/) had no monkeypatch surface to override the predicate. Hoisting to module scope adds the surface and aligns shape with PR #701's _EPHEMERAL_PATH_PREFIXES (will collapse onto a single constant when #701 rebases through). Signed-off-by: rrs <276464689+robotrocketscience@users.noreply.github.com>
Closes #695 (sub-task of #553).
Summary
HRRStructIndexCache._resolve_persist_dir()now auto-disables persistencewhen the resolved store-root parent path lives under a known ephemeral
prefix:
/tmp/,/var/tmp/,/dev/shm/,/run/. On the firstauto-disable per process, the cache logs a single WARNING explaining how
to force persistence on via the env var. This is the second of five #553
sub-tasks (after PR #693 wired the load+save substrate).
What changed
_EPHEMERAL_PATH_PREFIXES: Final[frozenset[str]] = frozenset({"/tmp/", "/var/tmp/", "/dev/shm/", "/run/"})._ephemeral_disable_logged: bool = Falseflag (one-shot WARNING gate)._resolve_persist_dir()resolves the store-root parent viaPath(self.store_path).resolve(strict=False).parent, then checks the trailing-slashed string form against each prefix (/tmpfoo/does not match/tmp/). Precedence:AELFRICE_HRR_PERSIST=0→ returnNone(explicit opt-out wins)AELFRICE_HRR_PERSIST=1→ return persist dir (env force-on overrides auto-disable)NoneWARNING log shape, per spec:
No public-API change. No new constructor field. The TOML key and doctor reporter rows are separate sub-issues that will read this resolver's output.
Test plan
8 new tests in
tests/test_hrr_struct_index.py:/tmp/...store → no persist dir, WARNING logged/var/tmp/...→ disabled (resolver-level)/dev/shm/...→ disabled (Linux-only; skipif on macOS)/run/...→ disabled (Linux-only; skipif on macOS)AELFRICE_HRR_PERSIST=1overrides ephemeral auto-disableAELFRICE_HRR_PERSIST=0wins over force-on path (explicit opt-out always wins)get()calls (one-shot gate)struct.npyon disk)39 pass / 4 skip (2 pre-existing perf-gated, 2 new Linux-only
/dev/shm+/runtests skip on macOS).macOS quirk
Path("/tmp/foo").resolve(strict=False)returns/private/tmp/fooon macOS because/tmpis a symlink. The literal/tmp/prefix never matches after resolving. Tests usemonkeypatch.setattr(_EPHEMERAL_PATH_PREFIXES, frozenset({resolved_prefix}))to swap in the resolved form, which keeps each test hermetic and portable.Production-runtime implication: on macOS dev/CI hosts, a store rooted at
/tmp/foowill NOT be auto-disabled (since it resolves to/private/tmp/foowhich is not in the prefix list). That matches the spec's intent —/tmpephemerality is a Linux container/server property; macOS/private/tmpis on-disk and persists across boots. The Linux target deployment gets the auto-disable; macOS dev pays the rebuild cost. This is documented as expected behavior.Out of scope
The remaining #553 follow-ups (TOML key, doctor reporter rows, cold-start bench gate, docs bundle) are filed as separate sub-issues. See the #553 umbrella for the cross-reference list.