mirror of
https://github.com/morluto/rea.git
synced 2026-11-05 06:45:22 +00:00
[GH-ISSUE #4189] [Bug] Trailing-slash CommonJS require ignores package main in reference import #1639
Closed
opened 2026-10-16 21:08:18 +00:00 by bsakaguchi
·
3 comments
No Branch/Tag specified
main
codex/procedure-reference-stacked
release-please--branches--main--components--rea-agents
release-please--branches--main--components--rea-agents--release-notes
codex/kuna-independent-retry
codex/byte-search-overlay-coverage
codex/open-failure-target-receipt
codex/kuna-xref-evidence
codex/ghidra-ambiguous-procedure-recovery
codex/function-source-bundle
codex/trace-function-integration-prototype
codex/snapshot-source-closure
codex/recorded-evidence-array-pages
codex/evidence-recovery-redesign
codex/trace-feature-address-scope
codex/call-discovery-scope
codex/ghidra-literal-candidate-evidence
codex/decompile-directory-independent-retry
codex/retry-provenance-base
codex/value-flow-capability-experiment
codex/ghidra-containing-instruction
cursor/readme-discord-button-ef9f
dependabot/github_actions/actions/setup-node-7.1.0
dependabot/github_actions/actions/upload-artifact-7.0.2
dependabot/npm_and_yarn/npm-minor-and-patch-d8d97ce6df
codex/kuna-1989
fix/8559-native-ui-fixture-ownership
fix/8555-go-verifier-mcp-ownership
codex/provider-capability-recovery
fix/8642-rizin-target-stdin
codex/ghidra-memory-effect-scope
codex/ghidra-annotation-entry-selector
codex/ghidra-readonly-recovery
codex/ghidra-regex-verifier-recovery
codex/evidence-discovery-view-guidance
fix/8545-bulk-append-overflow
fix/8428-navigation-refusal-alternatives
codex/address-context-recovery
codex/matching-member-limitations
codex/unknown-scope-contract
codex/evidence-view-guidance
feat/8373-native-trace-views
codex/ghidra-snapshot-verifier-binding
codex/elf-export-visibility
codex/evidence-view-recovery
codex/native-reference-cli-help
codex/provider-candidate-observation-scope
codex/kuna-session-verification
codex/ghidra-switch-lifetime-guidance
codex/pseudocode-paging-discovery
codex/clarify-evidence-view-support
codex/kuna-xrefs-selector-recovery
codex/context-capacity-recovery
codex/evidence-closure-large-links
codex/same-function-evidence-identity
codex/ghidra-verifier-inspected-jdk
codex/audit-guided-workflows
codex/crash-prompt-retained-dossiers
codex/analysis-view-error-recovery
codex/kuna-verifier-target-selection
codex/ghidra-selected-project-call-coverage
codex/docs-native-analysis-scope
codex/ghidra-java-socket-boundary
codex/ghidra-retained-snapshot-verifier
codex/ghidra-search-inventory-facts
fix/8284-zero-argument-parameter-bindings
fix/8198-ui-action-handler-offset
fix/8257-elf-entry-label-identity
fix/8304-deferred-output-schema-projection
fix/8277-call-path-computed-target-uncertainty
fix/pr-8089-conflicts
fix/ci-static-duplicate-export
dependabot/npm_and_yarn/lint-staged-17.6.0
dependabot/github_actions/actions/download-artifact-8.0.2
dependabot/npm_and_yarn/write-file-atomic-8.0.0
dependabot/npm_and_yarn/canonicalize-5.1.0
dependabot/github_actions/actions/cache/restore-6.1.0
dependabot/npm_and_yarn/toon-format/toon-4.4.0
dependabot/github_actions/actions/deploy-pages-5.0.1
codex/review-fixes-pr-2403
codex/review-fixes-pr-2400
codex/process-terminal-width
codex/test-brittleness-cleanup
verify/7167-browser-connect-macos
fix/7167-browser-connect
feat/native-matching-allowance-setting
feat/browser-scenario-dry-run
test/managed-caller-parameters-20261024
codex/parser-fortythird-boundaries
fix/6926-pinvoke-platform-decorations-20261023
fix/6889-har-body-encoding-20261023
fix/6888-sqlite-schema-budget-20261023
fix/dependency-security-gates-6708
cursor/evidence-overwrite-rebase-b4ac
feat/4057-verify-native-exports
fix/windows-acl-observer-overhead-20261022
cursor/erlang-beam-restack-4476
cursor/pe-certificate-review-bf32
fix/6116-javascript-application-fs-errors
fix/6061-unmapped-runtime-script-unknown
feat/browser-scenario-summary
fix/pe-certificates
codex/verify-3407
cursor/rebase-5699
cursor/rebase-5352
cursor/rebase-5600
cursor/fix-cli-schema-omission-10a8
codex/audit-hopper-shutdown-reasons-20261021
fix/demangle-swift-omitted-record
fix/nib-boolean-value-types
cursor/cancellation-partial-observation-a5ac
fix/ib-object-limit-reasons
fix/electron-fuse-limit-advice
fix/kuna-doctor-dangling-cache
fix/fixed-budget-refusal-advice
fix/js-ipc-listener-dedup
fix/js-return-member-provenance
fix/dmg-integrity-retry-advice
fix/ida-doctor-readiness
fix/kuna-version-probe-output-drain
fix/legacy-swift-runtime-name-matching
fix/dylib-lazy-load-commands
fix/browser-scenario-startup-cancel
fix/swift-nested-punycode-classification
fix/compare-unselected-scopes
fix/objc-method-budget-coverage
fix/dmg-mounted-root-observations
audit/ci-tests-20261019-round2
release/6.7.0
fix/wabt-cleanup-retry-resolution
fix/electron-fuse-elf-pe-architecture
fix/native-plist-descriptor-ownership
fix/kuna-caller-cleanup-ownership
experiment/atomic-codemode-20261016
review/first-contributor-3776
fix/call-resolution-full-read-cycles
fix/member-mutation-selection-repeat
experiment/atomic-re-tools-20261015
perf/member-mutation-lazy-origins
perf/static-network-mutation-index
fix/hopper-startup-lifecycle
audit/3050-windows-proof-20261015
feat/windows-window-capture-2183
audit/3049-windows-proof-20261015
audit/3735-macos-fixtures-20261015
fix/batch-decompile-null-pseudocode
fix/kuna-inventory-honors-jobs
experiment/browser-codemode-tool-design-20261015
fix/hopper-clean-runtime-argv
codex/review-2049-27f1b367
review-fixes/pr-2787-routing
fix/3360-scoped-this-emitters
fix/3367-replaced-global-effects
fix/3838-compact-any-value-items
test/hopper-download-probe-20261015
codex/windows-runtime-creation-red-green-20261015
codex/windows-readonly-root-red-green-20261015
codex/windows-root-share-red-green-20261015
codex/exp-1685-win-mcp-startup
codex/bug-sweep-20261015
investigate/2190-windows-package-phases
investigate/3543-macos-cli-deadline
perf/3281-reverse-tools-feedback-quality
fix/3406-hopper-doctor-fixture
fix/3341-wrapper-require-test-context
fix/3301-owned-uninstall-fixtures
fix/3164-compiler-input-ownership
fix/pcap-cleanup-stdout-newline-20261014
perf/interface-builder-summary
codex/review-fixes-pr-1977
fix/ghidra-effective-jvm-platform
fix/docs-turkish-rust-link-20261013
fix/main-maintenance-ci-20261010
fix/recover-binary-session-process-effects
codex/review-fixes-pr-2457
codex/ci-required-cancellation-gate
fix/main-format-baseline-20261013
fix/setup-preserve-entry-fields
cursor/restore-main-checks-1ffc
fix/ghidra-bridge-hashmap-import
codex/shared-ci-jadx-json-default-20261013
codex/shared-ci-ghidra-test-groups-20261013
codex/shared-ci-java-fixture-format-20261013
codex/fix-intrinsic-invocation-boundaries
test/release-preflight-reusable-jobs
test/js-parameter-provenance-expectation
fix/linux-hopper-verification-current
test/2419-ghidra-elf-probe-size
followup/pr-1544-native-ida
codex/fold-pr-2230-contribution
docs/readme-responsible-use
fix/issue-2064
fix/issue-2050
fix/issue-2053
fix/issue-1968
fix/issue-1945
experiment/codemode-bridge-20261011
fix/tool-effects-negative-wording-1904-20261012
fix/1842-electron-interop-provenance
feat/recover-javascript-multi-input
refactor/website-i18n-prep
fix/nativeaot-pe-virtual-extent
fix/browser-verifier-ci-hang
fix/pe-resources-input-selection
docs/beginner-friendly-guides
docs/beginner-setup-guide
fix/javascript-analysis-worker-1563
fix/1649-ghidra-duplicate-names
fix/javascript-export-keys-integration-1369
test/maintenance-boundary-contracts-20261011
review/javascript-export-keys-1369
review/process-live-progress-1483
test/javascript-1495-growth-ratio
fix/ci-escape-timing
docs/normalized-terminal-geometry-1450
release/6.3.0
archive/release-6.3.0-pr1381
release/6.2.0
fix/electron-preload-dynamic-override
fix/javascript-self-referential-bundler-edges
release/6.1.0
cursor/grok-client-cherry-pick-0b56
feat/signature-posture
feat/dyld-shared-cache
feat/artifact-integrity-policy
feat/pkg-inventory
release/6.0.0
chore/sync-release-5.0.0
release/5.0.0
cursor/cloud-agent-node-787e
fix/javascript-xhr-open-endpoints
review/pr-711-realpath-fallback-wording
cleanup/replay-confinement
codex/test-suite-performance
codex/issue-foundations
codex/address-open-issues-2026-07-20
agent/javascript-vite-rollup-esbuild-adapters
agent/process-cleanup
agent/triage-integration
agent/unknown-commands-registry
feat/mcp-identity-metadata
morlvps/issue_cleanup
codex/installer-redesign
morl/roadmap-investigation-core
morl/roadmap-investigation-docs
release-please--branches--main--components--rea
rea-agents-6.8.0
rea-agents-6.7.0
rea-agents-6.6.0
experiment/atomic-codemode-wait-runtime-20261016
rea-agents-6.5.0
rea-agents-6.4.0
rea-agents-6.3.0
rea-agents-6.2.0
rea-agents-6.1.0
rea-agents-6.0.0
rea-agents-5.0.0
rea-agents-4.1.0
rea-agents-4.0.1
rea-agents-4.0.0
rea-agents-3.2.1
rea-agents-3.2.0
rea-agents-3.1.0
rea-agents-3.0.0
rea-agents-2.7.0
rea-agents-2.6.0
rea-agents-2.5.1
rea-agents-2.5.0
rea-agents-2.4.0
rea-agents-2.3.0
rea-agents-2.2.0
rea-agents-2.1.0
rea-agents-2.0.0
rea-agents-1.7.0
rea-agents-1.6.0
rea-agents-1.5.0
rea-agents-1.4.0
rea-agents-1.3.0
rea-agents-1.2.0
rea-agents-1.1.0
rea-agents-1.0.0
rea-agents-0.5.0
rea-agents-0.4.0
rea-agents-0.3.0
rea-0.2.1
rea-0.2.0
Labels
Clear labels
area: bridge
area: bridge
area: build
area: build
area: build
area: cli
area: domain
area: evidence
area: mcp
area: native
area: providers
area: runtime
area: server
area: setup
area: tests
bug
design
documentation
enhancement
enhancement
enhancement
experiment
help wanted
i18n
invalid
P0: critical
P1: high
P2: medium
P2: medium
P2: medium
P3: low
performance
provider-request
pull-request
Mirrored from GitHub Pull Request
question
roadmap
triage
No labels
area: bridge
area: bridge
area: build
area: build
area: build
area: cli
area: domain
area: evidence
area: mcp
area: native
area: providers
area: runtime
area: server
area: setup
area: tests
bug
design
documentation
enhancement
enhancement
enhancement
experiment
help wanted
i18n
invalid
P0: critical
P1: high
P2: medium
P2: medium
P2: medium
P3: low
performance
provider-request
pull-request
question
roadmap
triage
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Dependencies
No dependencies set.
Reference
morluto/rea#1639
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @coygeek on GitHub (Oct 15, 2026).
Original GitHub issue: https://github.com/morluto/rea/issues/4189
Before submitting
Area
Evidence, artifacts, or reconstruction
Observed behavior
import-reference-sourcerecords the wrong dependency forrequire("./sub/"). Withsub/package.jsondeclaringactual.jsand bothsub/actual.jsandsub/index.jspresent, REA returns a parsed internal edge tosub/index.js. Node resolves the identical specifier tosub/actual.js. Removing only the trailing slash makes REA select the declared main. The source inventory remains available, but the dependency target is incorrect.Reproduction
From the built source checkout root at the revision below, run this exact executed reproduction with the stated Node executable on PATH. It creates three independent trees, calls the public CLI, asks Node to resolve each literal specifier without executing the source, and removes its disposable fixtures afterward. The second and third trees are controls, not suggested changes to historical source.
The exact final fixture reproduced in independent source-build CLI runs, including the final publication review. Every CLI call exited 0 with empty stderr and empty
parse_failures. Node's resolve-only calls also exited 0. Observed targets were:Expected behavior
slash-mainshould return an internal requires edge to the declared and inventoriedsub/actual.js, matching Node and theplain-maincontrol.slash-index-onlyshould continue selectingsub/index.jsbecause it has no package manifest. REA's package-main selection contract explicitly places a nonempty declared main before a directory index. Its compiled CLI coverage supports directory spellings and package-main precedence against Node's resolve-only loader, but does not combine this trailing-slash request with the manifest fixture.Impact and scope
P2, supported: one bounded CommonJS input produces an incorrect parsed internal dependency while retaining source inventory. No severe harm, broader workflow failure, downstream comparison error or real-world prevalence was measured. This report covers CLI behavior on the stated source build and platform.
A graph-result workaround preserving the original source bytes and identity remains unverified. Node's resolve-only control safely identifies the intended target for manual interpretation, but does not repair the graph. Removing the slash changes the historical input and is only a discriminating control.
REA version
Source-built checkout at 62bf09809ef7bb224028916424f8f07652a20f4f. The source CLI reports
6.5.0; the published package was not reproduced. Current public main was fetched before submission, and the relevant reference importer, parser, CLI, graph contracts and CLI documentation are unchanged. Current-main applicability is source-inspected, not a separate current-main runtime reproduction.Runtime and platform
Node.js v24.18.0; npm 11.16.0; macOS arm64. Independent source checkouts were compiled with
npm run build:cached. The fixture uses isolated HOME/config/cache directories. No external provider, network dependency or execution of imported source is needed. MCP, alternate platforms and published-package artifacts were not exercised.Target and artifact context
Benign local UTF-8 CommonJS source trees contain
main.cjs,sub/actual.js,sub/index.jsand, for the first two cases,sub/package.jsonwith{"main":"actual.js"}. The.cjsfile uses an ordinary unshadowedrequirewith no loader replacement. Both manifest and declared main were separately confirmed in the failing graph's inventory.Interface
CLI
Earliest failure stage
Native analysis or reconstruction. The importer records a parsed internal relationship with the wrong target.
Relevant output or evidence
The failing CLI graph contains:
The graph schema is
HistoricalSourceGraphandparse_failuresis[]. The same-tree Node control returnssub/actual.js. Independent verification also ran both--jsonand--format json, which returned the same relevant graph fields. The existing focused commandnpm run test:focused -- src/application/ReferenceSourceImportEntries.test.ts tests/boundary/cli/referenceSourceDirectoryImports.test.tspassed both files and all four tests in that verification; those tests do not contain the failing combination. No full suite or downstream comparison was executed.Typed outcome or recovery expected
Proposed closure check: rerun the unchanged reproduction.
slash-mainmust return a parsed internal requires edge tosub/actual.js, matching its Node control. Preserve theplain-maintargetsub/actual.js, theslash-index-onlytargetsub/index.js, and inventory of the original fixture files. Omitting the require or changing its specifier would not restore the historical-source result.Analysis or suspected cause
Source-derived: the directory/index recognition guard finds the index candidate but compares its dirname
subwith the normalized requestsub/. That comparison fails, so the importer records the index directly instead of consulting the declared package main. This is distinct from returning unresolved before any candidate match when the index is absent. The source explains the observed output; this report does not prescribe a particular implementation.Additional context
Open #3895 requires a sibling
dep.jsto win overdep/index.ts, without package metadata. This fixture has no sibling file and tests manifest precedence over an existing index. Open #3896 requires a declared main to resolve without an index; its plain-specifier/index-present control already passes here. Its no-index closure can pass while this trailing-slash/index-present guard remains wrong, and correcting this guard can leave that no-index early return unresolved.Closed #3383 reported ignored package-main precedence for the plain relative spelling. The
plain-maincontrol confirms that case is restored at the tested revision; this report identifies the remaining trailing-slash trigger on current source. No duplicate was found in the refreshed open inventory or targeted closed searches. NOT_ENOUGH_INFO: a last-known-good version for this trailing-slash case and installed-release behavior were not established.@hemv-857 commented on GitHub (Oct 15, 2026):
Taking this one. Root cause:
posix.normalize(posix.join(dirname, "./sub/"))preserves the trailing slash, sonormalizedissub/whileposix.dirname(match)issub— theresolvedThroughIndexcomparison inresolveInternalSpecifierfails, andselectPackageMain(the declared-mainselection) never runs for trailing-slash specifiers. Plain./subnormalizes without the slash, so it reaches the package-main pass. Fix: compare against the slash-stripped directory so trailing-slash directory references take the same package-main path as the plain control. Regression test intests/boundary/cli/referenceSourceDirectoryImports.test.tscombining the trailing-slash request with the manifest fixture.@kharedevansh11 commented on GitHub (Oct 15, 2026):
I independently arrived at the same root cause as @hemv-857:
posix.normalize("sub/")keeps the trailing slash, so theresolvedThroughIndexcheck fails andselectPackageMainis skipped. I opened #4221 around the same time as #4219. Mine strips trailing separators for that comparison only, so unresolved targets likemissing/keep their spelling, and it adds a./pkg/case to the existingreferenceSourceDirectoryImportsCLI test, which checks each fixture against Node'screateRequire().resolve. With it, your three cases match Node (sub/actual.js,sub/actual.js,sub/index.js). Happy to close mine in favour of #4219 if maintainers prefer.cc @morluto @kaoru0822-kitauji @N0zoM1z0
@morluto commented on GitHub (Oct 23, 2026):
Resolved by
github.com/morluto/rea@baf16784af. Trailing-slash CommonJS resolution consumes package main before index fallback; public fixture checks nested/main.js instead of its deliberately distinct index.js. Validation:tests/boundary/cli/referenceSourceModuleSemantics.test.tspassed in the recorded round2/3 execution; this review did not rerun tests. Coverage is limited to the cited control; no broader real-provider, Windows or performance claim.