Skip to content

feat(governance): minimal gates + evidence + TaskCertificate slice (#1393)#1544

Closed
ohdearquant wants to merge 2 commits into
mainfrom
feat/governance-minimal-slice
Closed

feat(governance): minimal gates + evidence + TaskCertificate slice (#1393)#1544
ohdearquant wants to merge 2 commits into
mainfrom
feat/governance-minimal-slice

Conversation

@ohdearquant

@ohdearquant ohdearquant commented Jun 19, 2026

Copy link
Copy Markdown
Owner

Closes #1393.

Implements the minimal governance slice: option 1 (gates + evidence + TaskCertificate, with restricted break-glass).

  • New lionagi/governance/ module: gates.py, evidence.py, certificate.py, context.py, errors.py
  • Tier folded into the evidence hash; certificate gated on chain validity; scope-leak closed
  • Full test suite under tests/governance/ (48 tests, green on current main)

Rebased clean onto main. Harvested from a stale fanout branch during disk/branch cleanup.

🤖 Generated with Claude Code

ohdearquant and others added 2 commits June 19, 2026 18:19
…1393)

Implements the minimal governance slice as directed (Ocean 2026-06-18):

- GatePolicy / GateExecutor / GateVerdict / GateResult / Enforcement
  Declarative policy rules bound to tool names. HARD enforcement short-
  circuits with DENY; SOFT/ADVISORY policies accumulate and collapse to
  a single ADVISORY verdict. gate_fn is a plain callable so policies
  need no DSL dependency.

- EvidenceChain / EvidenceNode / ChainVerifier / ChainVerification
  Blockchain-style append-only log with SHA-256 hash linkage. Thread-
  safe via threading.Lock. ChainVerifier detects tamper, reorder, and
  delete violations. Uses stdlib list instead of Pile (no append_only
  on current Pile).

- TaskCertificate / CertificateGrade
  Immutable Element minted at task completion. Grade computed from op
  counts: FULL (zero denials), PARTIAL (advisory only), FAILED (hard
  denial). mint() factory encapsulates grading logic.

- GoverningContext
  Per-run handle binding the three above: check(tool_name) evaluates
  policies, writes to the evidence chain, emits GateDenied signal to
  a branch if one is provided (duck-typed ctx.emit), raises
  GovernanceViolationError on DENY unless raise_on_deny=False.
  complete() mints the TaskCertificate.

Out of scope: charter DSL, SoD, JIT grants, break-glass, all
pile/branch/session rewiring. GateDenied from session/signal.py is
the only integration point.

43 tests, all passing. ruff clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…idity, drop scope leak

- evidence: compute_node_hash now includes the node tier, so an
  IMMUTABLE->MUTABLE downgrade is caught as a tamper by ChainVerifier
  (previously tier was outside the digest and silently mutable).
- certificate: mint() refuses FULL/PARTIAL when chain_verified is False;
  GoverningContext.complete() verifies the chain before minting.
- __init__: remove the public docstring line enumerating out-of-scope
  features; describe only what the module does.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ohdearquant ohdearquant marked this pull request as draft June 22, 2026 17:47
@oceanwaves630

Copy link
Copy Markdown
Collaborator

Closing while unreviewed and stale; #1393 remains the tracking issue and the branch is preserved. The governance slice will be re-cut through the current review gate when the lane is prioritized.

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.

decision: governance — minimal ~800-LOC slice (gates + evidence + TaskCertificate) or drop

2 participants