Skip to content

feat(scope-audit): one colour-coded Scopes column instead of three - #6

Merged
efiten merged 1 commit into
masterfrom
feat/scope-audit-merge-columns
Sep 5, 2026
Merged

feat(scope-audit): one colour-coded Scopes column instead of three#6
efiten merged 1 commit into
masterfrom
feat/scope-audit-merge-columns

Conversation

@efiten

@efiten efiten commented Sep 5, 2026

Copy link
Copy Markdown
Owner

Step one of getting the Scope Audit page ready to propose upstream. The page does not exist on Kpa-clawbot/CoreScope at all (no frontend, no route, no server code, zero grep hits), so it gets finished here first.

The problem

DECLARED, NOT OBSERVED and UNDECLARED OBSERVED sat side by side, and the first two were never independent. notObserved is a strict subset of declaredRegions, so the table printed the same set twice, once whole and once filtered, and left the reader to diff them.

Measured on a live 197-row response before changing anything:

rows
notObserved is a subset of declaredRegions 197 of 197, no exceptions
all declared regions observed 7
none observed 78
mixed 44
no declared regions at all 68

The 44 mixed rows are where the reader pays. They declare 8.3 regions on average of which 6.5 are unobserved, so usually only one or two are green. BE-TUR-REP1_ON3FNZ declares 20 regions and lists 19 under NOT OBSERVED; the sole difference is that be is missing from the second list. Finding that today means comparing two lists of twenty. Now it is one green chip among nineteen red.

Why UNDECLARED OBSERVED is gone rather than restyled

My first instinct was to keep it as a third chip colour, on the reasoning that a zero today does not prove the case is impossible. That reasoning was wrong: a repeater does not forward a scope it has not been configured with, so the column cannot fill at all, except transiently when an owner removes scopes while older messages are still inside the window. That is an artefact of the window, not a fault, and promoting it to a warning colour would have turned noise into an alert.

Nothing is lost by dropping it. The STATUS column already renders an N undeclared badge for that case, and undeclaredObserved still feeds statusScore and the search index, both untouched. Confirmed empty on all 197 rows at both 24h and 7d, which is consistent with it only ever arriving from stale history: a longer window would be more likely to show it, not less.

Verification

Eight new cases in test-frontend-helpers.js assert the rendered markup through a new window.__meshcoreScopeAuditInternals handle, following map.js (Kpa-clawbot#1356/Kpa-clawbot#1933) instead of grepping the source. Suite goes 662 → 670 passed, 0 failed. They cover observed vs missing colouring, one chip per declared region and no more, declared order preserved rather than regrouped by colour, an em dash instead of an empty cell for the 68 rows that declare nothing, each chip explaining its own colour in a title, HTML escaping of server-supplied names, and a defensive case where a notObserved entry that is not declared cannot invent a phantom chip.

Then every one of the 197 live rows was pushed through the real function:

volledig groen : 7    (verwacht 7)
volledig rood  : 78   (verwacht 78)
gemengd        : 44   (verwacht 44)
geen scopes    : 68   (verwacht 68)
chips totaal   : 793, declared totaal 793 -> gelijk: true

793 chips against 793 declared regions, so no chip is invented and none dropped.

Notes

  • Sorting keys off notObserved, which is what the page ranks by anyway. The separate sort-by-declared-count axis is gone with the column; say so if you used it.
  • Colours use the existing --status-green / --status-green-text variables alongside the --status-red the missing chip already used, so the two read as one scale. No hardcoded hex.
  • Dead code removed: scopeChips and undeclaredChips had no remaining callers.
  • Server side untouched. /api/scope-audit still returns undeclaredObserved, so this is frontend-only and reversible.

Next

Once you are happy with the page here, the upstream step is a proposal to contribute the whole feature: scope-audit.js (331 lines), scope-audit.css, three index.html wiring lines, plus the server half in scopes.go and routes.go with its existing tests in scopes_test.go.

The audit table printed DECLARED, NOT OBSERVED and UNDECLARED OBSERVED side by
side. The first two were never independent: notObserved is a strict subset of
declaredRegions, so the page showed the same set twice, once whole and once
filtered, and left the reader to diff them.

Measured on a live 197-row response before changing anything:

  notObserved is a subset of declaredRegions : 197 of 197 rows, no exceptions
  all declared regions observed              :   7 rows
  none observed                              :  78 rows
  mixed                                      :  44 rows
  no declared regions at all                 :  68 rows

The 44 mixed rows are the ones that cost the reader time. They declare 8.3
regions on average of which 6.5 are unobserved, so usually one or two are
green. BE-TUR-REP1_ON3FNZ declares 20 regions and lists 19 under NOT OBSERVED;
the only difference is that "be" is missing from the second list. Finding that
today means comparing two lists of twenty. Now it is one green chip among
nineteen red.

UNDECLARED OBSERVED is dropped. A repeater does not forward a scope it has not
been configured with, so the column cannot fill except transiently when an
owner REMOVES scopes while older messages are still inside the window, which
is an artefact of the window rather than a fault worth a column. Confirmed
empty on all 197 rows at both 24h and 7d. Nothing is lost: the STATUS column
already renders an "N undeclared" badge for that case, and undeclaredObserved
still feeds statusScore and the search index, both untouched.

Sorting keys off notObserved, which is what the page ranks by anyway. Declared
order is preserved rather than regrouped by colour, so a region stays in the
position an operator is used to scanning.

Verification: 8 new cases in test-frontend-helpers.js asserting the RENDERED
markup through a new window.__meshcoreScopeAuditInternals handle, following
map.js (Kpa-clawbot#1356/Kpa-clawbot#1933) rather than grepping source. Suite 662 to 670 passed, 0
failed. Then every one of the 197 live rows was pushed through the real
function: 7 all-green, 78 all-red, 44 mixed, 68 empty, reproducing the
independently computed figures exactly, and 793 chips against 793 declared
regions so no chip is invented or dropped.

Colours use existing variables (--status-green, --status-green-text) alongside
the --status-red the missing chip already used, so the two read as one scale.
Dead code removed: scopeChips and undeclaredChips had no remaining callers.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PQS3XLoPD98yu9pxdRujqg
@efiten
efiten merged commit 33bf8cb into master Sep 5, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant