Skip to content

fix: Address MII+ review feedback - hash position, bounds checks, test coverage#15

Merged
Steake merged 4 commits intotournament-mii-plus-systemfrom
copilot/sub-pr-14
Nov 28, 2025
Merged

fix: Address MII+ review feedback - hash position, bounds checks, test coverage#15
Steake merged 4 commits intotournament-mii-plus-systemfrom
copilot/sub-pr-14

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Nov 28, 2025

  • Understand review comments and categorize fixes
  • Fix: Add glider position to lexicographic hash (battle.rs:455)
  • Fix: Handle hash equality case in lexicographic_break (battle.rs:435-436)
  • Fix: Skip noise placement on existing glider cells (battle.rs:230-231)
  • Fix: Add bounds check for seed_offset in calculate_spawn_jitter
  • Fix: Integer overflow protection in blocks.rs:155 (height == 0)
  • Fix: Workspace Cargo.toml formatting - move bitcell-simulation to new line
  • Fix: Remove unused bitcell-ebsl dependency from simulation Cargo.toml
  • Fix: Remove unused thiserror dependency from simulation Cargo.toml
  • Fix: Remove verbose/defensive comment in orchestrator.rs:291-295
  • Fix: Make test assertion stricter - disallow Tie outcome in MII+ test (battle.rs:659-663)
  • Fix: Vary miner glider positions in simulation lib.rs:51-104
  • Refactor: Extract derive_position_from_pubkey helper to reduce duplication
  • Refactor: Use pub(crate) instead of cfg(test) wrapper pattern
  • Add: Tests for entropy-based features (spawn jitter, noise, fluctuations)
  • Add: Tests for lexicographic tiebreaker
  • Fix: Handle hash equality case in test_lexicographic_ordering test
  • Documentation: Note that phenotype feature is deferred to future PR (MII+.md)
  • Run code_review

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits November 28, 2025 10:06
…e, etc.

Co-authored-by: Steake <530040+Steake@users.noreply.github.com>
Co-authored-by: Steake <530040+Steake@users.noreply.github.com>
Copilot AI changed the title [WIP] Add MII+ tournament system with adaptive strategy fix: Address MII+ review feedback - hash position, bounds checks, test coverage Nov 28, 2025
Copilot AI requested a review from Steake November 28, 2025 10:20
@Steake Steake marked this pull request as ready for review November 28, 2025 10:43
Copilot AI review requested due to automatic review settings November 28, 2025 10:43
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses review feedback on the MII+ (Mutual Information Index Plus) tournament system, implementing critical bug fixes, code quality improvements, and comprehensive test coverage enhancements. The changes focus on ensuring deterministic behavior, preventing edge-case failures, and cleaning up technical debt.

Key Changes:

  • Fixed lexicographic tiebreaker to include glider position in hash calculation and handle hash equality gracefully
  • Added bounds checking for spawn jitter to prevent array access panics
  • Prevented noise cells from overwriting glider cells during battle initialization
  • Enhanced test coverage for jitter ranges, energy fluctuations, noise placement, and tiebreaker determinism

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
docs/MII+.md Added note documenting that phenotype feature is deferred to future PR
crates/bitcell-simulation/src/lib.rs Extracted derive_position_from_pubkey() helper to reduce duplication across miner agents
crates/bitcell-simulation/Cargo.toml Removed unused dependencies bitcell-ebsl and thiserror
crates/bitcell-consensus/src/orchestrator.rs Removed verbose defensive comments about borrow checker
crates/bitcell-ca/src/battle.rs Core fixes: position in hash, bounds check for jitter, noise skip logic, visibility changes to pub(crate), and comprehensive test suite additions
crates/bitcell-admin/src/api/blocks.rs Added guard against height == 0 to prevent underflow in block detail calculation
Cargo.toml Formatting improvement - split workspace members onto separate lines

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/bitcell-ca/src/battle.rs Outdated
Comment on lines +823 to +824
} else {
assert_eq!(outcome, BattleOutcome::BWins);
Copy link

Copilot AI Nov 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test logic doesn't handle the case where hash_a == hash_b. When hashes are equal, lexicographic_break() returns AWins, but the test's else branch (line 824) assumes hash_a > hash_b and expects BWins, which would cause a false test failure. The condition should be } else if hash_a > hash_b { to match the implementation.

Suggested change
} else {
assert_eq!(outcome, BattleOutcome::BWins);
} else if hash_a > hash_b {
assert_eq!(outcome, BattleOutcome::BWins);
} else {
// If hashes are equal, lexicographic_break returns AWins
assert_eq!(outcome, BattleOutcome::AWins);

Copilot uses AI. Check for mistakes.
@Steake
Copy link
Copy Markdown
Owner

Steake commented Nov 28, 2025

@copilot apply changes based on the comments in this thread

Co-authored-by: Steake <530040+Steake@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Nov 28, 2025

@copilot apply changes based on the comments in this thread

Fixed in ae99d6b. The test now properly handles all three cases: hash_a < hash_b (AWins), hash_a > hash_b (BWins), and hash_a == hash_b (AWins as per the implementation).

@Steake Steake merged commit 850b879 into tournament-mii-plus-system Nov 28, 2025
Steake added a commit that referenced this pull request Nov 28, 2025
No changes - review fixes already merged in PR #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.

3 participants