Skip to content

Stop SourceBaselines exposing the identity's own storage - #72

Merged
brandonifco merged 2 commits into
mainfrom
fix/identity-baselines-cannot-be-rewritten
Sep 15, 2026
Merged

brandonifco merged 2 commits into
mainfrom
fix/identity-baselines-cannot-be-rewritten

Conversation

@brandonifco

Copy link
Copy Markdown
Owner

Closes #55.

ReplayCompatibilityIdentity.SourceBaselines returned the identity's internal ImmutableArray. ImmutableCollectionsMarshal.AsArray on it gave the live array, so any caller could rewrite the baselines and change equality and the hash in place, with no reflection. The type documented this as unfixable.

It was fixable. The identity now keeps a private array, and the property returns a copy on each read. There is no API change.

  • New test Writing_through_the_exposed_baselines_cannot_rewrite_the_identity: it fails against the previous implementation and passes now.
  • It changes a kernel type, so I calibrated it. faa-part-107 (156 tests), hoyle-backgammon (560) and srd-52-combat (250) all pass, and docs/calibration/0.4.0.md is updated.
  • A release-checks.py dry run passes.

🤖 Generated with Claude Code

brandonifco and others added 2 commits September 15, 2026 16:12
ImmutableCollectionsMarshal.AsArray on the returned ImmutableArray gave the
live backing array, so any caller could rewrite an identity's baselines and
change its equality and hash in place. The identity now keeps a private array
and SourceBaselines returns a copy. No API change. The new test fails against
the previous implementation.

Closes #55

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
faa-part-107 156, hoyle-backgammon 560, srd-52-combat 250: all pass.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@brandonifco
brandonifco merged commit 6bbb662 into main Sep 15, 2026
1 check passed
@brandonifco
brandonifco deleted the fix/identity-baselines-cannot-be-rewritten branch September 15, 2026 20:15
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.

ImmutableCollectionsMarshal.AsArray can rewrite an identity's baselines in place

1 participant