mirror of
https://codeberg.org/reverse-skill-lab/apk-reverse
synced 2026-11-15 20:04:22 +08:00
Make the budget gate's hard index-row limit actually fail
`check_index_rows` read `'warn' if hard else 'warn'` -- both branches identical -- so INDEX_ROW_HARD was defined, computed, and unable to fail anything: an index row could grow without bound while every gate stayed green. Found by injecting an over-long row into SKILL.md and requiring the gate to fail. That is the only way a dead threshold shows itself; a gate that has only ever been observed passing is not evidence that it can see anything. A test now pins both sides -- a row past the soft limit warns, a row past the hard limit fails -- and it was checked against the pre-fix behaviour, where it fails.
This commit is contained in:
+5
-1
@@ -196,7 +196,11 @@ def check_index_rows(lines):
|
||||
out = []
|
||||
for section, key, size in long_rows:
|
||||
hard = size > INDEX_ROW_HARD
|
||||
out.append(('warn' if hard else 'warn',
|
||||
# `hard` must actually escalate. This read `'warn' if hard else 'warn'` -- both branches the
|
||||
# same -- so INDEX_ROW_HARD was defined, computed and never able to fail anything: an index
|
||||
# row could grow without limit and CI stayed green. Found by injecting an over-long row and
|
||||
# asking the gate to fail, which is the only way this class of defect shows up.
|
||||
out.append(('fail' if hard else 'warn',
|
||||
'%s: row for %s is %d chars (soft limit %d)%s' %
|
||||
(section, key, size, INDEX_ROW_SOFT,
|
||||
' -- that is a paragraph, not an index entry' if hard else '')))
|
||||
|
||||
@@ -88,3 +88,27 @@ def test_the_fallback_constant_is_the_calibrated_one(budget):
|
||||
assert abs(budget.TOKENS_PER_CHAR - expected) < 0.25, (
|
||||
"TOKENS_PER_CHAR is %.3f but this SKILL.md measures %.3f characters per token -- the "
|
||||
"document changed, so recalibrate" % (budget.TOKENS_PER_CHAR, expected))
|
||||
|
||||
|
||||
def test_an_index_row_past_the_hard_limit_fails_rather_than_warns(budget):
|
||||
"""The hard index-row limit must escalate, or the limit it names is decorative.
|
||||
|
||||
It read `'warn' if hard else 'warn'` -- both branches identical -- so `INDEX_ROW_HARD` was
|
||||
defined, computed, and unable to fail anything: an index row could grow without bound while
|
||||
every gate stayed green. That is the same failure mode this file exists for, one level up: the
|
||||
measurement happened and the verdict did not follow. It was found by injecting an over-long row
|
||||
and requiring the gate to fail, which is the only way a dead limit shows itself -- a gate that
|
||||
has only ever been seen passing is not evidence that it can see anything.
|
||||
"""
|
||||
def levels(desc_len):
|
||||
lines = [
|
||||
"## Symptom index",
|
||||
"| What you observe | Load first |",
|
||||
"| a row | %s |" % ("y" * desc_len),
|
||||
]
|
||||
return {level for level, _ in budget.check_index_rows(lines)}
|
||||
|
||||
assert levels(budget.INDEX_ROW_SOFT + 10) == {"warn"}
|
||||
assert levels(budget.INDEX_ROW_HARD + 10) == {"fail"}, (
|
||||
"a row past INDEX_ROW_HARD (%d chars) must fail the gate, not warn about it"
|
||||
% budget.INDEX_ROW_HARD)
|
||||
|
||||
Reference in New Issue
Block a user