Skip to content

Commit 3ba65cd

Browse files
committed
docs: add ABI contract validation gate
1 parent fd2176a commit 3ba65cd

4 files changed

Lines changed: 69 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ See `examples/` for demo programs covering basic usage, calculator-style logic,
234234
- `SPECIFICATION.md` documents the helper ABI, ISA mnemonics, and execution model.
235235
- `ROADMAP.md` sketches future work (CI, ABI stability, runtime verification).
236236
- `ENCODING.md` details the tryte-level encoding for the ISA.
237+
- `docs/abi-contract-validation.md` defines ABI drift policy and the reproducible validation command.
237238
- Run `./make_release.sh` to build a tarball release with headers and plugin artifacts.
238239

239240
## Contributing

docs/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ The repository README now lives at [`../README.md`](../README.md) so that visito
88
- [docs/MASTER_ISA.md](MASTER_ISA.md)
99
- [docs/ENCODING.md](ENCODING.md)
1010
- [`docs/examples.md`](examples.md) (guided sample programs + instructions to run `tools/quickstart.sh`)
11+
- [`docs/abi-contract-validation.md`](abi-contract-validation.md) (ABI drift policy + reproducible validation flow)

docs/abi-contract-validation.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# ABI Contract Validation
2+
3+
Roadmap linkage:
4+
- `t81-roadmap#2`
5+
- `t81-roadmap/PHASE1_STABILIZATION_MATRIX.md` (`P1-S3`)
6+
7+
This document defines the ABI contract validation path for `ternary_gcc_plugin`.
8+
9+
## Contract Scope
10+
11+
The ABI contract is the union of:
12+
13+
1. exported helper declarations in `include/ternary_runtime.h`,
14+
2. helper implementation coverage in `runtime/ternary_runtime.c`,
15+
3. helper symbol documentation in `README.md` and `docs/SPECIFICATION.md`.
16+
17+
## Drift Policy
18+
19+
Any change to helper declarations (add/remove/rename/signature change) must include:
20+
21+
1. header updates (`include/ternary_runtime.h` and related helper headers),
22+
2. runtime implementation updates,
23+
3. documentation updates (`README.md`, `docs/SPECIFICATION.md`, and this page if process changes),
24+
4. successful ABI validation run via `scripts/validate_abi_contract.sh`.
25+
26+
## Reproducible Validation
27+
28+
Run:
29+
30+
```bash
31+
scripts/validate_abi_contract.sh
32+
```
33+
34+
This command performs:
35+
36+
1. helper-doc parity check (`tools/check_helper_docs.py`),
37+
2. compile/link smoke checks against runtime ABI (`tests/test_abi.c`, `tests/test_varargs.c`),
38+
3. execution of those ABI smoke binaries.
39+
40+
## Escalation Rule
41+
42+
If ABI drift impacts downstream ecosystem contracts, link follow-up work in:
43+
44+
1. `t81-roadmap` Phase 1 tracker,
45+
2. downstream consumers (`t81-lang`, `t81-python`) when relevant.

scripts/validate_abi_contract.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
5+
BUILD_DIR="${BUILD_DIR:-$ROOT_DIR/build/abi-contract}"
6+
CC_BIN="${CC:-cc}"
7+
8+
mkdir -p "$BUILD_DIR"
9+
10+
echo "[abi] helper documentation parity"
11+
python3 "$ROOT_DIR/tools/check_helper_docs.py"
12+
13+
echo "[abi] compiling runtime and smoke tests with ${CC_BIN}"
14+
"$CC_BIN" -std=c11 -I"$ROOT_DIR/include" -c "$ROOT_DIR/runtime/ternary_runtime.c" -o "$BUILD_DIR/ternary_runtime.o"
15+
"$CC_BIN" -std=c11 -I"$ROOT_DIR/include" "$ROOT_DIR/tests/test_abi.c" "$BUILD_DIR/ternary_runtime.o" -o "$BUILD_DIR/test_abi"
16+
"$CC_BIN" -std=c11 -I"$ROOT_DIR/include" "$ROOT_DIR/tests/test_varargs.c" "$BUILD_DIR/ternary_runtime.o" -o "$BUILD_DIR/test_varargs"
17+
18+
echo "[abi] running smoke binaries"
19+
"$BUILD_DIR/test_abi"
20+
"$BUILD_DIR/test_varargs"
21+
22+
echo "[abi] validation passed"

0 commit comments

Comments
 (0)