# Reference-generated messages

These three framed, unpacked messages were generated by the official Cap'n
Proto **1.5.0** executable from declarations in the unmodified
[`test.capnp`](../capnproto-1.5.0/capnp/test.capnp). They were not produced by the
MoonBit writer. Their source values inherit the upstream MIT license in
[`LICENSE.txt`](../capnproto-1.5.0/LICENSE.txt).

Run from the repository root in a shell with binary-safe output redirection:

```sh
capnp eval --binary -Ifixtures/upstream/capnproto-1.5.0 \
  fixtures/upstream/capnproto-1.5.0/capnp/test.capnp genericConstant \
  > fixtures/upstream/oracle-1.5.0/generic-constant.bin
capnp eval --binary -Ifixtures/upstream/capnproto-1.5.0 \
  fixtures/upstream/capnproto-1.5.0/capnp/test.capnp anyPointerConstants \
  > fixtures/upstream/oracle-1.5.0/any-pointer-constants.bin
capnp eval --binary -Ifixtures/upstream/capnproto-1.5.0 \
  fixtures/upstream/capnproto-1.5.0/capnp/test.capnp TestUseGenerics.defaultUser \
  > fixtures/upstream/oracle-1.5.0/generic-default-user.bin
```

On Windows these were generated with `cmd /c` redirection directly from the
executable, without passing binary output through a text pipeline.

| File | Root type and assertions | SHA-256 |
| --- | --- | --- |
| `generic-constant.bin` | `TestGenerics(TestAllTypes, Text)`: `foo.int16Field=123`, `rev.foo="text"`, `rev.rev.foo.int16Field=321` | `587949d070e4c519a027e4bb3c44b4a29a7b7326b5be49a5256ab93e8a44cb91` |
| `any-pointer-constants.bin` | `TestAnyPointerConstants`: `anyKindAsStruct` and `anyStructAsStruct` equal `TestConstants.structConst`; `anyKindAsList` and `anyListAsList` are `[111111111, -111111111]` | `0fc522d3a93564eb66ddb633e4dcacb733aa9f3568955c3455de078c38cb4b5c` |
| `generic-default-user.bin` | `TestUseGenerics`: `basic.foo.int16Field=123`; other null fields expose the original schema's declared defaults | `9b24aebadf118841679ffb362b194d4927a6104a57adbe1897bd10454ec980c3` |

The textual `capnp eval` output is an independent way to inspect each expected
value. Reading these vectors checks one direction only; generated MoonBit
builders still require a reverse-direction check with the reference reader.

## Null-root canonicalization regression

`null-root.bin` is an independent, hand-authored 16-byte message: segment count
minus one is zero, segment size is one word, and the root pointer is zero.
Its bytes are `00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00`.
The official converter interprets the null root as an empty struct and emits
the eight-byte canonical segment `fc ff ff ff 00 00 00 00` (empty-struct
pointer with offset -1), rather than an all-zero root pointer.

```sh
capnp convert binary:canonical < fixtures/upstream/oracle-1.5.0/null-root.bin \
  > fixtures/upstream/oracle-1.5.0/null-root.canonical.bin
```

| File | SHA-256 |
| --- | --- |
| `null-root.bin` | `c363a7bc246a6180ed9330821f26c31b9a43d94a8462e5d95d8d6face2253822` |
| `null-root.canonical.bin` | `bf355370ac5d9c7ee6422a1d1e4c226ff680abfdbbb0529aa2ed5ccc3669f03ec` |

## Independent canonical boundary vectors

[`canonical-vectors.mbtx`](canonical-vectors.mbtx) generates eight additional
input messages directly from independent UInt64 wire words; it does not import
the project runtime. Each `.canonical.bin` was then produced with the official
1.5.0 converter. Regenerate input from the repository root with:

```sh
moon run --target js --deny-warn fixtures/upstream/oracle-1.5.0/canonical-vectors.mbtx
```

For each name in the table, run `capnp convert binary:canonical` with binary-safe
stdin/stdout redirection from `<name>.bin` to `<name>.canonical.bin` in this
directory, as in the null-root command above.

| Name | Condition | Expected canonical bytes | SHA-256 of `.canonical.bin` |
| --- | --- | ---: | --- |
| `bool-padding` | Nine true bits; dirty unused high bits and word padding must be cleared | 24 | `20385a4f49c583b3a4501fb86d8ae78aa6758bb095b551d69de743f06676b282` |
| `data-padding` | Three data bytes with dirty word padding | 24 | `db14ab1fdc2d11620c7fcff12c34fcf1783a62bf274d010765876c1ce76d530f` |
| `inline-trim` | Three struct elements need different data/pointer extents; trim uniformly to maximum live sections | 104 | `0e89494b80ad0fed7f0d6b4406e3f7c5513b22d1d473e2b5072b357440f5d47a` |
| `inline-all-zero` | Nonzero-size all-zero structs become zero-size list elements without losing count | 24 | `46f2ae1daee662173d5d6769ef9670c5c04bb855dd43b6618307321685069b48` |
| `empty-list-order` | Empty Void/bit/byte/pointer/composite lists retain kinds and preorder offsets | 56 | `4c6009a5e20ba2803d3c2c64ff59dc203aa098f955684521c1c066a94309a50b` |
| `nested-far` | Four segments with single-far root, double-far child, and empty Data | 32 | `4ca68e03e478f6488205fb3a330e3e250d0075909c84ffc7aae0bbb80a09dc78` |
| `far-empty-child` | A zero landing tag denotes a present empty struct, not a null pointer | 16 | `7ea5eff463aac5a4504ba4bd340b619e82b9c9d3ee4da583cd2b868f62bf3c18` |
| `reverse-allocation` | Children physically allocated in reverse order; an unreachable word must be omitted | 40 | `c23beaa2007eff2e6c4f1fe92f65167d75f1861111e3d183ff380043c47a0633` |

The padding vectors deliberately contain nonzero unused padding, so the test is
normalization behavior accepted by the reference converter, not an endorsement
of emitting such padding. The vector generator is project-authored MIT test
code; these `.bin` inputs are not described as unmodified upstream files.
