Skip to content

Commit 8bf2f47

Browse files
committed
fix(build-x): portable token-boundary regex in hallucination-check.sh
The initial manifest-resolution regex used a complex character class (['"\[ ] / ['"\] =<>~,]) that parses subtly differently across grep flavors — under ugrep (the grep on some Linux distros) it failed to match 'requests' in dependencies = ["requests"] even though GNU grep / BSD grep both matched it. Replace with the portable complement-of-name-chars pattern: (^|[^a-zA-Z0-9_-])${name}([^a-zA-Z0-9_-]|$) Applied to both check_python and check_rust. Equivalent in intent — the package name is a whole token, preceded and followed by a non-name char (or line boundary). Conservative by design (prefers false-positive avoidance over false-negative pickup). Caught by the cycle smoke (block §F1/§F2: 'requests' was being flagged as unresolved on a fixture where pyproject.toml clearly declared it). Item F follow-up.
1 parent 2819653 commit 8bf2f47

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

runtime/multi-agent/scripts/hallucination-check.sh

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,14 @@ check_python() {
132132
# In-repo module (file or package at the top level).
133133
if [[ -f "${top}.py" || -d "${top}" ]]; then continue; fi
134134

135-
# Look in the manifest's dependency lists. Cheap grep is sufficient
136-
# for the common case (the spec acknowledges this is conservative).
137-
if grep -qE "(^|[\"'\[ ])${top}([\"'\] =<>~,]|\$)" "${manifest}" 2>/dev/null; then
135+
# Look in the manifest's dependency lists. Match the package name
136+
# as a whole token — preceded and followed by a non-name char (or
137+
# line boundary). The negated bracket-expression form is portable
138+
# across grep flavors (GNU grep, BSD grep, ugrep) where the
139+
# `["'\[ ]`-style classes parse subtly differently. Conservative
140+
# by design (spec acknowledges false-positive avoidance over
141+
# false-negative pickup).
142+
if grep -qE "(^|[^a-zA-Z0-9_-])${top}([^a-zA-Z0-9_-]|\$)" "${manifest}" 2>/dev/null; then
138143
continue
139144
fi
140145

@@ -222,8 +227,9 @@ check_rust() {
222227
# `crate`, `self`, `super` are language constructs.
223228
case "${crate}" in crate|self|super|std|core|alloc) continue ;; esac
224229

225-
# Look in Cargo.toml dependencies.
226-
if grep -qE "(^|[\"'])${crate}([\"' =])" "${manifest}" 2>/dev/null; then
230+
# Look in Cargo.toml dependencies — same robust token-boundary
231+
# pattern as the Python check.
232+
if grep -qE "(^|[^a-zA-Z0-9_-])${crate}([^a-zA-Z0-9_-]|\$)" "${manifest}" 2>/dev/null; then
227233
continue
228234
fi
229235

0 commit comments

Comments
 (0)