fix(ci): repair the lint gate and the CRLF-fragile source scan on main - #178
Open
fxogg06-jpg wants to merge 1 commit into
Open
fxogg06-jpg wants to merge 1 commit into
fxogg06-jpg wants to merge 1 commit into
Conversation
Two independent defects broke the verification workflow on main:
1. `bun run lint` failed with 4x no-useless-assignment in
src/controllers/anthropic.js. In handleAnthropicStream and
handleAnthropicNonStream, `promptTokens`/`completionTokens` were
initialised to 0 and then unconditionally overwritten from the
authoritative usage object, so the initialisers were dead stores.
Remove the write-only locals and take both values as consts directly
from `usage` at the single point where they are resolved. No behavior
change: the values consumed by attributeChatUsage and the emitted
usage payload are identical.
2. tests/tool-prompt.test.js:805 failed on any CRLF checkout ("ningun
sitio de prompt/hint re-ensena la forma nativa <tool_call>"). The
per-line comment strip used a line-comment regex anchored with `$`,
and on CRLF input the dot stops before the CR so `$` matches there;
the match is not global, so the engine backtracked, matched the empty
string, and left the comment body in `code`. The rationale comments
that legitimately name `<tool_call>` then tripped the source scan.
Bound the strip by the newline instead, which is what the test
intends on both LF and CRLF checkouts.
Verified locally: lint exit 0; frontend build exit 0; test gate PASS
1146 tests / 134 suites / 0 fail (matches tests/expected-counts.json);
bun test:bun smoke PASS (8/8).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
mainat 928f816 has a redverify / regressionjob. The failing step is 7.Run bun run lint, which means step 8 (bun run test) is skipped — so the regression suite has not actually run on this commit. Fixing only the lint error would turn CI green while the second defect below stays hidden; both are included here.Reproduced locally on a clean checkout of 928f816.
1.
bun run lintfails with 4xno-useless-assignmentIn both
handleAnthropicStreamandhandleAnthropicNonStream, the two counters were initialised to0and then unconditionally overwritten from the authoritative usage object:The initialisers are dead stores: nothing reads the variables before the assignment. The locals are write-only intermediates, so they are removed and both values are taken as
constdirectly fromusageat the single point where they are resolved.No behaviour change — the values passed to
attributeChatUsageand written into the emittedusagepayload are byte-for-byte the same. This is a pure dead-store removal, not a change to how usage is resolved or estimated.2.
tests/tool-prompt.test.js:805fails on any CRLF checkoutThat test scans
chat.js/anthropic.js/request.jsto pin at source level that no model-readable string re-teaches the native<tool_call>form. It deliberately strips comments first, because the rationale comments in the tree legitimately name<tool_call>:The per-line strip is anchored with
$. On CRLF input.does not match\r, so$matches before the CR, and because that regex has nogflag the engine backtracks to the empty match at position 0 — leaving the entire comment body incode, including the<tool_call>the test means to exclude. It then trips on its own rationale comments:// 错误列表(hasParseError 永远为真,即使重试本身成功),而一个被截断的 <tool_call>Bounding the strip by the newline instead is what the test intends, and behaves identically on LF:
Also worth noting for triage: this is a git checkout dependency, not a platform one —
core.autocrlf=true(default on Windows) is enough to trigger it, and the repo has no.gitattributespinning* text=auto eol=lf. Adding one would be a more structural follow-up, but I kept this PR to the two defects so it stays reviewable.Verification
Run on Windows, Bun 1.4.2 (from
package.json), Node v24.21.0, matching the workflow's environment:bun run lintbun run testbun run build:frontendbun run test:bun1146 / 134 / 0 failmatchestests/expected-counts.jsonexactly, so the count gate is satisfied rather than merely non-failing. The smoke run covers real Bun startup, login, frontend, WASM, HTTP/SSE (including a 16 s upstream delay), and agent mid-stream quota failover.Verified the patch applies cleanly onto a fresh clone of
mainat 928f816 before opening this PR.