The engine works out what a target has left from six arguments and a mode flag: a quota and its consumption, the room and its consumption, whether the target is a tariff, and what the allotments are holding back. Six parameters and a boolean is the shape of several concepts sharing one function.

They are not several concepts. Revenue management has named all of this for decades, and named it as one rule: a resource's capacity is sold into classes; a booking limit caps a class; a protection level holds capacity out of a class for a named holder; and what a booking may take is the least any control it passes through will still give. A limit and a protection are the two ways the same nested control is written down, which is why an engine wants both rather than one.

So the sum becomes a fold over controls, and the mode flag disappears into the list: a target that is a class passes through its own limit and through the room, and a target that is the room passes through the room alone. What an allotment holds is a protection on the room rather than on the price, because seats are what it is holding.

Proved before it was used

A unit test runs 2400 combinations of the engine's six arguments through both the old signature and the fold and asserts they agree, including where the numbers are absurd: quotas larger than the room, consumption past the limit, protections larger than the capacity, and every combination of unlimited. The engine now delegates to the fold, and that test is what says it may.

Every figure in the hold cost log is identical, all ten scenarios, compared one by one: the fold is arithmetic and moves no statement.

Why this shape and not another

Capacity is shared rather than carved, which the fold preserves: an unsold seat in one class is still sellable in another. That is the nested form, and it is the one worth having. The literature is blunt about the alternative, where each class owns a distinct allocation: a full class refuses a booker while a cheaper class sits open beside it. Nothing here changes that behaviour, but it is now visible in the model rather than implied by an argument list.

This is the first step of #3618694: Take every submodule out of the engine's words, in code and in prose and the one that can kill it cheaply. If the availability sum had not turned out to be one rule over a list, the rest of that plan would have been wrong, and an afternoon would have been the cost of finding out instead of a month.

AI-Generated: Yes (Claude Code wrote the control, the equivalence test and this summary. The vocabulary is taken from revenue management practice rather than invented, after the maintainer pointed out that deriving it from the existing code only ratifies the existing code.)

Issue fork yoyaku-3618712

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

mably created an issue. See original summary.

mably’s picture

Status: Active » Needs review

  • mably committed 0e07f387 on 1.x
    task: #3618712 Write the availability sum as the inventory controls it...
mably’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.