Merge: keep the maintenance pass and the reconstruction pass, both

Two passes met on this branch and neither is discarded. `d0fe0ea` (inliver233) hardened
`build_scripts.py` -- 37 findings that were mostly noise, down to 0, with two defects found in its
own first implementation by an 18-case table -- generalised three absolute paths out of the evidence
record, and added a corpus-size note to `check_budget.py`. `2beade6` (this pass) rewrote
`check_budget.py`'s measurement, added four gates, rewrote `so_constpatch.py`'s zip writer,
replaced 59 out-of-package references, and shrank the always-loaded body.

Resolution, file by file:

  check_budget.py   the only real conflict. Their corpus note and this pass's rewritten measurement
                    are kept as separate functions and separate notes, because they measure different
                    quantities: what a task loads versus what the repository carries. Collapsing them
                    would let a growing corpus hide behind a green always-loaded count -- which is
                    the defect their note exists to prevent.
  build_scripts.py  theirs, taken as-is, including the case table.
  REPO-DECISIONS.md both sections: their maintenance-pass record follows this pass's decision record.
  three extensions  their absolute-path generalisations, on top of this pass's convergence edits.
  everything else   this pass's versions, which supersede (SKILL.md, the routing file, tests/, the
                    skill's evidence/ and references/).

One regression this merge introduced and this commit fixes: `EXTENSION-test-harness.md` carried a
device serial in a quoted `adb devices` transcript. It is `<DEVICE>` now, and `check_repo.py`'s
content scan -- the gate added in the same pass -- is what caught it.

Gates on the merged tree: check_repo 0 problem, check_refs 0 dangling / 0 warning, check_routing
coherent, check_budget 0 failure / 0 warning (6 notes, including both corpus thresholds),
check_commands 146 checked / 0 drift, pytest 608 passed / 158 skipped / 25 xfailed.
This commit is contained in:
inliver233 committed 2026-09-22 01:43:07 +08:00
commit fe5bdee087
7 files changed
+239 -26

No files matched your search

+45 -1
View File
@@ -39,6 +39,10 @@ What is measured, and why each measure is shaped the way it is:
load. This reports the ratio of hedging phrases to imperative ones as a *trend*, and lists the
hedged lines it found, so a human can decide -- the gate cannot judge whether a given sentence
should be optional.
7. **Corpus size** (a note, never a failure). The checks above govern what every task *loads*; this
reports what the repository *carries*. The first cannot see the second: a new reference costs
exactly one index line, so the corpus can double while the always-loaded count stays green. A
large corpus is a choice; a growth nobody measured is the defect.
Usage:
python check_budget.py # report; exit 1 if a hard limit is exceeded
@@ -71,6 +75,8 @@ INDEX_ROW_SOFT = 250 # chars of description per row
INDEX_ROW_HARD = 400 # a row longer than this is a paragraph, not an index entry
INDEXES = ('Symptom index', 'Reference index', 'Script index')
NAV_LINES = 100 # above this, a reference must open navigably
CORPUS_FILES_NOTE = 110 # references + scripts, reported as a note past this
CORPUS_LINES_NOTE = 26000 # total lines across the same corpus, same treatment
# A navigable head: one of these must appear in the first NAV_HEAD_LINES lines.
NAV_HEAD_LINES = 40
HEDGE_RE = re.compile(
@@ -276,6 +282,44 @@ def check_discoverable():
return out
def check_corpus():
"""Report corpus size so growth is visible instead of discovered late.
Contributed on this repository while the checks above were being rewritten. Kept as its own
function and its own note: it measures what the repository *carries*, which is a different
quantity from what a task loads, and collapsing the two would let a growing corpus hide behind a
green always-loaded count.
"""
refs = sorted(glob.glob(os.path.join(REFS, '**', '*.md'), recursive=True))
scripts = sorted(p for p in glob.glob(os.path.join(SKILL_DIR, 'scripts', '**', '*'), recursive=True)
if os.path.isfile(p))
def count(paths):
total = 0
for p in paths:
try:
with open(p, encoding='utf-8', errors='replace') as fh:
total += sum(1 for _ in fh)
except OSError:
pass
return total
ref_lines, script_lines = count(refs), count(scripts)
n_files = len(refs) + len(scripts)
lines_total = ref_lines + script_lines
notes = ['corpus: %d references + %d scripts = %d files, %d lines total'
% (len(refs), len(scripts), n_files, lines_total)]
if n_files > CORPUS_FILES_NOTE:
notes.append('corpus is %d files, past the %d-file note threshold -- every entry costs an '
'index line and a share of the maintenance surface, so confirm the new ones are '
'load-bearing rather than merely adjacent' % (n_files, CORPUS_FILES_NOTE))
if lines_total > CORPUS_LINES_NOTE:
notes.append('corpus is %d lines, past the %d-line note threshold'
% (lines_total, CORPUS_LINES_NOTE))
return notes
def main():
ap = argparse.ArgumentParser(description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
@@ -288,7 +332,7 @@ def main():
findings += check_index_rows(lines)
findings += check_discoverable()
findings += check_navigable()
notes = check_restated() + check_hedging()
notes = check_restated() + check_hedging() + check_corpus()
if args.json:
print(json.dumps({