Skip to content

Theory->Engineering: consent in TCB (A3), semantic gate (A4/A5), Mahdavi compass (A7) + red-team#4

Open
Aliipou wants to merge 31 commits into
mainfrom
feat/theory-gaps
Open

Theory->Engineering: consent in TCB (A3), semantic gate (A4/A5), Mahdavi compass (A7) + red-team#4
Aliipou wants to merge 31 commits into
mainfrom
feat/theory-gaps

Conversation

@Aliipou

@Aliipou Aliipou commented Jun 11, 2026

Copy link
Copy Markdown
Owner

What & why

Closes the three open gaps in Theory_to_Engineering_Plan.md, mapping axioms
A3/A4/A5/A7 of the Theory of Freedom (نظریه آزادی) from prose into Rust. Each
gap previously existed only as bypassable Python; this lands the parts that
belong in code, at the correct trust level — and nothing more.

Changes

Axiom Module Trust level
A3 — consent recorded, not assumed src/tcb/consent.rs (+ engine.rs Layer-4 gate, types.rs fields) TCB
A4/A5 — no coercion / deception src/semantic_gate.rs NOT TCB — advisory heuristic
A7 — Mahdavi compass src/compass/ NOT TCB — advisory post-hoc scorer
  • A3: ConsentRecord (ed25519, identity-bound, expiry, revocable). When the
    adapter sets requires_consent, no Permit issues without a valid, unexpired,
    unrevoked consent covering actor+resource+rights, folded into the binding hash.
  • A4/A5: typed SemanticGate trait + CoercionAnalyzer (exit-blocking, HHI,
    deception markers). Returns a verdict; never structurally denies.
  • A7: C(a) = w1*RVD + w2*VOI + w3*CD as a post-hoc scorer that annotates,
    never denies
    . The deny threshold is operator policy, not theory.

Honest scope (no overclaim)

  • The TCB does not verify a consent grantor is the resource's rightful owner —
    that's the L2 trust-root boundary, out of scope by design (documented + tested).
  • Semantic gate is heuristic; a known unicode-homoglyph evasion is tested, not hidden.
  • Compass cannot deny — asserted by test, not a formal proof.
  • TCB surface growth is minimal: engine.rs +28, types.rs +14, call_gate.rs +2.

Tests

cargo test --lib293 passed, 0 failed, including 47 red-team attack tests:
tcb/consent_redteam.rs (18), semantic_gate_redteam.rs (15), compass/redteam.rs (14).

Not in this PR (follow-ups from the 10-week plan)

Lean4 theorems (ConsentRequired, VerifierMonotonicity), Kani harnesses for the
consent path, TLC/Java run, the Constitutional-AI benchmark, and wiring the
semantic gate into CallGate.

🤖 Generated with Claude Code

alexanderthenth and others added 23 commits June 4, 2026 19:12
Engineering unchanged. Adds a code-free reading layer mapping each
Theory-of-Freedom component (axioms, ownership hierarchy, consent,
divine justice, guidance, Mahdavi compass, conflict-by-clarification)
to its file:line in src/, with an honest coverage matrix marking
enforced vs. extension-only vs. documented gaps.
…icy DSL, multi-agent; pragma unreachable branches
Companion to COVERAGE_MATRIX.md, adding the formal-artifact column it omits:
the actual Lean theorem / Kani harness behind each axiom AND its true strength.

Honest findings (no spin):
- A4/A6 are Kani-proven (prop_ownerless_machine_blocked,
  prop_machine_governs_human_blocked); their Lean theorems are `True := trivial`
  stubs.
- A5/A7 attenuation + epoch revocation are real Lean proofs.
- forbidden-flag theorems are real but SHALLOW: they prove "flag set => Blocked"
  (enforcement of a declared flag), NOT detection of coercion/deception.
- verify_deterministic is `:= rfl` (vacuous).
- Consent is Python-only/partial and absent from the Rust TCB; Justice, Guidance,
  and the Mahdavi compass are extensions-only with no proofs.

Conclusion stated plainly: AuthGate is a proven (narrow) Rights *Verification*
Kernel; the book's Rights-based *Decision* Kernel (detect coercion; choose the
most legitimate among permissible actions) is not built and has no formal content.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
47 attack tests across the three Theory-to-Engineering gaps:
- consent_redteam.rs (18): forged grantor keys, pubkey substitution,
  resource/rights swaps, consent-id forgery, revocation bypass, post-seal
  injection/reorder, documented L2 trust-root limit, permit<->valid invariant.
- semantic_gate_redteam.rs (15): exit-block disguise, HHI boundary, case/
  substring/unicode-homoglyph evasion (documented), NaN/negative shares,
  50+ case totality sweep, advisory-never-denies.
- compass/redteam.rs (14): score-gaming, NaN/Inf, zero/negative/huge weights,
  registry poisoning, and the safety proof that the Compass never denies.

Full suite: 293 passed, 0 failed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…verage

- Replace the misleading 'Python layer enforces the same logical invariants
  as the Rust TCB' claim with an honest 'compatibility runtime, not a security
  boundary; bypassable; only the Rust TCB carries guarantees'.
- Add a Theory->Engineering coverage table for the three now-implemented axioms
  (A3 consent = TCB; A4/A5 semantic gate + A7 compass = advisory, NOT TCB),
  each with explicit trust level and no overclaim (notes the L2 owner-binding
  limit; calls the compass 'never denies' an asserted test, not a proof).
- Update the verified Rust lib test count to 293 (incl. 47 red-team tests).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Aliipou Aliipou changed the base branch from nazariye-azadi to main June 11, 2026 06:31
@Aliipou Aliipou closed this Jun 11, 2026
@Aliipou Aliipou reopened this Jun 11, 2026
alexanderthenth and others added 4 commits June 11, 2026 09:32
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The zero-panic clippy gate runs -D warnings over --all-targets; the 8-arg
consent_signed_by test helper tripped clippy::too_many_arguments. Scoped allow
on the test-only helper. Verified clean locally with the exact CI flags.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…, E702)

These test files came in via nazariye-azadi and had never run through main's
ruff gate. Auto-fixed import sorting + unused import; split semicolon
multi-statements (E702) onto separate lines. ruff check src tests now clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Aliipou Aliipou changed the base branch from main to nazariye-azadi June 11, 2026 06:50
@Aliipou Aliipou changed the base branch from nazariye-azadi to main June 11, 2026 06:51
alexanderthenth and others added 4 commits June 12, 2026 00:12
…ayer above)

Explains why AuthGate (authority/enforcement, Rust TCB, crypto) and the Freedom
Decision Kernel (legitimacy/decision, pure Python, no crypto) are separate sibling
repos: legitimacy != authority. FDK decides whether an action is legitimate and
hands the chosen action to AuthGate, which enforces whether the actor is
authorized. Legitimacy first, then authority.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…act)

Lock the responsibility split between the two products and connect them
through ONE serialisable contract, not shared code:

- spec/policy_decision.schema.json: the boundary contract FDK emits
  (verdict ALLOW/DENY/DEFER, action_id, reasons, axiom_trace, fail_closed).
  No 'confidence' field — FDK is a deterministic categorical gate; DEFER
  already expresses 'unsure, ask a human'.
- authgate.integrations.fdk.enforce_legitimacy(): the ~50-line seam. Runs
  the CallGate (capability + scope + signature + TCB) ONLY on an explicit
  ALLOW bound to the same action_id. Fail-closed on DENY, DEFER, fail_closed,
  malformed payload, or action_id mismatch — no path from non-ALLOW to a tool
  call. Imports NO FDK code (the contract is the only coupling).
- tests/test_fdk_bridge.py: golden end-to-end flow + JSON round-trip + every
  non-ALLOW/malformed path, against a real registry/verifier/CallGate. 15
  tests, module 100% covered.
- examples/fdk_authgate_flow.py: decoupled runnable demo (3 outcomes).
- DECISIONS.md: records the contract-not-code boundary decision.

ruff + mypy clean; AuthGate stays the sole source of truth for authority,
FDK only interprets legitimacy.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…hema

Contract-drift guard for the AuthGate half of the hand-synced FDK<->AuthGate
boundary: asserts spec/policy_decision.schema.json's required fields are exactly
what parse_policy_decision enforces, the verdict enum matches, and a fully
populated schema payload parses. A schema change now breaks CI here instead of
silently in production.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ased]

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants