Skip to content

fix: snapshot spline public array state#78

Merged
0xC000005 merged 2 commits intomainfrom
audit/cycle-12-spline-public-state
May 6, 2026
Merged

fix: snapshot spline public array state#78
0xC000005 merged 2 commits intomainfrom
audit/cycle-12-spline-public-state

Conversation

@0xC000005
Copy link
Copy Markdown
Owner

Summary

  • harden ChebyshevSpline.Domain, NNodes, and Knots so public getters return snapshots
  • keep internal hot paths on backing fields/storage accessors instead of cloning through public getters
  • add regression coverage for public mutation, internal storage accessors, and null setter branches

Related to #73. This is a staged partial fix and does not close the issue.

Verification

  • RED: SplinePublicStateOwnershipTests failed 2/2 before the production change
  • dotnet test tests/ChebyshevSharp.Tests/ChebyshevSharp.Tests.csproj --configuration Release --filter FullyQualifiedName~SplinePublicStateOwnershipTests --verbosity minimal: 4/4 passed
  • dotnet test tests/ChebyshevSharp.Tests/ChebyshevSharp.Tests.csproj --configuration Release --filter "FullyQualifiedNameSpline|FullyQualifiedNameSpecialPoints|FullyQualifiedNameAutoKnots|FullyQualifiedNameExtrudeSlice|FullyQualifiedNameCalculus|FullyQualifiedNameBinaryFormat" --verbosity minimal: 403/403 passed
  • dotnet test tests/ChebyshevSharp.Tests/ChebyshevSharp.Tests.csproj --configuration Release --verbosity minimal: 1520/1520 passed
  • dotnet restore: passed for fresh worktree benchmark/example assets
  • dotnet build --configuration Release --no-restore --verbosity minimal: passed, 0 warnings/errors
  • dotnet format ChebyshevSharp.slnx --verify-no-changes --verbosity minimal: passed
  • dotnet pack src/ChebyshevSharp --configuration Release --no-build --output /tmp/chebsharp-cycle12-spline-pack: passed
  • git diff --check: passed

Reference/Design Notes

  • Microsoft CA1819 notes array-returning properties are not write-protected and require copies to be tamper-proof.
  • Microsoft CA2227 reinforces read-only collection/property contracts when mutation is not intended.
  • The fix follows the PR Snapshot Approximation public array state #77 pattern: public snapshots plus internal live storage, avoiding hidden clone allocations in evaluation/arithmetic paths.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@0xC000005 0xC000005 force-pushed the audit/cycle-12-spline-public-state branch from 73a9937 to 824c47c Compare May 6, 2026 16:11
@0xC000005 0xC000005 force-pushed the audit/cycle-12-spline-public-state branch from 824c47c to 9688d65 Compare May 6, 2026 16:17
@0xC000005 0xC000005 merged commit 9689db8 into main May 6, 2026
6 checks passed
@0xC000005 0xC000005 deleted the audit/cycle-12-spline-public-state branch May 6, 2026 16:36
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