interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / tests / crumbline / run_crb1_conformance.sh

75 lines · 2990 bytes Raw Blame History
1#!/bin/bash
2# SPDX-License-Identifier: Apache-2.0
3# Copyright 2026 Drake Stapleton (AIEN / aien-dev)
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17# CRB1 shared conformance (migration seam 1): Omega's C reader
18# (src/crumbline/cl_crumb.c via crumbline-learner --decode) against the
19# language-neutral corpus of aien-protocols specs/crumb-visible
20# (CRUMB_READER_CONTRACT.md 1.0.0). The corpus is vendored byte for byte in
21# tests/crumbline/crb1; PIN names the source commit and the manifest sha256.
22#
23# Every outcome line must equal the contract line, except differences listed
24# in crb1_findings.txt. Those are recorded Rust-vs-C FINDINGS: neither reader
25# was changed to hide them. A difference not listed fails, and a listed
26# finding that no longer occurs also fails (keep the list honest).
27#
28# Usage: run_crb1_conformance.sh [LEARNER] [CORPUS_DIR] [FINDINGS]
29set -u
30LEARNER=${1:-build/crumbline-learner}
31DIR=${2:-tests/crumbline/crb1}
32FINDINGS=${3:-tests/crumbline/crb1_findings.txt}
33PIN=$DIR/PIN
34
35want_sha=$(sed -n 's/^manifest_sha256 //p' "$PIN")
36got_sha=$(sha256sum "$DIR/expected.txt" | cut -d' ' -f1)
37if [ "$want_sha" != "$got_sha" ]; then
38 echo "CRB1 corpus manifest does not match PIN ($got_sha != $want_sha)"
39 exit 1
40fi
41
42pass=0 fail=0 known=0 agree=0 total=0
43seen=$(mktemp)
44trap 'rm -f "$seen"' EXIT
45while read -r name want; do
46 case "$name" in '' | '#'*) continue ;; esac
47 total=$((total + 1))
48 got=$("$LEARNER" --decode "$DIR/$name" | sed 's/^decode-error /refuse /')
49 # accept/refuse agreement is tracked separately from exact codes
50 [ "${got%% *}" == "${want%% *}" ] && agree=$((agree + 1))
51 if [ "$got" == "$want" ]; then
52 pass=$((pass + 1))
53 elif grep -qxF "$name $got" <(sed -n 's/^\([^# ][^ ]*\) \(.*\) F[0-9][0-9]*$/\1 \2/p' "$FINDINGS"); then
54 known=$((known + 1))
55 echo "$name" >>"$seen"
56 else
57 fail=$((fail + 1))
58 echo "MISMATCH $name"
59 echo " want: $want"
60 echo " got: $got"
61 fi
62done <"$DIR/expected.txt"
63
64# Listed findings that did not occur are stale.
65while read -r name _; do
66 case "$name" in '' | '#'*) continue ;; esac
67 if ! grep -qxF "$name" "$seen"; then
68 fail=$((fail + 1))
69 echo "STALE FINDING $name (now matches or changed; update crb1_findings.txt and the report)"
70 fi
71done <"$FINDINGS"
72
73echo "CRB1 accept/refuse agreement: $agree/$total"
74echo "CRUMB_VISIBLE_V1_CONFORMANCE impl=c pass=$pass fail=$fail known_findings=$known"
75[ "$fail" -eq 0 ]