Skip to content

Harden remaining panic surfaces#12

Merged
gphiIIips merged 2 commits into
mainfrom
test/panic-crash-surfaces
Jun 12, 2026
Merged

Harden remaining panic surfaces#12
gphiIIips merged 2 commits into
mainfrom
test/panic-crash-surfaces

Conversation

@gphiIIips

Copy link
Copy Markdown
Collaborator

Summary

This PR hardens the remaining avoidable runtime panic surfaces found after the config fallback work.

Changes:

  • Replaces hot-loop HashMap::get(...).unwrap() lookups in rules with canonical list enumeration where the list order is already the source of truth.
  • Removes a redundant treatment-failure optional-state unwrap by binding the recorded start level directly.
  • Makes weighted mechanism-profile sampling fail closed on mismatched, negative, or non-finite weights instead of indexing past the sampled slot.
  • Makes optional journey-logger snapshot locks recover from mutex poison and removes one avoidable active_journeys.get(...).unwrap().
  • Extends dimension invariants to cover DrugClass::all, DRUG_CLASS_LOOKUP, and drug_class_for_drug alignment.

The remaining panic!/expect sites after this pass are deliberate fail-fast contract checks: startup/Rayon setup, invalid RNG seed parsing, empty bacteria list, required config lookup, mechanism enum integrity, and misuse of Region::Home without prior resolution.

Validation

  • cargo check --all-targets
  • cargo test --all-targets -- --nocapture
  • cargo test weighted_profile_sampling -- --nocapture
  • cargo test --test dimension_invariants -- --nocapture
  • git diff --check

Note: whole-repo cargo fmt is currently blocked by pre-existing trailing whitespace in src/simulation/population.rs; this PR intentionally avoids broad formatter churn.

@gphiIIips gphiIIips marked this pull request as ready for review June 12, 2026 01:06
@gphiIIips gphiIIips merged commit fe42c07 into main Jun 12, 2026
1 check passed
@gphiIIips gphiIIips deleted the test/panic-crash-surfaces branch June 12, 2026 03:04
@gphiIIips gphiIIips changed the title [codex] Harden remaining panic surfaces Harden remaining panic surfaces Jun 12, 2026
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