feat(board): give --plan a focus cutoff that reports what it held back
--focus "<prose>" narrows the day plan to repos whose STATE.md DECLARES a matching topic marker. Measured on the real tree: 26 blocks to 6. The filter alone was never the feature. --plan documents that it takes one position (the order), hides nothing, and labels what it cannot rank rather than dropping it, so a silent cutoff would break a property the format had already written down. The same run prints the slugs the prose resolved to, how many blocks it removed, the repos that MENTION a resolved slug with no marker line - named, not counted - and how many STATE.md it searched. Each surviving block carries the declaration it survived on. Enumerated rather than counted because the decisive find behind this feature was invisible to every string measurement until the held-back population was listed. "nevner", never "dekker": this reports text found, and board.sh has no grounds for a claim about relevance. The slug vocabulary comes from the scanned STATE.md themselves, so the "no other file" invariant survives. Emitted as key=value, not '#' comments: the consumer's parser runs in paragraph mode and drops any block without tab=, so a comment would reach the operator on the terminal path and vanish on the driver path - the one case where the cutoff is applied unseen. board-selftest 89 -> 113. The narrowing check is comparative, since every presence-only assertion passes against a no-op filter. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0186vKCzuUEN5WcJB82kddzF
This commit is contained in:
parent
cb77f2889d
commit
f9d2c927ab
4 changed files with 438 additions and 0 deletions
|
|
@ -215,6 +215,64 @@ mkrepo "$ROOT/repo-typo"
|
|||
mkdir -p "$CLAUDE_COORD_DIR/repo-typo/inbox"
|
||||
echo "msg" > "$CLAUDE_COORD_DIR/repo-typo/inbox/2026-msg1-from-y.md"
|
||||
|
||||
# --- Focus fixtures --------------------------------------------------------
|
||||
# The topic marker grammar is the register's, not this repo's: a STATE.md line
|
||||
# of the form `<slug>: <status-token> <emdash> prose`. board.sh only ever READS
|
||||
# it, and reads it from STATE.md alone - it must never start opening
|
||||
# register.md to learn the vocabulary, so the slug set is whatever the scanned
|
||||
# STATE.md files declare.
|
||||
#
|
||||
# repo-focus-plain declares the slug in the bare form.
|
||||
mkrepo "$ROOT/repo-focus-plain"
|
||||
{
|
||||
echo "# STATE - repo-focus-plain"
|
||||
printf '## %s NESTE %s START HER\n' "$HAND" "$EMDASH"
|
||||
echo "<!-- board: status=in-progress; blocked-on=-; next-cost=Opus 5/high -->"
|
||||
echo "Neste steg for repo-focus-plain."
|
||||
echo ""
|
||||
printf -- '- demo-topic: in-progress %s wired at the boundary, ingen apen trad\n' "$EMDASH"
|
||||
} > "$ROOT/repo-focus-plain/STATE.md"
|
||||
|
||||
# repo-focus-bold: the SAME declaration wrapped in bold and backticks. This is
|
||||
# the class the register's own grep loses, and it was the most consequential
|
||||
# find in the measurement that produced the decision - a heavy consumer made
|
||||
# invisible by two asterisks. A reader that only accepts the bare form
|
||||
# reproduces that defect.
|
||||
mkrepo "$ROOT/repo-focus-bold"
|
||||
{
|
||||
echo "# STATE - repo-focus-bold"
|
||||
printf '## %s NESTE %s START HER\n' "$HAND" "$EMDASH"
|
||||
echo "<!-- board: status=planned; blocked-on=-; next-cost=Sonnet 5/high -->"
|
||||
echo "Neste steg for repo-focus-bold."
|
||||
echo ""
|
||||
printf -- '- **`demo-topic`**: planned %s pin bumpet, ikke startet\n' "$EMDASH"
|
||||
} > "$ROOT/repo-focus-bold/STATE.md"
|
||||
|
||||
# repo-focus-mentions: names the slug in prose and declares NOTHING. This is
|
||||
# the held-back class the report exists for. It is in-progress with a live
|
||||
# next step, so the cutoff genuinely removes a repo that would otherwise be a
|
||||
# tab - which is what makes silence about it a lie rather than a rounding.
|
||||
mkrepo "$ROOT/repo-focus-mentions"
|
||||
{
|
||||
echo "# STATE - repo-focus-mentions"
|
||||
printf '## %s NESTE %s START HER\n' "$HAND" "$EMDASH"
|
||||
echo "<!-- board: status=in-progress; blocked-on=-; next-cost=Opus 5/high -->"
|
||||
echo "Vi pinner demo-topic i byggefila, men har aldri skrevet en markorlinje."
|
||||
} > "$ROOT/repo-focus-mentions/STATE.md"
|
||||
|
||||
# repo-focus-other: declares a DIFFERENT slug sharing one hyphen-part, so
|
||||
# "topic" resolves to two slugs and "demo" to one. Ambiguity must widen the
|
||||
# answer and say so, never silently pick a winner.
|
||||
mkrepo "$ROOT/repo-focus-other"
|
||||
{
|
||||
echo "# STATE - repo-focus-other"
|
||||
printf '## %s NESTE %s START HER\n' "$HAND" "$EMDASH"
|
||||
echo "<!-- board: status=planned; blocked-on=-; next-cost=Sonnet 5/high -->"
|
||||
echo "Neste steg for repo-focus-other."
|
||||
echo ""
|
||||
printf -- '- other-topic: planned %s ikke startet\n' "$EMDASH"
|
||||
} > "$ROOT/repo-focus-other/STATE.md"
|
||||
|
||||
OUT="$("$BOARD" --roots "$ROOT" 2>/dev/null)"
|
||||
|
||||
# --- 1. Discovery ---------------------------------------------------------
|
||||
|
|
@ -638,6 +696,133 @@ check "plan output is valid UTF-8" $?
|
|||
"$BOARD" --help 2>/dev/null | grep -q '\-\-plan'
|
||||
check "--help documents --plan" $?
|
||||
|
||||
# --- 11. Focused day plan (--focus) ---------------------------------------
|
||||
# --focus is the first CUTOFF the plan has ever had, and every check here
|
||||
# exists because a cutoff is exactly what the plan format promised it was not.
|
||||
# The filter alone is half the feature; the other half is the run saying what
|
||||
# it held back, and they ship together or not at all.
|
||||
FPLAIN="$("$BOARD" --roots "$ROOT" --plan 2>/dev/null)"
|
||||
FDEMO="$("$BOARD" --roots "$ROOT" --plan --focus demo 2>/dev/null)"
|
||||
|
||||
n_all="$(printf '%s\n' "$FPLAIN" | grep -c '^repo=')"
|
||||
n_focus="$(printf '%s\n' "$FDEMO" | grep -c '^repo=')"
|
||||
|
||||
# The operator's instruction, as a test: prove it NARROWS. Every other check
|
||||
# in this section passes trivially against a no-op filter, which is precisely
|
||||
# the state the argument was in before this feature - swallowed by the unknown
|
||||
# argument fallback, full plan returned, no crash. "It did not crash" is not
|
||||
# evidence of a filter.
|
||||
[ "$n_focus" -lt "$n_all" ] && [ "$n_focus" -gt 0 ]
|
||||
check "focused plan is strictly smaller than the full plan, and not empty" $?
|
||||
|
||||
printf '%s\n' "$FDEMO" | grep -q '^repo=repo-focus-plain$'
|
||||
check "a repo declaring the slug survives the focus" $?
|
||||
|
||||
printf '%s\n' "$FDEMO" | grep -q '^repo=repo-focus-bold$'
|
||||
check "a bold/backtick declaration counts as declared (the register's grep loses it)" $?
|
||||
|
||||
printf '%s\n' "$FPLAIN" | grep -q '^repo=repo-a$'
|
||||
printf '%s\n' "$FDEMO" | grep -q '^repo=repo-a$'; [ $? -ne 0 ]
|
||||
check "an off-topic repo is in the full plan and gone from the focused one" $?
|
||||
|
||||
printf '%s\n' "$FDEMO" | grep -q '^repo=repo-focus-other$'; [ $? -ne 0 ]
|
||||
check "a repo declaring a DIFFERENT slug is not swept in" $?
|
||||
|
||||
# The precondition. A repo that mentions the slug without declaring it is
|
||||
# neither kept nor dropped silently: it is named. Enumerating this class - not
|
||||
# reasoning about it - is what found the heaviest consumer in the real tree.
|
||||
printf '%s\n' "$FDEMO" | grep -q '^fokus_utenfor='
|
||||
check "the run reports the repos it held back" $?
|
||||
|
||||
printf '%s\n' "$FDEMO" | grep '^fokus_utenfor=' | grep -q 'repo-focus-mentions'
|
||||
check "the held-back report NAMES the repo, not just a count" $?
|
||||
|
||||
printf '%s\n' "$FDEMO" | grep -q '^repo=repo-focus-mentions$'; [ $? -ne 0 ]
|
||||
check "a mention without a marker line does not become a tab" $?
|
||||
|
||||
# Wording is load-bearing: board.sh reads text, and has no grounds whatever
|
||||
# for a claim about relevance. It says what it FOUND.
|
||||
printf '%s\n' "$FDEMO" | grep '^fokus_utenfor=' | grep -q 'nevner'
|
||||
check "the held-back line says 'nevner' (a fact about text found)" $?
|
||||
|
||||
printf '%s\n' "$FDEMO" | grep '^fokus_utenfor=' | grep -qi 'dekker'; [ $? -ne 0 ]
|
||||
check "the held-back line never claims a repo 'dekker' the topic" $?
|
||||
|
||||
# It states its own reach: 27 STATE.md, not "the tree". One repo in the real
|
||||
# measurement has its strongest evidence in a README the scan never opens.
|
||||
printf '%s\n' "$FDEMO" | grep -q '^fokus_rekkevidde=.*STATE.md'
|
||||
check "the run states its reach (N STATE.md searched, live-counted)" $?
|
||||
|
||||
n_state="$(printf '%s\n' "$FDEMO" | sed -n 's/^fokus_rekkevidde=sokt i \([0-9]*\) STATE.md.*/\1/p')"
|
||||
# Both depths, because that is what board SCANS. The register's own roll-up
|
||||
# greps ~/repos/*/STATE.md and so cannot see a polyrepo child; the reach line
|
||||
# must state the population board actually searched, not the register's.
|
||||
real_state="$(ls "$ROOT"/*/STATE.md "$ROOT"/*/*/STATE.md 2>/dev/null | wc -l | tr -d ' ')"
|
||||
[ -n "$n_state" ] && [ "$n_state" = "$real_state" ]
|
||||
check "the reach count is measured, never a constant" $?
|
||||
|
||||
printf '%s\n' "$FDEMO" | grep -q '^fokus=demo-topic$'
|
||||
check "the run names the slug the prose resolved to" $?
|
||||
|
||||
# Per-block evidence: a focused run must say why each surviving block survived.
|
||||
# This is the need that closed topics= - relocated from all 27 blocks every
|
||||
# day into the focused run, where it is actually evidence.
|
||||
n_blocks="$(printf '%s\n' "$FDEMO" | grep -c '^repo=')"
|
||||
n_ev="$(printf '%s\n' "$FDEMO" | grep -c '^fokus_treff=')"
|
||||
[ "$n_ev" -eq "$n_blocks" ] && ev_ok=0 || ev_ok=1
|
||||
check "every surviving block carries its own evidence (fokus_treff=)" "$ev_ok"
|
||||
|
||||
printf '%s\n' "$FDEMO" | grep '^fokus_treff=' | grep -q 'demo-topic'
|
||||
check "the per-block evidence names the slug and its declared status" $?
|
||||
|
||||
# Ambiguity widens and is named. "topic" is a hyphen-part of two declared
|
||||
# slugs; picking one silently would be the cutoff lying about its own size.
|
||||
FBOTH="$("$BOARD" --roots "$ROOT" --plan --focus topic 2>/dev/null)"
|
||||
printf '%s\n' "$FBOTH" | grep '^fokus=' | grep -q 'demo-topic'
|
||||
printf '%s\n' "$FBOTH" | grep '^fokus=' | grep -q 'other-topic'
|
||||
check "ambiguous prose resolves to the union, with every slug named" $?
|
||||
|
||||
printf '%s\n' "$FBOTH" | grep -q '^repo=repo-focus-other$'
|
||||
check "the union actually includes the second slug's repo" $?
|
||||
|
||||
# No match: the full plan, plus a line saying the focus was not applied. An
|
||||
# empty plan would be the worst outcome of all - the driver forwards operator
|
||||
# prose verbatim, so a typo would silently produce a morning with no tabs.
|
||||
FNONE="$("$BOARD" --roots "$ROOT" --plan --focus kaffe 2>/dev/null)"
|
||||
n_none="$(printf '%s\n' "$FNONE" | grep -c '^repo=')"
|
||||
[ "$n_none" -eq "$n_all" ]
|
||||
check "prose matching no declared slug returns the FULL plan, never an empty one" $?
|
||||
|
||||
printf '%s\n' "$FNONE" | grep -q '^fokus_ikke_brukt='
|
||||
check "a focus that was not applied says so" $?
|
||||
|
||||
# Format invariant: --focus adds fields, it does not change the shape two
|
||||
# declared consumers parse.
|
||||
printf '%s\n' "$FDEMO" | grep -vE '^#|^$|^[a-z_]+=' | grep -q .; [ $? -ne 0 ]
|
||||
check "focused plan is still comments, blanks and key=value only" $?
|
||||
|
||||
printf '%s' "$FDEMO" | iconv -f UTF-8 -t UTF-8 >/dev/null 2>&1
|
||||
check "focused plan output is valid UTF-8" $?
|
||||
|
||||
# The read-only invariant holds for the new path too: reading is delivering,
|
||||
# and a plan that consumed a backlog would be the core defect of the engine.
|
||||
before_inbox="$(ls "$CLAUDE_COORD_DIR/repo-a/inbox" 2>/dev/null | wc -l | tr -d ' ')"
|
||||
"$BOARD" --roots "$ROOT" --plan --focus demo >/dev/null 2>&1
|
||||
after_inbox="$(ls "$CLAUDE_COORD_DIR/repo-a/inbox" 2>/dev/null | wc -l | tr -d ' ')"
|
||||
[ "$before_inbox" = "$after_inbox" ]
|
||||
check "--focus writes nothing to the mailbox" $?
|
||||
|
||||
# bash 3.2: `shift 2` past the end loops forever. A flag whose value is missing
|
||||
# must not hang the driver that forwards it - and it refuses loudly, exactly as
|
||||
# --roots does, rather than degrading into "no focus" and printing a full plan
|
||||
# that looks like a focused one.
|
||||
"$BOARD" --roots "$ROOT" --plan --focus >/dev/null 2>&1
|
||||
[ $? -eq 2 ]
|
||||
check "--focus with no value exits 2, like every other flag missing its value" $?
|
||||
|
||||
"$BOARD" --help 2>/dev/null | grep -q '\-\-focus'
|
||||
check "--help documents --focus" $?
|
||||
|
||||
echo ""
|
||||
echo "board-selftest: $PASS passed, $FAIL failed"
|
||||
[ "$FAIL" -eq 0 ] || exit 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue