# SFT Tools (Data → Target → Certificate)

This folder contains lightweight tools that support the SFT III workflow:

- `infer_target_two_cycle.py` : infer affine diagonal coupling b ≈ α a + Ψ (mod P) and decide CST vs full torus.
- `infer_degree_from_loop.py` : compute degree from sampled loop phases (unwrapping).
- `build_wsc_from_data.py` : build a WSC JSON using declared assumptions, inferred target, inferred witness integer, and stability margins.

These tools are  conservative: they do not over-claim and will emit a WOB stub when inference is inconclusive.

- `infer_target_integer_matrix.py` : infer small-integer matrix constraints $Ay\approx\Psi$ (mod $P$) in $\mathbb{T}^k$, emitting:
  - a **CST declaration** with `rank_r`, residual statistics, and a quantitative `stability_margin_*`, or
  - a **full torus declaration** with an explicit gap to the best small relation in the declared search, or
  - a **WOB obstruction** when inference is ill-posed at the declared tolerance (e.g. `WOB-14-insufficient-excitation`, `WOB-13-ambiguity`, or `WOB-15-resonance-masking`).
