Skip to content

nav: CoPH's packets, their assimilation and the channel (C4; G9-G10) - #1410

Merged
transfix merged 2 commits into
masterfrom
nav/coph-c4
Nov 21, 2026
Merged

transfix merged 2 commits into
masterfrom
nav/coph-c4

Conversation

@transfix

Copy link
Copy Markdown
Owner

C4 of docs/roadmap/NAV-COPH-ROADMAP.md (§4.4): the demos' packets in C++, their assimilation, and the channel they travel through. Additive and default-off: nothing calls it yet; C5's fleet driver will.

Depends on CVC-Lab/GRL-SNAM#201 (the G9–G10 generator). src/cvc/tests/data/coph_golden.json is that PR's fixture, the same blob (5bb26ee9). G1–G8 and G11 are unchanged. #201 merges first.

What lands

  • inc/cvc/nav/coph_packet.h
    • coph_packet is the demos' packet: cooperative.Packet's fields in order, then MazePacket's geometry.
    • bytes() is the length of its compact, key-sorted JSON (D9). Floats use coph_repr, which writes Python's repr from std::to_chars's shortest digits, with an snprintf/strtod fallback where floating to_chars is missing.
    • coph_exchange_state holds:
      • the received packets, with each sender's last (timestamp, stage);
      • TerrainLearner's route evidence and its 0.2 m cells;
      • MazeLearner's local and remote geometry reports.
  • inc/cvc/nav/coph_exchange.h
    • coph_export runs all three layers:

      • CooperativeLearner fits the 8-member block bootstrap and anchors at candidates around the agent;
      • TerrainLearner re-anchors at the riskiest supported readings with a second bootstrap;
      • MazeLearner adds the geometry.

      The resample indices are inputs (D8). The golden injects the Python's; in production, coph_draw_blocks draws them from a seeded std::mt19937 through detail::pick_below, the same on every standard library.

    • coph_assimilate runs:

      • MazeLearner's geometry checks;
      • CooperativeLearner's convention, provenance, age, order and payload checks, and the received cap;
      • TerrainLearner's route evidence, including the remote_route_only scope.
    • coph_expire, coph_refresh_terrain, coph_refresh_geometry.

    • coph_fit_messages: the legacy receiver's Gauss–Newton step per stage, with an analytic Jacobian, whitened by chol(C + (0.01 + 0.005 age) I) and clamped to ±0.5. coph_update now expires the held packets first and commits this step's weights when packets are held. With nothing received it is unchanged, and G5–G8 still pass bit for bit where they did.

  • inc/cvc/nav/coph_channel.h: the coph_channel interface (send(from, to, packet, bytes, at_s), poll(agent, now_s)) and coph_ideal_channel, with seeded delay and jitter, drops, duplicates and an optional range. libcvc gains no dependency on cvcdbg.
  • inc/cvc/nav/detail/coph_math.h: the RBF features, Cholesky and its solves, and the slab distance, moved unchanged out of coph_learner.cpp so coph_exchange.cpp shares them.
  • src/cvc/tests/nav_coph_exchange_test.cpp: G9, the repr and byte cases, and G10. It also has C++-only tests:
    • the channel's delay, drop, duplicate and range statistics;
    • seeded production exports;
    • the JSON writer's escapes.

Results on Windows (MSVC 19.44, Release)

G9:  14 of 1758 values bit for bit; the worst is 0.0737 of the tier's allowance
G10: 62 of 1595 values bit for bit; the worst is 0.0335 of the tier's allowance
  • Decisions: every one matches:
    • blocks, candidates and their support, the picked readings, the export path;
    • identities, sources, support points, geometry, bounds and anchor positions;
    • all 37 assimilate reasons, scopes and received sets, including both evictions at the cap;
    • the receiver's state afterwards (sequences, route evidence, cells, remote reports, reported geometry, store);
    • the message fit's anchors and row counts;
    • the update's plan, attempts, accept and reason.
  • Bytes: every byte count matches, and json() writes export 0's packet character for character. All 43 repr cases match.
  • Tier: rtol 1e-9, atol 1e-12. The Gram matrices are compared against their largest entry, as GRL-SNAM's own rules test does.
  • Other tests: nav_coph_learner_test (G5–G8, unchanged numbers), nav_coph_test (12) and nav_coph_model_test (10) still pass. clang-format 18 is clean on the touched files.

Where the spec met the code

The roadmap's §4.4 now has a Landed note recording these:

  • The packet is a MazePacket, and export and assimilation run three layers, not one.
  • Bytes are BIT on the wire form. A raw export's covariance entries change their shortest repr, and so the JSON length, with their last bits, on every platform the Python runs on too. G9 counts each export rounded to 2^-24, and production byte counts are as platform-dependent as the Python's.
  • The whitening adds 0.01 + 0.005 × age, not the covariance floor. The floor is added at export.
  • H and V_task use the navigation target. That is the router's last waypoint in a live run, else the goal. So coph_learner_state gains it, along with the agent id, the clock and the exchange state.
  • Left for C5: observe's packet-side bookkeeping (local geometry reports, expiring route evidence), the rate decision and the sending.

Joe approved merging C4 when green ("merge C4 when green and continue", 2026-11-20). It merges once every check has passed, after #201.

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.
@transfix
transfix enabled auto-merge (squash) November 21, 2026 05:05
@transfix
transfix merged commit 4938ac6 into master Nov 21, 2026
29 checks passed
@transfix
transfix deleted the nav/coph-c4 branch November 21, 2026 06:12
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