From e9552f0d2ede875e987072ace101a163ceecec28 Mon Sep 17 00:00:00 2001 From: Daniel Ziegler <281686281+Innov8zig@users.noreply.github.com> Date: Sat, 5 Dec 2026 15:44:11 -0800 Subject: [PATCH 1/2] Python independently checks Relate's transit classification: the second opinion uses ScopeMoat's own path search, no Relate query (v1.0.5); acceptance D6-D8, K6 updated; README Relate/Python row, edit line and git identity; EVIDENCE count 145 --- EVIDENCE.md | 2 +- README.md | 6 ++-- acceptance.py | 64 +++++++++++++++++++++++++++++++----- experiments/force_relate.py | 57 ++++++++++++++++++++++++++++++-- explorer/data/scenarios.json | 4 +-- scopemoat/rules_v5.py | 27 ++++++++++++--- 6 files changed, 137 insertions(+), 23 deletions(-) diff --git a/EVIDENCE.md b/EVIDENCE.md index 995855e..28d0acf 100644 --- a/EVIDENCE.md +++ b/EVIDENCE.md @@ -12,7 +12,7 @@ Every result ScopeMoat publishes, where its record lives, and the command that r | Relate path query agrees with the Python reference: 0 membership mismatches over 539 fixture-by-case comparisons | main | `blind/v5/reach_crosscheck.py`, `blind/v5/reach_inventory.json` | `python acceptance.py` (check K7) | | Browser explorer: Relate's WebAssembly build (1.4.0) returns the same rows as relate-db for every recorded state, 6/6 (proposal, repair, missing evidence; baseline and candidate each) | main | `explorer/` (index.html, data/scenarios.json, vendor/relate-wasm-1.4.0/) | `python -m explorer.build_export --check` (exit 0: data current), then `node explorer/parity.mjs` (expected `Parity: 6/6 states identical`) | | Transit search guard: on the pinned forwarding-clique fixture, 5 forwarding systems still BLOCK with the same Relate path; 6 and 20 are held for review by the search-size guard in under 0.2 s instead of 23 s / out of memory | main | `perf/README.md`, `perf/forwarding_clique.py`, `perf/bench.py` | `python perf/bench.py 5 6 7 20`; acceptance P1-P3 | -| Engine and gate behaviour | main | `acceptance.py` (141 required checks), `blind/v5/checks_v5.py` (67), `t3/test_t3.py` (36) | `python acceptance.py`; `python blind/v5/checks_v5.py`; `python t3/test_t3.py` | +| Engine and gate behaviour | main | `acceptance.py` (145 required checks), `blind/v5/checks_v5.py` (67), `t3/test_t3.py` (36) | `python acceptance.py`; `python blind/v5/checks_v5.py`; `python t3/test_t3.py` | ## How to read these diff --git a/README.md b/README.md index 4764039..6c49e07 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ A shallow clone skips the T4 rescore; a ZIP download (no git) skips the T4 and T ## Try the gate yourself - **Read-only, nothing changes in your clone:** `.venv/bin/python -m scopemoat check graph/brightline.rl changes/bi_to_orders.json --explain` (Windows: `.\.venv\Scripts\python.exe -m scopemoat check graph\brightline.rl changes\bi_to_orders.json --explain`). It exits 1 and prints `VERDICT: BLOCK: 1 system(s) enter scope, 0 move into the CDE` and `Relate path: bi-dashboards -> orders-api -> checkout-api`, then the Cypher query with its parameters and Relate's rows before the change (7) and after it (8, the new one marking the added link in its `changes` column). The hook names the Compose edit ("bi-dashboards joins orders-db-net"), while `check` on a change file says "added by the change file"; it is the same link. -- **With the commit gate, in your clone:** run `.venv/bin/python -m scopemoat install-hook`, make the edit above, then `git add deploy/compose.yaml` and `git commit`. Git refuses the commit. `.venv/bin/python -m scopemoat gate --explain` prints the Cypher query and Relate's rows. `.venv/bin/python -m t3.clean_replay t3/runs/20261130T025027Z_bi_order_status/trace.json` replays the recorded proposal and repair in a temporary clone. +- **With the commit gate, in your clone:** run `.venv/bin/python -m scopemoat install-hook`, make the edit above (line 25 of `deploy/compose.yaml`: `networks: [bi-net]` becomes `networks: [bi-net, orders-db-net]`), then `git add deploy/compose.yaml` and `git commit` (on a fresh machine, set `git config user.name` and `user.email` first). Git refuses the commit. `.venv/bin/python -m scopemoat gate --explain` prints the Cypher query and Relate's rows. `.venv/bin/python -m t3.clean_replay t3/runs/20261130T025027Z_bi_order_status/trace.json` replays the recorded proposal and repair in a temporary clone. - **Step by step:** the full walkthrough is in [docs/WALKTHROUGH.md](docs/WALKTHROUGH.md). It covers the commit gate's fail-closed rules, the `review` policy, the chokepoint query in Relate's CLI, where card data reappears, and the MCP servers. - **No install:** [pull request #1](https://github.com/Innov8zig/ScopeMoat/pull/1) fails the change and passes the repair in GitHub Actions. The [browser explorer](https://innov8zig.github.io/ScopeMoat/explorer/) reruns the hook's query in Relate's WebAssembly build. @@ -67,7 +67,7 @@ A shallow clone skips the T4 rescore; a ZIP download (no git) skips the T4 and T | Which network links the staged Compose file adds | Python ([scopemoat/compose.py](scopemoat/compose.py)) | | Which systems are in scope on recorded facts (card data systems, the CDE, systems connected to it or securing it, and systems that reach it through others), before and after the change | Relate: Cypher queries over an in-memory Relate database that ScopeMoat loads from `graph/brightline.rl` (systems, data flows, security services) plus the per-direction `REACH` evidence it writes ([scopemoat/relate_scope.py](scopemoat/relate_scope.py)) | | Which path puts a system in scope, and which edit opened it | Relate's row (`path` and `changes` columns) | -| BLOCK or PASS | Relate's in-scope classes. The Python rules ([scopemoat/rules_v5.py](scopemoat/rules_v5.py), mapped to the PCI SSC guidance in [provider_reference/RULE_TO_SSC.md](provider_reference/RULE_TO_SSC.md)) compute the same classes independently; if the two disagree, or Relate cannot answer, the gate returns REVIEW REQUIRED | +| BLOCK or PASS | Relate's in-scope classes. The Python rules ([scopemoat/rules_v5.py](scopemoat/rules_v5.py), mapped to the PCI SSC guidance in [provider_reference/RULE_TO_SSC.md](provider_reference/RULE_TO_SSC.md)) compute the same classes independently, including systems that reach the CDE through others (ScopeMoat's own Python path search, with no Relate query; since v1.0.5); if the two disagree, or Relate cannot answer, the gate returns REVIEW REQUIRED | | REVIEW REQUIRED for unresolved evidence (the worst case, every unrecorded fact treated as open) | Python rules. Relate does not run this search: on Brightline it explores more than two million trails | | Refusing the commit | Git, through the local pre-commit hook | @@ -149,7 +149,7 @@ The same gate runs on every pull request ([.github/workflows/scopemoat.yml](.git | `t3/`, `t4/`, `t5/` | the recorded agent run and replay, the agent benchmark, the pre-registered agent A/B | | `blind/` | the frozen 40-case comparison with simpler checks | | `explorer/` | the browser explorer and scope page (Relate WebAssembly) | -| `verify.py`, `acceptance.py`, [EVIDENCE.md](EVIDENCE.md) | every published claim in one command, the full check suite, and the evidence index | +| `verify.py`, `acceptance.py`, [EVIDENCE.md](EVIDENCE.md) | the release checks in one command, the full check suite, and the evidence index | Records under `blind/`, `t3/runs/`, `t4/runs/` and `provider_reference/results/` are frozen and are not edited after they are committed. A rerun is reported as a separate run. diff --git a/acceptance.py b/acceptance.py index be75ff2..d5ed0b1 100644 --- a/acceptance.py +++ b/acceptance.py @@ -1029,8 +1029,8 @@ def _rows(res, state): and not any("Relate" in p for p in _er.problems), f"verdict {_er.verdict if _er else None} (from the other v5 rules); error {(getattr(_er, 'reach', None) or {}).get('error', '?')}") - # K6: data dependency at the gate boundary. (a) Python transit disabled: the BLOCK and its path still come - # from Relate. (b) Relate's answer replaced by an empty one: BI no longer enters scope through R4/R4R. + # K6: data dependency at the gate boundary. (a) Python's own transit search disabled: Relate alone cannot + # BLOCK. (b) Relate's path query answers nothing: Python alone cannot BLOCK. Both are REVIEW (v1.0.5). def _judge_blocked(): c = store.open_baseline(STORE)[0] try: @@ -1049,12 +1049,13 @@ def _judge_blocked(): _no_cy = _judge_blocked() finally: _reach.PATH_QUERY = _orig_q - check("K6 the verdict depends on Relate's answer: with Python's transit table disabled the BLOCK and path stand; " - "with Relate's answer emptied, BI does not enter scope", - _no_py.verdict == BLOCK and _no_py.entered_scope.get("bi-dashboards") is not None - and _no_py.entered_scope["bi-dashboards"].path == ["bi-dashboards", "orders-api", "checkout-api"] - and "bi-dashboards" not in _no_cy.entered_scope and (getattr(_no_cy, "reach", None) or {}).get("error", "x") is None, - f"python off: {_no_py.verdict} {list(_no_py.entered_scope)}; relate empty: {_no_cy.verdict} {list(_no_cy.entered_scope)}") + # v1.0.5: both opinions are required. Either side alone cannot BLOCK or PASS the BI change. + check("K6 both opinions are required: with Python's own transit search disabled, or with Relate's path query " + "emptied, the BI change is REVIEW REQUIRED naming bi-dashboards, never BLOCK or PASS on one side alone", + _no_py.verdict == REVIEW and any("bi-dashboards: Relate OTHER, Python OUT" in p for p in _no_py.problems) + and _no_cy.verdict == REVIEW and any("bi-dashboards: Relate OUT, Python OTHER" in p for p in _no_cy.problems) + and "bi-dashboards" not in (getattr(_no_cy, "entered_scope", None) or {}), + f"python off: {_no_py.verdict} {_no_py.problems[:1]}; relate empty: {_no_cy.verdict} {_no_cy.problems[:1]}") # K9-K12: ChatGPT review of b63611d (Nov 30) def _mini(g, name): @@ -1201,7 +1202,7 @@ def _judge_store(spec_path, head, staged): if _row["system"] == "bi-dashboards": _row["path"] = ["bi-dashboards", "relate-said-this", "checkout-api"] _m8b = _pic.mermaid(_r8b, _ops8) or "" - _m8c = _pic.mermaid(_no_cy, _ops8) or "" + _m8c = _pic.mermaid(_er, []) or "" # a successful query with no new reachability (K5) # names that differ only in punctuation keep distinct nodes: a-b -> a_b -> b is drawn as two nodes, not a self-loop _g8 = {"description": "K8", "graph": {"systems": [ {"name": n, "zone": z, "stores_pan": p, "processes_pan": p} @@ -1883,6 +1884,51 @@ def _force(mode, *args): finally: shutil.rmtree(_d5dir, ignore_errors=True) +# D6-D8 (v1.0.5): the second opinion is independent of Relate. A consistent wrong Relate transit answer (the class +# queries and the path rows both wrong, so they agree with each other) is caught only by ScopeMoat's own Python +# transit search. On v1.0.4 the same injected addition gave BLOCK with 2 systems (the Python side reused Relate's +# path query), and the omission was held only by the worst case. +_d6 = _force("transit-drop", "check", "graph/brightline.rl", "changes/bi_to_orders.json") +check("D6 independent Python transit: Relate's transit rows omit bi-dashboards in every answer; the gate is REVIEW " + "REQUIRED (exit 2) because Python's own search still finds it", + _d6.returncode == 2 and "Relate and the Python rules disagree on the confirmed scope" in _d6.stdout + and "changed bi-dashboards: Relate OUT, Python OTHER" in _d6.stdout, f"exit {_d6.returncode}") +_d7 = _force("transit-add", "check", "graph/brightline.rl", "changes/bi_to_orders.json") +check("D7 independent Python transit: Relate's transit answer adds wiki consistently (class queries and path rows); " + "the gate is REVIEW REQUIRED (exit 2) because Python's own search does not find it", + _d7.returncode == 2 and "Relate and the Python rules disagree on the confirmed scope" in _d7.stdout + and "changed wiki: Relate OTHER, Python OUT" in _d7.stdout, f"exit {_d7.returncode}") +for _mode, _who in (("transit-drop", "changed bi-dashboards: Relate OUT, Python OTHER"), + ("transit-add", "changed wiki: Relate OTHER, Python OUT")): + _d8dir = tempfile.mkdtemp(prefix="acc-force-transit-") + try: + _d8 = os.path.join(_d8dir, "repo") + subprocess.run(["git", "clone", "-q", HERE, _d8], capture_output=True, timeout=300) + for _k, _v in (("user.email", "acc@example.com"), ("user.name", "acc")): + subprocess.run(["git", "config", _k, _v], cwd=_d8, capture_output=True) + subprocess.run([sys.executable, "-m", "scopemoat", "install-hook"], cwd=_d8, capture_output=True, timeout=120) + _hp = os.path.join(_d8, ".git", "hooks", "pre-commit") + with open(_hp, encoding="utf-8") as _f: + _hook = _f.read() + with open(_hp, "w", encoding="utf-8", newline="\n") as _f: + _f.write(_hook.replace("-m scopemoat gate", f"-m experiments.force_relate {_mode} -- gate")) + with open(os.path.join(HERE, "t3/runs/20261130T025027Z_bi_order_status/trace.json"), encoding="utf-8") as _f: + _comp = json.load(_f)["steps"][0]["compose"] + with open(os.path.join(_d8, "deploy", "compose.yaml"), "w", encoding="utf-8", newline="\n") as _f: + _f.write(_comp) + subprocess.run(["git", "add", "deploy/compose.yaml"], cwd=_d8, capture_output=True) + _h0 = subprocess.run(["git", "rev-parse", "HEAD"], cwd=_d8, capture_output=True, text=True).stdout + _c = subprocess.run(["git", "commit", "-m", f"forced {_mode}"], cwd=_d8, capture_output=True, text=True, + encoding="utf-8", timeout=300) + _h1 = subprocess.run(["git", "rev-parse", "HEAD"], cwd=_d8, capture_output=True, text=True).stdout + _out = _c.stdout + _c.stderr + check(f"D8 through the installed Git hook, {_mode} is REVIEW REQUIRED (exit 2), names the mismatch, and HEAD " + "does not move", + _c.returncode != 0 and _who in _out and "Commit blocked by ScopeMoat (exit 2)" in _out and _h0 == _h1, + f"commit exit {_c.returncode}; HEAD moved {_h0 != _h1}") + finally: + shutil.rmtree(_d8dir, ignore_errors=True) + # E: the pull request check runs the base branch's engine, not the pull request's, and holds any pull request that # changes the gate itself for review (ci/pr_check.py). Each case runs pr_check.py from a fresh base checkout. _edir = tempfile.mkdtemp(prefix="acc-prcheck-") diff --git a/experiments/force_relate.py b/experiments/force_relate.py index a5ef842..3697f3c 100644 --- a/experiments/force_relate.py +++ b/experiments/force_relate.py @@ -7,12 +7,19 @@ drop Relate's answer for the changed graph omits bi-dashboards (Python still has it) add Relate's answer for the changed graph adds a system Python does not put in scope (wiki) unavailable Relate cannot answer within the search-size guard + transit-drop Relate's transit path query omits bi-dashboards in every answer, so the class queries and the + path rows agree with each other; the omission is applied to Relate's raw rows, which the + witness check cannot catch (it validates returned paths, it does not search) + transit-add Relate's transit answer adds a system no recorded path supports (wiki), consistently in the class + queries and the path rows, after the witness check (as if the witness check had a bug) -Used by acceptance.py (D1-D5). It patches only this process; nothing on disk changes. +Used by acceptance.py (D1-D8). It patches only this process; nothing on disk changes. """ import sys -from scopemoat import cli, relate_scope +import relate + +from scopemoat import cli, reach, relate_scope mode, args = sys.argv[1], sys.argv[sys.argv.index("--") + 1:] orig, calls = relate_scope.known_scope, [] @@ -31,7 +38,51 @@ def forced(m): return k -relate_scope.known_scope = forced +if mode in ("drop", "add", "unavailable", "count"): + relate_scope.known_scope = forced + +if mode == "transit-drop": + _connect = relate.connect + + class _Conn: + """A Relate connection whose transit path query answers without bi-dashboards.""" + + def __init__(self, c): + object.__setattr__(self, "_c", c) + + def __getattr__(self, k): + return getattr(self._c, k) + + def __setattr__(self, k, v): + setattr(self._c, k, v) + + def execute(self, q, *a, **kw): + rows = self._c.execute(q, *a, **kw) + if isinstance(q, str) and "RETURN u.name AS system" in q: + calls.append(1) + return [r for r in rows if r["system"] != "bi-dashboards"] + return rows + + relate.connect = lambda *a, **kw: _Conn(_connect(*a, **kw)) + +if mode == "transit-add": + _validate, _known = reach.Provider._validate, relate_scope.known_scope + _path = ["wiki", "orders-api", "checkout-api"] + + def validate_add(self, *a, **kw): + found = _validate(self, *a, **kw) + if self.state == "candidate": + calls.append(1) + found = {**found, "wiki": (list(_path), "R4R", {"system": "wiki", "path": list(_path)})} + return found + + def known_add(m): + k = _known(m) + if "bi-dashboards" in k["other"]: # the changed graph only + k = {**k, "other": k["other"] | {"wiki"}, "transit": {**k["transit"], "wiki": list(_path)}} + return k + + reach.Provider._validate, relate_scope.known_scope = validate_add, known_add code = cli.main(args) print(f"force_relate: mode={mode} known_scope calls={len(calls)}", file=sys.stderr) sys.exit(code) diff --git a/explorer/data/scenarios.json b/explorer/data/scenarios.json index 925c361..75d7557 100644 --- a/explorer/data/scenarios.json +++ b/explorer/data/scenarios.json @@ -1,6 +1,6 @@ { - "commit": "5408016", - "engine": "scopemoat/engine.py (committed; rules v5: scopemoat/rules_v5.py sha256 b50aa3a2ba54)", + "commit": "4fa3a78", + "engine": "scopemoat/engine.py (committed; rules v5: scopemoat/rules_v5.py sha256 4397ba00a496)", "relate_db": "1.4.0", "scenarios": [ { diff --git a/scopemoat/rules_v5.py b/scopemoat/rules_v5.py index ebb0ea6..b0ff0ca 100644 --- a/scopemoat/rules_v5.py +++ b/scopemoat/rules_v5.py @@ -276,8 +276,9 @@ def leaving(n, u, y, t): def _python_transit(m, scope, cde, d, nbrs, possible, label, leaving): - """v5 transit (R4/R4R) computed in Python: used for the worst case and for resolved-fact searches (REVIEW). - The known-facts case in evaluate() asks Relate instead (scopemoat/reach.py).""" + """v5 transit (R4/R4R) computed in Python: used for the worst case, for resolved-fact searches (REVIEW), and + since v1.0.5 as the independent second opinion on the known-facts case, which evaluate() also asks Relate for + (scopemoat/reach.py, scopemoat/relate_scope.py).""" relay = m.directions()[1] # C2b: nxt[(n, u, t)] set if n forwards traffic that entered from u labelled t onward to the CDE; fixed point labels = {"any", "unknown"} | {v["op"] for v in d.values()} | {o for r in relay.values() for o in r["ops"]} @@ -1205,7 +1206,7 @@ def evaluate(conn, ops, replaces=None): return r # Confirmed scope from Relate: every in-scope class on recorded facts, computed by Cypher # (scopemoat/relate_scope.py), before and after the change. The BLOCK sets below come from Relate's rows; - # the Python rules (bb, ab) recompute them independently. Any disagreement fails closed to REVIEW. + # the Python rules recompute them independently (ib, ia below). Any disagreement fails closed to REVIEW. try: kb, ka = relate_scope.known_scope(before), relate_scope.known_scope(after) except relate_scope.Unavailable as e: @@ -1216,9 +1217,15 @@ def evaluate(conn, ops, replaces=None): return r def _relate_class(k): return {n: ("CDE" if n in k["cde"] else "OTHER") for n in k["cde"] | k["other"]} + + def _py_class(sc): + return {n: ("CDE" if f.category == "CDE" else "OTHER") for n, f in sc.items()} rel_b, rel_a = _relate_class(kb), _relate_class(ka) - py_b = {n: ("CDE" if f.category == "CDE" else "OTHER") for n, f in bb.items()} - py_a = {n: ("CDE" if f.category == "CDE" else "OTHER") for n, f in ab.items()} + # The second opinion is independent of Relate: every class, transit (R4/R4R) included, from ScopeMoat's own + # Python search on the same recorded facts, with no Relate query and no Relate rows (v1.0.5). bb/ab keep + # Relate's paths as the evidence the verdict shows. + ib, ia = scope_of(before, False), scope_of(after, False) + py_b, py_a = _py_class(ib), _py_class(ia) if rel_b != py_b or rel_a != py_a: diff = [f"{tag} {n}: Relate {rel.get(n, 'OUT')}, Python {py.get(n, 'OUT')}" for tag, rel, py in (("baseline", rel_b, py_b), ("changed", rel_a, py_a)) @@ -1227,6 +1234,16 @@ def _relate_class(k): r.reductions, r.review_groups, r.review_detail, r.basis_removed = [], {}, {}, {} r.reach = {"baseline": rb.record, "candidate": ra.record, "new": {}, "error": "relate/python disagreement"} return r + # Relate's path rows (reach.Provider) must give the same classes as Relate's class queries (relate_scope). + if _py_class(bb) != rel_b or _py_class(ab) != rel_a: + diff = [f"{tag} {n}: class queries {rel.get(n, 'OUT')}, path rows {pr.get(n, 'OUT')}" + for tag, rel, pr in (("baseline", rel_b, _py_class(bb)), ("changed", rel_a, _py_class(ab))) + for n in sorted(set(rel) | set(pr)) if rel.get(n) != pr.get(n)] + r = Result(E.REVIEW, "Relate's class queries and its path rows disagree on the confirmed scope", + problems=diff, notes=notes) + r.reductions, r.review_groups, r.review_detail, r.basis_removed = [], {}, {}, {} + r.reach = {"baseline": rb.record, "candidate": ra.record, "new": {}, "error": "relate class/path disagreement"} + return r bw, aw = scope_of(before, True), scope_of(after, True) cb = {n: (("CDE" if bb[n].category == "CDE" else "OTHER") if n in bb else ("UNRESOLVED" if n in bw else "OUT")) for n in before.zone} ca = {n: (("CDE" if ab[n].category == "CDE" else "OTHER") if n in ab else ("UNRESOLVED" if n in aw else "OUT")) for n in after.zone} From 4e15e302f8116d8de26adf2715a66d47fc918258 Mon Sep 17 00:00:00 2001 From: Daniel Ziegler <281686281+Innov8zig@users.noreply.github.com> Date: Sat, 5 Dec 2026 15:53:54 -0800 Subject: [PATCH 2/2] README: evaluation summary with result and key limitation side by side; full tables moved unchanged to docs/EVALUATION.md; Relate/Python roles worded per v1.0.5 --- README.md | 48 ++++++---------------------------------------- docs/EVALUATION.md | 45 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 42 deletions(-) create mode 100644 docs/EVALUATION.md diff --git a/README.md b/README.md index 6c49e07..edc442b 100644 --- a/README.md +++ b/README.md @@ -67,53 +67,17 @@ A shallow clone skips the T4 rescore; a ZIP download (no git) skips the T4 and T | Which network links the staged Compose file adds | Python ([scopemoat/compose.py](scopemoat/compose.py)) | | Which systems are in scope on recorded facts (card data systems, the CDE, systems connected to it or securing it, and systems that reach it through others), before and after the change | Relate: Cypher queries over an in-memory Relate database that ScopeMoat loads from `graph/brightline.rl` (systems, data flows, security services) plus the per-direction `REACH` evidence it writes ([scopemoat/relate_scope.py](scopemoat/relate_scope.py)) | | Which path puts a system in scope, and which edit opened it | Relate's row (`path` and `changes` columns) | -| BLOCK or PASS | Relate's in-scope classes. The Python rules ([scopemoat/rules_v5.py](scopemoat/rules_v5.py), mapped to the PCI SSC guidance in [provider_reference/RULE_TO_SSC.md](provider_reference/RULE_TO_SSC.md)) compute the same classes independently, including systems that reach the CDE through others (ScopeMoat's own Python path search, with no Relate query; since v1.0.5); if the two disagree, or Relate cannot answer, the gate returns REVIEW REQUIRED | +| BLOCK or PASS | Relate's in-scope classes | +| Independent check of Relate's result | Python rules ([scopemoat/rules_v5.py](scopemoat/rules_v5.py), mapped to the PCI SSC guidance in [provider_reference/RULE_TO_SSC.md](provider_reference/RULE_TO_SSC.md)) recompute the confirmed classes, transit reachability included, with ScopeMoat's own Python path search and no Relate query (since v1.0.5). A disagreement, or no answer from Relate, puts the change into REVIEW REQUIRED | | REVIEW REQUIRED for unresolved evidence (the worst case, every unrecorded fact treated as open) | Python rules. Relate does not run this search: on Brightline it explores more than two million trails | | Refusing the commit | Git, through the local pre-commit hook | -No AI decides scope. Relate's queries and the Python rules are two implementations of the same rules, and the gate needs both to agree; `verify.py` checks that they agree on every frozen state. Without Relate the demo change drops to REVIEW REQUIRED and loses its path. Replacing only Relate's transit query with ScopeMoat's separate Python search still gives BLOCK, because the in-scope classes still come from Relate's queries. Run `.venv/bin/python experiments/relate_ablation.py` with `shipped` (BLOCK), `no_relate` (REVIEW REQUIRED) or `python_transit` (BLOCK) ([experiments/relate_ablation.py](experiments/relate_ablation.py)). +No AI decides scope. Relate computes confirmed scope and supplies the path shown in the demo. ScopeMoat uses Relate's result to detect scope expansion. Python independently recomputes transit reachability, and a disagreement puts the change into REVIEW REQUIRED. `verify.py` checks that the two agree on every frozen state. Without Relate the demo change drops to REVIEW REQUIRED and loses its path. Replacing only Relate's transit query with ScopeMoat's separate Python search still gives BLOCK, because the in-scope classes still come from Relate's queries. Run `.venv/bin/python experiments/relate_ablation.py` with `shipped` (BLOCK), `no_relate` (REVIEW REQUIRED) or `python_transit` (BLOCK) ([experiments/relate_ablation.py](experiments/relate_ablation.py)). -## Checked against published answer keys +## Checked against answer keys -ScopeMoat's unchanged rules, scored against published answer keys: PCI SSC 2017 and 2024, AWS and Google, two simpler baselines (B1, B2) on the same AWS and Google labels, and W3 (Google's PCI on GKE blueprint). In W3, Google labels the 3 in-scope services; the 7 out-of-scope labels are the author's inference from cluster placement. Every graph in these rows was built by the author from the published text ([provider_reference/GAPS.md](provider_reference/GAPS.md): "built from the published sources listed in SOURCES.md"). For the AWS and Google rows, the labels were committed (563e140) before the graphs (3960950, tag `provider-ref-frozen-2026-12-04`) and before any engine run, the graphs had a cold review against the cited sources ([REVIEW.md](provider_reference/REVIEW.md)), and the run was scored once ([SCORING.md](provider_reference/SCORING.md) step 7: "No run is repeated to get a different number"). - -In short, every number below is from the table: -- Against the published answer keys (PCI SSC 2017 and 2024, AWS and Google, Google's GKE blueprint), ScopeMoat never puts a system out of scope that the publisher puts in scope: 0 looser in every one of those rows. -- Where a source states no control on a connection, ScopeMoat holds the system in scope instead of guessing: 7 of the 25 AWS and Google labels are UNRESOLVED. -- Simpler rules can match more labels but miss in-scope systems: B1 (in scope only where card numbers are stored, processed, sent or received) matches 18 and is looser on 7; B2 (any link to a card-data system puts a system in scope) matches 20 and is looser on 1; ScopeMoat matches 15 and is looser on 0. - -How to read the result column (classes as defined in [provider_reference/RULE_TO_SSC.md](provider_reference/RULE_TO_SSC.md)): -- **CDE:** the system stores, processes or transmits account data, is on the same network segment as a system handling account data, or has unrestricted connectivity to one (rules R1, R1S and R2). -- **OTHER:** "every other rule gives OTHER": in scope but not CDE, for example connected-to, providing security services to the CDE, or a usable access path to the CDE through another system. -- **OUT:** "in scope in neither case: no rule fires even with missing evidence treated as open". -- **Stricter:** ScopeMoat puts a system in scope that the publisher left out. That costs audit effort. -- **Looser:** ScopeMoat puts a system out of scope where the publisher says it is in scope. This is the dangerous error: a system that needs PCI controls is left out of the assessment. -- **UNRESOLVED:** the source states no control on a connection. ScopeMoat withholds OUT and treats the system as in scope until evidence arrives. - Of the 7 UNRESOLVED results, the publishers label 4 in scope (A1-04, A2-02, A3-01, G2-01) and 3 out of scope (A2-03, A3-05, G2-02) ([RESULTS.md](provider_reference/RESULTS.md) per-label table, lines 62, 73-76, 83-84). Treating missing evidence as closed instead of open would make those 4 looser; that is why ScopeMoat fails closed. - -| Answer key (full title, year) | Compared | Result | File | -|---|---|---|---| -| PCI SSC, Guidance for PCI DSS Scoping and Network Segmentation v1.1 (May 2017) | Examples 1 and 2: 5 systems, 2 variants, 10 labels | 8 of 10 matched, 2 stricter, 0 looser | [experiments/ssc_examples/README.md](experiments/ssc_examples/README.md) | -| PCI SSC, PCI DSS Scoping and Segmentation Guidance for Modern Network Architectures (Sept 2024) | 6 examples, 15 scored labels | 15 of 15 matched; the Python rules and the Relate provider agree | [experiments/ssc_2024/README.md](experiments/ssc_2024/README.md) | -| AWS and Google Cloud published PCI reference architectures | 26 publisher labels; 25 modelable | ScopeMoat: 15 match, 3 stricter, 0 looser, 7 UNRESOLVED of 25 | [provider_reference/RESULTS.md](provider_reference/RESULTS.md) | -| Same 25 labels, baseline B1: PAN-presence oracle (a system is in scope (CDE) only if it stores or processes card numbers or is an end of a PAN or SAD flow; everything else is OUT) | 25 labels | 18 match, 0 stricter, 7 looser, 0 UNRESOLVED of 25 | [provider_reference/baselines/RESULTS.md](provider_reference/baselines/RESULTS.md) | -| Same 25 labels, baseline B2: permissive one-hop (any link to a card-data system puts a system in scope) | 25 labels | 20 match, 4 stricter, 1 looser, 0 UNRESOLVED of 25 | [provider_reference/baselines/RESULTS.md](provider_reference/baselines/RESULTS.md) | -| Google, PCI on GKE blueprint, developed for PCI DSS 3.2.1 (W3) | 3 services Google labels in scope, 7 out of scope by cluster placement; 2 variants | every label matches in both variants; the Python rules and the Relate provider agree | [experiments/w3_gke/LABELS.md](experiments/w3_gke/LABELS.md) | - -B1 and B2 match more labels (18 and 20), yet they are worse: B1 is looser on 7 labels and B2 on 1, while ScopeMoat is looser on 0. B1 is the best case for any rule that looks only at where card numbers are, and it calls every connected-to and security-impacting system out of scope. - -## Checked against the author's own keys - -The same rules against keys the author wrote: the 40 frozen cases; T4, the author's benchmark of 12 frozen agent tasks; the twin, one change judged on two baselines that differ in one recorded fact; and T5, the pre-registered agent A/B, the same agent on the same facts with and without a Relate query tool. In short, on T4 the gate did not improve outcomes: 0 of 36 unsafe ships in both arms, and 12 of 36 safe deliveries with the gate output against 15 of 36 without. On T5 the Relate tool did not improve outcomes: 8 of 11 twin pairs fully right with it against 11 of 11 without, and 0 of 23 false PASS against 2 of 23. - -| Answer key (full title, year) | Compared | Result | File | -|---|---|---|---| -| The author's answer key for 40 frozen cases, written before scoring | 40 changes | ScopeMoat: 36 exact, 0 false PASS. One-hop check: 24 exact, 15 false PASS. Plain reachability: 20 exact, 16 false PASS. Neither simpler check can return REVIEW REQUIRED, and 14 of the 40 expected verdicts are REVIEW. On the 26 expected BLOCK or PASS cases, one-hop is exact on 24 and ScopeMoat on 23 | [blind/baselines/SPLITS.txt](blind/baselines/SPLITS.txt) (lines 1-3), [AUDIT.md](blind/baselines/AUDIT.md) (line 7) | -| The author's 12 frozen agent tasks (T4), claude-sonnet-5-5, 3 repeats, 36 runs per arm, blind-scored | the same agent without and with ScopeMoat's gate output | Unsafe ships (the benchmark's scored decision category): 0 of 36 without the gate output, 0 of 36 with it. Safe deliveries: 15 of 36 without, 12 of 36 with. Under the frozen win rule the gate arm did not win (3 fewer safe deliveries, all on T4-07, where the gate returned REVIEW REQUIRED on a design the frozen answer key rates PASS) | [t4/runs/live1/README.md](t4/runs/live1/README.md) (lines 3, 9-16) | -| Twin pair P01 (from the T5 design; rule-derived label) | the demo change on two baselines that differ in one recorded fact | BLOCK becomes REVIEW REQUIRED; Relate's rows go from 8 to 0 | [experiments/twin_replay.py](experiments/twin_replay.py) | -| The author's pre-registered agent A/B (T5), claude-sonnet-5-5, one repeat, 23 singles and 11 twin pairs | the same agent with the facts as text (arm A) or the same text plus a read-only Relate Cypher tool (arm B) | Registered: "H1: B gets more twin pairs fully right than A. H2: B has no more false PASS than A." and "H1 counts as supported only if B leads on pairs and p < 0.10". Twin pairs fully right: 11 of 11 without the Relate tool (arm A), 8 of 11 with it (arm B); 3 of arm B's answers were malformed JSON, which the registered scorer counts as failures. False PASS on singles: 2 of 23 (A), 0 of 23 (B). Exact verdicts on singles: 20 of 23 (A), 21 of 23 (B). No demonstrated difference on H1, as registered ("anything else is reported as no demonstrated difference, with the counts") (A alone right on 3 pairs, B alone on 0; p = 0.25); H2 holds. B made 12 Relate queries; in no state where the arms' verdicts differed did a query return a fact the answer used (one timed out), so no result is credited to the graph. The registered audit (S1, S2) found 140 of 140 checkable cited facts in A's answers and 146 of 147 in B's in the graph, and ScopeMoat enforcing its configured policy matched the key on 34 of 35 states with 0 false PASS. The run resumed after the daily spend cap; three files off the prompt and scoring path changed in between (listed in the commit). T5 tested giving the agent raw Cypher access; ScopeMoat's gate does not depend on it (the agent receives the gate's verdict, not the graph). | [t5/runs/fri4/report.json](t5/runs/fri4/report.json), [audit.json](t5/runs/fri4/audit.json), [t5/README.md](t5/README.md) | - -The 40-case key was written by the author, 17 of those cases were used to develop the rules ([blind/baselines/SPLITS.txt](blind/baselines/SPLITS.txt): 23 untuned, suite 1 of 17), and the twin label is derived from the rules. +- **Published answer keys.** Result: against keys it did not write (PCI SSC's scoping examples, 2017: 8 of 10 matched, 2 stricter; 2024: 15 of 15; AWS and Google's PCI reference architectures, 25 labels: 15 match, 3 stricter, 7 UNRESOLVED), ScopeMoat never put a system out of scope that the publisher put in scope (0 looser). Key limitation: every graph was built by the author from the published text, and the 7 UNRESOLVED labels are held for review because the source states no control (publishers label 4 of them in scope). [Full tables](docs/EVALUATION.md#checked-against-published-answer-keys) +- **The author's own keys.** Result: on 40 frozen cases it passed none of the changes the key blocks or holds for review (0 false PASS); a one-hop check passed 15 and plain reachability 16. Key limitation: the author wrote that key and used 17 of the cases to develop the rules, and two agent experiments, giving an agent the gate's output (T4) or a raw Relate query tool (T5), showed no demonstrated improvement in the agent's decisions. [Full tables](docs/EVALUATION.md#checked-against-the-authors-own-keys) ## What the graph tells an auditor, a company and a red team diff --git a/docs/EVALUATION.md b/docs/EVALUATION.md new file mode 100644 index 0000000..199fa14 --- /dev/null +++ b/docs/EVALUATION.md @@ -0,0 +1,45 @@ +# ScopeMoat evaluation: answer keys and agent experiments + +Moved from the README unchanged (v1.0.5) so the README stays short. Every result is reproduced by `python verify.py`; the evidence index is [EVIDENCE.md](../EVIDENCE.md). + +## Checked against published answer keys + +ScopeMoat's unchanged rules, scored against published answer keys: PCI SSC 2017 and 2024, AWS and Google, two simpler baselines (B1, B2) on the same AWS and Google labels, and W3 (Google's PCI on GKE blueprint). In W3, Google labels the 3 in-scope services; the 7 out-of-scope labels are the author's inference from cluster placement. Every graph in these rows was built by the author from the published text ([provider_reference/GAPS.md](../provider_reference/GAPS.md): "built from the published sources listed in SOURCES.md"). For the AWS and Google rows, the labels were committed (563e140) before the graphs (3960950, tag `provider-ref-frozen-2026-12-04`) and before any engine run, the graphs had a cold review against the cited sources ([REVIEW.md](../provider_reference/REVIEW.md)), and the run was scored once ([SCORING.md](../provider_reference/SCORING.md) step 7: "No run is repeated to get a different number"). + +In short, every number below is from the table: +- Against the published answer keys (PCI SSC 2017 and 2024, AWS and Google, Google's GKE blueprint), ScopeMoat never puts a system out of scope that the publisher puts in scope: 0 looser in every one of those rows. +- Where a source states no control on a connection, ScopeMoat holds the system in scope instead of guessing: 7 of the 25 AWS and Google labels are UNRESOLVED. +- Simpler rules can match more labels but miss in-scope systems: B1 (in scope only where card numbers are stored, processed, sent or received) matches 18 and is looser on 7; B2 (any link to a card-data system puts a system in scope) matches 20 and is looser on 1; ScopeMoat matches 15 and is looser on 0. + +How to read the result column (classes as defined in [provider_reference/RULE_TO_SSC.md](../provider_reference/RULE_TO_SSC.md)): +- **CDE:** the system stores, processes or transmits account data, is on the same network segment as a system handling account data, or has unrestricted connectivity to one (rules R1, R1S and R2). +- **OTHER:** "every other rule gives OTHER": in scope but not CDE, for example connected-to, providing security services to the CDE, or a usable access path to the CDE through another system. +- **OUT:** "in scope in neither case: no rule fires even with missing evidence treated as open". +- **Stricter:** ScopeMoat puts a system in scope that the publisher left out. That costs audit effort. +- **Looser:** ScopeMoat puts a system out of scope where the publisher says it is in scope. This is the dangerous error: a system that needs PCI controls is left out of the assessment. +- **UNRESOLVED:** the source states no control on a connection. ScopeMoat withholds OUT and treats the system as in scope until evidence arrives. + Of the 7 UNRESOLVED results, the publishers label 4 in scope (A1-04, A2-02, A3-01, G2-01) and 3 out of scope (A2-03, A3-05, G2-02) ([RESULTS.md](../provider_reference/RESULTS.md) per-label table, lines 62, 73-76, 83-84). Treating missing evidence as closed instead of open would make those 4 looser; that is why ScopeMoat fails closed. + +| Answer key (full title, year) | Compared | Result | File | +|---|---|---|---| +| PCI SSC, Guidance for PCI DSS Scoping and Network Segmentation v1.1 (May 2017) | Examples 1 and 2: 5 systems, 2 variants, 10 labels | 8 of 10 matched, 2 stricter, 0 looser | [experiments/ssc_examples/README.md](../experiments/ssc_examples/README.md) | +| PCI SSC, PCI DSS Scoping and Segmentation Guidance for Modern Network Architectures (Sept 2024) | 6 examples, 15 scored labels | 15 of 15 matched; the Python rules and the Relate provider agree | [experiments/ssc_2024/README.md](../experiments/ssc_2024/README.md) | +| AWS and Google Cloud published PCI reference architectures | 26 publisher labels; 25 modelable | ScopeMoat: 15 match, 3 stricter, 0 looser, 7 UNRESOLVED of 25 | [provider_reference/RESULTS.md](../provider_reference/RESULTS.md) | +| Same 25 labels, baseline B1: PAN-presence oracle (a system is in scope (CDE) only if it stores or processes card numbers or is an end of a PAN or SAD flow; everything else is OUT) | 25 labels | 18 match, 0 stricter, 7 looser, 0 UNRESOLVED of 25 | [provider_reference/baselines/RESULTS.md](../provider_reference/baselines/RESULTS.md) | +| Same 25 labels, baseline B2: permissive one-hop (any link to a card-data system puts a system in scope) | 25 labels | 20 match, 4 stricter, 1 looser, 0 UNRESOLVED of 25 | [provider_reference/baselines/RESULTS.md](../provider_reference/baselines/RESULTS.md) | +| Google, PCI on GKE blueprint, developed for PCI DSS 3.2.1 (W3) | 3 services Google labels in scope, 7 out of scope by cluster placement; 2 variants | every label matches in both variants; the Python rules and the Relate provider agree | [experiments/w3_gke/LABELS.md](../experiments/w3_gke/LABELS.md) | + +B1 and B2 match more labels (18 and 20), yet they are worse: B1 is looser on 7 labels and B2 on 1, while ScopeMoat is looser on 0. B1 is the best case for any rule that looks only at where card numbers are, and it calls every connected-to and security-impacting system out of scope. + +## Checked against the author's own keys + +The same rules against keys the author wrote: the 40 frozen cases; T4, the author's benchmark of 12 frozen agent tasks; the twin, one change judged on two baselines that differ in one recorded fact; and T5, the pre-registered agent A/B, the same agent on the same facts with and without a Relate query tool. In short, on T4 the gate did not improve outcomes: 0 of 36 unsafe ships in both arms, and 12 of 36 safe deliveries with the gate output against 15 of 36 without. On T5 the Relate tool did not improve outcomes: 8 of 11 twin pairs fully right with it against 11 of 11 without, and 0 of 23 false PASS against 2 of 23. + +| Answer key (full title, year) | Compared | Result | File | +|---|---|---|---| +| The author's answer key for 40 frozen cases, written before scoring | 40 changes | ScopeMoat: 36 exact, 0 false PASS. One-hop check: 24 exact, 15 false PASS. Plain reachability: 20 exact, 16 false PASS. Neither simpler check can return REVIEW REQUIRED, and 14 of the 40 expected verdicts are REVIEW. On the 26 expected BLOCK or PASS cases, one-hop is exact on 24 and ScopeMoat on 23 | [blind/baselines/SPLITS.txt](../blind/baselines/SPLITS.txt) (lines 1-3), [AUDIT.md](../blind/baselines/AUDIT.md) (line 7) | +| The author's 12 frozen agent tasks (T4), claude-sonnet-5-5, 3 repeats, 36 runs per arm, blind-scored | the same agent without and with ScopeMoat's gate output | Unsafe ships (the benchmark's scored decision category): 0 of 36 without the gate output, 0 of 36 with it. Safe deliveries: 15 of 36 without, 12 of 36 with. Under the frozen win rule the gate arm did not win (3 fewer safe deliveries, all on T4-07, where the gate returned REVIEW REQUIRED on a design the frozen answer key rates PASS) | [t4/runs/live1/README.md](../t4/runs/live1/README.md) (lines 3, 9-16) | +| Twin pair P01 (from the T5 design; rule-derived label) | the demo change on two baselines that differ in one recorded fact | BLOCK becomes REVIEW REQUIRED; Relate's rows go from 8 to 0 | [experiments/twin_replay.py](../experiments/twin_replay.py) | +| The author's pre-registered agent A/B (T5), claude-sonnet-5-5, one repeat, 23 singles and 11 twin pairs | the same agent with the facts as text (arm A) or the same text plus a read-only Relate Cypher tool (arm B) | Registered: "H1: B gets more twin pairs fully right than A. H2: B has no more false PASS than A." and "H1 counts as supported only if B leads on pairs and p < 0.10". Twin pairs fully right: 11 of 11 without the Relate tool (arm A), 8 of 11 with it (arm B); 3 of arm B's answers were malformed JSON, which the registered scorer counts as failures. False PASS on singles: 2 of 23 (A), 0 of 23 (B). Exact verdicts on singles: 20 of 23 (A), 21 of 23 (B). No demonstrated difference on H1, as registered ("anything else is reported as no demonstrated difference, with the counts") (A alone right on 3 pairs, B alone on 0; p = 0.25); H2 holds. B made 12 Relate queries; in no state where the arms' verdicts differed did a query return a fact the answer used (one timed out), so no result is credited to the graph. The registered audit (S1, S2) found 140 of 140 checkable cited facts in A's answers and 146 of 147 in B's in the graph, and ScopeMoat enforcing its configured policy matched the key on 34 of 35 states with 0 false PASS. The run resumed after the daily spend cap; three files off the prompt and scoring path changed in between (listed in the commit). T5 tested giving the agent raw Cypher access; ScopeMoat's gate does not depend on it (the agent receives the gate's verdict, not the graph). | [t5/runs/fri4/report.json](../t5/runs/fri4/report.json), [audit.json](../t5/runs/fri4/audit.json), [t5/README.md](../t5/README.md) | + +The 40-case key was written by the author, 17 of those cases were used to develop the rules ([blind/baselines/SPLITS.txt](../blind/baselines/SPLITS.txt): 23 untuned, suite 1 of 17), and the twin label is derived from the rules.