fix(arch): tighten test-file dirs and import-hint resolution#49
Open
Asgarrrr wants to merge 1 commit into
Open
fix(arch): tighten test-file dirs and import-hint resolution#49Asgarrrr wants to merge 1 commit into
Asgarrrr wants to merge 1 commit into
Conversation
Three correctness fixes in `senseArchitecture` (V0.2 architecture sensing,
ADR 0005), all within the filesystem-only envelope:
- test-file: also check co-located `__tests__/` and the repo-root
`tests/` / `__tests__/` directories. The previous `${dir}/tests/`-only
rule produced zero test-file signals on Mira's own repo, where all
tests live at top-level `tests/`.
- import-hint: switch from basename-only matching to deterministic
POSIX path resolution against the importer's directory, with
`.ts/.tsx` and `/index.ts(x)` suffix recovery. Eliminates the
cross-directory basename-collision false positives
(`src/utils/foo.ts` ↔ unrelated `src/auth/foo`).
- import-hint: skip bare specifiers (`from "react"`) and tsconfig-paths
aliases (`from "@/x"`); fixes the false match on a changed file
whose basename happens to collide with a package name.
ADR 0005 amended (V0.2.1) to record the tightened semantics.
7 new test cases added: 3 for the new test-file dirs, 4 for the
import-hint hardening (collision, bare specifier, index.ts
directory imports, tsconfig alias as documented false negative).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Three correctness fixes in
senseArchitecture(V0.2 architecture sensing). All stay inside ADR 0005's filesystem-only envelope — no AST, no import graph, no new dependencies.What changed
test-file${dir}/<stem>...and${dir}/tests/<stem>...__tests__/and repo-roottests//__tests__/import-hintbasename(spec) === basename(changed)specagainst importer dir (POSIX), match resolved path with.ts/.tsxand/index.ts(x)suffix recoveryimport-hintfrom "..."regex matchfrom "react") and tsconfig-paths aliases (from "@/x")Why now
A deep read of
src/architecture/sense.tssurfaced two real correctness gaps and one real coverage gap:${dir}/tests/-only rule never fires on Mira's own repo — all tests live at top-leveltests/. Same for any project using Bun-style top-level tests, Jest's__tests__/, or Python-style top-leveltests/.src/utils/foo.tsflagged any file importing an unrelatedsrc/auth/foo. Path-resolved comparison eliminates this without leaving filesystem-only scope.react.tsmatchedfrom "react"purely by basename. Same fix.tsconfigpaths aliases are intentionally skipped — false negatives are preferred over false positives per ADR 0005's invariant. Documented as a deliberate non-coverage in a test case and in the ADR amendment.ADR
Amended
docs/adr/0005-architecture-sensing-v0-2-scope.md(V0.2.1):Test plan
bun test tests/architecture-signal.test.ts— 27 pass / 0 fail (20 existing + 7 new)bun test— 316 pass / 0 fail / 23 filesOut of scope (deferred follow-ups)
import "./x") andrequire()recognition. Would expand ADR scope.stemOfcollapsing on first dot. Documented design choice.Risk / rollback
The new
import-hintmatcher is stricter — projects that relied on basename-only matching for tsconfig-aliased imports will lose those signals. The ADR amendment makes this explicit; the V0.2 invariant "prefer false negatives" justifies the trade-off. Single commit, cleangit revert.