Repository navigation
Conversation
Semgrep writes two records of the same run: the SARIF invocations'
toolExecutionNotifications, and the JSON errors[] array. They are not the same
set. On a 436k-line C tree the notices named 252 files and errors[] named 249.
machdep.h ("Other syntax error") appeared in the JSON alone.
Only the notices reach monitor/sarif-read.mjs. A file the notices omit is a file
the lane reports clean. That is the silent-clean class the coverage accounting
exists to close: a short result list read as a clean tree.
semgrep-retry.mjs already copies the JSON's time.fixpoint_timeouts into the
SARIF for exactly this reason. This does the same for errors[], under
properties.commitworkJsonErrors, and only for the types that mean "read only in
part": Syntax error, Other syntax error, Lexical error, Timeout, PartialParsing.
A type the script does not map is counted in the receipt as unclassified rather
than guessed at. A type Semgrep adds later is then visible.
Two ways it must not fire, both pinned by a test. A file the notices already
name is left alone, because injecting it again would inflate the notice count
without changing the file count. A file the retry already re-measured is left
alone too: partialLedger cleared its row because the retry resolved it, not
because the notices omitted it. Injecting it back would claim a recovery that is
not one.
Measured on the Hercules tree: 1 file injected (machdep.h), 233 to 234 files
read only in part, and a second pass injects nothing.
Note: Semgrep writes `type` as a string for a syntax error and as an ARRAY for a
partial parse (["PartialParsing", {...}]). The map is keyed on the first element
when it is an array. String(type) would never match the latter, which is how 196
entries first read as unclassified.
Refs: cw-hercules-scan-20261129 F6
Portll
force-pushed
the
fix/semgrep-json-errors-20261206
branch
from
December 6, 2026 08:25
8f06c0e to
a607032
Compare
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.
The defect
Semgrep writes two records of the same run: the SARIF invocations'
toolExecutionNotifications, and the JSONerrors[]array. They are not the same set.Measured on the Hercules tree (
SDL-Hercules-390/hyperion@8ab5c3f1, 436k lines of C):errors[]machdep.h, "Other syntax error")Only the notices reach
monitor/sarif-read.mjs. A file the notices omit is a file the lane reports clean — the silent-clean class the coverage accounting exists to close. A short result list read as a clean tree.The fix
semgrep-retry.mjsalready copies the JSON'stime.fixpoint_timeoutsinto the SARIF for exactly this reason (properties.commitworkFixpoint). This does the same forerrors[], underproperties.commitworkJsonErrors, and only for the types that mean "read only in part":Syntax error,Other syntax error,Lexical error,Timeout,PartialParsingA type the script does not map is counted in the receipt as
unclassifiedrather than guessed at, so a type Semgrep adds later is visible.Two ways it must not fire, both pinned by a test
partialLedgercleared its row because the retry resolved it, not because the notices omitted it. Injecting it back would claim a recovery that is not one.Measured on the Hercules tree
CLI:
A trap worth knowing
Semgrep writes
typeas a string for a syntax error and as an array for a partial parse (["PartialParsing", {...}]).String(type)never matches the latter — that is how 196 entries first read asunclassified. The map is keyed on the first element when it is an array.Tests
6 new cases in
bin/test/semgrep-retry.test.mjs:readJsonErrorsmaps a string type and an array type, dedupes per file+reason, and counts what it cannot maperrors[]names and the notices do not is injected, and only that file--jsonleaves the SARIF byte-identical and says sobin/test/semgrep-retry.test.mjs62/62 on this base (56 existing + 6 new).Rebased
Rebased onto
5e2bf407 fix(bin): retry timed-out files in batches inside the budget. The first cut of this branch was cut from a localmainthat predated that commit and would have reverted it; the diff here is additive only (2 intentional line changes in each file).What this does NOT fix
The magnitude of the loss, not its honesty. On this tree 222 files fail to parse and 24 time out. All of it is reported as
degradedwith the files named, and5e2bf407already raised the retry cap to 500 files across batches, so the cap is no longer the binding constraint here. What remains is Semgrep's C parser on this codebase, which is a tool limitation rather than a lane defect.Refs: cw-hercules-scan-20261129 F6
Correction (2026-12-06): #23 explains the measured instance
The one file this PR injected on the Hercules tree was
machdep.h. The reason it was missing fromthe notices is a case-sensitive regex in
monitor/sarif-read.mjsthat does not match Semgrep'slower-case
Other syntax error. PR #23 fixes that.With #23 applied the two records agree exactly on this tree: 249 files from the SARIF notices, 249
from the JSON
errors[], zero difference in either direction. On the only tree measured, this PR'sinjection is a no-op once #23 lands.
It stays open as a cross-check between two independent records, not as a fix for that instance. A
file the notices genuinely omit, for a reason other than a message shape the reader cannot parse,
is still invisible without it. The honest reading is that the measured divergence had a single
cause, and that cause was #23's.