oliver-zehentleitner / maity
hub: one quota and above_ceiling refusal through ceilings (instances.refuse_over_quota, placements.refuse_over_instances, routes/projects inline copy)
tsk-w0erv9pya971 Open
Audit round 3 (tsk-hgnbapyw7hnh), read at 588f911b. Kind: duplication / design.
What is wrong
- The 409
instance_quotarefusal is written twice:hub/src/maity_hub/instances.py:216-240(refuse_over_quota) andhub/src/maity_hub/placements.py:776-799(refuse_over_instances). Both read the project, callmax_instances_limitand raise withceilings.details; they differ only in the count function (active_countvsinstances_held) and the message ("the team has as many instances…" vs "the agent runs as many instances…"), so one code carries two texts.instances.py:768-774repeats the project/owner lookup ofmax_instances_limit(instances.py:203-213). - The same quota-refusal shape (
ceilings.resolve, count,ApiError(…, ceilings.details(…))) is inhub/src/maity_hub/routes/placements.py:308-325(_refuse_over_placements) andhub/src/maity_hub/routes/joins.py:524-541(_require_slot);placements.py:1183-1202(runner_quota) builds the §6.31 details dict by hand. - The
above_ceilingrefusal exists twice with different messages:hub/src/maity_hub/ceilings.py:176-185("the value is above its ceiling") and the inlineApiErrorathub/src/maity_hub/routes/projects.py:645-650("the request does not validate")._check_bound(routes/projects.py:656-673) re-reads the project per policy field (:669) although the caller holds it.
Proposal
- One
refuse_over_instances(conn, member, count, adding, caller_id)ininstances.pythat takes the count; delete the placements copy; the member PATCH callsmax_instances_limit. - A
ceilings.refuse(code, status, message, …)helper used by the placement, join and runner quotas; move_refuse_over_placementsintoplacements.py. - One
ceilings.above_ceilingused by both callers; pass the project into_check_bound.
Effort / risk: S-M. Low risk; tests that pin the details and texts need updating.