Rainbow depth counts only the pairs the rainbow shows

User-reported: a begin inside a case (or any scope the rainbow filters
off the wire) painted one level deeper than its siblings — the hidden
scope read as an invisible begin/end layer. Depth now counts only
enclosing RAINBOW_KEYWORDS frames, one const shared by the counter and
the wire filter. Corpus: same 8,146 wire pairs, max depth 13 -> 7;
depth-0 bucket goes from near-empty to 2,881 (the palette was rotated).

Also closes M4 QA's e2e gap: the exclude test now asserts the republish
half of reindex(), and that a no-op settings push publishes nothing.

Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
lucioandClaude Fable 5 committed 2026-08-24 03:34:37 -07:00
1 parent 9a3a92cabb
commit 78eeef6050
4 files changed
+473 -37

No files matched your search

+5 -4
View File
@@ -133,11 +133,12 @@ server.on('close', (code) => {
if (scopePairs.error) fail(`vfmt/scopePairs failed: ${JSON.stringify(scopePairs.error)}`);
const pairs = scopePairs.result && scopePairs.result.pairs;
if (!Array.isArray(pairs)) fail(`vfmt/scopePairs result has no pairs array: ${JSON.stringify(scopePairs.result)}`);
// The module is matched by the server and filtered out; the two begins nest
// under it at 1 and 2, and the fork is the outer begin's sibling.
// Depth counts only the scopes the rainbow draws, so the enclosing module
// does not count: the outer begin is 0, the begin inside it is 1, and the
// fork is the outer begin's sibling at 0.
const depths = pairs.map((p) => p.depth);
if (JSON.stringify(depths) !== JSON.stringify([1, 2, 1])) {
fail(`expected depths [1,2,1] (outer begin, inner begin, fork), got ${JSON.stringify(depths)}`);
if (JSON.stringify(depths) !== JSON.stringify([0, 1, 0])) {
fail(`expected depths [0,1,0] (outer begin, inner begin, fork), got ${JSON.stringify(depths)}`);
}
// Opener lines, 0-based: `initial begin`, `if (a) begin`, `initial fork`.
const openLines = pairs.map((p) => p.open.start.line);