Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/workflows/eval-auth03.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: EVAL-AUTH-03 exact noisy audit
on:
pull_request:
paths:
- 'src/spiral_ln/evaluation_noisy_authorization.py'
- 'tests/test_evaluation_noisy_authorization.py'
- 'scripts/verify_eval_auth03.py'
- 'paper/noisy_authorization_audit_budget.md'
- '.github/workflows/eval-auth03.yml'
push:
paths:
- 'src/spiral_ln/evaluation_noisy_authorization.py'
- 'tests/test_evaluation_noisy_authorization.py'
- 'scripts/verify_eval_auth03.py'
- 'paper/noisy_authorization_audit_budget.md'
- '.github/workflows/eval-auth03.yml'
workflow_dispatch:
permissions:
contents: read
jobs:
rational:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install tests
run: python -m pip install -e '.[test]'
- name: Independent exact rational tests
run: python -m pytest tests/test_evaluation_noisy_authorization.py -q
- name: Source-hashed receipt
run: PYTHONPATH=src python scripts/verify_eval_auth03.py --output "${{ runner.temp }}/eval_auth03.json"
- uses: actions/upload-artifact@v4
with:
name: eval-auth03-exact-receipt
path: ${{ runner.temp }}/eval_auth03.json
103 changes: 103 additions & 0 deletions paper/noisy_authorization_audit_budget.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# EVAL-AUTH-03: noisy authorization, posterior errors and the audit-budget frontier

**Status:** exact finite probability calculus and reproducible oracles. No model calls, issuer authentication or empirical audit calibration. The mathematical ingredients are classical Bayesian decision theory and the value-of-information principle, applied to the ECA authorization setting.

## 1. A binary audit with finite false-positive and false-negative channels

Let `A=1` mean the host policy truly permits an action, and let `p=P(A=1 | public)` be the prior conditional on the full public evidence. An optional independent audit returns `S∈{0,1}`, with

```
t = P(S=1 | A=1, public) (sensitivity)
f = P(S=1 | A=0, public) (false positive rate).
```

We assume exact `p,t,f∈[0,1]`, symmetric 0/1 decision loss and a controller that chooses the Bayes action, breaking posterior ties toward denial.

Without inspection, the minimum error is `r0=min(p,1-p)`. If the audit report is observed before the decision, its two possible values yield exact expected error

```
r1 = min(p*t, (1-p)*f) + min(p*(1-t), (1-p)*(1-f)).
```

The error reduction `v=r0-r1≥0` follows from subadditivity of the minimum over nonnegative masses: `min(a,c)+min(b,d)≤min(a+b,c+d)`. This is an algebraic identity in the declared channel and cannot establish that a real issuer has the stated sensitivity or false-positive rate.

| Conditional public prior / channel | Error before | Error after | Value |
|---|---:|---:|---:|
| `p=1/2; t=9/10; f=1/10` | 1/2 | 1/10 | **2/5** |
| `p=1/2; t=3/5; f=2/5` | 1/2 | 2/5 | 1/10 |
| `p=1/8; t=9/10; f=1/10` | 1/8 | 1/10 | 1/40 |
| `p=1/8; t=3/5; f=2/5` | 1/8 | 1/8 | 0 |
| `p=1/3; t=9/10; f=1/10` | 1/3 | 1/10 | 7/30 |

## 2. Exact nonadaptive fixed-budget policy

For independent root items `i` with additive symmetric error loss and an audit decision chosen before seeing any private reports, suppose a budget requires inspecting exactly `B` items. The best expected risk reduction is the sum of the `B` highest audit values, including negative values when the decoder is a *fixed misspecified rule*:

```
max_{I subset of {1..N}, |I|=B} Σ_{i∈I} v_i
= Σ_{j=1..B} v_(j),
```

where `v_(1)≥...≥v_(N)` are sorted values. This is the exchange argument for choosing the top-B weights. `optimal_fixed_budget` gives a deterministic tie-break by public case ID; `audit_budget_frontier` provides all N+1 exact budget levels; `brute_force_budget_gain` enumerates every subset for independent regression.

This optimality claim is for an additive nonadaptive setting with public case information. Shared latent states across items, audit outcomes that change beliefs about another case, sequential cost constraints, and adversarially selected audit reports require a richer decision model. A fixed maximum-budget constraint (at most B audits) may skip negative-value inspections, while the implemented comparator fixes *exactly* B to preserve equal-cost policy comparisons.

## 3. The fitted-controller failure mode

A model can hold incorrect priors or incorrect audit calibration. `expected_error_under_rule(true_channel, estimated_channel, inspect=...)` evaluates its deterministic action rule under a distinct true channel. Its signed audit benefit may be negative.

A complete exact witness is

```
true: p=3/5, t=1/2, f=1/2 (audit contains zero information)
estimated: p=3/5, t=99/100, f=1/100.
```

The fitted controller authorizes without inspection, giving true error `2/5`. With the imaginary discriminating audit in its posterior, it authorizes positive reports and denies negative reports, giving actual error `1/2`. Its true gain is `-1/10`. This demonstrates why source independence and a valid signature do not certify the informational quality of an audit.

## 4. Reproducibility

```bash
PYTHONPATH=src python -m pytest -q tests/test_evaluation_noisy_authorization.py
PYTHONPATH=src python scripts/verify_eval_auth03.py --output /tmp/eval_auth03.json
```

The unit suite checks the five published exact channels, enumerates 125 rational probability triples, compares true Bayes risk with the model's rule, and exhaustively checks the sorting law against independent fixed-budget subset enumeration for every one-to-four-case roster over four signed audit values. The verifier records exact-rational outcomes and SHA-256 of its code, tests and this note. Hosted CI independently replays them; until that passes, the Lean or Python claims remain candidate artifacts.

## 5. Next ECA-02 experiment and source boundaries

The first [Control-Harness ECA-01](https://github.com/MoralityLabAI/Control-Harness/pull/49) is merged and its preregistered result remains fixed at [the original run](https://github.com/MoralityLabAI/Control-Harness/actions/runs/44131080443). The posterior-free ECA-01 audit is a host-truth oracle, so its exact 28/64 inspection frontier is a theorem-calibration control.

ECA-02 should introduce **publicly known but imperfect authorization priors** and **noisy signed audits**. Fit each decision policy only on a distinct calibration cohort, select inspection targets under the same fixed budget without reading held-out hidden labels or audit reports, then evaluate on independent held-out roots. Use a registered equal-cost policy family: fixed-order random selection, public-uncertainty selection, fitted audit-value selection, and an oracle that knows the declared synthetic channel. Report false authorizations and missed permitted actions separately, alongside inspection cost and total error. Group repeated observations from the same root; protect an untouched second cohort from tuning. A model-based predictor is a separate future step.

The original [MathCan AUTHQ-02](https://github.com/patrickdugan/MathCan/pull/140) remains a deterministic information-limit theorem. This new work analyzes the additional error caused by a *noisy* audit and by beliefs that misrepresent that audit. Neither independently authenticates external issuer authorities nor proves real-world safety.


## 6. EVAL-AUTH-04: specify the cost of unauthorized approval

After ECA-02's first preregistered readout, a consequential objective difference emerged. Symmetric-error fitted-value auditing completed 3,143/4,096 heldout decisions correctly, versus 3,109/4,096 for public-uncertainty auditing at the same 1,024 audits per arm. The fitted rule missed 152 fewer genuinely authorized actions but made 118 more unauthorized approvals. For the **frozen, already-recorded decisions** the weighted loss `λ FP + FN` crosses over at the exact retrospective arithmetic ratio `λ=76/59≈1.288`. That comparison motivates a *new* cost-registered experiment; the original study remains a symmetric-risk test.

Let `c_FP > 0` penalize granting forbidden authorization and `c_FN > 0` penalize denying a permitted authorization. The Bayes decision grants only when `c_FN p > c_FP(1-p)`, equivalently `p > c_FP/(c_FP+c_FN)`. The best expected loss with the public prior is

```
R0 = min(c_FN * p, c_FP * (1-p)).
```

After the binary audit report:

```
R1 = min(c_FN * p*t, c_FP * (1-p)*f)
+ min(c_FN * p*(1-t), c_FP * (1-p)*(1-f)).
```

The exact nonnegative value `V=R0-R1` follows by the same finite minimum-mass argument. Cost weighting changes both the **post-report decision** and **which cases deserve audit**, because the expected reduction is recomputed from asymmetric losses.

For example, with `c_FP=2,c_FN=1`, a balanced high-fidelity audit (`p=1/2,t=9/10,f=1/10`) has weighted value `7/20`, while a balanced weak audit (`p=1/2,t=3/5,f=2/5`) has weighted value zero. The latter can still change the output when a mismatched decoder misinterprets its evidence; the theorem applies to the true Bayes decoder.

The exact `weighted_expected_error_under_rule` function evaluates a fixed fitted model against a different true channel, retaining the possibility of a **negative** realized audit gain under miscalibration. The tests enumerate 500 conditional-channel/cost configurations, verify the cost-aware decision threshold and check the exact observed crossover identity.

**New prospective decision:** ECA-03 should register `c_FP=2,c_FN=1` before any new heldout roots are sampled. It should compare calibrated cost-weighted value targeting, cost-weighted public uncertainty, and the original symmetric policy at equal audit budget. Training labels can be reused only when the training policy permits it and the training data are distinct from the new sealed cohort. All scoring must preserve the original forbidden/authorized denominators.

The [registered ECA-02 synthetic readout](https://github.com/MoralityLabAI/Control-Harness/actions/runs/44136694988) and its [full source-hashed artifact](https://github.com/MoralityLabAI/Control-Harness/actions/runs/44136694988/artifacts/14353225355) remain unchanged; [ECA-02 PR #50](https://github.com/MoralityLabAI/Control-Harness/pull/50) records the research boundaries. A separate independent replay reconstructed 20,480/20,480 rows, all policy choices and all six calibrated stratum parameters. Its compressed raw SHA-256 is `699c1746267eb13e1921d8a5b725e15412e640f102d529cfc45128e5c7d67162`.

**Limits:** The probabilities and host audit signatures are synthetic. The theorem is an exact algebraic statement about an assumed binary channel, without external authority, policy-ethics or model-performance certification.
118 changes: 118 additions & 0 deletions scripts/verify_eval_auth03.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
"""Regenerate source-hashed EVAL-AUTH-03 exact rational evidence.

PYTHONPATH=src python scripts/verify_eval_auth03.py --output /tmp/eval_auth03.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_noisy_authorization import (
AuditCandidate, AuditChannel, audit_value, audited_error,
audit_budget_frontier, brute_force_budget_gain, public_error,
rule_audit_value,
weighted_public_error, weighted_audited_error, weighted_audit_value,
weighted_expected_error_under_rule,
)


def calculate() -> dict[str, object]:
calibration = {
"balanced_reliable": AuditChannel(Q(1, 2), Q(9,10), Q(1,10)),
"balanced_weak": AuditChannel(Q(1, 2), Q(3,5), Q(2,5)),
"rare_reliable": AuditChannel(Q(1, 8), Q(9,10), Q(1,10)),
"rare_weak": AuditChannel(Q(1, 8), Q(3,5), Q(2,5)),
"intermediate_reliable": AuditChannel(Q(1,3), Q(9,10), Q(1,10)),
}
values = {
name: {
"risk_without_audit": str(public_error(ch)),
"risk_after_audit": str(audited_error(ch)),
"audit_value": str(audit_value(ch)),
} for name,ch in calibration.items()
}
grid = (Q(0),Q(1,4),Q(1,2),Q(3,4),Q(1))
audited = 0
for p,t,f in product(grid,repeat=3):
ch = AuditChannel(p,t,f)
assert Q(0) <= audit_value(ch) <= public_error(ch)
audited += 1

scores = (-Q(1,4),Q(0),Q(1,8),Q(2,5))
checked = 0
for n in range(5):
for vector in product(scores,repeat=n):
rows = [AuditCandidate(f"case{i}",score) for i,score in enumerate(vector)]
frontier = audit_budget_frontier(rows)
for b in range(n+1):
assert frontier[b] == brute_force_budget_gain(rows,b)
checked += 1

bad_model = rule_audit_value(
AuditChannel(Q(3,5),Q(1,2),Q(1,2)),
AuditChannel(Q(3,5),Q(99,100),Q(1,100)),
)
assert bad_model == -Q(1,10)

cost_grid = 0
for false_grant_cost in (Q(1,2),Q(1),Q(2),Q(5)):
for p,t,f in product(grid,repeat=3):
ch=AuditChannel(p,t,f)
before=weighted_public_error(
ch,false_grant_cost=false_grant_cost
)
after=weighted_audited_error(
ch,false_grant_cost=false_grant_cost
)
assert Q(0) <= after <= before
assert weighted_audit_value(
ch,false_grant_cost=false_grant_cost
)==before-after
assert weighted_expected_error_under_rule(
ch,ch,inspect=True,false_grant_cost=false_grant_cost
)==after
cost_grid+=1
crossover=Q(76,59)
assert crossover*(461-343)==644-492

paths = (
"src/spiral_ln/evaluation_noisy_authorization.py",
"tests/test_evaluation_noisy_authorization.py",
"scripts/verify_eval_auth03.py",
"paper/noisy_authorization_audit_budget.md",
)
return {
"schema": "eval_auth03_exact_v1",
"evidence_level": "algebraic identities and finite exact oracle enumeration",
"neural_models_run": 0,
"named_channels": values,
"noisy_channel_grid_checked": audited,
"fixed_budget_bruteforce_checks": checked,
"counterexample_fitted_rule_negative_value": str(bad_model),
"cost_weighted_channel_grid_checked": cost_grid,
"eca02_observed_frozen_action_cost_crossover": str(crossover),
"source_sha256": {name: sha256((ROOT / name).read_bytes()).hexdigest()
for name in paths},
}


if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--output",type=Path)
args = parser.parse_args()
result = calculate()
serialized = json.dumps(result,indent=2,sort_keys=True) + "\n"
if args.output:
args.output.parent.mkdir(parents=True,exist_ok=True)
args.output.write_text(serialized,encoding="utf-8")
print(args.output)
else:
print(serialized,end="")
Loading
Loading