|
7 | 7 | - "specs/**" |
8 | 8 | - "gen/**" |
9 | 9 | - "build.rs" |
| 10 | + - ".t27c-version" |
10 | 11 | - ".github/workflows/spec-drift-guard.yml" |
11 | 12 |
|
12 | | -# Rebuild t27c from upstream master and regenerate every committed backend |
13 | | -# under gen/<target>/<spec>.<ext> from specs/<spec>.t27. If any committed |
14 | | -# output disagrees with the freshly generated output, the job fails with a |
15 | | -# diff so drift between the SSOT and generated code cannot land silently. |
| 13 | +# PHYSICAL GUARD for the golden pipeline: specs/*.t27 -> t27c gen-rust -> gen/rust. |
16 | 14 | # |
17 | | -# Covered specs (68) × backends (3) = 204 drift checks: |
18 | | -# wire.t27 → gen/{rust,wire.rs} gen/{zig,wire.zig} gen/{c,wire.c} |
19 | | -# hello.t27 → gen/{rust,hello.rs} gen/{zig,hello.zig} gen/{c,hello.c} |
20 | | -# etx.t27 → gen/{rust,etx.rs} gen/{zig,etx.zig} gen/{c,etx.c} |
| 15 | +# The compiler is PINNED (.t27c-version). This job rebuilds t27c at exactly that |
| 16 | +# commit, regenerates every gen/rust/*.rs from specs/*.t27, and fails on ANY byte |
| 17 | +# difference against the committed output. That makes three classes of the |
| 18 | +# recurring breakage impossible to land: |
| 19 | +# 1. committing gen/rust produced by a stale/wrong t27c (the 2026-07-07 break), |
| 20 | +# 2. hand-editing gen/rust directly, |
| 21 | +# 3. editing a spec without regenerating. |
| 22 | +# It then builds + tests the tree so a green gen set that does not compile is |
| 23 | +# also caught. Rust is NEVER written by hand in gen/; it is generated only. |
21 | 24 | # |
22 | | -# ExprCast is lowered in all three backends via t27#1320 (Rust) + t27#1337 (Zig+C). |
23 | | -# See docs/T27_FIRST_MIGRATION.md for the SSOT contract. |
| 25 | +# Only the rust backend is checked -- the gen/zig and gen/c backends were removed |
| 26 | +# from the tree, so the old "68 x 3 backends" guard was checking deleted paths. |
24 | 27 | # Anchor: phi^2 + phi^-2 = 3. |
25 | 28 |
|
26 | 29 | jobs: |
27 | | - regenerate-and-diff: |
28 | | - name: drift check (68 specs × 3 backends) |
| 30 | + drift: |
| 31 | + name: gen/rust drift vs pinned t27c |
29 | 32 | runs-on: ubuntu-latest |
30 | 33 | steps: |
31 | 34 | - name: Checkout tri-net |
32 | 35 | uses: actions/checkout@v4 |
33 | | - with: |
34 | | - path: tri-net |
35 | 36 |
|
36 | | - - name: Checkout t27 (SSOT compiler source) |
| 37 | + - name: Read pinned t27c commit |
| 38 | + id: pin |
| 39 | + run: echo "sha=$(grep -vE '^[[:space:]]*#' .t27c-version | grep -oE '[0-9a-f]{40}' | head -1)" >> "$GITHUB_OUTPUT" |
| 40 | + |
| 41 | + - name: Checkout t27 at pinned commit |
37 | 42 | uses: actions/checkout@v4 |
38 | 43 | with: |
39 | 44 | repository: gHashTag/t27 |
40 | | - ref: master |
| 45 | + ref: ${{ steps.pin.outputs.sha }} |
41 | 46 | path: t27 |
42 | 47 |
|
43 | | - - name: Install stable Rust toolchain |
44 | | - uses: dtolnay/rust-toolchain@stable |
| 48 | + - uses: dtolnay/rust-toolchain@stable |
45 | 49 |
|
46 | | - - name: Build t27c (release) |
47 | | - working-directory: t27 |
48 | | - run: cargo build --release --manifest-path bootstrap/Cargo.toml --bin t27c |
| 50 | + - name: Build pinned t27c |
| 51 | + run: cargo build --release -p t27c --manifest-path t27/Cargo.toml |
49 | 52 |
|
50 | | - - name: Drift check — Rust (all specs) |
51 | | - working-directory: tri-net |
| 53 | + - name: Regenerate every gen/rust from specs |
52 | 54 | run: | |
53 | | - T27C=../t27/target/release/t27c |
54 | | - STATUS=0 |
55 | | - for spec in wire hello etx crc16 byte_utils mesh_routing key_management frame_buffer packet_queue congestion_control flow_control self_healing trust_manager timer transport_tx_fsm redundancy_management fault_detection lite_crypto network_metrics m3_multihop link_statistics access_control bandwidth_allocator cache_management compression_engine cross_layer_optimizer energy_aware_routing adaptive_retry link_quality_monitor multipath_router auto_config adaptive_routing anomaly_detector api_documenter area_optimization docs_generator fpga_synthesis_report health_dashboard health_monitoring integration_tests load_predictor local_processing mesh_node_sim mesh_protocol_stack multipath_routing network_coding network_orchestrator network_simulator olsr_routing pattern_predictor performance_benchmarks performance_profiler power_monitoring production_deployment production_scenarios quarantine_manager resource_scheduler swarm_coordinator test_framework timing_closure topology_visualizer traffic_animator failure_predictor hardware_validation integration_framework network_analytics packet_loss_injection test_validator; do |
56 | | - $T27C gen-rust specs/${spec}.t27 > /tmp/${spec}_regen.rs |
57 | | - if ! diff -u gen/rust/${spec}.rs /tmp/${spec}_regen.rs; then |
58 | | - echo "::error file=gen/rust/${spec}.rs::DRIFT: gen/rust/${spec}.rs != t27c gen-rust specs/${spec}.t27" |
59 | | - echo "Fix: t27c gen-rust specs/${spec}.t27 > gen/rust/${spec}.rs" |
60 | | - STATUS=1 |
61 | | - else |
62 | | - echo "gen/rust/${spec}.rs matches specs/${spec}.t27" |
63 | | - fi |
| 55 | + T27C="t27/target/release/t27c" |
| 56 | + for spec in specs/*.t27; do |
| 57 | + name="$(basename "$spec" .t27)" |
| 58 | + "$T27C" gen-rust "$spec" > "gen/rust/${name}.rs" |
64 | 59 | done |
65 | | - exit $STATUS |
66 | 60 |
|
67 | | - - name: Drift check — Zig (all specs) |
68 | | - working-directory: tri-net |
| 61 | + - name: Fail on any drift |
69 | 62 | run: | |
70 | | - T27C=../t27/target/release/t27c |
71 | | - STATUS=0 |
72 | | - for spec in wire hello etx crc16 byte_utils mesh_routing key_management frame_buffer packet_queue congestion_control flow_control self_healing trust_manager timer transport_tx_fsm redundancy_management fault_detection lite_crypto network_metrics m3_multihop link_statistics access_control bandwidth_allocator cache_management compression_engine cross_layer_optimizer energy_aware_routing adaptive_retry link_quality_monitor multipath_router auto_config adaptive_routing anomaly_detector api_documenter area_optimization docs_generator fpga_synthesis_report health_dashboard health_monitoring integration_tests load_predictor local_processing mesh_node_sim mesh_protocol_stack multipath_routing network_coding network_orchestrator network_simulator olsr_routing pattern_predictor performance_benchmarks performance_profiler power_monitoring production_deployment production_scenarios quarantine_manager resource_scheduler swarm_coordinator test_framework timing_closure topology_visualizer traffic_animator failure_predictor hardware_validation integration_framework network_analytics packet_loss_injection test_validator; do |
73 | | - $T27C gen specs/${spec}.t27 > /tmp/${spec}_regen.zig |
74 | | - if ! diff -u gen/zig/${spec}.zig /tmp/${spec}_regen.zig; then |
75 | | - echo "::error file=gen/zig/${spec}.zig::DRIFT: gen/zig/${spec}.zig != t27c gen specs/${spec}.t27" |
76 | | - echo "Fix: t27c gen specs/${spec}.t27 > gen/zig/${spec}.zig" |
77 | | - STATUS=1 |
78 | | - else |
79 | | - echo "gen/zig/${spec}.zig matches specs/${spec}.t27" |
80 | | - fi |
81 | | - done |
82 | | - exit $STATUS |
| 63 | + if ! git diff --quiet -- gen/rust/; then |
| 64 | + echo "::error::gen/rust drifted from specs/*.t27 under the pinned t27c." |
| 65 | + echo "Regenerate locally with the pinned t27c and commit the result;" |
| 66 | + echo "never hand-edit gen/rust or use an unpinned compiler." |
| 67 | + git --no-pager diff --stat -- gen/rust/ |
| 68 | + git --no-pager diff -- gen/rust/ | head -200 |
| 69 | + exit 1 |
| 70 | + fi |
| 71 | + echo "gen/rust is in sync with specs under the pinned t27c." |
83 | 72 |
|
84 | | - - name: Drift check — C (all specs) |
85 | | - working-directory: tri-net |
| 73 | + - name: Build + test the regenerated tree |
86 | 74 | run: | |
87 | | - T27C=../t27/target/release/t27c |
88 | | - STATUS=0 |
89 | | - for spec in wire hello etx crc16 byte_utils mesh_routing key_management frame_buffer packet_queue congestion_control flow_control self_healing trust_manager timer transport_tx_fsm redundancy_management fault_detection lite_crypto network_metrics m3_multihop link_statistics access_control bandwidth_allocator cache_management compression_engine cross_layer_optimizer energy_aware_routing adaptive_retry link_quality_monitor multipath_router auto_config adaptive_routing anomaly_detector api_documenter area_optimization docs_generator fpga_synthesis_report health_dashboard health_monitoring integration_tests load_predictor local_processing mesh_node_sim mesh_protocol_stack multipath_routing network_coding network_orchestrator network_simulator olsr_routing pattern_predictor performance_benchmarks performance_profiler power_monitoring production_deployment production_scenarios quarantine_manager resource_scheduler swarm_coordinator test_framework timing_closure topology_visualizer traffic_animator failure_predictor hardware_validation integration_framework network_analytics packet_loss_injection test_validator; do |
90 | | - $T27C gen-c specs/${spec}.t27 > /tmp/${spec}_regen.c |
91 | | - if ! diff -u gen/c/${spec}.c /tmp/${spec}_regen.c; then |
92 | | - echo "::error file=gen/c/${spec}.c::DRIFT: gen/c/${spec}.c != t27c gen-c specs/${spec}.t27" |
93 | | - echo "Fix: t27c gen-c specs/${spec}.t27 > gen/c/${spec}.c" |
94 | | - STATUS=1 |
95 | | - else |
96 | | - echo "gen/c/${spec}.c matches specs/${spec}.t27" |
97 | | - fi |
98 | | - done |
99 | | - exit $STATUS |
| 75 | + cargo build --all-targets --verbose |
| 76 | + cargo test --verbose |
0 commit comments