Skip to content

rewrite(phase4): mock.hpp batch B — Table 24 response suppression + regmap/discovery wiring - #147

Merged
SoundMatt merged 1 commit into
rewrite/v3-from-c-rcpfrom
phase4/mock-b
Aug 22, 2026
Merged

SoundMatt merged 1 commit into
rewrite/v3-from-c-rcpfrom
phase4/mock-b

Conversation

@SoundMatt

Copy link
Copy Markdown
Owner

Part of the v3.0.0 ground-up rewrite (#129, ROADMAP.md Phase 17), branch rewrite/v3-from-c-rcp. Phase 4 batch B of a four-batch mock.hpp port, built on batch A's server::Endpoint admission wiring.

Ported

  • Table 24 response suppression (REQ-RMAP-048/049): suppress_response_per_stream_cfg(), resolving stream_id and zeroing the response when the resolved stream's rx_ack_stream_index/rx_resp_stream_index is 0.
  • Storage: set_request_stream_cfg()/set_ep_id_map() (REQ-RMAP-034/037), bounds-checked, syncing capacity fields.
  • Discovery wiring (REQ-RMAP-066): discovery::DiscoveryClaim member, getter, set_discovery_timeout_us(). Confirmed by direct source read that c-RCP's own mock.c never wires the claim into dispatch, so nothing beyond storage was added.

dispatch_* changes

Each of the ten operational dispatch_*() functions renamed to dispatch_*_inner() (unchanged batch-A body), with a thin wrapper calling _inner then the suppression step — mirroring c-RCP's dispatch_plain()/dispatch_plain_inner() split. dispatch() gained a trailing, defaulted stream_id parameter; the default preserves all pre-existing call-site behavior.

Bug found and fixed

make_initial_register_map()'s ten default ep_id_mapping rows all left request_stream_index at 0 — TC18's own end-of-table sentinel — which would make ep_id_map::effective_count() read the whole populated table as zero rows. Fixed to 1, matching the power-on convention. Inert today, fixes future batch-C consumers.

Small addition to discovery.hpp

Added DiscoveryClaim::set_timeout() — needed to re-derive the claim's window from a new register value without resetting the held claim, matching c-RCP's documented contract.

Verification

Existing 60 tests pass unmodified. 11 new TEST_CASEs: bug-fix assertions, bounds checks, 5 Table-24 suppression tests, a sweep across all ten endpoint types, 3 discovery-claim tests. mock.hpp: 1387→1759 lines. test_mock.cpp: 1285→1561 lines, 60→71 TEST_CASEs (583 assertions).

Full tree rebuilds clean (0 errors/warnings), 58/58 ctest suites pass (100%) — independently re-verified from a fresh build.

…egmap/discovery wiring

Part of the v3.0.0 ground-up rewrite (cpp-RCP #129, ROADMAP.md Phase 17),
branch rewrite/v3-from-c-rcp. Phase 4 batch B of a four-batch mock.hpp
port, built on batch A's server::Endpoint admission wiring.

## Ported (c-RCP src/mock.c -> mock::Server)

- Table 24 response suppression (src/mock.c:1716-1760, REQ-RMAP-048/049):
  new private static Server::suppress_response_per_stream_cfg(),
  resolving stream_id via regmap::request_stream_cfg::resolve_index()
  and zeroing out_resp/out_resp_payload when the resolved stream's
  rx_ack_stream_index (Acknowledge-classified responses) or
  rx_resp_stream_index (everything else) is 0.
- Storage: Server::set_request_stream_cfg()/request_stream_cfg() and
  set_ep_id_map()/ep_id_map(), mirroring c-RCP's
  rcp_mock_server_set_request_stream_cfg()/_set_ep_id_map()
  (src/mock.c:444-460/565-580), bounds-checked against
  regmap::request_stream_cfg::kMaxEntries/regmap::ep_id_map::kMaxEntries,
  syncing svr_request_stream_cfg_capacity/svr_ep_bytebus_id_map_capacity
  (REQ-RMAP-034/037).
- Discovery wiring (mock.h:501-529, src/mock.c:663-687, REQ-RMAP-066):
  discovery::DiscoveryClaim member, discovery_claim() getter,
  set_discovery_timeout_us() keeping it and
  regs_.svr_ep_cfg.svr_discovery_timeout in sync. Confirmed by direct
  source read that c-RCP's own mock.c never wires the claim into
  dispatch, so nothing beyond storage was added.

## dispatch_* changes

Each of the ten operational dispatch_*() functions (gpio/spi/i2c/adc/
pwm_in/lin/can/uart/iseled/mdio) renamed to dispatch_*_inner()
(unchanged batch-A body), with a new thin dispatch_*() wrapper calling
_inner then suppress_response_per_stream_cfg() -- mirroring c-RCP's
dispatch_plain()/dispatch_plain_inner() split, generalized per
endpoint type. dispatch() gained a trailing, defaulted
avtp::StreamId stream_id parameter threaded to all ten; the default
resolves to "no stream configured," so no pre-existing call site's
behavior changes. dispatch_ep0() left untouched (not one of the ten
operational endpoints).

## Bug found and fixed

make_initial_register_map()'s ten default ep_id_mapping rows all left
request_stream_index at its struct default (0) -- TC18's own
end-of-table sentinel -- which would make
regmap::ep_id_map::effective_count() read the whole populated table as
zero rows. Fixed to 1 (matching row_init_default()'s own power-on
convention); also fixed svr_ep_bytebus_id_map_capacity to sync to 10.
Neither was exercised by existing tests, so this is inert today but
fixes future batch-C consumers (broadcast_safe_state, sequencer access
control).

## Small addition to already-merged discovery.hpp

Added DiscoveryClaim::set_timeout() -- batch B's
set_discovery_timeout_us() needed a way to re-derive the claim's
window from a new register value without resetting holder_/
claimed_at_ (c-RCP's own documented contract), and no such mutator
existed.

## Verification

Existing 60 test cases required no changes (default request_streams
table is empty, so suppression is a no-op unless a test opts in). 11
new TEST_CASEs added: ep_id_mapping bug-fix assertions, bounds-check
tests, 5 Table-24 suppression tests ported from c-RCP's
tests/test_mock.c:1061-1204, one sweep across all ten endpoint types,
3 discovery-claim tests ported from tests/test_mock.c:1917-1980
(adapted to DiscoveryClaim's steady_clock-based API).

include/rcp/mock.hpp: 1387 -> 1759 lines. tests/test_mock.cpp: 1285 ->
1561 lines, 60 -> 71 TEST_CASEs (583 assertions). include/rcp/
discovery.hpp: 818 -> 837 lines. Full tree rebuilds clean (0 errors, 0
warnings), 58/58 ctest suites pass (100%) -- independently re-verified
from a fresh build, not just the porting agent's own report.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: Matt <47545907+SoundMatt@users.noreply.github.com>
@SoundMatt
SoundMatt merged commit a7a1244 into rewrite/v3-from-c-rcp Aug 22, 2026
22 checks passed
@SoundMatt
SoundMatt deleted the phase4/mock-b branch August 22, 2026 06:47
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