KB-25D4

codex_adversarial_probes.py

5 min read Revision 1
fix7codexauthority-sealrejected2026-06-11

#!/usr/bin/env python3 """Codex-owned FIX7 authority authoring fail-closed probes.""" import copy import tempfile from pathlib import Path import codex_authority_seal as seal

def mutate(c, **kwargs): c = copy.deepcopy(c) c.update(kwargs) return c

def run(): good = seal.base_config("2026-06-11T08:00:00Z", "2026-06-11T15:00:00+07:00") downstream = mutate(good, probe_fixture=True, a5="OPT_3_AUTHORIZE_CODEX_AUTHORITY_SEAL_AND_POST_SEAL_IMPLEMENTATION_PLANNING_ONLY") probes = [ ("actual owner A5 rejected by contract grammar", "SEAL_FIELD_BAD_ENUM", lambda: seal.build_chain(good)), ("missing N6 certificate", "N6_CERTIFICATE_MISSING_OR_MISMATCH", lambda: seal.build_chain(mutate(good, n6_certificate=""))), ("stale N6 digest", "STALE_N6_DIGEST", lambda: seal.build_chain(mutate(good, n6="0" * 64))), ("N6 falsely official before seal", "N6_FALSELY_OFFICIAL_BEFORE_SEAL", lambda: seal.build_chain(mutate(good, n6_is_official_before_seal=True))), ("missing A1", "MISSING_A1", lambda: seal.build_chain(mutate(good, a1=""))), ("missing A2", "MISSING_A2", lambda: seal.build_chain(mutate(good, a2=""))), ("missing A3", "MISSING_A3", lambda: seal.build_chain(mutate(good, a3=""))), ("missing A5", "MISSING_A5", lambda: seal.build_chain(mutate(good, a5=""))), ("owner OPT-1", "OWNER_DECISION_NOT_OPT3", lambda: seal.build_chain(mutate(good, a5="OPT-1_HOLD"))), ("malformed A1", "SEAL_FIELD_BAD_ID", lambda: seal.build_chain(mutate(good, a1="bad id with spaces"))), ("empty approver identity", "MISSING_A2", lambda: seal.build_chain(mutate(good, a2=""))), ("stale N7 active blocker", "STALE_N7_ENVELOPE_ACTIVE_BLOCKER", lambda: seal.build_chain(mutate(good, n7_envelope_current_blocker="SEAL_REAL_N6_NOT_AVAILABLE"))), ("N7 depends on N8", "SEAL_HASH_GRAPH_CYCLE", lambda: seal.build_chain(mutate(downstream, n7_extra=[("detached_seal_sha256", "1" * 64)]))), ("N8 depends on P7", "SEAL_HASH_GRAPH_CYCLE", lambda: seal.build_chain(mutate(downstream, n8_extra=[("authority_seal_pin_sha256", "2" * 64)]))), ("P7 missing N7", "SEAL_INPUT_MISSING", lambda: seal.build_chain(mutate(downstream, p7_drop=["envelope_manifest_sha256"]))), ("P7 missing N8", "SEAL_INPUT_MISSING", lambda: seal.build_chain(mutate(downstream, p7_drop=["detached_seal_sha256"]))), ("duplicate report", "SEAL_REPORT_SET_DUPLICATE", lambda: seal.build_chain(mutate(downstream, report_set=good["report_set"] + [good["report_set"][0]], expected_report_set=good["report_set"] + [good["report_set"][0]]))), ("missing report", "N8_REPORT_SET_MISSING_OR_DRIFTED", lambda: seal.build_chain(mutate(downstream, report_set=good["report_set"][:-1]))), ("report digest mismatch", "N8_REPORT_SET_DIGEST_MISMATCH", lambda: seal.build_chain(mutate(downstream, claimed_report_digest="0" * 64))), ("P7 ID collision", "P7_AUTHORITY_ID_COLLISION", lambda: seal.build_chain(mutate(downstream, existing_authority_ids=[good["report_id"]]))), ("production mutation attempt", "FORBIDDEN_MUTATION_OR_EXECUTION", lambda: seal.build_chain(mutate(good, requested_actions=["production_mutation"]))), ("implementation execution attempt", "FORBIDDEN_MUTATION_OR_EXECUTION", lambda: seal.build_chain(mutate(good, requested_actions=["implementation_execution"]))), ("REAL_RUN attempt", "FORBIDDEN_MUTATION_OR_EXECUTION", lambda: seal.build_chain(mutate(good, requested_actions=["REAL_RUN"]))), ("QT001 attempt", "FORBIDDEN_MUTATION_OR_EXECUTION", lambda: seal.build_chain(mutate(good, requested_actions=["QT001"]))), ("cutover attempt", "FORBIDDEN_MUTATION_OR_EXECUTION", lambda: seal.build_chain(mutate(good, requested_actions=["cutover"]))), ] passed = 0 with tempfile.TemporaryDirectory() as td: original_root = seal.ROOT seal.ROOT = Path(td) try: for name, expected, fn in probes: try: fn() print(f"[FAIL-OPEN] {name}: accepted") continue except Exception as exc: actual = getattr(exc, "code", getattr(exc, "status", type(exc).name)) official = any((seal.ROOT / f).exists() for f in seal.OFFICIAL_FILES.values()) if actual == expected and not official: passed += 1 print(f"[FAIL-CLOSED] {name} -> {actual}; official_artifacts=0") else: print(f"[WRONG-REJECT] {name}: expected={expected} actual={actual} official={official}") finally: seal.ROOT = original_root print(f"CODEX_ADVERSARIAL_PROBES: {passed}/{len(probes)} fail-closed") return 0 if passed == len(probes) else 1

if name == "main": raise SystemExit(run())

Back to Knowledge Hub knowledge/dev/reports/architecture/codex-fix7-n7-n8-p7-authority-seal-authoring-2026-06-11/codex_adversarial_probes.py