Skip to content

[c-RCP-AUDIT-03] Unify 5-file conditional-request split into one module (architecture target, judgment call on value) #165

Description

@SoundMatt

Background

RELAY's docs/RCP-ARCHITECTURE.md (canonical choice #4, "Conditional-request layer") names cpp-RCP's request.hpp and rust-RCP's request.rs as the reference shape: one request-kind enum plus shared sequencer-bank, priority-tier, and ledger state, all in a single module.

c-RCP instead keeps a 5-way file split, duplicating that shared state 5 times:

src/request_compound.c    src/request_chained.c    src/request_triggered.c
src/request_timed.c       src/request_cancel.c
include/rcp/request_compound.h   (+ matching headers for the other 4)

2353 total lines across these 10 files (2026-08-07 count).

Important: this is not a bug. This session independently re-verified c-RCP's Chained and Cancel implementations are byte-precise and TC18-conformant in their current split form — unlike go-RCP's equivalent layer, which has real wire-format defects (see go-RCP's own tracked redesign, a much larger and more urgent piece of work). This issue is purely about cross-repo architectural consistency, not fixing broken behavior.

Before starting: confirm this is worth doing at all

RCP-ARCHITECTURE.md itself calls this "the largest structural change in this effort — sequenced last, after the smaller items above are stable." Given:

The agent picking this up should explicitly raise with the user whether this is worth doing now, or at all, before writing any code — do not treat "RCP-ARCHITECTURE.md names it as the target" as sufficient authorization to start a large refactor unilaterally. This mirrors the standing project convention that large, invasive, non-bug-fixing changes get flagged for explicit human sign-off rather than started autonomously (see go-RCP's conditional-envelope redesign for the same posture on a much larger, bug-driven version of this problem).

If given the go-ahead, what the target shape looks like

  1. One request-kind enum covering Compound, CompoundWait, Triggered, Chained, Timed, and the three cancellation forms (clear-all, clear-non-safestate, clear-single) — replacing the 5 separate per-file type systems.
  2. Shared sequencer-bank, priority-tier, and ledger state owned once, not duplicated per request kind.
  3. Reference the actual cpp-RCP (include/rcp/request.hpp) and rust-RCP (src/request.rs) source directly for the concrete shape — do not design from scratch or from this issue's description alone.
  4. c-RCP's own request_compound.c/request_timed.c were separately named in RCP-ARCHITECTURE.md as reference shapes for wire-layer correctness (the field-level TC18 encoding, e.g. cmp_start_state/cmp_next_state/cmp_sequencer/cmp_exec_delay/cmp_repetitions) even while being flagged for restructuring at the module-organization level — preserve that correctness; this is an organizational refactor, not a wire-format change.
  5. Requirement-id grouping (REQ-CMP-*/REQ-TRIG-*/REQ-CHAIN-*/REQ-TIMED-*/REQ-CANCEL-*) is already c-RCP's own convention and is itself the cross-repo target (canonical choice feat: v0.7.0 TLS transport — mutual TLS interface stub #7) — preserve these prefixes even as the underlying files merge.

Verification standard

  • Full native build + full test suite + ASan/UBSan build (this repo has one, use it).
  • Freshly built, CI-pinned cfusa: check 0 errors, trace --req-coverage 100 --sec-tested 100.
  • Every existing test for Compound/CompoundWait/Triggered/Chained/Timed/Cancel must still pass unchanged in behavior — this is a pure structural refactor, so any test that needs to change its assertions (not just its location/imports) is a signal something broke.
  • Mutation-test a sample of the moved logic (revert a small piece, confirm the now-missing behavior actually fails a test) to build confidence the refactor didn't silently drop coverage.

Not in scope for this issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions