Repository navigation
[access] refactor(quota): split the quota read and the quota decision into named steps - #5961
Merged
Merged
Conversation
… the split Assisted-by: ClaudeCode:claude-opus-5-5
…ed steps getQuota builds its query through quotaQuery and reads the first row through firstQuotaRow, all inside the same catch. decide answers the hard-limit decision from the EXCEEDED_DECISIONS map through exceededDecision and the allowed decision through allowDecision. Assisted-by: ClaudeCode:claude-opus-5-5
rubenvdlinde
requested review from
WilcoLouwerse,
bbrands02 and
rjzondervan
as code owners
November 11, 2026 18:31
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
TenantQuotaService::getQuotaand::decideread as short lists of steps:getQuota()builds itsfindAll()config throughquotaQuery()(with its comment) and reads the first row throughfirstQuotaRow(); the row read and the Organisation limit overlay stay inside the same catch, so a failure anywhere still answers null.decide()answersunlimitedfor a missing limit, the hard-limit decision throughexceededDecision()(the block / throttle / warn answers are now theEXCEEDED_DECISIONSmap, any other enforcement still warns) and the allowed decision throughallowDecision()(soft once the warning threshold is reached).Behaviour is unchanged: the same decisions, soft flags and reasons at every boundary, the same query, the same null answers.
Not touched:
initialize()andpersistQuota()(open #5353) andresetIfDue()(open #4882).Characterisation tests (committed first, green on the old code)
Added to
TenantQuotaServiceTest:testEveryDecisionIsExact(unlimited, within the limit, at the warning threshold, at the limit itself, a string limit, a custom warning percent, a larger increment, block, throttle, warn and an unknown enforcement, each as the whole answer) andtestAQuotaReadThatThrowsAnswersNull. Mutation check: refusing at the limit instead of past it turns the tests red.What ran
vendor/bin/phpunit -c phpunit-unit.xml --no-coverageonTenantQuotaServiceTest,TenantScopedLookupsTest,TenantQuotaWritePathsTest,tests/Unit/BackgroundJob,QuotaConsumptionListenerTestandtests/Unit/Architecture: 241 tests, one inherited failure:ServiceCatchReturnsNullTest::testEveryAllowlistEntryNamesALiveSitenamesOpenRegisterBridge::approvalService#1, which is red on development too.vendor/bin/phpcsandvendor/bin/phpstan analyseon the service: clean.Figures (TenantQuotaService.php)
getQuota(lines / complexity)decideEvery new helper is at most 15 lines, complexity 5 or below and takes at most 2 parameters.
Maintainability floor: compare against development holds.
Left in this file:
initialize(complexity 8) is changed by open #5353.AI-assisted: prepared with Claude Code (claude-opus-5-5); reviewed by a maintainer before merge.
Generated by Claude Code