feat: MGTP minimal deterministic decision artefact demo#9
feat: MGTP minimal deterministic decision artefact demo#9Copilot wants to merge 3 commits intofeat/mgtp-scaffold-v0.1from
Conversation
Co-authored-by: LalaSkye <228581229+LalaSkye@users.noreply.github.com>
…ble) Co-authored-by: LalaSkye <228581229+LalaSkye@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds a deterministic “decision artefact” demo + golden-fixture replay tests to prove canonicalisation stability and decision hash replay for the MGTP/commit_gate commit authority evaluation, and wires the demo into CI.
Changes:
- Add a fixed-input demo script that prints the evaluated verdict + canonical artefact bytes (base64).
- Add golden canonical bytes + replay tests asserting byte-identical canonicalisation and stable decision_hash.
- Document the demo/replay steps in README and run the demo in CI.
Reviewed changes
Copilot reviewed 5 out of 34 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_replay_decision.py | Adds two replay tests (byte-identical canonical bytes + decision_hash match). |
| tests/fixtures/golden_canonical_bytes.b64 | Stores the locked “golden” canonical bytes fixture (base64). |
| examples/minimal_decision_demo.py | Deterministic demo that evaluates a fixed request/ruleset and prints canonical bytes (base64). |
| README.md | Documents deterministic artefact demo inputs, expected outputs, and replay commands. |
| .github/workflows/ci.yml | Runs the demo script as an additional CI step across the Python matrix. |
| .gitignore | Adds ignores for Python bytecode/caches and build artefacts. |
| tests/pycache/test_smoke_mgtp.cpython-312-pytest-9.0.2.pyc | Compiled artefact accidentally committed (should be removed from git). |
| pycache/stop_machine.cpython-312.pyc | Compiled artefact accidentally committed (should be removed from git). |
| pycache/authority_gate.cpython-312.pyc | Compiled artefact accidentally committed (should be removed from git). |
| pycache/invariant_litmus.cpython-312.pyc | Compiled artefact accidentally committed (should be removed from git). |
| pycache/test_stop_machine.cpython-312-pytest-9.0.2.pyc | Compiled artefact accidentally committed (should be removed from git). |
| pycache/test_authority_gate.cpython-312-pytest-9.0.2.pyc | Compiled artefact accidentally committed (should be removed from git). |
| commit_gate/src/commit_gate/pycache/engine.cpython-312.pyc | Compiled artefact accidentally committed (should be removed from git). |
| commit_gate/src/commit_gate/pycache/drift.cpython-312.pyc | Compiled artefact accidentally committed (should be removed from git). |
| commit_gate/src/commit_gate/pycache/canonicalise.cpython-312.pyc | Compiled artefact accidentally committed (should be removed from git). |
| commit_gate/src/commit_gate/pycache/init.cpython-312.pyc | Compiled artefact accidentally committed (should be removed from git). |
| commit_gate/tests/pycache/test_determinism.cpython-312-pytest-9.0.2.pyc | Compiled artefact accidentally committed (should be removed from git). |
| commit_gate/tests/pycache/test_drift.cpython-312-pytest-9.0.2.pyc | Compiled artefact accidentally committed (should be removed from git). |
| prometheus/tests/pycache/conftest.cpython-312-pytest-9.0.2.pyc | Compiled artefact accidentally committed (should be removed from git). |
| prometheus/tests/pycache/init.cpython-312.pyc | Compiled artefact accidentally committed (should be removed from git). |
| prometheus/tests/pycache/test_schema_validation.cpython-312-pytest-9.0.2.pyc | Compiled artefact accidentally committed (should be removed from git). |
| prometheus/tests/pycache/test_redline_scanner.cpython-312-pytest-9.0.2.pyc | Compiled artefact accidentally committed (should be removed from git). |
| prometheus/tests/pycache/test_negative_injection.cpython-312-pytest-9.0.2.pyc | Compiled artefact accidentally committed (should be removed from git). |
| prometheus/tests/pycache/test_input_hashing.cpython-312-pytest-9.0.2.pyc | Compiled artefact accidentally committed (should be removed from git). |
| prometheus/tests/pycache/test_fit_report_classification.cpython-312-pytest-9.0.2.pyc | Compiled artefact accidentally committed (should be removed from git). |
| prometheus/tests/pycache/test_aggregation_determinism.cpython-312-pytest-9.0.2.pyc | Compiled artefact accidentally committed (should be removed from git). |
| prometheus/src/prometheus/pycache/schemas.cpython-312.pyc | Compiled artefact accidentally committed (should be removed from git). |
| prometheus/src/prometheus/pycache/redlines.cpython-312.pyc | Compiled artefact accidentally committed (should be removed from git). |
| prometheus/src/prometheus/pycache/io_jsonl.cpython-312.pyc | Compiled artefact accidentally committed (should be removed from git). |
| prometheus/src/prometheus/pycache/hashing.cpython-312.pyc | Compiled artefact accidentally committed (should be removed from git). |
| prometheus/src/prometheus/pycache/fit_report.cpython-312.pyc | Compiled artefact accidentally committed (should be removed from git). |
| prometheus/src/prometheus/pycache/aggregate.cpython-312.pyc | Compiled artefact accidentally committed (should be removed from git). |
| prometheus/src/prometheus/pycache/init.cpython-312.pyc | Compiled artefact accidentally committed (should be removed from git). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| result = evaluate(REQUEST, RULESET) | ||
| canonical_bytes = canonicalise(result) | ||
| canonical_b64 = base64.b64encode(canonical_bytes).decode("ascii") |
There was a problem hiding this comment.
This script runs significant logic at import time (evaluate + printing). Wrapping execution in a main() and guarding with if name == 'main' avoids side effects if the module is imported (e.g., by tooling) and makes it easier to reuse in tests.
| def _load_golden_bytes(): | ||
| b64_text = (FIXTURES_DIR / "golden_canonical_bytes.b64").read_text().strip() | ||
| return base64.b64decode(b64_text) |
There was a problem hiding this comment.
For deterministic behavior across environments, consider specifying an explicit encoding when reading the fixture (it's ASCII/base64) and using base64.b64decode(..., validate=True) so corruption/non-base64 characters fail loudly with a clear error.
Adds a minimal, regulator-readable artefact demonstration proving deterministic canonicalisation, hash stability, and replay correctness for the MGTP commit gate — with no changes to any upstream module.
New files
examples/minimal_decision_demo.py— Fixed-input demo (no randomness, no live timestamps). Evaluates a canonicalCommitRequest, printsverdict,decision_hash, andcanonical_bytes(base64):Reproduce:
python examples/minimal_decision_demo.pytests/fixtures/golden_canonical_bytes.b64— Locked golden canonical bytes for the fixed input set.tests/test_replay_decision.py— Two replay assertions:canonicalise(evaluate(REQUEST, RULESET))is byte-identical to the golden fixture (any byte difference → fail).decision_hashin re-evaluated result matches hash embedded in golden bytes.Modified files
README.md— New Deterministic Decision Artefact Demo section: input table, output artefact snippet,decision_hash, and exact reproduce/replay commands..github/workflows/ci.yml— Added check-mode step runningpython examples/minimal_decision_demo.pyacross the Python 3.10/3.11/3.12 matrix on every push/PR..gitignore— Excludes__pycache__,.pyc,.pytest_cache.🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.