HoldFastPlayground

Run the packet validator

Three inputs exercise destination preservation, clearing and a read-only payload view. Packet validator source

Run from the repository root with python3 on Linux or python on Windows (WSL). The tool parses and elaborates before compiling and running generated C with local C11 cc. For each edit, pass a fresh validator copy with --source PATH. Source errors and unproved contracts stop execution. Outputs below are excerpts.

A short header leaves the destination intact

Console
python tools/run.py holdfast-parser packet-example "56 02 6B"

Each hex pair is a byte. The header needs magic, payload length, checksum and flags, so PrepareAndValidatePacket refuses these three bytes. The driver sets eight destination bytes to CC and a ninth to A5 to detect writes beyond the working range.

Plain text
before CC CC CC CC CC CC CC CC A5
Err(FramingShort)
after  CC CC CC CC CC CC CC CC A5

Change the first guard from pkt.Length < 4 to pkt.Length < 3 and rerun. A three-byte packet reaches pkt[3] without a bounds proof.

A bad checksum clears the working bytes

Console
python tools/run.py holdfast-parser packet-example "56 02 FF 01 11 22"

Length and flags pass. The validator checks the supplied FF against 5A ^ 02 ^ 11 ^ 22, or 6B, before copying the packet. The working bytes were cleared after the framing guard.

Plain text
Err(ChecksumRejected)
after  00 00 00 00 00 00 00 00 A5

Change the dst.Fill(0, 8, 0x00) immediately after the framing guard to clear nine bytes. That would wipe the caller's A5 and overrun an eight-byte destination. The checker reports an unproved bound.

Success returns a read-only view of the destination

Console
python tools/run.py holdfast-parser packet-example "56 02 6B 01 11 22"

The checksum 6B passes. The caller can read both payload bytes through the returned view at offset 4 from the destination base.

Plain text
Ok copied=2 offset=4 length=2 read=1 write=0
payload 11 22
after  56 02 6B 01 11 22 00 00 A5

Replace the success return with these statements. The write has an in-bounds index and a mutable binding. The view's read-only permission causes the checker to refuse it at Span.CanWrite.

HoldFast
var payloadView = dst.Slice(4, payloadLen).ReadOnly();
if (payloadLen > 0) { payloadView[0] = 0x00; }
return Ok(ValidatedPacket(payloadLen, in payloadView));

Replay the original proofs in Rocq and run Sail capability controls with python tools/run.py holdfast-parser first-slice. Native tooling setup · Check scope and remaining target evidence