Skip to content

fix: guard alexander/conway/jones — CI hung to GitHub's 6h kill on O(n!) determinant - #82

Merged
hyperpolymath merged 1 commit into
mainfrom
fix/polynomial-crossing-guards
Jul 27, 2026
Merged

fix: guard alexander/conway/jones — CI hung to GitHub's 6h kill on O(n!) determinant#82
hyperpolymath merged 1 commit into
mainfrom
fix/polynomial-crossing-guards

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

Summary

Fixes the defect that has killed every KRL Verification run since KnotTheory#43 merged: the Julia job ran until GitHub's 6-hour job limit and died (reported as cancelled — check job duration, not conclusion, to tell this apart from the repo's routine concurrency cancels).

Root cause

quandle_descriptor computed alexander_polynomial / conway_polynomial / jones_polynomial unguarded. Upstream, Alexander's polynomial-matrix minor determinant is naive cofactor expansion — O(n!) in crossing count — and Conway calls Alexander, inheriting the cost. Measured on s1^n torus closures (the worst case):

crossings alexander time
11 1.2 s
12 12.2 s
13 106 s
16 > 6 h (the CI kill)

Before KnotTheory#43, the braid strand-swap bug made the axioms suite's 16-crossing s1^16 fixture a degenerate, cheap diagram — which is exactly how the missing guards went unnoticed. The upstream correctness fix turned it into a genuine (2,16)-torus-link diagram and exposed the latent performance hole. Guards calibrated against buggy inputs are not load-bearing.

Changes

  • Guards + sentinels (mirroring the existing HOMFLY_MAX_CROSSINGS pattern, same deferred:too_many_crossings sentinel): alexander ≤ 12, conway ≤ 12, jones ≤ 20 (KnotTheory's Kauffman bracket throws above 20; measured a fine 2.8 s at 16 — the throw becomes a sentinel). BR-5's 4–12-crossing fuzz corpus sits entirely below the bounds, so every fuzz-covered descriptor is byte-identical to before.
  • timeout-minutes on all three CI jobs (krl-tests 90, agda 30, tlaplus 15) — a future hang fails in minutes instead of burning 6 h of runner time.
  • New upstream finding, honestly marked: the KT-2 exact-value fixture suite (issue KT-2 extension: wire Jones + Conway + HOMFLY into quandle_descriptor #32) had never actually executed — it merged behind the hang. Its first run caught conway(figure_eight) = -(1 − z²): a genuine sign bug on mixed-sign diagrams (Conway has no legitimate unit ambiguity since ∇(unknot)=1). Marked @test_broken citing KnotTheory#42; data point posted there.
  • Upstream perf issue filed: KnotTheory#46 (proposes Bareiss fraction-free elimination — O(n³) polynomial ops — after which these bounds can be lifted).

Verification (local, Julia 1.12.6, siblings at KnotTheory#43+)

  • Full test_quandle_axioms.jl: completes in minutes (previously: never), all testsets pass, exactly 1 expected Broken (the new conway marker).
  • test_br5_fuzz.jl at CI's 50 trials: all pass, 1 expected Broken (quandle_key order-sensitivity counter, 3/50 — consistent with the known 11/200; KnotTheory#42).
  • The pd_large testset now asserts all four polynomial fields: three sentinels + Jones real (a Jones sentinel would mean someone tightened the bound without re-measuring).

The KRL Verification run on this PR completing at all — in ~30 min instead of dying at 6 h — is the primary acceptance signal.

🤖 Generated with Claude Code

…ed O(n!) determinant

Every KRL Verification run since KnotTheory#43 merged died at GitHub's
6-hour job kill (reported 'cancelled') inside the axioms step. Root
cause: quandle_descriptor computed alexander/conway/jones unguarded,
and KnotTheory's alexander_polynomial evaluates its polynomial-matrix
minor determinant by naive cofactor expansion — O(n!) in crossing
count (measured on s1^n torus closures: 12 → 12s, 13 → 106s, 16 → 6h+).
conway_polynomial calls alexander_polynomial, inheriting the cost.
Before KnotTheory#43, the braid strand-swap bug made the suite's
16-crossing s1^16 fixture degenerate and cheap, which is how the
missing guards passed unnoticed — a correctness fix upstream turned a
degenerate input into a genuine (2,16)-torus-link diagram.

- alexander/conway guarded at 12 crossings, jones at 20 (KnotTheory's
  Kauffman bracket throws above 20; measured 2.8s at 16 — the throw
  becomes a sentinel). Same 'deferred:too_many_crossings' sentinel as
  the existing HOMFLY guard. BR-5's 4-12-crossing corpus is entirely
  below the bounds, so fuzz-covered descriptors are unchanged.
- timeout-minutes on all three CI jobs (krl-tests 90) so a future hang
  fails in minutes, not 6 hours of runner time.
- The KT-2 exact-value fixture suite (issue #32) had never actually
  executed — it merged behind the hang. First run caught
  conway(figure_eight) = -(1 - z²): a genuine upstream sign bug on
  mixed-sign diagrams (KnotTheory#42 — Conway has no legitimate unit
  ambiguity since ∇(unknot)=1). Marked @test_broken citing #42.
- Upstream perf issue filed: KnotTheory#46 (proposes Bareiss
  fraction-free elimination, O(n^3) polynomial ops).

Validated locally (Julia 1.12.6, sibling checkouts at KnotTheory#43+):
full axioms suite completes in minutes, all pass, exactly 1 expected
Broken (the conway marker); BR-5 fuzz at CI's 50 trials green with its
1 expected Broken (quandle_key order-sensitivity, #42).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@hyperpolymath
hyperpolymath marked this pull request as ready for review July 27, 2026 13:03
@hyperpolymath
hyperpolymath merged commit 4382e8a into main Jul 27, 2026
21 checks passed
@hyperpolymath
hyperpolymath deleted the fix/polynomial-crossing-guards branch July 27, 2026 13:30
hyperpolymath added a commit that referenced this pull request Jul 28, 2026
…s 12 → 128 (unblocks red main) (#85)

## Summary

**`main` is currently red and this unblocks it.** KnotTheory.jl#48
merged, so quandledb's `@test_broken` on `conway(figure_eight)` now
reports **"Unexpected Pass"** — a hard error, and precisely the forcing
signal the marker existed to produce. Reproduced locally against
KnotTheory `a2f2938`.

### 1. Conway marker → hard assertion

Upstream now normalises Alexander to **Δ(1) = +1** (the Conway
normalisation) instead of "leading coefficient positive", which was the
wrong canonical choice on mixed-sign knots. `conway(figure_eight)` = `1
− z²` exactly, so the assertion is restored.

### 2. Alexander/Conway bounds: 12 → 128

The bound of 12 in #82 was calibrated against the **O(n!)** cofactor
determinant that #48 replaced with **O(n³)** Bareiss elimination.
Re-measured on `s1^n` torus closures (the worst case — no arc merging):

| crossings | alexander, Bareiss | alexander, cofactor (before) |
|---|---|---|
| 16 | ~0 s | **> 6 h** (the CI kill) |
| 40 | 0.07 s | — |
| 100 | 0.10 s | — |
| 140 | 0.61 s | — |

128 keeps the worst case sub-second while covering every realistic
diagram. **Jones (20) and HOMFLY (15) are unchanged** — those are
genuinely exponential (Kauffman bracket 2ⁿ; skein recursion), and their
bounds come from upstream's own limits.

### 3. Guard testset reworked

With the three bounds now an order of magnitude apart, one diagram can
no longer exercise them all — the old single-fixture test would have
silently stopped testing the alexander/conway guard. It now covers:

- **16 crossings** — only HOMFLY defers; alexander, conway and jones
must all be *real* values.
- **130 crossings** — all four defer, with an explicit `@test
length(pd.crossings) > ALEXANDER_MAX_CROSSINGS` so that raising the
bound without raising the fixture fails loudly instead of going quiet.

## Verification

Full axioms suite against KnotTheory `a2f2938`: passes with **zero
broken markers** — a first for this suite.

## Note on the BR-5 fuzz residual

Re-measured at 200 trials: **still exactly 11/200**, unchanged by #48.
My expectation that the sign fix would shrink it was **wrong** — the
mismatches are not caused by the alexander/conway sign convention. A
component-level diagnostic is running to identify the actual cause; the
`@test_broken` counter marker stays until that is known, and the finding
will be posted to KnotTheory#42 (and appended here if it changes
anything in this PR).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Fable 5 <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.

1 participant