Skip to content

import_bag: seed CUBE predicted surface from Chart prior to reject false-deep detections (#89)#90

Merged
rolker merged 3 commits into
jazzyfrom
feature/issue-89
Jun 29, 2026
Merged

import_bag: seed CUBE predicted surface from Chart prior to reject false-deep detections (#89)#90
rolker merged 3 commits into
jazzyfrom
feature/issue-89

Conversation

@rolker

@rolker rolker commented Jun 29, 2026

Copy link
Copy Markdown
Owner

Summary

Seeds the CUBE predicted surface in import_bag from a Chart (contour) prior
so CUBE's predicted-surface blunder gate turns on and rejects false-deep
detections
— the false detections (water-column / second-bottom returns) that
place soundings much too deep and corrupt both the bathy and (via the bogus large
range) the co-estimated backscatter.

Closes #89.

Mechanism

CUBE's blunder gate is predicted-surface-relative and is skipped when
predicted_depth_ is NaN
(node.cpp). With no prior there is nothing to reject
false-deep soundings against — which is why they survive today. Priming the
predicted surface from the existing Chart layer (e.g. the Massabesic contour)
turns the gate on: a sounding below
target − blunder_scalar·√(predicted_var) is rejected.

Changes

  • Predicted-only primeprimeFromTile/loadIntoSheet gain seed_settled
    (default true, preserving the Persist GeoMapSheet draft tiles between sessions #21/Bound memory + output for long-duration operation: evict cold tiles from RAM; retire monolithic publish for incremental tiles #70 warm-start callers). With false, only
    the predicted surface is seeded — no settled hypothesis — so the survey/Processed
    layer keeps honest holes rather than being filled with coarse contour depths
    (which would contaminate the bathy and the co-estimated backscatter). Gap-filling
    survey→chart stays a query-time overlay concern (ADR-0002).
  • import_bag --prior <store_dir> — loads that store's Chart layer and primes
    the predicted surface before the replay.
  • Validation (review hardening)--prior refuses to build a silently
    un-gated store: hard-errors on a bad path / missing chart/ layer (0 tiles) and
    on an all-wrong-GGGS-level chart (none would coincide with a survey node), warns
    on partial level mismatch, and wraps load() in try/catch for a friendly
    diagnostic. The shallow-chart false-reject tradeoff is noted in the help text.

Tests

  • PredictedOnlyPrimeSeedsNoSettledHypothesis — predicted-only seeds predicted, not
    settled (sheet stays clean).
  • SeededPredictedSurfaceRejectsDeepBlunder — a deep blunder accepted without a
    prior is rejected once the predicted surface is seeded.
  • Full suite: 406 tests, 0 failures.

Local review

Pre-push review (Standard tier) run before opening: 1 must-fix (silent --prior
no-op) + suggestions, all addressed in this branch. Build + tests green.


Authored-By: Claude Code Agent
Model: Claude Opus 4.8 (1M context)

Claude Code Agent added 3 commits June 29, 2026 00:29
Add a seed_settled=true parameter to primeFromTile and loadIntoSheet. When
false, seed ONLY the predicted surface (setPredictedDepthAt) and skip the
settled CUBE hypothesis (setSettledDepthAt), so the cell carries a
blunder-rejection prior that turns on Node::insert's predicted-surface gate
without filling/settling the cell. Default true preserves the existing
#21/#70 warm-start reload behavior.

This is the mechanism behind seeding the CUBE predicted surface from a Chart
(contour) prior: settling coarse contour depths would contaminate the survey
layer (and its co-estimated backscatter) with non-measured fill, so the prior
only gates, it does not fill.

Tests: PredictedOnlyPrimeSeedsNoSettledHypothesis (predicted set, no settled
hypothesis, sheet stays clean, contrasted against seed_settled=true) and
SeededPredictedSurfaceRejectsDeepBlunder (a shallow predicted surface rejects
a false-deep sounding that is accepted with no prior).

Part of #89
…ior (#89)

Add a --prior <store_dir> flag. Before the CUBE replay, load that store's
Chart (contour) layer and prime the GeoMapSheet predicted surface with
loadIntoSheet(..., seed_settled=false). The prime lazy-creates a node per
chart cell carrying a predicted depth, turning on CUBE's predicted-surface
blunder gate (Node::insert is a pass-through when predicted_depth_ is NaN), so
false-deep detections below target - blunder_scalar*sqrt(predicted_var) are
rejected before they reach the winning hypothesis -- protecting both the bathy
and backscatter stores.

The prior store is built at the survey's GGGS level; a code comment documents
that a chart cell only gates when its level is compatible with the survey
node (a future refinement could resample).

Part of #89
…ld (#89)

Review found the --prior path could silently no-op: load() returns 0 with
no error on a missing dir / no chart layer / level-mismatched store, yet the
code logged 'blunder rejection active' regardless — the operator could ship
an unprotected store believing outliers were gated.

- Hard-error when --prior yields 0 Chart tiles (bad path / no chart/ layer).
- Hard-error when ALL Chart tiles are at a non-survey GGGS level (none would
  coincide with a survey node → gate inactive); warn on partial mismatch.
- Wrap load() in try/catch for a friendly diagnostic instead of an abort.
- Correct the ALIGNMENT comment: load() keys level off each tile's filename,
  so fromCellSize() does not pin the prime level.
- Note the shallow-chart false-reject tradeoff in --prior help text.
Copilot AI review requested due to automatic review settings June 29, 2026 04:51

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@rolker rolker merged commit e3972a0 into jazzy Jun 29, 2026
1 of 2 checks passed
@rolker rolker deleted the feature/issue-89 branch June 29, 2026 04:57
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.

import_bag: seed CUBE predicted surface from the Chart (contour) prior to reject false-deep detections

2 participants