Skip to content

fix: correct scanner positions, suppress stderr noise, and fix stdin hang#155

Merged
rhuanbarreto merged 3 commits intomainfrom
fix/scanner-positions
Mar 23, 2026
Merged

fix: correct scanner positions, suppress stderr noise, and fix stdin hang#155
rhuanbarreto merged 3 commits intomainfrom
fix/scanner-positions

Conversation

@rhuanbarreto
Copy link
Copy Markdown
Contributor

@rhuanbarreto rhuanbarreto commented Mar 23, 2026

Summary

  • Scanner stderr noise: Remove logError that printed scanner violations to stderr unconditionally — violations now flow only through the structured JSON/console reporter, so --json output is clean
  • Wrong line/column in violations: Bun.Transpiler strips comments and types, shifting AST positions. Added string-search remapping (source-positions.ts) that finds violations in the original source by occurrence order, skipping matches inside comments and string literals
  • stdin hang: archgate check blocked forever when spawned by editors or in pipe chains because Bun.stdin.text() waited for EOF on an empty stdin. Now races against a 100ms timeout
  • Git credential prompts in tests: Added GIT_TERMINAL_PROMPT=0, GCM_INTERACTIVE=never, and GIT_ASKPASS="" to test preload so credential managers don't pop up during test runs
  • Misc: Add bin/ to .gitignore, use Bun.env instead of process.env in test preload

Changes

File What
src/engine/loader.ts Remove logError loop for scanner violations
src/engine/rule-scanner.ts Replace loc(node) with pushViolation + remapViolations
src/engine/source-positions.ts New — non-code range detection, code-only occurrence search, position remapping
src/commands/check.ts Race Bun.stdin.text() against 100ms timeout to prevent hang
tests/preload.ts Suppress git credential prompts, use Bun.env
tests/engine/rule-scanner-positions.test.ts New — 16 tests for transpilation position remapping
tests/engine/rule-scanner-adversarial.test.ts New — 18 tests for patterns in comments/strings
tests/engine/source-positions.test.ts New — 5 unit tests for the remapping module

Test plan

  • bun run validate passes
  • archgate check --json produces clean JSON on stdout with no stderr noise for scanner violations
  • Scanner violations report correct original-source line/column (not transpiled positions)
  • Patterns in comments/strings before code violations don't confuse the remapping
  • echo "src/cli.ts" | archgate check still works (stdin pipe)
  • archgate check from VS Code extension doesn't hang
  • No git credential prompts during bun test

🤖 Generated with Claude Code

rhuanbarreto and others added 2 commits March 23, 2026 20:08
…mode

- Remove logError in loader that printed scanner violations to stderr
  unconditionally — violations now flow only through the result pipeline
- Fix wrong line/column in scanner violations: Bun.Transpiler strips
  comments and types which shifted AST positions. Added string-search
  remapping that finds violations in the original source by occurrence
- Skip matches in comments and string literals when remapping positions
  so patterns like "// Don't use Bun.spawn" don't confuse the mapping
- Fix stdin hang in check command when spawned by editors or in pipes
  by racing Bun.stdin.text() against a 100ms timeout
- Suppress git credential prompts in test preload via GIT_TERMINAL_PROMPT,
  GCM_INTERACTIVE, and GIT_ASKPASS environment variables
- Add 39 new tests for position remapping and adversarial edge cases

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Mar 23, 2026

Deploying archgate-cli with  Cloudflare Pages  Cloudflare Pages

Latest commit: 91842c2
Status: ✅  Deploy successful!
Preview URL: https://470c68a8.archgate-cli.pages.dev
Branch Preview URL: https://fix-scanner-positions.archgate-cli.pages.dev

View logs

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@rhuanbarreto rhuanbarreto changed the title fix: correct scanner positions and suppress stderr in JSON mode fix: correct scanner positions, suppress stderr noise, and fix stdin hang Mar 23, 2026
@rhuanbarreto rhuanbarreto merged commit 387b318 into main Mar 23, 2026
8 of 9 checks passed
@rhuanbarreto rhuanbarreto deleted the fix/scanner-positions branch March 23, 2026 19:14
@github-actions github-actions bot mentioned this pull request Mar 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant