4 Commits
Author SHA1 Message Date
Pavlo Ratushnyi 36d9338621 the queue is settled when it is empty, and the impact scene asks its questions one at a time
ci / build, test, smoke (push) Successful in 2m39s
ci / the operator page in a real browser (push) Failing after 2m29s
ci / lint the workflow and the shell (push) Successful in 8s
ci / build the image and smoke it (push) Successful in 4m2s
Two assertions that could not pass, each for a different reason.

AlertPushQueueTests.Attempts_run_out_and_the_surface_says_who_was_never_told
waited for the first delivery to give up and then asserted the queue was empty.
Six 502s at N=3 raise two alerts - the crossing at 3, the doubling at 6 - so two
deliveries are owed, and the second is still inside its backoff window when the
first gives up. Measured on the Gitea runner (run 2361, head 223b8d6): 404 of 405
passed and this one read pending=1. The wait now asks for both, which is what the
Settled helper two screens up already says a settled queue means.

console-check.cjs asked /admin-api/impact whether a live range already covers the
match while its own seeded exemption was still live. The endpoint reports
alreadyCoveredBy as what already ANSWERS for the match's own address, and a live
allow answers that address first, so the field is null by design and the
assertion could not pass for any build. Measured on the same run: the answer
named the exemption and nothing else. The exemption now comes off before that
question is asked.
2026-10-05 21:53:02 +02:00
Pavlo Ratushnyi 6664f94b22 an operator's decisions move to another edge in one call
An operator running several edges types every rule several times: blocks, allowlist, request rules, country rules and the policy overrides have their own endpoints one row at a time, and nothing moved them as a set. A new deployment starts empty, and a change that turns out wrong has nothing to be restored from. This is the multi-instance finding one level up from the shared streak store: SharedStreaks shares the counters, nothing shared the decisions.

GET /admin-api/export answers one document — version, exportedAt, edgeId, per-section counts, the policy section, and blocks / allowlist / rules / country rules. Only live rows; rules keep their evaluation order; and the document names how many engine bans it left behind, because "0 blocks" and "0 operator blocks, 7 engine bans left behind" are different sentences. A ban the engine earned is a claim about this edge's own traffic, so enforcing it where that traffic was never seen is a decision nobody made.

POST /admin-api/import is additive and idempotent: it never deletes a row the document does not mention — a transfer that silently clears a fleet's exemptions is worse than one that duplicates a block — a live row for the same source is reported as already there rather than rewritten, and expiry travels as an instant, so a block that expires in ten minutes where it came from expires in ten minutes here. Per-section counts (added / alreadyThere / skippedExpired / rejected) and a rejected[] list named by section and index; an unknown version, an oversize body or a malformed document writes nothing at all; a storage failure answers 503 with the report, because "it failed" and "it added 41 of 60" must not collapse into one sentence.

What the run caught, in order: (1) a unit assert used "203.0.113" as the invalid address and passed for the wrong reason — IPAddress.TryParse accepts it as 203.0.113.0, so the assert now names 203.0.113.999. (2) Two smoke asserts were wrong rather than the product: a helper printed a Python boolean where the gate compares text, and a blocks delete was asserted as 204 when the endpoint answers 200 with {"deleted":n}. (3) The metrics-as-a-number test could pass its wait on a cache refreshed between an enqueue and its first attempt — pending > 0 was true a moment before attempts > 0 could be — so the wait now requires both numbers. (4) A real defect, not a test one: the alert notifier left the rows it had claimed claimed when the process stopped, so the next process waited out the five-minute reclaim window to deliver an alert that was already owed. It now releases what it holds on the way out, and the reclaim window is back to being what it is for — a process that was killed and cannot say anything.

Gates on this tree: build 0 warnings / 0 errors, unit 285/285, integration 257/257 in 23s, smoke 82 passed / 0 failed (14 new), image 262 MB, compose-smoke 243 passed / 0 failed with 0 containers left behind (11 new, against the shipped image).

Refs OPEN-61.
2026-10-05 04:16:05 +02:00
Pavlo Ratushnyi 78e20b1859 the push queue says how hard it tried, not only what it still owes
The ticket named openwaf_alert_push_attempts_total and the queue published delivered instead. The two answer different questions: pending and given-up say what the queue holds now, attempts says what it cost to get there — attempts per delivery is what separates an endpoint that refuses everything from one that refuses occasionally, and it is the number that makes the give-up bound checkable from outside.

PushQueueCounts carries the sum, /metrics publishes it, /admin-api/state answers alertPushAttempts, and the smoke and compose gauge assertions now name all four. Re-run of every gate on this commit: build 0/0, unit 277/277, integration 251/251 in 34s, smoke 68/0, image 261 MB, compose-smoke 232/0 with 0 containers left behind, console 90/0.

Refs OPEN-60.
2026-10-05 03:31:51 +02:00
Pavlo Ratushnyi d635a00078 an alert that could not be pushed is pushed later, and says so while it waits
The push queue was a channel in one process: three attempts inside one request of work, then the row was simply no longer owed to anybody. An endpoint down for ten minutes swallowed every alert raised in that window, and a restart swallowed everything still waiting. The alert table stayed correct the whole time, which is exactly what made the hole invisible from the surface.

What is owed is now a row in alert_pushes: denormalised payload (retention prunes edge_alerts, and a delivery still owed must not go with the row it was copied from), attempts, next-attempt time, last error, and a claim so two edges over one database send each row once. Attempts are configuration (OpenWaf:Alerts:MaxPushAttempts, PushRetrySeconds), validated at startup like the other bounds; when they run out the row records that and the surface says how many were given up, because a counter that cannot tell 'still retrying' from 'stopped retrying' is the blindness this item removes.

Surfaces: /admin-api/state answers alertPushPending/Delivered/GivenUp/OldestPendingAt/LastError from the table, /metrics publishes the same as gauges from a cache no older than 5s (the metrics endpoint's rule is that it never leans on the database per scrape). Retention prunes only rows that are finished.

What the run caught, in order: (1) SchemaUpgradeTests hardcoded the migration count as a literal, so the new migration turned a working upgrade into a red test - the count is now read from the migrations assembly. (2) Two of the new queue tests asserted 'pending == 0' after waiting only for 'delivered >= 1'; one scene raises more than one alert, so the read landed between two rows and failed on a correct product - the wait now requires the queue to have emptied. (3) The whole integration suite answered 9 failures of 251, every one 'Timed out waiting for the entry point to build the IHost after 00:05:00', while the identical build minutes later answered 251/251 in 34s: a test host that cannot bind a loopback socket fails as a timeout, and the README now says so next to the scheduling note that used to be the only explanation on file.

Gates on this tree: build 0 warnings / 0 errors, unit 277/277, integration 251/251 in 34s, smoke 68 passed / 0 failed (3 new), image 261 MB, compose-smoke 232 passed / 0 failed with 0 containers left behind (2 new, including the push-queue table being added by the edge to a volume that predates it), console 90 assertions / 0 failed.

Refs OPEN-60.
2026-10-05 03:21:39 +02:00