tools (volt): queue_index.py -- a Status: marker whose bold closes before its value is not 'no status'

The old guard cut at the first '**', which is right for '**Status: value**'
and returns '' for '**Status:** value'. Empty is falsy, so the parse stored
None and docs/queue-index.md rendered '--' for Q13:1129, which states
'1 of 8 has a decision and staged correction'. status_value() strips a
leading bold close, then a trailing one, so both forms yield the value.

selftest 54 -> 58 cells (inline fixture, no existing line numbers move).
docs/queue-index.md regenerated: exactly 2 lines (the Q13 cell + its pin).
Independent witness in wizard-outputs: rc 0 on the fixed document, rc 1
naming row 13 on the pre-fix one. verify.py 3/3 rc 0.
This commit is contained in:
Volt committed 2026-10-19 00:09:51 +00:00
1 parent 2e8ae5a7d3
commit 331927fc99
3 files changed
+162 -8

No files matched your search

+34 -6
View File
@@ -94,7 +94,7 @@ USAGE
python3 tools/queue_index.py --json out.json
python3 tools/queue_index.py --write docs/queue-index.md
python3 tools/queue_index.py --check docs/queue-index.md
python3 tools/queue_index.py --selftest # fixture corpus, 54 cells
python3 tools/queue_index.py --selftest # fixture corpus, 58 cells
Re-run `--write` after any append to the queue. The document carries the
queue's sha256, so a stale copy is a RED check, never a silent lie.
@@ -178,6 +178,23 @@ def line_bytes(line, is_last, trailing_newline):
return len(line.encode("utf-8")) + 1
def status_value(raw):
"""The value of a `Status:` marker, in either emphasis form.
`**Status: value**` puts the value *inside* the bold run; `**Status:** value`
closes the bold *before* it. The `STATUS` pattern consumes the optional
leading `**`, so cutting at the first `**` is right for the first form and
returns "" for the second -- which published a stated status as `--`.
Q13:1129 (`**Status:** 1 of 8 has a decision ...`) was the live case.
"""
raw = raw.strip()
while raw.startswith("**"):
raw = raw[2:].strip()
if "**" in raw:
raw = raw.split("**", 1)[0].strip()
return raw
def parse(text):
"""Return the structural parse: sections, nested ids, id map, byte accounting."""
lines, trailing_newline = split_lines(text)
@@ -212,10 +229,7 @@ def parse(text):
for off, ln in enumerate(body, start=line_no + 1):
m = STATUS.match(ln)
if m:
raw = m.group(1).strip()
if "**" in raw: # a bold status marker closes mid-line
raw = raw.split("**", 1)[0]
status = raw.strip()
status = status_value(m.group(1)) or None
status_line = off
break
title = rest.lstrip("—- ").strip()
@@ -652,6 +666,20 @@ def selftest():
check("status line number", secs[0]["status_line"], 7)
check("section with no marker is None", secs[1]["status"], None)
check("continuation status is its own", secs[2]["status"], "OPEN.")
# `**Status:** value` -- the bold run closes *before* the value. Cutting at
# the first `**` returned "" and the index published a stated status as
# `--` (Q13:1129 was the live case in the real queue).
lead = parse("## Q1 — a\n\n**Status:** 1 of 8 decided.\n\n"
"## Q2 — b\n\n**Status:** **OPEN.** tail.\n\n"
"## Q3 — c\n\n**Status:**\n")
check("status whose bold closes before its value",
lead["sections"][0]["status"], "1 of 8 decided.")
check("that marker still reports its own line",
lead["sections"][0]["status_line"], 3)
check("status lead with a bold value still extracts",
lead["sections"][1]["status"], "OPEN.")
check("a marker with no value at all stays None",
lead["sections"][2]["status"], None)
check("nested ids found", [r["id"] for r in p["nested"]], ["Q41", "Q43", "Q45"])
check("nested owner is the containing section", p["nested"][0]["section"], "Q3")
check("nested shape is bullet carrying a bold lead", p["nested"][0]["shape"], "BULLET+BOLD")
@@ -842,7 +870,7 @@ def main(argv=None):
ap.add_argument("--check", metavar="PATH", help="re-derive and compare a rendered index")
ap.add_argument("--outside", action="store_true",
help="report ids the prose corpus names that the queue never mentions")
ap.add_argument("--selftest", action="store_true", help="fixture corpus, 54 cells")
ap.add_argument("--selftest", action="store_true", help="fixture corpus, 58 cells")
args = ap.parse_args(argv)
if args.selftest:
return selftest()