GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(res-to-affine): walker parity for raw-js, untyped-exception, mutable-global (Phase 2c, Refs #57) by hyperpolymath · Pull Request #385 · hyperpolymath/affinescript

Conversation

@hyperpolymath

@hyperpolymath hyperpolymath commented May 26, 2026

Copy link
Copy Markdown
Owner

Summary

Brings the tree-sitter AST walker (Phase 2b, #322) to feature parity with the Phase-1 line-regex scanner across all four anti-patterns. Walker and scanner now emit the same (kind, line) pairs on the synthetic fixture, locked in by a new alcotest.

Pattern Phase 1 (scanner) Phase 2b Phase 2c (this PR)
side-effect-import ✅ regex ✅ AST ✅
raw-js ✅ regex — ✅ AST (new)
untyped-exception ✅ regex — ✅ AST (new)
mutable-global ✅ regex — ✅ AST (new)

New walker detectors

  • raw_js — extension_expression whose extension_identifier is raw or bs.raw. Reaches inside ERROR subtrees so the older [%bs.raw ...] syntax (which the pinned grammar can't parse cleanly) is still flagged.

  • untyped_exception — three structural triggers:

    1. any try_expression (try/catch block);
    2. value_identifier_path OR module_identifier_path whose surface text starts with Js.Exn or Promise.catch (catches the path in both expression and pattern position — line 22 of sample.res | Js.Exn.Error(_) => is the latter);
    3. call_expression whose function child is the bare identifier raise.
  • mutable_global — mutation_expression that lives directly inside an expression_statement at module top level (ancestor chain is expression_statement :: source_file or expression_statement :: block :: module_declaration). In-function x := y against a local ref is correctly not flagged — the structurally-stronger version of the column-0 regex anchor introduced in docs(res-to-affine): corpus run + regex precision fixes (Refs #57) #319.

Shared helper push_finding consolidates the slice/trim/truncate/cons boilerplate that all four detectors now use. The DFS is one pass with all detectors invoked per node.

Phase 2c follow-ups remaining (not in this PR)

  • The two anti-patterns deferred from Phase 1 (inline lambda callback records, oversized 4+ tuple matches) — both need new Scanner.kind variants and emitter guidance.
  • Flipping the CLI default from --engine=scanner to --engine=walker — a behavior change deserving its own PR.
  • The two precision-pass deferrals in CORPUS-RUN.md (module-block nested side effects, top-level let x = ref(...) declarations).

Test plan

  • dune build tools/res-to-affine clean.
  • dune test tools/res-to-affine/ — 9/9 (3 existing emitter + 6 walker cases, 4 new in this PR).
  • dune build + dune test clean repo-wide (327/327 tests pass).
  • Spot-checked end-to-end against tools/res-to-affine/test/fixtures/sample.res:
    walker emits 6 findings, same (kind, line) set as scanner.
  • CI on this PR.

Refs #57 (multi-phase; this is Phase 2c parity port).

🤖 Generated with Claude Code

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@hyperpolymath @claude
feat(res-to-affine): walker parity for raw-js, untyped-exception, mut…
d5797e8
…able-global (Phase 2c, Refs #57)

Brings the tree-sitter AST walker (Phase 2b, #322) to feature parity with
the Phase-1 line-regex scanner across all four anti-patterns. Walker and
scanner now emit the same (kind, line) pairs on the synthetic fixture,
locked in by a new `walker / scanner parity` alcotest.

New walker detectors:

- `raw_js` — extension_expression whose extension_identifier is "raw" or
  "bs.raw". Reaches inside ERROR subtrees so the older `[%bs.raw ...]`
  syntax (which the pinned grammar can't parse cleanly) is still flagged.

- `untyped_exception` — three structural triggers:
    1. any try_expression (try/catch block);
    2. value_identifier_path OR module_identifier_path whose surface
       text starts with `Js.Exn` or `Promise.catch` (catches the path in
       both expression and pattern position — line 22 of sample.res
       `| Js.Exn.Error(_) =>` is the latter);
    3. call_expression whose function child is the bare identifier
       `raise`.

- `mutable_global` — mutation_expression that lives directly inside an
  expression_statement at module top level (ancestor chain is
  `expression_statement :: source_file` or
  `expression_statement :: block :: module_declaration`). In-function
  `x := y` against a local ref is correctly NOT flagged — the
  structurally-stronger version of the column-0 regex anchor introduced
  in #319.

Shared helper `push_finding` consolidates the slice/trim/truncate/cons
boilerplate that all four detectors now use. The DFS is one pass with
all detectors invoked per node.

Phase 2c follow-ups remaining (not in this PR):

- Two anti-patterns deferred from Phase 1 (inline lambda callback
  records, oversized 4+ tuple matches) — both need new Scanner.kind
  variants and emitter guidance.
- Flipping the CLI default from --engine=scanner to --engine=walker
  (a behavior change deserving its own PR).
- The two precision-pass deferrals in CORPUS-RUN.md (module-block
  nested side effects, top-level `let x = ref(...)` declarations).

Test plan:
- `dune build tools/res-to-affine` clean.
- `dune test tools/res-to-affine/` — 9/9 (3 existing emitter + 6 walker
  cases, 4 of them new in this PR).
- `dune build` + `dune test` clean repo-wide (327/327 tests pass).
- Spot-checked end-to-end: walker emits 6 findings on sample.res, same
  (kind, line) set as scanner.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@hyperpolymath
hyperpolymath enabled auto-merge (squash) May 26, 2026 14:02
@github-actions

github-actions Bot commented May 26, 2026

Copy link
Copy Markdown

🔍 Hypatia Security Scan

Findings: 43 issues detected

Severity Count
🔴 Critical 15
🟠 High 16
🟡 Medium 12

⚠️ Action Required: Critical security issues found!

View findings
[
  {
    "reason": "Action hyperpolymath/standards/.github/workflows/governance-reusable.yml@main needs attention",
    "type": "unpinned_action",
    "file": "governance.yml",
    "action": "pin_sha",
    "rule_module": "workflow_audit",
    "severity": "high"
  },
  {
    "reason": "Action actions/checkout@v6 needs attention",
    "type": "unpinned_action",
    "file": "publish-jsr.yml",
    "action": "pin_sha",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Action denoland/setup-deno@v2 needs attention",
    "type": "unpinned_action",
    "file": "publish-jsr.yml",
    "action": "pin_sha",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "TypeScript file detected -- banned language",
    "type": "banned_language_file",
    "file": "/home/runner/work/affinescript/affinescript/affinescript-deno-test/example/smoke_driver.ts",
    "action": "flag",
    "rule_module": "cicd_rules",
    "severity": "critical"
  },
  {
    "reason": "TypeScript file detected -- banned language",
    "type": "banned_language_file",
    "file": "/home/runner/work/affinescript/affinescript/affinescript-deno-test/cli.ts",
    "action": "flag",
    "rule_module": "cicd_rules",
    "severity": "critical"
  },
  {
    "reason": "TypeScript file detected -- banned language",
    "type": "banned_language_file",
    "file": "/home/runner/work/affinescript/affinescript/affinescript-deno-test/mod.ts",
    "action": "flag",
    "rule_module": "cicd_rules",
    "severity": "critical"
  },
  {
    "reason": "TypeScript file detected -- banned language",
    "type": "banned_language_file",
    "file": "/home/runner/work/affinescript/affinescript/affinescript-deno-test/lib/compile.ts",
    "action": "flag",
    "rule_module": "cicd_rules",
    "severity": "critical"
  },
  {
    "reason": "TypeScript file detected -- banned language",
    "type": "banned_language_file",
    "file": "/home/runner/work/affinescript/affinescript/affinescript-deno-test/lib/runner.ts",
    "action": "flag",
    "rule_module": "cicd_rules",
    "severity": "critical"
  },
  {
    "reason": "TypeScript file detected -- banned language",
    "type": "banned_language_file",
    "file": "/home/runner/work/affinescript/affinescript/affinescript-deno-test/lib/discover.ts",
    "action": "flag",
    "rule_module": "cicd_rules",
    "severity": "critical"
  },
  {
    "reason": "TypeScript file detected -- banned language",
    "type": "banned_language_file",
    "file": "/home/runner/work/affinescript/affinescript/packages/affine-js/types.d.ts",
    "action": "flag",
    "rule_module": "cicd_rules",
    "severity": "critical"
  }
]

Powered by Hypatia Neurosymbolic CI/CD Intelligence

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@hyperpolymath
hyperpolymath merged commit 2395c76 into main May 27, 2026
21 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@hyperpolymath
hyperpolymath deleted the feat/issue-57-phase2c-walker-parity branch May 27, 2026 12:07
This was referenced May 30, 2026
feat(res-to-affine): Phase 3 slice 1 — structural type-decl translation (Refs #57) #477
Merged
[Repo] Migration assistant tool: parser + metaparser for .res→.affine skeletons #57
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@hyperpolymath
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.