Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion EVIDENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Every result ScopeMoat publishes, where its record lives, and the command that r
| 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` (152 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` |
| Compose parsing matches Docker Compose | main | `experiments/compose_differential.py`: 3,000 generated files (anchors, merge keys, overrides, YAML 1.1 words, quoted names, `!reset`/`!override`) read by the gate and by `docker compose config` (v5.7.1): 0 read differently; the gate refuses only files Compose also rejects, plus the two merge tags (REVIEW). A planted bug is caught (127 of 200 files flagged) | `python -m experiments.compose_differential 1000 1` (needs Docker) |
| Compose parsing matches Docker Compose | main | `experiments/compose_differential.py` against `docker compose config` (Docker Compose 5.7.1), 3,000 generated files (anchors, merge keys, keys written over merged ones, YAML 1.1 words, quoted names, `!reset`/`!override`). Seeds 1, 2, 3 (1,000 each): agree 675 / 685 / 670 (same service-to-network memberships); refused by the gate and rejected by Compose 268 / 248 / 262; held for review for `!reset`/`!override`, which Compose accepts, 57 / 67 / 68; refused for any other reason while Compose accepts 0; read by the gate while Compose rejects 0; memberships differ 0. Each run prints PASS only when the last three are 0; planted bugs (a membership error, a stricter parser) each make it FAIL. Settings outside the supported subset (`ports`, `volumes`, ...) are not generated; acceptance.py covers them (REVIEW REQUIRED) | `python -m experiments.compose_differential 1000 1` (then seeds 2 and 3; needs Docker) |

## How to read these

Expand Down
59 changes: 39 additions & 20 deletions experiments/compose_differential.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
"""Differential test: does the gate read a Compose file the way Docker Compose does?

Generates random Compose files (anchors, merge keys, overrides, nested and list merges, YAML 1.1 words,
duplicate keys, Compose's !reset / !override tags), runs each through `docker compose config` and through
scopemoat.compose.memberships, and sorts the result:
agree both read the file and give the same network memberships
closed the gate refuses the file (ComposeError -> ERROR, Unsupported -> REVIEW): never a PASS
danger the gate reads the file but its memberships differ from Compose's (possible false PASS)
stricter Compose rejects the file and the gate refuses it too (counted in closed)
looser Compose rejects the file but the gate reads it (not a false PASS: Compose would not run it)
Generates random Compose files (anchors, merge keys, keys written over merged ones, nested and list merges,
YAML 1.1 words, quoted names, duplicate keys, Compose's !reset / !override tags), runs each through
`docker compose config` and through scopemoat.compose.memberships, and sorts every file into one bucket:
agree both read the file and give the same service-to-network memberships
refused, both the gate refuses it (ERROR or REVIEW) and Compose rejects it too
refused, tag the gate holds it for review because it uses !reset or !override; Compose accepts it
refused, other the gate refuses a file Compose accepts, for any other reason (stricter than Compose)
looser the gate reads a file Compose rejects
danger both read the file and the memberships differ (a possible false PASS)
PASS means: no danger, no looser and no "refused, other" file, so on this corpus the gate reads exactly what
Compose reads and refuses only what Compose rejects, plus the two tags. Settings outside the gate's supported
subset (ports, volumes, ...) are not generated; acceptance.py covers those (REVIEW REQUIRED).
Usage: python -m experiments.compose_differential [N] [SEED] (needs the docker CLI with compose v2+)
"""
import json
Expand Down Expand Up @@ -104,28 +108,43 @@ def gate_view(text):
return None, f"ERROR: {str(e).splitlines()[0]}"


ORDER = ("agree", "refused, both", "refused, tag", "refused, other", "looser", "danger")


def classify(dv, gv, gerr):
if gv is None:
if dv is None:
return "refused, both"
return "refused, tag" if gerr.startswith("REVIEW: the Compose YAML tag !") else "refused, other"
if dv is None:
return "looser"
return "agree" if dv == gv else "danger"


def main():
n = int(sys.argv[1]) if len(sys.argv) > 1 else 1000
rng = random.Random(int(sys.argv[2]) if len(sys.argv) > 2 else 20261205)
seed = int(sys.argv[2]) if len(sys.argv) > 2 else 20261205
rng = random.Random(seed)
work = tempfile.mkdtemp(prefix="compose-diff-")
counts, examples = {}, {}
ver = subprocess.run(["docker", "compose", "version", "--short"], capture_output=True, text=True).stdout.strip()
counts, examples = {k: 0 for k in ORDER}, {}
for _ in range(n):
text = gen(rng)
dv, derr = docker_view(text, work)
gv, gerr = gate_view(text)
if gv is None:
kind = "closed"
elif dv is None:
kind = "looser"
else:
kind = "agree" if dv == gv else "danger"
counts[kind] = counts.get(kind, 0) + 1
kind = classify(dv, gv, gerr)
counts[kind] += 1
examples.setdefault(kind, []).append((text, dv, derr, gv, gerr))
print(f"compose differential: {n} files: " + ", ".join(f"{k} {v}" for k, v in sorted(counts.items())))
for kind in ("danger", "looser"):
bad = counts["danger"] + counts["looser"] + counts["refused, other"]
print(f"compose differential: {n} files, seed {seed}, Docker Compose {ver or 'unknown'}: "
+ ", ".join(f"{k} {counts[k]}" for k in ORDER))
for kind in ("danger", "looser", "refused, other"):
for text, dv, derr, gv, gerr in examples.get(kind, [])[:3]:
print(f"--- {kind}\n{text}docker: {dv or derr}\ngate: {gv or gerr}")
return 1 if counts.get("danger") else 0
print("PASS: the gate read every file Compose read, with the same memberships, and refused only files Compose "
"rejects or that use !reset / !override" if not bad else f"FAIL: {bad} file(s) in danger, looser or "
"refused, other")
return 1 if bad else 0


if __name__ == "__main__":
Expand Down
Loading