Skip to content

feat(mgtp): DECISION_ARTEFACT_V0_1 – deterministic, time-bounded, evidenced decision record#7

Draft
Copilot wants to merge 3 commits intofeat/mgtp-scaffold-v0.1from
copilot/build-decision-record-artefact
Draft

feat(mgtp): DECISION_ARTEFACT_V0_1 – deterministic, time-bounded, evidenced decision record#7
Copilot wants to merge 3 commits intofeat/mgtp-scaffold-v0.1from
copilot/build-decision-record-artefact

Conversation

Copy link

Copilot AI commented Feb 28, 2026

Introduces a canonical, replayable DecisionRecord artefact for MGTP with fail-closed time-window and evidence enforcement.

mgtp/types.py

  • Added Verdict(str, Enum)ALLOW | REFUSE | SUPERVISED
  • Added EvidenceRef frozen dataclass — ref_id + description

mgtp/decision_record.py (new)

  • DecisionRecord frozen dataclass — fields: record_id, decision_time, authority window [start, end], verdict, reason_codes (sorted tuple), provided_evidence (sorted tuple or None)
  • canonical_bytes() — deterministic UTF-8 JSON: sort_keys=True, compact separators, reason codes and evidence refs pre-sorted; explicit field set via _CANONICAL_FIELDS tuple
  • decision_hash property — sha256(canonical_bytes()) lowercase hex
  • evaluate() — constructs a DecisionRecord after applying two fail-closed rules in order:
    1. decision_time ∉ [window_start, window_end] → force REFUSE + append outside_authority_window
    2. verdict == ALLOW and provided_evidence is None → force REFUSE + append evidence_missing
rec = evaluate(
    record_id="rec-001",
    decision_time="2026-02-28T12:00:00Z",
    authority_window_start="2026-02-28T00:00:00Z",
    authority_window_end="2026-02-28T23:59:59Z",
    requested_verdict="ALLOW",
    reason_codes=["allowlist_match"],
    provided_evidence=[EvidenceRef(ref_id="ev-001", description="owner confirmed")],
)
# rec.decision_hash == sha256(rec.canonical_bytes())  — stable across processes

tests/fixtures/golden_decision.json (new)

Frozen base64 canonical bytes + sha256 hash for cross-process replay regression.

tests/test_decision_record_determinism.py (new)

12 tests covering:

  • Determinismcanonical_bytes() and decision_hash identical across N=50 calls
  • Golden replay — exact byte/hash match against stored fixture
  • Time-bound — before/after window → REFUSE; inside window → unchanged
  • EvidenceALLOW without evidence → REFUSE + reason code; REFUSE/SUPERVISED without evidence → unchanged
  • Surface-area guard — SHA-256 file-hash assertions on authority_gate.py, stop_machine.py, and all commit_gate/** Python files to detect accidental no-touch violations

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits February 28, 2026 13:43
Co-authored-by: LalaSkye <228581229+LalaSkye@users.noreply.github.com>
…me-bound + evidence enforcement

Co-authored-by: LalaSkye <228581229+LalaSkye@users.noreply.github.com>
Copilot AI changed the title [WIP] Build decision record artefact with required features feat(mgtp): DECISION_ARTEFACT_V0_1 – deterministic, time-bounded, evidenced decision record Feb 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants