Skip to content

Re-prime the prior gate on evict/revisit reload (#118) - #132

Merged
rolker merged 15 commits into
jazzyfrom
feature/issue-118
Aug 18, 2026
Merged

Re-prime the prior gate on evict/revisit reload (#118)#132
rolker merged 15 commits into
jazzyfrom
feature/issue-118

Conversation

@rolker

@rolker rolker commented Aug 18, 2026

Copy link
Copy Markdown
Owner

Closes #118.

Summary

Closes the last gap in the prior-gate chain (#89#96#115#119/#91): a tile whose predicted surface came only from the reference/chart prior used to return from eviction with the blunder gate — and, since #59, live slope correction — silently OFF, because the reload path restored the Survey layer only.

Test plan

  • New regression test ReferenceOnlyTileEvictRevisitKeepsGate: a reference-gated tile is surveyed on one cell, evicted by spread batches, then revisited with a −150 m blunder at a different, never-surveyed cell — the blunder must be rejected and the original survey must survive the round-trip. Discrimination verified: with the reload re-prime disabled, the test fails (pre-fix bug reproduced).
  • New PriorReadFailureKeepsTileEvicted covering the retry semantics.
  • Full package suite: 517 tests, 0 errors, 0 failures (lint clean).
  • Pre-push /review-code (deep tier, 2 rounds): round 1 changes-requested (2 live-path must-fixes, both fixed), round 2 approved / Ship: recommended, 0 must-fix.

Authored-By: Claude Code Agent
Model: Claude Fable 5

Claude Code Agent and others added 13 commits August 18, 2026 06:33
Extend reloadEvictedTile at both call sites (offline + live node) to
re-apply Chart+Reference prior after survey restore; add regression test.
Extract seedNewTile's whole prior rung (Chart exact -> Reference exact ->
#115 containment-checked cross-level fallback, predicted-only,
warn-and-continue) into file-local primePriorLayersForTile and call it
from reloadEvictedTile BEFORE the survey restore -- prior first so the
finer survey-derived predicted depth overwrites where measured data
exists, the same order as first touch. Previously a tile whose predicted
surface came only from the prior returned from eviction with the blunder
gate (and #59 slope correction) silently OFF. Re-primes are logged for
auditability. Regression test evicts a reference-gated tile and revisits
with a deep blunder at a never-surveyed cell; verified to FAIL with the
re-prime disabled.
reloadEvictedTile now re-primes the revisited tile from prior_store_dir
first (single-tile exact-level Chart-then-Reference lookups -- not a
whole-window prime, which would lazy-create neighbor nodes against the
very budget doing the evicting), then the draft restore overwrites where
survey data exists. The revisit loop also runs when only a prior store
is configured: prior-primed tiles are clean and evictable without draft
persistence, and previously could never be re-primed. Throttled INFO on
re-prime, throttled WARN + continue-ungated on a prior read error. The
two 'deferred as #118' comments now describe the shipped behaviour.
…prior read failure (#118)

Address the two pre-push must-fixes on the live revisit gate path plus the
re-prime-failure observability suggestion:

- Reload-before-add (must-fix): the revisit reload loop ran AFTER
  addSoundings, so a false-deep blunder in the FIRST revisit batch of an
  evicted prior-only tile was settled ungated (Node::insert accepts anything
  while predicted_depth_ is NaN) before the reload re-primed the gate. Move the
  loop before addSoundings and key it off gridIndicesForSoundings -- the same
  influence-radius-expanded window addSoundings touches -- mirroring the offline
  importer's reload-before-add. Failed reloads are dropped AFTER the add.

- Keep-evicted-on-prior-read-failure (must-fix): a thrown prior loadWindow was
  caught and the draft-empty branch fell through to 'return true', so the caller
  erased the evicted marker and the prior-only tile ran ungated for the rest of
  the session with no retry. Track prior_ok and return it from both the
  draft-empty and survey-restore branches so a prior read failure keeps the tile
  evicted for retry.

- Observability (suggestion): the re-prime-failure WARN now names the tile and
  throttles tighter (1 s) than the success INFO (30 s) so distinct failing tiles
  are less likely to be collapsed, and states the (now real) retry contract.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…118)

Offline analog of the live-node prior-read-failure fix. primePriorLayersForTile
returned only 'did I prime a cell', not 'did the windowed load succeed', so a
thrown prior read on revisit (caught internally, returns false) followed by a
successful survey restore left ImportAccumulator::reloadEvictedTile returning
true -- the caller erased the evicted_ marker and the tile's prior-only cells ran
ungated for the rest of the run with no retry. Add an optional read_ok out-param
that reports whether the load threw, and return it from reloadEvictedTile so a
prior read failure keeps the tile evicted (caller drops it, protecting the intact
on-disk survey surface) for a later revisit to retry -- the same drop-and-retry
already used for survey read errors.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add ImportEviction.PriorReadFailureOnRevisitKeepsTileEvicted: survey a cell of a
reference-gated tile, evict it, corrupt the reference tile so the revisit prior
re-prime read throws (survey restore still succeeds), then revisit with a deep
blunder at a different never-surveyed cell. The blunder must not settle -- the
tile is kept evicted and its ungated revisit soundings dropped. Exercises the
shared reload logic that the live CubeBathymetryNode::reloadEvictedTile mirrors
(the ROS node class is not unit-test-exposed -- behind main(), no header/library
target).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings August 18, 2026 10:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR closes #118 by ensuring tiles that are evicted and later revisited regain their prior-seeded predicted surface (and therefore blunder gating and slope correction) before new soundings are accumulated, in both the offline importer and the live node.

Changes:

  • Extracts the import-time prior priming logic into a shared helper and reuses it during ImportAccumulator::reloadEvictedTile so revisited tiles are re-gated before survey restoration.
  • Updates the live node’s revisit path to re-prime priors and to reload evicted tiles before addSoundings, with retry semantics on prior read failure.
  • Adds regression tests covering the evict→revisit gate retention and the “prior read failure keeps tile evicted” retry behavior.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
cube_bathymetry/test/test_import_eviction.cpp Adds regression tests for evict/revisit prior-gate retention and retry-on-prior-read-failure behavior.
cube_bathymetry/src/store_import.cpp Introduces primePriorLayersForTile() helper; re-primes priors on reload and propagates prior-read success to control eviction retry semantics.
cube_bathymetry/src/cube_bathymetry_node.cpp Re-primes priors on revisit; reloads evicted tiles before addSoundings; keeps tiles evicted on prior read failure to enforce retry behavior.
cube_bathymetry/include/cube_bathymetry/store_import.h Documents the updated reloadEvictedTile semantics (prior-first, then survey restore).
.agent/work-plans/issue-118/plan.md Adds the implementation plan for issue #118.
.agent/work-plans/issue-118/progress.md Records progress/review notes and rationale for design decisions and must-fix resolutions.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread cube_bathymetry/src/store_import.cpp Outdated
Comment on lines +683 to +686
// cross-level Reference fallback resample. Warn-and-continue on any load error
// (the tile simply runs ungated; a prior read failure must never drop
// soundings). Shared by seedNewTile (first touch) and reloadEvictedTile (#118
// revisit re-prime); @p context names the caller in the audit/error lines.
Comment thread cube_bathymetry/src/store_import.cpp Outdated
Comment on lines +781 to +782
std::cerr << "import_bag: could not prior-seed tile on " << context << ": "
<< e.what() << " (no prior gate for this tile)" << std::endl;
Copilot AI review requested due to automatic review settings August 18, 2026 10:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

@rolker
rolker merged commit 8030d31 into jazzy Aug 18, 2026
2 checks passed
@rolker
rolker deleted the feature/issue-118 branch August 18, 2026 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Blunder gate lost on evict/revisit of reference-only tiles (seeded_ not cleared; reloadEvictedTile restores Survey only)

2 participants