Skip to content

v0.7.37 - a check that cannot be seen is not a check

Choose a tag to compare

@Raknaos Raknaos released this 03 Oct 15:38
· 9 commits to main since this release

0.7.37 - a check that cannot be seen is not a check

The defect

@check is what prints a verdict line and appends it to RESULTS. A function
whose name sits in LOCAL/LIVE but which no @check decorator wraps cannot
fail the gate at all - the loop calls it, the return value goes nowhere.

That hazard was recorded as prose (point 13). Nothing proved it. Measured
0.7.37: the audit existed only as ad-hoc runs, so a check could be written,
registered, and left without its decorator with the gate still reporting 53/53.

The new check reads the gate's own source with ast and proves three things at
once:

  • every registered name resolves to a function - otherwise the gate raises
    NameError instead of reporting
  • every registered function carries @check
  • no top-level function is neither registered, nor decorated, nor called
ok   every registered check is decorated and resolvable
     53 checks: every registered name resolves and is decorated; 18 helpers are
     all called; nothing is neither

The audit was wrong twice before it was right

Both failures are the same shape as earlier ones in this repo: a regex over
Python source.

The first version matched ast.Name for the decorator. But @check("x") is an
ast.Call, not a Name - so it reported all 53 checks as undecorated. An
earlier line-slicing version ran past the closing bracket of LOCAL into the
next function body and counted 191 names where the gate runs 53.

So: parse the gate with ast, never with a regex over its text.

A helper is identified by being called

The third clause needed two corrections. Its first version flagged the twelve
real helpers - record, relay_call, project_python, _node_pass_count - as
checks written and never wired, and reddened on a perfectly healthy tree.
A check that refuses the correct state measures nothing.

A helper's identity is that something calls it, not how it is named or
decorated. A top-level def that no other code calls is the only genuine
orphan:

FAIL 1 function(s) are never registered, never decorated and never called:
      _node_pass_count_unused - a check written and never wired is a comment
      about a bug

Gate

53 checks, 0 skipped. 262 Python tests, 244 node assertions, relay self-test ok.

A note on the process

I destroyed CHANGELOG.md twice in this session with the same mistake - a
write_text(...) chained onto another write_text(...), where the first call
returns the number of bytes and the second was invoked on an int. The file
went from 1154 lines to 6. Both times it was restored from HEAD and the entry
was prepended in a single write.

The gate's own changelog_is_not_duplicated check did not catch a six-line
file with one entry - there was nothing to duplicate. That is not a gap in it;
it is what the check is for. Restoring from HEAD and re-reading the head of the
file before claiming it works is the whole lesson, and it is the reason this
paragraph exists rather than a silently fixed file.