Skip to content

fix: resolve issue 566 Phase 0 soundness and blocking panic audit (PR1) - #589

Merged
shinaoka merged 59 commits into
mainfrom
audit/issue-566-remediation
Aug 10, 2026
Merged

fix: resolve issue 566 Phase 0 soundness and blocking panic audit (PR1)#589
shinaoka merged 59 commits into
mainfrom
audit/issue-566-remediation

Conversation

@shinaoka

Copy link
Copy Markdown
Member

Summary

Resolves issue #566 Phase 0 (soundness hotfixes) and the Phase 1
blocking library-panic audit. Implements PR 1 of
docs/superpowers/plans/2026-08-08-issue-566-pr1-soundness-ci.md (Tasks 1–8)
plus the Task 13 integration round (sync, dual review, full validation).

Phase 0 soundness fixes (issue #566)

  • Matrix invariants (tensorbackend): checked shape products in all
    constructors; axis-checked Index/IndexMut (no more m[[3,0]] aliasing
    m[[1,1]]); multiplication output shape validated before the backend call.
  • RRLU (tcicore): real validation at the rrlu/rrlu_inplace entry,
    no longer debug-only; matrixluci block shape products checked.
  • Quanticstci: coordinate-conversion failures propagate instead of
    silently injecting V::default(); empty discrete grids error instead of
    panicking; invalid initial pivots surface as errors.
  • C API (capi): checked dimension products, isize::MAX byte bounds on
    raw slices and index-pointer arrays, and metadata-before-allocation for
    structured/diagonal constructors (new Storage::validate_structured_metadata
    seam — no duplicated validation).
  • HDF5: file-derived integers validated with dataset context; allocation
    only after child-group consistency; constant-space attribute lookup.
  • Quantics transform: checked_multivar_dims shared by all multivariable
    operators; no unchecked 1 << nvariables remains.

Phase 1: blocking, source-aware panic audit

  • scripts/audit-library-panics.py + tools/library-panic-audit are wired
    into CI as a blocking gate (self-test + audit steps).
  • Compiler-backed raw diagnostics (panic/unreachable/unwrap/expect) plus a
    reviewed public-path assertion baseline (assert/assert_eq/assert_ne/
    debug_assert variants; 23 entries, stale entries fail, raw entries can never
    be baselined).
  • Always-on release test job restored in CI_rs.yml (uses the ci cargo
    profile from build: drop full debug info from default profiles #581Reduce CI build artifact size #587 to keep CI artifacts small) and added to the rollup.

Task 13 integration

Recorded decisions (see worklog)

  • CI_rs_selfhost.yml retired (repo-owner-authored commit; it only ran a
    subset of the restored test job and its self-hosted runner was never active).
  • The assertion scanner covers public functions/methods and trait impls;
    private-helper assertions are classified outside that surface per the plan's
    scanner design (documented in tools/library-panic-audit/src/audit.rs;
    extending to all functions is a PR 2 candidate).
  • _comment_tooling coverage rationale pins the panic-audit tool files (they
    are exercised deterministically by subprocess self-tests that llvm-cov
    cannot attribute); treetn/dmrg release-only deficit is pre-existing and
    deferred to Task 12.

Out of scope (later PRs)

Tasks 9–12 (incremental API-doc/crate-boundary gates, doctest/kryst cleanup,
debris deletion, release-coverage switch), the shared-rules prerequisite
tensor4all-agent-rules#6, and the remaining Phase 1–5 backlog.

shinaoka added 30 commits August 9, 2026 02:09
shinaoka added 20 commits August 9, 2026 21:33
Sources are resolved per Make rule against the exact artifact output; an
unrelated rule can no longer satisfy an artifact's source validation.
Nested macro_rules! definitions inside a transcriber are recognized so
their matcher patterns (a name, not a call) are excluded while real
transcriber invocations are still reported.
…isapprox rejection

Also correct the norm_squared doc: the LASSQ accumulation is inherently
nonnegative, so the stale finite-negative-roundoff clamp claim is removed.
- All Materialized scaling now converts only the compact payload and returns
  compact storage, so untracked scaling no longer traverses unreferenced
  strided-gap backing entries (drops the whole-backing Storage::scale path).
- to_dense_*_col_major_vec reject logical-dim product overflow instead of
  silently returning an empty buffer.
- Regression tests: untracked strided structured scale stays compact,
  dense overflow fails closed, unmatched support in both operand orders,
  exact-mode and structured-payload NaN rejection, zero-vs-nonzero rtol.
…ssion

- StructuredStorage::logical_dense_col_major_vec now returns StorageResult
  and fails closed on logical-dim product overflow through
  checked_logical_len; the two Storage to_dense_* wrappers propagate it.
- The untracked structured-scale regression now uses genuinely gapped
  storage (strides [3,1], five backing entries with an unreferenced gap)
  and asserts the result collapses to Dense compact storage with the
  correct referenced values, so reintroducing the whole-backing scale
  path (which preserved the gap as Structured storage) fails the test.
  Correct expected payload order for the strided offsets.
…iation

# Conflicts:
#	.github/workflows/CI_rs.yml
#	.github/workflows/CI_rs_selfhost.yml
- matrix: reject overflowing multiplication output before backend call
- quanticstci: reject empty discrete grid size instead of panicking
- capi: bound index-pointer array byte length; validate structured/diag
  payload lengths against metadata before copying
- tcicore: use checked block shape products in matrixluci sources
- scanner: recognize assert_eq/assert_ne/debug_assert_eq/debug_assert_ne;
  reviewed baseline grows from 14 to 23 entries
- self-test: cover comment/rustdoc exclusion, private-helper classification,
  and stale-baseline failure
The fallible TensorVectorSpace surface (norm_squared/norm/maxabs/isapprox)
had dropped core/src/tensor_like.rs below the 75% CI gate (75.2% -> 70.0%).
NaN-input tests exercise the trait error propagation for TensorDynLen, and a
BlockTensor test exercises the trait-default isapprox (sub mismatch and NaN
norm failure). Debug coverage restored to 80.6%; 207/207 files pass.

Also gitignore .pi-subagents/ session infrastructure (it tripped the
repository-rules-review sensitive-diff scan) and pin the panic-audit tool
coverage with _comment_tooling rationale for Task 12.
@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown

Repository rules review

Repository rules review (32852babf0873a8a68da47baa35463208af98d63...62ddc3204b43c299a958fdcd1c4763cb4a83adcc)
Verdict: pass
Findings:
- [warn] llm-skipped (External LLM Review) <unknown>: External LLM review was skipped
  Skipped by rules-review:no-llm label after maintainer review.

@shinaoka shinaoka added the rules-review:no-llm Skip the LLM pass; deterministic checks still run label Aug 10, 2026
f-string expressions contained backslashes (Python 3.12+ only); precompute
the fixture line numbers so ubuntu-22.04's Python parses the file.
@shinaoka shinaoka added rules-review:no-llm Skip the LLM pass; deterministic checks still run and removed rules-review:no-llm Skip the LLM pass; deterministic checks still run labels Aug 10, 2026
@shinaoka
shinaoka enabled auto-merge (squash) August 10, 2026 03:47
@shinaoka
shinaoka merged commit 928c567 into main Aug 10, 2026
20 of 26 checks passed
@shinaoka
shinaoka deleted the audit/issue-566-remediation branch August 10, 2026 03:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rules-review:no-llm Skip the LLM pass; deterministic checks still run

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant