Skip to content

🐛 fix(nps-relay): release the per-IP slot and day count when the create-only registration write loses the race - #560

Merged
hivecommons-hive[bot] merged 2 commits into
mainfrom
scanner/fix-559
Nov 1, 2026
Merged

hivecommons-hive[bot] merged 2 commits into
mainfrom
scanner/fix-559

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

handleRegister reserved the per-IP slot and the day count before the create-only write, and leaked both when that write lost the race, so a rare double-registration burned one of the IP's 3 slots for 24h. The losing branch now releases both reservations, mirroring #555/#558.

Closes #559

— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88

hivecommons-hive Bot and others added 2 commits November 1, 2026 03:01
…te-only registration write loses the race

Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
…ier config

Co-authored-by: Copilot <[email protected]>
Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@kubestellar-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign clubanderson for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@netlify

netlify Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for hivecommons-docs canceled.

Name Link
🔨 Latest commit e028429
🔍 Latest deploy log https://app.netlify.com/projects/hivecommons-docs/deploys/6ae6f440b56098cc0f70b6fa

@hivecommons-hive

hivecommons-hive Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor Author

Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor.

hive/awaiting-ci: CI pending — sweep will merge when green.


🐝 Hive Agent: scanner | Instance: hosted-available-oke-11-placeholder-r05x | SHA: unknown

— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88

Evidence bundle `#560e028429` sha256:cce889d9a0280b6269c621b3a97d7cb0f4ed2f113f51588e4b884676cfd6bdd4 — download from the dashboard or `hivectl review evidence #560`.

@hivecommons-hive hivecommons-hive Bot added author/hive This repository's own hive (the App or one of its agent lanes) authored this PR dco All commits are DCO signed-off role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it stage/060-reviewed Review swarm verdict approve; a gate is still pending (CI running, soak not started) and removed stage/060-reviewed Review swarm verdict approve; a gate is still pending (CI running, soak not started) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Nov 1, 2026
@hivecommons-hive
hivecommons-hive Bot merged commit 4b0a2c3 into main Nov 1, 2026
@kubestellar-prow
kubestellar-prow Bot deleted the scanner/fix-559 branch November 1, 2026 09:05
@hivecommons-hive hivecommons-hive Bot removed role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/060-reviewed Review swarm verdict approve; a gate is still pending (CI running, soak not started) labels Nov 1, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logic looks correct to me; the only thing blocking this is a Prettier failure in the new test.

Read netlify/nps-relay/relay.ts at b396799. The losing-write branch (relay.ts:784-792) now calls releaseSlot(store, ipKey, now) and a compareAndSwap decrement on dayKey, which is exactly the pair reserved at relay.ts:750-765 and mirrors the existing dayDenied release at relay.ts:766-769. releaseSlot (relay.ts:575-586) removes the now timestamp by value, so releasing the slot reserved in this same request is safe even when other live timestamps exist, and Math.max(0, count - 1) keeps the counter from going negative if the record was reset in between. The new test drives the lost race through a RelayStore wrapper that fails only onlyIfNew writes on INSTALL_PREFIX keys, so the IP and day CAS writes still land and the assertions check the released state — it fails without the fix.

Blocker (CI, not logic): the TypeScript & ESLint job fails in its Prettier step on netlify/nps-relay/relay.test.ts. The offending span is relay.test.ts:506-509; Prettier wants

const res = await handleRelayRequest(register(), deps({ store: losing }));

on one line. npx prettier --write netlify/nps-relay/relay.test.ts fixes it. Once that is pushed, nothing else stands out — Vitest, Build and npm audit are already green on this head.

— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it labels Nov 1, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read handleRegister and the CAS helpers at the PR head; this looks correct to me.

  • The new release in the !created.modified branch (netlify/nps-relay/relay.ts:784-792) is the same releaseSlot(store, ipKey, now) + day-counter CAS pattern the dayDenied path already uses at relay.ts:766-769, so the three reservation/release paths are now symmetric. Math.max(0, count - 1) keeps the counter from going negative if the key was reset in between.
  • Both releases run before getInstall, so the 200 (same key) and 409 (different key) outcomes both give the quota back — matching #559's evidence line.
  • Verified the test is a real regression guard: with relay.ts reverted to the merge-base, releases the per-IP slot and day count when the create-only write loses the race fails with expected { count: 1 } to deeply equal { count: +0 }; at the PR head all 50 relay tests pass.

Changelog fragment name follows changelog.d/README.md (fixed-…). No findings.

— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot added stage/060-reviewed Review swarm verdict approve; a gate is still pending (CI running, soak not started) and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Nov 1, 2026
hivecommons-hive Bot added a commit that referenced this pull request Nov 1, 2026
…ubmit request (#564)

Three fixes in a row (#555, #558, #560) each closed one path where a
reserved slot was not released after a later refusal. Each shipped a
site-local regression test; nothing asserted the class. This adds one
table-driven test: for every known refusal reason, the live slots held by
every quota record are identical before and after the request. Rows that
refuse after a reservation also require the store to have been written
(reserve + release) so the equality is not vacuous; rows that refuse before
any reservation require that no quota key was created.

Reverting any one of the three release hunks makes exactly one row fail.

Closes #563

Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com>
Co-authored-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com>
Co-authored-by: Copilot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author/hive This repository's own hive (the App or one of its agent lanes) authored this PR dco All commits are DCO signed-off dco-signoff: yes size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[reviewer] Review backlog (correctness): Lost create-only race still consumes IP slot and day count without a registration

0 participants