Skip to content
gf3-conservation-oracle <<<<<<< HEAD logo

gf3-conservation-oracle <<<<<<< HEAD

> Formal oracle verifying GF(3) trit conservation across skill triads. Triggers: verify trit conservation, check GF(3) invariant, pre-commit trit check, triad validation, conservation law enforcement, sum mod 3 check. >>>>>>> origin/main

plurigrid/asi0installs67starsDevOps & CI/CD

SKILL.md

Full skill instructions

GF(3) Conservation Oracle

Formal Specification

Type

<<<<<<< HEAD
ConservationOracle : SkillGraph → ConservationResult

ConservationResult =
  | CONSERVED   { certificate: list[ValidTriad] }   -- all triads sum to 0 mod 3
  | VIOLATED    { witness: ViolatingTriad }          -- explicit counterexample
  | UNKNOWN     { reason: string }                  -- trit not defined for some skill

ValidTriad    = (s₁, s₂, s₃, trits) where trit(s₁) + trit(s₂) + trit(s₃) ≡ 0 mod 3
ViolatingTriad = (s₁, s₂, s₃, trits) where trit(s₁) + trit(s₂) + trit(s₃) ≢ 0 mod 3
=======
ConservationOracle : SkillGraph -> ConservationResult

ConservationResult =
  | CONSERVED   { certificate: list[ValidTriad] }
  | VIOLATED    { witness: ViolatingTriad }
  | UNKNOWN     { reason: string }

ValidTriad     = (s1, s2, s3, trits) where trit(s1) + trit(s2) + trit(s3) = 0 mod 3
ViolatingTriad = (s1, s2, s3, trits) where trit(s1) + trit(s2) + trit(s3) != 0 mod 3
>>>>>>> origin/​main

Preconditions

  1. SkillGraph has at least 3 skills <<<<<<< HEAD
  2. Every skill has a trit ∈ {-1, 0, +1} (from gf3-trit-oracle, NOT guessed)
  3. "Valid triad" means: the three skills are connected (skill graph edge or hub connection)
  4. Background: skills.json registry with trit fields populated =======
  5. Every skill has a trit in {-1, 0, +1}
  6. "Valid triad" means: three skills are connected (edge or hub connection)

origin/​main

Postconditions

  1. Returns EXACTLY ONE of: CONSERVED | VIOLATED | UNKNOWN <<<<<<< HEAD
  2. CONSERVED is witnessed by an explicit list of checked triads (never "all triads ok")
  3. VIOLATED provides the FIRST violating triad found (witness, not just count)
  4. UNKNOWN only if a skill in the checked graph has CellValue.nothing from gf3-trit-oracle
  5. Deterministic: same graph state → same result (no randomness)

GF(3) Arithmetic (exact)

# GF(3) = ℤ/​3ℤ with representatives {-1, 0, +1} ≡ {2, 0, 1} (mod 3)

def gf3_rep(x: int) -> int:
    """Map any integer to canonical GF(3) representative in {-1, 0, +1}."""
    r = x % 3
    return r if r <= 1 else r - 3  # {0,1,2} → {0,1,-1}

def gf3_add(a: int, b: int) -> int:
    """Precondition: a, b ∈ {-1, 0, +1}. Postcondition: result ∈ {-1, 0, +1}."""
    return gf3_rep(a + b)

def gf3_sum(*args: int) -> int:
    """Sum of any number of trits in GF(3)."""
=======
2. `CONSERVED` is witnessed by an explicit list of checked triads
3. `VIOLATED` provides the FIRST violating triad found
4. `UNKNOWN` only if a skill has undefined trit
5. Deterministic: same graph state -> same result

## GF(3) Arithmetic

```python
def gf3_rep(x: int) -> int:
    """Map any integer to canonical GF(3) representative in {-1, 0, +1}."""
    r = x % 3
    return r if r <= 1 else r - 3

def gf3_add(a: int, b: int) -> int:
    return gf3_rep(a + b)

def gf3_sum(*args: int) -> int:
>>>>>>> origin/​main
    result = 0
    for a in args:
        result = gf3_add(result, a)
    return result

def is_valid_triad(t1: int, t2: int, t3: int) -> bool:
<<<<<<< HEAD
    """Conservation law: t1 + t2 + t3 ≡ 0 (mod 3)."""
    return gf3_sum(t1, t2, t3) == 0

def third_trit(t1: int, t2: int) -> int:
    """Given two trits, compute the unique third conserving GF(3).
    Postcondition: is_valid_triad(t1, t2, result) == True
    """
    return gf3_rep(-(t1 + t2))

# Cayley table for GF(3) addition (trits as {-1, 0, +1}):
# +  | -1   0  +1
# ---|------------
# -1 |  1  -1   0
#  0 | -1   0  +1
# +1 |  0  +1  -1

======= """Conservation law: t1 + t2 + t3 = 0 (mod 3).""" return gf3_sum(t1, t2, t3) == 0

def third_trit(t1: int, t2: int) -> int: """Given two trits, compute the unique third conserving GF(3).""" return gf3_rep(-(t1 + t2))


>>>>>>> origin/​main
## Oracle Implementation

```python
from dataclasses import dataclass
<<<<<<< HEAD
from typing import Optional
=======
>>>>>>> origin/​main
import json

@dataclass
class SkillNode:
    name: str
<<<<<<< HEAD
    trit: int       # -1, 0, +1 — from gf3-trit-oracle (NOT guessed)
    role: str       # VALIDATOR | ERGODIC | BRIDGE | GENERATOR
=======
    trit: int
    role: str
>>>>>>> origin/​main

@dataclass
class Triad:
    s1: SkillNode
    s2: SkillNode
    s3: SkillNode

    @property
    def trit_sum(self) -> int:
        return gf3_sum(self.s1.trit, self.s2.trit, self.s3.trit)

    @property
    def is_valid(self) -> bool:
        return self.trit_sum == 0

def conservation_oracle(
    skills: list[SkillNode],
<<<<<<< HEAD
    edges: list[tuple[str, str]],  # skill graph edges
    check_all: bool = False,       # if False, return on first violation
) -> dict:
    """
    Requirement:  all skills have trit ∈ {-1, 0, +1} (not None)
    Postcondition: returns CONSERVED | VIOLATED | UNKNOWN

    Triad selection: connected triples only (s1-s2 edge AND s2-s3 edge AND s1-s3 edge)
    OR hub triples: (hub, s1, s2) where hub connects to both s1 and s2
    """
    # Check for UNKNOWN (any skill has undefined trit)
    skill_map = {s.name: s for s in skills}
    for skill in skills:
        if skill.trit not in (-1, 0, 1):
            return {
                "result": "UNKNOWN",
                "reason": f"Skill '{skill.name}' has undefined trit: {skill.trit}"
            }

    # Build adjacency for connected triple enumeration
=======
    edges: list[tuple[str, str]],
    check_all: bool = False,
) -> dict:
    """
    Requirement:  all skills have trit in {-1, 0, +1}
    Postcondition: returns CONSERVED | VIOLATED | UNKNOWN
    """
    skill_map = {s.name: s for s in skills}
    for skill in skills:
        if skill.trit not in (-1, 0, 1):
            return {"result": "UNKNOWN", "reason": f"Skill '{skill.name}' has undefined trit"}

>>>>>>> origin/​main
    adj = {s.name: set() for s in skills}
    for (a, b) in edges:
        adj[a].add(b)
        adj[b].add(a)

    violations = []
    valid_triads = []

<<<<<<< HEAD
    # Check all connected triples
=======
>>>>>>> origin/​main
    skill_names = list(skill_map.keys())
    for i, n1 in enumerate(skill_names):
        for n2 in skill_names[i+1:]:
            if n2 not in adj[n1]:
<<<<<<< HEAD
                continue  # not connected — skip
=======
                continue
>>>>>>> origin/​main
            for n3 in skill_names:
                if n3 == n1 or n3 == n2:
                    continue
                if n3 not in adj[n1] and n3 not in adj[n2]:
<<<<<<< HEAD
                    continue  # n3 not connected to either — skip
=======
                    continue
>>>>>>> origin/​main

                s1, s2, s3 = skill_map[n1], skill_map[n2], skill_map[n3]
                triad = Triad(s1, s2, s3)

                if triad.is_valid:
                    valid_triads.append({
                        "skills": [n1, n2, n3],
                        "trits": [s1.trit, s2.trit, s3.trit],
<<<<<<< HEAD
                        "sum_mod3": 0
=======
>>>>>>> origin/​main
                    })
                else:
                    violations.append({
                        "skills": [n1, n2, n3],
                        "trits": [s1.trit, s2.trit, s3.trit],
                        "sum_mod3": triad.trit_sum
                    })
                    if not check_all:
<<<<<<< HEAD
                        # Return immediately on first violation
                        return {
                            "result": "VIOLATED",
                            "witness": violations[0]
                        }

    if violations:
        return {
            "result": "VIOLATED",
            "witness": violations[0],
            "all_violations": violations if check_all else None,
        }

    return {
        "result": "CONSERVED",
        "certificate": valid_triads,
        "triads_checked": len(valid_triads),
    }

Pre-Commit Integration (gf3-pr-verify hook)

======= return {"result": "VIOLATED", "witness": violations[0]}

if violations:
    return {"result": "VIOLATED", "witness": violations[0],
            "all_violations": violations if check_all else None}

return {"result": "CONSERVED", "certificate": valid_triads,
        "triads_checked": len(valid_triads)}

## Pre-Commit Hook
>>>>>>> origin/​main

```bash
#!/​usr/​bin/​env bash
# .git/​hooks/​pre-commit
<<<<<<< HEAD
# Requirement: gf3-trit-oracle is accessible (jq + skills.json)
# Postcondition: blocks commit if GF(3) conservation violated

=======
>>>>>>> origin/​main
set -euo pipefail

SKILLS_JSON="$HOME/​i/​asi/​skills.json"
ORACLE_SCRIPT="$HOME/​i/​asi/​skills/​gf3-conservation-oracle/​check.py"

<<<<<<< HEAD
# Get changed skill directories
CHANGED_SKILLS=$(git diff --cached --name-only | grep 'skills/' | cut -d/ -f1-3 | sort -u)

if [ -z "$CHANGED_SKILLS" ]; then
    exit 0  # No skill changes — no conservation check needed
=======
CHANGED_SKILLS=$(git diff --cached --name-only | grep 'skills/' | cut -d/ -f1-3 | sort -u)

if [ -z "$CHANGED_SKILLS" ]; then
    exit 0
>>>>>>> origin/​main
fi

echo "GF(3) Conservation Oracle: checking changed skills..."

<<<<<<< HEAD
# Extract full skill graph from registry
=======
>>>>>>> origin/​main
python3 "$ORACLE_SCRIPT" \
    --skills-json "$SKILLS_JSON" \
    --changed-skills "$CHANGED_SKILLS" \
    --mode "pre-commit"

STATUS=$?
if [ $STATUS -ne 0 ]; then
    echo "BLOCKED: GF(3) conservation violated."
<<<<<<< HEAD
    echo "Fix the trit assignment before committing."
=======
>>>>>>> origin/​main
    echo "Use: third_trit(t1, t2) to compute the required third trit."
    exit 1
fi

echo "GF(3) conservation: CONSERVED. Commit allowed."
<<<<<<< HEAD
exit 0

Monotonic Skill Invariant

# Requirement: skills.json has a "count" field or is countable
# Postcondition: new count >= old count (MONOTONIC_SKILL_INVARIANT)

def monotonic_oracle(old_skills_json: str, new_skills_json: str) -> dict:
    """
    Precondition:  both JSON files are valid ASI skill registries
    Postcondition: returns CONSERVED if new_count >= old_count, VIOLATED otherwise

    This is SEPARATE from GF(3) conservation — both must hold.
=======

Monotonic Skill Invariant

def monotonic_oracle(old_skills_json: str, new_skills_json: str) -> dict:
    """
    Separate from GF(3) conservation -- both must hold.
    Postcondition: CONSERVED if new_count >= old_count, VIOLATED otherwise.
>>>>>>> origin/​main
    """
    old_count = len(json.load(open(old_skills_json))["skills"])
    new_count = len(json.load(open(new_skills_json))["skills"])

    if new_count >= old_count:
<<<<<<< HEAD
        return {
            "result": "CONSERVED",
            "old_count": old_count,
            "new_count": new_count,
            "delta": new_count - old_count,
        }
    else:
        return {
            "result": "VIOLATED",
            "witness": {
                "old_count": old_count,
                "new_count": new_count,
                "deleted_count": old_count - new_count,
            }
        }

Composition of GF(3) Oracles

Conservation oracle checks:       STATIC invariant (graph structure)
Trit oracle provides:             ATOMIC classification per skill
Abductive oracle uses:            DYNAMIC classification per evidence
Bisimulation oracle uses:         BEHAVIORAL equivalence per trit class
Neurofeedback oracle provides:    REAL-TIME trit from EEG signal

All five must agree (no contradiction across layers):

CellValue.nothing    → oracle not yet run
CellValue.value(t)   → oracle returned definite trit t
CellValue.contradiction → two authoritative sources disagree → HALT

Dafny Formal Verification

// Requirement: Dafny 4.x installed
// Postcondition: conservation law formally verified for up to N triad checks

=======
        return {"result": "CONSERVED", "old_count": old_count,
                "new_count": new_count, "delta": new_count - old_count}
    else:
        return {"result": "VIOLATED", "witness": {
            "old_count": old_count, "new_count": new_count}}

Dafny Formal Verification

>>>>>>> origin/​main
lemma GF3Conservation(t1: int, t2: int, t3: int)
    requires t1 in {-1, 0, 1} && t2 in {-1, 0, 1} && t3 in {-1, 0, 1}
    requires (t1 + t2 + t3) % 3 == 0
    ensures third_trit(t1, t2) == t3
{
<<<<<<< HEAD
    // Proof: by exhaustive case analysis (27 cases)
    // Dafny verifies this automatically via SAT
=======
    // Proof by exhaustive case analysis (27 cases) -- Dafny verifies via SAT
>>>>>>> origin/​main
}

function third_trit(t1: int, t2: int): int
    requires t1 in {-1, 0, 1} && t2 in {-1, 0, 1}
    ensures third_trit(t1, t2) in {-1, 0, 1}
    ensures (t1 + t2 + third_trit(t1, t2)) % 3 == 0
{
    var sum := t1 + t2;
    var raw := (-sum) % 3;
    if raw == 2 then -1 else raw
}

<<<<<<< HEAD

What This Oracle Is NOT

  • NOT a style checker — conservation is a mathematical invariant, not a convention
  • NOT a majority vote — one violation invalidates the entire graph
  • NOT approximate — conservation is exact (mod 3), no tolerance, no ε
  • NOT transitive — CONSERVED for subgraph does NOT imply CONSERVED for full graph
  • NOT bypassed by --no-verify in a correctly configured git repo

Related Skills

  • gf3-trit-oracle — provides the trit values this oracle checks
  • gf3-pr-verify — pre-commit hook that invokes this oracle
  • gf3-tripartite — composition invariant checker (same algebra, different scope)
  • belief-revision-log — beliefs must also satisfy GF(3) conservation at each timestamp
  • skill-validation-gf3 — validates individual skills against registry
  • formal-verification / dafny-formal-verification — Dafny proof of the lemmas above
  • bisimulation-oracle — uses trit class to gate bisimulation queries =======

What This Oracle Is NOT

  • NOT a style checker -- conservation is a mathematical invariant
  • NOT a majority vote -- one violation invalidates the entire graph
  • NOT approximate -- exact mod 3, no tolerance
  • NOT transitive -- CONSERVED for subgraph does NOT imply CONSERVED for full graph

origin/​main

Para(Optic) atlas

Part of: para-mensch-commons.

More DevOps & CI/CD skills

Project scaffolding, deployment configuration, and CI/CD setup for Google ADK agents.

6K 472.6K
View

Set up tracing, logging, and monitoring for deployed ADK agents across Cloud Trace, BigQuery, and third-party platforms.

6K 472.6K
View

Enterprise Azure infrastructure architect generating Bicep or Terraform from workload descriptions.

1.5K 454.3K
View
azure-kubernetes logo
DevOps & CI/CD

azure-kubernetes

Plan and configure production-ready Azure Kubernetes Service clusters with Day-0 and Day-1 best practices.

1.5K 447.1K
View

Raw mechanical interfaces fusing Swiss typographic print with military terminal aesthetics. Rigid grids, extreme type scale contrast, utilitarian color, analog degradation effects. For data-heavy dashboards, portfolios, or editorial sites that need to feel like declassified blueprints.

92.7K 354.9K
View
just-scrape logo
DevOps & CI/CD

just-scrape

Web search, scraping, extraction, crawling, and monitoring via ScrapeGraph AI CLI.

69 245K
View

Skill for working with Firebase Hosting (Classic). Use this when you want to deploy static web apps, Single Page Apps (SPAs), or simple microservices. Do NOT use for Firebase App Hosting.

462 159.7K
View

Deploy and manage web apps with Firebase App Hosting. Use this skill when deploying Next.js/Angular apps with backends.

462 159.1K
View
deploy-to-vercel logo
DevOps & CI/CD

deploy-to-vercel

Deploy applications and websites to Vercel. Use when the user requests deployment actions like "deploy my app", "deploy and give me the link", "push this live", or "create a preview deployment".

31.9K 146.6K
View
programmatic-seo logo
DevOps & CI/CD

programmatic-seo

Build SEO-optimized pages at scale using templates, data, and proven playbook patterns.

53.3K 140.1K
View

Design and build isolated, reusable Convex backend components with clear boundaries and app-facing wrappers.

63 123.5K
View

Deploy and manage projects on Vercel using token-based authentication. Use when working with Vercel CLI using access tokens rather than interactive login — e.g. "deploy to vercel", "set up vercel", "add environment variables to vercel".

31.9K 116.1K
View

Coding & apps AI tools

Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View
I
Coding & apps

Imagica

Build a no-code AI app in minutes.

Freemium
View
E
Coding & apps

Emergent.sh

An IDE for code migration from legacy to modern frameworks through coding agents.

Freemium
View
Wonder Dynamics logo
Coding & apps

Wonder Dynamics

Automate CGI animation in live-action scenes

Paid
View
M
Coding & apps

Mixo

Launch a website in seconds with AI.

Paid
View
AI Code Convert logo
Coding & apps

AI Code Convert

Streamline Your Coding Experience with AI Code Helper

Free
View