# DGR-006 — architecture-defined boundary input/output

Status: complete deterministic/offline contract and dense-fixture evidence.

## Result

The native protocol now carries a versioned `TensorBundle` on the decode fast
path. It includes explicit architecture and boundary-point metadata. Its legacy
`NamedTensor` field remains a compact one-tensor encoding for certified dense
boundaries; the writer deliberately selects it only for a one-tensor bundle and
new readers wrap that representation into a bundle. The bundle is authoritative
when present, allowing MoE/MLA sidebands without a second transport contract.

`architecture_boundary.py` is the fail-closed adapter boundary. Dense head
Shards accept token IDs and own embedding. Middle/tail Shards accept only a
validated bundle. Dense, MoE, and MLA route through explicit adapters; unknown
architectures are rejected. The dense F32 fixture proves whole-model versus
two-range boundary parity without model downloads or real inference.

Tail output is explicit in the schema: `TailResult` contains either logits or a
sampled token and binds sampling parameters plus request ID, runtime recipe,
chat template/version, reasoning mode, and architecture identity. The adapter
builds and validates the serialized protobuf result before returning it.

## Files changed

- `packages/node/native/proto/shard_runtime.proto`
- `packages/node/meshnet_node/native_protocol/{codec.py,__init__.py,conformance.py,generated/*}`
- `packages/node/native/testdata/decode_step_golden.binpb`
- `packages/node/native/tests/test_shard_protocol_conformance.cpp`
- `packages/node/meshnet_node/architecture_boundary.py`
- `tests/test_architecture_boundary.py`
- `tests/test_native_shard_protocol.py`
- `packages/node/native/README.md`

## Commands and results

All Python commands used `/run/media/popov/d/DEV/repos/d-popov.com/AI/.venv/bin/python`.
All native commands used `/run/media/popov/d/DEV/repos/d-popov.com/AI/.venv/bin/cmake`.

```text
python scripts/generate_native_protocol.py --check       -> passed
python scripts/generate_protocol_goldens.py --check      -> passed
pytest -q tests/test_architecture_boundary.py \
  tests/test_native_shard_protocol.py tests/test_llama_cpp_dependency.py
                                                    -> 59 passed
cmake -S packages/node/native -B build/native \
  -DCMAKE_PREFIX_PATH=/tmp/pbsrc/install                -> configured
cmake --build build/native -j$(nproc)                   -> built shard_protocol_conformance
ctest --test-dir build/native --output-on-failure       -> 1/1 passed
python -m compileall -q packages tests                  -> passed
git diff --check                                        -> passed
pytest -q                                               -> 917 passed, 18 skipped
```

## Compatibility and limitations

- Existing Nodes that send `DecodeStep.tensor` are accepted. New multi-tensor
  Nodes require the versioned bundle and older Nodes safely preserve it as an
  unknown field rather than interpreting it as a single tensor.
- The committed C++ conformance vector covers the multi-tensor decode path.
- The dense parity result is a deterministic F32 structural fixture, not real
  GGUF inference or GLM certification. No real inference was run.
- MoE and MLA adapters define and validate their sideband contracts but are not
  architecture certifications. DGR-019 owns GLM MoE/MLA/DSA/IndexShare semantics.

## Handoff

DGR-007 can key its Hot KV state to the validated decoded bundle. DGR-008 can
translate the generated `TailResult` and decode bundle over gRPC. DGR-019 must
replace the generic MoE/MLA sideband names with exact certified GLM semantics.
