Repository navigation
Description
What is wrong
The Python bitwise_ops rule is <<|>>|\^|~ matched as text. It counts those characters inside string literals and regex patterns, so it scores the engine's own regexes as bit-twiddling. A function containing only the string below scores 3. Precision against ast is 0.32 over 72,044 functions (the family fired in 6,700 functions; about a third contain any bitwise-looking operator, counting & and |). The planted case below proves the mechanism; what share of the 6,700 is string or comment content has not been counted yet, so that is the first thing to measure. It also ignores & and |, by design (set and dict operators), which is the reason recall is 0.15 against an oracle that counts them: that part is a definition choice, not the bug.
Reproduce
import re
def bits(s):
return re.compile(r"^a|~b<<") # no bitwise operator; bitwise_ops == 3Expected
bitwise_ops counts operators in operator position, not characters in strings or comments. Other languages have the same text-rule shape (yacc, zig, css and others carry a similar bitwise_ops regex): check whether string/comment blanking already runs before the family rule on those, and why not for Python.
How this was found
A pilot that compares each function_data signal with what Python's own ast says the function does (72,044 functions of GitGalaxy's own code; see the pilot note, with corrections and one-function-per-case reproductions in temporal-crucible PR #188). This is part of the keyword-family validity epic (linked below once filed).
Rules for the fix
- Any change to a keyword list adds or removes regex work, so time it: CPU seconds on keyword-rosetta and language-crucible before and after, and say the number in the PR.
- If keyword-rosetta counts move, label the PR
rosetta:rebless-owedand rebless as usual. - Add the case below as a test (one function per case, so a regression names itself).
Activity
squid-protocol commentedon Nov 21, 2026
Part of #8863 (keyword-family validity epic).
squid-protocol commentedon Nov 21, 2026
Measured with the new tool (#8864): reading only operators in operator position (
<< >> ^ ~, the same set the Python rule means;&and|left out as the rule leaves them out), 230 of GitGalaxy's own 72,044 Python functions have one, whilebitwise_opsfires in 6,700. Of the family's hits, about 3% are real operators (precision 0.03); recall is 1.00. So roughly 97% of the Pythonbitwise_opscount is characters in strings, regexes or comments. That settles the open point in the body above.squid-protocol commentedon Nov 21, 2026
Correction (2026-11-21). My earlier comment (230 functions, precision 0.03) read the contract too narrowly: it left out
&and|, which the contract names ("shift, and, or, xor, or the unary complement"). With the oracle aligned to the contract, andstr | Noneannotations excluded (a type union is not a bitwise operator on values), a parser sees a bitwise operator in 2,294 of GitGalaxy's own Python functions; the family fires in 6,700. Recall 0.43, precision 0.15: about 85% of the family's hits are not bitwise operators (the planted string case in the body above proves one mechanism), and it misses the|(1,014 functions) and&(925) its contract includes. The cross-language version of this, with the generics mechanism, is #8866.squid-protocol commentedon Nov 21, 2026
Correction (2026-11-21): the string-literal mechanism in the body above is documented engine behaviour, not a regression: #2535 was closed as not-a-bug (no string-literal shielding exists for structural signals; only comments are stripped) and keyword-rosetta's string decoy expects it. It conflicts with the contract's "in operator position", so it is a decision (see #8866). The genuine bugs here are the missed
&/|and, in generic-heavy languages, closing>``>counted as a shift.squid-protocol commentedon Nov 21, 2026
Claimed by promoter-bot host
melek, lease renewed 2026-11-22T00:03Z. It lapses after 6 h without a renewal. To take it back, assign someone or remove theclaim:meleklabel.tests/tools: family_oracle scores each keyword family against an ast …
Python bitwise_ops counts & and |, not type unions (Closes squid-prot…