Skip to content

coph_golden: the golden libcvc's C++ twin of grl_snam.coph reproduces (CoPH T5: G1, G4) - #168

Merged
transfix merged 1 commit into
mainfrom
feat/coph-golden
Nov 13, 2026
Merged

transfix merged 1 commit into
mainfrom
feat/coph-golden

Conversation

@transfix

@transfix transfix commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

This is T5 of libcvc's CoPH roadmap (docs/roadmap/NAV-COPH-ROADMAP.md §3.4 and §5): the golden that libcvc's C++ twin of grl_snam.coph will be pinned to. It builds on T1 (#166) and lands before C1.

python -m grl_snam.tools.coph_golden --out DIR   # writes DIR/coph_golden.json

Every double is its raw bits: 16 hex digits of the uint64, most significant first. The file is the same bytes on every run and OS. libcvc commits it in src/cvc/tests/data, and GRL-SNAM keeps a copy in tests/fixtures/coph_golden. .gitattributes keeps git from converting its line endings.

It covers the C1 cases, the records and the stage ledger (G1 and G4). Later C steps add theirs, the way the belief-material controller's golden (#164) did.

G1: the configuration

  • 74 Config and 5 CommunicationConfig cases.
  • Accepted cases record:
    • every field after __post_init__, which fills replay_update_cap;
    • the fields outside the demos' profile, which the C++ refuses (D7).
  • Refused cases record __post_init__'s message.
  • Coverage:
    • every refusal: the test parses __post_init__ and checks that the golden's messages are exactly its raise ValueError set;
    • partial overrides, integers given for doubles, both ways replay_update_cap gets filled, and modes __post_init__ accepts that lie outside the profile;
    • four cases where more than one check fails, so the C++ must keep the same check order.

G4: the stage ledger, and a correction for C1

The demos' learner is crossing_demo.CrossingLearner, a maze_learning.MazeLearner. Its stage rule is not learner.Learner.advance's, which is the rule the roadmap's §1 and C1 describe:

  • The axis. It advances along whichever axis left the inner box (delta > size * (1 - overlap) / 2), by size * (1 - overlap) in either direction. So y steps are 2.8 m, not 2.1 m.
  • Readings. The new stage pools the readings of every kept stage, then drops repeated uids and keeps its last sample_cap. It also pools their footprints.
  • No anchors. It never sets Stage.anchors. _field_fit's overlap continuity rows read those anchors, so they are always empty in the demos.

G4 pins the demos' rule, and C1 should implement that one.

The case. One scripted path of 360 ticks, run under three configurations:

  • the profile;
  • small caps with previous 3 and overlap 0.5;
  • previous 0 with no overlap and 2.5 × 3.5 m stages.

The path runs out along the middle row to the door, waits there 20 ticks, comes back, then goes down the west column, along the south row, up the east column and along a diagonal. So stages advance along both axes in both directions, and on the diagonal the axis comes from delta / size.

What each tick records:

  • the advance;
  • the geometry store, which comes from the navigation layer and is an input for C1;
  • for each kept stage, its readings, transitions, footprints and obstacles, as what was dropped from the front and what was appended since the last tick.

Each stage's fixed fields are recorded once, when it is made: centre, entry, target, RBF centres, weights and version. Every cap fills: 240 readings and 120 footprints in the profile, and all three small caps.

The rules. The file states them in full (stage_rules). tests/test_coph_golden.py rebuilds every tick of all three configurations from the file's inputs and those rules alone, in plain Python, so the rules the C++ follows are complete.

Cross-platform. Most of the ledger's arithmetic is single IEEE operations. The tests that go through a BLAS dot (intersects' d @ d, the store's distance filter, slab visibility) could differ in the last bit between platforms. So the generator refuses a script where any of them sits within 1e-9 of its threshold. The first script it refused had a real tie: an obstacle exactly 1.25 m from a path point.

Size

444 KB: the configuration cases 55 KB, the script 105 KB, and the three ledgers 67 to 123 KB each. Recording deltas rather than full lists brought it down from 1.18 MB.

Tests and checks

  • tests/test_coph_golden.py, 9 tests:
    • the byte compare;
    • the bit encoding;
    • G1: refusal coverage, the profile, the filled caps, check order, and values by declared type;
    • G4: the replay of each configuration, and that the path exercises both axes in both directions, retention and every cap.
  • Local runs. On Windows, the new tests and the belief golden's pass: 13 passed. black and ruff are clean.
  • Determinism. Regenerating twice gives identical bytes.
  • Linux. CI's three legs (cp311–cp313) pass the byte compare, so the fixture written on Windows regenerates byte for byte there.

VENDORED.md gains a Goldens section, and a step in Re-syncing to regenerate the golden. No vendored module changes.

… (G1, G4)

T5 of libcvc's NAV-COPH-ROADMAP.md (§3.4, §5). python -m
grl_snam.tools.coph_golden --out DIR writes coph_golden.json, with every double
as its raw bits (16 hex digits). It covers the C1 cases:

- G1: 74 Config and 5 CommunicationConfig cases. Accepted ones record every
  field after __post_init__ and the fields outside the demos' profile; refused
  ones record the message. Every refusal is covered, plus check order.
- G4: the stage ledger of the demos' own learner (CrossingLearner) along a
  360-tick scripted path, under three configurations, as per-tick deltas. The
  file states the rules; the test rebuilds every tick from them in plain Python.

The demos' MazeLearner advances along either axis, pools every kept stage's
readings and never sets anchors, so the overlap continuity rows are empty in
the profile. G4 pins that rule, not Learner.advance. The generator refuses a
script whose BLAS-dot decisions sit within 1e-9 of a threshold.

tests/test_coph_golden.py regenerates the file and compares bytes with
tests/fixtures/coph_golden; .gitattributes keeps its line endings.
@transfix
transfix merged commit 7bc1b9a into main Nov 13, 2026
5 checks passed
transfix added a commit to transfix/libcvc that referenced this pull request Nov 15, 2026
C1 of docs/roadmap/NAV-COPH-ROADMAP.md: the C++ twin of GRL-SNAM's
grl_snam.coph (CoPH-Stagewise, vendored at c1f1ff3), up to the stage ledger.

inc/cvc/nav/coph_config.h:
- coph_config and coph_communication_config: every field of Config and
  CommunicationConfig, with Python's defaults; modes are strings, as in
  Python. validate() is __post_init__: the same refusals with the same
  messages, in the same order, and it fills replay_update_cap the same way.
  Python's min() is mirrored, so NaN scales pass where upstream's do.
- outside_profile() and require_profile(): the mode fields that differ from
  the demos' profile, which the twin refuses (D7). coph_profile() and
  coph_communication_profile() are the demos' configurations.

inc/cvc/nav/coph_ledger.h (built with -ffp-contract=off):
- coph_shape (disk or slab), coph_reading, coph_transition, coph_footprint,
  coph_observation, coph_stage (new_stage, contains) and coph_intersects.
- coph_ledger: the current stage and the previous cfg.previous, with observe,
  advance and set_geometry. The geometry store comes from the navigation
  layer.

The demos' learner is crossing_demo.CrossingLearner, a MazeLearner, and its
rule is not Learner.advance's, which the roadmap first described. It advances
along whichever axis left the inner box, in either direction (y steps are
2.8 m), pools the readings and footprints of every kept stage, and never sets
Stage.anchors, so _field_fit's overlap continuity rows are always empty in
the demos. The ledger implements that rule; the roadmap's §1, §4.1, §4.3 and
G4 now say so.

The golden is written by GRL-SNAM (grl_snam.tools.coph_golden,
CVC-Lab/GRL-SNAM#168) and committed in src/cvc/tests/data, the same blob as
GRL-SNAM's tests/fixtures copy. nav_coph_test reproduces it bit for bit:
- G1: all 74 Config and 5 CommunicationConfig cases (acceptance, Python's
  message, every value, the fields outside the profile, and that the ledger
  refuses those);
- G4: every tick of the 360-tick script under its three configurations:
  each advance and its axis, each new stage's fixed fields, and each kept
  stage's readings, transitions, footprints and obstacles.
C++-only tests cover upstream's NaN behaviour, require_profile's message, a
sensor-less observation and a repeated uid across stages.

* nav: coph_profile_modes returns its list by value (the singleton scan)

The function-local static in coph_profile_modes() is process-wide state, which libcvc does not keep; package-linux's singleton scan refused it.
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.

1 participant