Skip to content

fix: make D17 gap-rate consistency dimension-coherent (#69) - #79

Merged
marcohost33-maker merged 2 commits into
mainfrom
fix/69-d17-gap-rate-coherence
Jul 4, 2026
Merged

marcohost33-maker merged 2 commits into
mainfrom
fix/69-d17-gap-rate-coherence

Conversation

@marcohost33-maker

@marcohost33-maker marcohost33-maker commented Jul 4, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes #69. D17 gap-rate consistency was dimensionally incoherent: it compared the relative-entropy fit rate beta_D directly with the spectral gap Delta, so a metric multiplier contaminated the number and made the A1 "gap-controlled" label unreachable for every system (feeding the #68 problem).

The physics (empirically verified, not assumed)

Near the steady state pi, write rho(t) = pi + delta(t), delta ~ e^{-Delta t}.

  • Linear distance metrics (trace distance, 1-F) decay at the bare mode rate Delta.
  • Relative entropy D(rho||pi) is the wrong dimension: its gradient vanishes at the minimiser pi, so for a faithful (full-rank) pi it is quadratic in delta -> decays at 2*Delta. For a rank-deficient pi the null-space-leakage term -Tr rho log pi is linear -> decays at 1*Delta.

The factor is regime-dependent, NOT a universal 2 — this is exactly why option (2) (hardcode 2*Delta) would be wrong. Measured decay-rate ratio r_D / r_Td (relative-entropy rate / trace-distance rate) across V1-V5, and the full-pipeline metric multiplier m = beta_D / beta_D_linear:

System rank(pi) r_D/r_Td (tail) pipeline m
V1 qutrit 3 (faithful) 1.99 2.01
V2 dephasing 2 (faithful) 2.00 2.16
V4 thermal 2 (faithful) 2.00 1.92
V3 amp-damp 1 (rank-def.) 1.08 1.05
V5 JC 1 (rank-def.) 1.06 1.05

m ~ 2 for faithful pi, m ~ 1 for rank-deficient pi — clean split, matching theory. (There is also a second, independent confounder — the initial state can skip the slowest spectral mode; that is a genuine non-gap-controlled signal D17 must keep, and it does.)

Chosen option — (3), explicit + dimension-coherent

Option (2) (compare to 2*Delta) hides a regime-dependent factor and is wrong for rank-deficient pi. Instead:

  • D17 now uses beta_D_linear = dominant rate of the linear trace-distance curve (LIOU-F-018), fit with the same M0-M3b/AICc machinery. A linear metric always decays at the bare mode rate, so beta_D_linear is dimension-coherent with Deltaregime-independent, no discontinuous rank heuristic.
  • The relative-entropy beta_D (headline relaxation rate) and the entire fit/bootstrap/anchor pipeline are untouched.
  • The factor is made explicit and auditable: the evidence dict now carries beta_D, beta_D_linear, gap, and d17_metric_multiplier = beta_D/beta_D_linear. Nothing is hidden.
  • A strong-gap-controlled early branch (D17 < 0.05 AND the observable relaxation is a single exponential) lets a genuine textbook system earn A1/F1, overriding the relative-entropy-shape-driven M2/A5 branch (that curve's quadratic-metric curvature can prefer a bi-exponential even for single-mode dynamics).

Verdict changes (full pipeline, bootstrap_B=30, seed=42)

System Delta D17 old D17 new a_class old->new
V1 qutrit 0.280 2.689 0.832 A5 -> A5 (unchanged)
V2 dephasing 0.250 3.315 1.000 A11/F4 -> A11/F4 (unchanged)
V3 amp-damp 0.250 1.096 1.000 A5 -> A5 (unchanged)
V4 thermal 0.541 1.202 0.146 A5 -> A5 (unchanged)
V5 JC 0.250 0.088 0.131 A11/F4 -> A11/F4 (unchanged)
gap-controlled reference (new) 0.800 1.039 0.000 (was unreachable) -> A1/F1 CONFIRMED

No V1-V5 mechanism label changes — none of them is a single-mode gap-controlled system (they mode-skip or are Mpemba/multi-timescale), which is the honest outcome. Only the D17 number is corrected (dimensionally deflated). A1 is now reachable: the new textbook reference (faithful pi, fast dephasing so the population mode is the gap, diagonal initial state overlapping it) earns A1/F1. A1 thresholds unchanged (0.05 / 0.20) — the dimension correction did not require moving them.

Test plan

  • ruff check src tests benchmarks -> exit 0
  • mypy src/liouscope -> Success, 50 files
  • pytest tests/test_anchors.py -v -> 21 passed (anchors pin D16, not D17 — untouched)
  • pytest --cov=liouscope --cov-fail-under=80 -> 442 passed, coverage 94.39%
  • pytest -m qutip (cross-check) -> 8 passed
  • python .github/scripts/check_workflow_hardening.py -> exit 0; check_claim_safety.py -> exit 0
  • python examples/quickstart.py -> smoke OK
  • New tests/test_validation_systems/test_d17_gap_coherence.py -> 20 passed (e2e V1-V5 dimension-coherence + faithful/rank-deficient multiplier split + gap-controlled reference reaches A1 + old-formula-would-have-failed regression). This is the end-to-end classification coverage that was previously absent (only synthetic evidence dicts existed).

Notes

  • Anchor regressions (sacred gate): untouched — test_anchors.py pins D16 lep_proximity, not D17; all 21 green.
  • CITATION.cff: not bumped — it tracks tagged releases (0.5.0, date-released 2026-06-25); this is an [Unreleased] change, consistent with the other [Unreleased] methodology entries (D21-D23, claim gates) which also did not touch it. CITATION bump belongs to the next release gate.
  • MANIFEST_SCHEMA: not touched (run-manifest contract unchanged; new fields are additive result-object fields, not manifest fields).
  • Backup-First / 2026-05-16 incident: no branch/history-touching ops in this PR (new branch + additive commit only).

Draft until Equalita (+ Cross-Family, HIGH / canonical physics) verify. Do not merge on CI alone.

🤖 Generated with Claude Code

D17 was |beta_D - Delta| / Delta, comparing the RELATIVE-ENTROPY fit rate
beta_D directly with the spectral gap Delta. Relative entropy near the steady
state pi is quadratic in (rho - pi) for a faithful (full-rank) pi -> decays at
2*Delta; for a rank-deficient pi the null-space-leakage term is linear ->
decays at 1*Delta. That metric multiplier m in {1,2} (empirically 2.0 for
faithful pi V1/V2/V4, 1.05 for rank-deficient pi V3/V5) inflated D17
(dephasing ~3.3, amp-damp ~1.1) and made the A1 "gap-controlled" label
unreachable for every system.

Fix: D17 now uses beta_D_linear, the dominant decay rate of the LINEAR
trace-distance curve (LIOU-F-018), fit with the same M0-M3b/AICc machinery.
A linear distance metric decays at the bare mode rate, so it is
dimension-coherent with Delta. The relative-entropy beta_D (headline rate) and
the fit/bootstrap/anchor pipeline are untouched. The classifier exposes beta_D,
beta_D_linear, gap and the implied multiplier d17_metric_multiplier in the
evidence dict (explicit + auditable), and a strong-gap-controlled early branch
(D17<0.05 AND single-exponential linear fit) lets a genuine textbook system
earn A1/F1. No V1-V5 mechanism label changes; only the D17 number is corrected.

- RelaxationResult.beta_D_linear/linear_fit_model, LepResult.beta_D_linear
  (additive, defaulted -> serialised reports stay valid)
- compute_lep_layer(beta_D=) -> (beta_D_linear=); gap_rate_consistency param
  beta_D -> rate (both internal)
- new tests/test_validation_systems/test_d17_gap_coherence.py (14 e2e tests;
  previously classification had only synthetic-evidence unit tests)

Anchor regressions untouched (test_anchors.py pins D16, not D17).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@marcohost33-maker marcohost33-maker added the agent:claude PR authored by Claude Code label Jul 4, 2026
…69)

Equalita #79 adversarial review found two blocking issues; both valid.

Befund 1 (regression risk, #68 class): the new A1 early-branch fired BEFORE
the F1-F5 gap-failure families. gap_rate_consistency + linear_fit_model come
from the initial-state-DEPENDENT trace-distance curve, whereas
pseudospectral_radius/henrici/trans_amplitude/kreiss/petermann are
operator-INTRINSIC. A strongly non-normal phantom/skin operator with an rho_0
exciting only the slow gap mode yields a clean single-exp at the gap rate and
would have been mislabelled A1/F1 CONFIRMED/PUBLICATION_GRADE, shadowing the
true A10/F5 (or A4/F2) mechanism.

Fix (Option b, cleaner): move the A1 early-branch to AFTER F5/F1/F2/F3 and
only BEFORE the relative-entropy-SHAPE branches (M2/M3a/M3b) -- exactly the
stated intent (A1 priority over the shape branches) without shadowing the real
non-normality families. A1 "gap-controlled" is awarded only when no gap-failure
family fires. Verified: constructed d=4 non-normal phantom ladder (henrici 4.2,
pseudospec 2.15 > 2*gap_to_gns 2.0) with a slow-mode-aligned rho_0 (D17=0.0000,
single-exp) is now classified A10/F5, not A1.

Befund 2 (test gap): the "no V1-V5 label change" claim was unpinned. Added
end-to-end a_class golden asserts for V1-V5 (full pipeline). Measured on main
(baseline 3fef6a1) vs this branch: IDENTICAL -- V1 A5, V2 A11, V3 A5, V4 A5,
V5 A11. No flip. Claim now golden-pinned.

- tests/test_classification.py: +3 synthetic ordering regressions
  (A1-early reached when no gap-failure; A1-early does NOT shadow F5 phantom;
  ...does not shadow F2 skin)
- tests/test_validation_systems/test_d17_gap_coherence.py: +V1-V5 a_class
  golden (5) + adversarial non-normal-phantom shadow test (1) -> 20 tests total

Local CI chain green: ruff pass, mypy 50 files, anchors 21, full+cov 450
passed / 94.39%, qutip 8.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@marcohost33-maker

Copy link
Copy Markdown
Owner Author

Equalita #79 review — both blocking findings addressed (commit 723ee50)

Befund 1 (shadowing, #68 class) — Option b (reorder), chosen for cleanliness.
The A1 early-branch now runs after the F1-F5 gap-failure families and only before the relative-entropy-SHAPE branches (M2/M3a/M3b). Rationale: gap_rate_consistency + linear_fit_model come from the initial-state-dependent trace-distance curve, whereas pseudospectral_radius/henrici/trans_amplitude/kreiss/petermann are operator-intrinsic. A1 "gap-controlled" is awarded only when no gap-failure family fires — so a fine-tuned rho_0 can no longer make a phantom/skin operator self-certify as gap-controlled. (Reorder preferred over the extra-gate Option a: it realizes the stated intent — A1 over the shape branches — without special-casing.)

Adversarial construction (physical, now a test): d=4 directional-ladder phantom, henrici=4.20, pseudospectral_radius=2.15 > 2*gap_to_gns=2.00 (F5 fires), with a slow-mode-aligned rho_0 giving D17=0.0000, d17_linear_single_exp=1.0 (A1-early condition met). Result: A10/F5, not A1. With the old ordering it would have been A1/F1 CONFIRMED.

Befund 2 (unpinned claim) — V1-V5 a_class golden-pinned end-to-end.
Measured full pipeline (bootstrap_B=30, seed=42) on main baseline 3fef6a1 vs this branch:

System main a_class branch a_class
V1 qutrit A5 A5
V2 dephasing A11 A11
V3 amp-damp A5 A5
V4 thermal A5 A5
V5 JC A11 A11

No flip. The "no label change" claim is now pinned by test_v_systems_mechanism_label_golden. (Note: the reorder was applied first, per the requested order — it did not change whether V2/V4 flip; they never flipped, because they hit the F4/shape branches before the A1 branch either way.)

New tests: test_classification.py +3 synthetic ordering regressions (test_a1_early_branch_reached_when_no_gap_failure_family, test_a1_early_branch_does_not_shadow_f5_phantom, test_a1_early_branch_does_not_shadow_f2_skin); test_d17_gap_coherence.py +V1-V5 golden (test_v_systems_mechanism_label_golden, 5) + test_phantom_with_gap_matched_rho0_is_not_mislabelled_a1 (1) -> 20 tests in that module.

Local CI chain (identical to workflows): ruff pass · mypy 50 files · anchors 21 · full+cov 450 passed / 94.39% · qutip 8. Real numbers. Not merged — awaiting Equalita re-verify + Cross-Family.

@marcohost33-maker
marcohost33-maker marked this pull request as ready for review July 4, 2026 16:51
@marcohost33-maker
marcohost33-maker merged commit fda7442 into main Jul 4, 2026
13 checks passed
@marcohost33-maker
marcohost33-maker deleted the fix/69-d17-gap-rate-coherence branch July 4, 2026 16:51

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 723ee5005f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

# check (D17) must use. (_dominant_rate is fail-closed: it returns nan if
# every model fit fails, so D17 then reads "unknown" rather than a spurious
# match.)
beta_D_linear, linear_fit_model = _dominant_rate(t_grid, trace_distance_curve)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Treat zero trace-distance curves as undefined

When rho_initial is already the steady state (or the trace-distance curve is otherwise all numerical zero), this still sends a no-signal curve through the fitter. The exponential parameters are then underdetermined and the rate stays at a seed value (e.g. 1.0 or 0.001), so beta_D_linear, D17, and any downstream A1 evidence are fabricated rather than marked unknown. Please short-circuit near-zero trace-distance curves to (nan, "none") before fitting.

Useful? React with 👍 / 👎.

Comment on lines +147 to +150
if (
ev.get("gap_rate_consistency", float("inf")) < 0.05
and ev.get("d17_linear_single_exp", 0.0) > 0.5
):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Require M1 offsets to be negligible before A1

When the trace-distance fit wins M1, the curve is A exp(-alpha t) + C, so a real nonzero offset/plateau is not a single exponential relaxation to the supplied steady state. In contexts with a non-primitive Liouvillian or a caller-supplied steady state that is not the attracting component, gap_rate_consistency < 0.05 plus an M1 plateau can now award A1/CONFIRMED even though the observable distance does not decay to zero; either restrict this early branch to M0 or store/check that the M1 offset is numerically negligible.

Useful? React with 👍 / 👎.


def gap_rate_consistency(beta_D: float, gap: float) -> float:
"""D17: ``|beta_D - Delta| / Delta``. Returns inf if gap is zero."""
def gap_rate_consistency(rate: float, gap: float) -> float:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Update citation metadata for D17 methodology change

This change redefines D17 from comparing the relative-entropy rate to comparing a trace-distance rate, which is a methodology/results change. The repository instructions in AGENTS.md state that “changes touching results or methodology must update CITATION.cff,” but this commit has no CITATION.cff diff, so the public citation metadata will lag the reported diagnostic semantics.

Useful? React with 👍 / 👎.

marcohost33-maker added a commit that referenced this pull request Jul 7, 2026
…gap certificate (#80) (#90)

The A1 early branch awarded CONFIRMED/PUBLICATION_GRADE (0.95) whenever
gap_rate_consistency < 0.05 + single-exp held and none of the F1-F5
thresholds fired -- resting a publication-grade claim on the unprovable
exhaustiveness of the threshold set (residual flagged independently by both
#79 reviewers). A weakly-non-normal gap failure below all thresholds with a
single-exp-at-gap trajectory would have self-certified.

Fix (issue #80 to-do 2, burden of proof reversed):
- new evidence key sym_gap_corroborated: 1.0 iff a MEASURED symmetrised gap
  shows no F3-grade reduction (certified GNS gap_to_gns_ratio <= 1.2, or
  KMS gap_to_kms_ratio <= 1.2), fail-closed on floored/uncertified gaps
- A1 confidence: 0.95 only with the certificate; uncorroborated A1 caps at
  0.70 -> CANDIDATE/CONFIRMATION
- gap_to_kms_ratio graduates from advisory (#89) to class-influencing;
  an F3 veto off it stays deferred to its own FP study

Anchor-preserving: the gap-controlled thermal reference has
Delta_GNS = Delta_KMS = Delta exactly (stays 0.95/CONFIRMED); V1-V5 golden
labels (A5/A11) never take the A1 confidence path. New synthetic adversary,
KMS-certificate and double-floored fail-closed tests.

Gates: pytest 489 passed (anchors 21/21 incl. QuTiP), ruff clean, mypy clean.
claim_status: pending until cross-family review confirms the semantics.


Claude-Session: https://claude.ai/code/session_01BuG9j9cRJ6x6QMuYk7vXdx

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

Labels

agent:claude PR authored by Claude Code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

D17 gap-rate consistency compares a relative-entropy rate (~2Δ) to Δ — the A1 "gap-controlled" label is effectively unreachable

1 participant