Skip to content

Category-Theory Session Summary

NON-NORMATIVE. This document summarizes the canonical category-theory and validation material already present in the repo. Normative requirements remain in morphism-kernel.md.

Sources

This summary is derived from:

What Is Normative vs Non-Normative

  • Normative: morphism-kernel.md defines the seven invariants and Read-Verify-Execute protocol.
  • Derived operational reference: MORPHISM.md maps the kernel into ten operational tenets and implementation surfaces.
  • Formal targets: MORPHISM_FORMAL.md states the definitions and theorems the project is designed around.
  • Semi-formal proof text: proofs/theorem-proofs.md provides structured proofs, but not machine-checked formalization.
  • Executable enforcement: scripts, tests, metrics, drift detection, proof witnesses, and dashboard routes implement the runtime validation layer.

Seven Invariants, Ten Tenets, Nine Theorem Surfaces

Seven Invariants

ID Invariant Practical meaning
I-1 One Truth Per Domain Every governance fact has one canonical source
I-2 Drift Is Debt Divergence blocks merge and must be remediated
I-3 Observability Governance-changing transitions need auditable traces
I-4 Scope Binding Changes are valid only inside declared scope
I-5 Entropy Monotonicity Disorder must not increase without authorization
I-6 Refusal as Structure Invalid transitions fail explicitly and cheaply
I-7 Minimal Authority Permissions stay at the smallest admissible unit

Ten Operational Tenets

Tenet Runtime surface
T1 SSOT Integrity scripts/ssot_verify.py, scripts/docs_sync.py --check
T2 Commit Grammar scripts/validate_commit.py, .githooks/commit-msg
T3 Branch Naming scripts/validate_branch.py, .githooks/pre-push
T4 CI Gate Passage CI workflows plus scripts/policy_check.py --mode ci
T5 Secret Zero scripts/scan-credentials.sh, security workflow
T6 Docs Coverage scripts/docs_graph.py --check, orphan scan
T7 Registry Consistency docs/ssot/registry.json, scripts/ssot_verify.py
T8 Dependency Freshness scripts/dependency_health.py, dependency workflows
T9 Incident Readiness scripts/runbook_coverage.py, docs/runbooks/
T10 Maturity Tracking scripts/maturity_score.py, metrics regression tooling

Nine Theorem Surfaces

Theorem Executable witness
1. Canonical source uniqueness SSOT registry/hash checks
2. Drift blocks admissible merge drift/refusal gates
3. Observability commit grammar, logs, proof witnesses
4. Scope binding explicit scope checks, rule conflict detection
5. Entropy monotonicity maturity score, kappa trajectories
6. Refusal totality and structure structured non-zero exits and error payloads
7. Minimal authority CODEOWNERS, pipeline coverage, RLS policies
8. Convergence kappa, delta, convergence certificates
9. Monad laws for G trace composition model exercised in tests

Core Category-Theory Concepts in Morphism

Category of context

States are objects. Admissible transitions are morphisms.

s0 --f--> s1 --g--> s2

identity: id_s : s -> s
composition: (g o f) : s0 -> s2

In Morphism, state is approximated by repo artifacts, registry state, governance vectors, and proof/log evidence.

Morphisms

Morphisms preserve structure across state transitions.

A --f--> B --g--> C

valid iff:
  source(f) = A
  target(f) = B
  source(g) = B
  target(g) = C

then:
  g o f : A -> C

In code, this is modeled in src/morphism/engine/morphisms.py.

Functors

A functor maps objects and morphisms from one category to another while preserving identity and composition.

Source category              Target category

   A ----f----> B              F(A) --F(f)--> F(B)
   |           |        =>       |             |
  id_A       id_B             id_F(A)      id_F(B)

In Morphism:

  • Functor.map_object() maps governance objects or abstract objects.
  • Functor.map_morphism() maps transitions.
  • verify_laws() checks identity and composition preservation.

Natural transformations

Natural transformations compare two functors that act on the same source category.

        alpha_X
F(X) -----------> G(X)
 |                 |
 | F(f)            | G(f)
 |                 |
 v     alpha_Y     v
F(Y) -----------> G(Y)

Naturality condition:
  G(f) o alpha_X = alpha_Y o F(f)

In Morphism, this is the model for policy coherence across contexts. The runtime naturality surface lives in src/morphism/engine/natural_transformations.py and related governance tooling.

Sheaves and drift

Local sections must agree on overlaps if a global state is to exist.

local section on U_i      local section on U_j
        |                         |
        v                         v
   restriction to overlap U_i cap U_j

if restricted values disagree:
  local agreement fails
  global gluing fails
  drift exists

In Morphism:

  • src/morphism/sheaf/cech_complex.py computes compatibility and H^1-style drift signals.
  • src/morphism/healing/cech_complex.py models agent-jurisdiction overlaps and healing patches.

Governance monad and traces

The governance monad packages valid execution traces.

eta(s)      = trivial trace at s
tau bind f  = append admissible transition f to trace tau

invalid transition:
  no admissible trace
  no composition

This is why refusal is structural, not cosmetic: invalid operations are not merely discouraged, they are excluded from the admissible trace space.

Kappa, delta, fixed points

kappa measures distance from the ideal compliant state. delta measures change in kappa.

current state s ----distance----> ideal state F(s)

kappa = d(s, F(s))
delta = kappa_now - kappa_prev

kappa = 0  => fixed point
delta < 0  => improving
delta > 0  => regressing

kappa < 1 is a design target and runtime metric, not a machine-checked theorem in this repo today.

Agent States and Mappings

File to agent to governance state

AgentClassifier supports two mapping modes:

  • path-based ownership
  • jurisdiction-based ownership by governance dimension
file path
  |
  v
AgentClassifier
  |
  +--> path match
  |
  +--> jurisdiction match
         |
         v
  governance dimension
         |
         v
  GovernanceState component

The current seven governance state dimensions are:

  • policy
  • git_hook
  • ci_workflow
  • ssot_atom
  • document
  • security_gate
  • runbook

End-to-end mapping flow

file change
  |
  v
dimension / jurisdiction ownership
  |
  v
governance evidence
  |
  v
GovernanceState vector
  |
  +--> kappa / delta / convergence certificate
  |
  +--> functor laws / naturality checks
  |
  +--> sheaf compatibility / drift analysis
  |
  v
ProofWitness JSON
  |
  v
dashboard + API surface

The TypeScript governance loop in packages/mcp-server/src/governance-loop.ts is the clearest deployed version of this pipeline.

Drift Taxonomy: Basic vs Complex

Basic scanner-level drift

These are explicit runtime drift types in the repo today:

  • missing_frontmatter
  • stale_date
  • broken_link
  • missing_invariant_ref
  • encoding_mismatch

These are produced by src/morphism/healing/scanner.py and remediated by src/morphism/healing/drift_healer.py.

Complex sheaf/governance drift

These cases go beyond single-file hygiene:

  • subtle-below-threshold drift
  • gradual degradation over time
  • three-way drift
  • no-shared-dimension non-drift
  • empty-section non-drift
  • overlapping-jurisdiction disagreement
  • proof/API mismatch
  • migration/schema drift

These require either:

  • multi-object compatibility analysis
  • threshold-sensitive drift evaluation
  • proof and dashboard contract validation
  • schema/migration consistency checks

Executable Validation Surfaces

Governance and script layer

  • scripts/policy_check.py
  • scripts/ssot_verify.py
  • scripts/validate_branch.py
  • scripts/validate_commit.py
  • scripts/docs_graph.py
  • scripts/dependency_health.py
  • scripts/runbook_coverage.py
  • scripts/maturity_score.py
  • scripts/drift_detector.py

Python category-theory layer

  • src/morphism/engine/
  • src/morphism/sheaf/
  • src/morphism/healing/cech_complex.py
  • src/morphism/metrics/governance_metric.py
  • src/morphism/bridge/python_bridge.py

TypeScript and deployed proof surfaces

  • packages/agentic-math/
  • packages/mcp-server/src/governance-loop.ts
  • apps/morphism/src/app/api/governance/route.ts
  • apps/morphism/src/app/api/governance/proofs/route.ts
  • apps/morphism/src/app/(dashboard)/dashboard/governance/proofs/page.tsx

Benchmark and test layer

  • tests/test_accuracy.py
  • tests/test_kernel_invariants.py
  • tests/test_python_bridge.py
  • tests/test_governance_metric.py
  • tests/e2e/test_golden_paths.py
  • benchmarks/benchmarks.py
  • benchmarks/entropy_reduction.py
  • benchmarks/comparative.py

Drift Detect, Heal, Re-Verify Loop

repo state
  |
  v
scan
  |
  +--> no drift ---------> accept
  |
  +--> drift found
         |
         v
       classify
         |
         v
       heal
         |
         v
       re-scan
         |
         +--> clean ------> accept + log
         |
         +--> still dirty -> refuse + evidence

This loop appears both in the healing system and in the golden-path e2e tests.

Known Design Targets vs Proved / Runtime-Enforced Claims

Runtime-enforced today

  • SSOT hash enforcement
  • branch and commit grammar checks
  • structured refusal through non-zero exits and error payloads
  • drift scanning and healing
  • maturity scoring
  • kappa and delta computation
  • convergence certificate issuance
  • proof witness generation and dashboard exposure

Semi-formal but not machine-checked

Design targets, not formalized proofs in this repo

  • full machine-checked convergence proof
  • Lean/Agda/Coq-style theorem verification
  • formal certification export

The central precision point is:

Executable metric:        yes
Semi-formal proof text:   yes
Machine-checked proof:    no

That distinction must remain explicit in docs, UI copy, and validation narratives.