From 4db36f86d0374a92526cbfc50dd026100dbdd24e Mon Sep 17 00:00:00 2001 From: Pavlo Ratushnyi Date: Mon, 5 Oct 2026 06:30:22 +0200 Subject: [PATCH] the operator's console shows what changed on this edge OPEN-64 gave the edge a record of every deliberate config change and an endpoint that reads it; the record was invisible to the person it is for. `/admin` now draws it: when, section, action, target, the note somebody typed, and the surface it came through, newest 25 of the total. Rulings this copy holds to: * The surface column says `operator` or `import`, never a person. The edge has one admin token; a column implying a per-person attribution it cannot provide would be a false record, not a thinner one. * Engine bans are absent, and the line under the table says so in the same breath as the counts: "engine bans are not here, they are not decisions". A table that mixed them in would read as "the operator chose to ban this address", which is a different claim. * The log's two bounds are printed under the table they govern - "pruned after 30d or 5000 rows, whichever comes first" - the way the retention windows sit on the observations and alerts tables. They come from `/state` (`changeRetentionDays`, `changeLogMaxRows`), so the numbers are the ones this process was actually started with. * A change record that did not land is named in the durable-writes pill with its count: "change records not written x1 (1 changes unrecorded)". It is the one write failure that changes nothing the edge enforces, which is exactly why it would otherwise go unseen - the config did change, only its record is missing. What the run measured rather than assumed: the gate's seed writes a block whose reason carries markup (` probe`), and that reason is now the detail of a change row - so the change table is a place where a stored operator string reaches the one browser in this system that holds the admin token. The markup-seed assertion now covers `#changes tbody`, and a companion assertion proves the string really arrived as text, because without it an injection count of zero would only prove that nothing was looked at. Gates on this head: build 0 warnings / 0 errors, unit 313/313, integration 298/298 in 34 s, console 98 assertions / 0 failed, smoke passed 127 failed 0, image 262 MB, compose-smoke 278 passed 0 failed. Refs OPEN-65. --- README.md | 20 +++++++-- dotnet/OpenWaf.Edge/Admin/AdminConsole.cs | 38 ++++++++++++++-- dotnet/OpenWaf.Edge/Admin/AdminEndpoints.cs | 4 ++ scripts/console-check.cjs | 48 ++++++++++++++++++++- 4 files changed, 102 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 0f0d776..1e090ae 100644 --- a/README.md +++ b/README.md @@ -973,6 +973,11 @@ it is a read. curl -H "X-Admin-Token: $TOKEN" 'http://edge:8080/admin-api/changes?section=block&limit=5' ``` +The console shows the same rows under **What changed on this edge** — when, +section, action, target, the operator's own note, and the surface — newest first, +newest 25 of the total, with the two retention bounds printed under the table +they govern. A block row and the record of why it was written are on one screen. + One row per deliberate change: a block, exemption, path rule or country decision added, changed or removed; a policy update; a config import. A policy record says what moved (`mode Enforce->Off, streakThreshold 3->4`) rather than only that @@ -1036,7 +1041,7 @@ policy not re-read from storage ×14`. A second pill carries the write side and present in the clean case too — `durable writes ok`, or `durable writes bans not written ×2 (2 not enforced) · observations not persisted ×3 (4 rows lost) · alerts not persisted ×2 (2 lost) · retention not -running ×1` — because a pill that only appears when something is wrong makes +running ×1 · change records not written ×1 (1 changes unrecorded)` — because a pill that only appears when something is wrong makes "no alerts" and "alerts are not being written" look identical from the operator's chair, and because the ban case has to read differently: those two bans are not merely unrecorded, they are not in force anywhere. @@ -1053,6 +1058,12 @@ nobody is told about never fires at 3am either. With an endpoint configured the page says `pushed to `, with how many landed, how many failed and how many are still owed; without one it says `not pushed anywhere: each row waits for someone to open this page`, so "no alerts" and "alerts go nowhere" stay two different sentences. +It shows what changed on this edge — the record of every deliberate config +change (OPEN-64) as a table of when, section, action, target, the note somebody +typed and the surface it came through, with the log's two bounds (`pruned after +30d or 5000 rows, whichever comes first`) printed under it and the reason engine +bans are absent said in the same line. The surface column is the honest one: the +edge has one admin token, so it names `operator` or `import`, never a person. It decides nothing: every control on it is one call to the API above. It is on the always-pass list, so an operator who is themselves blocked can still reach the page that clears it, and it is never observed, so fumbling it cannot build a @@ -1182,9 +1193,10 @@ Rehearsed 2026-10-02, most recently at `dc88f36`, each stage run on its own. On the head of this file the host suite has been re-run and the container stages have not, so the two sets of numbers are labelled separately rather than merged into one green line. macOS host, this tree, re-measured 2026-10-05 with the durable -alert-push queue, the config transfer, the second token, the startup refusals and the change -log on it: build 0 warnings / 0 errors, unit **313/313**, integration **298/298 in 23 s**, -console **90 assertions, 0 failed**, smoke **passed 127, failed 0**, and compose **278 passed, +alert-push queue, the config transfer, the second token, the startup refusals, the change +log and that log on the console: build 0 warnings / 0 errors, unit **313/313**, +integration **298/298 in 34 s**, +console **98 assertions, 0 failed**, smoke **passed 127, failed 0**, and compose **278 passed, 0 failed** against the built image at 262 MB, 0 containers left behind. The smoke count moved by more than its new scene: the edge was being started from the repository root, where there is no `appsettings.json`, so it loaded no `ReverseProxy` section, logged "Request reached the end of the diff --git a/dotnet/OpenWaf.Edge/Admin/AdminConsole.cs b/dotnet/OpenWaf.Edge/Admin/AdminConsole.cs index e0bb40c..eb433c3 100644 --- a/dotnet/OpenWaf.Edge/Admin/AdminConsole.cs +++ b/dotnet/OpenWaf.Edge/Admin/AdminConsole.cs @@ -149,6 +149,10 @@ internal static class AdminConsole
kindsourcecountlastwhen
+

What changed on this edge

+
+
whensectionactiontargetdetailsurface
+

Countries seen

codesourcesrefusalsrefusals vs the busiestrule
@@ -253,7 +257,7 @@ function row(cells) { async function load() { if (!token) { note('no token', true); return; } try { - const [stateRes, blocksRes, obsRes, streaksRes, countriesRes, rulesRes, allowRes, pathRulesRes, rateRes, alertsRes, geoRes] = await Promise.all([ + const [stateRes, blocksRes, obsRes, streaksRes, countriesRes, rulesRes, allowRes, pathRulesRes, rateRes, alertsRes, geoRes, changesRes] = await Promise.all([ apiRaw('/admin-api/state'), apiRaw('/admin-api/blocks?live=false'), apiRaw(withSrc('/admin-api/observations?limit=25')), apiRaw(withSrc('/admin-api/streaks')), @@ -261,7 +265,8 @@ async function load() { apiRaw('/admin-api/allow?live=false&limit=500'), apiRaw('/admin-api/rules?live=false&limit=500'), apiRaw('/admin-api/rate?limit=25'), apiRaw('/admin-api/alerts?limit=25'), - apiRaw('/admin-api/geo') + apiRaw('/admin-api/geo'), + apiRaw('/admin-api/changes?limit=25') ]); // The core read decides whether there is anything to draw. When the admin // surface is switched off the edge says so in the body — "admin api @@ -276,7 +281,8 @@ async function load() { const obs = obsRes.body; const alerts = alertsRes.body; const streaks = streaksRes.body, countries = countriesRes.body, rules = rulesRes.body, - allow = allowRes.body, pathRules = pathRulesRes.body, rate = rateRes.body, geo = geoRes.body; + allow = allowRes.body, pathRules = pathRulesRes.body, rate = rateRes.body, geo = geoRes.body, + changes = changesRes.body; // The listing is capped server-side. Saying so is the difference between a // console and a misleading one: the delete beside this table is not capped. el('blocknote').textContent = blocksRes.truncated @@ -324,6 +330,12 @@ async function load() { + ' (' + esc(state.alertsLost) + ' lost)'); if (Number(state.retentionPruneFailures) > 0) writeProblems.push('retention not running \u00d7' + esc(state.retentionPruneFailures)); + // The change log is the one table whose failure does not change what the + // edge enforces, so it would be invisible if it were not said here: the + // config changed, the record of it did not land (OPEN-64). + if (Number(state.changeWriteFailures) > 0) + writeProblems.push('change records not written \u00d7' + esc(state.changeWriteFailures) + + ' (' + esc(state.changesNotWritten) + ' changes unrecorded)'); el('summary').innerHTML = 'mode ' + esc(state.mode) + ' ' + // The age against the bound it is measured against was half the story, and @@ -493,6 +505,26 @@ async function load() { const busiest = seen.reduce((m, c) => Math.max(m, c.refusals || 0), 0); const totalSources = seen.reduce((t, c) => t + (c.sources || 0), 0); const totalRefusals = seen.reduce((t, c) => t + (c.refusals || 0), 0); + // The record of deliberate changes (OPEN-64). The surface column is the + // honest one: the edge has one admin token, so it says which surface wrote, + // not which person. + el('changes').tBodies[0].innerHTML = (changes || []).map((c) => row([ + { v: (c.at || '').replace('T', ' ').slice(0, 19) }, + { v: c.section }, + { v: c.action }, + { v: c.target }, + { v: c.detail || '' }, + { v: c.actor } + ])).join('') || row([{ v: 'nothing recorded yet - every operator write from now on leaves a row here' }]); + el('changenote').textContent = Number(changesRes.total) === 0 + ? 'no config changes recorded. engine bans are not here: they are not decisions.' + : (changesRes.truncated + ? 'newest ' + changes.length + ' of ' + changesRes.total + ' records - engine bans are not here, they are not decisions' + : changesRes.total + ' ' + plural(Number(changesRes.total), 'record') + ' - engine bans are not here, they are not decisions'); + if (state.changeRetentionDays != null) + el('changenote').textContent += ' - pruned after ' + state.changeRetentionDays + 'd or ' + + state.changeLogMaxRows + ' rows, whichever comes first'; + el('countrysum').textContent = seen.length ? seen.length + ' ' + plural(seen.length, 'country') + ', ' + totalSources + ' ' + plural(totalSources, 'source') + ', ' diff --git a/dotnet/OpenWaf.Edge/Admin/AdminEndpoints.cs b/dotnet/OpenWaf.Edge/Admin/AdminEndpoints.cs index 4916b39..ac46f14 100644 --- a/dotnet/OpenWaf.Edge/Admin/AdminEndpoints.cs +++ b/dotnet/OpenWaf.Edge/Admin/AdminEndpoints.cs @@ -881,6 +881,10 @@ note = t.Note rateLimitPerWindow = state.Current.Policy.RateLimitPerWindow, rateWindowSeconds = state.Current.Policy.RateWindow.TotalSeconds, rateTrackedSources = rateTracker.TrackedCount, + // The change log's two bounds, printed on the table they apply to + // (OPEN-64), the same way the retention windows sit on theirs. + changeRetentionDays = (int)state.Current.Policy.ChangeRetention.TotalDays, + changeLogMaxRows = state.Current.Policy.ChangeLogMaxRows, observationRetentionDays = (int)state.Current.Policy.ObservationRetention.TotalDays, banRetentionDays = (int)state.Current.Policy.BanRetention.TotalDays, mode = state.Current.Policy.Mode.ToString() diff --git a/scripts/console-check.cjs b/scripts/console-check.cjs index 487a70e..e1873e3 100644 --- a/scripts/console-check.cjs +++ b/scripts/console-check.cjs @@ -191,6 +191,41 @@ const rgb = (s) => s.match(/\d+/g).slice(0, 3).map(Number); check('the kind an operator has to act on is marked, not only printed', warnCells.includes('server_error_streak'), JSON.stringify(warnCells)); + // The record of deliberate config changes (OPEN-64) on the page an operator + // actually reads (OPEN-65). The seed wrote a policy, an allow entry and two + // blocks before this page was driven, so an empty table here is a page that + // did not draw, not a log that is empty. + const changeRows = await cells('#changes tbody tr'); + check('the change table lists the writes this run made', + changeRows.length > 0 && changeRows.some((r) => + r[1] === 'block' && r[2] === 'added' && r[3] === SEED_BLOCK) + && changeRows.some((r) => r[1] === 'allow' && r[2] === 'added' + && r[3] === SEED_EXPIRED_CIDR), + JSON.stringify(changeRows.slice(0, 4).map((r) => [r[1], r[2], r[3], r[5]]))); + // The edge has one admin token, so the honest column is the surface the + // change came through. A row naming anything else would be a record the edge + // cannot support. + check('the change table names the surface, never a person', + changeRows.every((r) => r[5] === 'operator' || r[5] === 'import'), + JSON.stringify([...new Set(changeRows.map((r) => r[5]))])); + const changeNote = (await page.textContent('#changenote')).replace(/\s+/g, ' ').trim(); + check('the note under the table states both bounds of the log', + /pruned after \d+d or \d+ rows, whichever comes first/.test(changeNote), changeNote); + // An engine ban is not a decision somebody made, and a table that quietly + // mixed the two would read as "the operator chose to ban this address". + check('the note says engine bans are not in this table', + /engine bans are not here/.test(changeNote), changeNote); + // The seed's block reason carries markup, and that reason is the detail of a + // change row. Without this line the injection count below could be zero + // because the string never reached the table at all. + const markupChange = changeRows.find((r) => r[3] === SEED_MARKUP_BLOCK); + check('the markup the seed typed reached the change table as text', + !!markupChange && (markupChange[4] || '').includes(""), + JSON.stringify(markupChange)); + check('no engine ban reached the change table', + !changeRows.some((r) => r[5] === 'engine'), + JSON.stringify(changeRows.map((r) => [r[1], r[2], r[5]]))); + check('the token never appears in the markup', !html.includes(TOKEN)); // esc() is the only thing between an anonymous request and the one browser in @@ -828,6 +863,8 @@ const rgb = (s) => s.match(/\d+/g).slice(0, 3).map(Number); alertLastWriteError: 'gate: durable write blocked', retentionPruneFailures: 1, retentionLastError: 'gate: durable write blocked', retentionLastPruneAt: '2026-10-02T04:41:19.0000000+00:00', + changeWriteFailures: 1, changesNotWritten: 1, + changeLastError: 'gate: durable write blocked', trackedSources: 4, operatorBlocks: 2, engineBans: 0, allowEntries: 0, allowEntriesExpired: 0, mode: 'Enforce' }) @@ -862,6 +899,12 @@ const rgb = (s) => s.match(/\d+/g).slice(0, 3).map(Number); !!snapshotPill && !/warn/.test(snapshotPill.cls) && !/not persisted/.test(snapshotPill.text) && /retention not running/.test(writePill.text || ''), JSON.stringify({ write: writePill, snapshot: snapshotPill })); + // The change log is the one write whose failure does not change what the + // edge enforces, so without this line the config would have changed and + // nothing would say the record of it is missing. + check('and it names the change records that never landed, with how many', + !!writePill && /change records not written \u00d71 \(1 changes unrecorded\)/.test(writePill.text), + JSON.stringify(writePill)); check('the page threw no javascript on that answer', lostProblems.length === 0, lostProblems.join(' | ')); await lost.close(); } @@ -973,7 +1016,7 @@ const rgb = (s) => s.match(/\d+/g).slice(0, 3).map(Number); await page.click('div.bar button[data-act="srcfilter"]'); await page.waitForFunction((k) => document.getElementById('obsnote').textContent.includes(k), MARKUP_KEY, { timeout: 15000 }).catch(() => {}); - const markupInjected = await page.$$eval('#obs tbody, #streaks tbody, #alerts tbody', + const markupInjected = await page.$$eval('#obs tbody, #streaks tbody, #alerts tbody, #changes tbody', (bodies) => bodies.reduce((n, b) => n + b.querySelectorAll('img,svg,script,iframe,object,embed').length, 0)); const markupNote = await noteOf('#obsnote'); const markupTitle = await page.title(); @@ -1048,6 +1091,9 @@ const rgb = (s) => s.match(/\d+/g).slice(0, 3).map(Number); check('the token is not in the markup at phone width either', !m.html.includes(TOKEN)); const phoneAlertRows = await page.$$eval('#alerts tbody tr', (r) => r.length); check('the alerts table is still there at phone width', phoneAlertRows > 0, `${phoneAlertRows} rows`); + const phoneChangeRows = await phone.$$eval('#changes tbody tr', (r) => r.length); + check('the change table is still there at phone width', phoneChangeRows > 0, + `${phoneChangeRows} rows`); check('the country bars survive the phone layout', m.barWidths.length > 0 && m.barWidths.every((w) => w >= 2), JSON.stringify(m.barWidths)); check('the page threw no javascript at phone width', phoneProblems.length === 0, phoneProblems.join(' | '));