Skip to content

nav: the CoPH ledger's items in the episode record (C5 part 2c) - #1502

Merged
transfix merged 1 commit into
masterfrom
nav/coph-c5d
Nov 24, 2026
Merged

transfix merged 1 commit into
masterfrom
nav/coph-c5d

Conversation

@transfix

Copy link
Copy Markdown
Owner

C5 part 2c of docs/roadmap/NAV-COPH-ROADMAP.md (§4.5, D11): the episode record carries the CoPH ledger of each car a coph_driver drives.

What changes

  • The feed. While the sim's nav_stats is armed, coph_driver::apply() passes that tick's share of each attached car's account to the new sim_world::feed_coph. The next step() folds it into the collector as nav_samplers::coph. A coph_sample holds:
    • a CoPH step's work, heat, kinetic change, residual, shaping jump, unallocated work and risk cost;
    • every tick's |e|²dt and |u|²dt.
  • The record.
    • A car CoPH drove (coph_tracked) gets coph_steps, coph_work, coph_heat, coph_kinetic_change, coph_residual, coph_residual_max, coph_shaping_jumps, coph_unallocated_work, coph_risk_cost and coph_allocation_residual.
    • The episode gets coph_vehicles, the fleet's sums and the largest step residual.
  • Their own tables. The items are in plant_ledger_coph_vehicle() and plant_ledger_coph_episode(), with a new source::coph.
    • The JSON and cvcGL's publish_nav_stats write them only for what CoPH drove.
    • So every other run's output is unchanged. That includes readers that take one column or key per item of the plant tables: .cvcrun columns, the panels, and pycvc's item lists.
  • Exact sums. The driver books each term once and gives the same value to its account and to the feed, so each sum in the record equals the account's. The shaping jumps are differences of the learner's running total, so they agree to round-off.

Without nav_stats armed, feed_coph does nothing, and nothing else touches the run.

Checked on Windows (Release, MSVC 19.44)

  • nav_stats_test (18 tests): NavStats.CophLedger covers the reduction, the JSON, which items apply, and an unfed run whose record equals the fed one's minus its CoPH keys.
  • nav_coph_driver_test (7 tests):
    • TheEpisodeRecordCarriesTheCarsAccount: car 0 over 200 ticks. Every sum equals its account (99 CoPH steps, allocation residual 0.149). Car 1, driven by the sim, has no CoPH keys.
    • ARecordWithoutCophHasNoneOfItsKeys: with nav_stats armed, a driver that drives nothing leaves the JSON byte for byte as it is without a driver.
  • nav_arms_test (20) and nav_coph_fleet_test (8, G12) are unchanged.
  • clang-format 18 is clean on the changed lines.

Not checked locally: cvcGL's nav_stats_publish.cpp, because this build has CVC_BUILD_CVCGL=OFF. CI compiles and tests it.

Left out

The cross-episode scorecard (aggregate_nav), nav_arms' .cvcrun columns and pycvc's item lists don't take the CoPH items yet. Each can read them from the new tables when a reader needs them.

While a sim_world's nav_stats is armed, coph_driver::apply() feeds that tick's share of every
attached car's account to sim_world::feed_coph. The next step() folds it into the collector as
nav_samplers::coph. A coph_sample holds a CoPH step's work, heat, kinetic change, residual,
shaping jump, unallocated work and risk cost, and every tick's |e|^2 dt and |u|^2 dt.

- veh_nav_stats gains the CoPH ledger for a car CoPH drove (coph_tracked): coph_steps, work,
  heat, kinetic change, residual and its largest step |residual|, shaping jumps, unallocated
  work, risk cost, and allocation residual sqrt(sum e2 / sum u2).
- episode_nav_stats gains coph_vehicles, the fleet's work, heat and unallocated work, and the
  largest step |residual|.
- plant_ledger.h has a coph source and its own tables, plant_ledger_coph_vehicle() and
  plant_ledger_coph_episode(). The JSON and cvcGL's publish_nav_stats write them only for what
  CoPH drove. Every other run, and every reader that takes a column or key per item of the plant
  tables (nav_arms' .cvcrun columns, the panels, pycvc's lists), is unchanged.
- The driver books each term once and hands the same value to both its account and the feed, so
  each sum in the record is the account's, bit for bit. The shaping jumps are differences of the
  learner's running total, so they agree to round-off.

Tests:
- NavStats.CophLedger: the reduction, the JSON, applicability, and a run fed no terms being the
  fed one's record less its CoPH keys.
- CophDriver.TheEpisodeRecordCarriesTheCarsAccount: car 0 over 200 ticks; every sum equals its
  account.
- CophDriver.ARecordWithoutCophHasNoneOfItsKeys: armed nav_stats and a driver that drives
  nothing give the record with no driver, byte for byte.
@transfix
transfix enabled auto-merge (squash) November 23, 2026 20:59
@transfix
transfix merged commit 28da111 into master Nov 24, 2026
31 checks passed
@transfix
transfix deleted the nav/coph-c5d branch November 24, 2026 01:36
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