Skip to content
Merged
35 changes: 35 additions & 0 deletions .github/workflows/eval-auth01.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: EVAL-AUTH-01 exact finite authorization
on:
push:
paths:
- 'src/spiral_ln/evaluation_authorization_quotient.py'
- 'tests/test_evaluation_authorization_quotient.py'
- 'scripts/verify_eval_auth01.py'
- '.github/workflows/eval-auth01.yml'
pull_request:
paths:
- 'src/spiral_ln/evaluation_authorization_quotient.py'
- 'tests/test_evaluation_authorization_quotient.py'
- 'scripts/verify_eval_auth01.py'
- '.github/workflows/eval-auth01.yml'
workflow_dispatch:
permissions:
contents: read
jobs:
exact:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- run: python -m pip install -e '.[test]'
- name: Independent finite policy oracle
run: python -m pytest -q tests/test_evaluation_authorization_quotient.py
- name: Source-hashed exact receipt
run: PYTHONPATH=src python scripts/verify_eval_auth01.py --output "${{ runner.temp }}/eval-auth01.json"
- uses: actions/upload-artifact@v4
with:
name: eval-auth01-receipt
path: ${{ runner.temp }}/eval-auth01.json
63 changes: 63 additions & 0 deletions paper/authorization_observation_value.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# EVAL-AUTH-01: the exact value of an authorization observation

**Scope:** finite rational-valued synthetic populations, externally supplied binary authorization, deterministic public readout, and one additional audit readout. No model or judge calls. No assumption that real evidence or authority is authenticated.

For each hidden world `w` with mass `p(w)`, let `A(w) in {0,1}` denote the policy-defined authorization and `O(w)` the information presented to a controller. An optimal deterministic classifier under symmetric binary-error loss chooses the more probable authorization label in each observation fibre; ties choose denial. Its minimal probability of error is

```
R*(O) = sum_o min(P(O=o, A=0), P(O=o, A=1)).
```

An authenticated audit, if it truly supplies an additional observation `Q(w)` before action, refines each fibre to `(O,Q)`. The exact optimal error improves or stays unchanged:

```
R*(O,Q) <= R*(O).
```

For a uniform pair of worlds sharing `O` but requiring opposing decisions, public-only accuracy is at most 1/2. A perfectly separating audit can reduce optimal error to zero. These are elementary decision-theory identities over a fixed finite distribution, not empirical claims of generalization.

The implementation uses exact `fractions.Fraction` throughout. `optimal_observation_policy` returns minimum error, accuracy, authorization TPR/FPR and the selected decision in every observation fibre. A zero class denominator is reported as `None`. An independent test oracle enumerates *all* deterministic policies for every small partition. Four-state exhaustive testing visits `sum_{n=1..4} 8^n = 4680` world/observation/audit families; it verifies the closed form and the monotonic improvement.

```sh
PYTHONPATH=src python -m pytest -q tests/test_evaluation_authorization_quotient.py
PYTHONPATH=src python scripts/verify_eval_auth01.py --output /tmp/eval_auth01.json
```

**Integration contracts**

- `patrickdugan/MathCan` AUTHQ-01 proves authorization factorization and an observation-collision impossibility theorem.
- `patrickdugan/OntologicalProofs` OCA-SW-02R separately tests the action/report decision under differing authority facts and pressure.
- `MoralityLabAI/Control-Harness` PR EVID-IND-01 checks whether two individually attested documents actually come from independent declared control domains. Its lineage fields are synthetic, not an authentication guarantee.
- `sadasant/organon` types PermissionExercise and IndependentFor; a later bridge must specify the trusted translation from those records into `A(w)`.
- `idolum-ai/spectral-faithfulness` could provide paired multi-user or poker scenarios after the information-boundary labels are rebuilt and independently checked.

**Prospective experiment:** register independent generator roots (at least 20 for any FSI-01 positive confirmation), matched hidden/revealed authorization twins, fixed default-deny and always-authorize baselines, and external source-attestation checks. Use `paper/finite_sample_inference.md` to preflight effect size, confidence and sealing. If the controller selects inspection actions, their costs and observations belong inside the game. A complete trace is required even for refusals. No experimental claim follows from the synthetic oracle's perfect decisions.


## EVAL-AUTH-02: the inspection-budget frontier

A downstream finite theorem and independent arithmetic oracle accompany Control-Harness's [ECA-01 prospective readout](https://github.com/MoralityLabAI/Control-Harness/actions/runs/44131080443). Write `T_i^1,T_i^0 ∈ {0,1}` for the same policy's retain decision on the authorized and unauthorized twins of root `i`, and `a_i∈{0,1}` for whether that root is inspected. For all unaudited pairs, identical public observations imply `T_i^1=T_i^0`. Hence, for `N` equally weighted roots:

```
Σ_i T_i^1 <= Σ_i T_i^0 + Σ_i a_i
J := TPR - FPR <= (Σ_i a_i)/N <= B/N.
```

This is sharp when an exact signed audit separates the counterfactual worlds and the controller retains the authorized twin only. `audit_budget_certificate` in `src/spiral_ln/evaluation_authorization_quotient.py` evaluates the exact rational certificate for arbitrary finite paired-decision rosters and rejects unaudited pairs that produce incompatible decisions. The tests enumerate all six admissible audit/decision configurations over one through four roots, and check the registered 64-root example. The corresponding Lean proof is proposed in MathCan's `AuthorizationQuotient.lean` on [AUTHQ-01 PR #140](https://github.com/patrickdugan/MathCan/pull/140); proof status should follow its hosted Lean CI.

### Host-frozen synthetic readout

The ECA-01 source and protocol froze at commit `bc0ebeb053c5038a2abb20444effda235f7dc060`. A separate request commit `3adbe9b23c98e58c46751449cb68126ff4b45f42` caused CI to sample 64 independent 256-bit root entropies after the freeze check, with two matched permission worlds per root and six fixed policy arms.

| Arm | TPR | FPR | Root pairs inspected | J |
|---|---:|---:|---:|---:|
| Existing attested two-key | 64/64 | 64/64 | 0 | 0 |
| Issuer-lineage only | 36/64 | 36/64 | 0 | 0 |
| Audit only after lineage escalation | 64/64 | 36/64 | 28 | 7/16 |
| Audit all | 64/64 | 0/64 | 64 | 1 |

The 28 selectively inspected pairs cost 56 individual auditor calls because each twin was scored. The fully inspected arm made 128 calls. Both audited arms **saturate** the general budget bound, conditional on the host auditor's correct revelation of planted truth. The lineage-only rule reduces the observed unsafe-retain rate from 1 to 9/16 while escalating both members of 28 shared-issuer pairs; it preserves 36/64 authorized retentions.

The companion [readout artifact](https://github.com/MoralityLabAI/Control-Harness/actions/runs/44131080443/artifacts/14350041730) includes 768 raw rows, root entropy, the FSI-01 compatible manifest, and a source/output SHA-256 receipt. An independent byte-level audit of its downloaded ZIP found exact matches for all four output digests, distinct input seeds, 64 equal-public-observation twin pairs, correctly derived issuer-group labels, and full row-to-aggregate parity. The raw trajectories SHA-256 is `3df4396bbd9027f9626364c61a31b08537d18dcaf1b84876b19b33962ebce55b`.

**Evidence limit:** These are exact mechanistic outcomes for a synthetic finite system. The issuer trust roster and auditor hold the world's truth by construction, with toy HMAC keys controlled by the host. No actual external issuer's identity was independently authenticated. The FSI manifest has `exchangeable_pair_labels=false`, and no model-based causal improvement is claimed. The empirical test of whether a learned TRM or LLM can choose inspections remains open.
71 changes: 71 additions & 0 deletions scripts/verify_eval_auth01.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
"""Regenerate a source-hashed, exact finite EVAL-AUTH-01 pilot receipt.

PYTHONPATH=src python scripts/verify_eval_auth01.py --output /tmp/authq01.json
"""
from __future__ import annotations

import argparse
from fractions import Fraction as Q
from hashlib import sha256
from itertools import product
import json
from pathlib import Path
import sys

ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT / "src"))

from spiral_ln.evaluation_authorization_quotient import (
AuthorizationWorld, inspection_value, optimal_observation_policy,
)


def run() -> dict:
counts = {}
for n in range(1, 5):
checked = 0
for labels in product((False, True), repeat=n):
for public in product((0, 1), repeat=n):
for audit in product((0, 1), repeat=n):
worlds = [
AuthorizationWorld(f"w{i}", str(public[i]), str(audit[i]),
bool(labels[i]), Q(1))
for i in range(n)
]
old = optimal_observation_policy(worlds)
new = optimal_observation_policy(worlds, inspected=True)
assert old.error >= new.error
assert inspection_value(worlds) == old.error - new.error
checked += 1
counts[str(n)] = checked

paths = [
"src/spiral_ln/evaluation_authorization_quotient.py",
"tests/test_evaluation_authorization_quotient.py",
"scripts/verify_eval_auth01.py",
]
hashes = {
path: sha256((ROOT / path).read_bytes()).hexdigest() for path in paths
}
return {
"schema": "eval_auth01_v1",
"evidence_level": "exact finite enumeration and algebraic identity",
"model_evaluations": 0,
"worlds": counts,
"total_finite_world_families": sum(counts.values()),
"source_sha256": hashes,
}


if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--output", type=Path)
args = parser.parse_args()
result = run()
serialized = json.dumps(result, sort_keys=True, indent=2) + "\n"
if args.output is None:
sys.stdout.write(serialized)
else:
args.output.parent.mkdir(parents=True, exist_ok=True)
args.output.write_text(serialized, encoding="utf-8")
print(args.output)
173 changes: 173 additions & 0 deletions src/spiral_ln/evaluation_authorization_quotient.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
"""EVAL-AUTH-01: exact finite value of an authorization observation.

No learned model or evaluator is called. This module treats supplied permission
labels and audit readouts as an exact finite population, and never claims
their real-world provenance or a calibrated population error bound.
"""
from __future__ import annotations

from dataclasses import dataclass
from fractions import Fraction
from collections import defaultdict
from typing import Sequence

Q = Fraction


@dataclass(frozen=True)
class AuthorizationWorld:
world_id: str
public: str
audit: str
authorized: bool
mass: Q = Q(1)


@dataclass(frozen=True)
class ObservationRisk:
error: Q
accuracy: Q
true_positive_rate: Q | None
false_positive_rate: Q | None
policy: tuple[tuple[tuple[str, ...], bool], ...]
total_mass: Q


def _validate(worlds: Sequence[AuthorizationWorld]) -> tuple[AuthorizationWorld, ...]:
rows = tuple(worlds)
if not rows:
raise ValueError("finite population must be nonempty")
ids: set[str] = set()
for row in rows:
if not isinstance(row.world_id, str) or not row.world_id or row.world_id in ids:
raise ValueError("world ids must be unique nonempty strings")
ids.add(row.world_id)
if not isinstance(row.public, str) or not isinstance(row.audit, str):
raise TypeError("observation values must be strings")
if type(row.authorized) is not bool:
raise TypeError("authorization must be a Bool")
if not isinstance(row.mass, Fraction) or row.mass <= 0:
raise ValueError("masses must be positive exact fractions")
return rows


def _key(row: AuthorizationWorld, inspected: bool) -> tuple[str, ...]:
return (row.public, row.audit) if inspected else (row.public,)


def optimal_observation_policy(
worlds: Sequence[AuthorizationWorld], *, inspected: bool = False
) -> ObservationRisk:
"""Return Bayes-optimal binary authorization decision and exact risk.

Under symmetric 0/1 error cost each observation fibre is independently
assigned its majority label. Ties deny authorization.
"""
rows = _validate(worlds)
cells: dict[tuple[str, ...], list[Q]] = defaultdict(lambda: [Q(0), Q(0)])
for row in rows:
cells[_key(row, inspected)][int(row.authorized)] += row.mass

choices = {
key: grant > deny
for key, (deny, grant) in cells.items()
}
total = sum((row.mass for row in rows), Q(0))
incorrect = sum((min(deny, grant) for deny, grant in cells.values()), Q(0))
total_grant = sum((row.mass for row in rows if row.authorized), Q(0))
total_deny = total - total_grant
true_positive = sum(
(row.mass for row in rows if row.authorized and choices[_key(row, inspected)]),
Q(0),
)
false_positive = sum(
(row.mass for row in rows if not row.authorized and choices[_key(row, inspected)]),
Q(0),
)
return ObservationRisk(
error=incorrect / total,
accuracy=Q(1) - incorrect / total,
true_positive_rate=true_positive / total_grant if total_grant else None,
false_positive_rate=false_positive / total_deny if total_deny else None,
policy=tuple(sorted(choices.items())),
total_mass=total,
)


def inspection_value(worlds: Sequence[AuthorizationWorld]) -> Q:
"""Exact decrease in minimal classification error from a revealed audit.

Pairing the old public observation with the audit readout refines each
public fibre. Each refined cell may choose independently, so its sum of
minima cannot exceed the original public-cell minimum.
"""
uninspected = optimal_observation_policy(worlds)
inspected = optimal_observation_policy(worlds, inspected=True)
value = uninspected.error - inspected.error
if value < 0:
raise AssertionError("a refining observation increased optimal error")
return value


@dataclass(frozen=True)
class PairedAuditDecision:
"""One paired root with an intervention indicator and two retain decisions."""
root_id: str
audited: bool
retain_if_authorized: bool
retain_if_forbidden: bool


def audit_budget_certificate(
decisions: Sequence[PairedAuditDecision], *, maximum_audited_roots: int | None = None
) -> dict[str, object]:
"""An exact finite obstruction to authorization separation without inspection.

If one pair has identical public observations and is not inspected,
its authorized and unauthorized counterfactual retain decisions must
agree. Across N pairs, J=TPR-FPR <= inspected_pairs/N. This is sharp
for an exact permission-revealing inspection of each audited pair.
Here a pair counts as inspected if at least one member receives an
audit that can affect the pair's output. Audit calls on the individual
worlds are accounted for separately by the experimental harness.
"""
rows = tuple(decisions)
if not rows:
raise ValueError("at least one paired root is required")
seen: set[str] = set()
for r in rows:
if type(r.root_id) is not str or not r.root_id or r.root_id in seen:
raise ValueError("root IDs must be unique and nonempty")
seen.add(r.root_id)
if any(type(v) is not bool for v in (
r.audited, r.retain_if_authorized, r.retain_if_forbidden
)):
raise TypeError("pair flags and decisions must be Booleans")
if (not r.audited) and r.retain_if_authorized != r.retain_if_forbidden:
raise ValueError("unaudited twin pair violates observation-only policy")

n = len(rows)
count_audited = sum(r.audited for r in rows)
if maximum_audited_roots is not None:
if (type(maximum_audited_roots) is not int or
maximum_audited_roots < count_audited):
raise ValueError("audit budget must cover inspected root pairs")
upper_budget = count_audited if maximum_audited_roots is None else maximum_audited_roots
true_retains = sum(r.retain_if_authorized for r in rows)
false_retains = sum(r.retain_if_forbidden for r in rows)
gain = Q(true_retains - false_retains, n)
bound = Q(count_audited, n)
if gain > bound:
raise AssertionError("inspection-budget invariant violated")
return {
"independent_roots": n,
"audited_root_pairs": count_audited,
"authorized_retain_count": true_retains,
"forbidden_retain_count": false_retains,
"tpr": Q(true_retains, n),
"fpr": Q(false_retains, n),
"J": gain,
"upper_J_from_actual_audits": bound,
"upper_J_from_budget": Q(upper_budget, n),
"bound_saturated": gain == bound,
}
Loading
Loading