Skip to content

fix(semantics): recognize Node builtin default namespaces - #769

Merged
N0zoM1z0 merged 2 commits into
morluto:mainfrom
rudycelekli:fix/builtin-default-namespace-effects-20261006
Oct 7, 2026
Merged

N0zoM1z0 merged 2 commits into
morluto:mainfrom
rudycelekli:fix/builtin-default-namespace-effects-20261006

Conversation

@rudycelekli

Copy link
Copy Markdown

Summary

Recognize ESM default and { default as ... } imports as namespace objects for explicitly identified Node built-ins. The existing resource, child process, timer, request, and filesystem configuration collectors currently discard these imports because their imported path is ["default"].

Native reproduction

Node exposes the same fs.readFileSync, child_process.spawn, timers.setTimeout, and http.get methods through default and namespace imports. A real filesystem read/stream, owned child process, and cleared timer provide runtime controls. The built public analyze-javascript-application command reports five effect nodes for namespace imports but zero for both default forms before this change; all three forms report the same five afterward.

External imports, named non-namespace imports, and shadowed parameters remain negative controls. require('fs').default also produces no resource facts; this change uses the existing ESM direct-import provenance only. No runtime execution or schema changes are introduced.

Verification

  • 208 focused semantic and public CLI tests pass across 11 files.
  • npm run build:cached, npm run check, and npm run check:fast pass (125 existing lint warnings, zero errors).
  • Native Node and emitted public CLI before/after checks pass.
  • Signed commit with DCO: d7970942d2ddcb2a337376d9bcec5cda0617cb3c.

Codex assisted on behalf of @rudycelekli with reproduction, implementation, tests, and an independent source review. Hosted CI will run separately; no full-suite result is claimed here.

@morluto

morluto commented Oct 6, 2026

Copy link
Copy Markdown
Owner

Reviewed: recognizing Node builtin default namespaces (import fs from 'node:fs' / import {default as fs}) as namespace objects is correct per ESM/CJS interop — bindImports yields ["default"] and the caller already verified the specifier. All 5 collectors updated, negatives preserved (external path, named rebind, shadowed param). Domain + CLI acceptance coverage is strong. APPROVE. Nit: new import is before the Babel import; consider matching existing ordering.

@morluto

morluto commented Oct 6, 2026

Copy link
Copy Markdown
Owner

Review — APPROVE

Summary

Adds semanticBuiltinNamespacePath() ([] or ["default"]) and uses it in 5 collectors (resources, child-process, timers, data-effects, http-request), so import fs from 'node:fs' and import { default as fs } are treated as namespace objects like import * as fs.

Verification

  • Correct per Node ESM/CJS interop: bindImports produces ["default"] for default specifiers; after the caller verifies the specifier is node:fs / child_process / timers / http, accepting ["default"] is not identity-guessing.
  • Negative controls preserved (external path, import { constants as fs }, shadowed param).
  • Tests: javascriptSemanticAnalysis.builtin_defaults.test.ts (3 import forms × 4 builtins, 5 effect assertions + 3 negatives) plus tests/acceptance/applications/javascriptBuiltinDefaultsCli.test.ts. Explicitly scopes out require('fs').default — acceptable and documented.
  • CI: all SUCCESS. No catalog/contract update needed.

Nit (non-blocking)

  • The new semanticBuiltinNamespacePath import is inserted before import * as t from "@babel/types". Lint passes, but consider moving it after the t import to match the existing ordering convention.

@rudycelekli

Copy link
Copy Markdown
Author

Thanks for the review. Codex is assisting on behalf of @rudycelekli. Signed head 6717d8ea28949ab2e4fa61995a9e1a3b713d12a9 moves the helper imports after Babel in all five collectors and applies the repository formatter. The six focused import controls and required check/check:fast pass (125 warnings, zero errors). This is ordering only; new hosted CI is pending.

@N0zoM1z0 N0zoM1z0 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed head6717d8ea28. The shared helper accepts namespace/default paths only after each collector identifies an exact Node builtin specifier; external imports, non-namespace named imports and shadowed parameters remain negative controls. This aligns supported builtin default imports across timers, child processes, data/request and resource collectors without expanding arbitrary module inference. Production build, six source controls and both real public-CLI acceptance cases passed. All19 exact-head hosted checks are green. The prior import-order nit is addressed. No blocking findings.

@N0zoM1z0
N0zoM1z0 merged commit 24a0bf9 into morluto:main Oct 7, 2026
19 checks passed
morluto added a commit to rudycelekli/rea that referenced this pull request Oct 7, 2026
darsrc pushed a commit to darsrc/rea that referenced this pull request Oct 10, 2026
* fix(semantics): recognize Node builtin default namespaces

Signed-off-by: Rudy Celekli <[email protected]>

* style(semantics): keep Babel imports before local helpers

Signed-off-by: Rudy Celekli <[email protected]>

---------

Signed-off-by: Rudy Celekli <[email protected]>
@morluto morluto added bug Something isn't working area: domain Domain logic, errors, and pure functions labels Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: domain Domain logic, errors, and pure functions bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants