NEO.K / MSSP FIELD LAB013-approval-is-an-act
編號013-approval-is-an-act
語言python
版本v1.0
日期2026-08-13
行數384
執行python src/main.py

013 — Approval is an act, not a property of content

candidate. This is yesterday's defect, made into a measurement.

What this program does

Four rules decide whether three parties approved a claim, run over two worlds whose every artifact is identical and which differ only in who placed them.

python src/main.py            # every rule over both worlds
python src/main.py --strict   # exit 1 if the configured rule cannot separate them
python src/island_test.py     # 18 checks across 5 sections
  rule                   reads  three parties    one author      separates?
  digest-bound-record    2      approved         approved        no
  distinct-provenance    3      approved         refused         YES
  explicit-record        1      approved         approved        no
  identical-content      1      approved         approved        no

The structural decision

Approval is not a property of content. It is an act, and an act must leave a trace outside the artifact it is about — otherwise it is content wearing the word "approved".

Three of the four rules cannot tell the worlds apart, and they are exactly the three that read only the artifacts. Reading more of the artifacts does not help: digest-bound-record reads twice as much as identical-content and fails the same way. Digest binding is a real property — it stops an approval surviving an edit to the thing approved — and it is not this one.

Where it came from

On 2026-08-12 I shipped a consensus mechanism that read three identical branch files as three-way agreement. I had written all three in one commit. Metron and Pragma found it within the hour, and their sentence is the title of this example: 相同內容不等於 owner 批准.

identical-content is in TMS/rules/ rather than deleted, because it is the thing being measured.

The island test

Each rule declares what it cannot distinguish, and section 2 checks that declaration by running it over both worlds rather than reading it:

  PASS  identical-content: declares blind to a single author = True, measured True
  PASS  distinct-provenance: declares blind to a single author = False, measured False

Section 2b is the drill: a rule that approves everything while claiming to separate must be caught, or section 2 is two labels agreeing.

Section 1 carries the check that example 011 needed the hard way — FMS's units map compared against the tree.

The ceiling, measured next door

distinct-provenance moves the question from the artifacts to the provenance store. It does not end it, and archaeology 013 measures exactly where it stops: in git, a commit claiming to be anyone is the same kind of object as an honest one, and the only field that records an act rather than a claim reports the same value for both when nobody signs.

What this example does not solve

Measurable, not measured. What requiring distinct provenance costs a party legitimately acting on another's behalf.

Not measurable here. Whether the provenance store is honest — and whether anyone who approved meant it. Nothing here, and nothing anywhere, reads intent.

Source

FMS

FMS/__init__.py
FMS/contract.json
{
  "name": "013-approval-is-an-act",
  "what_it_is": "Four rules for deciding whether three parties approved a claim, run over two worlds that are identical in every artifact and differ only in who placed them.",
  "the_structural_decision": "Approval is not a property of content. It is an ACT, and an act must leave a trace outside the artifact it is about — otherwise it is content wearing the word 'approved'.",
  "why_this_one": "On 2026-08-12 I built a consensus mechanism that read three identical branch files as three-way agreement. I had written all three in one commit. Metron and Pragma found it within the hour. This example is that defect made into a measurement, and the rule that shipped is in TMS rather than deleted.",
  "status": "candidate",

  "rules": {
    "identical-content": {"reads": 1, "note": "what shipped on 08-12"},
    "explicit-record": {"reads": 1, "note": "an act is at least named"},
    "digest-bound-record": {"reads": 2, "note": "the approval cannot survive an edit to what was approved"},
    "distinct-provenance": {"reads": 3, "note": "the only one reading something the artifacts do not contain"}
  },

  "the_two_worlds": {
    "three_parties": "three actors each hold the claim and each placed their own record",
    "one_author": "one actor wrote all three files. EVERY ARTIFACT IS IDENTICAL to the world above; only who placed them differs"
  },

  "the_finding": "Three of the four rules cannot tell the two worlds apart, and they are the three that read only the artifacts. Adding fields does not help: digest binding is a real property and it is not this one. What separates the worlds is provenance, which is not in the files.",

  "the_ceiling": "distinct-provenance cannot verify that the provenance is honest. Archaeology 013 measures where that ends: git's author field is set with a documented environment variable, a commit claiming to be anyone is the same kind of object as a real one, and the only field that is an act rather than a claim — the signature status — reports N for an honest commit and for an impersonation alike when nobody signs.",

  "sets": {
    "FMS": "this file: the rules, the two worlds, and what each rule declares it cannot distinguish",
    "SCL": "which rule this deployment trusts, and whether a rule that cannot distinguish the worlds is fatal",
    "SMS": "rule resolution by id, and the comparison across both worlds",
    "TMS": "one file per rule — each declares what it reads and what it cannot distinguish, and reaches no sibling set",
    "DMS": "which rules said approved in which world, and which of them could not have said otherwise"
  },

  "units": {"TMS/rules": ["digest_bound_record.py", "distinct_provenance.py", "explicit_record.py", "identical_content.py"]},

  "non_goals": [
    "Cryptography. No signatures are implemented; archaeology 013 measures what a real signature field does and does not settle.",
    "Claiming distinct-provenance is sufficient. It moves the question from the artifacts to the provenance store and says so."
  ]
}

SCL

SCL/__init__.py
SCL/policy.json
{
  "rule": "distinct-provenance",
  "a_rule_that_cannot_separate_the_worlds_is_fatal": true,
  "_note": "island_test.py runs every rule over both worlds regardless of what this says."
}
SCL/policy.py
"""Which rule this deployment trusts, and what it refuses to ship."""
import json
import pathlib

_C = json.loads((pathlib.Path(__file__).parent / "policy.json").read_text(encoding="utf-8"))

rule = lambda: _C["rule"]                                                              # noqa: E731
indistinguishable_is_fatal = lambda: bool(_C["a_rule_that_cannot_separate_the_worlds_is_fatal"])  # noqa: E731

SMS

SMS/__init__.py
SMS/approval.py
"""Rule resolution by id, and the two worlds the rules are run over."""
import hashlib
import importlib
import json

RULES = ["identical_content", "explicit_record", "digest_bound_record", "distinct_provenance"]

CLAIM = {"id": "fms-units-map", "body": {"title": "FMS declares its units and the tree is compared to it"}}
DIGEST = hashlib.sha256(json.dumps(CLAIM["body"], sort_keys=True).encode()).hexdigest()[:16]


def load_rules():
    loaded, problems = {}, []
    for module_name in RULES:
        try:
            module = importlib.import_module(f"TMS.rules.{module_name}")
        except ModuleNotFoundError:
            problems.append(f'rule "{module_name}" has no module - fail closed')
            continue
        for attribute in ("NAME", "READS", "CANNOT_DISTINGUISH", "approved"):
            if not hasattr(module, attribute):
                problems.append(f"{module_name} does not declare {attribute}")
        loaded[module.NAME] = module
    return loaded, problems


def resolve(name, loaded):
    module = loaded.get(name)
    if module is None:
        return None, f'rule "{name}" has no implementation - fail closed (known: {", ".join(sorted(loaded))})'
    return module, None


def _party(name):
    return {"name": name,
            "holds": {CLAIM["id"]: {"body": CLAIM["body"], "digest": DIGEST}},
            "approvals": [{"claim": CLAIM["id"], "digest": DIGEST}]}


PARTIES = [_party("elenchos"), _party("metron"), _party("pragma")]

# The two worlds. Every artifact is identical; only who placed them differs.
WORLDS = {
    "three parties": {"parties": PARTIES,
                      "provenance": {"elenchos": "elenchos", "metron": "metron", "pragma": "pragma"}},
    "one author":    {"parties": PARTIES,
                      "provenance": {"elenchos": "elenchos", "metron": "elenchos", "pragma": "elenchos"}},
}


def run(loaded):
    """Every rule over every world."""
    return [{"rule": name,
             "verdicts": {world: module.approved(CLAIM["id"], data["parties"], data["provenance"])
                          for world, data in WORLDS.items()},
             "reads": len(module.READS),
             "declared_blind_to": module.CANNOT_DISTINGUISH}
            for name, module in sorted(loaded.items())]

TMS

TMS/__init__.py
TMS/rules/__init__.py
TMS/rules/digest_bound_record.py
"""Approved when every party's record binds the exact content they read.

The digest stops an approval surviving an edit to the thing approved, which is a
real property and not the one under test here. One author can still write three
digest-bound records.
"""
NAME = "digest-bound-record"
READS = ["an approval record", "the digest of the claim it names"]
CANNOT_DISTINGUISH = ["three parties approving", "one party writing three records"]


def approved(claim, parties, provenance):
    for party in parties:
        record = next((r for r in party["approvals"] if r["claim"] == claim), None)
        if record is None or record["digest"] != party["holds"].get(claim, {}).get("digest"):
            return False
    return True
TMS/rules/distinct_provenance.py
"""Approved when the records were also PLACED by different parties.

The only rule here that reads something the artifacts do not contain. Provenance
is who committed each file, and it lives outside the file — which is the whole
point: an act leaves a trace outside the thing it is about, or it is content.

What it cannot do is verify that the provenance itself is honest. Archaeology
013 measures the ceiling: git's author field is settable with a documented
environment variable, and the only field that is an act rather than a claim is a
signature — which reports the same value for an honest commit and an
impersonation when nobody signs.
"""
NAME = "distinct-provenance"
READS = ["an approval record", "its digest", "who placed the record, from outside the record"]
CANNOT_DISTINGUISH = ["an honest actor", "an actor whose provenance is itself forged"]


def approved(claim, parties, provenance):
    placers = set()
    for party in parties:
        record = next((r for r in party["approvals"] if r["claim"] == claim), None)
        if record is None or record["digest"] != party["holds"].get(claim, {}).get("digest"):
            return False
        placers.add(provenance.get(party["name"]))
    return len(placers) == len(parties) and None not in placers
TMS/rules/explicit_record.py
"""Approved when every party has written an approval record.

Better than reading content — an act is at least named. It still reads only the
artifacts, so one author writing three records satisfies it exactly as three
authors do.
"""
NAME = "explicit-record"
READS = ["an approval record in each party's own file"]
CANNOT_DISTINGUISH = ["three parties approving", "one party writing three records"]


def approved(claim, parties, provenance):
    return all(any(record["claim"] == claim for record in party["approvals"]) for party in parties)
TMS/rules/identical_content.py
"""Approved when every party holds the same content.

This is what I shipped on 2026-08-12 and it was wrong within the hour: the three
files were identical because I wrote all three in one commit. Kept here as a
unit rather than deleted, because it is the thing the example is measuring.
"""
NAME = "identical-content"
READS = ["the content each party holds"]
CANNOT_DISTINGUISH = ["three parties agreeing", "one party writing three files"]


def approved(claim, parties, provenance):
    held = [party["holds"].get(claim) for party in parties]
    return all(h is not None for h in held) and len({str(h) for h in held}) == 1

DMS

DMS/__init__.py
DMS/report.py
"""Which rules said approved where, and which of them could not have said otherwise."""


def table(rows, out):
    worlds = list(rows[0]["verdicts"])
    out(f"\n  {'rule':<22} {'reads':<6} " + "  ".join(f"{w:<15}" for w in worlds) + " separates?")
    for row in rows:
        cells = "  ".join(f"{('approved' if row['verdicts'][w] else 'refused'):<15}" for w in worlds)
        separates = len(set(row["verdicts"].values())) > 1
        out(f"  {row['rule']:<22} {row['reads']:<6} {cells} {'YES' if separates else 'no'}")


def blindness(rows, out):
    out("\n  what each rule declares it cannot distinguish:")
    for row in rows:
        out(f"    {row['rule']:<22} {row['declared_blind_to'][1]}")


def gaps(out):
    out("\n  measurable, not measured here:")
    out("    - what requiring distinct provenance costs a party that legitimately")
    out("      acts on another's behalf")
    out("\n  not measurable by this program at all:")
    out("    - whether the provenance store is honest. This moves the question")
    out("      from the artifacts to who placed them; it does not end it, and")
    out("      archaeology 013 measures exactly where that ends.")
    out("    - whether a party who wrote an approval meant it. Nothing here, and")
    out("      nothing anywhere, reads intent.")

root

island_test.py
"""The island test.

    python src/island_test.py

Section 2 is the one this example exists for: each rule declares what it cannot
distinguish, and that declaration is checked by running it over both worlds
rather than read.
"""
import json
import pathlib
import re
import sys

HERE = pathlib.Path(__file__).parent
sys.path.insert(0, str(HERE))

from SCL import policy  # noqa: E402
from SMS import approval  # noqa: E402

CONTRACT = json.loads((HERE / "FMS" / "contract.json").read_text(encoding="utf-8"))
FAILURES = []


def check(label, ok, detail=""):
    print(f"  {'PASS' if ok else 'FAIL'}  {label}{' - ' + detail if detail else ''}")
    if not ok:
        FAILURES.append(label)


LOADED, PROBLEMS = approval.load_rules()
ROWS = {row["rule"]: row for row in approval.run(LOADED)}
separates = lambda name: len(set(ROWS[name]["verdicts"].values())) > 1  # noqa: E731

print("\n== 1. every rule is an island, and FMS's units map matches the tree")
check("all four rules loaded with no problems", not PROBLEMS, "; ".join(PROBLEMS))
rule_dir = HERE / "TMS" / "rules"
files = sorted(f.name for f in rule_dir.iterdir() if f.suffix == ".py" and f.name != "__init__.py")
check("there are four rule files", len(files) == 4, ", ".join(files))
for name in files:
    source = (rule_dir / name).read_text(encoding="utf-8")
    reaches = re.findall(r"^\s*(?:from|import)\s+(\S+)", source, re.M)
    siblings = [r for r in reaches if r.split(".")[0] in {"TMS", "SMS", "SCL", "DMS", "FMS"}]
    check(f"{name} reaches no sibling set", not siblings, ", ".join(reaches) or "no imports at all")
# 011 shipped an FMS that outlived the code it described. This is that check.
for where, expected in CONTRACT["units"].items():
    on_disk = sorted(f.name for f in (HERE / where).iterdir()
                     if f.suffix == ".py" and f.name != "__init__.py")
    check(f"{where}: FMS declares {len(expected)}, on disk {len(on_disk)}",
          on_disk == sorted(expected), ", ".join(on_disk))

print("\n== 2. each rule's declared blindness, checked by running it")
for name, row in sorted(ROWS.items()):
    blind_to_one_author = "one party writing three" in row["declared_blind_to"][1]
    measured_blind = not separates(name)
    check(f"{name}: declares blind to a single author = {blind_to_one_author}, measured {measured_blind}",
          blind_to_one_author == measured_blind,
          f"{row['verdicts']['three parties']} / {row['verdicts']['one author']}")

print("\n== 2b. the drill: a rule that claims to separate and does not must be caught")


class Overclaiming:
    NAME = "reads-everything-decides-nothing"
    READS = ["all of it"]
    CANNOT_DISTINGUISH = ["nothing at all", "an actor whose provenance is itself forged"]

    @staticmethod
    def approved(claim, parties, provenance):
        return True


measured = {world: Overclaiming.approved(None, data["parties"], data["provenance"])
            for world, data in approval.WORLDS.items()}
check("a rule that approves everything while claiming to separate is caught",
      len(set(measured.values())) == 1 and "one party writing three" not in Overclaiming.CANNOT_DISTINGUISH[1],
      f"declared it separates, measured {measured}")

print("\n== 3. how many rules separate the worlds, and what adding fields buys")
separating = [name for name in ROWS if separates(name)]
check("exactly one of four rules separates them", len(separating) == 1, ", ".join(separating))
check("and it is the only one reading something outside the artifacts",
      ROWS[separating[0]]["reads"] == max(row["reads"] for row in ROWS.values()),
      f"{separating[0]} reads {ROWS[separating[0]]['reads']} things")
check("reading MORE of the artifacts does not help - digest-bound reads two and still cannot",
      ROWS["digest-bound-record"]["reads"] > ROWS["identical-content"]["reads"]
      and not separates("digest-bound-record"),
      "the digest binds the approval to the content, which is a real property and not this one")

print("\n== 4. fail closed")
_, problem = approval.resolve("majority-vote", LOADED)
check("an unresolvable rule stops the run", problem is not None, problem or "resolved anyway")
check("SCL names a rule that exists", policy.rule() in LOADED, policy.rule())
check("and the rule it names is one that separates", separates(policy.rule()), policy.rule())

print("\n== 5. what this example does not solve")
print("        MEASURABLE, NOT MEASURED")
print("          - what requiring distinct provenance costs a party legitimately")
print("            acting on another's behalf")
print("        NOT MEASURABLE HERE")
print("          - whether the provenance store is honest. This moves the question")
print("            from the artifacts to who placed them and does not end it;")
print("            archaeology 013 measures where it ends.")
print("          - whether anyone who approved meant it. Nothing reads intent.")

print(f"\n{len(FAILURES)} failure(s)" if FAILURES else "\nall checks passed")
for f in FAILURES:
    print(f"  - {f}")
sys.exit(1 if FAILURES else 0)
main.py
"""Four rules, two worlds identical in every artifact.

    python src/main.py            every rule over both worlds
    python src/main.py --strict   exit 1 if the configured rule cannot separate them
"""
import json
import pathlib
import sys

HERE = pathlib.Path(__file__).parent
sys.path.insert(0, str(HERE))

from DMS import report  # noqa: E402
from SCL import policy  # noqa: E402
from SMS import approval  # noqa: E402

ARCH = json.loads((HERE / "FMS" / "contract.json").read_text(encoding="utf-8"))


def main(argv):
    out = lambda line="": sys.stdout.write(line + "\n")  # noqa: E731
    loaded, problems = approval.load_rules()
    if problems:
        for problem in problems:
            out(f"  !! {problem}")
        return 1

    out("\n== two worlds, and every artifact in them is identical")
    for name, description in ARCH["the_two_worlds"].items():
        out(f"    {name:<15} {description}")

    rows = approval.run(loaded)
    report.table(rows, out)
    report.blindness(rows, out)

    configured, problem = approval.resolve(policy.rule(), loaded)
    if problem:
        out(f"\n  !! {problem}")
        return 1
    row = next(r for r in rows if r["rule"] == policy.rule())
    separates = len(set(row["verdicts"].values())) > 1
    out(f"\n== this deployment trusts {policy.rule()}")
    out(f"    it {'separates' if separates else 'CANNOT separate'} the two worlds")

    report.gaps(out)

    if "--strict" in argv and not separates and policy.indistinguishable_is_fatal():
        return 1
    return 0


if __name__ == "__main__":
    sys.exit(main(sys.argv[1:]))