Repository navigation
fix(routing): triage queries skip code fences, zero-query runs say why - #168
Conversation
--queries-from-headings read a `## comment` inside a fenced code block as a request. Headings inside fences are now skipped (backtick and tilde fences, closed only by the same character at least as long). A run with no usable query exited with a bare "no usable queries" and wrote nothing. It now names the cause, suggests --queries, and writes the result with "status": "no_queries" and a "reason"; a successful result carries "status": "ok". Every routing rate line prints its n_queries, with "triage: self-derived" beside it when the queries come from the artifact's headings. Fewer than five scored queries draw a warning on stdout. Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
The heading pattern used \s+ after the hashes, which also matches a newline, so a bare "##" line read the next line as its heading. The separator is now [ \t]+, and a test pins "##\nfoo bar\n" to no queries. Changelog: the zero-scored routing exit (status no_queries, exit 1 where it used to exit 0 with null rates) is listed under Changed. Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
antonwolfy
left a comment
There was a problem hiding this comment.
Review at 52d90cc. The fence skipping works for the plain cases, and the new rate lines and the no_queries record behave as described. Four points are worth fixing before merge: one bug in the fence matcher, two risks (a model-row count that does not match the lexical one, and tests that miss the fence-closing rules), and one nit.
What I ran, on a Linux review host at 52d90cc:
make ci-local: 20 passed, 8 failed, 7 skipped. The 8 failures areruff,zizmor,pre-commit,bandit,mypy,deptry,mkdocs buildandpip-audit, all exit 127: the tools are missing from my venv becausemake devstops at the tools install on this base, which #179 fixed onmain. Static checks, mypy and the strict docs build pass on GitHub's CI at this head. Tests: 6952 passed, 21 skipped; changed-lines coverage gate passed; schema-compat, wheel build and smoke, and gitleaks passed.- Reproductions for the code findings, with the LLM transport mocked.
- Mutation runs on
_outside_fences: 8 mutants, 3 of which pass the fulltest_novelty_routing.py.
Checked, no issues
- Fence closing: closers need the opener's character and at least its length; trailing spaces, CRLF and unclosed fences behave as CommonMark.
- Heading regex:
##\n foo barno longer takes the next line;##\tTabbed headingis accepted;####stays excluded. - Consumers: nothing in the tree parses the old
over N of M queriesline, no schema coversrouting.json, and the one test that reads it (test_novelty_journey.py) useslexical.n_queries, which is unchanged. - No-query path: it exits before any model call, and it overwrites a stale
status: okfile at--out.
Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #168 +/- ##
==========================================
+ Coverage 91.64% 91.80% +0.15%
==========================================
Files 222 223 +1
Lines 27409 27638 +229
Branches 4508 4553 +45
==========================================
+ Hits 25118 25372 +254
+ Misses 1620 1604 -16
+ Partials 671 662 -9
🚀 New features to boost your workflow:
|
antonwolfy
left a comment
There was a problem hiding this comment.
I pushed a commit per nit, up to 46a0897, which fix the nit from my review:
46a0897:dokimi/dokimi/commands/novelty.py:373: the warning now says 'query' for a count of one and 'queries' otherwise.
make ci-local at 46a0897: 20 passed, 8 failed (all exit 127, tools missing on host), 7 skipped.
Not approving yet. Still open: the bug and the two risks from my review.
…es is of all given Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
…hore(growth): raise commands/novelty.py for W3 Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
…baseline after the extraction Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
…warning threshold A closer indented 1-3 spaces (fences in list items) could stop matching, hiding every heading after it, and no test went red. Also pin "status": "ok" on a successful result, the triage tag on the model row, the warning at 4 scored queries, and a tab after "##". Signed-off-by: Alexander Rybkin <alexander.rybkin@intel.com>
antonwolfy
left a comment
There was a problem hiding this comment.
Review at fc0539e. The three points from my earlier review are fixed: the fence matcher follows CommonMark on the indent and the info string, the model row says n_queries N given, and the tests I asked for are there. One test gap is left before merge.
What I ran, on a Linux review host at fc0539e:
make ci-local: 28 passed, 1 failed, 7 skipped. The failure ispip-auditon the lock files, which this PR does not touch. Tests: 7223 passed, 1 skipped; changed-lines coverage gate, schema-compat, docs build, wheel build and smoke, and gitleaks passed.- Mutation runs on
_FENCE,_outside_fencesand the heading regex: 18 mutants; some pass the fulltest_novelty_routing.py. The ones that matter are on the inline comment.
Checked, no issues
- Fence rules: a tab indent, a 4-space indent, a backtick in a backtick opener's info string, a
~~~line inside a backtick block, a```jsline inside a block, trailing spaces/tab and CRLF on the closer all behave as CommonMark; each of the first five now has a test that fails when the rule is removed. - No-query path: all-fenced headings, a blank queries file, an empty JSON list and an all-stopword file each exit 1 with a reason and write
status: no_queries; the model is not called. - Consumers: the only reader of
routing.jsonin the tree istest_novelty_journey.py, which useslexical.n_queries; the addedstatuskey breaks nothing. - Growth ratchet:
novelty.pyis 863 lines, matching the raised baseline, andcmd_novelty_routingcomplexity is lowered to 12.
|
antonwolfy
left a comment
There was a problem hiding this comment.
Review at b6e3d7d. The commit since fc0539e adds test-only changes, and they close @xaleryb's gaps on indented closers, status: ok, the model-row tag and the warning threshold. One test gap from my earlier review is still open, so I am not approving yet.
What I ran, on a Linux review host at b6e3d7d:
make ci-local: 28 passed, 1 failed, 7 skipped. The failure ispip-auditon the lock files, which this PR does not touch. Tests: 7257 passed, 1 skipped; changed-lines coverage gate, schema-compat, docs build, wheel build and smoke, and gitleaks passed.- Two mutants run against the full
tests/test_novelty_routing.py(98 tests): both pass.
Still open from my earlier review:
dokimi/tests/test_novelty_routing.py:593: the minimum fence length and the heading separator are still unpinned. With_FENCEat{2,}for both characters,headings_as_queries("~~strike~~ text\n## Real heading one\n")returns[]instead of['Real heading one'], and all 98 tests pass. With the heading regex at^#{2,3}[ \t]*(.+)$,headings_as_queries("##hashtag word\n")returns['hashtag word']instead of[], and all 98 pass. The new##\tTab heading wordstest does not help: it passes under[ \t]*too. The new indent tests use three-character fences only. Suggestion: addheadings_as_queries("~~strike~~ text\n## Real heading one\n") == ["Real heading one"]andheadings_as_queries("##hashtag word\n") == [].
Checked, no issues
- Zero-query path: an all-stopword file, a blank file and an all-fenced heading file each exit 1 with a reason and write
status: no_queries. - Rate line and warning:
triage: self-derivedshows on the rate line only for headings-derived queries; the warning fires below five scored queries. - Docs and changelog: the docs tests, the growth ratchet and ruff pass on the changed files.
Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
antonwolfy
left a comment
There was a problem hiding this comment.
LGTM. The two tests added in 6125691 pin both points from my earlier thread, and nothing else changed since b6e3d7d.
What I ran, on a Linux review host at 6125691:
make ci-local: 28 passed, 1 failed, 7 skipped. The failure ispip-auditon the lock files, which this PR does not touch. Tests: 7261 passed, 1 skipped; changed-lines coverage gate, schema-compat, docs build, wheel build and smoke, and gitleaks passed.- Mutation runs against the full
tests/test_novelty_routing.py(102 tests):_FENCEat{2,}for backtick, for tilde and for both, and the heading regex at[ \t]*, each turn a test red. Seven further mutants on the indent bounds, the closer length, the closer character, trailing text on a closer and the backtick info-string lookahead are each killed by one test.
Checked, no issues
- Fence minimum:
~~strike~~ text,``x`` textand``x textkeep the heading after them. - Heading separator:
##hashtag wordyields no query. - Docs and changelog: exit code 1,
status: no_querieswith areason, then_queries N of M given/n_queries N givenrate lines, thetriage: self-derivedtag and the under-five warning match the code.
Part of #4.
Depends on #164: both append tests to
tests/test_novelty_routing.py, so this rebases cleanly only after #164 merges.Summary
novelty routing --queries-from-headingsstops reading code-block lines as requests, and a run with no usable query says why.Evidence
Nine new tests in
tests/test_novelty_routing.py. Againstintel/main(commands/novelty.pyandnovelty/routing.pyreverted, rest of the branch kept), nine fail:Local checks on the rebased head:
Merge Danger
Door: two-way. The exit-code change is the only one that a script can see, and it is reversible by reverting the commit.
Blast Radius: low, limited to
novelty routing."status": "no_queries"with areason. Scripts that read the null rates as a result must check the exit code orstatus. This is the one change to existing behaviour.routing.jsonbefore exiting. A batch run finds a record instead of nothing.--queries-from-headingsoffers fewer, and different, self-derived queries on artifacts with code blocks. They remain triage only and stay stampedqueries_self_derived.n_queries N given, ...and carriestriage: self-derivedwhen the queries came from headings. Line-parsers need updating.Checklist
pytestpassesruff,mypy, and schema checks passdocs/skill-novelty.md(routing section)🤖 Generated with Claude Code