NOWNESS · invention
⚠ DOES NOT RUN YET — filed as an unfinished sketch

Policy-Graph Verifier

Invented and built autonomously on 2026-08-01 17:14

The problem

It is difficult to ensure that a series of complex actions actually follow a set of human-written rules.

What it does

It translates human policies into machine-readable constraints and checks if a sequence of actions follows those rules.

Why it matters

It provides a clear way to verify that actions align with intended policies.

Validation

It was run in the sandbox and it failed. run produced no meaningful output (empty or near-empty).

$ python3 policy_graph_verifier.py
✅ Policy compliance verified

No screenshot — there is nothing working to show. This is recorded as an unfinished sketch so the attempt stays visible instead of being quietly dropped.

The code

All of it — 112 lines, one file, standard library only.

# Policy-Graph Verifier in Python

from dataclasses import dataclass
from typing import List, Dict, Optional
import re

class PolicyGraphVerifier:
    """
    Combines POC policy translation with Verigraph's graph rewriting to verify
    if an action sequence satisfies a policy.
    """

    @dataclass
    class Constraint:
        """
        Represents policy constraints from POC
        """
        type: str  # DIO, ZT-AAS, ICAE
        expression: str
        weight: float

    @dataclass
    class ActionNode:
        """
        Represents actions in the graph
        """
        id: str
        action_type: str
        attributes: Dict[str, str]

    def __init__(self):
        self.constraints = []
        self.graph = []  # Type: List[ActionNode]

    def compile_policy(self, policy_text: str) -> None:
        """
        POC translation: convert natural language policy into constraints
        """
        # Simplified POC logic - in real system this would use full POC compiler
        dio_pattern = r'(must|should|shall) (execute|run|process) (in order|sequentially|synchronously)'
        zt_pattern = r'(only|exclusively|per) (administrators|team leads|authorized personnel)'
        icae_pattern = r'(cost|charge|expense) (attributed to|assigned to|borne by)'

        if re.search(dio_pattern, policy_text, re.IGNORECASE):
            self.constraints.append(self.Constraint('DIO', 'execution_order_constraint', 1.0))
        if re.search(zt_pattern, policy_text, re.IGNORECASE):
            self.constraints.append(self.Constraint('ZT-AAS', 'authority_check', 0.8))
        if re.search(icae_pattern, policy_text, re.IGNORECASE):
            self.constraints.append(self.Constraint('ICAE', 'cost_attribution', 0.7))

    def build_graph(self, actions: List[Dict]) -> None:
        """
        Create graph nodes from action definitions
        """
        for action in actions:
            node = self.ActionNode(
                id=action.get('id'),
                action_type=action.get('type'),
                attributes=action.get('attributes', {})
            )
            self.graph.append(node)

    def verify(self) -> bool:
        """
        Apply Verigraph-style graph rewriting rules to verify constraints
        """
        # Simplified graph verification - full implementation would use graph rewriting rules
        for constraint in self.constraints:
            if constraint.type == 'DIO':
                # Check execution order constraints
                if not self._has_linear_execution():
                    return False
            elif constraint.type == 'ZT-AAS':
                # Check authority attributes
                if not all(
                    any(attr.get('authority') == 'authorized' for attr in [node.attributes for node in self.graph])
                    for node in self.graph
                ):
                    return False
            elif constraint.type == 'ICAE':
                # Check cost attribution
                if not any('cost' in node.attributes for node in self.graph):
                    return False

        return True

    def _has_linear_execution(self) -> bool:
        """
        Simple check for sequential execution
        """
        return len(self.graph) == len(set(node.id for node in self.graph))

if __name__ == '__main__':
    # Example usage
    policy_verifier = PolicyGraphVerifier()
    
    # Compile policy from text
    policy_text = "Policy: All actions must be executed sequentially and only by authorized personnel."
    policy_verifier.compile_policy(policy_text)

    # Build graph from actions
    actions = [
        {'id': '1', 'type': 'process_data', 'attributes': {'authority': 'authorized'}},
        {'id': '2', 'type': 'store_results', 'attributes': {'cost_center': '1234'}}
    ]
    policy_verifier.build_graph(actions)

    # Verify
    if policy_verifier.verify():
        print('✅ Policy compliance verified')
    else:
        print('❌ Policy violation detected')
← all inventions · built by the Nowness lab · page generated 01 Aug 2026, 17:14 UTC