Skip to content

fix: adversarial inputs of the public API are refused early or answered on both kernel paths - #41

Merged
SMI-Lab-Inha merged 8 commits into
devfrom
fix/input-validation-020
Nov 20, 2026
Merged

SMI-Lab-Inha merged 8 commits into
devfrom
fix/input-validation-020

Conversation

@SMI-Lab-Inha

@SMI-Lab-Inha SMI-Lab-Inha commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

Summary

An adversarial probe of the public API before 0.2.0: about 320 cases over the cable YAML (every numeric field of every layer of the bundled 33 kV single-core cable set to 0, negative, NaN, inf, a string or removed; lay angles 0 to 89.99°; 1 to 10 000 wires), compute_fatigue (zero, constant, one-sample, 200 000-sample, NaN/inf, mismatched, 2-D, integer and list histories; μ = 0 to 1e6; every option), compute_mkappa, compute_neutral_axes, export_bending_law, compute_thermal, the sea-state batch options and both CSV readers (CRLF, BOM, blank rows, exponent forms, short rows, non-monotonic time, UTF-16, Latin-1), each with and without the compiled kernels. Every case either gave a finite answer or a CableXSec error naming the input, except the ones below, which are fixed here with a test each (tests/test_robustness_inputs.py).

Input Before Now
compute_fatigue(..., mu=1e6) compiled kernels: stuck answer; reference kernels (CABLEXSEC_DISABLE_NUMBA=1): CableInputError: wire history exceeds floating-point range both: the stuck answer, equal to mu = 1 to 1e-12
compute_mkappa(..., mu=1e6) CableInputError: wire history exceeds floating-point range on both paths the stuck loop: on the 33 kV template it equals the loop at mu = 100, where the friction-limited wires already stick, slip fractions included
symmetric fibres of equal damage phi_critical_deg 63° with numba, 243° without (argmax of a round-off difference) the first of the values within 1e-12 of the largest, on both paths
compute_thermal(n_cores=0) ZeroDivisionError CableInputError naming n_cores (also 1.5, True)
compute_thermal(current_A=-1), ambient_C=-300, conductor_temp_C=-274 accepted refused (negative current, below absolute zero)
thermal_network(ambient_C=nan), ambient_C=-400, n_cores=1.5; steady_state(-600), transient(..., ambient_C=-280) a network of NaN temperatures; accepted refused, naming the input
export_bending_law(n_points=20.5) numpy TypeError CableInputError
a bad value in a cable layer ValidationError titled tagged-union[function-after[...HelicalLayer]...], located helical.d_wire_m titled layer 6 'inner_armour' of cable.yaml, located layers.6.helical... (still pydantic.ValidationError, as documented)
read_series_csv of a UTF-16 or Latin-1 file UnicodeDecodeError CableSchemaError
read_series_csv with a row of spaces or commas CableSchemaError skipped as a blank row
a CSV cell 1_0 (either reader) read as 10 refused, naming the line
SeaStateBatchOptions(exposure_years=0, design_fatigue_factor=0.5, n_fibres=2, chunk_rows=4, mu=-0.1) checked only after every run had been read and evaluated refused at construction
SeaStateRun(line_id=0) or True accepted refused

Details

Capstan overflow. wire_slip_stress_bounds forms the tension bound σ₀ g expm1(μ |sin α| ψ). For μ = 1e6 the exponent overflows; the compiled bounds (fast_slip) return inf and the wires stick, the reference path raised on the overflow. The reference bound is now held at 1e300 Pa, a bound no wire stress reaches, so both paths stick. The damage of the probe history at μ = 1e6 equals that at μ = 1 (where the wires already stick on that history, at 200 kN) on both paths. The compute_mkappa loop, which raised on both paths before, equals the loop at μ = 100 on the 33 kV template at 100 kN. Before dev 7e14481 (#39) it also equalled the loop at μ = 1. Since the Yun shear stack stops at the layer's support, the wires slip at μ = 1 on that loop, so the test compares with μ = 100.

Ties. compute_fatigue takes the critical fibre per wire, the critical wire per layer and the critical layer with _first_maximum: the first index whose value is within 1e-12 × |max| of the maximum (_TIE_RTOL). Damage is unchanged; only the reported location of a tie is now deterministic across kernel paths.

Not changed (intended). compute_neutral_axes returns NaN directions and offsets where they are undefined (documented). A round-wire layer that overfills its radius (n_wires = 10000) warns (WireFillWarning, documented, kept for the pinned legacy definitions). compute_fatigue on a constant curvature with the distributed model gives 1e-58 damage with the compiled kernels and 0 without (round-off cycles of an iterative solve; the reported critical angle of an all-zero damage is not meaningful).

Gates

On 01322d0 (dev caca014 merged in: #40, #42, #43, #46, #48, #49):

  • pytest (full suite, venv with the CI wheels, NUMBA_NUM_THREADS=1): 4822 passed, 4 skipped.
  • With CABLEXSEC_DISABLE_NUMBA=1: 4706 passed, 120 skipped.
  • python -m mypy: no issues in 119 source files. ruff check and ruff format --check on src tests examples validation release doc: clean.
  • Taxonomy (from the --collect-only IDs per marker): no marked test added; counts unchanged (1248 / 77 / 59).
  • The merge with dev conflicted in sea_state_batch.py: this PR's early option checks and dev's curvature_check_* checks in SeaStateBatchOptions.__post_init__. Both are kept.

…ed on both kernel paths

An adversarial probe of the public API (cable YAML, compute_fatigue,
compute_mkappa, compute_neutral_axes, export_bending_law, compute_thermal,
the sea-state batch, the CSV readers; edge and invalid values, with and
without the compiled kernels) found:

- mu = 1e6 overflowed the capstan factor of the reference return map ("wire
  history exceeds floating-point range") while the compiled kernels held the
  wires stuck. The reference bound is now held at a value no wire stress
  reaches, so both paths give the stuck answer, that of mu = 1.
- The critical fibre, wire and layer were an argmax over values equal to
  round-off at symmetric fibres: 63 deg on one kernel path, 243 deg on the
  other. Values within 1e-12 of the largest are a tie, won by the first.
- compute_thermal took a negative current and temperatures below absolute
  zero, and n_cores = 0 divided by zero.
- export_bending_law raised numpy's TypeError for a fractional n_points.
- A layer's schema error was titled with the union of every layer kind and
  located within the kind; it now names the layer, its index and the file.
- read_series_csv raised UnicodeDecodeError on a file that is not UTF-8 and
  stopped on a row of spaces; both CSV readers took 1_0 as 10.
- SeaStateBatchOptions left n_fibres, chunk_rows, mu, exposure_years and
  design_fatigue_factor to be checked after every run had been evaluated;
  SeaStateRun did not check line_id.

Signed-off-by: Jae Hoon Seo <jaehoon.seo@inha.ac.kr>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-19T23:47:16.662053Z 01322d0 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@SMI-Lab-Inha

Copy link
Copy Markdown
Owner Author

@codex review

@read-the-docs-community

read-the-docs-community Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Documentation build overview

📚 CableXSec | 🛠️ Build #36028154 | 📁 Comparing 01322d0 against latest (240bf9c)

  🔍 Preview build  

24 files changed · ± 24 modified

± Modified

@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: 3f0c9d1355

ℹ️ 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".

Comment thread src/cablexsec/io/series.py Resolved
A row of separators with more cells than the header put the surplus cells
under None as a list, and the blank-row check raised AttributeError on it.
Such a row is skipped when every cell is blank and refused with
CableSchemaError, naming the line, when a surplus cell holds a value.

Signed-off-by: Jae Hoon Seo <jaehoon.seo@inha.ac.kr>
@SMI-Lab-Inha

Copy link
Copy Markdown
Owner Author

@codex review

@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: 7b739149bc

ℹ️ 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".

Comment thread src/cablexsec/io/series.py Resolved
Both CSV readers split the text into lines before the CSV parser saw it, so
a quoted cell holding a newline had its parts joined ("1" and "0" read as
10). They now parse a newline-preserving stream and refuse such a cell.

Signed-off-by: Jae Hoon Seo <jaehoon.seo@inha.ac.kr>
@SMI-Lab-Inha

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 3cc81cb4b3

ℹ️ 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".

… fractional core count

thermal_network built a network of NaN temperatures from a NaN ambient and
took an ambient below absolute zero and n_cores = 1.5; its steady, transient
and matrix states took negative currents and such ambients. They are refused
as compute_thermal refuses them; the core count check is shared.

Signed-off-by: Jae Hoon Seo <jaehoon.seo@inha.ac.kr>
@SMI-Lab-Inha

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 83bbf306da

ℹ️ 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".

Signed-off-by: Jae Hoon Seo <jaehoon.seo@inha.ac.kr>
@SMI-Lab-Inha

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: e22ebe45a2

ℹ️ 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".

After the Yun shear stack of an armour layer stops at its support (dev
7e14481), the 33 kV template's wires slip at mu = 1 on this loop, so it is
no longer the stuck reference. At mu = 100 the friction-limited wires stick
and the loop equals the mu = 1e6 one exactly on both kernel paths, slip
fractions included; the test compares with it.

Signed-off-by: Jae Hoon Seo <jaehoon.seo@inha.ac.kr>
@SMI-Lab-Inha

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: c6dd33bdd4

ℹ️ 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".

Signed-off-by: Jae Hoon Seo <jaehoon.seo@inha.ac.kr>
Signed-off-by: Jae Hoon Seo <jaehoon.seo@inha.ac.kr>
@SMI-Lab-Inha

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: 01322d0d80

ℹ️ 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".

@SMI-Lab-Inha
SMI-Lab-Inha merged commit e74e01f into dev Nov 20, 2026
14 checks passed
@SMI-Lab-Inha
SMI-Lab-Inha deleted the fix/input-validation-020 branch November 20, 2026 01:04
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