Skip to content

nav: CoPH's agent and fleet, and the crossing world (C5 part 1; G12) - #1413

Merged
transfix merged 5 commits into
masterfrom
nav/coph-c5
Nov 22, 2026
Merged

transfix merged 5 commits into
masterfrom
nav/coph-c5

Conversation

@transfix

Copy link
Copy Markdown
Owner

C5 part 1 of docs/roadmap/NAV-COPH-ROADMAP.md (§4.5): one CoPH agent as a whole, a fleet of them, and the crossing world, reproducing GRL-SNAM's G12. Additive and default-off.

Stacked on #1410 (C4), and its golden comes from CVC-Lab/GRL-SNAM#202 (G12, itself on #201). Until #1410 merges, this branch's first commit is C4's. src/cvc/tests/data/coph_golden.json is #202's fixture (blob 6a96239c). G1–G11 are unchanged. Merging this PR is Joe's call.

What lands

  • inc/cvc/nav/coph_agent.h: coph_agent, the demos' whole learner (CrossingLearner) over C1–C4.
    • observe:
      • CooperativeLearner's agent-prefixed uids;
      • navigation.observe_geometry's store (what intersects a kept stage or lies within the stopping distance, nearest first);
      • C1's ledger;
      • the expiries;
      • MazeLearner's geometry reports.
    • advance.
    • action: the routed control (C3) in the live navigation context.
    • update: CooperativeLearner's diagnostic controls, whose guard steps count against the budget, around C3/C4's update; then TerrainLearner's own anchors, one per 0.2 m cell.
    • export_to and assimilate, with the received-geometry events.
  • inc/cvc/nav/coph_fleet.h
    • coph_fleet is the demos' runner (staggered_demo.execute) for agents that start together, over a coph_channel. Each boundary observes and advances, exports on the update cadence, delivers in (timestamp, identity) order, then updates and acts. It keeps the runner's records and each agent's energy account (coph_energy).
    • coph_crossing_world is the crossing demo's world: the exact-flow plant, door and corridor hits, and the 21-point sensor with a pluggable noise. run() drives a fleet through it.
  • Hooks in C1–C3:
    • coph_ledger::commit;
    • route_changed and the raw command (proposed) in coph_control_meta;
    • coph_corridor_clear and coph_slab_sweep;
    • coph_field_vector;
    • TerrainLearner's local cells in the exchange state.

Results on Windows (MSVC 19.44, Release)

G12: 479 of 968 values bit for bit; the worst difference is 2.78e-16 (atol 1e-06)
  • Decisions: every one matches:
    • each boundary's stage, version and done flag;
    • every routed control's reason, route, waypoint, guard steps and route change;
    • every update's packets, attempts and verdict;
    • every activation, send and delivery with its reason, and each receiver's version and verdict after it;
    • both agents' geometry events, including agent 1 sensing the middle door and agent 0 learning it from agent 1's packet;
    • the outcomes.
  • C++-only tests:
    • Refusals. Configs outside the profile are refused.
    • Channel delay. With a 0.3 s channel delay, every packet arrives at the first boundary after it, and its delivery triggers an off-cadence update.
    • The whole crossing. Run to the end (at most 2,000 ticks, with the fleet's own seeded draws), both agents reach their goals with no hit. Agent 0 takes 767 steps (92.0 s), the demo's reciprocal finish time in GRL-SNAM's numbers gate; agent 1 takes 784. Each energy account's residual stays at 7e-15 against 7.9 J of work. The whole test file takes 2.9 s.
  • Earlier tests: C1–C4's tests still pass with unchanged numbers. clang-format 18 is clean.

Not yet: part 2

  • The vehicle driver of §4.5 (attach to sim_world agents, Froude scaling, the allocation, override_command).
  • The plant_ledger items (D11).
  • The byte-unchanged runs without a fleet.

The roadmap's §4.5 now has a "Landed in part 1" note saying so.

Also not modelled: the runner's status replies and acknowledgements. They cost bytes but never bind at the demos' budgets, and the fleet counts payload bytes only.

C4 of docs/roadmap/NAV-COPH-ROADMAP.md (section 4.4), additive and default-off: nothing calls it
yet; C5's fleet driver will.

- coph_packet.h: the demos' packet (cooperative.Packet, then MazePacket's geometry), and bytes():
  the length of its compact, key-sorted JSON, with Python's repr for floats (coph_repr, from
  std::to_chars's shortest digits) (D9). coph_exchange_state holds the received packets, the
  route evidence and its cells, and the reported geometry.
- coph_exchange.h:
  - coph_export: CooperativeLearner's bootstrap and candidate anchors, TerrainLearner's
    risk-ordered anchors and second bootstrap, MazeLearner's geometry. The resample indices are
    injected, or drawn from a seeded std::mt19937 through detail::pick_below (D8).
  - coph_assimilate: MazeLearner's geometry checks; CooperativeLearner's schema, provenance, age,
    order, payload and received cap; TerrainLearner's route evidence.
  - coph_expire and the two refreshes.
  - coph_fit_messages: the legacy receiver's whitened Gauss-Newton step, which coph_update now
    commits when packets are held.
- coph_channel.h: the transport interface and coph_ideal_channel (seeded delay and jitter, drops,
  duplicates, an optional range).
- detail/coph_math.h: the features, Cholesky and slab distance that coph_learner.cpp and
  coph_exchange.cpp share (moved out of coph_learner.cpp unchanged).

nav_coph_exchange_test reproduces GRL-SNAM's G9 and G10 (CVC-Lab/GRL-SNAM#201;
data/coph_golden.json is its fixture). Every decision and byte count matches exactly, and the
values come within 0.074 of the tier's allowance on Windows. It also checks the channel's
statistics, production draws and JSON escapes.
C5 part 1 of docs/roadmap/NAV-COPH-ROADMAP.md (section 4.5), additive and default-off.

- coph_agent.h: the demos' whole learner (CrossingLearner) over C1-C4.
  - observe: CooperativeLearner's uids, navigation.observe_geometry's store, C1's ledger, the
    expiries, MazeLearner's geometry reports.
  - advance.
  - action: the routed control in the live navigation context.
  - update: CooperativeLearner's diagnostic controls around C3's update, then TerrainLearner's
    own anchors.
  - export and assimilate, with the received-geometry events.
- coph_fleet.h:
  - coph_fleet: the demos' runner (staggered_demo.execute) for agents that start together, over
    a coph_channel. Its boundaries observe and advance, export on the update cadence, deliver,
    update and act. It keeps records and each agent's energy account.
  - coph_crossing_world: the crossing demo's world, with its plant, its door and corridor hits
    and its sensing.
- C1-C3 gain the hooks it needs:
  - coph_ledger::commit;
  - the route change and the raw command in coph_control_meta;
  - coph_corridor_clear and coph_slab_sweep;
  - coph_field_vector;
  - TerrainLearner's local cells in the exchange state.

nav_coph_fleet_test reproduces GRL-SNAM's G12 (CVC-Lab/GRL-SNAM#202; data/coph_golden.json is its
fixture). Every decision matches, and positions and forces are within 2.8e-16 against an atol of
1e-6. The C++-only tests cover:
- refusals outside the profile;
- packets arriving after a channel's delay;
- a run of the whole crossing, which both agents finish (agent 0 in 92.0 s, the demo's
  reciprocal finish time) with each energy account's residual at 7e-15.

The vehicle driver and the plant_ledger items (D11) are part 2.
# Conflicts:
#	inc/cvc/nav/coph_exchange.h
#	inc/cvc/nav/coph_learner.h
#	inc/cvc/nav/coph_packet.h
#	inc/cvc/nav/detail/coph_math.h
#	src/cvc/CMakeLists.txt
#	src/cvc/nav/coph_exchange.cpp
#	src/cvc/tests/CMakeLists.txt
#	src/cvc/tests/data/coph_golden.json
@transfix
transfix enabled auto-merge (squash) November 22, 2026 08:29
@transfix
transfix merged commit 08a7386 into master Nov 22, 2026
31 checks passed
@transfix
transfix deleted the nav/coph-c5 branch November 22, 2026 11:15
transfix added a commit that referenced this pull request Nov 22, 2026
Brings in master through 08a7386 (#1413, #1430, #1446, #1420, #1447, #1435). No conflicts; nothing in it touches state_exec.
transfix added a commit that referenced this pull request Nov 23, 2026
…on slow Debug runners (#1462)

CophFleet.TheEnergyAccountStaysAtRoundOffOverALongRun runs the crossing until both agents are
at their goals (767 and 784 ticks). It takes about 4 s in Release and 69.65 s in
package-linux / libcvc-debug on a normal runner (#1413's job 137148518817). A PR's Debug ctest
gives a test without a TIMEOUT of its own 300 s, and on #1452's run 45049798289 (job
137292269354) it timed out on all three tries. On that runner this executable's other cases ran
4.2-4.7 times slower than on #1413's (the golden cases 24 s against 5, the channel-delay test 30
against 7.2), so the long run would have needed about 290-330 s.

The executable gets TIMEOUT 900, as the segmentation action test has for a Debug time of about
100 s: 13 times the normal Debug time, about 2.8 times that slow runner's. The test is
unchanged.

Not shortened in Debug: both agents reaching their goals, with no hit and the energy residual
at round-off, is what the test checks. Not made cheaper: at /Od the learner's updates are about
60 % of the run, the actions 19 % and the exports 15 %, all held bit for bit to GRL-SNAM's G12
golden, so a cheaper step is learner work rather than a test fix.

Checked on Windows with the test built from its sources in a Debug configuration (/Od /Ob0
/RTC1) and this file's cvc_discover_tests wrapper and line: every discovered case has TIMEOUT
900, the eight pass under ctest --timeout 300, and the long run passes under --timeout 5 (the
property wins over the command line). The long run took 17.5 s there, 35 s with the machine
loaded.
transfix added a commit that referenced this pull request Nov 23, 2026
#1413 landed as a squash, and nav/coph-c5b took master in (f32c670). The one conflict,
src/cvc/tests/CMakeLists.txt, keeps master's TIMEOUT for nav_coph_fleet_test (#1462) and
nav/coph-c5b's for nav_coph_cars_test, and gives nav_coph_driver_test the same 900 s.

#1461's first run failed package-linux / libcvc-debug on two timeouts at the PR Debug ctest's
300 s default, on a runner about 5x slower than usual (the fleet's goldens took 25 s against 5):
CophFleet.TheEnergyAccountStaysAtRoundOffOverALongRun, which #1462 fixes, and
CophDriver.ABlockSensedLateIsNeverHit. CophDriver.TwoCarsCrossTheField passed there in 298 s.
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