cdk-rsx-rechain
Rechain dispatches an action through synchronous reducers and retains a bounded, canonical history in its owner-private Nyxus module. The original action is prepared once. Recording, admission checks and all expected rejections finish before the original prepared plan is committed. A failure after persistent mutation traps so IC rollback covers history, reducers and synchronous listener. No Store view crosses an await. Services are transient, nonowning bindings.
The tools bundle includes examples/rrt-chat. It binds a synchronous reducer
and starts Rechain on the shared Reactor scheduler.
Chat example
Record and read hooks
A chain declares Action, CONTRACT, record and read. The defaults record the
canonical ICWire action and allow original reads. Custom hooks declare explicit
schema, record-hook and read-hook identifiers in RecordContract. These are
application-selected semantic identities; they are not automatic source hashes.
ChainConfig::with_domain(source, genesis) binds a deployment and
with_hook_data(bytes) supplies bounded immutable, nonsecret record configuration.
Saved configuration is checked when binding. After the first action or key
installation, startup configuration cannot change that chain's domain, hook data
or contract. Admission capacities may grow, and new chains may be added.
record(action, context, hook_data) returns RecordedPayload { bytes, read_policy }. It runs before history or business mutation and receives trusted
commit metadata, including deployment, chain, index, previous hash and time.
On the IC the time comes from the system API; the native dispatch time is a test
clock. The returned bytes are the one stored representation. A transformation
must retain everything its replay reducer needs. Omitting secrets is safe only
when replay can reconstruct the intended business state without those secrets;
Rechain does not infer this property or recreate a private keystore.
read(header, original_bytes, context) returns Original, Redacted(bytes) or
Restricted. Hosts construct ReadContext::from_system() at the query boundary;
caller and current time must not come from user arguments. The per-record policy
bytes are committed with the record, so a host can implement authorized readers
and delayed publication without recomputing old deadlines. These are hooks,
not a built-in global access-control framework or reveal scheduler.
Read responses identify their disclosure explicitly. Only Original carries
the exact bytes and opening needed by ReadBlock::into_original; redactions and
restrictions cannot replay as originals. Local and archive reads use the same
configured hook. Restricted and redacted responses do not copy the original
payload into the response. Read hooks are still trusted application code and
must not leak secrets through their redactions, policy bytes or errors.
V3 commitments and replay
The fresh V3 format separates a body commitment from the public header chain:
C = BLAKE3("rechain/body-commitment/v3\0" || opening32 || len_u64_le || payload)
H = BLAKE3("rechain/header-chain/v3\0" || canonical_ICWire_header || C)
The header commits the source, genesis, chain, index, parent, commit time, contract,
blinding epoch and read policy. A public chain uses the all-zero opening. A
Blinded chain requires install_blinding_key before its first recorded dispatch.
This private native key is retained separately from actions and DTOs. Each
opening is derived with keyed BLAKE3 from that seed, the complete header and a
payload digest. There is no public or zero-key fallback. Installation accepts
an exact repeat but rejects replacement. Key rotation is not implemented.
Every read supplies the original C, so even a restricted newest tail has a
verifiable header hash. Original disclosure supplies its opening and body;
clients verify C and then H. Redactions retain the original commitment and
are not certified replacement bodies. Hiding payload bytes does not hide public
header metadata, sizes, policy data or traffic. Confidential plaintext storage
requires a host whose private memory and archive storage meet its threat model.
A public unblinded commitment does not hide low-entropy payloads.
reader::Reader pins source, genesis, chain and record contract in its own
persistent module. It assembles and validates a contiguous original prefix before
running its application callback; Restricted or Redacted records do not advance
its cursor. The application decodes the stored record schema and uses reducers
that can replay it without external authentication or omitted private material.
A callback acknowledges a leading prefix, and cursor/hash advance by exactly that
acknowledgement. Hosts own polling, backoff, authenticated transports and draining
physical calls on upgrade. Reader does not create a scheduler or detached future.
Retention, archives and certification
Payloads, headers, openings, counters and private commitment material use retained
Nyxus containers. Limits count records and the logical retained header, payload
and opening bytes; they are not physical page quotas. Read responses are bounded
by their actual encoded metadata and disclosed body, with a bounded record count.
The standard wire_get_blocks page can exceed the ordinary Wire frame cap.
Declare response_limits = cdk_rsx::wire::LARGE_PAYLOAD_LIMITS when exposing
that page budget, and check the full page through the generated client.
Wire limits and rehearsal
An optional archive::Store independently pins source, genesis and each chain's
read contract. Authenticated append retains original immutable records and checks
complete metadata and exact retries. The coordinator's internal original accessor
is for authenticated retention transfer, not a public query. Public local and
archive reads both apply their registered read hooks. Archive deployment must
install the same policy implementation and satisfy the private-storage contract.
archive::Coordinator retains exact request bytes until a source/range/hash-bound
acknowledgement releases a local prefix. Missing or rejected replies preserve
source records and uncertain work. Hosts explicitly provision archives, execute
calls through the shared Reactor and finish transfers in a fresh write frame.
Archive canister lifecycle, key provisioning, automatic age/byte maintenance and
physical-call draining remain host responsibilities.
Certified tips publish V3 chain hashes through the shared Reactor scheduler.
Start the Reactor IC controller and pass its scheduler to rechain::ic::start
on install and restore. Reactor drives deferred publication and clears its
timers on drained shutdown. Basic Rechain startup ·
Root lifecycle
Generated IC Wire clients expose the query's certificate, CBOR witness and tip
hash as Uint8Array. Earlier generated clients can still decode the reply as
byte lists.
To certify an HTTP page alongside history, follow the composed HTTP certification recipe. For new record kinds and supported old projections, see record family evolution.
Public fingerprints do not prove payload availability or that a redaction is complete. Certification trees retain IC-mandated SHA-256; application hashes and replay identities use BLAKE3. See composition, source provenance, and current native and actual-IC qualification results. Unit tests or narrow models do not establish whole-application replay or production confidentiality. There is no previous-format decoder or migration.
The V3 Heavy16 qualification measures the ordinary identity/public path against its pinned V2 control: +3.22% replicated instructions, unchanged exact work, simulated latency and grown capacity. This does not qualify high-volume private policies or actual-IC archive/Reader lifecycle.
License
This crate is available under the ICP3V License.