The Principia Machina/TPC-PY/gen record corpus.py: Difference between revisions
Appearance
TPC-PY source gen_record_corpus.py (0.1.0), SHA-256 0588448729d0dd0f; conformed TPS 0.4.0; PROPOSED, not declared (TPC-PY 0.2.0) |
m 1 revision imported |
||
(No difference)
| |||
Latest revision as of 02:11, 30 September 2026
# -*- coding: utf-8 -*-
"""gen_record_corpus 0.1.0 (agent TQ, increment 12; agent TQ3, wave 5):
writes vectors/record_corpus.json, the vectors of tpc_record 0.1.0
(proposed), from tpm_record_schema 0.4.0 (sections 8-14) and
tpm_record_functions 0.3.0 (sections 3-8, 11, 13-16).
0.3.0/0.2.0 (READY_E5; S107, S108): prec_decimal and a RESULT's U_C in its
precision form (the PD, BC29-BC39, RD020-RD027 and RP006-RP009 cases; BC27
re-expected); REC-54's article (F-GV2-11).
0.4.0/0.3.0 (wave 5; tpm_w5_change_note 0.1.0, section 3): the user's
answers D214.1, D215.2 and D218.1 (tpm_post_tpcpy_selections 0.4.0); no
case name carries a drafted item's mark (S105, S114). D215.2 re-expresses
25 cases (an inherited record lands at its class's landing grade, REC-32
whatever INHERITS, REC-40 retired; schema_json's GRADE the LANDGRADE alone)
and adds 12 (the WITHDRAWAL's cause INHERITED: GN-Q, GN-R, SWS5, RB08,
WR04, WX33-WX39).
VECTORS FIRST. Every expectation below is a literal of this generator,
written from the specification text before tpc_record existed, in TPM's
canonical JSON (tpm_record_schema 11.4), which this generator writes with
its own writer (cj). Values the specification leaves to an existing TPC
function (a unit or form refusal's reason, t2_findings' text, a zone
digest) are taken from that existing function over literal data; nothing
here calls tpc_record. Digests are recomputed here with hashlib over a
netstring built by hand and must equal the specification's literals where
it prints them (9.8, 16.2-16.4). A few families (every required field
missing, one at a time) are written by a one-line template per case.
The table (section 7.5) is embedded here as its text, a third copy beside
tpc_record.py's and tpc_record.php's; tools outside the tree check each
copy against the specification.
Run from tpc/: python gen_record_corpus.py (standard library only)
"""
import copy
import hashlib
import json
import os
import sys
HERE = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, HERE)
import tpc_digest as G # noqa: E402 existing functions, read only
import tpc_form as F # noqa: E402
import tpc_tests as TT # noqa: E402
import tpc_units as U # noqa: E402
import tpc_zone as Z # noqa: E402
CORPUS_VERSION = "0.1.0"
CASES = []
# ---------------------------------------------------------------- helpers
def cj(v):
"""TPM canonical JSON (tpm_record_schema 11.4), written here."""
if v is True:
return "true"
if v is False:
return "false"
if v is None:
return "null"
if type(v) is int:
return str(v)
if type(v) is str:
out = ['"']
for ch in v:
if ch == '"':
out.append('\\"')
elif ch == "\\":
out.append("\\\\")
elif ord(ch) < 0x20:
out.append("\\u%04x" % ord(ch))
else:
out.append(ch)
out.append('"')
return "".join(out)
if type(v) is list:
return "[" + ",".join(cj(x) for x in v) + "]"
if type(v) is dict:
return "{" + ",".join(cj(k) + ":" + cj(v[k]) for k in sorted(v)) + "}"
raise TypeError(type(v))
def add(name, fn, args, expected):
CASES.append({"name": name, "fn": fn, "args": args, "expected": expected})
def ok():
return '["OK"]'
def refused(*probs):
ps = sorted(set(tuple(p) for p in probs))
return cj(["REFUSED", [list(p) for p in ps]])
def netstring(fields):
b = b""
for f in fields:
x = str(f).encode("utf-8")
b += str(len(x)).encode("ascii") + b":" + x
return b
def sha(fields):
return hashlib.sha256(netstring(fields)).hexdigest()
def chk(name, record, expected, tfk=None, setting=None, stage="LANDED"):
add(name, "record_check", {"record": record, "tfk": tfk, "setting": setting,
"stage": stage}, expected)
def without(rec, *keys):
r = copy.deepcopy(rec)
for k in keys:
r.pop(k, None)
return r
def withf(rec, **kv):
r = copy.deepcopy(rec)
r.update(kv)
return r
# ---------------------------------------------------------------- fixtures
DIS = "7f1e6c0d2b9a4e3f8c5d1a0b6e2f4c9d3a8b7e1f0c6d5a4b3e2f1d0c9b8a7e6f"
T0 = "2026-09-28T12:00:00Z"
with open(os.path.join(HERE, "examples", "spring_draft.json"), encoding="utf-8") as _f:
TFK = json.load(_f) # the tree's own example TFK (read only)
D_TPK = Z.d_tpk(TFK["TPK"])
D_TRM = Z.d_trm(TFK["TrM"])
D_TMS = Z.d_tms(TFK["TMS"])
D_TFK = G.d_tfk(D_TPK, D_TRM, D_TMS)
assert D_TPK == "ad9d20d633d374edf7f7a2ddfefa6e886e67132a6e8a7cd42edd0237d3927088"
ENV = {"GRADE": "PROVISIONAL", "STATUS": "UNMARKED", "BLOCK": "B-1",
"AUTHOR": "agent-a", "LANDED_BY": "agent-a", "LANDED": T0,
"CITES": [], "ASSUMPTIONS": [], "TPS": "0.4.0", "D_IS": DIS}
TPX_ENV = ["GRADE", "STATUS", "BLOCK", "AUTHOR", "LANDED_BY", "LANDED", "VETTED_IN",
"INHERITS", "TPS", "D_IS", "DIGEST"]
def rec(rid, cls, **kv):
r = {"ID": rid, "CLASS": cls}
r.update(copy.deepcopy(ENV))
r.update(kv)
return r
RES_L = rec("RR-10", "RESULT", STATEMENT="The period does not depend on the amplitude.",
REGIME="L", DERIVATION={"STEPS": 2, "TEXT": "Two steps."},
FALSIFIER="A period that changes with the amplitude.", FALSIFIER_CLASS="F2")
# tpm_record_schema 9.8, RECORD A and RECORD B, exactly
REC_A = {"ASSUMPTIONS": [], "AUTHOR": "agent-a", "BLOCK": "B-4", "CITES": [],
"CLASS": "ASSUMPTION", "D_IS": DIS, "GRADE": "PROVISIONAL", "ID": "RR-2",
"LANDED": "2026-09-28T12:00:00Z", "LANDED_BY": "agent-a",
"PROPOSITION": "The pivot of the pendulum does not move.", "REFS": ["L"],
"STATUS": "UNMARKED", "TPS": "0.4.0"}
REC_B = {"ASSUMPTIONS": ["RR-5", "RR-2"], "AT": [{"DOF": "t", "UNIT": "s", "VALUE": "0"}],
"AUTHOR": "agent-b", "BLOCK": "B-9",
"BUDGET": [{"BASIS": "Ten repeated timings.", "EVALUATION": "A", "NAME": "timing",
"U": "0.0010", "UNIT": "s"},
{"BASIS": "Tape resolution, rectangular.", "EVALUATION": "B",
"NAME": "length", "U": "0.66", "UNIT": "ms"}],
"CITES": ["RR-3"], "CLASS": "RESULT",
"DERIVATION": {"STEPS": 3, "TEXT": "Ten swings timed; the mean taken; the budget below."},
"D_IS": DIS, "ENTRIES": ["period"],
"FALSIFIER": "A period outside the stated interval at the same length.",
"FALSIFIER_CLASS": "F3", "GRADE": "PROVISIONAL", "ID": "RR-7",
"LANDED": "2026-09-28T12:05:00Z", "LANDED_BY": "agent-a", "QUANTITY": "period",
"REGIME": "M", "STATEMENT": "The measured period of the pendulum at the stated length.",
"STATUS": "UNMARKED", "TPS": "0.4.0", "UNIT": "s", "U_C": "0.0012", "VALUE": "2.0070",
"VETTED_IN": "B-10"}
# an M RESULT over the example TFK (entry E_x, L1; DOF t, T1)
RES_M = rec("RR-11", "RESULT", STATEMENT="The amplitude measured at t = 0.",
REGIME="M", DERIVATION={"STEPS": 1, "TEXT": "Read off the scale."},
FALSIFIER="A second reading outside the interval.", FALSIFIER_CLASS="F3",
ENTRIES=["E_x"], QUANTITY="E_x", VALUE="0.0100", UNIT="m", U_C="0.0005",
BUDGET=[{"NAME": "scale", "U": "0.5", "UNIT": "mm", "EVALUATION": "B",
"BASIS": "Half the smallest division."}],
AT=[{"DOF": "t", "VALUE": "0", "UNIT": "s"}])
ASM_SIT = rec("RR-3", "ASSUMPTION", PROPOSITION="The initial displacement is one centimetre.",
REFS=["x"], SITUATION="INITIAL", DOF="x", VALUE="0.01", UNIT="m",
AT=[{"DOF": "t", "VALUE": "0", "UNIT": "s"}])
IND = {"ACCOUNT": "agent-b", "SNAPSHOT": "snap-1", "VENDOR": "vendor-1",
"IMPLEMENTATION": "impl-1", "ORIGIN": "REPRODUCTION BLOCK",
"NOT_SERVED_BEFORE": True, "SAME_SPONSOR": False, "SAME_MODEL": False}
CORR = rec("RR-20", "CORROBORATION", TARGET="RR-10", OUTCOME="MATCH", INDEPENDENCE=IND,
TARGET_STATUS="PROVISIONAL")
CORR["AUTHOR"] = "agent-b"
VER = rec("RR-30", "VERIFICATION", REGIME="M", TARGET="RR-7",
EXTERNAL={"VALUE": "2.0064", "U_C": "0.0005", "UNIT": "s", "QUANTITY": "period"},
SOURCE="Handbook, table 3.",
DIFFERENCE={"VALUE": "6e-4", "U": "13e-4", "ZETA": "461538461538e-12"})
GAP = {"ID": "RR-2", "CLASS": "NAMED_GAP", "GRADE": "NOT GRADED", "LANDED_BY": "TPX",
"LANDED": T0, "TPS": "0.4.0", "SOURCE": "IC2", "AGAINST": ["z"],
"TRIGGER": "DECLARATIONS Volume 1, line 7",
"STATEMENT": "The DOF z is tied by no TrM entry (IC2).", "STATE": "OPEN"}
ES = rec("RR-40", "ENTRY_STATUS", GRADE="NOT GRADED", ENTRY="E_x", NOTE="Scrutiny pending.")
MASTER = {"ID": "RR-1", "CLASS": "MASTER", "GRADE": "NOT GRADED", "LANDED_BY": "TPX",
"LANDED": T0, "TPS": "0.4.0", "UUID": "123e4567-e89b-42d3-a456-426614174000",
"PREFIX": "RR", "D_TPK": D_TPK, "D_TRM": D_TRM, "D_TMS": D_TMS, "D_TFK": D_TFK,
"CERTIFICATE": "DECLARATIONS Volume 1, line 7",
"STRUCTURE_LINE": "structurally regular", "MODULES_USED": "none"}
REQUIRED_LANDED = { # REQ R fields per class (table 7.5), in table order
"RESULT": ["ID", "CLASS", "GRADE", "STATUS", "BLOCK", "AUTHOR", "LANDED_BY", "LANDED",
"CITES", "ASSUMPTIONS", "TPS", "D_IS", "STATEMENT", "REGIME", "DERIVATION",
"FALSIFIER", "FALSIFIER_CLASS"],
"ASSUMPTION": ["ID", "CLASS", "GRADE", "STATUS", "BLOCK", "AUTHOR", "LANDED_BY", "LANDED",
"CITES", "ASSUMPTIONS", "TPS", "D_IS", "PROPOSITION", "REFS"],
"CORROBORATION": ["ID", "CLASS", "GRADE", "STATUS", "BLOCK", "AUTHOR", "LANDED_BY",
"LANDED", "CITES", "ASSUMPTIONS", "TPS", "D_IS", "TARGET", "OUTCOME",
"INDEPENDENCE", "TARGET_STATUS"],
"VERIFICATION": ["ID", "CLASS", "GRADE", "STATUS", "BLOCK", "AUTHOR", "LANDED_BY",
"LANDED", "CITES", "ASSUMPTIONS", "TPS", "D_IS", "REGIME", "TARGET",
"EXTERNAL", "SOURCE", "DIFFERENCE"],
"NAMED_GAP": ["ID", "CLASS", "GRADE", "LANDED_BY", "LANDED", "TPS", "SOURCE", "AGAINST",
"TRIGGER", "STATEMENT", "STATE"],
"ENTRY_STATUS": ["ID", "CLASS", "GRADE", "STATUS", "BLOCK", "AUTHOR", "LANDED_BY",
"LANDED", "CITES", "ASSUMPTIONS", "TPS", "D_IS", "ENTRY"],
"MASTER": ["ID", "CLASS", "GRADE", "LANDED_BY", "LANDED", "TPS", "UUID", "PREFIX",
"D_TPK", "D_TRM", "D_TMS", "D_TFK", "CERTIFICATE", "STRUCTURE_LINE",
"MODULES_USED"],
}
TPX_FIELDS = {c: ["GRADE", "STATUS", "BLOCK", "AUTHOR", "LANDED_BY", "LANDED", "VETTED_IN",
"INHERITS", "TPS", "D_IS", "DIGEST"] for c in REQUIRED_LANDED}
TPX_FIELDS["CORROBORATION"] = TPX_FIELDS["CORROBORATION"] + ["OUTCOME", "DIFFERENCE",
"INDEPENDENCE", "TARGET_STATUS"]
def push_form(r):
return {k: copy.deepcopy(v) for k, v in r.items() if k not in TPX_FIELDS[r["CLASS"]]}
P = lambda code, field, msg: [code, field, msg] # noqa: E731
# ============================================================ record_check
# the minimal valid record of each keyed class, at LANDED and at PUSH
chk("RC001 RESULT L minimal, LANDED", RES_L, ok())
chk("RC002 RESULT L minimal, PUSH", push_form(RES_L), ok(), stage="PUSH")
chk("RC003 RESULT M (9.8 RECORD B), LANDED, no TFK", REC_B, ok())
chk("RC004 RESULT M (9.8 RECORD B), PUSH", push_form(REC_B), ok(), stage="PUSH")
chk("RC005 ASSUMPTION (9.8 RECORD A), LANDED", REC_A, ok())
chk("RC006 ASSUMPTION, PUSH", push_form(REC_A), ok(), stage="PUSH")
chk("RC007 CORROBORATION, LANDED", CORR, ok())
chk("RC008 CORROBORATION, PUSH (TPX writes OUTCOME, INDEPENDENCE, TARGET_STATUS)",
push_form(CORR), ok(), stage="PUSH")
chk("RC009 VERIFICATION, LANDED", VER, ok())
chk("RC010 VERIFICATION, PUSH", push_form(VER), ok(), stage="PUSH")
chk("RC011 NAMED_GAP, LANDED", GAP, ok())
chk("RC012 ENTRY_STATUS, LANDED", ES, ok())
chk("RC013 ENTRY_STATUS, PUSH", push_form(ES), ok(), stage="PUSH")
chk("RC014 MASTER, LANDED", MASTER, ok())
chk("RC015 MASTER with the TFK: the zones digest to its D_TPK, D_TRM, D_TMS", MASTER, ok(),
tfk=TFK)
_TFK_BADH = copy.deepcopy(TFK)
_TFK_BADH["TrM"]["HEADER"]["TRANSFORMATIONS"] = {}
chk("RC015b MASTER: a TrM the zone check refuses cannot be digested, REC-39 in S5 (8.2; C-RS-18)", MASTER,
refused(P("REC-39", "-", "the TFK is not readable")), tfk=_TFK_BADH)
chk("RC016 RESULT M over the example TFK, LANDED", RES_M, ok(), tfk=TFK)
chk("RC017 SITUATION ASSUMPTION over the example TFK", ASM_SIT, ok(), tfk=TFK)
chk("RC018 ENTRY_STATUS over the example TFK", ES, ok(), tfk=TFK)
chk("RC019 NAMED_GAP IC2 over the example TFK (z a DOF)", GAP, ok(), tfk=TFK)
# S1 and the argument errors
chk("RC020 REC-01 a record that is not an object", 42,
refused(P("REC-01", "-", "the record is not an object")))
chk("RC021 REC-01 a list", [RES_L], refused(P("REC-01", "-", "the record is not an object")))
chk("RC022 REC-02 CLASS missing", without(RES_L, "CLASS"),
refused(P("REC-02", "CLASS", "CLASS is missing")))
chk("RC023 REC-02 the empty object", {}, refused(P("REC-02", "CLASS", "CLASS is missing")))
chk("RC024 REC-09 CLASS not a string", withf(RES_L, CLASS=1),
refused(P("REC-09", "CLASS", "CLASS is not a string")))
chk("RC025 REC-03 CLASS not a class", withf(RES_L, CLASS="FINDING"),
refused(P("REC-03", "CLASS", "CLASS FINDING is not a record class")))
chk("RC026 REC-03 CLASS in lower case", withf(RES_L, CLASS="result"),
refused(P("REC-03", "CLASS", "CLASS result is not a record class")))
chk("RC027 REC-03 a block kind is not a class", withf(RES_L, CLASS="REPRODUCTION"),
refused(P("REC-03", "CLASS", "CLASS REPRODUCTION is not a record class")))
chk("RC028 REC-03 CLASS with a final line feed shown", withf(RES_L, CLASS="RESULT\n"),
refused(P("REC-03", "CLASS", "CLASS RESULT<U+000A> is not a record class")))
for i, c in enumerate(["HOLD", "RELEASE", "WITHDRAWAL", "PROMOTION"]):
chk("RC03%d REC-04 %s is a list-form class" % (i, c), {"CLASS": c, "ID": "RR-9"},
refused(P("REC-04", "CLASS", "CLASS %s is written by TPX in its own form" % c)))
chk("RC034 REC-05 NAMED_GAP pushed", GAP,
refused(P("REC-05", "CLASS", "CLASS NAMED_GAP is written by TPX and never pushed")),
stage="PUSH")
chk("RC035 REC-05 MASTER pushed", MASTER,
refused(P("REC-05", "CLASS", "CLASS MASTER is written by TPX and never pushed")),
stage="PUSH")
chk("RC036 REC-36 stage not PUSH or LANDED", RES_L,
refused(P("REC-36", "-", 'stage "LAND" is not PUSH or LANDED')), stage="LAND")
chk("RC037 REC-36 stage null", RES_L,
refused(P("REC-36", "-", "stage null is not PUSH or LANDED")), stage=None)
chk("RC038 REC-36 setting not a setting", RES_L,
refused(P("REC-36", "-", 'setting "YES" is not OFF, ON, CLOSED or null')), setting="YES")
chk("RC039 REC-36 setting a list", RES_L,
refused(P("REC-36", "-", 'setting ["ON"] is not OFF, ON, CLOSED or null')),
setting=["ON"])
chk("RC040 REC-36 stage checked before setting", RES_L,
refused(P("REC-36", "-", 'stage "X" is not PUSH or LANDED')), setting="YES", stage="X")
chk("RC041 REC-39 tfk not an object", RES_L,
refused(P("REC-39", "-", "the TFK is not readable")), tfk=[])
chk("RC042 REC-39 TPK a list", RES_L, refused(P("REC-39", "-", "the TFK is not readable")),
tfk={"TPK": [], "TrM": {"ENTRIES": []}})
chk("RC043 REC-39 an entry without DIMENSION", RES_L,
refused(P("REC-39", "-", "the TFK is not readable")),
tfk={"TPK": {}, "TrM": {"ENTRIES": [{"NAME": "E"}]}})
chk("RC044 REC-39 a DOF whose NAME is not a string", RES_L,
refused(P("REC-39", "-", "the TFK is not readable")),
tfk={"TPK": {"DOF": [{"NAME": 1, "DIMENSION": "L1"}]}, "TrM": {"ENTRIES": []}})
chk("RC044b REC-39 a DOF without DIMENSION (tpm_record_schema 0.2.1 8.2; C-RS-15)", RES_L,
refused(P("REC-39", "-", "the TFK is not readable")),
tfk={"TPK": {"DOF": [{"NAME": "x"}]}, "TrM": {"ENTRIES": []}})
chk("RC044c REC-39 a DOF whose DIMENSION normalize_dimension does not read (C-RS-15)", RES_L,
refused(P("REC-39", "-", "the TFK is not readable")),
tfk={"TPK": {"DOF": [{"NAME": "x", "DIMENSION": "L one"}]}, "TrM": {"ENTRIES": []}})
chk("RC045 REC-39 checked before the record", 7,
refused(P("REC-39", "-", "the TFK is not readable")), tfk={"TPK": {}})
chk("RC046 a minimal readable TFK (no DOF, no CONSTANT, no entries)", RES_L, ok(),
tfk={"TPK": {}, "TrM": {"ENTRIES": []}})
# S2 unknown fields, TPX fields at PUSH, missing fields
chk("RC050 REC-06 an unknown field", withf(RES_L, COLOR="red"),
refused(P("REC-06", "COLOR", "unknown field COLOR")))
chk("RC051 REC-06 a lower-case spelling is unknown", withf(without(RES_L, "STATEMENT"),
statement="x"),
refused(P("REC-06", "statement", "unknown field statement"),
P("REC-08", "STATEMENT", "STATEMENT is missing")))
chk("RC052 REC-06 a key holding a control character, shown", withf(RES_L, **{"A\tB": 1}),
refused(P("REC-06", "A<U+0009>B", "unknown field A<U+0009>B")))
chk("RC053 REC-06 STATUS on a MASTER (it carries none)", withf(MASTER, STATUS="UNMARKED"),
refused(P("REC-06", "STATUS", "unknown field STATUS")))
chk("RC054 REC-06 a field of another class (TARGET on a RESULT)", withf(RES_L, TARGET="RR-3"),
refused(P("REC-06", "TARGET", "unknown field TARGET")))
chk("RC055 REC-07 GRADE at PUSH", withf(push_form(RES_L), GRADE="PROVISIONAL"),
refused(P("REC-07", "GRADE", "GRADE is written by TPX")), stage="PUSH")
chk("RC056 REC-07 every TPX field at PUSH, bad values not read",
withf(push_form(RES_L), GRADE=1, STATUS="X", BLOCK="", AUTHOR="a", LANDED_BY="b",
LANDED="never", VETTED_IN="c", INHERITS="RR-1", TPS="x", D_IS="y", DIGEST="z"),
refused(*[P("REC-07", f, f + " is written by TPX") for f in
["GRADE", "STATUS", "BLOCK", "AUTHOR", "LANDED_BY", "LANDED", "VETTED_IN",
"INHERITS", "TPS", "D_IS", "DIGEST"]]), stage="PUSH")
chk("RC057 REC-07 OUTCOME and INDEPENDENCE on a pushed CORROBORATION",
withf(push_form(CORR), OUTCOME="MATCH", INDEPENDENCE=IND),
refused(P("REC-07", "INDEPENDENCE", "INDEPENDENCE is written by TPX"),
P("REC-07", "OUTCOME", "OUTCOME is written by TPX")), stage="PUSH")
chk("RC058 PUSH: a TPX field absent is not missing", push_form(CORR), ok(), stage="PUSH")
n = 60
for cls, base in (("RESULT", RES_L), ("ASSUMPTION", REC_A), ("CORROBORATION", CORR),
("VERIFICATION", VER), ("NAMED_GAP", GAP), ("ENTRY_STATUS", ES),
("MASTER", MASTER)):
for f in REQUIRED_LANDED[cls]:
if f == "CLASS":
continue
chk("RC%03d REC-08 %s without %s at LANDED" % (n, cls, f), without(base, f),
refused(P("REC-08", f, f + " is missing")))
n += 1
chk("RC200 REC-08 at PUSH: an author's field missing", without(push_form(RES_L), "FALSIFIER"),
refused(P("REC-08", "FALSIFIER", "FALSIFIER is missing")), stage="PUSH")
chk("RC201 REC-08 at PUSH: ID missing (LEAD)", without(push_form(RES_L), "ID"),
refused(P("REC-08", "ID", "ID is missing")), stage="PUSH")
chk("RC202 REC-08 DIGEST is never required", without(RES_L, "DIGEST"), ok())
chk("RC203 REC-08 nested: DERIVATION {}", withf(RES_L, DERIVATION={}),
refused(P("REC-08", "DERIVATION.STEPS", "DERIVATION.STEPS is missing"),
P("REC-08", "DERIVATION.TEXT", "DERIVATION.TEXT is missing")))
chk("RC204 REC-08 nested in a LIST member", withf(REC_B, BUDGET=[
{"NAME": "timing", "U": "0.0012", "UNIT": "s", "EVALUATION": "A"}]),
refused(P("REC-08", "BUDGET[1].BASIS", "BUDGET[1].BASIS is missing")))
chk("RC205 REC-06 nested unknown field", withf(RES_L, DERIVATION={"STEPS": 1, "TEXT": "t",
"NOTE": "n"}),
refused(P("REC-06", "DERIVATION.NOTE", "unknown field DERIVATION.NOTE")))
chk("RC206 INDEPENDENCE missing a member", withf(CORR, INDEPENDENCE=without(IND, "SAME_MODEL")),
refused(P("REC-08", "INDEPENDENCE.SAME_MODEL", "INDEPENDENCE.SAME_MODEL is missing")))
# S2 (c): the JSON type of each type class and cardinality
chk("RC210 REC-09 ID a number", withf(RES_L, ID=10),
refused(P("REC-09", "ID", "ID is not a record identifier")))
chk("RC211 REC-09 CITES a string", withf(RES_L, CITES="RR-3"),
refused(P("REC-09", "CITES", "CITES is not a set of record identifiers")))
chk("RC212 REC-09 CITES an object", withf(RES_L, CITES={}),
refused(P("REC-09", "CITES", "CITES is not a set of record identifiers")))
chk("RC213 REC-09 CITES with a number member", withf(RES_L, CITES=["RR-3", 4]),
refused(P("REC-09", "CITES", "CITES is not a set of record identifiers")))
chk("RC214 REC-09 ENTRY an array (IDENT ONE)", withf(ES, ENTRY=["E_x"]),
refused(P("REC-09", "ENTRY", "ENTRY is not an identifier")))
chk("RC215 REC-09 REFS a string (IDENT SET)", withf(REC_A, REFS="L"),
refused(P("REC-09", "REFS", "REFS is not a set of identifiers")))
chk("RC216 REC-09 STATEMENT a number (TEXT)", withf(RES_L, STATEMENT=1),
refused(P("REC-09", "STATEMENT", "STATEMENT is not a text")))
chk("RC217 REC-09 AGAINST a string (TEXT SET)", withf(GAP, AGAINST="z"),
refused(P("REC-09", "AGAINST", "AGAINST is not a set of texts")))
chk("RC218 REC-09 VALUE a number (DECIMAL)", withf(REC_B, VALUE=2.007),
refused(P("REC-09", "VALUE", "VALUE is not a decimal string")))
chk("RC219 REC-09 UNIT null (UNIT)", withf(REC_B, UNIT=None),
refused(P("REC-09", "UNIT", "UNIT is not a unit string")))
chk("RC220 REC-09 EQUATION a list (FORM)", withf(RES_L, EQUATION=["x"], REFS=["x"]),
refused(P("REC-09", "EQUATION", "EQUATION is not a form string")))
chk("RC221 REC-09 DOMAIN_CONDITION an object (PREDICATE)",
withf(RES_L, DOMAIN_CONDITION={"x": 1}, REFS=["x"]),
refused(P("REC-09", "DOMAIN_CONDITION", "DOMAIN_CONDITION is not a predicate string")))
chk("RC222 REC-09 REGIME a boolean (ENUM)", withf(RES_L, REGIME=True),
refused(P("REC-09", "REGIME", "REGIME is not a string")))
chk("RC223 REC-09 GRADE null (ENUM)", withf(RES_L, GRADE=None),
refused(P("REC-09", "GRADE", "GRADE is not a string")))
chk("RC224 REC-09 a bool where an INT is wanted", withf(RES_L, DERIVATION={"STEPS": True,
"TEXT": "t"}),
refused(P("REC-09", "DERIVATION.STEPS", "DERIVATION.STEPS is not an integer")))
chk("RC225 REC-09 a float where an INT is wanted", withf(RES_L, DERIVATION={"STEPS": 2.0,
"TEXT": "t"}),
refused(P("REC-09", "DERIVATION.STEPS", "DERIVATION.STEPS is not an integer")))
chk("RC226 REC-09 a string where an INT is wanted", withf(RES_L, DERIVATION={"STEPS": "2",
"TEXT": "t"}),
refused(P("REC-09", "DERIVATION.STEPS", "DERIVATION.STEPS is not an integer")))
chk("RC227 REC-09 CORRELATED a string (BOOL)", withf(REC_B, CORRELATED="false"),
refused(P("REC-09", "CORRELATED", "CORRELATED is not a boolean")))
chk("RC228 REC-09 CORRELATED 0 (BOOL)", withf(REC_B, CORRELATED=0),
refused(P("REC-09", "CORRELATED", "CORRELATED is not a boolean")))
chk("RC229 REC-09 DERIVATION a list (OBJECT ONE)", withf(RES_L, DERIVATION=[]),
refused(P("REC-09", "DERIVATION", "DERIVATION is not an object")))
chk("RC230 REC-09 BUDGET an object (OBJECT LIST)", withf(REC_B, BUDGET={}),
refused(P("REC-09", "BUDGET", "BUDGET is not a list of objects")))
chk("RC231 REC-09 BUDGET with a list member", withf(REC_B, BUDGET=[[]]),
refused(P("REC-09", "BUDGET", "BUDGET is not a list of objects")))
chk("RC232 REC-09 INDEPENDENCE's BOOL a string",
withf(CORR, INDEPENDENCE=withf(IND, SAME_MODEL="no")),
refused(P("REC-09", "INDEPENDENCE.SAME_MODEL", "INDEPENDENCE.SAME_MODEL is not a boolean")))
chk("RC233 REC-09 EXTERNAL {} is an object whose fields are missing",
withf(VER, EXTERNAL={}),
refused(*[P("REC-08", "EXTERNAL." + f, "EXTERNAL.%s is missing" % f)
for f in ("VALUE", "U_C", "UNIT", "QUANTITY")]))
chk("RC234 REC-09 EXTERNAL [] is not an object", withf(VER, EXTERNAL=[]),
refused(P("REC-09", "EXTERNAL", "EXTERNAL is not an object")))
# S2 (d): per value
chk("RC240 REC-19 ID with a final line feed", withf(RES_L, ID="RR-10\n"),
refused(P("REC-19", "ID", "ID RR-10<U+000A> is not a record identifier")))
chk("RC241 REC-19 ID with a leading zero", withf(RES_L, ID="RR-01"),
refused(P("REC-19", "ID", "ID RR-01 is not a record identifier")))
chk("RC242 REC-19 ID without a prefix", withf(RES_L, ID="-10"),
refused(P("REC-19", "ID", "ID -10 is not a record identifier")))
chk("RC243 REC-19 a CITES member with a final line feed", withf(RES_L, CITES=["RR-3\n"]),
refused(P("REC-19", "CITES", "CITES member RR-3<U+000A> is not a record identifier")))
chk("RC244 REC-19 the first failing CITES member only", withf(RES_L, CITES=["RR-3", "x",
"y-0"]),
refused(P("REC-19", "CITES", "CITES member x is not a record identifier")))
chk("RC245 REC-19 ROLE with a final line feed",
withf(RES_L, EQUATION="D(x,t) = v", REFS=["t", "v", "x"], ROLE="EOM(x)\n"),
refused(P("REC-19", "ROLE", "ROLE EOM(x)<U+000A> is not EOM(<DOF>), CONSTRAINT, "
"CONSTITUTIVE, INVARIANT or DEFINITION")))
chk("RC246 REC-19 ROLE with a space", withf(RES_L, EQUATION="D(x,t) = v",
REFS=["t", "v", "x"], ROLE="EOM( x)"),
refused(P("REC-19", "ROLE", "ROLE EOM( x) is not EOM(<DOF>), CONSTRAINT, "
"CONSTITUTIVE, INVARIANT or DEFINITION")))
chk("RC247 ROLE EOM(x) and each word accepted",
withf(RES_L, EQUATION="D(x,t) = v", REFS=["t", "v", "x"], ROLE="EOM(x)"), ok())
for i, w in enumerate(["CONSTRAINT", "CONSTITUTIVE", "INVARIANT", "DEFINITION"]):
chk("RC24%d ROLE %s" % (8 + i, w) if i < 2 else "RC25%d ROLE %s" % (i - 2, w),
withf(REC_A, EQUATION="x = 1", ROLE=w), ok())
chk("RC252 REC-19 ROLE EOM without a name", withf(REC_A, EQUATION="x = 1", ROLE="EOM()"),
refused(P("REC-19", "ROLE", "ROLE EOM() is not EOM(<DOF>), CONSTRAINT, CONSTITUTIVE, "
"INVARIANT or DEFINITION")))
chk("RC253 REC-19 an IDENT SET member", withf(REC_A, REFS=["L", "2x"]),
refused(P("REC-19", "REFS", "REFS member 2x is not an identifier")))
chk("RC254 REC-19 an IDENT", withf(ES, ENTRY="E x"),
refused(P("REC-19", "ENTRY", "ENTRY E x is not an identifier")))
chk("RC255 REC-19 a BIB ID member", withf(RES_L, LITERATURE=["RR-3"]),
refused(P("REC-19", "LITERATURE", "LITERATURE member RR-3 is not a BIB ID")))
chk("RC256 LITERATURE of BIB IDs accepted", withf(RES_L, LITERATURE=["RR-BIB2", "RR-BIB10"]),
ok())
chk("RC257 REC-19 HEX64 upper case", withf(RES_L, D_IS=DIS.upper()),
refused(P("REC-19", "D_IS", "D_IS %s is not 64 lowercase hexadecimal characters"
% DIS.upper())))
chk("RC258 REC-19 HEX64 of 63", withf(RES_L, D_IS=DIS[:63]),
refused(P("REC-19", "D_IS", "D_IS %s is not 64 lowercase hexadecimal characters"
% DIS[:63])))
chk("RC259 REC-19 VERSION with a leading zero", withf(RES_L, TPS="0.04.0"),
refused(P("REC-19", "TPS", "TPS 0.04.0 is not a version n.n.n")))
chk("RC260 REC-19 VERSION of five digits", withf(RES_L, TPS="10000.0.0"),
refused(P("REC-19", "TPS", "TPS 10000.0.0 is not a version n.n.n")))
chk("RC261 VERSION 9999.9999.9999 accepted", withf(RES_L, TPS="9999.9999.9999"), ok())
chk("RC262 UTC on 2028-02-29 accepted", withf(RES_L, LANDED="2028-02-29T23:59:59Z"), ok())
chk("RC263 REC-19 UTC 2026-02-29", withf(RES_L, LANDED="2026-02-29T00:00:00Z"),
refused(P("REC-19", "LANDED", "LANDED 2026-02-29T00:00:00Z is not a UTC time "
"YYYY-MM-DDTHH:MM:SSZ")))
chk("RC264 REC-19 UTC 2100-02-29", withf(RES_L, LANDED="2100-02-29T00:00:00Z"),
refused(P("REC-19", "LANDED", "LANDED 2100-02-29T00:00:00Z is not a UTC time "
"YYYY-MM-DDTHH:MM:SSZ")))
chk("RC265 UTC 2000-02-29 accepted", withf(RES_L, LANDED="2000-02-29T00:00:00Z"), ok())
chk("RC266 REC-19 UTC hour 24", withf(RES_L, LANDED="2026-09-28T24:00:00Z"),
refused(P("REC-19", "LANDED", "LANDED 2026-09-28T24:00:00Z is not a UTC time "
"YYYY-MM-DDTHH:MM:SSZ")))
chk("RC267 REC-19 UTC second 60", withf(RES_L, LANDED="2026-09-28T23:59:60Z"),
refused(P("REC-19", "LANDED", "LANDED 2026-09-28T23:59:60Z is not a UTC time "
"YYYY-MM-DDTHH:MM:SSZ")))
chk("RC268 REC-19 UTC without Z", withf(RES_L, LANDED="2026-09-28T12:00:00"),
refused(P("REC-19", "LANDED", "LANDED 2026-09-28T12:00:00 is not a UTC time "
"YYYY-MM-DDTHH:MM:SSZ")))
chk("RC269 REC-19 UTC month 13", withf(RES_L, LANDED="2026-13-01T00:00:00Z"),
refused(P("REC-19", "LANDED", "LANDED 2026-13-01T00:00:00Z is not a UTC time "
"YYYY-MM-DDTHH:MM:SSZ")))
chk("RC270 REC-19 UUID4 variant digit c", withf(MASTER, UUID="123e4567-e89b-42d3-c456-426614174000"),
refused(P("REC-19", "UUID", "UUID 123e4567-e89b-42d3-c456-426614174000 is not a "
"version-4 UUID")))
chk("RC271 REC-19 UUID version 1", withf(MASTER, UUID="123e4567-e89b-12d3-a456-426614174000"),
refused(P("REC-19", "UUID", "UUID 123e4567-e89b-12d3-a456-426614174000 is not a "
"version-4 UUID")))
chk("RC272 UUID4 variant digits 8, 9 and b accepted",
withf(MASTER, UUID="123e4567-e89b-42d3-8456-426614174000"), ok())
chk("RC273 REC-19 UUID upper case", withf(MASTER, UUID="123E4567-E89B-42D3-A456-426614174000"),
refused(P("REC-19", "UUID", "UUID 123E4567-E89B-42D3-A456-426614174000 is not a "
"version-4 UUID")))
chk("RC274 REC-19 TPXONLY", withf(GAP, LANDED_BY="agent-a"),
refused(P("REC-19", "LANDED_BY", "LANDED_BY agent-a is not TPX")))
chk("RC275 STATELINE SETTLED accepted", withf(GAP, STATE="SETTLED 2026-09-28 BY RR-12, RR-9"),
ok())
chk("RC276 STATELINE STANDING accepted",
withf(GAP, STATE="STANDING 2026-09-28 BY DECLARATIONS Volume 2, line 4"), ok())
chk("RC277 REC-19 STATELINE with a bad date",
withf(GAP, STATE="SETTLED 2026-02-30 BY RR-12"),
refused(P("REC-19", "STATE", "STATE SETTLED 2026-02-30 BY RR-12 is not a STATE line")))
chk("RC278 REC-19 STATELINE with a bad identifier",
withf(GAP, STATE="SETTLED 2026-09-28 BY RR-12,RR-9"),
refused(P("REC-19", "STATE", "STATE SETTLED 2026-09-28 BY RR-12,RR-9 is not a STATE "
"line")))
chk("RC279 REC-19 STATELINE lower case", withf(GAP, STATE="open"),
refused(P("REC-19", "STATE", "STATE open is not a STATE line")))
chk("RC280 REC-19 STATELINE STANDING with a blank text",
withf(GAP, STATE="STANDING 2026-09-28 BY "),
refused(P("REC-19", "STATE", "STATE STANDING 2026-09-28 BY is not a STATE line")))
chk("RC281 REC-19 STEPS 0", withf(RES_L, DERIVATION={"STEPS": 0, "TEXT": "t"}),
refused(P("REC-19", "DERIVATION.STEPS", "DERIVATION.STEPS 0 is not an integer from 1 "
"to 1000000")))
chk("RC282 REC-19 STEPS 1000001", withf(RES_L, DERIVATION={"STEPS": 1000001, "TEXT": "t"}),
refused(P("REC-19", "DERIVATION.STEPS", "DERIVATION.STEPS 1000001 is not an integer "
"from 1 to 1000000")))
chk("RC283 STEPS 1000000 accepted", withf(RES_L, DERIVATION={"STEPS": 1000000, "TEXT": "t"}),
ok())
chk("RC284 REC-19 STEPS -1", withf(RES_L, DERIVATION={"STEPS": -1, "TEXT": "t"}),
refused(P("REC-19", "DERIVATION.STEPS", "DERIVATION.STEPS -1 is not an integer from 1 "
"to 1000000")))
chk("RC290 REC-10 U+0000 in a TEXT", withf(RES_L, STATEMENT="a\u0000b"),
refused(P("REC-10", "STATEMENT", "STATEMENT holds the disallowed code point U+0000")))
chk("RC291 REC-10 U+0085 in a TEXT", withf(RES_L, STATEMENT="a\u0085b"),
refused(P("REC-10", "STATEMENT", "STATEMENT holds the disallowed code point U+0085")))
chk("RC292 REC-10 U+2028 in a TEXT", withf(RES_L, STATEMENT="a
b"),
refused(P("REC-10", "STATEMENT", "STATEMENT holds the disallowed code point U+2028")))
chk("RC293 REC-10 a bidirectional control U+202E", withf(RES_L, STATEMENT="ab"),
refused(P("REC-10", "STATEMENT", "STATEMENT holds the disallowed code point U+202E")))
chk("RC294 REC-10 the first disallowed code point only", withf(RES_L, STATEMENT="\u0001"),
refused(P("REC-10", "STATEMENT", "STATEMENT holds the disallowed code point U+200B")))
chk("RC295 REC-10 private use U+E000", withf(RES_L, FALSIFIER=""),
refused(P("REC-10", "FALSIFIER", "FALSIFIER holds the disallowed code point U+E000")))
chk("RC296 TAB, LF and CRLF accepted in a TEXT", withf(RES_L, STATEMENT="a\tb\r\nc\rd\ne"),
ok())
chk("RC297 a TEXT needing NFC accepted as given", withf(RES_L, STATEMENT="café"),
ok())
chk("RC298 REC-10 in a nested TEXT", withf(REC_B, BUDGET=[
{"NAME": "timing", "U": "0.0012", "UNIT": "s", "EVALUATION": "A", "BASIS": "x\u0007"}]),
refused(P("REC-10", "BUDGET[1].BASIS", "BUDGET[1].BASIS holds the disallowed code point "
"U+0007")))
chk("RC299 REC-10 a TEXT SET member", withf(GAP, SOURCE="SR5_LOCUS", AGAINST=["RR-3\u0000"],
TRIGGER="RR-50"),
refused(P("REC-10", "AGAINST", "AGAINST holds the disallowed code point U+0000")))
chk("RC300 REC-11 a blank TEXT", withf(RES_L, STATEMENT=" \t "),
refused(P("REC-11", "STATEMENT", "STATEMENT is blank")))
chk("RC301 REC-11 the empty TEXT", withf(RES_L, FALSIFIER=""),
refused(P("REC-11", "FALSIFIER", "FALSIFIER is blank")))
chk("RC302 REC-11 a TEXT of U+3000 and U+00A0", withf(RES_L, STATEMENT=" "),
refused(P("REC-11", "STATEMENT", "STATEMENT is blank")))
chk("RC303 a blank AGAINST member passes S2 (no NOTBLANK) and fails its form",
withf(GAP, SOURCE="SR7_DOMAIN", AGAINST=[" "], TRIGGER="RR-50"),
refused(P("REC-19", "AGAINST", "AGAINST is not the one member TFK DOMAIN")))
chk("RC304 REC-12 REGIME X", withf(RES_L, REGIME="X"),
refused(P("REC-12", "REGIME", "REGIME X is not one of L or M")))
chk("RC305 REC-12 FALSIFIER_CLASS F0", withf(RES_L, FALSIFIER_CLASS="F0"),
refused(P("REC-12", "FALSIFIER_CLASS", "FALSIFIER_CLASS F0 is not one of F1, F2 or F3")))
chk("RC306 REC-12 GRADE not a grade", withf(RES_L, GRADE="STRUCK"),
refused(P("REC-12", "GRADE", "GRADE STRUCK is not one of PROVISIONAL, ESTABLISHED, "
"REFUTED, WITHDRAWN or NOT GRADED")))
chk("RC307 REC-12 STATUS VOID", withf(RES_L, STATUS="VOID"),
refused(P("REC-12", "STATUS", "STATUS VOID is not one of UNMARKED, HELD or REFUTED")))
chk("RC308 REC-12 STATUS REFUTED on an ASSUMPTION", withf(REC_A, STATUS="REFUTED"),
refused(P("REC-12", "STATUS", "STATUS REFUTED is not one of UNMARKED or HELD")))
chk("RC309 STATUS HELD and REFUTED on a RESULT accepted", withf(RES_L, STATUS="HELD"), ok())
chk("RC310 STATUS REFUTED on a CORROBORATION accepted", withf(CORR, STATUS="REFUTED"), ok())
chk("RC311 REC-12 OUTCOME", withf(CORR, OUTCOME="AGREES"),
refused(P("REC-12", "OUTCOME", "OUTCOME AGREES is not one of MATCH or MATCH WITH "
"DIFFERENCE NOTED")))
chk("RC312 REC-12 TARGET_STATUS", withf(CORR, TARGET_STATUS="REFUTED"),
refused(P("REC-12", "TARGET_STATUS", "TARGET_STATUS REFUTED is not one of PROVISIONAL, "
"ESTABLISHED or HELD")))
chk("RC313 REC-12 VERIFICATION REGIME L", withf(VER, REGIME="L"),
refused(P("REC-12", "REGIME", "REGIME L is not one of M")))
chk("RC314 REC-12 SITUATION", withf(ASM_SIT, SITUATION="FINAL"),
refused(P("REC-12", "SITUATION", "SITUATION FINAL is not one of INITIAL or BOUNDARY")))
chk("RC315 REC-12 EVALUATION", withf(REC_B, BUDGET=[
{"NAME": "timing", "U": "0.0012", "UNIT": "s", "EVALUATION": "C", "BASIS": "b"}]),
refused(P("REC-12", "BUDGET[1].EVALUATION", "BUDGET[1].EVALUATION C is not one of A or B")))
chk("RC316 REC-12 ORIGIN", withf(CORR, INDEPENDENCE=withf(IND, ORIGIN="ELSEWHERE")),
refused(P("REC-12", "INDEPENDENCE.ORIGIN", "INDEPENDENCE.ORIGIN ELSEWHERE is not one of "
"SAME BLOCK or REPRODUCTION BLOCK")))
chk("RC317 REC-12 GAP SOURCE", withf(GAP, SOURCE="IC3"),
refused(P("REC-12", "SOURCE", "SOURCE IC3 is not one of IC2, UNDER, SR5_LOCUS, "
"SR7_ASSUMPTIONS or SR7_DOMAIN")))
chk("RC318 REC-12 an ENUM compared byte for byte", withf(RES_L, REGIME="l"),
refused(P("REC-12", "REGIME", "REGIME l is not one of L or M")))
chk("RC319 REC-12 an ENUM value shown with its control", withf(RES_L, REGIME="L\n"),
refused(P("REC-12", "REGIME", "REGIME L<U+000A> is not one of L or M")))
chk("RC320 REC-32 GRADE ESTABLISHED at landing", withf(RES_L, GRADE="ESTABLISHED"),
refused(P("REC-32", "GRADE", "GRADE ESTABLISHED is not PROVISIONAL, the landing grade "
"of RESULT")))
chk("RC321 REC-32 GRADE PROVISIONAL on an ENTRY_STATUS", withf(ES, GRADE="PROVISIONAL"),
refused(P("REC-32", "GRADE", "GRADE PROVISIONAL is not NOT GRADED, the landing grade "
"of ENTRY_STATUS")))
chk("RC322 REC-32 GRADE REFUTED without INHERITS", withf(CORR, GRADE="REFUTED"),
refused(P("REC-32", "GRADE", "GRADE REFUTED is not PROVISIONAL, the landing grade of "
"CORROBORATION")))
# D215.2: an inherited record lands at its class's LANDGRADE, INHERITS present or not;
# every other grade is REC-32 (REC-40 retired). INH keeps gate 2's grades per class in
# gate 2's order, so each case keeps its number.
INH = [("RESULT", RES_L, ["PROVISIONAL", "REFUTED", "WITHDRAWN"], ["ESTABLISHED", "NOT GRADED"]),
("ASSUMPTION", REC_A, ["PROVISIONAL", "WITHDRAWN"], ["ESTABLISHED", "REFUTED"]),
("CORROBORATION", CORR, ["PROVISIONAL", "REFUTED", "WITHDRAWN"], ["ESTABLISHED"]),
("VERIFICATION", VER, ["PROVISIONAL", "WITHDRAWN"], ["REFUTED", "ESTABLISHED"]),
("ENTRY_STATUS", ES, ["NOT GRADED"], ["PROVISIONAL", "WITHDRAWN"]),
("NAMED_GAP", GAP, ["NOT GRADED"], ["PROVISIONAL"])]
LG = {"RESULT": "PROVISIONAL", "ASSUMPTION": "PROVISIONAL", "CORROBORATION": "PROVISIONAL",
"VERIFICATION": "PROVISIONAL", "ENTRY_STATUS": "NOT GRADED", "NAMED_GAP": "NOT GRADED"}
n = 330
for cls, base, good, bad in INH:
for g in good + bad:
if g == LG[cls]:
chk("RC%03d inherited %s lands %s" % (n, cls, g),
withf(base, INHERITS="QQ-%d" % (n - 300), GRADE=g), ok())
else:
chk("RC%03d REC-32 inherited %s refused %s" % (n, cls, g),
withf(base, INHERITS="QQ-%d" % (n - 300), GRADE=g),
refused(P("REC-32", "GRADE", "GRADE %s is not %s, the landing grade of %s"
% (g, LG[cls], cls))))
n += 1
chk("RC360 REC-12 before REC-32", withf(RES_L, INHERITS="QQ-1", GRADE="HELD"),
refused(P("REC-12", "GRADE", "GRADE HELD is not one of PROVISIONAL, ESTABLISHED, REFUTED, "
"WITHDRAWN or NOT GRADED")))
chk("RC361 INHERITS at PUSH is a TPX field",
withf(push_form(RES_L), INHERITS="QQ-1"),
refused(P("REC-07", "INHERITS", "INHERITS is written by TPX")), stage="PUSH")
chk("RC362 INHERITS on a MASTER is unknown", withf(MASTER, INHERITS="QQ-1"),
refused(P("REC-06", "INHERITS", "unknown field INHERITS")))
chk("RC363 a bad INHERITS and GRADE WITHDRAWN: REC-19 and REC-32",
withf(RES_L, INHERITS="QQ-01", GRADE="WITHDRAWN"),
refused(P("REC-19", "INHERITS", "INHERITS QQ-01 is not a record identifier"),
P("REC-32", "GRADE", "GRADE WITHDRAWN is not PROVISIONAL, the landing grade of "
"RESULT")))
chk("RC370 REC-13 a CITES member repeated", withf(RES_L, CITES=["RR-3", "RR-4", "RR-3"]),
refused(P("REC-13", "CITES", "CITES repeats RR-3")))
chk("RC371 REC-13 a REFS member repeated", withf(REC_A, REFS=["x", "x"]),
refused(P("REC-13", "REFS", "REFS repeats x")))
chk("RC372 REC-13 a TEXT SET member repeated after NFC",
withf(GAP, AGAINST=["é", "é"]),
refused(P("REC-13", "AGAINST", "AGAINST repeats é")))
chk("RC373 REC-13 a KEY repeated in BUDGET", withf(REC_B, BUDGET=[
{"NAME": "timing", "U": "0.0010", "UNIT": "s", "EVALUATION": "A", "BASIS": "a"},
{"NAME": "timing", "U": "0.0005", "UNIT": "s", "EVALUATION": "B", "BASIS": "b"}]),
refused(P("REC-13", "BUDGET", "BUDGET repeats timing")))
chk("RC374 REC-13 a KEY repeated in AT", withf(REC_B, AT=[
{"DOF": "t", "VALUE": "0", "UNIT": "s"}, {"DOF": "t", "VALUE": "1", "UNIT": "s"}]),
refused(P("REC-13", "AT", "AT repeats t")))
chk("RC375 REC-13 a CITES member repeated only once reported",
withf(RES_L, CITES=["RR-3", "RR-3", "RR-4", "RR-4"]),
refused(P("REC-13", "CITES", "CITES repeats RR-3")))
chk("RC376 LITERATURE members distinct", withf(RES_L, LITERATURE=["RR-BIB1", "RR-BIB1"]),
refused(P("REC-13", "LITERATURE", "LITERATURE repeats RR-BIB1")))
chk("RC380 decimals: 0.050 accepted", withf(REC_B, VALUE="0.050"), ok())
chk("RC381 decimals: -0 accepted as VALUE", withf(REC_B, VALUE="-0"), ok())
chk("RC382 REC-14 1e", withf(REC_B, VALUE="1e"),
refused(P("REC-14", "VALUE", "VALUE 1e is not a decimal")))
chk("RC383 decimals: 1.5E+03 accepted", withf(REC_B, VALUE="1.5E+03"), ok())
chk("RC384 REC-14 .5", withf(REC_B, VALUE=".5"),
refused(P("REC-14", "VALUE", "VALUE .5 is not a decimal")))
chk("RC385 REC-14 an exponent of five digits", withf(REC_B, VALUE="1e10000"),
refused(P("REC-14", "VALUE", "VALUE 1e10000 is not a decimal")))
chk("RC386 REC-14 +1", withf(REC_B, VALUE="+1"),
refused(P("REC-14", "VALUE", "VALUE +1 is not a decimal")))
chk("RC387 REC-15 U_C 0", withf(REC_B, U_C="0"),
refused(P("REC-15", "U_C", "U_C 0 is not positive")))
chk("RC388 REC-15 U_C -0.001", withf(REC_B, U_C="-0.001"),
refused(P("REC-15", "U_C", "U_C -0.001 is not positive")))
chk("RC389 REC-15 U_C 0.000", withf(REC_B, U_C="0.000"),
refused(P("REC-15", "U_C", "U_C 0.000 is not positive")))
chk("RC390 REC-16 a component U -1", withf(REC_B, BUDGET=[
{"NAME": "timing", "U": "-1", "UNIT": "s", "EVALUATION": "A", "BASIS": "b"}]),
refused(P("REC-16", "BUDGET[1].U", "BUDGET[1].U -1 is negative")))
chk("RC391 a component U -0 is 0, not negative", withf(REC_B, BUDGET=[
{"NAME": "timing", "U": "-0", "UNIT": "s", "EVALUATION": "A", "BASIS": "b"}]), ok())
chk("RC392 REC-15 DIFFERENCE.U 0", withf(VER, DIFFERENCE={"VALUE": "6e-4", "U": "0",
"ZETA": "1"}),
refused(P("REC-15", "DIFFERENCE.U", "DIFFERENCE.U 0 is not positive")))
chk("RC393 REC-16 EXTERNAL.U_C negative", withf(VER, EXTERNAL={
"VALUE": "2", "U_C": "-5e-4", "UNIT": "s", "QUANTITY": "period"}),
refused(P("REC-16", "EXTERNAL.U_C", "EXTERNAL.U_C -5e-4 is negative")))
chk("RC394 EXTERNAL.U_C 0 accepted (NONNEG)", withf(VER, EXTERNAL={
"VALUE": "2", "U_C": "0", "UNIT": "s", "QUANTITY": "period"}), ok())
chk("RC395 REC-14 a DIFFERENCE.ZETA", withf(VER, DIFFERENCE={"VALUE": "6e-4", "U": "1",
"ZETA": "zeta"}),
refused(P("REC-14", "DIFFERENCE.ZETA", "DIFFERENCE.ZETA zeta is not a decimal")))
chk("RC400 REC-17 a unit that does not parse", withf(REC_B, UNIT="furlong"),
refused(P("REC-17", "UNIT", "UNIT: " + U.unit_parse("furlong")[1])))
chk("RC401 REC-17 degC", withf(REC_B, UNIT="degC"),
refused(P("REC-17", "UNIT", "UNIT: " + U.unit_parse("degC")[1])))
chk("RC402 REC-17 the empty unit", withf(REC_B, UNIT=""),
refused(P("REC-17", "UNIT", "UNIT: " + U.unit_parse("")[1])))
chk("RC403 REC-17 a nested unit", withf(REC_B, AT=[{"DOF": "t", "VALUE": "0",
"UNIT": "sec"}]),
refused(P("REC-17", "AT[1].UNIT", "AT[1].UNIT: " + U.unit_parse("sec")[1])))
chk("RC404 UNIT in another spelling accepted", withf(REC_B, UNIT="s1"), ok())
chk("RC410 REC-18 a form that does not parse", withf(RES_L, EQUATION="x = = 1", REFS=["x"]),
refused(P("REC-18", "EQUATION", "EQUATION: " + F.parse_form("x = = 1", "equation")[1])))
chk("RC411 REC-18 an EQUATION without =", withf(RES_L, EQUATION="x + 1", REFS=["x"]),
refused(P("REC-18", "EQUATION", "EQUATION: " + F.parse_form("x + 1", "equation")[1])))
_BIG = "x = " + "+".join(["x"] * 2100)
chk("RC412 REC-18 a form past D186.1's bounds", withf(RES_L, EQUATION=_BIG, REFS=["x"]),
refused(P("REC-18", "EQUATION", "EQUATION: " + F.parse_form(_BIG, "equation")[1])))
chk("RC413 REC-18 a predicate that does not parse",
withf(RES_L, DOMAIN_CONDITION="x > ", REFS=["x"]),
refused(P("REC-18", "DOMAIN_CONDITION", "DOMAIN_CONDITION: "
+ F.parse_form("x > ", "predicate")[1])))
chk("RC414 REC-18 D inside a predicate", withf(RES_L, DOMAIN_CONDITION="D(x, t) > 0",
REFS=["t", "x"]),
refused(P("REC-18", "DOMAIN_CONDITION", "DOMAIN_CONDITION: "
+ F.parse_form("D(x, t) > 0", "predicate")[1])))
chk("RC415 a predicate accepted", withf(RES_L, DOMAIN="small x",
DOMAIN_CONDITION="abs(x) < x_max",
REFS=["x", "x_max"]), ok())
chk("RC416 REC-35 BUDGET empty", withf(REC_B, BUDGET=[]),
refused(P("REC-35", "BUDGET", "BUDGET is empty")))
chk("RC417 AT empty accepted", withf(REC_B, AT=[]), ok())
# S3 the RULE lines: firing and silence
M_BARE = without(REC_B, "QUANTITY", "VALUE", "UNIT", "U_C", "BUDGET", "AT", "ENTRIES")
chk("RC420 RESULT rule 1: REGIME M requires five fields", M_BARE,
refused(*[P("REC-20", f, f + " is required when REGIME is M")
for f in ("QUANTITY", "VALUE", "UNIT", "U_C", "BUDGET")]))
chk("RC421 RESULT rule 1 at PUSH: author fields still required", push_form(M_BARE),
refused(*[P("REC-20", f, f + " is required when REGIME is M")
for f in ("QUANTITY", "VALUE", "UNIT", "U_C", "BUDGET")]), stage="PUSH")
chk("RC422 RESULT rule 2: REGIME M forbids EQUATION and ROLE",
withf(REC_B, EQUATION="x = 1", ROLE="CONSTRAINT", REFS=["x"]),
refused(P("REC-21", "EQUATION", "EQUATION is not allowed when REGIME is M"),
P("REC-21", "ROLE", "ROLE is not allowed when REGIME is M")))
chk("RC423 RESULT rule 3: REGIME L forbids U_C and BUDGET",
withf(RES_L, U_C="1", BUDGET=REC_B["BUDGET"]),
refused(P("REC-21", "BUDGET", "BUDGET is not allowed when REGIME is L"),
P("REC-21", "U_C", "U_C is not allowed when REGIME is L")))
chk("RC424 RESULT rule 4: ALL OR NONE with one of three", withf(RES_L, QUANTITY="period"),
refused(P("REC-22", "VALUE", "QUANTITY, VALUE and UNIT are given together or not at all")))
chk("RC425 RESULT rule 4: ALL OR NONE with two of three",
withf(RES_L, QUANTITY="period", VALUE="2"),
refused(P("REC-22", "UNIT", "QUANTITY, VALUE and UNIT are given together or not at all")))
chk("RC426 RESULT rule 4: an L derived value, all three", withf(RES_L, QUANTITY="period",
VALUE="2", UNIT="s"), ok())
chk("RC427 RESULT rule 5: CORRELATED without BUDGET", withf(RES_L, CORRELATED=False),
refused(P("REC-21", "CORRELATED", "CORRELATED is not allowed when BUDGET is absent")))
chk("RC428 RESULT rule 6: AT without VALUE", withf(RES_L, AT=[]),
refused(P("REC-21", "AT", "AT is not allowed when VALUE is absent")))
chk("RC429 RESULT rule 7: ROLE requires EQUATION", withf(RES_L, ROLE="INVARIANT"),
refused(P("REC-20", "EQUATION", "EQUATION is required when ROLE is present")))
chk("RC430 RESULT rule 8: EQUATION requires REFS", withf(RES_L, EQUATION="x = 1"),
refused(P("REC-20", "REFS", "REFS is required when EQUATION is present")))
chk("RC431 RESULT rule 9: DOMAIN_CONDITION requires REFS",
withf(RES_L, DOMAIN_CONDITION="x > 0"),
refused(P("REC-20", "REFS", "REFS is required when DOMAIN_CONDITION is present")))
chk("RC432 RESULT rules silent: an L record with a derived value and AT",
withf(RES_L, QUANTITY="period", VALUE="2", UNIT="s", AT=[{"DOF": "t", "VALUE": "0",
"UNIT": "s"}]), ok())
chk("RC433 RESULT rule 7 fires on presence even when ROLE fails its form",
withf(RES_L, ROLE="nonsense"),
refused(P("REC-19", "ROLE", "ROLE nonsense is not EOM(<DOF>), CONSTRAINT, CONSTITUTIVE, "
"INVARIANT or DEFINITION"),
P("REC-20", "EQUATION", "EQUATION is required when ROLE is present")))
chk("RC434 RESULT rule 1 compares the raw value: REGIME M given as m fires nothing",
withf(M_BARE, REGIME="m"),
refused(P("REC-12", "REGIME", "REGIME m is not one of L or M")))
chk("RC440 ASSUMPTION rule 1: SITUATION requires DOF, VALUE, UNIT",
without(ASM_SIT, "DOF", "VALUE", "UNIT"),
refused(*[P("REC-20", f, f + " is required when SITUATION is present")
for f in ("DOF", "VALUE", "UNIT")]))
chk("RC441 ASSUMPTION rule 2: no SITUATION forbids DOF, VALUE, UNIT, AT",
withf(REC_A, DOF="x", VALUE="1", UNIT="m", AT=[]),
refused(*[P("REC-21", f, f + " is not allowed when SITUATION is absent")
for f in ("DOF", "VALUE", "UNIT", "AT")]))
chk("RC442 ASSUMPTION rule 3: SITUATION forbids EQUATION and ROLE",
withf(ASM_SIT, EQUATION="x = 1", ROLE="CONSTRAINT"),
refused(P("REC-21", "EQUATION", "EQUATION is not allowed when SITUATION is present"),
P("REC-21", "ROLE", "ROLE is not allowed when SITUATION is present")))
chk("RC443 ASSUMPTION rule 4: ROLE requires EQUATION", withf(REC_A, ROLE="DEFINITION"),
refused(P("REC-20", "EQUATION", "EQUATION is required when ROLE is present")))
chk("RC444 ASSUMPTION rules silent: a SITUATION record without AT",
without(ASM_SIT, "AT"), ok())
chk("RC450 CORROBORATION rule 1: MATCH WITH DIFFERENCE NOTED requires DIFFERENCE",
withf(CORR, OUTCOME="MATCH WITH DIFFERENCE NOTED"),
refused(P("REC-20", "DIFFERENCE", "DIFFERENCE is required when OUTCOME is MATCH WITH "
"DIFFERENCE NOTED")))
chk("RC451 CORROBORATION rule 2: MATCH forbids DIFFERENCE",
withf(CORR, DIFFERENCE="u_c 0.0003 s against 0.0005 s"),
refused(P("REC-21", "DIFFERENCE", "DIFFERENCE is not allowed when OUTCOME is MATCH")))
chk("RC452 CORROBORATION rules silent: with the difference noted",
withf(CORR, OUTCOME="MATCH WITH DIFFERENCE NOTED",
DIFFERENCE="u_c 0.0003 s against 0.0005 s"), ok())
chk("RC453 CORROBORATION with SELF_REPORTED accepted", withf(CORR, SELF_REPORTED="blind"),
ok())
chk("RC460 ENTRY_STATUS rule: AT LEAST ONE", without(ES, "NOTE"),
refused(P("REC-23", "-", "one of RIDER, NOTE, SCRUTINY or CHECKS_OWED is required")))
chk("RC461 ENTRY_STATUS rule silent: all four", withf(ES, RIDER="r", SCRUTINY="s",
CHECKS_OWED="c"), ok())
chk("RC462 ENTRY_STATUS rule at PUSH", without(push_form(ES), "NOTE"),
refused(P("REC-23", "-", "one of RIDER, NOTE, SCRUTINY or CHECKS_OWED is required")),
stage="PUSH")
# S3 cross-field checks
chk("RC470 REC-27 QUANTITY not among ENTRIES", withf(REC_B, ENTRIES=["length"]),
refused(P("REC-27", "ENTRIES", "ENTRIES does not name QUANTITY period")))
chk("RC471 REC-27 silent without ENTRIES", without(REC_B, "ENTRIES"), ok())
chk("RC472 REC-27 silent on an L record", withf(RES_L, QUANTITY="period", VALUE="2",
UNIT="s", ENTRIES=["length"]), ok())
chk("RC473 REC-28 MASTER ID not PREFIX-1", withf(MASTER, ID="RR-2"),
refused(P("REC-28", "ID", "ID RR-2 is not RR-1")))
chk("RC474 REC-28 MASTER of another prefix", withf(MASTER, ID="QQ-1"),
refused(P("REC-28", "ID", "ID QQ-1 is not RR-1")))
_BAD = "0" * 64
chk("RC475 REC-33 MASTER D_TFK not the combination", withf(MASTER, D_TFK=_BAD),
refused(P("REC-33", "D_TFK", "D_TFK %s is not the combination of D_TPK, D_TRM and "
"D_TMS" % _BAD)))
_D2 = G.d_tfk(_BAD, D_TRM, D_TMS)
chk("RC476 REC-34 MASTER D_TPK not the TFK's (D_TFK consistent)",
withf(MASTER, D_TPK=_BAD, D_TFK=_D2),
refused(P("REC-34", "D_TPK", "D_TPK %s is not the TFK's D(TPK)" % _BAD)), tfk=TFK)
chk("RC477 REC-34 silent without a TFK", withf(MASTER, D_TPK=_BAD, D_TFK=_D2), ok())
_D3 = G.d_tfk(D_TPK, _BAD, _BAD)
chk("RC478 REC-34 two zones", withf(MASTER, D_TRM=_BAD, D_TMS=_BAD, D_TFK=_D3),
refused(P("REC-34", "D_TMS", "D_TMS %s is not the TFK's D(TMS)" % _BAD),
P("REC-34", "D_TRM", "D_TRM %s is not the TFK's D(TrM)" % _BAD)), tfk=TFK)
chk("RC479 REC-39 in S5: a MASTER over a TFK without TMS",
MASTER, refused(P("REC-39", "-", "the TFK is not readable")),
tfk={"TPK": TFK["TPK"], "TrM": TFK["TrM"]})
chk("RC480 REC-30 LITERATURE under OFF", withf(RES_L, LITERATURE=["RR-BIB1"]),
refused(P("REC-30", "LITERATURE", "LITERATURE is not kept under BIBLIOGRAPHY SETTING "
"OFF")), setting="OFF")
chk("RC481 LITERATURE under ON", withf(RES_L, LITERATURE=["RR-BIB1"]), ok(), setting="ON")
chk("RC482 LITERATURE under CLOSED", withf(RES_L, LITERATURE=["RR-BIB1"]), ok(),
setting="CLOSED")
chk("RC483 LITERATURE with setting null", withf(RES_L, LITERATURE=["RR-BIB1"]), ok())
chk("RC484 REC-31 SOURCE under ON not in LITERATURE", VER,
refused(P("REC-31", "SOURCE", "SOURCE Handbook, table 3. is not a BIB ID in LITERATURE")),
setting="ON")
chk("RC485 SOURCE under ON a BIB ID in LITERATURE",
withf(VER, SOURCE="RR-BIB4", LITERATURE=["RR-BIB4"]), ok(), setting="ON")
chk("RC486 REC-31 SOURCE a BIB ID LITERATURE does not name",
withf(VER, SOURCE="RR-BIB4", LITERATURE=["RR-BIB5"]),
refused(P("REC-31", "SOURCE", "SOURCE RR-BIB4 is not a BIB ID in LITERATURE")),
setting="CLOSED")
chk("RC487 SOURCE prose under OFF", VER, ok(), setting="OFF")
chk("RC488 SOURCE under null setting: NOTBLANK only", withf(VER, SOURCE="RR-BIB4"), ok())
chk("RC489 REC-31 and REC-30 apart: under OFF a BIB ID SOURCE is prose",
withf(VER, SOURCE="RR-BIB4"), ok(), setting="OFF")
chk("RC490 AGAINST under UNDER: identifiers", withf(GAP, SOURCE="UNDER", AGAINST=["x"]), ok())
chk("RC491 REC-19 AGAINST under IC2 not an identifier", withf(GAP, AGAINST=["the z"]),
refused(P("REC-19", "AGAINST", "AGAINST member the z is not an identifier")))
chk("RC492 AGAINST under SR5_LOCUS: identifiers of records",
withf(GAP, SOURCE="SR5_LOCUS", AGAINST=["RR-4", "RR-8"], TRIGGER="RR-50"), ok())
chk("RC493 REC-19 AGAINST under SR7_ASSUMPTIONS not an RID",
withf(GAP, SOURCE="SR7_ASSUMPTIONS", AGAINST=["RR-4", "x"], TRIGGER="RR-50"),
refused(P("REC-19", "AGAINST", "AGAINST member x is not a record identifier")))
chk("RC494 AGAINST under SR7_DOMAIN: TFK DOMAIN", withf(GAP, SOURCE="SR7_DOMAIN",
AGAINST=["TFK DOMAIN"],
TRIGGER="RR-50"), ok())
chk("RC495 REC-19 AGAINST under SR7_DOMAIN another member",
withf(GAP, SOURCE="SR7_DOMAIN", AGAINST=["TFK DOMAIN", "x"], TRIGGER="RR-50"),
refused(P("REC-19", "AGAINST", "AGAINST is not the one member TFK DOMAIN")))
chk("RC496 REC-19 TRIGGER not an RID under SR5_LOCUS",
withf(GAP, SOURCE="SR5_LOCUS", AGAINST=["RR-4"], TRIGGER="the withdrawal"),
refused(P("REC-19", "TRIGGER", "TRIGGER the withdrawal is not a record identifier")))
chk("RC497 TRIGGER text under IC2", GAP, ok())
chk("RC498 BIBSOURCE is the VERIFICATION's SOURCE only: a NAMED_GAP's SOURCE under ON",
GAP, ok(), setting="ON")
chk("RC499 a NAMED_GAP's SOURCE under CLOSED", withf(GAP, SOURCE="UNDER", AGAINST=["x"]), ok(),
setting="CLOSED")
# S4 T2 on a PROPOSITION
_T2 = ["The pivot is fixed and the string is light.",
"The pivot is fixed but the string stretches.",
"The pivot is fixed whereas the bob moves.",
"The pivot as well as the string is fixed.",
"The pivot is fixed & the string is light.",
"The pivot is fixed ∧ the string is light.",
"The pivot is fixed; the string is light.",
"The pivot is fixed. The string is light.",
"Premises:\n- the pivot is fixed\n- the string is light"]
for i, prop in enumerate(_T2):
fnd = TT.t2_findings(prop)
assert fnd, prop
chk("RC5%02d REC-24 %s" % (i, fnd[0]), withf(REC_A, PROPOSITION=prop),
refused(*[P("REC-24", "PROPOSITION", "PROPOSITION " + f) for f in fnd]))
chk("RC520 T2 silent: one claim", REC_A, ok())
# S5 the TFK
chk("RC530 REC-25 a REFS member not in the TPK", withf(REC_A, REFS=["x", "q"]),
refused(P("REC-25", "REFS", "REFS member q is not a DOF or CONSTANT of the TPK")), tfk=TFK)
chk("RC531 REFS of DOF and CONSTANT names accepted", withf(REC_A, REFS=["k_s", "m", "x"]),
ok(), tfk=TFK)
chk("RC532 REC-25 the ASSUMPTION's DOF", withf(ASM_SIT, DOF="q"),
refused(P("REC-25", "DOF", "DOF q is not a DOF of the TPK")), tfk=TFK)
chk("RC533 REC-25 a CONSTANT is not a DOF", withf(ASM_SIT, DOF="m", UNIT="kg"),
refused(P("REC-25", "DOF", "DOF m is not a DOF of the TPK")), tfk=TFK)
chk("RC534 REC-25 ENTRIES member", withf(RES_M, ENTRIES=["E_x", "E_q"]),
refused(P("REC-25", "ENTRIES", "ENTRIES member E_q is not an entry of the TrM")), tfk=TFK)
chk("RC535 REC-25 QUANTITY (and REC-27 silent since ENTRIES names it)",
withf(RES_M, QUANTITY="E_q", ENTRIES=["E_q"]),
refused(P("REC-25", "ENTRIES", "ENTRIES member E_q is not an entry of the TrM"),
P("REC-25", "QUANTITY", "QUANTITY E_q is not an entry of the TrM")), tfk=TFK)
chk("RC536 REC-25 ENTRY_STATUS ENTRY", withf(ES, ENTRY="E_q"),
refused(P("REC-25", "ENTRY", "ENTRY E_q is not an entry of the TrM")), tfk=TFK)
chk("RC537 REC-25 AT[1].DOF", withf(RES_M, AT=[{"DOF": "q", "VALUE": "0", "UNIT": "s"}]),
refused(P("REC-25", "AT[1].DOF", "AT[1].DOF q is not a DOF of the TPK")), tfk=TFK)
chk("RC538 REC-26 UNIT against the QUANTITY entry", withf(RES_M, UNIT="s", BUDGET=[
{"NAME": "scale", "U": "0.5", "UNIT": "ms", "EVALUATION": "B", "BASIS": "b"}]),
refused(P("REC-26", "UNIT", "UNIT s has dimension T1, not L1")), tfk=TFK)
chk("RC539 REC-26 silent when QUANTITY fails", withf(RES_M, QUANTITY="E_q", ENTRIES=["E_q"],
UNIT="s"),
refused(P("REC-25", "ENTRIES", "ENTRIES member E_q is not an entry of the TrM"),
P("REC-25", "QUANTITY", "QUANTITY E_q is not an entry of the TrM")), tfk=TFK)
chk("RC540 REC-26 the SITUATION UNIT against its DOF", withf(ASM_SIT, UNIT="kg"),
refused(P("REC-26", "UNIT", "UNIT kg has dimension M1, not L1")), tfk=TFK)
chk("RC541 REC-26 an AT point's UNIT against its DOF",
withf(RES_M, AT=[{"DOF": "t", "VALUE": "0", "UNIT": "m"}]),
refused(P("REC-26", "AT[1].UNIT", "AT[1].UNIT m has dimension L1, not T1")), tfk=TFK)
chk("RC542 REC-26 EXTERNAL.UNIT against EXTERNAL.QUANTITY", withf(VER, EXTERNAL={
"VALUE": "0.01", "U_C": "0.0005", "UNIT": "s", "QUANTITY": "E_x"}),
refused(P("REC-26", "EXTERNAL.UNIT", "EXTERNAL.UNIT s has dimension T1, not L1")), tfk=TFK)
chk("RC543 REC-25 EXTERNAL.QUANTITY", VER,
refused(P("REC-25", "EXTERNAL.QUANTITY", "EXTERNAL.QUANTITY period is not an entry of "
"the TrM")), tfk=TFK)
chk("RC544 REC-25 NAMED_GAP AGAINST under IC2 not a DOF", withf(GAP, AGAINST=["q"]),
refused(P("REC-25", "AGAINST", "AGAINST member q is not a DOF of the TPK")), tfk=TFK)
chk("RC545 NAMED_GAP AGAINST under SR5_LOCUS not read against the TPK",
withf(GAP, SOURCE="SR5_LOCUS", AGAINST=["RR-4"], TRIGGER="RR-50"), ok(), tfk=TFK)
chk("RC546 UNIT mm against an entry of L1 accepted", withf(RES_M, UNIT="mm", VALUE="10"),
ok(), tfk=TFK)
chk("RC547 the UNIT of a BUDGET component is not read against the entry",
withf(RES_M, BUDGET=[{"NAME": "scale", "U": "0.5", "UNIT": "s", "EVALUATION": "B",
"BASIS": "b"}]), ok(), tfk=TFK)
# S6 the digest; and the ordering of several problems
_DA = sha(["TPC-RECORD", "1", 13, "ID", "RR-2", "CLASS", "ASSUMPTION", "GRADE", "PROVISIONAL",
"BLOCK", "B-4", "AUTHOR", "agent-a", "LANDED_BY", "agent-a", "LANDED",
"2026-09-28T12:00:00Z", "CITES", 0, "ASSUMPTIONS", 0, "TPS", "0.4.0", "D_IS", DIS,
"PROPOSITION", "The pivot of the pendulum does not move.", "REFS", 1, "L"])
assert _DA == "09bd3acfbf22777b0301fcfd7de37086326800dc817f42eac6126ee3836ae1af"
chk("RC560 DIGEST equal to the record's digest", withf(REC_A, DIGEST=_DA), ok())
chk("RC561 REC-29 DIGEST unequal", withf(REC_A, DIGEST=_BAD),
refused(P("REC-29", "DIGEST", "DIGEST %s is not the record's digest %s" % (_BAD, _DA))))
chk("RC562 DIGEST not checked at PUSH (a TPX field)", withf(push_form(REC_A), DIGEST=_BAD),
refused(P("REC-07", "DIGEST", "DIGEST is written by TPX")), stage="PUSH")
chk("RC563 REC-29 silent when another problem is found", withf(REC_A, DIGEST=_BAD,
REFS=["L", "L"]),
refused(P("REC-13", "REFS", "REFS repeats L")))
chk("RC564 REC-19 a DIGEST that is not HEX64", withf(REC_A, DIGEST="xyz"),
refused(P("REC-19", "DIGEST", "DIGEST xyz is not 64 lowercase hexadecimal characters")))
chk("RC565 DIGEST ignores STATUS", withf(REC_A, STATUS="HELD", DIGEST=_DA), ok())
chk("RC570 several problems sorted by code, field, message",
withf(RES_L, COLOR="c", ZZ=1, CITES=["x"], REGIME="Q", STATEMENT="",
DERIVATION={"STEPS": 0}),
refused(P("REC-06", "COLOR", "unknown field COLOR"), P("REC-06", "ZZ", "unknown field ZZ"),
P("REC-19", "CITES", "CITES member x is not a record identifier"),
P("REC-11", "STATEMENT", "STATEMENT is blank"),
P("REC-12", "REGIME", "REGIME Q is not one of L or M"),
P("REC-19", "DERIVATION.STEPS", "DERIVATION.STEPS 0 is not an integer from 1 to "
"1000000"),
P("REC-08", "DERIVATION.TEXT", "DERIVATION.TEXT is missing")))
chk("RC571 a PUSH record checked with the TFK", push_form(RES_M), ok(), tfk=TFK, stage="PUSH")
chk("RC572 a PUSH ASSUMPTION with SITUATION, setting ON", push_form(ASM_SIT), ok(), tfk=TFK,
setting="ON", stage="PUSH")
# ============================================================ preimage and digest
_FA = ["TPC-RECORD", "1", 13, "ID", "RR-2", "CLASS", "ASSUMPTION", "GRADE", "PROVISIONAL",
"BLOCK", "B-4", "AUTHOR", "agent-a", "LANDED_BY", "agent-a", "LANDED",
"2026-09-28T12:00:00Z", "CITES", 0, "ASSUMPTIONS", 0, "TPS", "0.4.0", "D_IS", DIS,
"PROPOSITION", "The pivot of the pendulum does not move.", "REFS", 1, "L"]
_FB = ["TPC-RECORD", "1", 25, "ID", "RR-7", "CLASS", "RESULT", "GRADE", "PROVISIONAL", "BLOCK",
"B-9", "AUTHOR", "agent-b", "LANDED_BY", "agent-a", "LANDED", "2026-09-28T12:05:00Z",
"VETTED_IN", "B-10", "CITES", 1, "RR-3", "ASSUMPTIONS", 2, "RR-2", "RR-5", "TPS", "0.4.0",
"D_IS", DIS, "STATEMENT", "The measured period of the pendulum at the stated length.",
"REGIME", "M", "DERIVATION", 2, "STEPS", 3, "TEXT",
"Ten swings timed; the mean taken; the budget below.", "FALSIFIER",
"A period outside the stated interval at the same length.", "FALSIFIER_CLASS", "F3",
"ENTRIES", 1, "period", "QUANTITY", "period", "VALUE", "2007e-3", "UNIT", "s", "U_C",
"12e-4", "BUDGET", 2, 5, "NAME", "length", "U", "66e-2", "UNIT", "ms", "EVALUATION", "B",
"BASIS", "Tape resolution, rectangular.", 5, "NAME", "timing", "U", "1e-3", "UNIT", "s",
"EVALUATION", "A", "BASIS", "Ten repeated timings.", "CORRELATED", "false", "AT", 1, 3,
"DOF", "t", "VALUE", "0", "UNIT", "s"]
assert len(netstring(_FA)) == 332 and len(netstring(_FB)) == 870
_DB = sha(_FB)
assert _DB == "2fc5af8e5a1199104ed48ae0e60ed45ebffe9824c86aacf09fa5d43732e2d8da"
def pre(name, record, expected):
add(name, "record_preimage", {"record": record}, expected)
def dig(name, record, expected):
add(name, "record_digest", {"record": record}, expected)
pre("RP001 9.8 RECORD A's field list", REC_A, cj(["OK", _FA]))
dig("RD001 9.8 RECORD A's digest", REC_A, cj(["OK", _DA]))
pre("RP002 9.8 RECORD B's field list", REC_B, cj(["OK", _FB]))
dig("RD002 9.8 RECORD B's digest", REC_B, cj(["OK", _DB]))
_B_KEYS = dict(sorted(REC_B.items(), reverse=True)) # the input object's key order reversed
dig("RD003 field-order independence of the input object", _B_KEYS, cj(["OK", _DB]))
dig("RD004 STATUS HELD does not move the digest", withf(REC_B, STATUS="HELD"), cj(["OK", _DB]))
dig("RD005 U_C 12e-4, ASSUMPTIONS reordered, BUDGET reversed, CORRELATED false declared",
withf(REC_B, U_C="12e-4", ASSUMPTIONS=["RR-2", "RR-5"],
BUDGET=list(reversed(REC_B["BUDGET"])), CORRELATED=False), cj(["OK", _DB]))
dig("RD006 VALUE 2.007 digests as 2.0070", withf(REC_B, VALUE="2.007"), cj(["OK", _DB]))
dig("RD007 AT [] declared digests as AT omitted", withf(REC_A, DIGEST=_BAD), cj(["OK", _DA]))
_FB2 = list(_FB)
_FB2[_FB2.index("CORRELATED") + 1] = "true"
dig("RD008 CORRELATED true moves the digest", withf(REC_B, CORRELATED=True),
cj(["OK", sha(_FB2)]))
_FB3 = _FB[:-9] + ["AT", 0]
dig("RD009 AT [] on an M RESULT digests as AT omitted", without(REC_B, "AT"),
cj(["OK", sha(_FB3)]))
dig("RD010 AT [] declared equals AT omitted", withf(REC_B, AT=[]), cj(["OK", sha(_FB3)]))
_FA_G = list(_FA)
_FA_G.insert(_FA_G.index("TPS"), "INHERITS")
_FA_G.insert(_FA_G.index("TPS"), "PP-2")
_FA_G[2] = 14
assert sha(_FA_G) == "babf6346238ba8ca054242c82852542c1c671ba3837cac89d0df85579254728f"
dig("RD011 INHERITS inside the digest (D215.2: GRADE the LANDGRADE)",
withf(REC_A, INHERITS="PP-2"), cj(["OK", sha(_FA_G)]))
_FG = ["TPC-RECORD", "1", 10, "ID", "RR-2", "CLASS", "NAMED_GAP", "GRADE", "NOT GRADED",
"LANDED_BY", "TPX", "LANDED", T0, "TPS", "0.4.0", "SOURCE", "IC2", "AGAINST", 1, "z",
"TRIGGER", "DECLARATIONS Volume 1, line 7", "STATEMENT",
"The DOF z is tied by no TrM entry (IC2).", ]
dig("RD012 NAMED_GAP: STATE outside the digest", withf(GAP, STATE="SETTLED 2026-09-29 BY RR-9"),
cj(["OK", sha(_FG)]))
pre("RP003 NAMED_GAP's field list", GAP, cj(["OK", _FG]))
_FT = ["TPC-RECORD", "1", 18, "ID", "RR-10", "CLASS", "RESULT", "GRADE", "PROVISIONAL",
"BLOCK", "B-1", "AUTHOR", "agent-a", "LANDED_BY", "agent-a", "LANDED", T0, "CITES", 0,
"ASSUMPTIONS", 0, "TPS", "0.4.0", "D_IS", DIS, "STATEMENT", "café x",
"REGIME", "L", "DERIVATION", 2, "STEPS", 2, "TEXT", "a\nb",
"FALSIFIER", "A period that changes with the amplitude.", "FALSIFIER_CLASS", "F2",
"REFS", 2, "t", "x", "EQUATION", "x=2*t"]
pre("RP004 text in LF then NFC; the form's canonical spelling; REFS sorted",
withf(RES_L, STATEMENT="café x", DERIVATION={"STEPS": 2, "TEXT": "a\r\nb"},
REFS=["x", "t"], EQUATION="x = 2 * t"), cj(["OK", _FT]))
_FT2 = list(_FT)
_FT2[-1] = "x=t*2"
dig("RD013 x = 2*t and x = t*2 digest apart (the spelling only)",
withf(RES_L, STATEMENT="café x", DERIVATION={"STEPS": 2, "TEXT": "a\r\nb"},
REFS=["x", "t"], EQUATION="x = t * 2"), cj(["OK", sha(_FT2)]))
dig("RD014 a refused record", without(REC_A, "REFS"),
refused(P("REC-08", "REFS", "REFS is missing")))
dig("RD015 a PUSH record is refused (TPX fields missing)", push_form(REC_A),
refused(*[P("REC-08", f, f + " is missing") for f in
("GRADE", "STATUS", "BLOCK", "AUTHOR", "LANDED_BY", "LANDED", "TPS", "D_IS")]))
pre("RP005 a refused record", 3, refused(P("REC-01", "-", "the record is not an object")))
_FM = ["TPC-RECORD", "1", 15, "ID", "RR-1", "CLASS", "MASTER", "GRADE", "NOT GRADED",
"LANDED_BY", "TPX", "LANDED", T0, "TPS", "0.4.0", "UUID",
"123e4567-e89b-42d3-a456-426614174000", "PREFIX", "RR", "D_TPK", D_TPK, "D_TRM", D_TRM,
"D_TMS", D_TMS, "D_TFK", D_TFK, "CERTIFICATE", "DECLARATIONS Volume 1, line 7",
"STRUCTURE_LINE", "structurally regular", "MODULES_USED", "none"]
dig("RD016 the MASTER's digest", MASTER, cj(["OK", sha(_FM)]))
_FC = ["TPC-RECORD", "1", 15, "ID", "RR-20", "CLASS", "CORROBORATION", "GRADE", "PROVISIONAL",
"BLOCK", "B-1", "AUTHOR", "agent-b", "LANDED_BY", "agent-a", "LANDED", T0, "CITES", 0,
"ASSUMPTIONS", 0, "TPS", "0.4.0", "D_IS", DIS, "TARGET", "RR-10", "OUTCOME", "MATCH",
"INDEPENDENCE", 8, "ACCOUNT", "agent-b", "SNAPSHOT", "snap-1", "VENDOR", "vendor-1",
"IMPLEMENTATION", "impl-1", "ORIGIN", "REPRODUCTION BLOCK", "NOT_SERVED_BEFORE", "true",
"SAME_SPONSOR", "false", "SAME_MODEL", "false", "TARGET_STATUS", "PROVISIONAL"]
dig("RD017 the CORROBORATION's digest (BOOL as text)", CORR, cj(["OK", sha(_FC)]))
_FV = ["TPC-RECORD", "1", 17, "ID", "RR-30", "CLASS", "VERIFICATION", "GRADE", "PROVISIONAL",
"BLOCK", "B-1", "AUTHOR", "agent-a", "LANDED_BY", "agent-a", "LANDED", T0, "CITES", 0,
"ASSUMPTIONS", 0, "TPS", "0.4.0", "D_IS", DIS, "REGIME", "M", "TARGET", "RR-7",
"EXTERNAL", 4, "VALUE", "20064e-4", "U_C", "5e-4", "UNIT", "s", "QUANTITY", "period",
"SOURCE", "Handbook, table 3.", "AT", 0, "DIFFERENCE", 3, "VALUE", "6e-4", "U", "13e-4",
"ZETA", "461538461538e-12"]
dig("RD018 the VERIFICATION's digest (AT defaulted)", VER, cj(["OK", sha(_FV)]))
_FE = ["TPC-RECORD", "1", 13, "ID", "RR-40", "CLASS", "ENTRY_STATUS", "GRADE", "NOT GRADED",
"BLOCK", "B-1", "AUTHOR", "agent-a", "LANDED_BY", "agent-a", "LANDED", T0, "CITES", 0,
"ASSUMPTIONS", 0, "TPS", "0.4.0", "D_IS", DIS, "ENTRY", "E_x", "NOTE",
"Scrutiny pending."]
dig("RD019 the ENTRY_STATUS's digest", ES, cj(["OK", sha(_FE)]))
# D218.1 (READY_E5 3.7): record B with U_C replaced (DIGEST absent); U_C enters the
# preimage in its precision form, every other DECIMAL canonical (schema 0.3.0 9.3, 13.7).
# The digests are RS's literals; the field lists are _FB with U_C's element replaced, and
# their hashlib digests must equal the literals.
PREC_DIG = {"10e-4": "d8cc57854fb7a692e5fa5c17f3ecd2cd83a7adcc4546158f1d599af07c8e2df0",
"1e-3": "508dd0177d4fe8d13b6b9c73d5df070531921cec76d1533a511186d9676eb314",
"12e-4": "2fc5af8e5a1199104ed48ae0e60ed45ebffe9824c86aacf09fa5d43732e2d8da",
"100e-5": "7ce5e9a5555addd4917784eb773265caa39c8c953d57f31fbbf080611f91f387"}
def _fb_uc(p):
f = list(_FB)
f[f.index("U_C") + 1] = p
return f
for p, d in PREC_DIG.items():
assert sha(_fb_uc(p)) == d, p
assert PREC_DIG["12e-4"] == _DB
for i, (u_c, p) in enumerate([("0.0010", "10e-4"), ("10e-4", "10e-4"), ("1.0e-3", "10e-4"),
("1e-3", "1e-3"), ("0.001", "1e-3"), ("0.0012", "12e-4"),
("12e-4", "12e-4"), ("0.00100", "100e-5")]):
dig("RD%03d U_C %s digests in its precision form %s" % (20 + i, u_c, p),
without(withf(REC_B, U_C=u_c), "DIGEST"), cj(["OK", PREC_DIG[p]]))
for i, (u_c, p) in enumerate([("0.0010", "10e-4"), ("0.001", "1e-3"), ("0.00100", "100e-5"),
("1.0e-3", "10e-4")]):
pre("RP%03d U_C %s's element %s" % (6 + i, u_c, p), without(withf(REC_B, U_C=u_c), "DIGEST"),
cj(["OK", _fb_uc(p)]))
# ============================================================ record_view
FULL = withf(REC_B, EQUATION="x = 1", ROLE="EOM(x)", REFS=["x"], LITERATURE=["RR-BIB1"],
DOMAIN="small x", CITES=["RR-3", "RR-4"])
def view(name, record, v, grade, expected):
add(name, "record_view", {"record": record, "view": v, "grade": grade}, expected)
view("RV001 HOLD view of a full record", FULL, "HOLD", None,
cj(["OK", {"id": "RR-7", "block_id": "B-9", "author": "agent-b",
"cites": ["RR-3", "RR-4"], "assumptions": ["RR-5", "RR-2"], "kind": "RESULT",
"status": "PROVISIONAL", "vetted_by": "agent-a", "vetted_in": "B-10"}]))
view("RV002 HOLD view of a TPX-written CORROBORATION",
withf(CORR, LANDED_BY="TPX"), "HOLD", None,
cj(["OK", {"id": "RR-20", "block_id": "B-1", "author": "TPX", "cites": [],
"assumptions": [], "kind": "CORROBORATION", "status": "PROVISIONAL",
"supplied_by": "agent-b"}]))
view("RV003 HOLD view: vetted_by absent when LANDED_BY is AUTHOR", RES_L, "HOLD", None,
cj(["OK", {"id": "RR-10", "block_id": "B-1", "author": "agent-a", "cites": [],
"assumptions": [], "kind": "RESULT", "status": "PROVISIONAL"}]))
view("RV004 STRIKE view", FULL, "STRIKE", None,
cj(["OK", {"assumptions": ["RR-5", "RR-2"], "cites": ["RR-3", "RR-4"], "steps": 3}]))
view("RV005 SUITE view", FULL, "SUITE", None,
cj(["OK", {"regime": "M", "assumptions": ["RR-5", "RR-2"], "cites": ["RR-3", "RR-4"],
"steps": 3, "domain": "small x"}]))
view("RV006 PROBE_L view with EQUATION", FULL, "PROBE_L", None,
cj(["OK", {"finding": {"type": "EQUATION", "value": "x = 1"}}]))
view("RV007 PROBE_L view with VALUE", without(FULL, "EQUATION"), "PROBE_L", None,
cj(["OK", {"finding": {"type": "DECIMAL", "value": "2.0070"}}]))
view("RV008 PROBE_L view with STATEMENT only", RES_L, "PROBE_L", None,
cj(["OK", {"finding": {"type": "TEXT",
"value": "The period does not depend on the amplitude."}}]))
view("RV009 PROBE_L view of nothing", {"CLASS": "RESULT"}, "PROBE_L", None, cj(["OK", {}]))
view("RV010 PROBE_M view", FULL, "PROBE_M", None,
cj(["OK", {"x": "2.0070", "u": "0.0012", "unit": "s"}]))
view("RV011 PROBE_LOAD view, standing", FULL, "PROBE_LOAD", None,
cj(["OK", {"cites": ["RR-3", "RR-4"], "assumptions": ["RR-5", "RR-2"],
"standing": True}]))
view("RV012 PROBE_LOAD view, HELD", withf(FULL, STATUS="HELD"), "PROBE_LOAD", None,
cj(["OK", {"cites": ["RR-3", "RR-4"], "assumptions": ["RR-5", "RR-2"],
"standing": False}]))
view("RV013 PROBE_LOAD view without a word", {"CITES": []}, "PROBE_LOAD", None,
cj(["OK", {"cites": []}]))
view("RV014 LITERATURE view", FULL, "LITERATURE", None,
cj(["OK", {"id": "RR-7", "status": "PROVISIONAL", "literature": ["RR-BIB1"]}]))
view("RV015 LITERATURE view's default []", RES_L, "LITERATURE", "WITHDRAWN",
cj(["OK", {"id": "RR-10", "status": "WITHDRAWN", "literature": []}]))
view("RV016 EOM view", FULL, "EOM", None,
cj(["OK", {"ID": "RR-7", "STATUS": "PROVISIONAL", "ROLE": "EOM(x)",
"EQUATION": "x = 1"}]))
view("RV017 W: STATUS HELD wins over a grade given", withf(FULL, STATUS="HELD"), "EOM",
"ESTABLISHED", cj(["OK", {"ID": "RR-7", "STATUS": "HELD", "ROLE": "EOM(x)",
"EQUATION": "x = 1"}]))
view("RV018 W: STATUS REFUTED", withf(FULL, STATUS="REFUTED"), "LITERATURE", "WITHDRAWN",
cj(["OK", {"id": "RR-7", "status": "REFUTED", "literature": ["RR-BIB1"]}]))
view("RV019 W: the grade given over GRADE", FULL, "EOM", "WITHDRAWN",
cj(["OK", {"ID": "RR-7", "STATUS": "WITHDRAWN", "ROLE": "EOM(x)", "EQUATION": "x = 1"}]))
view("RV020 W: GRADE only (STATUS UNMARKED)", FULL, "HOLD", None,
cj(["OK", {"id": "RR-7", "block_id": "B-9", "author": "agent-b",
"cites": ["RR-3", "RR-4"], "assumptions": ["RR-5", "RR-2"], "kind": "RESULT",
"status": "PROVISIONAL", "vetted_by": "agent-a", "vetted_in": "B-10"}]))
view("RV021 W: neither (no key emitted)", without(FULL, "GRADE", "STATUS"), "EOM", None,
cj(["OK", {"ID": "RR-7", "ROLE": "EOM(x)", "EQUATION": "x = 1"}]))
view("RV022 a view copies values as given, never canonicalized",
{"ID": "RR-5", "STATUS": "HELD", "EQUATION": "x = 1", "ROLE": 7}, "EOM", None,
cj(["OK", {"ID": "RR-5", "STATUS": "HELD", "EQUATION": "x = 1", "ROLE": 7}]))
view("RV023 a view of the empty object", {}, "HOLD", None, cj(["OK", {}]))
view("RV024 STRIKE: steps only when DERIVATION holds STEPS", withf(RES_L, DERIVATION={"TEXT": "t"}),
"STRIKE", None, cj(["OK", {"assumptions": [], "cites": []}]))
view("RV025 REC-01 a record not an object", "RR-7", "HOLD", None,
refused(P("REC-01", "-", "the record is not an object")))
view("RV026 REC-37 an unknown view", FULL, "PROBE", None,
refused(P("REC-37", "-", 'view "PROBE" is not a view')))
view("RV027 REC-37 view null", FULL, None, None,
refused(P("REC-37", "-", "view null is not a view")))
view("RV028 REC-38 grade not a grade", FULL, "EOM", "HELD",
refused(P("REC-38", "-", 'grade "HELD" is not a grade')))
view("RV029 REC-38 grade a number", FULL, "EOM", 3,
refused(P("REC-38", "-", "grade 3 is not a grade")))
view("RV030 REC-01 before REC-37", [], "X", "Y",
refused(P("REC-01", "-", "the record is not an object")))
view("RV031 REC-37 before REC-38", {}, "X", "Y",
refused(P("REC-37", "-", 'view "X" is not a view')))
view("RV032 grade NOT GRADED on an ENTRY_STATUS", ES, "LITERATURE", "NOT GRADED",
cj(["OK", {"id": "RR-40", "status": "NOT GRADED", "literature": []}]))
view("RV033 HOLD: vetted_by when AUTHOR is absent", {"ID": "RR-5", "LANDED_BY": "agent-a"},
"HOLD", None, cj(["OK", {"id": "RR-5", "vetted_by": "agent-a"}]))
view("RV034 HOLD: a TPX-landed RESULT has no supplied_by", withf(RES_L, LANDED_BY="TPX"),
"HOLD", None,
cj(["OK", {"id": "RR-10", "block_id": "B-1", "author": "agent-a", "cites": [],
"assumptions": [], "kind": "RESULT", "status": "PROVISIONAL"}]))
view("RV035 REC-37 a view shown with its control", FULL, "EOM\n", None,
refused(P("REC-37", "-", 'view "EOM\\u000a" is not a view')))
# ============================================================ E2: tpm_record_functions 0.2.0
def ca(name, fn, args, expected):
add(name, fn, args, expected)
def mk(rid, cls, **kv):
r = rec(rid, cls)
if cls in ("NAMED_GAP", "MASTER"):
for k in ("STATUS", "BLOCK", "AUTHOR", "CITES", "ASSUMPTIONS", "D_IS"):
r.pop(k, None)
r["GRADE"] = "NOT GRADED"
r["LANDED_BY"] = "TPX"
if cls == "ENTRY_STATUS":
r["GRADE"] = "NOT GRADED"
r.update(kv)
return r
def cjv(v):
return cj(v)
# ---- 4 grade and status
for c in ["RESULT", "ASSUMPTION", "CORROBORATION", "VERIFICATION", "WITHDRAWAL", "NAMED_GAP",
"ENTRY_STATUS", "PROMOTION", "MASTER", "HOLD", "RELEASE"]:
g = {"RESULT": ["PROVISIONAL", "ESTABLISHED", "REFUTED", "WITHDRAWN"],
"ASSUMPTION": ["PROVISIONAL", "WITHDRAWN"],
"CORROBORATION": ["PROVISIONAL", "REFUTED", "WITHDRAWN"],
"VERIFICATION": ["PROVISIONAL", "WITHDRAWN"]}.get(c, ["NOT GRADED"])
s = {"RESULT": ["UNMARKED", "HELD", "REFUTED"], "ASSUMPTION": ["UNMARKED", "HELD"],
"CORROBORATION": ["UNMARKED", "HELD", "REFUTED"], "VERIFICATION": ["UNMARKED", "HELD"],
"ENTRY_STATUS": ["UNMARKED", "HELD"]}.get(c, [])
ca("GV-%s grade_values" % c, "grade_values", {"class": c}, cj(["OK", g]))
ca("SV-%s status_values" % c, "status_values", {"class": c}, cj(["OK", s]))
ca("GV-X REC-51 not a class", "grade_values", {"class": "FINDING"},
refused(P("REC-51", "-", 'class "FINDING" is not a record class')))
ca("SV-X REC-51 a number", "status_values", {"class": 3},
refused(P("REC-51", "-", "class 3 is not a record class")))
ca("IS01 is_standing PROVISIONAL", "is_standing", {"word": "PROVISIONAL"}, cj(["OK", True]))
ca("IS02 is_standing ESTABLISHED", "is_standing", {"word": "ESTABLISHED"}, cj(["OK", True]))
for i, w in enumerate(["REFUTED", "WITHDRAWN", "HELD", "NOT GRADED"]):
ca("IS%02d is_standing %s" % (i + 3, w), "is_standing", {"word": w}, cj(["OK", False]))
ca("IS07 REC-53 UNMARKED is a STATUS, not a status word", "is_standing", {"word": "UNMARKED"},
refused(P("REC-53", "-", "word UNMARKED is not a status word")))
ca("IS08 REC-53 STRUCK retired", "is_standing", {"word": "STRUCK"},
refused(P("REC-53", "-", "word STRUCK is not a status word")))
ca("IS09 REC-53 null", "is_standing", {"word": None},
refused(P("REC-53", "-", "word null is not a status word")))
ca("SW01 status_word: HELD over a grade", "status_word", {"grade": "ESTABLISHED", "status": "HELD"},
cj(["OK", "HELD"]))
ca("SW02 status_word: REFUTED", "status_word", {"grade": "PROVISIONAL", "status": "REFUTED"},
cj(["OK", "REFUTED"]))
ca("SW03 status_word: UNMARKED gives the grade", "status_word",
{"grade": "WITHDRAWN", "status": "UNMARKED"}, cj(["OK", "WITHDRAWN"]))
ca("SW04 status_word: null status gives the grade", "status_word",
{"grade": "NOT GRADED", "status": None}, cj(["OK", "NOT GRADED"]))
ca("SW05 REC-38 a grade not a grade", "status_word", {"grade": "HELD", "status": None},
refused(P("REC-38", "-", 'grade "HELD" is not a grade')))
ca("SW06 REC-53 a status not a status", "status_word", {"grade": "PROVISIONAL", "status": "VOID"},
refused(P("REC-53", "-", "word VOID is not a status word")))
GN = [("RESULT", "PROVISIONAL", "PROMOTE", "ESTABLISHED"),
("RESULT", "PROVISIONAL", "STRIKE", "REFUTED"), ("RESULT", "ESTABLISHED", "STRIKE", "REFUTED"),
("CORROBORATION", "PROVISIONAL", "STRIKE", "REFUTED"),
("RESULT", "PROVISIONAL", "WITHDRAW", "WITHDRAWN"),
("RESULT", "ESTABLISHED", "WITHDRAW", "WITHDRAWN"),
("ASSUMPTION", "PROVISIONAL", "WITHDRAW", "WITHDRAWN"),
("CORROBORATION", "PROVISIONAL", "WITHDRAW", "WITHDRAWN"),
("VERIFICATION", "PROVISIONAL", "WITHDRAW", "WITHDRAWN")]
for i, (c, g, e, out) in enumerate(GN):
ca("GN%02d grade_next %s %s %s" % (i, c, g, e), "grade_next", {"class": c, "grade": g, "event": e},
cj(["OK", out]))
GX = [("RESULT", "ESTABLISHED", "PROMOTE"), ("RESULT", "REFUTED", "PROMOTE"),
("RESULT", "WITHDRAWN", "PROMOTE"), ("ASSUMPTION", "PROVISIONAL", "PROMOTE"),
("VERIFICATION", "PROVISIONAL", "PROMOTE"), ("ASSUMPTION", "PROVISIONAL", "STRIKE"),
("VERIFICATION", "PROVISIONAL", "STRIKE"), ("RESULT", "REFUTED", "STRIKE"),
("RESULT", "WITHDRAWN", "WITHDRAW"), ("RESULT", "REFUTED", "WITHDRAW"),
("ASSUMPTION", "ESTABLISHED", "WITHDRAW"), ("ENTRY_STATUS", "NOT GRADED", "WITHDRAW"),
("NAMED_GAP", "NOT GRADED", "STRIKE"), ("MASTER", "NOT GRADED", "PROMOTE"),
("HOLD", "NOT GRADED", "WITHDRAW"), ("RESULT", "NOT GRADED", "PROMOTE")]
# REC-54's article (F-GV2-11; READY_E5 3.6): "an" before ASSUMPTION and ENTRY_STATUS, "a"
# before every other class; the eight messages that move, literal:
ART = {"ASSUMPTION": "an", "ENTRY_STATUS": "an"}
E5_ART = {"GX03": "PROMOTE does not apply to an ASSUMPTION of grade PROVISIONAL",
"GX05": "STRIKE does not apply to an ASSUMPTION of grade PROVISIONAL",
"GX10": "WITHDRAW does not apply to an ASSUMPTION of grade ESTABLISHED",
"GX11": "WITHDRAW does not apply to an ENTRY_STATUS of grade NOT GRADED",
"SX01": "STRIKE does not apply to an ASSUMPTION of STATUS UNMARKED",
"SX03": "STRIKE does not apply to an ENTRY_STATUS of STATUS UNMARKED",
"SX04": "RELEASE:REFUTED does not apply to an ASSUMPTION of STATUS HELD",
"SX05": "HOLD does not apply to an ASSUMPTION of STATUS REFUTED"}
for i, (c, g, e) in enumerate(GX):
msg = "%s does not apply to %s %s of grade %s" % (e, ART.get(c, "a"), c, g)
assert msg == E5_ART.get("GX%02d" % i, msg), i
ca("GX%02d REC-54 grade_next %s %s %s" % (i, c, g, e), "grade_next",
{"class": c, "grade": g, "event": e}, refused(P("REC-54", "-", msg)))
ca("GX20 REC-55 an unknown event", "grade_next", {"class": "RESULT", "grade": "PROVISIONAL",
"event": "HOLD"},
refused(P("REC-55", "-", "event HOLD is not PROMOTE, STRIKE or WITHDRAW")))
ca("GX21 REC-51 before the rest", "grade_next", {"class": "X", "grade": "Y", "event": "Z"},
refused(P("REC-51", "-", 'class "X" is not a record class')))
ca("GX22 REC-38 a grade not a grade", "grade_next", {"class": "RESULT", "grade": "HELD",
"event": "PROMOTE"},
refused(P("REC-38", "-", 'grade "HELD" is not a grade')))
SN = [("RESULT", "UNMARKED", "HOLD", "HELD"), ("RESULT", "HELD", "HOLD", "HELD"),
("RESULT", "REFUTED", "HOLD", "REFUTED"), ("ASSUMPTION", "UNMARKED", "HOLD", "HELD"),
("ENTRY_STATUS", "UNMARKED", "HOLD", "HELD"),
("RESULT", "UNMARKED", "STRIKE", "REFUTED"), ("RESULT", "HELD", "STRIKE", "REFUTED"),
("CORROBORATION", "HELD", "STRIKE", "REFUTED"),
("RESULT", "HELD", "RELEASE:HELD", "HELD"), ("RESULT", "HELD", "RELEASE:REFUTED", "REFUTED"),
("RESULT", "HELD", "RELEASE:PROVISIONAL", "UNMARKED"),
("RESULT", "HELD", "RELEASE:ESTABLISHED", "UNMARKED"),
("RESULT", "HELD", "RELEASE:WITHDRAWN", "UNMARKED"),
("ASSUMPTION", "HELD", "RELEASE:PROVISIONAL", "UNMARKED"),
("ENTRY_STATUS", "HELD", "RELEASE:NOT GRADED", "UNMARKED")]
for i, (c, s, e, out) in enumerate(SN):
ca("SN%02d status_next %s %s %s" % (i, c, s, e), "status_next", {"class": c, "status": s, "event": e},
cj(["OK", out]))
SX = [("RESULT", "REFUTED", "STRIKE"), ("ASSUMPTION", "UNMARKED", "STRIKE"),
("VERIFICATION", "HELD", "STRIKE"), ("ENTRY_STATUS", "UNMARKED", "STRIKE"),
("ASSUMPTION", "HELD", "RELEASE:REFUTED"), ("ASSUMPTION", "REFUTED", "HOLD"),
("RESULT", "VOID", "HOLD")]
for i, (c, s, e) in enumerate(SX):
msg = "%s does not apply to %s %s of STATUS %s" % (e, ART.get(c, "a"), c, s)
assert msg == E5_ART.get("SX%02d" % i, msg), i
ca("SX%02d REC-54 status_next %s %s %s" % (i, c, s, e), "status_next",
{"class": c, "status": s, "event": e}, refused(P("REC-54", "-", msg)))
assert sum(1 for c in CASES if c["name"][:4] in E5_ART and "REC-54" in c["name"]
and E5_ART[c["name"][:4]] in c["expected"]) == 8
for i, c in enumerate(["NAMED_GAP", "MASTER", "HOLD", "WITHDRAWAL"]):
ca("SX1%d REC-56 %s carries no STATUS" % (i, c), "status_next",
{"class": c, "status": "UNMARKED", "event": "HOLD"},
refused(P("REC-56", "-", "%s carries no STATUS" % c)))
ca("SX20 REC-55 an unknown event", "status_next", {"class": "RESULT", "status": "UNMARKED",
"event": "WITHDRAW"},
refused(P("REC-55", "-", "event WITHDRAW is not HOLD, STRIKE or RELEASE:<word>")))
ca("SX21 REC-55 a RELEASE of no word", "status_next", {"class": "RESULT", "status": "HELD",
"event": "RELEASE:UNMARKED"},
refused(P("REC-55", "-", "event RELEASE:UNMARKED is not HOLD, STRIKE or RELEASE:<word>")))
IG = [("RESULT", "PROVISIONAL", "PROVISIONAL"), ("RESULT", "ESTABLISHED", "PROVISIONAL"),
("RESULT", "REFUTED", "REFUTED"), ("RESULT", "WITHDRAWN", "WITHDRAWN"),
("ASSUMPTION", "WITHDRAWN", "WITHDRAWN"), ("CORROBORATION", "REFUTED", "REFUTED"),
("ENTRY_STATUS", "NOT GRADED", "NOT GRADED"), ("NAMED_GAP", "NOT GRADED", "NOT GRADED"),
("MASTER", "PROVISIONAL", "NOT GRADED")]
for i, (c, g, out) in enumerate(IG):
ca("IG%02d inherit_grade %s %s" % (i, c, g), "inherit_grade", {"class": c, "grade": g},
cj(["OK", out]))
ca("IG20 REC-38 inherit_grade of HELD", "inherit_grade", {"class": "RESULT", "grade": "HELD"},
refused(P("REC-38", "-", 'grade "HELD" is not a grade')))
ca("IG21 REC-51 inherit_grade of a non-class", "inherit_grade", {"class": "X", "grade": "PROVISIONAL"},
refused(P("REC-51", "-", 'class "X" is not a record class')))
# the register of 16.2: RR-2 an ASSUMPTION; RR-3 a RESULT on RR-2; RR-8 citing RR-3; RR-9 citing
# RR-8, STATUS HELD
R2 = mk("RR-2", "ASSUMPTION", PROPOSITION="The pivot does not move.", REFS=[])
R3 = mk("RR-3", "RESULT", ASSUMPTIONS=["RR-2"], STATEMENT="s3", REGIME="L",
DERIVATION={"STEPS": 1, "TEXT": "t"}, FALSIFIER="f", FALSIFIER_CLASS="F2")
R8 = mk("RR-8", "RESULT", CITES=["RR-3"], STATEMENT="s8", REGIME="L",
DERIVATION={"STEPS": 1, "TEXT": "t"}, FALSIFIER="f", FALSIFIER_CLASS="F2")
R9 = mk("RR-9", "RESULT", CITES=["RR-8"], STATUS="HELD", STATEMENT="s9", REGIME="L",
DERIVATION={"STEPS": 1, "TEXT": "t"}, FALSIFIER="f", FALSIFIER_CLASS="F2")
REG = [R2, R3, R8, R9]
ACT = {"cascade": [["RR-8", "PROVISIONAL"], ["RR-9", "HELD"]], "cause": "AUTHOR", "d_tms": DIS,
"locus_gap": "", "prior_status": "PROVISIONAL", "status_set": "WITHDRAWN", "still_stands": [],
"superseded_by": "", "tps_version": "0.4.0", "withdrawn": "RR-3", "withdrawn_by": "agent-a"}
WF = ["TPC-WITHDRAW", "1", "AUTHOR", "RR-3", "agent-a", "WITHDRAWN", "PROVISIONAL", "", "", 0, 2,
"RR-8", "PROVISIONAL", "RR-9", "HELD", "0.4.0", DIS]
assert len(netstring(WF)) == 182
WD = sha(WF)
assert WD == "2c712168e788348ea4b515f68d2634e5cf37e986be019ec1f3b71b04a7c207c4"
WREC = ["RR-990", "WITHDRAWAL", "AUTHOR", "RR-3", "agent-a", "WITHDRAWN", "PROVISIONAL", "", "", [],
[["RR-8", "PROVISIONAL"], ["RR-9", "HELD"]], "0.4.0", DIS, WD]
REGW = REG + [WREC]
for rid, g in (("RR-2", "PROVISIONAL"), ("RR-3", "PROVISIONAL"), ("RR-8", "PROVISIONAL"),
("RR-9", "PROVISIONAL")):
ca("GN-A %s before the withdrawal" % rid, "grade_now", {"register": REG, "id": rid}, cj(["OK", g]))
for rid, g in (("RR-2", "PROVISIONAL"), ("RR-3", "WITHDRAWN"), ("RR-8", "WITHDRAWN"),
("RR-9", "WITHDRAWN")):
ca("GN-B %s after the withdrawal (16.2)" % rid, "grade_now", {"register": REGW, "id": rid},
cj(["OK", g]))
ca("SWS1 status_words before (16.2)", "status_words", {"register": REG},
cj(["OK", {"RR-2": "PROVISIONAL", "RR-3": "PROVISIONAL", "RR-8": "PROVISIONAL", "RR-9": "HELD"}]))
ca("SWS2 status_words after (16.2)", "status_words", {"register": REGW},
cj(["OK", {"RR-2": "PROVISIONAL", "RR-3": "WITHDRAWN", "RR-8": "WITHDRAWN", "RR-9": "HELD"}]))
PROM = ["RR-992", "PROMOTION", "B-12", [["RR-3", "F2", "F2"]], "0" * 64]
ca("GN-C a PROMOTION sets ESTABLISHED", "grade_now", {"register": REG + [PROM], "id": "RR-3"},
cj(["OK", "ESTABLISHED"]))
ca("GN-D a PROMOTION and a later WITHDRAWAL: WITHDRAWN", "grade_now",
{"register": REG + [PROM, WREC], "id": "RR-3"}, cj(["OK", "WITHDRAWN"]))
ca("GN-E the WITHDRAWAL before the PROMOTION in the list: still WITHDRAWN (precedence)", "grade_now",
{"register": REG + [WREC, PROM], "id": "RR-3"}, cj(["OK", "WITHDRAWN"]))
STRIKE_W = ["RR-991", "WITHDRAWAL", "SR5", "RR-8", "RR-50", "REFUTED", "PROVISIONAL", "", "RR-60", [],
[["RR-9", "HELD"]], "0.4.0", DIS, "1" * 64]
ca("GN-F a cascade and a strike of one record: REFUTED wins", "grade_now",
{"register": REG + [WREC, STRIKE_W], "id": "RR-8"}, cj(["OK", "REFUTED"]))
ca("GN-G the cascaded member of the strike: WITHDRAWN", "grade_now",
{"register": REG + [STRIKE_W], "id": "RR-9"}, cj(["OK", "WITHDRAWN"]))
# D215.2 (functions 0.3.0 6.3, 16.7): the copy RR-3 of PP-3 lands PROVISIONAL, STATUS
# UNMARKED, with INHERITS; TPX then writes RR-993, cause INHERITED, setting the
# predecessor's grade; one setting REFUTED also writes STATUS REFUTED (RD-RS-45)
WI_F = ["TPC-WITHDRAW", "1", "INHERITED", "RR-3", "PP-3", "REFUTED", "PROVISIONAL", "", "", 0, 0,
"0.4.0", DIS]
WI = ["RR-993", "WITHDRAWAL", "INHERITED", "RR-3", "PP-3", "REFUTED", "PROVISIONAL", "", "", [], [],
"0.4.0", DIS, sha(WI_F)]
assert WI[13] == "de0bd3162fdd7f5b9a3f2db4e3e90d552227f230bc13c17766e1bde9217dc727"
WI_W = WI[:5] + ["WITHDRAWN"] + WI[6:13] + [sha(WI_F[:5] + ["WITHDRAWN"] + WI_F[6:])]
assert WI_W[13].startswith("1498e14c")
WI_4 = (WI_W[:3] + ["RR-4", "PP-4"] + WI_W[5:13]
+ [sha(WI_F[:3] + ["RR-4", "PP-4", "WITHDRAWN"] + WI_F[6:])])
assert WI_4[13].startswith("98d2b82c")
C3 = withf(R3, INHERITS="PP-3")
ca("GN-H an inherited record landed PROVISIONAL, its INHERITED withdrawal setting REFUTED",
"grade_now", {"register": [withf(C3, STATUS="REFUTED"), WI], "id": "RR-3"}, cj(["OK", "REFUTED"]))
ca("GN-Q an inherited record landed PROVISIONAL, its INHERITED withdrawal setting WITHDRAWN",
"grade_now", {"register": [C3, WI_W], "id": "RR-3"}, cj(["OK", "WITHDRAWN"]))
ca("GN-R the copy before its INHERITED withdrawal: PROVISIONAL", "grade_now",
{"register": [C3], "id": "RR-3"}, cj(["OK", "PROVISIONAL"]))
ca("SWS5 status_words: an INHERITED REFUTED copy (STATUS REFUTED) and an INHERITED WITHDRAWN one",
"status_words", {"register": [withf(C3, STATUS="REFUTED"), WI,
withf(R8, ID="RR-4", CITES=[], INHERITS="PP-4"), WI_4]},
cj(["OK", {"RR-3": "REFUTED", "RR-4": "WITHDRAWN"}]))
ca("GN-I an inherited REFUTED is not lowered by a later cascade", "grade_now",
{"register": [withf(C3, STATUS="REFUTED"), WI,
["RR-9", "WITHDRAWAL", "AUTHOR", "RR-1", "a", "WITHDRAWN", "PROVISIONAL", "", "", [],
[["RR-3", "PROVISIONAL"]], "0.4.0", DIS, "2" * 64]], "id": "RR-3"},
cj(["OK", "REFUTED"]))
GAPR = mk("RR-4", "NAMED_GAP", SOURCE="UNDER", AGAINST=["x"], TRIGGER="T",
STATEMENT="The unknown DOF x is determined by no form (UNDER).", STATE="OPEN")
ca("GN-J a NOT GRADED record named by a PROMOTION stays NOT GRADED", "grade_now",
{"register": [GAPR, ["RR-9", "PROMOTION", "B", [["RR-4", "F2", "F2"]], "3" * 64]], "id": "RR-4"},
cj(["OK", "NOT GRADED"]))
ca("GN-K REC-52 not in the register", "grade_now", {"register": REG, "id": "RR-77"},
refused(P("REC-52", "-", "record RR-77 is not in the register")))
ca("GN-L REC-52 a list-form id is not a keyed record", "grade_now", {"register": REGW, "id": "RR-990"},
refused(P("REC-52", "-", "record RR-990 is not in the register")))
ca("GN-M REC-50 a member neither form", "grade_now", {"register": REG + [7], "id": "RR-2"},
refused(P("REC-50", "-", "register %s is not a register" % cj(REG + [7]))))
ca("GN-N REC-50 two keyed members with one ID", "grade_now", {"register": [R2, R2], "id": "RR-2"},
refused(P("REC-50", "-", "register %s is not a register" % cj([R2, R2]))))
ca("GN-O REC-50 a register not a list", "status_words", {"register": {}},
refused(P("REC-50", "-", "register {} is not a register")))
ca("GN-P REC-50 a list member of another class", "status_words",
{"register": [["RR-5", "RESULT"]]},
refused(P("REC-50", "-", 'register [["RR-5","RESULT"]] is not a register')))
ca("SWS3 status_words: an ENTRY_STATUS's word is NOT GRADED; a HELD one HELD", "status_words",
{"register": [ES, withf(ES, ID="RR-41", STATUS="HELD"), GAPR]},
cj(["OK", {"RR-40": "NOT GRADED", "RR-41": "HELD", "RR-4": "NOT GRADED"}]))
ca("SWS4 status_words of the empty register", "status_words", {"register": []}, cj(["OK", {}]))
# ---- 5 citation_check
NEW = mk("RR-20", "RESULT", CITES=["RR-3"], ASSUMPTIONS=["RR-2"], STATEMENT="n", REGIME="L",
DERIVATION={"STEPS": 1, "TEXT": "t"}, FALSIFIER="f", FALSIFIER_CLASS="F2")
def cc(name, record, register, expected, entries=(), decided=False):
ca(name, "citation_check", {"record": record, "register": register, "entries": entries if isinstance(entries, str) else list(entries),
"supersede_decided": decided}, expected)
cc("CC01 standing premises", NEW, REG, ok())
cc("CC02 REC-57 the ID already in the register", withf(NEW, ID="RR-8"), REG,
refused(P("REC-57", "ID", "ID RR-8 is already in the register")))
cc("CC03 REC-58 a CITES member not landed", withf(NEW, CITES=["RR-3", "RR-30"]), REG,
refused(P("REC-58", "CITES", "CITES member RR-30 is not a RESULT of the register")))
cc("CC04 REC-58 a CITES member an ASSUMPTION", withf(NEW, CITES=["RR-2"]), REG,
refused(P("REC-58", "CITES", "CITES member RR-2 is not a RESULT of the register")))
cc("CC05 REC-59 a HELD premise (TPS 4.4.9)", withf(NEW, CITES=["RR-9"]), REG,
refused(P("REC-59", "CITES", "CITES member RR-9 does not stand (HELD)")))
cc("CC06 REC-59 a WITHDRAWN premise", withf(NEW, CITES=["RR-8"]), REGW,
refused(P("REC-59", "CITES", "CITES member RR-8 does not stand (WITHDRAWN)")))
cc("CC07 REC-59 a REFUTED premise", withf(NEW, CITES=["RR-3"]), [R2, withf(R3, STATUS="REFUTED")],
refused(P("REC-59", "CITES", "CITES member RR-3 does not stand (REFUTED)")))
cc("CC08 REC-58 an ASSUMPTIONS member a RESULT", withf(NEW, ASSUMPTIONS=["RR-3"]), REG,
refused(P("REC-58", "ASSUMPTIONS", "ASSUMPTIONS member RR-3 is not an ASSUMPTION of the register")))
cc("CC09 REC-59 a WITHDRAWN ASSUMPTION", withf(NEW, ASSUMPTIONS=["RR-2"], CITES=[]),
REG + [["RR-9", "WITHDRAWAL", "AUTHOR", "RR-2", "a", "WITHDRAWN", "PROVISIONAL", "", "", [], [],
"0.4.0", DIS, "4" * 64]],
refused(P("REC-59", "ASSUMPTIONS", "ASSUMPTIONS member RR-2 does not stand (WITHDRAWN)")))
cc("CC10 the first failing member of each field only", withf(NEW, CITES=["RR-30", "RR-31"]), REG,
refused(P("REC-58", "CITES", "CITES member RR-30 is not a RESULT of the register")))
CRR = withf(CORR, ID="RR-21", TARGET="RR-9")
cc("CC11 a CORROBORATION of a HELD target accepted", CRR, REG, ok())
cc("CC12 REC-59 a CORROBORATION of a WITHDRAWN target", withf(CRR, TARGET="RR-8"), REGW,
refused(P("REC-59", "TARGET", "TARGET RR-8 does not stand (WITHDRAWN)")))
cc("CC13 REC-58 a TARGET not a RESULT", withf(CRR, TARGET="RR-2"), REG,
refused(P("REC-58", "TARGET", "TARGET RR-2 is not a RESULT of the register")))
cc("CC14 a VERIFICATION's TARGET", withf(VER, ID="RR-31", TARGET="RR-3"), REG, ok())
SUP = withf(NEW, ID="RR-22", SUPERSEDES="RR-8")
cc("CC15 a supersession by the same author", SUP, REG, ok())
cc("CC16 REC-60 a supersession by another author", withf(SUP, AUTHOR="agent-b"), REG,
refused(P("REC-60", "SUPERSEDES", "SUPERSEDES RR-8 was authored by agent-a, not agent-b")))
cc("CC17 a supersession by another author with the decision", withf(SUP, AUTHOR="agent-b"), REG, ok(),
decided=True)
cc("CC18 REC-58 SUPERSEDES of another class", withf(SUP, SUPERSEDES="RR-2"), REG,
refused(P("REC-58", "SUPERSEDES", "SUPERSEDES RR-2 is not a RESULT of the register")))
cc("CC19 REC-59 SUPERSEDES of a HELD record", withf(SUP, SUPERSEDES="RR-9"), REG,
refused(P("REC-59", "SUPERSEDES", "SUPERSEDES RR-9 does not stand (HELD)")))
cc("CC20 LITERATURE among the entries", withf(NEW, LITERATURE=["RR-BIB1"]), REG, ok(),
entries=["RR-BIB1", "RR-BIB2"])
cc("CC21 REC-61 a LITERATURE member not landed", withf(NEW, LITERATURE=["RR-BIB1", "RR-BIB3"]), REG,
refused(P("REC-61", "LITERATURE", "LITERATURE member RR-BIB3 is not a landed entry of the UWC")),
entries=["RR-BIB1"])
cc("CC22 LITERATURE under OFF with entries []", NEW, REG, ok())
cc("CC23 several fields at once", withf(NEW, ID="RR-2", CITES=["RR-9"], ASSUMPTIONS=["RR-3"]), REG,
refused(P("REC-57", "ID", "ID RR-2 is already in the register"),
P("REC-59", "CITES", "CITES member RR-9 does not stand (HELD)"),
P("REC-58", "ASSUMPTIONS", "ASSUMPTIONS member RR-3 is not an ASSUMPTION of the register")))
cc("CC24 REC-50 entries not a list", NEW, REG,
refused(P("REC-50", "-", 'entries "RR-BIB1" is not a list of BIB IDs')), entries="RR-BIB1")
ca("CC25 REC-50 supersede_decided not a boolean", "citation_check",
{"record": NEW, "register": REG, "entries": [], "supersede_decided": "yes"},
refused(P("REC-50", "-", 'supersede_decided "yes" is not a boolean')))
cc("CC26 an ESTABLISHED premise", NEW, REG + [PROM], ok())
# the record differential of the E5 pass: an ID that is not a string is not looked up for REC-57
# (TPC-PHP's is_string); TPC-PY raised on an unhashable one
cc("CC27 an ID that is an object: no REC-57, the other checks run", withf(CRR, ID={}, TARGET="RR-2"), REG,
refused(P("REC-58", "TARGET", "TARGET RR-2 is not a RESULT of the register")))
cc("CC28 an ID that is a list: no REC-57", withf(NEW, ID=["RR-2"]), REG, ok())
# ---- 6 the withdrawal
def ws(name, register, root, ss, expected):
ca(name, "withdrawal_scope", {"register": register, "root": root, "still_stands": ss}, expected)
ws("WS01 16.2: the author's withdrawal of RR-3", REG, "RR-3", [],
cj(["OK", [["RR-8", "PROVISIONAL"], ["RR-9", "HELD"]]]))
ws("WS02 an ASSUMPTION root", REG, "RR-2", [],
cj(["OK", [["RR-3", "PROVISIONAL"], ["RR-8", "PROVISIONAL"], ["RR-9", "HELD"]]]))
ws("WS03 a still_stands member cut off with its dependents kept", REG, "RR-3", ["RR-8"], cj(["OK", []]))
ws("WS04 REC-62 a still_stands member not reached", REG, "RR-8", ["RR-2"],
refused(P("REC-62", "-", "STILL STANDS member RR-2 is not reached by the withdrawal")))
D1 = mk("RR-11", "RESULT", CITES=["RR-3"])
D2 = mk("RR-12", "RESULT", CITES=["RR-3"])
D3 = mk("RR-13", "RESULT", CITES=["RR-11", "RR-12"])
ws("WS05 a diamond", REG[:2] + [D1, D2, D3], "RR-3", [],
cj(["OK", [["RR-11", "PROVISIONAL"], ["RR-12", "PROVISIONAL"], ["RR-13", "PROVISIONAL"]]]))
C1 = mk("RR-14", "RESULT", CITES=["RR-3", "RR-15"])
C2 = mk("RR-15", "RESULT", CITES=["RR-14"])
ws("WS06 a cycle", REG[:2] + [C1, C2], "RR-3", [],
cj(["OK", [["RR-14", "PROVISIONAL"], ["RR-15", "PROVISIONAL"]]]))
ws("WS07 an already WITHDRAWN member left out, its dependent kept", REGW + [mk("RR-16", "RESULT",
CITES=["RR-9"])],
"RR-2", [], cj(["OK", [["RR-16", "PROVISIONAL"]]]))
ws("WS08 an already REFUTED member left out", [R2, R3, withf(R8, STATUS="REFUTED"),
["RR-993", "WITHDRAWAL", "SR5", "RR-8", "RR-50", "REFUTED",
"PROVISIONAL", "", "RR-60", [], [], "0.4.0", DIS, "1" * 64]],
"RR-3", [], cj(["OK", []]))
ws("WS08b STATUS REFUTED with no grade-setting record: the current grade reads (RD-TQ-40)",
[R2, R3, withf(R8, STATUS="REFUTED")], "RR-3", [], cj(["OK", [["RR-8", "REFUTED"]]]))
ws("WS09 still_stands on a diamond: RR-13 still reached through RR-12", REG[:2] + [D1, D2, D3],
"RR-3", ["RR-11"], cj(["OK", [["RR-12", "PROVISIONAL"], ["RR-13", "PROVISIONAL"]]]))
ws("WS10 REC-52 a root not in the register", REG, "RR-70", [],
refused(P("REC-52", "-", "record RR-70 is not in the register")))
ws("WS11 REC-50 still_stands not a list", REG, "RR-3", "RR-8",
refused(P("REC-50", "-", 'still_stands "RR-8" is not a list of record identifiers')))
ws("WS12 a root with no dependents", REG, "RR-9", [], cj(["OK", []]))
ws("WS13 an ESTABLISHED dependent listed with its word", REG + [PROM], "RR-2", [],
cj(["OK", [["RR-3", "ESTABLISHED"], ["RR-8", "PROVISIONAL"], ["RR-9", "HELD"]]]))
def wp(name, act, expected):
ca(name, "withdrawal_preimage", {"act": act}, expected)
def wr(name, wid, act, expected):
ca(name, "withdrawal_record", {"withdrawal_id": wid, "act": act}, expected)
wp("WP01 16.2's field list", ACT, cj(["OK", WF]))
wr("WR01 16.2's record and digest", "RR-990", ACT, cj(["OK", WREC]))
wr("WR02 the digest is independent of withdrawal_id", "RR-995", ACT,
cj(["OK", ["RR-995"] + WREC[1:]]))
wr("WR03 REC-64 withdrawal_id not an RID", "990", ACT,
refused(P("REC-64", "withdrawal_id", "withdrawal_id 990 is not a record identifier")))
wp("WP02 REC-63 an act with a key missing", without(ACT, "d_tms"),
refused(P("REC-63", "-", "act is not a withdrawal act")))
wp("WP03 REC-63 an act with a key added", withf(ACT, note="x"),
refused(P("REC-63", "-", "act is not a withdrawal act")))
wp("WP04 REC-63 an act not an object", [1], refused(P("REC-63", "-", "act is not a withdrawal act")))
WX = [("cause", "SR2", "cause SR2 is not one of SR1, SR5, AUDIT, AUTHOR, SUPERSEDED or INHERITED"),
("withdrawn", "RR-03", "withdrawn RR-03 is not a record identifier"),
("withdrawn_by", " ", "withdrawn_by is not a text"),
("status_set", "REFUTED", "status_set REFUTED is not the grade cause AUTHOR sets"),
("prior_status", "WITHDRAWN", "prior_status WITHDRAWN is not a status word of a record that "
"stands or is held"),
("superseded_by", "RR-4", "superseded_by RR-4 is not empty"),
("locus_gap", "RR-5", "locus_gap RR-5 is not empty"),
("still_stands", [["RR-8", "PROVISIONAL"]], 'still_stands [["RR-8","PROVISIONAL"]] is not empty'),
("cascade", [["RR-9", "HELD"], ["RR-8", "PROVISIONAL"]],
'cascade [["RR-9","HELD"],["RR-8","PROVISIONAL"]] is not a sorted list of [id, word] pairs'),
("tps_version", "0.4", "tps_version 0.4 is not a version n.n.n"),
("d_tms", "x", "d_tms x is not 64 lowercase hexadecimal characters")]
for i, (k, v, msg) in enumerate(WX):
wp("WX%02d REC-64 %s" % (i, k), withf(ACT, **{k: v}), refused(P("REC-64", k, msg)))
wp("WX20 SR1 sets REFUTED", withf(ACT, cause="SR1", status_set="REFUTED"),
cj(["OK", ["TPC-WITHDRAW", "1", "SR1"] + WF[3:5] + ["REFUTED"] + WF[6:]]))
wp("WX21 REC-64 SR5 with WITHDRAWN", withf(ACT, cause="SR5"),
refused(P("REC-64", "status_set", "status_set WITHDRAWN is not the grade cause SR5 sets")))
wp("WX22 AUDIT with REFUTED or WITHDRAWN", withf(ACT, cause="AUDIT", status_set="REFUTED",
still_stands=[["RR-7", "PROVISIONAL"]]),
cj(["OK", ["TPC-WITHDRAW", "1", "AUDIT", "RR-3", "agent-a", "REFUTED", "PROVISIONAL", "", "", 1,
"RR-7", "PROVISIONAL", 2, "RR-8", "PROVISIONAL", "RR-9", "HELD", "0.4.0", DIS]]))
wp("WX23 SUPERSEDED requires superseded_by", withf(ACT, cause="SUPERSEDED"),
refused(P("REC-64", "superseded_by", "superseded_by is not a record identifier")))
wp("WX24 SUPERSEDED with superseded_by", withf(ACT, cause="SUPERSEDED", superseded_by="RR-22"),
cj(["OK", ["TPC-WITHDRAW", "1", "SUPERSEDED", "RR-3", "agent-a", "WITHDRAWN", "PROVISIONAL",
"RR-22", "", 0, 2, "RR-8", "PROVISIONAL", "RR-9", "HELD", "0.4.0", DIS]]))
wp("WX25 SR5 with a locus gap", withf(ACT, cause="SR5", status_set="REFUTED", locus_gap="RR-60"),
cj(["OK", ["TPC-WITHDRAW", "1", "SR5", "RR-3", "agent-a", "REFUTED", "PROVISIONAL", "", "RR-60",
0, 2, "RR-8", "PROVISIONAL", "RR-9", "HELD", "0.4.0", DIS]]))
wp("WX26 SR5 with no locus gap", withf(ACT, cause="SR5", status_set="REFUTED"),
cj(["OK", ["TPC-WITHDRAW", "1", "SR5", "RR-3", "agent-a", "REFUTED", "PROVISIONAL", "", "", 0, 2,
"RR-8", "PROVISIONAL", "RR-9", "HELD", "0.4.0", DIS]]))
wp("WX27 REC-64 SR5 with a locus gap not an RID", withf(ACT, cause="SR5", status_set="REFUTED",
locus_gap="gap"),
refused(P("REC-64", "locus_gap", "locus_gap gap is not a record identifier")))
wp("WX28 REC-65 withdrawn in the cascade", withf(ACT, cascade=[["RR-3", "PROVISIONAL"]]),
refused(P("REC-65", "-", "RR-3 is named twice")))
wp("WX29 REC-65 an id in both lists", withf(ACT, cause="AUDIT", still_stands=[["RR-8", "PROVISIONAL"]]),
refused(P("REC-65", "-", "RR-8 is named twice")))
wp("WX30 REC-64 a cascade id repeated", withf(ACT, cascade=[["RR-8", "HELD"], ["RR-8", "HELD"]]),
refused(P("REC-64", "cascade", 'cascade [["RR-8","HELD"],["RR-8","HELD"]] is not a sorted list of '
'[id, word] pairs')))
wp("WX31 several keys at once", withf(ACT, cause="X", withdrawn=3, d_tms=None),
refused(P("REC-64", "cause", "cause X is not one of SR1, SR5, AUDIT, AUTHOR, SUPERSEDED or "
"INHERITED"),
P("REC-64", "withdrawn", "withdrawn 3 is not a record identifier"),
P("REC-64", "d_tms", "d_tms null is not 64 lowercase hexadecimal characters")))
wp("WX32 an empty cascade", withf(ACT, cascade=[]),
cj(["OK", WF[:9] + [0, 0] + ["0.4.0", DIS]]))
# D215.2 (functions 0.3.0 6.2, 16.7): the cause INHERITED
ACT_I = withf(ACT, cause="INHERITED", withdrawn_by="PP-3", status_set="REFUTED", cascade=[])
wp("WX33 INHERITED sets REFUTED (D215.2)", ACT_I,
cj(["OK", ["TPC-WITHDRAW", "1", "INHERITED", "RR-3", "PP-3", "REFUTED", "PROVISIONAL", "", "",
0, 0, "0.4.0", DIS]]))
wp("WX34 INHERITED sets WITHDRAWN (D215.2)", withf(ACT_I, status_set="WITHDRAWN"),
cj(["OK", ["TPC-WITHDRAW", "1", "INHERITED", "RR-3", "PP-3", "WITHDRAWN", "PROVISIONAL", "", "",
0, 0, "0.4.0", DIS]]))
wp("WX35 REC-64 INHERITED with a cascade", withf(ACT_I, cascade=ACT["cascade"]),
refused(P("REC-64", "cascade", 'cascade [["RR-8","PROVISIONAL"],["RR-9","HELD"]] is not empty')))
wp("WX36 REC-64 INHERITED with prior_status ESTABLISHED", withf(ACT_I, prior_status="ESTABLISHED"),
refused(P("REC-64", "prior_status", "prior_status ESTABLISHED is not PROVISIONAL")))
wp("WX37 REC-64 INHERITED with prior_status HELD", withf(ACT_I, prior_status="HELD"),
refused(P("REC-64", "prior_status", "prior_status HELD is not PROVISIONAL")))
wp("WX38 REC-64 INHERITED setting PROVISIONAL", withf(ACT_I, status_set="PROVISIONAL"),
refused(P("REC-64", "status_set", "status_set PROVISIONAL is not the grade cause INHERITED sets")))
wp("WX39 REC-64 INHERITED with still_stands", withf(ACT_I, still_stands=[["RR-8", "PROVISIONAL"]]),
refused(P("REC-64", "still_stands", 'still_stands [["RR-8","PROVISIONAL"]] is not empty')))
wr("WR04 the INHERITED record (functions 16.7's form)", "RR-993", ACT_I, cj(["OK", WI]))
# ---- 7 budget_check and field_values
def bc(name, record, expected):
ca(name, "budget_check", {"record": record}, expected)
def comp(name, u, unit, ev="B"):
return {"NAME": name, "U": u, "UNIT": unit, "EVALUATION": ev, "BASIS": "b"}
def mrec(u_c, unit, comps, **kv):
return withf(REC_B, U_C=u_c, UNIT=unit, BUDGET=comps, **kv)
R68 = "U_C %s is not the root sum of squares of BUDGET at its last digit"
bc("BC01 RECORD B (16.1: LOW 13225, S 14356, HIGH 15625 at 10^-10)", REC_B, ok())
bc("BC02 S on HIGH exactly: U_C 5, one component 5.5 (inclusive)", mrec("5", "s", [comp("a", "5.5", "s")]),
ok())
bc("BC03 S on LOW exactly: U_C 5, one component 4.5", mrec("5", "s", [comp("a", "4.5", "s")]), ok())
bc("BC04 REC-68 one digit past HIGH: 5.51", mrec("5", "s", [comp("a", "5.51", "s")]),
refused(P("REC-68", "U_C", R68 % "5")))
bc("BC05 REC-68 one digit below LOW: 4.49", mrec("5", "s", [comp("a", "4.49", "s")]),
refused(P("REC-68", "U_C", R68 % "5")))
bc("BC06 U_C 1e3, component 1000", mrec("1e3", "s", [comp("a", "1000", "s")]), ok())
bc("BC07 U_C 1e3: 500 on LOW (DEC1 of 1 is 0, the factor 5)", mrec("1e3", "s", [comp("a", "500", "s")]),
ok())
bc("BC08 REC-68 U_C 1e3: 1501", mrec("1e3", "s", [comp("a", "1501", "s")]),
refused(P("REC-68", "U_C", R68 % "1e3")))
bc("BC09 U_C 999 with 999", mrec("999", "s", [comp("a", "999", "s")]), ok())
bc("BC10 REC-68 U_C 999 with 998.4", mrec("999", "s", [comp("a", "998.4", "s")]),
refused(P("REC-68", "U_C", R68 % "999")))
bc("BC11 U_C 12e-4 as written (canonical)", mrec("12e-4", "s", REC_B["BUDGET"]), ok())
bc("BC12 a component in km beside m: 0.003 km and 4 m give 5 m",
mrec("5", "m", [comp("a", "0.003", "km"), comp("b", "4", "m")]), ok())
bc("BC13 m2 beside cm2 (shift -4): U_C 1e-4 m2, 1 cm2", mrec("1e-4", "m2", [comp("a", "1", "cm2")]), ok())
bc("BC14 INSPECT min beside s", mrec("5", "s", [comp("a", "0.05", "min")]),
cj(["INSPECT", "BUDGET[1].UNIT min is not a power of ten of UNIT s"]))
bc("BC15 CONVENTION Hz beside s-1", mrec("5", "s-1", [comp("a", "5", "Hz")]),
cj(["CONVENTION", "units of different kind: Hz1 and none"]))
bc("BC16 REC-67 kg beside m", mrec("5", "m", [comp("a", "5", "m"), comp("b", "1", "kg")]),
refused(P("REC-67", "BUDGET[2].UNIT", "BUDGET[2].UNIT kg has dimension M1, not L1")))
bc("BC17 REC-67 before a convention and an inspection",
mrec("5", "s", [comp("a", "5", "min"), comp("b", "1", "Hz-1"), comp("c", "1", "kg")]),
refused(P("REC-67", "BUDGET[3].UNIT", "BUDGET[3].UNIT kg has dimension M1, not T1")))
bc("BC18 a convention before an inspection", mrec("5", "s", [comp("a", "5", "min"),
comp("b", "1", "Hz-1")]),
cj(["CONVENTION", "units of different kind: Hz-1 and none"]))
bc("BC19 a zero component left out", mrec("5", "s", [comp("a", "5", "s"), comp("b", "0", "s")]), ok())
bc("BC20 a single component equal to U_C", mrec("0.0012", "s", [comp("a", "0.0012", "s")]), ok())
bc("BC21 CORRELATED true: INSPECT", withf(REC_B, CORRELATED=True),
cj(["INSPECT", "BUDGET is correlated: its consistency is INSPECTION"]))
bc("BC22 INSPECT past 20000 digits: exponents 9999 and -9999",
mrec("1e9999", "s", [comp("a", "1e-9999", "s")]),
cj(["INSPECT", "BUDGET spans more than 20000 decimal digits"]))
bc("BC23 REC-66 an L record", RES_L, refused(P("REC-66", "-", "budget_check reads an M RESULT")))
bc("BC24 REC-66 not a RESULT", REC_A, refused(P("REC-66", "-", "budget_check reads an M RESULT")))
bc("BC25 REC-68 two components summing past HIGH", mrec("1", "s", [comp("a", "1", "s"), comp("b", "1.2", "s")]),
refused(P("REC-68", "U_C", R68 % "1")))
bc("BC26 two components 3 and 4 give 5", mrec("5", "s", [comp("a", "3", "s"), comp("b", "4", "s")]), ok())
bc("BC27 REC-68 U_C 0.050 at its written digit (1e-3): 0.054 outside",
mrec("0.050", "s", [comp("a", "0.054", "s")]), refused(P("REC-68", "U_C", R68 % "0.050")))
bc("BC28 REC-68 U_C 0.050 at its written digit (1e-3): 0.056 outside",
mrec("0.050", "s", [comp("a", "0.056", "s")]), refused(P("REC-68", "U_C", R68 % "0.050")))
# D218.1 (READY_E5 3.7; functions 0.2.0 7.1 VECTORS): record B's components at U_C as
# written; one component {NAME a, UNIT s, EVALUATION A, BASIS x}
for i, (u_c, want) in enumerate([("0.0010", False), ("0.00100", False), ("1.0e-3", False),
("10e-4", False), ("0.0012", True), ("12e-4", True),
("1e-3", True), ("0.001", True)]):
bc("BC%02d %sU_C %s against record B's budget, at its written digit"
% (29 + i, "" if want else "REC-68 ", u_c), withf(REC_B, U_C=u_c),
ok() if want else refused(P("REC-68", "U_C", R68 % u_c)))
ONE = {"NAME": "a", "UNIT": "s", "EVALUATION": "A", "BASIS": "x"}
bc("BC37 U_C 0.050 against 0.0504 at 1e-3", withf(REC_B, U_C="0.050", BUDGET=[dict(ONE, U="0.0504")]),
ok())
bc("BC38 U_C 5e-2 against 0.054 at 1e-2", withf(REC_B, U_C="5e-2", BUDGET=[dict(ONE, U="0.054")]), ok())
bc("BC39 U_C 0.10e-9999 against 0.1e-9999 (precision form 10e-10001)",
withf(REC_B, U_C="0.10e-9999", BUDGET=[dict(ONE, U="0.1e-9999")]), ok())
# ---- 7.3 prec_decimal (READY_E5 3.7; functions 0.2.0 7.3)
def pd(name, s, expected):
ca(name, "prec_decimal", {"s": s}, expected)
for i, (s, p) in enumerate([("0.0010", "10e-4"), ("1.0e-3", "10e-4"), ("10e-4", "10e-4"),
("0.00100", "100e-5"), ("0.001", "1e-3"), ("1e-3", "1e-3"),
("0.0012", "12e-4"), ("12e-4", "12e-4"), ("100", "100"),
("1.5E+03", "15e2"), ("-0.050", "-50e-3"), ("0.000", "0"),
("12.50e1234", "1250e1232"), ("0.10e-9999", "10e-10001"), ("7", "7")], 1):
pd("PD%02d %s -> %s" % (i, s, p), s, cj(["OK", p]))
pd("PD16 REC-50 a number", 1, refused(P("REC-50", "-", "s 1 is not a decimal string")))
pd("PD17 REC-50 1e", "1e", refused(P("REC-50", "-", 's "1e" is not a decimal string')))
def fv(name, record, expected):
ca(name, "field_values", {"record": record}, expected)
fv("FV01 an L RESULT gives 0", RES_L, cj(["OK", {"U_C": "0"}]))
fv("FV02 an M RESULT in s", REC_B, cj(["OK", {"U_C": "12e-4"}]))
fv("FV03 an M RESULT in ms", withf(REC_B, UNIT="ms", VALUE="2007", U_C="1.2",
BUDGET=[comp("a", "1.2", "ms")]), cj(["OK", {"U_C": "12e-4"}]))
fv("FV04 an M RESULT in km", withf(REC_B, UNIT="km", U_C="0.5", BUDGET=[comp("a", "0.5", "km")]),
cj(["OK", {"U_C": "5e2"}]))
fv("FV05 the twelve-digit rounding", withf(REC_B, U_C="0.1234567890123456"),
cj(["OK", {"U_C": "123456789012e-12"}]))
fv("FV06 REC-69 not a RESULT", REC_A, refused(P("REC-69", "-", "field_values reads a RESULT")))
fv("FV07 REC-70 a unit tpc_units refuses", withf(REC_B, UNIT="furlong"),
refused(P("REC-70", "U_C", "U_C: " + U.normalize_measurement("2.0070", "0.0012", "furlong")[1])))
# ---- 8 l_finding_pair
def lp(name, o, r, expected):
ca(name, "l_finding_pair", {"original": o, "reproduction": r}, expected)
def lres(**kv):
return withf(RES_L, **kv)
def fnd(t, v):
return {"finding": {"type": t, "value": v}}
lp("LP01 EQUATION pair equal", lres(EQUATION="x = 2 * t", REFS=["t", "x"]),
lres(EQUATION="x=2*t", REFS=["t", "x"]), cj(["OK", fnd("EQUATION", "x=2*t"), fnd("EQUATION", "x=2*t")]))
lp("LP02 EQUATION x*2 against 2*x (2.2.14's limit)", lres(EQUATION="y = x*2", REFS=["x", "y"]),
lres(EQUATION="y = 2*x", REFS=["x", "y"]),
cj(["OK", fnd("EQUATION", "y=x*2"), fnd("EQUATION", "y=2*x")]))
lp("LP03 VALUE 2 km against 2000 m (16.6)", lres(QUANTITY="E_x", VALUE="2", UNIT="km"),
lres(QUANTITY="E_x", VALUE="2000", UNIT="m"), cj(["OK", fnd("DECIMAL", "2e3"), fnd("DECIMAL", "2e3")]))
lp("LP04 REC-72 2 m against 2 s", lres(QUANTITY="q", VALUE="2", UNIT="m"),
lres(QUANTITY="q", VALUE="2", UNIT="s"),
refused(P("REC-72", "-", "units of different dimension: L1 and T1")))
lp("LP05 CONVENTION Hz against s-1", lres(QUANTITY="q", VALUE="2", UNIT="Hz"),
lres(QUANTITY="q", VALUE="2", UNIT="s-1"), cj(["CONVENTION", "units of different kind: Hz1 and none"]))
lp("LP06 EQUATION on one side and VALUE on both: VALUE", lres(EQUATION="x = 1", REFS=["x"], QUANTITY="q",
VALUE="1", UNIT="m"),
lres(QUANTITY="q", VALUE="100", UNIT="cm"), cj(["OK", fnd("DECIMAL", "1"), fnd("DECIMAL", "1")]))
lp("LP07 EQUATION on one side, VALUE on the other only: TEXT", lres(EQUATION="x = 1", REFS=["x"]),
lres(QUANTITY="q", VALUE="1", UNIT="m"),
cj(["OK", fnd("TEXT", RES_L["STATEMENT"]), fnd("TEXT", RES_L["STATEMENT"])]))
lp("LP08 TEXT differing in NFC only: equal after canonical text", lres(STATEMENT="café"),
lres(STATEMENT="café"), cj(["OK", fnd("TEXT", "café"), fnd("TEXT", "café")]))
lp("LP09 TEXT with CRLF", lres(STATEMENT="a\r\nb"), lres(STATEMENT="a\nb"),
cj(["OK", fnd("TEXT", "a\nb"), fnd("TEXT", "a\nb")]))
lp("LP10 REC-71 an M RESULT", REC_B, RES_L, refused(P("REC-71", "-", "l_finding_pair reads two L RESULTs")))
lp("LP11 REC-71 an ASSUMPTION", RES_L, REC_A, refused(P("REC-71", "-", "l_finding_pair reads two L RESULTs")))
lp("LP12 VALUE 0.5 s against 500 ms", lres(QUANTITY="q", VALUE="0.5", UNIT="s"),
lres(QUANTITY="q", VALUE="500", UNIT="ms"), cj(["OK", fnd("DECIMAL", "5e-1"), fnd("DECIMAL", "5e-1")]))
# ---- 11 the declared form on a record
def fc(name, record, expected):
ca(name, "record_form_check", {"record": record, "tfk": TFK}, expected)
def dc(name, record, expected):
ca(name, "domain_check", {"record": record, "tfk": TFK}, expected)
R75 = refused(P("REC-75", "-", "record_form_check reads a RESULT or an ASSUMPTION"))
fc("FC01 a derived EOM(v)", lres(EQUATION="m*D(v,t) = -k_s*x", REFS=["k_s", "m", "t", "v", "x"],
ROLE="EOM(v)"), ok())
fc("FC02 REC-81 EOM(q), q not a DOF", lres(EQUATION="m*D(v,t) = -k_s*x", REFS=["k_s", "m", "t", "v", "x"],
ROLE="EOM(q)"),
refused(P("REC-81", "ROLE", "ROLE EOM(q): q is not a DOF of the TPK")))
fc("FC03 REC-81 EOM(m), m a CONSTANT", lres(EQUATION="D(x,t) = v", REFS=["t", "v", "x"], ROLE="EOM(m)"),
refused(P("REC-81", "ROLE", "ROLE EOM(m): m is not a DOF of the TPK")))
fc("FC04 REC-80 a second D variable under ONE", lres(EQUATION="D(v, x) = v/x", REFS=["v", "x"]),
refused(P("REC-80", "EQUATION", "EQUATION's D variables x and the TPK's t are more than one under "
"D_VARIABLES ONE")))
fc("FC05 REC-79 the TARGET of a CONSTRAINT as D variable", lres(EQUATION="D(x, z) = x/z", REFS=["x", "z"]),
refused(P("REC-79", "EQUATION", "EQUATION's D variable z is the TARGET of CONSTRAINT:C_NOZ"),
P("REC-80", "EQUATION", "EQUATION's D variables z and the TPK's t are more than one under "
"D_VARIABLES ONE")))
fc("FC06 REC-79 a D variable not a DOF", lres(EQUATION="D(x, m) = x/m", REFS=["m", "x"]),
refused(P("REC-79", "EQUATION", "EQUATION's D variable m is not a DOF"),
P("REC-80", "EQUATION", "EQUATION's D variables m and the TPK's t are more than one under "
"D_VARIABLES ONE")))
fc("FC07 REC-76 a name outside REFS", lres(EQUATION="D(x,t) = v", REFS=["t", "x"]),
refused(P("REC-76", "EQUATION", "EQUATION names v, which is not in REFS")))
fc("FC08 REC-77 a REFS member named by neither form", lres(EQUATION="D(x,t) = v", REFS=["m", "t", "v", "x"]),
refused(P("REC-77", "REFS", "REFS m is named in neither EQUATION nor DOMAIN_CONDITION")))
fc("FC09 a REFS member named by DOMAIN_CONDITION", lres(EQUATION="D(x,t) = v", REFS=["t", "v", "x", "x_max"],
DOMAIN_CONDITION="abs(x) < x_max"), ok())
fc("FC10 INVARIANT", lres(EQUATION="m*v = m*v", REFS=["m", "v"], ROLE="INVARIANT"), ok())
_T4 = F.form_dimension("x = t", "equation", {"x": "L1", "t": "T1"})[1]
fc("FC11 REC-78 T4's law half", lres(EQUATION="x = t", REFS=["t", "x"]),
refused(P("REC-78", "EQUATION", "EQUATION %s (T4)" % _T4)))
fc("FC12 no form", RES_L, ok())
fc("FC13 REC-75 a CORROBORATION", CORR, R75)
fc("FC14 an ASSUMPTION supplying an equation", withf(REC_A, EQUATION="x = x_max", REFS=["x", "x_max"],
ROLE="CONSTRAINT"), ok())
fc("FC15 the names step stops the check before T4", lres(EQUATION="x = t", REFS=["x"]),
refused(P("REC-76", "EQUATION", "EQUATION names t, which is not in REFS")))
fc("FC16 the D step stops the check before ROLE", lres(EQUATION="D(v, x) = v/x", REFS=["v", "x"],
ROLE="EOM(q)"),
refused(P("REC-80", "EQUATION", "EQUATION's D variables x and the TPK's t are more than one under "
"D_VARIABLES ONE")))
# the record differential of the E5 pass: a TPK CONSTRAINT that is not a list reads as none,
# as TPC-PHP reads it; TPC-PY raised on null
_TFK_NC = copy.deepcopy(TFK)
_TFK_NC["TPK"]["CONSTRAINT"] = None
ca("FC17 a TPK CONSTRAINT null reads as none", "record_form_check",
{"record": lres(EQUATION="D(x,t) = v", REFS=["t", "v", "x", "x_max"], DOMAIN_CONDITION="abs(x) < x_max"),
"tfk": _TFK_NC}, ok())
ca("FC18 no CONSTRAINT read: z a D variable but no TARGET (REC-80 alone)", "record_form_check",
{"record": lres(EQUATION="D(x, z) = x/z", REFS=["x", "z"]), "tfk": _TFK_NC},
refused(P("REC-80", "EQUATION", "EQUATION's D variables z and the TPK's t are more than one under "
"D_VARIABLES ONE")))
dc("DC01 a total condition", lres(DOMAIN="small x", DOMAIN_CONDITION="abs(x) < x_max", REFS=["x", "x_max"]),
ok())
_T6 = F.form_totality("ln(x/x_max) > 0", {"x": "L1", "x_max": "L1"})[1]
dc("DC02 REC-83 an unguarded ln and division", lres(DOMAIN_CONDITION="ln(x/x_max) > 0", REFS=["x", "x_max"]),
refused(*[P("REC-83", "DOMAIN_CONDITION", "DOMAIN_CONDITION %s (T6)" % p) for p in _T6]))
_T6R = F.form_totality("x > t", {"x": "L1", "t": "T1"})[1]
dc("DC03 REC-83 a dimension mismatch in a comparison", lres(DOMAIN_CONDITION="x > t", REFS=["t", "x"]),
refused(P("REC-83", "DOMAIN_CONDITION", "DOMAIN_CONDITION %s (T6)" % _T6R)))
dc("DC04 REC-82 a condition naming outside REFS", lres(DOMAIN_CONDITION="abs(x) < x_max", REFS=["x"]),
refused(P("REC-82", "DOMAIN_CONDITION", "DOMAIN_CONDITION names x_max, which is not in REFS")))
dc("DC05 REC-77 without EQUATION a REFS member the condition does not name",
lres(DOMAIN_CONDITION="abs(x) < x_max", REFS=["v", "x", "x_max"]),
refused(P("REC-77", "REFS", "REFS v is named in neither EQUATION nor DOMAIN_CONDITION")))
dc("DC06 with EQUATION the REFS rule is record_form_check's",
lres(EQUATION="D(x,t) = v", DOMAIN_CONDITION="abs(x) < x_max", REFS=["t", "v", "x", "x_max"]), ok())
dc("DC07 no DOMAIN_CONDITION", RES_L, ok())
dc("DC08 the names step stops the check before T6", lres(DOMAIN_CONDITION="x > t", REFS=["x"]),
refused(P("REC-82", "DOMAIN_CONDITION", "DOMAIN_CONDITION names t, which is not in REFS")))
# ---- 13 named gaps
GF1 = ["TPC-RECORD", "1", 10, "ID", "RR-2", "CLASS", "NAMED_GAP", "GRADE", "NOT GRADED", "LANDED_BY",
"TPX", "LANDED", T0, "TPS", "0.4.0", "SOURCE", "IC2", "AGAINST", 1, "theta", "TRIGGER",
"DECLARATIONS Volume 1, line 7", "STATEMENT", "The DOF theta is tied by no TrM entry (IC2)."]
GD1 = sha(GF1)
assert GD1 == "97a3f62acc1efff0df133b21d0c54859fa55b6e1b849ae9b983e048a4865228b"
GF2 = ["TPC-RECORD", "1", 10, "ID", "RR-3", "CLASS", "NAMED_GAP", "GRADE", "NOT GRADED", "LANDED_BY",
"TPX", "LANDED", T0, "TPS", "0.4.0", "SOURCE", "UNDER", "AGAINST", 1, "x", "TRIGGER",
"DECLARATIONS Volume 1, line 7", "STATEMENT", "The unknown DOF x is determined by no form (UNDER)."]
GD2 = sha(GF2)
assert GD2 == "bbe017aec02f031f2e801a15c4e6a0f64ed9cc222ba2afffdc20c7d3be60b4df"
def gapr(rid, src, against, stmt, trig="DECLARATIONS Volume 1, line 7"):
fl = ["TPC-RECORD", "1", 10, "ID", rid, "CLASS", "NAMED_GAP", "GRADE", "NOT GRADED", "LANDED_BY", "TPX",
"LANDED", T0, "TPS", "0.4.0", "SOURCE", src, "AGAINST", len(against)] + sorted(against) + \
["TRIGGER", trig, "STATEMENT", stmt]
return {"ID": rid, "CLASS": "NAMED_GAP", "GRADE": "NOT GRADED", "LANDED_BY": "TPX", "LANDED": T0,
"TPS": "0.4.0", "SOURCE": src, "AGAINST": sorted(against), "TRIGGER": trig, "STATEMENT": stmt,
"STATE": "OPEN", "DIGEST": sha(fl)}
def gr(name, ic2, under, expected, prefix="RR", trig="DECLARATIONS Volume 1, line 7", landed=T0, tps="0.4.0"):
ca(name, "gap_records", {"prefix": prefix, "ic2": ic2, "under": under, "trigger": trig,
"landed": landed, "tps": tps}, expected)
TIC2 = "The DOF %s is tied by no TrM entry (IC2)."
TUND = "The unknown DOF %s is determined by no form (UNDER)."
G16 = [gapr("RR-2", "IC2", ["theta"], TIC2 % "theta"), gapr("RR-3", "UNDER", ["x"], TUND % "x")]
assert G16[0]["DIGEST"] == GD1 and G16[1]["DIGEST"] == GD2
gr("GR01 16.4: one IC2 and one UNDER gap", ["theta"], ["x"], cj(["OK", G16]))
gr("GR02 IC2 only, sorted", ["z", "theta"], [], cj(["OK", [gapr("RR-2", "IC2", ["theta"], TIC2 % "theta"),
gapr("RR-3", "IC2", ["z"], TIC2 % "z")]]))
gr("GR03 UNDER only", [], ["x", "v"], cj(["OK", [gapr("RR-2", "UNDER", ["v"], TUND % "v"),
gapr("RR-3", "UNDER", ["x"], TUND % "x")]]))
gr("GR04 one DOF in both lists: two records", ["z"], ["z"],
cj(["OK", [gapr("RR-2", "IC2", ["z"], TIC2 % "z"), gapr("RR-3", "UNDER", ["z"], TUND % "z")]]))
gr("GR05 none", [], [], cj(["OK", []]))
gr("GR06 REC-89 a DOF repeated in ic2", ["z", "z"], [], refused(P("REC-89", "-", "ic2 repeats z")))
gr("GR07 REC-89 a DOF repeated in under", [], ["x", "v", "x"], refused(P("REC-89", "-", "under repeats x")))
gr("GR08 REC-50 ic2 not a list", "z", [], refused(P("REC-50", "-", 'ic2 "z" is not a list of identifiers')))
gr("GR09 REC-50 an under member not an identifier", [], ["2x"],
refused(P("REC-50", "-", 'under ["2x"] is not a list of identifiers')))
gr("GR10 REC-50 landed not a UTC time", ["z"], [], refused(P("REC-50", "-", 'landed "now" is not a UTC time')),
landed="now")
gr("GR11 REC-50 tps not a version", ["z"], [], refused(P("REC-50", "-", 'tps "0.4" is not a version n.n.n')),
tps="0.4")
gr("GR12 a prefix that makes no RID: record_check's refusal returned", ["z"], [],
refused(P("REC-19", "ID", "ID 2x-2 is not a record identifier")), prefix="2x")
gr("GR13 a blank trigger: record_check's refusal returned", ["z"], [],
refused(P("REC-11", "TRIGGER", "TRIGGER is blank")), trig=" ")
TSR5 = "The ASSUMPTIONS %s lie outside the closer record's closure in the withdrawal %s (SR5)."
TSR7A = "The ASSUMPTIONS %s of an L record are contradicted by %s (SR7)."
TSR7D = "%s contradicts an L record whose a(r) is 0: a finding against the TFK DOMAIN (SR7)."
def gr1(name, rid, src, against, trig, expected):
ca(name, "gap_record", {"id": rid, "source": src, "against": against, "trigger": trig, "landed": T0,
"tps": "0.4.0"}, expected)
gr1("GQ01 an SR5 locus gap", "RR-60", "SR5_LOCUS", ["RR-5", "RR-4"], "RR-50",
cj(["OK", gapr("RR-60", "SR5_LOCUS", ["RR-5", "RR-4"], TSR5 % ("RR-4, RR-5", "RR-50"), "RR-50")]))
gr1("GQ02 an SR7 assumptions gap", "RR-61", "SR7_ASSUMPTIONS", ["RR-4"], "RR-31",
cj(["OK", gapr("RR-61", "SR7_ASSUMPTIONS", ["RR-4"], TSR7A % ("RR-4", "RR-31"), "RR-31")]))
gr1("GQ03 an SR7 DOMAIN gap", "RR-62", "SR7_DOMAIN", ["TFK DOMAIN"], "RR-31",
cj(["OK", gapr("RR-62", "SR7_DOMAIN", ["TFK DOMAIN"], TSR7D % "RR-31", "RR-31")]))
gr1("GQ04 an SR5 gap whose TRIGGER is not an RID: record_check's refusal", "RR-60", "SR5_LOCUS", ["RR-4"],
"the withdrawal", refused(P("REC-19", "TRIGGER", "TRIGGER the withdrawal is not a record identifier")))
gr1("GQ05 an SR7 DOMAIN gap against another member", "RR-62", "SR7_DOMAIN", ["x"], "RR-31",
refused(P("REC-19", "AGAINST", "AGAINST is not the one member TFK DOMAIN")))
gr1("GQ06 an IC2 gap found later", "RR-63", "IC2", ["z"], "DECLARATIONS Volume 1, line 7",
cj(["OK", gapr("RR-63", "IC2", ["z"], TIC2 % "z")]))
gr1("GQ07 an unknown source: record_check's refusal", "RR-64", "SR6", ["RR-4"], "RR-31",
refused(P("REC-08", "STATEMENT", "STATEMENT is missing"),
P("REC-12", "SOURCE", "SOURCE SR6 is not one of IC2, UNDER, SR5_LOCUS, SR7_ASSUMPTIONS or "
"SR7_DOMAIN")))
def gs(name, state, date, what, expected):
ca(name, "gap_state", {"state": state, "date": date, "what": what}, expected)
gs("GS01 OPEN", "OPEN", None, None, cj(["OK", "OPEN"]))
gs("GS02 SETTLED, identifiers sorted", "SETTLED", "2026-09-28", ["RR-9", "RR-12"],
cj(["OK", "SETTLED 2026-09-28 BY RR-12, RR-9"]))
gs("GS03 STANDING", "STANDING", "2026-09-28", "DECLARATIONS Volume 2, line 4",
cj(["OK", "STANDING 2026-09-28 BY DECLARATIONS Volume 2, line 4"]))
gs("GS04 REC-90 another state", "CLOSED", "2026-09-28", [],
refused(P("REC-90", "-", "state CLOSED is not OPEN, SETTLED or STANDING")))
gs("GS05 REC-50 a date that is not real", "SETTLED", "2026-02-30", ["RR-9"],
refused(P("REC-50", "-", 'date "2026-02-30" is not a date YYYY-MM-DD')))
gs("GS06 REC-50 SETTLED with no identifiers", "SETTLED", "2026-09-28", [],
refused(P("REC-50", "-", "what [] is not a list of record identifiers")))
gs("GS07 REC-50 STANDING with a blank line", "STANDING", "2026-09-28", " ",
refused(P("REC-50", "-", 'what " " is not a text')))
gs("GS08 REC-50 SETTLED with a repeated identifier", "SETTLED", "2026-09-28", ["RR-9", "RR-9"],
refused(P("REC-50", "-", 'what ["RR-9","RR-9"] is not a list of record identifiers')))
gs("GS09 OPEN reads neither date nor what", "OPEN", "x", 5, cj(["OK", "OPEN"]))
UG = gapr("RR-4", "UNDER", ["x"], TUND % "x")
IG2 = gapr("RR-5", "IC2", ["v"], TIC2 % "v")
ca("EO01 eom0_open: an UNDER gap OPEN", "eom0_open", {"records": [UG, IG2]}, cj(["OK", True]))
ca("EO02 eom0_open: the UNDER gap SETTLED", "eom0_open",
{"records": [withf(UG, STATE="SETTLED 2026-09-28 BY RR-9"), IG2]}, cj(["OK", False]))
ca("EO03 eom0_open: an IC2 gap OPEN only", "eom0_open", {"records": [IG2]}, cj(["OK", False]))
ca("EO04 eom0_open: STANDING", "eom0_open", {"records": [withf(UG, STATE="STANDING 2026-09-28 BY L7")]},
cj(["OK", False]))
ca("EO05 REC-50 records not a list", "eom0_open", {"records": UG},
refused(P("REC-50", "-", "records %s is not a register" % cj(UG))))
# gap_view over the example TFK: E_x's DOF is x
GV_R1 = mk("RR-20", "RESULT", REFS=["x"], STATEMENT="s", REGIME="L", DERIVATION={"STEPS": 1, "TEXT": "t"},
FALSIFIER="f", FALSIFIER_CLASS="F2")
GV_R2 = withf(REC_B, ID="RR-21", QUANTITY="E_x", ENTRIES=["E_x"], ASSUMPTIONS=["RR-2"], CITES=[])
GV_R3 = mk("RR-22", "RESULT", ENTRIES=["E_x"], STATUS="HELD", STATEMENT="s", REGIME="L",
DERIVATION={"STEPS": 1, "TEXT": "t"}, FALSIFIER="f", FALSIFIER_CLASS="F2")
GV_R4 = mk("RR-23", "RESULT", CITES=["RR-21"], STATEMENT="s", REGIME="L", DERIVATION={"STEPS": 1, "TEXT": "t"},
FALSIFIER="f", FALSIFIER_CLASS="F2")
GV_REG = [R2, GV_R1, GV_R2, GV_R3, GV_R4]
ca("GW01 IC2 gap on x: REFS and QUANTITY touch; a HELD record does not stand", "gap_view",
{"gap": gapr("RR-5", "IC2", ["x"], TIC2 % "x"), "records": GV_REG, "tfk": TFK},
cj(["OK", ["RR-20", "RR-21"]]))
ca("GW02 SR5 locus gap on RR-2: the assumption closure, transitively", "gap_view",
{"gap": gapr("RR-60", "SR5_LOCUS", ["RR-2"], TSR5 % ("RR-2", "RR-50"), "RR-50"), "records": GV_REG,
"tfk": TFK}, cj(["OK", ["RR-21", "RR-23"]]))
ca("GW03 SR7_DOMAIN: the view is empty", "gap_view",
{"gap": gapr("RR-62", "SR7_DOMAIN", ["TFK DOMAIN"], TSR7D % "RR-31", "RR-31"), "records": GV_REG,
"tfk": TFK}, cj(["OK", []]))
ca("GW04 UNDER gap on v: nothing touches it", "gap_view",
{"gap": gapr("RR-6", "UNDER", ["v"], TUND % "v"), "records": GV_REG, "tfk": TFK}, cj(["OK", []]))
ca("GW05 REC-50 a gap that is not a NAMED_GAP", "gap_view", {"gap": R2, "records": GV_REG, "tfk": TFK},
refused(P("REC-50", "-", "gap %s is not a NAMED_GAP record" % cj(R2))))
# ---- 14 verification
def vo(name, t, v, s, expected):
ca(name, "verification_order", {"target_push": t, "verification_push": v, "source_push": s}, expected)
vo("VO01 after the target, source after", 3, 5, 4, ok())
vo("VO02 REC-91 the same push", 3, 3, None,
refused(P("REC-91", "-", "the VERIFICATION lands in its TARGET's push or before it")))
vo("VO03 REC-91 before the target", 3, 2, None,
refused(P("REC-91", "-", "the VERIFICATION lands in its TARGET's push or before it")))
vo("VO04 INSPECT the source before the target", 3, 5, 1,
cj(["INSPECT", "the SOURCE entry landed before the TARGET"]))
vo("VO05 the source in the target's push", 3, 5, 3, ok())
vo("VO06 prose SOURCE (null)", 0, 1, None, ok())
vo("VO07 REC-50 a negative push", -1, 1, None,
refused(P("REC-50", "-", "pushes [-1,1,null] is not integers from 0")))
vo("VO08 REC-50 a push as text", 1, "2", None,
refused(P("REC-50", "-", 'pushes [1,"2",null] is not integers from 0')))
VT = withf(REC_B, ID="RR-7")
VV = withf(VER, TARGET="RR-7", AT=[{"DOF": "t", "VALUE": "0", "UNIT": "ms"}])
def vd(name, t, v, k, expected):
ca(name, "verification_difference", {"target": t, "verification": v, "k": k}, expected)
vd("VD01 16.5: RECORD B against 2.0064 s, k 2", VT, VV,
"2", cj(["OK", {"VALUE": "6e-4", "U": "13e-4", "ZETA": "461538461538e-12"}, False]))
vd("VD02 an L target (u 0)", withf(RES_L, ID="RR-7", QUANTITY="period", VALUE="2.007", UNIT="s"),
withf(VER, TARGET="RR-7", DIFFERENCE={"VALUE": "6e-4", "U": "5e-4", "ZETA": "12e-1"}),
"2", cj(["OK", {"VALUE": "6e-4", "U": "5e-4", "ZETA": "12e-1"}, False]))
vd("VD03 an L target contradicting: zeta 3 against k 2", withf(RES_L, ID="RR-7", QUANTITY="period",
VALUE="2.0079", UNIT="s"),
withf(VER, TARGET="RR-7", DIFFERENCE={"VALUE": "15e-4", "U": "5e-4", "ZETA": "3"}),
"2", cj(["OK", {"VALUE": "15e-4", "U": "5e-4", "ZETA": "3"}, True]))
vd("VD04 zeta exactly k does not contradict", withf(RES_L, ID="RR-7", QUANTITY="period", VALUE="2.0074",
UNIT="s"),
withf(VER, TARGET="RR-7", DIFFERENCE={"VALUE": "1e-3", "U": "5e-4", "ZETA": "2"}),
"2", cj(["OK", {"VALUE": "1e-3", "U": "5e-4", "ZETA": "2"}, False]))
vd("VD05 m against km", withf(RES_L, ID="RR-7", QUANTITY="period", VALUE="2000", UNIT="m"),
withf(VER, TARGET="RR-7", EXTERNAL={"VALUE": "2", "U_C": "0.001", "UNIT": "km", "QUANTITY": "period"},
DIFFERENCE={"VALUE": "0", "U": "1", "ZETA": "0"}),
"2", cj(["OK", {"VALUE": "0", "U": "1", "ZETA": "0"}, False]))
vd("VD06 CONVENTION Hz against s-1", withf(RES_L, ID="RR-7", QUANTITY="period", VALUE="2", UNIT="Hz"),
withf(VER, TARGET="RR-7", EXTERNAL={"VALUE": "2", "U_C": "0.1", "UNIT": "s-1", "QUANTITY": "period"}),
"2", cj(["CONVENTION", "units of different kind: Hz1 and none"]))
vd("VD07 REC-72 m against s", withf(RES_L, ID="RR-7", QUANTITY="period", VALUE="2", UNIT="m"), VER, "2",
refused(P("REC-72", "-", "units of different dimension: L1 and T1")))
vd("VD08 REC-95 both u 0", withf(RES_L, ID="RR-7", QUANTITY="period", VALUE="2", UNIT="s"),
withf(VER, TARGET="RR-7", EXTERNAL={"VALUE": "2", "U_C": "0", "UNIT": "s", "QUANTITY": "period"}), "2",
refused(P("REC-95", "-", "U is 0: both uncertainties are 0")))
vd("VD09 REC-96 a presented DIFFERENCE off in its last digit", VT,
withf(VV, DIFFERENCE={"VALUE": "6e-4", "U": "13e-4", "ZETA": "461538461539e-12"}), "2",
refused(P("REC-96", "DIFFERENCE.ZETA", "DIFFERENCE.ZETA 461538461539e-12 is not the recomputed "
"461538461538e-12")))
vd("VD10 a presented DIFFERENCE in another spelling of the same value", VT,
withf(VV, DIFFERENCE={"VALUE": "0.0006", "U": "0.00130", "ZETA": "0.461538461538"}), "2",
cj(["OK", {"VALUE": "6e-4", "U": "13e-4", "ZETA": "461538461538e-12"}, False]))
vd("VD11 REC-93 QUANTITY mismatch", VT, withf(VV, EXTERNAL=withf(VV["EXTERNAL"], QUANTITY="length")), "2",
refused(P("REC-93", "EXTERNAL.QUANTITY", "EXTERNAL.QUANTITY length is not the TARGET's QUANTITY period")))
vd("VD12 REC-94 AT mismatch", VT, withf(VV, AT=[{"DOF": "t", "VALUE": "1", "UNIT": "s"}]), "2",
refused(P("REC-94", "AT", "AT is not the TARGET's AT")))
vd("VD13 REC-94 AT absent against the target's", VT, without(VV, "AT"), "2",
refused(P("REC-94", "AT", "AT is not the TARGET's AT")))
vd("VD14 REC-92 a VERIFICATION of another target", VT, withf(VV, TARGET="RR-8"), "2",
refused(P("REC-92", "-", "verification_difference reads a RESULT and a VERIFICATION of it")))
vd("VD15 REC-92 a target without VALUE", RES_L, withf(VV, TARGET="RR-10"), "2",
refused(P("REC-92", "-", "verification_difference reads a RESULT and a VERIFICATION of it")))
vd("VD16 REC-50 k not a positive canonical decimal", VT, VV, "2.0",
refused(P("REC-50", "-", 'k "2.0" is not a positive canonical decimal')))
vd("VD17 REC-50 k zero", VT, VV, "0", refused(P("REC-50", "-", 'k "0" is not a positive canonical decimal')))
# ---- 15 promotion, the entry view, successors
PR_R = mk("RR-30", "RESULT", STATEMENT="The amplitude stays below x_max.", REGIME="L",
DERIVATION={"STEPS": 2, "TEXT": "t"}, FALSIFIER="f", FALSIFIER_CLASS="F3", DOMAIN="small x",
DOMAIN_CONDITION="abs(x) < x_max", REFS=["x", "x_max"], ENTRIES=["E_x"], ASSUMPTIONS=["RR-2"])
PR_W = {"RR-2": "PROVISIONAL", "RR-30": "PROVISIONAL"}
def pe(name, records, words, audits, rid, expected, tfk=None):
ca(name, "promotion_eligible", {"records": records, "words": words, "tfk": tfk or TFK,
"open_audits": audits, "id": rid}, expected)
pe("PE01 eligible: F3 against the floor F2", [R2, PR_R], PR_W, [], "RR-30", cj(["ELIGIBLE", "F3", "F2"]))
pe("PE02 class read: the lowest of the record's and its entries' (E_v F2)",
[R2, withf(PR_R, ENTRIES=["E_v", "E_x"])], PR_W, [], "RR-30", cj(["ELIGIBLE", "F2", "F2"]))
pe("PE03 the record's F1 below the floor", [R2, withf(PR_R, FALSIFIER_CLASS="F1")], PR_W, [], "RR-30",
cj(["NOT", ["FALSIFIER_CLASS F1 is below PROMOTION_FLOOR F2"]]))
TFK_F3 = copy.deepcopy(TFK)
TFK_F3["TMS"]["PARAMETERS"]["PROMOTION_FLOOR"] = "F3"
pe("PE04 a floor F3 and an entry of F2", [R2, withf(PR_R, ENTRIES=["E_v"])], PR_W, [], "RR-30",
cj(["NOT", ["FALSIFIER_CLASS F2 is below PROMOTION_FLOOR F3"]]), tfk=TFK_F3)
TFK_F1 = copy.deepcopy(TFK)
TFK_F1["TMS"]["PARAMETERS"]["PROMOTION_FLOOR"] = "F1"
pe("PE05 a floor F1", [R2, withf(PR_R, FALSIFIER_CLASS="F1")], PR_W, [], "RR-30",
cj(["ELIGIBLE", "F1", "F1"]), tfk=TFK_F1)
pe("PE06 DOMAIN and DOMAIN_CONDITION absent", [R2, without(PR_R, "DOMAIN", "DOMAIN_CONDITION")], PR_W, [],
"RR-30", cj(["NOT", ["DOMAIN is absent", "DOMAIN_CONDITION is absent"]]))
pe("PE07 ENTRIES absent", [R2, without(PR_R, "ENTRIES")], PR_W, [], "RR-30",
cj(["NOT", ["ENTRIES is absent or empty"]]))
pe("PE08 ENTRIES empty", [R2, withf(PR_R, ENTRIES=[])], PR_W, [], "RR-30",
cj(["NOT", ["ENTRIES is absent or empty"]]))
PR_C = withf(PR_R, ID="RR-31", CITES=["RR-30"])
pe("PE09 a PROVISIONAL premise", [R2, PR_R, PR_C], dict(PR_W, **{"RR-31": "PROVISIONAL"}), [], "RR-31",
cj(["NOT", ["cites RR-30, which is not ESTABLISHED"]]))
pe("PE10 an ESTABLISHED premise", [R2, PR_R, PR_C], dict(PR_W, **{"RR-30": "ESTABLISHED",
"RR-31": "PROVISIONAL"}), [], "RR-31",
cj(["ELIGIBLE", "F3", "F2"]))
pe("PE11 an open audit on a premise's assumption", [R2, PR_R, PR_C],
dict(PR_W, **{"RR-30": "ESTABLISHED", "RR-31": "PROVISIONAL"}), ["RR-2"], "RR-31",
cj(["NOT", ["an audit block is open on RR-2"]]))
pe("PE12 an open audit on the record and a premise", [R2, PR_R, PR_C],
dict(PR_W, **{"RR-31": "PROVISIONAL"}), ["RR-31", "RR-30"], "RR-31",
cj(["NOT", ["cites RR-30, which is not ESTABLISHED", "an audit block is open on RR-30",
"an audit block is open on RR-31"]]))
pe("PE13 HELD", [R2, PR_R], dict(PR_W, **{"RR-30": "HELD"}), [], "RR-30",
cj(["NOT", ["does not stand as PROVISIONAL (HELD)"]]))
pe("PE14 already ESTABLISHED", [R2, PR_R], dict(PR_W, **{"RR-30": "ESTABLISHED"}), [], "RR-30",
cj(["NOT", ["does not stand as PROVISIONAL (ESTABLISHED)"]]))
pe("PE15 a VERIFICATION is not a RESULT", [R2, withf(VER, ID="RR-32")], PR_W, [], "RR-32",
cj(["NOT", ["not a RESULT"]]))
pe("PE16 an ASSUMPTION is not a RESULT", [R2], PR_W, [], "RR-2", cj(["NOT", ["not a RESULT"]]))
pe("PE17 every reason in order", [R2, PR_R, withf(PR_R, ID="RR-31", CITES=["RR-30"], FALSIFIER_CLASS="F1",
ENTRIES=[], DOMAIN_CONDITION="abs(x) < x_max")],
dict(PR_W, **{"RR-31": "WITHDRAWN"}), ["RR-31"], "RR-31",
cj(["NOT", ["does not stand as PROVISIONAL (WITHDRAWN)", "ENTRIES is absent or empty",
"FALSIFIER_CLASS F1 is below PROMOTION_FLOOR F2", "cites RR-30, which is not ESTABLISHED",
"an audit block is open on RR-31"]]))
pe("PE18 REC-52 an id not in the records", [R2], PR_W, [], "RR-30",
refused(P("REC-52", "-", "record RR-30 is not in the register")))
pe("PE19 REC-50 open_audits not a list", [R2, PR_R], PR_W, "RR-2", "RR-30",
refused(P("REC-50", "-", 'open_audits "RR-2" is not a list of record identifiers')))
PR_D = withf(PR_R, ID="RR-32", CITES=["RR-31"])
CHAIN = [R2, PR_R, PR_C, PR_D]
CW = {"RR-2": "PROVISIONAL", "RR-30": "PROVISIONAL", "RR-31": "PROVISIONAL", "RR-32": "PROVISIONAL"}
ca("PP01 the fixed point over a chain of three", "promotion_pass",
{"records": CHAIN, "words": CW, "tfk": TFK, "open_audits": []},
cj(["OK", [["RR-30", "F3", "F2"], ["RR-31", "F3", "F2"], ["RR-32", "F3", "F2"]]]))
ca("PP02 an audit in the middle stops the chain there", "promotion_pass",
{"records": CHAIN, "words": CW, "tfk": TFK, "open_audits": ["RR-31"]},
cj(["OK", [["RR-30", "F3", "F2"]]]))
ca("PP03 nothing eligible", "promotion_pass",
{"records": CHAIN, "words": dict(CW, **{"RR-30": "HELD"}), "tfk": TFK, "open_audits": []},
cj(["OK", []]))
PF = ["TPC-PROMOTE", "1", "B-12", 1, "RR-7", "F3", "F2"]
assert netstring(PF).decode() == "11:TPC-PROMOTE1:14:B-121:14:RR-72:F32:F2"
PDG = sha(PF)
assert PDG == "add59df96afc6d4128e79c9454dacc7de25c981344ab3e4cc4e43b92388121e6"
def pr(name, pid, block, promoted, expected):
ca(name, "promotion_record", {"promotion_id": pid, "landing_block": block, "promoted": promoted}, expected)
pr("PR01 16.3", "RR-992", "B-12", [["RR-7", "F3", "F2"]], cj(["OK", ["RR-992", "PROMOTION", "B-12",
[["RR-7", "F3", "F2"]], PDG]]))
PF2 = ["TPC-PROMOTE", "1", "CAC RR", 2, "RR-30", "F3", "F2", "RR-7", "F2", "F2"]
pr("PR02 sorted by id; a successor's CAC block", "RR-993", "CAC RR", [["RR-7", "F2", "F2"], ["RR-30", "F3", "F2"]],
cj(["OK", ["RR-993", "PROMOTION", "CAC RR", [["RR-30", "F3", "F2"], ["RR-7", "F2", "F2"]], sha(PF2)]]))
pr("PR03 REC-97 nothing promoted", "RR-994", "B-12", [],
refused(P("REC-97", "-", "a PROMOTION with nothing promoted is never written")))
pr("PR04 REC-50 a malformed triple", "RR-994", "B-12", [["RR-7", "F4", "F2"]],
refused(P("REC-50", "-", 'promoted [["RR-7","F4","F2"]] is not a list of [id, class_read, floor] '
'triples')))
pr("PR05 REC-50 ids repeated", "RR-994", "B-12", [["RR-7", "F3", "F2"], ["RR-7", "F3", "F2"]],
refused(P("REC-50", "-", 'promoted [["RR-7","F3","F2"],["RR-7","F3","F2"]] is not a list of '
'[id, class_read, floor] triples')))
pr("PR06 REC-50 promotion_id not an RID", "992", "B-12", [["RR-7", "F3", "F2"]],
refused(P("REC-50", "-", 'promotion_id "992" is not a record identifier')))
EV_ES1 = mk("RR-40", "ENTRY_STATUS", ENTRY="E_x", NOTE="first", LANDED="2026-09-28T12:00:00Z")
EV_ES2 = mk("RR-41", "ENTRY_STATUS", ENTRY="E_x", NOTE="second", LANDED="2026-09-28T13:00:00Z")
EV_ES3 = mk("RR-39", "ENTRY_STATUS", ENTRY="E_v", NOTE="other", LANDED="2026-09-28T14:00:00Z")
EV_V = withf(VER, ID="RR-50", TARGET="RR-21", EXTERNAL={"VALUE": "0.01", "U_C": "0.001", "UNIT": "m",
"QUANTITY": "E_x"})
EV_G = gapr("RR-5", "IC2", ["x"], TIC2 % "x")
EV_REC = [R2, GV_R1, GV_R2, GV_R3, EV_ES1, EV_ES2, EV_ES3, EV_V, EV_G,
withf(EV_G, ID="RR-6", STATE="SETTLED 2026-09-28 BY RR-21")]
EV_W = {"RR-2": "PROVISIONAL", "RR-20": "PROVISIONAL", "RR-21": "ESTABLISHED", "RR-22": "HELD"}
ca("EV01 the entry view of E_x", "entry_view", {"records": EV_REC, "words": EV_W, "tfk": TFK, "entry": "E_x"},
cj(["OK", {"ENTRY": "E_x", "RECORDS": [["RR-21", "ESTABLISHED"], ["RR-22", "HELD"]], "GAPS": ["RR-5"],
"VERIFICATIONS": ["RR-50"], "ENTRY_STATUS": "RR-41"}]))
ca("EV02 the entry view of E_t: nothing", "entry_view",
{"records": EV_REC, "words": EV_W, "tfk": TFK, "entry": "E_t"},
cj(["OK", {"ENTRY": "E_t", "RECORDS": [], "GAPS": [], "VERIFICATIONS": [], "ENTRY_STATUS": None}]))
ca("EV03 ENTRY_STATUS by (LANDED, ID): a tie on LANDED goes to the greater ID", "entry_view",
{"records": [withf(EV_ES1, ID="RR-9"), withf(EV_ES2, ID="RR-10", LANDED=EV_ES1["LANDED"])],
"words": {}, "tfk": TFK, "entry": "E_x"},
cj(["OK", {"ENTRY": "E_x", "RECORDS": [], "GAPS": [], "VERIFICATIONS": [], "ENTRY_STATUS": "RR-9"}]))
ca("EV04 REC-74 not an entry of the TrM", "entry_view",
{"records": EV_REC, "words": EV_W, "tfk": TFK, "entry": "E_q"},
refused(P("REC-74", "-", "quantity E_q is not an entry of the TrM")))
def ra(name, src, dst, expected):
ca(name, "reaudit_scope", {"src": src, "dst": dst}, expected)
TMS0 = TFK["TMS"]
SRC = {"D_TPK": D_TPK, "D_TRM": D_TRM, "TMS": TMS0}
def tms_with(**params):
t = copy.deepcopy(TMS0)
t["PARAMETERS"].update(params)
return t
ra("RA01 an identical TFK: nothing re-run", SRC, copy.deepcopy(SRC), cj(["OK", []]))
ra("RA02 D(TPK) moved: ALL", SRC, dict(SRC, D_TPK=_BAD), cj(["OK", ["ALL"]]))
ra("RA03 D(TrM) moved: ALL", SRC, dict(SRC, D_TRM=_BAD), cj(["OK", ["ALL"]]))
ra("RA04 K only", SRC, dict(SRC, TMS=tms_with(K="3")), cj(["OK", ["SR3", "SR8"]]))
ra("RA05 K in another spelling of the same value", SRC, dict(SRC, TMS=tms_with(K="2.0")), cj(["OK", []]))
ra("RA06 N_X", SRC, dict(SRC, TMS=tms_with(N_X=3)), cj(["OK", ["SR6"]]))
ra("RA07 STEP_CONVENTION", SRC, dict(SRC, TMS=tms_with(STEP_CONVENTION="one line is one step")),
cj(["OK", ["SR4", "SR5"]]))
ra("RA08 STEP_CONVENTION restated equal", SRC,
dict(SRC, TMS=tms_with(STEP_CONVENTION=TMS0["PARAMETERS"]["STEP_CONVENTION"])), cj(["OK", []]))
ra("RA09 PROMOTION_FLOOR raised", SRC, dict(SRC, TMS=tms_with(PROMOTION_FLOOR="F3")), cj(["OK", ["PROMOTION"]]))
ra("RA10 PROMOTION_FLOOR F2 declared equals absent", SRC, dict(SRC, TMS=tms_with(PROMOTION_FLOOR="F2")),
cj(["OK", []]))
ra("RA11 STRUCTURE_CHECK OFF", SRC, dict(SRC, TMS=tms_with(STRUCTURE_CHECK="OFF")),
cj(["OK", ["EOM-0", "STRUCTURE"]]))
ra("RA12 S_MAX", SRC, dict(SRC, TMS=tms_with(S_MAX=12)), cj(["OK", ["T3"]]))
ra("RA13 IC2_POLICY REJECT", SRC, dict(SRC, TMS=tms_with(IC2_POLICY="REJECT")), cj(["OK", ["IC2"]]))
_Y = copy.deepcopy(TMS0)
_Y["YARDSTICKS"][0]["KEY"] = ["SR1", "A", "S"]
ra("RA14 YARDSTICKS only", SRC, dict(SRC, TMS=_Y), cj(["OK", ["SR4", "SR5"]]))
_C = copy.deepcopy(TMS0)
_C["CONSTANTS"][1]["VALUE"] = "0.25"
ra("RA15 a CONSTANT only (RD-RS-40)", SRC, dict(SRC, TMS=_C), cj(["OK", ["SR4", "SR5"]]))
_C2 = copy.deepcopy(TMS0)
_C2["CONSTANTS"] = list(reversed(_C2["CONSTANTS"]))
ra("RA16 CONSTANTS reordered: the zone serialization sorts them", SRC, dict(SRC, TMS=_C2), cj(["OK", []]))
ra("RA17 several at once, sorted and distinct", SRC, dict(SRC, TMS=tms_with(K="3", N_X=4, S_MAX=11)),
cj(["OK", ["SR3", "SR6", "SR8", "T3"]]))
ra("RA18 REC-50 src without TMS", {"D_TPK": D_TPK, "D_TRM": D_TRM}, SRC,
refused(P("REC-50", "-", 'src %s is not an object with D_TPK, D_TRM and TMS'
% cj({"D_TPK": D_TPK, "D_TRM": D_TRM}))))
ra("RA19 REC-50 dst not an object", SRC, [],
refused(P("REC-50", "-", "dst [] is not an object with D_TPK, D_TRM and TMS")))
_T_BADY = copy.deepcopy(TMS0)
_T_BADY["YARDSTICKS"] = [{"NAME": 0, "KEY": ["SR1"], "LIMITING": []}]
_SRC_BADY = dict(SRC, TMS=_T_BADY)
ra("RA20 REC-50 a TMS the zone check refuses (a yardstick NAME not a string; RD-TQ-41)", _SRC_BADY,
dict(SRC, TMS=tms_with(K="3")),
refused(P("REC-50", "-", "src %s is not an object with D_TPK, D_TRM and TMS" % cj(_SRC_BADY))))
# repromote_batch (D202.1; D215.2): the successor's RESULTs inheriting an ESTABLISHED source
# record; a copy the successor withdraws by cause INHERITED is never a candidate (RD-RS-49)
S_R = [R2, PR_R, PR_C]
S_W = {"RR-2": "PROVISIONAL", "RR-30": "ESTABLISHED", "RR-31": "ESTABLISHED"}
D_R2 = withf(R2, ID="QQ-2", INHERITS="RR-2")
D_R30 = withf(PR_R, ID="QQ-30", INHERITS="RR-30", ASSUMPTIONS=["QQ-2"])
D_R31 = withf(PR_C, ID="QQ-31", INHERITS="RR-31", ASSUMPTIONS=["QQ-2"], CITES=["QQ-30"])
D_REC = [D_R2, D_R30, D_R31]
D_W = {"QQ-2": "PROVISIONAL", "QQ-30": "PROVISIONAL", "QQ-31": "PROVISIONAL"}
def rb(name, src_r, src_w, dst_r, dst_w, expected, tfk=None, audits=()):
ca(name, "repromote_batch", {"src_records": src_r, "src_words": src_w, "dst_records": dst_r,
"dst_words": dst_w, "tfk": tfk or TFK, "open_audits": list(audits)}, expected)
rb("RB01 an identical TFK: the ESTABLISHED re-promoted bottom-up", S_R, S_W, D_REC, D_W,
cj(["OK", [["QQ-30", "F3", "F2"], ["QQ-31", "F3", "F2"]]]))
rb("RB02 the floor raised: fewer re-promoted", S_R, S_W, [D_R2, D_R30, withf(D_R31, FALSIFIER_CLASS="F2")],
D_W, cj(["OK", [["QQ-30", "F3", "F3"]]]), tfk=TFK_F3)
rb("RB03 a source record HELD at the copy: not re-promoted, nor its dependent", S_R,
dict(S_W, **{"RR-30": "HELD"}), D_REC, D_W, cj(["OK", []]))
rb("RB04 a source record PROVISIONAL: not a candidate; its dependent waits", S_R,
dict(S_W, **{"RR-30": "PROVISIONAL"}), D_REC, D_W, cj(["OK", []]))
def _wq(g):
f = ["TPC-WITHDRAW", "1", "INHERITED", "QQ-30", "RR-30", g, "PROVISIONAL", "", "", 0, 0, "0.4.0",
DIS]
return ["QQ-995", "WITHDRAWAL", "INHERITED", "QQ-30", "RR-30", g, "PROVISIONAL", "", "", [], [],
"0.4.0", DIS, sha(f)]
assert _wq("REFUTED")[13].startswith("b145e376")
rb("RB05 an inherited premise the copy withdrew (WITHDRAWN): not a candidate, its dependent not "
"re-promoted", S_R, dict(S_W, **{"RR-30": "WITHDRAWN"}), D_REC + [_wq("WITHDRAWN")],
dict(D_W, **{"QQ-30": "WITHDRAWN"}), cj(["OK", []]))
rb("RB08 an inherited premise the copy withdrew (REFUTED, STATUS REFUTED): its dependent not "
"re-promoted", S_R, dict(S_W, **{"RR-30": "REFUTED"}),
[D_R2, withf(D_R30, STATUS="REFUTED"), D_R31, _wq("REFUTED")],
dict(D_W, **{"QQ-30": "REFUTED"}), cj(["OK", []]))
rb("RB06 an open audit in the successor", S_R, S_W, D_REC, D_W, cj(["OK", [["QQ-30", "F3", "F2"]]]),
audits=["QQ-31"])
rb("RB07 a successor record without INHERITS is not a candidate", S_R, S_W,
[D_R2, without(D_R30, "INHERITS"), D_R31], D_W, cj(["OK", []]))
# ============================================================ schema_json
# the generator's own builder of 11.2-11.4 over its own copy of the table,
# pinned to 14.2's length, SHA-256 and fragment digests
def _table():
# the generator's transcription of section 7.5 (a third copy); see TABLE below
lines = TABLE.split("\n")
i0 = lines.index("BEGIN RECORD TABLE")
i1 = lines.index("END RECORD TABLE")
joined = []
for ln in lines[i0 + 1:i1]:
if ln.startswith(" "):
joined[-1] += " " + ln.strip()
elif ln.strip():
joined.append(ln)
T = {"enums": {}, "classes": [], "landgrade": {}, "grades": {}, "statuses": {}, "subs": [],
"fields": {}}
for ln in joined:
kw = ln.split(" ", 1)[0]
if kw == "ENUM":
nm, vals = ln[5:].split(" = ", 1)
T["enums"][nm] = vals.split(" | ")
elif kw == "CLASS":
_, nm, form, _w = ln.split(" ")
T["classes"].append((nm, form))
elif kw == "LANDGRADE":
nm, v = ln[10:].split(" = ", 1)
T["landgrade"][nm] = v
elif kw == "STATUSES":
nm, v = ln[9:].split(" = ", 1)
T["statuses"][nm] = v.split(" | ")
elif kw == "GRADES":
nm, v = ln[7:].split(" = ", 1)
T["grades"][nm] = v.split(" | ")
elif kw == "SUB":
T["subs"].append(ln.split(" ")[1])
elif kw == "FIELD":
p = ln.split(" ")
T["fields"].setdefault(p[1], []).append(
{"name": p[2], "type": p[3], "card": p[4], "req": p[5], "writer": p[6],
"cons": [] if p[9] == "-" else p[9].split(",")})
return T
def _desc(f):
t, cons = f["type"], f["cons"]
d = "%s (%s), written by %s" % (t, f["card"], f["writer"])
fn = {"FORM": "tpc_form parse_form", "PREDICATE": "tpc_form parse_form",
"DECIMAL": "tpc_zone canon_decimal", "UNIT": "tpc_units unit_parse",
"DIMENSION": "tpc_zone normalize_dimension"}.get(t)
if fn is None:
quiet = {"GRADE", "STATUS", "NOTBLANK", "KEY", "NONEMPTY", "SETTING", "TPKNAME",
"TPKDOF", "TRMENTRY", "DTFK", "DIGEST", "T2"}
other = [c for c in cons if c not in quiet and not c.startswith(
("ENUM=", "SUB=", "DIM=", "ZONE="))]
if other or t in ("RID", "IDSET") or "ROLE" in cons:
fn = "tpc_record record_check"
return d + ("; checked by TPC " + fn if fn else "") + "."
def _fs(T, cls, f):
t, card, cons = f["type"], f["card"], f["cons"]
D = _desc(f)
sub = [c[4:] for c in cons if c.startswith("SUB=")]
if card == "SET":
return {"type": "array", "items": {"type": "string"}, "uniqueItems": True,
"description": D}
if t == "OBJECT" and card == "ONE":
return {"$ref": "#/$defs/" + sub[0], "description": D}
if t == "OBJECT":
return {"type": "array", "items": {"$ref": "#/$defs/" + sub[0]}, "description": D}
if t == "ENUM" and "ROLE" not in cons:
if "GRADE" in cons: # tpm_record_schema 0.4.0 11.3 (S100; D215.2)
return {"enum": [T["landgrade"][cls]], "description": D}
if "STATUS" in cons:
return {"enum": T["statuses"][cls], "description": D}
en = [c[5:] for c in cons if c.startswith("ENUM=")][0]
return {"enum": T["enums"][en], "description": D}
if t == "INT":
return {"type": "integer", "minimum": 1, "maximum": 1000000, "description": D}
if t == "BOOL":
return {"type": "boolean", "description": D}
return {"type": "string", "description": D}
def _schema_doc():
T = _table()
keyed = [c for c, form in T["classes"] if form == "KEYED"]
branches = []
for c in keyed:
fl = T["fields"][c]
branches.append({"if": {"properties": {"CLASS": {"const": c}}, "required": ["CLASS"]},
"then": {"type": "object",
"properties": {f["name"]: _fs(T, c, f) for f in fl},
"required": [f["name"] for f in fl if f["req"] == "R"
and f["writer"] in ("AUTHOR", "LEAD")],
"additionalProperties": False}})
defs = {}
for s in T["subs"]:
fl = T["fields"]["SUB:" + s]
defs[s] = {"type": "object", "properties": {f["name"]: _fs(T, None, f) for f in fl},
"required": [f["name"] for f in fl if f["req"] == "R"],
"additionalProperties": False}
doc = {"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "TPM register record",
"description": ("Generated by TPC tpc_record schema_json from tpm_record_schema "
"0.4.0. Non-normative: the table governs and TPC record_check "
"decides; a validator run on this document can pass a record TPX "
"refuses."),
"type": "object", "required": ["CLASS"], "properties": {"CLASS": {"enum": keyed}},
"allOf": branches, "$defs": defs}
return doc, keyed, branches, defs
FRAG = {"$defs/COMPONENT": "38f40af93e0ff99c4236cea59c8b08c6c574fbb62e5cf9b049cfa7e39cc3f65b",
"$defs/DERIVATION": "ae819a86a6015988e8e1388be54fdd52f5ad2be98404ef743fe6a41c95b0f08b",
"$defs/DIFFERENCE": "6c57d086d7286d4b37f1ff0dc9bcecbb5540122525e07f37966a05ba8088246f",
"$defs/EXTERNAL": "3cc0f0359ab5b6be14758b086638e05f8bf3fcd9c99247fa9bb9cdb8ca1df82d",
"$defs/INDEPENDENCE": "e7a3a480636d4e233a0196c3313b5bad013df523d52608709af6c7494c71cae4",
"$defs/POINT": "d286e09d91118c5719bc07690df19fe1fcdb38cc5c0990ffb6c985d75d583c78",
"ASSUMPTION": "7bef4aa69559f4c7c7d2abb87a752a86c1ab3358b9bfbe9e8a5087d10d844826",
"CORROBORATION": "ef1e9facd92c4096a13b2f08fecb30944bfdfe234e4d47470dbdf9970cb4ee0b",
"ENTRY_STATUS": "62d2942b4eb3ed3e1d24758e62b9e2900acbc0d5c863dda496075a0d92d1ccbb",
"MASTER": "9a3c8e2d8ec011f343440791b2bf351cf47ae6eb8704fc1496bed42a2d7732f8",
"NAMED_GAP": "f7719268762811e3c2697828414ab5d9095ad94e80528c8b5a646667759fc2f8",
"RESULT": "81c7c13aedc4706db844ec24d3dcfd07e1366f6af1deaaeada7956fb801a3645",
"VERIFICATION": "160a3db2b352e4bedcf476d6f112f677e16c5b36a5825aa32906edf1aae605a2"}
SCHEMA_LEN = 21835 # tpm_record_schema 0.4.0 14.2 (D215.2)
SCHEMA_SHA = "36358588db9d6fe8aaa340b58357e9dcc6728445e90039f72774a1799cc421e1"
def _add_schema():
doc, keyed, branches, defs = _schema_doc()
txt = cj(doc)
assert all(ord(c) < 128 for c in txt)
assert '"pattern"' not in txt
assert len(txt.encode("utf-8")) == SCHEMA_LEN, len(txt)
assert hashlib.sha256(txt.encode("utf-8")).hexdigest() == SCHEMA_SHA
for c, b in zip(keyed, branches):
assert hashlib.sha256(cj(b).encode("utf-8")).hexdigest() == FRAG[c], c
for s, d in defs.items():
assert hashlib.sha256(cj(d).encode("utf-8")).hexdigest() == FRAG["$defs/" + s], s
add("SJ001 schema_json: the whole document (14.2: 21835 bytes, 36358588...)",
"schema_json", {}, cj(["OK", txt]))
# ---------------------------------------------------------------- the table
# tpm_record_schema 0.4.0 section 7.5 (0.3.0's line for line; 0.2.1's but U_C's PREC), BEGIN to END RECORD TABLE, verbatim
TABLE = """BEGIN RECORD TABLE
ENUM CLASS = RESULT | ASSUMPTION | CORROBORATION | VERIFICATION
| WITHDRAWAL | NAMED_GAP | ENTRY_STATUS | PROMOTION | MASTER | HOLD
| RELEASE
ENUM GRADE_VALUES = PROVISIONAL | ESTABLISHED | REFUTED | WITHDRAWN
| NOT GRADED
ENUM REGIME = L | M
ENUM REGIME_M = M
ENUM FALSIFIER_CLASS = F1 | F2 | F3
ENUM SITUATION = INITIAL | BOUNDARY
ENUM OUTCOME = MATCH | MATCH WITH DIFFERENCE NOTED
ENUM TARGET_STATUS = PROVISIONAL | ESTABLISHED | HELD
ENUM EVALUATION = A | B
ENUM ORIGIN = SAME BLOCK | REPRODUCTION BLOCK
ENUM GAP_SOURCE = IC2 | UNDER | SR5_LOCUS | SR7_ASSUMPTIONS | SR7_DOMAIN
ENUM ROLE_WORDS = CONSTRAINT | CONSTITUTIVE | INVARIANT | DEFINITION
CLASS RESULT KEYED PUSH
CLASS ASSUMPTION KEYED PUSH
CLASS CORROBORATION KEYED PUSH
CLASS VERIFICATION KEYED PUSH
CLASS WITHDRAWAL LIST TPX
CLASS NAMED_GAP KEYED TPX
CLASS ENTRY_STATUS KEYED PUSH
CLASS PROMOTION LIST TPX
CLASS MASTER KEYED TPX
CLASS HOLD LIST TPX
CLASS RELEASE LIST TPX
LANDGRADE RESULT = PROVISIONAL
LANDGRADE ASSUMPTION = PROVISIONAL
LANDGRADE CORROBORATION = PROVISIONAL
LANDGRADE VERIFICATION = PROVISIONAL
LANDGRADE WITHDRAWAL = NOT GRADED
LANDGRADE NAMED_GAP = NOT GRADED
LANDGRADE ENTRY_STATUS = NOT GRADED
LANDGRADE PROMOTION = NOT GRADED
LANDGRADE MASTER = NOT GRADED
LANDGRADE HOLD = NOT GRADED
LANDGRADE RELEASE = NOT GRADED
GRADES RESULT = PROVISIONAL | ESTABLISHED | REFUTED | WITHDRAWN
GRADES ASSUMPTION = PROVISIONAL | WITHDRAWN
GRADES CORROBORATION = PROVISIONAL | REFUTED | WITHDRAWN
GRADES VERIFICATION = PROVISIONAL | WITHDRAWN
GRADES WITHDRAWAL = NOT GRADED
GRADES NAMED_GAP = NOT GRADED
GRADES ENTRY_STATUS = NOT GRADED
GRADES PROMOTION = NOT GRADED
GRADES MASTER = NOT GRADED
GRADES HOLD = NOT GRADED
GRADES RELEASE = NOT GRADED
STATUSES RESULT = UNMARKED | HELD | REFUTED
STATUSES ASSUMPTION = UNMARKED | HELD
STATUSES CORROBORATION = UNMARKED | HELD | REFUTED
STATUSES VERIFICATION = UNMARKED | HELD
STATUSES ENTRY_STATUS = UNMARKED | HELD
SUB DERIVATION KEY -
SUB COMPONENT KEY NAME
SUB POINT KEY DOF
SUB INDEPENDENCE KEY -
SUB EXTERNAL KEY -
SUB DIFFERENCE KEY -
FIELD RESULT ID RID ONE R LEAD D - -
FIELD RESULT CLASS ENUM ONE R AUTHOR D - ENUM=CLASS
FIELD RESULT GRADE ENUM ONE R TPX D - GRADE
FIELD RESULT STATUS ENUM ONE R TPX X - STATUS
FIELD RESULT BLOCK TEXT ONE R TPX D - NOTBLANK
FIELD RESULT AUTHOR TEXT ONE R TPX D - NOTBLANK
FIELD RESULT LANDED_BY TEXT ONE R TPX D - NOTBLANK
FIELD RESULT LANDED TEXT ONE R TPX D - UTC
FIELD RESULT VETTED_IN TEXT ONE O TPX D - NOTBLANK
FIELD RESULT CITES IDSET SET R AUTHOR D - RID
FIELD RESULT ASSUMPTIONS IDSET SET R AUTHOR D - RID
FIELD RESULT LITERATURE IDSET SET O AUTHOR D - BIBID,SETTING
FIELD RESULT SUPERSEDES RID ONE O AUTHOR D - -
FIELD RESULT INHERITS RID ONE O TPX D - -
FIELD RESULT TPS TEXT ONE R TPX D - VERSION
FIELD RESULT D_IS TEXT ONE R TPX D - HEX64
FIELD RESULT STATEMENT TEXT ONE R AUTHOR D - NOTBLANK
FIELD RESULT REGIME ENUM ONE R AUTHOR D - ENUM=REGIME
FIELD RESULT DERIVATION OBJECT ONE R AUTHOR D - SUB=DERIVATION
FIELD RESULT FALSIFIER TEXT ONE R AUTHOR D - NOTBLANK
FIELD RESULT FALSIFIER_CLASS ENUM ONE R AUTHOR D - ENUM=FALSIFIER_CLASS
FIELD RESULT DOMAIN TEXT ONE O AUTHOR D - NOTBLANK
FIELD RESULT DOMAIN_CONDITION PREDICATE ONE O AUTHOR D - -
FIELD RESULT REFS IDENT SET C AUTHOR D - TPKNAME
FIELD RESULT EQUATION FORM ONE C AUTHOR D - -
FIELD RESULT ROLE ENUM ONE C AUTHOR D - ROLE
FIELD RESULT ENTRIES IDENT SET O AUTHOR D - TRMENTRY
FIELD RESULT QUANTITY IDENT ONE C AUTHOR D - TRMENTRY
FIELD RESULT VALUE DECIMAL ONE C AUTHOR D - -
FIELD RESULT UNIT UNIT ONE C AUTHOR D - DIM=QUANTITY
FIELD RESULT U_C DECIMAL ONE C AUTHOR D - POSITIVE,PREC
FIELD RESULT BUDGET OBJECT LIST C AUTHOR D - SUB=COMPONENT,NONEMPTY
FIELD RESULT CORRELATED BOOL ONE C AUTHOR D FALSE -
FIELD RESULT AT OBJECT LIST C AUTHOR D EMPTY SUB=POINT
FIELD RESULT DIGEST TEXT ONE O TPX X - HEX64,DIGEST
RULE RESULT | IF REGIME = M | REQUIRE | QUANTITY, VALUE, UNIT, U_C, BUDGET
RULE RESULT | IF REGIME = M | FORBID | EQUATION, ROLE
RULE RESULT | IF REGIME = L | FORBID | U_C, BUDGET
RULE RESULT | IF REGIME = L | ALL OR NONE | QUANTITY, VALUE, UNIT
RULE RESULT | IF BUDGET ABSENT | FORBID | CORRELATED
RULE RESULT | IF VALUE ABSENT | FORBID | AT
RULE RESULT | IF ROLE PRESENT | REQUIRE | EQUATION
RULE RESULT | IF EQUATION PRESENT | REQUIRE | REFS
RULE RESULT | IF DOMAIN_CONDITION PRESENT | REQUIRE | REFS
FIELD ASSUMPTION ID RID ONE R LEAD D - -
FIELD ASSUMPTION CLASS ENUM ONE R AUTHOR D - ENUM=CLASS
FIELD ASSUMPTION GRADE ENUM ONE R TPX D - GRADE
FIELD ASSUMPTION STATUS ENUM ONE R TPX X - STATUS
FIELD ASSUMPTION BLOCK TEXT ONE R TPX D - NOTBLANK
FIELD ASSUMPTION AUTHOR TEXT ONE R TPX D - NOTBLANK
FIELD ASSUMPTION LANDED_BY TEXT ONE R TPX D - NOTBLANK
FIELD ASSUMPTION LANDED TEXT ONE R TPX D - UTC
FIELD ASSUMPTION VETTED_IN TEXT ONE O TPX D - NOTBLANK
FIELD ASSUMPTION CITES IDSET SET R AUTHOR D - RID
FIELD ASSUMPTION ASSUMPTIONS IDSET SET R AUTHOR D - RID
FIELD ASSUMPTION LITERATURE IDSET SET O AUTHOR D - BIBID,SETTING
FIELD ASSUMPTION SUPERSEDES RID ONE O AUTHOR D - -
FIELD ASSUMPTION INHERITS RID ONE O TPX D - -
FIELD ASSUMPTION TPS TEXT ONE R TPX D - VERSION
FIELD ASSUMPTION D_IS TEXT ONE R TPX D - HEX64
FIELD ASSUMPTION PROPOSITION TEXT ONE R AUTHOR D - NOTBLANK,T2
FIELD ASSUMPTION REFS IDENT SET R AUTHOR D - TPKNAME
FIELD ASSUMPTION SITUATION ENUM ONE O AUTHOR D - ENUM=SITUATION
FIELD ASSUMPTION DOF IDENT ONE C AUTHOR D - TPKDOF
FIELD ASSUMPTION VALUE DECIMAL ONE C AUTHOR D - -
FIELD ASSUMPTION UNIT UNIT ONE C AUTHOR D - DIM=DOF
FIELD ASSUMPTION AT OBJECT LIST C AUTHOR D EMPTY SUB=POINT
FIELD ASSUMPTION EQUATION FORM ONE C AUTHOR D - -
FIELD ASSUMPTION ROLE ENUM ONE C AUTHOR D - ROLE
FIELD ASSUMPTION DIGEST TEXT ONE O TPX X - HEX64,DIGEST
RULE ASSUMPTION | IF SITUATION PRESENT | REQUIRE | DOF, VALUE, UNIT
RULE ASSUMPTION | IF SITUATION ABSENT | FORBID | DOF, VALUE, UNIT, AT
RULE ASSUMPTION | IF SITUATION PRESENT | FORBID | EQUATION, ROLE
RULE ASSUMPTION | IF ROLE PRESENT | REQUIRE | EQUATION
FIELD CORROBORATION ID RID ONE R LEAD D - -
FIELD CORROBORATION CLASS ENUM ONE R AUTHOR D - ENUM=CLASS
FIELD CORROBORATION GRADE ENUM ONE R TPX D - GRADE
FIELD CORROBORATION STATUS ENUM ONE R TPX X - STATUS
FIELD CORROBORATION BLOCK TEXT ONE R TPX D - NOTBLANK
FIELD CORROBORATION AUTHOR TEXT ONE R TPX D - NOTBLANK
FIELD CORROBORATION LANDED_BY TEXT ONE R TPX D - NOTBLANK
FIELD CORROBORATION LANDED TEXT ONE R TPX D - UTC
FIELD CORROBORATION VETTED_IN TEXT ONE O TPX D - NOTBLANK
FIELD CORROBORATION CITES IDSET SET R AUTHOR D - RID
FIELD CORROBORATION ASSUMPTIONS IDSET SET R AUTHOR D - RID
FIELD CORROBORATION LITERATURE IDSET SET O AUTHOR D - BIBID,SETTING
FIELD CORROBORATION SUPERSEDES RID ONE O AUTHOR D - -
FIELD CORROBORATION INHERITS RID ONE O TPX D - -
FIELD CORROBORATION TPS TEXT ONE R TPX D - VERSION
FIELD CORROBORATION D_IS TEXT ONE R TPX D - HEX64
FIELD CORROBORATION TARGET RID ONE R AUTHOR D - -
FIELD CORROBORATION OUTCOME ENUM ONE R TPX D - ENUM=OUTCOME
FIELD CORROBORATION DIFFERENCE TEXT ONE C TPX D - NOTBLANK
FIELD CORROBORATION INDEPENDENCE OBJECT ONE R TPX D - SUB=INDEPENDENCE
FIELD CORROBORATION TARGET_STATUS ENUM ONE R TPX D - ENUM=TARGET_STATUS
FIELD CORROBORATION SELF_REPORTED TEXT ONE O AUTHOR D - NOTBLANK
FIELD CORROBORATION DIGEST TEXT ONE O TPX X - HEX64,DIGEST
RULE CORROBORATION | IF OUTCOME = MATCH WITH DIFFERENCE NOTED
| REQUIRE | DIFFERENCE
RULE CORROBORATION | IF OUTCOME = MATCH | FORBID | DIFFERENCE
FIELD VERIFICATION ID RID ONE R LEAD D - -
FIELD VERIFICATION CLASS ENUM ONE R AUTHOR D - ENUM=CLASS
FIELD VERIFICATION GRADE ENUM ONE R TPX D - GRADE
FIELD VERIFICATION STATUS ENUM ONE R TPX X - STATUS
FIELD VERIFICATION BLOCK TEXT ONE R TPX D - NOTBLANK
FIELD VERIFICATION AUTHOR TEXT ONE R TPX D - NOTBLANK
FIELD VERIFICATION LANDED_BY TEXT ONE R TPX D - NOTBLANK
FIELD VERIFICATION LANDED TEXT ONE R TPX D - UTC
FIELD VERIFICATION VETTED_IN TEXT ONE O TPX D - NOTBLANK
FIELD VERIFICATION CITES IDSET SET R AUTHOR D - RID
FIELD VERIFICATION ASSUMPTIONS IDSET SET R AUTHOR D - RID
FIELD VERIFICATION LITERATURE IDSET SET O AUTHOR D - BIBID,SETTING
FIELD VERIFICATION SUPERSEDES RID ONE O AUTHOR D - -
FIELD VERIFICATION INHERITS RID ONE O TPX D - -
FIELD VERIFICATION TPS TEXT ONE R TPX D - VERSION
FIELD VERIFICATION D_IS TEXT ONE R TPX D - HEX64
FIELD VERIFICATION REGIME ENUM ONE R AUTHOR D - ENUM=REGIME_M
FIELD VERIFICATION TARGET RID ONE R AUTHOR D - -
FIELD VERIFICATION EXTERNAL OBJECT ONE R AUTHOR D - SUB=EXTERNAL
FIELD VERIFICATION SOURCE TEXT ONE R AUTHOR D - NOTBLANK,BIBSOURCE
FIELD VERIFICATION AT OBJECT LIST O AUTHOR D EMPTY SUB=POINT
FIELD VERIFICATION DIFFERENCE OBJECT ONE R AUTHOR D - SUB=DIFFERENCE
FIELD VERIFICATION DIGEST TEXT ONE O TPX X - HEX64,DIGEST
FIELD NAMED_GAP ID RID ONE R TPX D - -
FIELD NAMED_GAP CLASS ENUM ONE R TPX D - ENUM=CLASS
FIELD NAMED_GAP GRADE ENUM ONE R TPX D - GRADE
FIELD NAMED_GAP LANDED_BY TEXT ONE R TPX D - TPXONLY
FIELD NAMED_GAP LANDED TEXT ONE R TPX D - UTC
FIELD NAMED_GAP TPS TEXT ONE R TPX D - VERSION
FIELD NAMED_GAP INHERITS RID ONE O TPX D - -
FIELD NAMED_GAP SOURCE ENUM ONE R TPX D - ENUM=GAP_SOURCE
FIELD NAMED_GAP AGAINST TEXT SET R TPX D - AGAINST
FIELD NAMED_GAP TRIGGER TEXT ONE R TPX D - NOTBLANK,TRIGGER
FIELD NAMED_GAP STATEMENT TEXT ONE R TPX D - NOTBLANK
FIELD NAMED_GAP STATE TEXT ONE R TPX X - STATELINE
FIELD NAMED_GAP DIGEST TEXT ONE O TPX X - HEX64,DIGEST
FIELD ENTRY_STATUS ID RID ONE R LEAD D - -
FIELD ENTRY_STATUS CLASS ENUM ONE R AUTHOR D - ENUM=CLASS
FIELD ENTRY_STATUS GRADE ENUM ONE R TPX D - GRADE
FIELD ENTRY_STATUS STATUS ENUM ONE R TPX X - STATUS
FIELD ENTRY_STATUS BLOCK TEXT ONE R TPX D - NOTBLANK
FIELD ENTRY_STATUS AUTHOR TEXT ONE R TPX D - NOTBLANK
FIELD ENTRY_STATUS LANDED_BY TEXT ONE R TPX D - NOTBLANK
FIELD ENTRY_STATUS LANDED TEXT ONE R TPX D - UTC
FIELD ENTRY_STATUS VETTED_IN TEXT ONE O TPX D - NOTBLANK
FIELD ENTRY_STATUS CITES IDSET SET R AUTHOR D - RID
FIELD ENTRY_STATUS ASSUMPTIONS IDSET SET R AUTHOR D - RID
FIELD ENTRY_STATUS LITERATURE IDSET SET O AUTHOR D - BIBID,SETTING
FIELD ENTRY_STATUS INHERITS RID ONE O TPX D - -
FIELD ENTRY_STATUS TPS TEXT ONE R TPX D - VERSION
FIELD ENTRY_STATUS D_IS TEXT ONE R TPX D - HEX64
FIELD ENTRY_STATUS ENTRY IDENT ONE R AUTHOR D - TRMENTRY
FIELD ENTRY_STATUS RIDER TEXT ONE O AUTHOR D - NOTBLANK
FIELD ENTRY_STATUS NOTE TEXT ONE O AUTHOR D - NOTBLANK
FIELD ENTRY_STATUS SCRUTINY TEXT ONE O AUTHOR D - NOTBLANK
FIELD ENTRY_STATUS CHECKS_OWED TEXT ONE O AUTHOR D - NOTBLANK
FIELD ENTRY_STATUS DIGEST TEXT ONE O TPX X - HEX64,DIGEST
RULE ENTRY_STATUS | ALWAYS | AT LEAST ONE | RIDER, NOTE, SCRUTINY, CHECKS_OWED
FIELD MASTER ID RID ONE R TPX D - MASTERID
FIELD MASTER CLASS ENUM ONE R TPX D - ENUM=CLASS
FIELD MASTER GRADE ENUM ONE R TPX D - GRADE
FIELD MASTER LANDED_BY TEXT ONE R TPX D - TPXONLY
FIELD MASTER LANDED TEXT ONE R TPX D - UTC
FIELD MASTER TPS TEXT ONE R TPX D - VERSION
FIELD MASTER UUID TEXT ONE R TPX D - UUID4
FIELD MASTER PREFIX IDENT ONE R TPX D - -
FIELD MASTER D_TPK TEXT ONE R TPX D - HEX64,ZONE=TPK
FIELD MASTER D_TRM TEXT ONE R TPX D - HEX64,ZONE=TrM
FIELD MASTER D_TMS TEXT ONE R TPX D - HEX64,ZONE=TMS
FIELD MASTER D_TFK TEXT ONE R TPX D - HEX64,DTFK
FIELD MASTER CERTIFICATE TEXT ONE R TPX D - NOTBLANK
FIELD MASTER STRUCTURE_LINE TEXT ONE R TPX D - NOTBLANK
FIELD MASTER MODULES_USED TEXT ONE R TPX D - NOTBLANK
FIELD MASTER DIGEST TEXT ONE O TPX X - HEX64,DIGEST
FIELD SUB:DERIVATION STEPS INT ONE R AUTHOR D - STEPS
FIELD SUB:DERIVATION TEXT TEXT ONE R AUTHOR D - NOTBLANK
FIELD SUB:COMPONENT NAME IDENT ONE R AUTHOR D - KEY
FIELD SUB:COMPONENT U DECIMAL ONE R AUTHOR D - NONNEG
FIELD SUB:COMPONENT UNIT UNIT ONE R AUTHOR D - -
FIELD SUB:COMPONENT EVALUATION ENUM ONE R AUTHOR D - ENUM=EVALUATION
FIELD SUB:COMPONENT BASIS TEXT ONE R AUTHOR D - NOTBLANK
FIELD SUB:POINT DOF IDENT ONE R AUTHOR D - KEY,TPKDOF
FIELD SUB:POINT VALUE DECIMAL ONE R AUTHOR D - -
FIELD SUB:POINT UNIT UNIT ONE R AUTHOR D - DIM=DOF
FIELD SUB:INDEPENDENCE ACCOUNT TEXT ONE R TPX D - NOTBLANK
FIELD SUB:INDEPENDENCE SNAPSHOT TEXT ONE R TPX D - NOTBLANK
FIELD SUB:INDEPENDENCE VENDOR TEXT ONE R TPX D - NOTBLANK
FIELD SUB:INDEPENDENCE IMPLEMENTATION TEXT ONE R TPX D - NOTBLANK
FIELD SUB:INDEPENDENCE ORIGIN ENUM ONE R TPX D - ENUM=ORIGIN
FIELD SUB:INDEPENDENCE NOT_SERVED_BEFORE BOOL ONE R TPX D - -
FIELD SUB:INDEPENDENCE SAME_SPONSOR BOOL ONE R TPX D - -
FIELD SUB:INDEPENDENCE SAME_MODEL BOOL ONE R TPX D - -
FIELD SUB:EXTERNAL VALUE DECIMAL ONE R AUTHOR D - -
FIELD SUB:EXTERNAL U_C DECIMAL ONE R AUTHOR D - NONNEG
FIELD SUB:EXTERNAL UNIT UNIT ONE R AUTHOR D - DIM=QUANTITY
FIELD SUB:EXTERNAL QUANTITY IDENT ONE R AUTHOR D - TRMENTRY
FIELD SUB:DIFFERENCE VALUE DECIMAL ONE R AUTHOR D - -
FIELD SUB:DIFFERENCE U DECIMAL ONE R AUTHOR D - POSITIVE
FIELD SUB:DIFFERENCE ZETA DECIMAL ONE R AUTHOR D - -
END RECORD TABLE
"""
_add_schema()
# ================================================================ write
def main():
names = [c["name"] for c in CASES]
assert len(set(names)) == len(names), "duplicate case names"
for c in CASES:
json.loads(c["expected"])
counts = {}
for c in CASES:
counts[c["fn"]] = counts.get(c["fn"], 0) + 1
out = {"corpus": "record", "version": CORPUS_VERSION,
"spec": "tpm_record_schema 0.4.0; tpm_record_functions 0.3.0",
"note": ("vectors first: every expectation a literal of the generator, in TPM's "
"canonical JSON; unit and form reasons, t2 findings and zone digests from "
"existing TPC-PY functions over literal data; record digests recomputed "
"here with hashlib; the drafted items' cases at the answers D214.1, D215.2 "
"and D218.1"),
"cases": CASES}
with open(os.path.join(HERE, "vectors", "record_corpus.json"), "w", encoding="utf-8",
newline="\n") as f:
json.dump(out, f, indent=1, sort_keys=True, ensure_ascii=True)
f.write("\n")
print("wrote %d record cases" % len(CASES))
for fn in sorted(counts):
print(" %-24s %d" % (fn, counts[fn]))
if __name__ == "__main__":
main()
# END OF ARTIFACT --- gen_record_corpus.py 0.1.0
# If this line is absent, the payload arrived truncated.