Commit 82d5ebf
committed
fix(engine): make unresolved ParentObjectTargetController restriction fail-closed, not panic
Address maintainer review: the enforcement arm in
casting::restriction_scope_matches_player did debug_assert!(false) for
RestrictionPlayerScope::ParentObjectTargetController, but add_restriction's
fill_runtime_fields can legitimately leave that scope unresolved when there is
no object referent (proven by parent_object_target_controller_unresolved_without_object_target).
That made the documented fail-closed path unsafe: a castability query against
that stored state would panic in debug/test builds instead of restricting no
one.
Remove the debug assertion for this arm so it genuinely returns false
(fail-closed). Unlike the always-resolved sibling scopes (TargetedPlayer,
ScopedPlayer), this scope can reachably remain unresolved, so an unresolved
value is a valid state, not a bug.
Add an integration test that drives the public can_cast_object_now against the
stored unresolved restriction and asserts it restricts no one without panicking
— proving the fail-closed behavior, not just the stored enum shape.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WQcP6woAkU5iEBTkA9oQ6J1 parent 3b23999 commit 82d5ebf
2 files changed
Lines changed: 66 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
510 | 510 | | |
511 | 511 | | |
512 | 512 | | |
513 | | - | |
514 | | - | |
515 | | - | |
516 | | - | |
517 | | - | |
518 | | - | |
519 | | - | |
520 | | - | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
521 | 523 | | |
522 | 524 | | |
523 | 525 | | |
| |||
Lines changed: 56 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
19 | 22 | | |
20 | 23 | | |
21 | 24 | | |
| |||
53 | 56 | | |
54 | 57 | | |
55 | 58 | | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
56 | 112 | | |
57 | 113 | | |
58 | 114 | | |
| |||
0 commit comments