Skip to content

chore: drop the unreachable duplicates in denial_reason() (#151) - #152

Merged
ifahimreza merged 1 commit into
mainfrom
chore/151-denial-reason-dead-code
Aug 24, 2026
Merged

chore: drop the unreachable duplicates in denial_reason() (#151)#152
ifahimreza merged 1 commit into
mainfrom
chore/151-denial-reason-dead-code

Conversation

@ifahimreza

Copy link
Copy Markdown
Contributor

Closes #151

What

Deletes 19 unreachable lines at the end of Saddle_Capabilities::denial_reason().

Why

The function ended with verbatim copies of two branches it had already run:

  • The second domain-drift condition is character-identical to the first. If it were true, the function already returned saddle_domain_drift.
  • The second tier-denied condition is character-identical to the first. If it were true, the function already returned saddle_insufficient_scope or saddle_tier_denied — that block has no fall-through path.
  • $required is assigned before both, and nothing between them touches it, $gate, or any state either condition reads.

This is worth deleting rather than ignoring, because the duplicate tier block is a worse version of the one that runs — it omits the saddle_insufficient_scope branch. If it ever became reachable it would tell an OAuth-scope-limited agent to go raise the site's access level, which is the wrong screen, and is exactly the bug #108 fixed. A stale copy of a corrected code path sitting next to the corrected one is how that regression comes back.

Found while reading denial_reason() for #148, and kept out of that PR so the security diff stays reviewable.

Testing

  • composer test — 612 tests, unchanged. No new test: unreachable code cannot change behaviour, and the proof nothing moved is capabilities-test.php's existing gate-ordering coverage staying green.
  • composer lint — 0 errors
  • php -l clean

CI note: main is red on Saddle_Skills_Test::test_the_playbook_adapts_step_two_to_a_classic_theme (#145, CI-only, green locally). This branch inherits it; unrelated to this diff.

The function ended with verbatim copies of two branches it had already
run. Both conditions are character-identical to the earlier ones, the
earlier ones always return, and nothing between them touches $required,
$gate, or any state either condition reads — so the copies could never
execute.

Worth deleting rather than ignoring, because the duplicate tier block is
a WORSE version of the one that runs: it omits the
saddle_insufficient_scope branch. If it ever became reachable it would
send an OAuth-scope-limited agent to raise the site's access level, which
is the wrong screen — the exact bug #108 fixed. A stale copy of a
corrected code path sitting next to the corrected one is how that comes
back.

No behaviour change and no new test: unreachable code cannot change
behaviour, and the proof nothing moved is capabilities-test.php's
existing gate-ordering coverage staying green. 612 tests, 0 lint errors.

Closes #151
@ifahimreza ifahimreza linked an issue Aug 24, 2026 that may be closed by this pull request
@ifahimreza

Copy link
Copy Markdown
Contributor Author

CI: red on the inherited #145 failure only.

Tests: 612, Assertions: 2410, Failures: 1Saddle_Skills_Test::test_the_playbook_adapts_step_two_to_a_classic_theme, which is #145. Assertion count is unchanged from main, which is the expected result for deleting unreachable code. PHPCS passes.

Not claiming green.

@ifahimreza
ifahimreza merged commit 6ef59bc into main Aug 24, 2026
1 of 7 checks passed
@ifahimreza
ifahimreza deleted the chore/151-denial-reason-dead-code branch August 24, 2026 21:01
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.

denial_reason() ends with two unreachable duplicate branches

1 participant