Repository navigation
serve: print the [prefix] line on the refusal branch too, where it has never once fired (engine#2895) - #2898
bong-water-water-bong wants to merge 1 commit into
Conversation
…s never once fired (engine#2895)
The [prefix] slot= line sits inside the branch that requires cache_prompt, so the refusal branch above it recorded stats.prefix = {-1, 0, "cache_prompt: false"} and emitted nothing. A serve log with the cache declined therefore had no [prefix] line at all -- indistinguishable from the prefix path not being reached, which is the pair of states that line exists to separate (#650).
The in-code comment above the refusal claimed the line below 'says so rather than staying silent'. It did not. A comment that promises a diagnostic is worse than no comment, because the next reader trusts it instead of checking -- which is how this survived #2889 with a CHANGES on it.
Three lines, no control-flow change: the print is duplicated into the refusal branch with the same format and the same arguments, and both prints sit inside an e.prefix && e.prefix->enabled() guard, so exactly one fires per request and neither fires when the prefix path is off. I considered hoisting to a single print after both branches and did not: that restructures the block, and a C++ refactor I cannot build here is worth less than an addition whose guard is visible in two lines.
NOT BUILT locally -- this tree needs the full ONEBIT_HRX configuration and I am not spending the fleet's queue on it. CI is the build. What I did verify: exactly two [prefix] slot= prints, each inside its own enabled() guard, and the file's braces balance.
|
VERDICT at 1d8296: CHANGES — superseded by Land |
Superseded by #2899 — same issue (engine#2895), better shape#2899 fixes this by introducing one const auto log_prefix = [&ids](const npu::PrefixDecision& d) {
std::fprintf(stderr, "[prefix] slot=%d cached=%d of %zu reason=%s\n", …);
};
… log_prefix(stats.prefix); // accept branch
… log_prefix(stats.prefix); // refusal branchand adds a check arm that fails when a recorded decision has no log within 12 lines (mutation-verified: The difference that matters is the third path: with one function, a new decision site has to call it; with an extra Suggestion: |
|
VERDICT at 31d7744: CHANGES — superseded by The substance is unchanged and short:
Same fix in all three. So: land |
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
|
My commit duplicated the fprintf onto the refusal branch — the option I explicitly considered and declined as 'a C++ refactor I cannot build here'. Main's version hoists it into a 504: const auto log_prefix = [&ids](const npu::PrefixDecision& d) {
512: log_prefix(stats.prefix); <- refusal branch, the one that never printed
533: log_prefix(stats.prefix); <- consulted branchOne definition, two call sites, no duplicated format string — which is what I said I would not attempt without a build, and the right answer regardless. engine#2895 is fixed on main; this PR is superseded and the branch is deleted. The lesson costs me nothing to write: the cheaper option was cheaper because I could not verify it, not because it was better. A lane that can build should always prefer the hoist. |
Fixes engine#2895 — the
[prefix]line that explains a cache refusal has never printed on the branch that refuses.The defect, in two line numbers
So a serve log with the cache declined had no
[prefix]line at all — indistinguishable from the prefix path not being reached, which is the pair of states that line exists to separate (#650).And the comment directly above the refusal claimed the line below "says so rather than staying silent." It did not. A comment that promises a diagnostic is worse than no comment, because the next reader trusts it instead of checking — which is how this survived #2889 carrying a CHANGES on it.
The change
Three lines, no control-flow change: the print is duplicated into the refusal branch with the same format and the same arguments.
Both prints sit inside an
e.prefix && e.prefix->enabled()guard, so exactly one fires per request and neither fires when the prefix path is off:I considered hoisting to a single print after both branches and did not. That restructures the block, and a C++ refactor I cannot build here is worth less than an addition whose guard is visible in two lines.
What I verified, and what I did not
Verified by reading: exactly two
[prefix] slot=prints, each inside its ownenabled()guard; the file's braces balance (375 / 375);tools/copyright.py --checkpasses.Not built locally. This tree needs the full
ONEBIT_HRXconfiguration and I am not spending the fleet's queue on a three-line addition. CI is the build — and if CI disagrees with my reading, the reading is what is wrong.