You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Import-boundary rule misses bare specifiers, so core can reach an adapter through the package's own exports map #579
severity:highReal defect on a boundary or documented claim; MVP-relevant, bounded blast radiustest-integrityTest/eval integrity: mutation sweep, invariant pinning, assertion strengthverified-on-mainReviewed against current main and the described break no longer exists - nothing to build, close it
test/host/import-boundary.test.ts inspects only relative specifiers, so the boundary it enforces can be crossed by naming the package itself. The rule is the sole enforcement of the core-to-adapter separation — typecheck and lint do not catch a relative violation either — so a hole in the rule is a hole in the invariant, not a style gap.
Reproduction
At the head of the adapter-isolation pull, in a scratch worktree, with package.json exporting "./tui" to ./src/adapters/opencode/tui/panel.tsx:
// src/runtime/setup.ts
import * as probe from "opencode-self-improvement/tui";
void probe;
Both assertions in test/host/import-boundary.test.ts pass and bun run typecheck reports no errors. The same import expressed relatively is caught.
Required
Resolve bare specifiers that name this package through its own exports map, and apply the existing deny set to the resolved target.
Keep the test's own fail-before fixtures: add the bare-specifier shape alongside the existing ones so the coverage is pinned rather than intended.
Run the sweep across every dependency form already handled — static, import type, export *, named re-export, dynamic import(), require, and typeof import() — since the resolution change affects all of them.
Acceptance
The import above fails the boundary test with a message naming the file and the resolved adapter target, while typecheck still passes; a control fixture using an unrelated bare specifier stays clean, so the rule cannot be satisfied by blanket-banning all bare imports.
Raising the severity now that the adapter isolation has landed: on main at ad176f9 (0.38.2) the bypass resolves straight into shipped adapter code, so this is no longer a latent gap in a rule protecting a future layout.
Re-measured at that head in a scratch worktree, with the published exports map on main reading "./tui": "./src/adapters/opencode/tui/panel.tsx":
Relative violation — src/runtime/setup.ts importing ../adapters/opencode/identity.ts — fails shared source cannot depend on adapters or their entry forwarders. Enforced.
Bare self-reference — src/runtime/setup.ts importing opencode-self-improvement/tui — passes both assertions of that test and typecheck reports no errors. Not enforced, and the resolved target is now src/adapters/opencode/tui/panel.tsx.
The rule's AST walk inspects specifiers that begin with ., so a dependency named after the package itself never enters resolution. Nothing in the tree uses that shape today, which is the only reason this is not a live violation.
Already fixed on main. Closing as done — no pull request, because there is nothing left to change.
Filed 2026-11-28 against 0.38.2 (ad176f9), where the premise was true. It stopped being true with 65a005ffeat: route maintained adapters through the public engine API, merged 2026-12-01 through PR #601 and shipped in 0.42.0 (6e6acec). The ticket was never re-run after that merge.
Measured at three trees in a scratch clone (the live checkout was not touched), current main = 0344d56:
#
Tree + probe
Result
1
ad176f9 + import * as probe from "opencode-self-improvement/tui"
0344d56 + control import { join } from "node:path"
0 fail — no false positive on real dependencies
6
0344d56 + ./tui, then bun x tsc --noEmit
exit 0: the self-reference compiles, resolving through exports to src/adapters/opencode/tui/panel.tsx; foil opencode-self-improvement/no-such-key-xyz → TS2307, so tsc really evaluated it
The rule that closes it, on main at test/host/import-boundary.test.ts:8 and :63:
constpublicEngine=newSet(["opencode-self-improvement/host","opencode-self-improvement/status"])// …if(specifier==="opencode-self-improvement"||specifier.startsWith("opencode-self-improvement/")){if(!publicEngine.has(specifier))reject();// deny by defaultreturn;}
At filing the only gate was if (!specifier.startsWith(".")) return;, so a bare self-named specifier never entered the check at all. Every import form now routes through the same check() — static, import type, export *, named re-export, import(), require, typeof import(), template literals — and expected-violation fixtures for opencode-self-improvement/{pi,oh-my-pi,tui,""} in core files are pinned (4 tests / 124 expects).
Answer to the ticket's question. Can core reach an adapter through a bare self-import on main? No — and not via the exports map either: every package-named specifier except the two public-engine keys is rejected before resolution, and both allowed keys resolve to core code (src/host/index.ts, src/status/index.ts).
The limitation the fix leaves behind, stated rather than glossed. What landed is string enumeration, not resolution: a hardcoded two-key allow-list with no exports-map lookup. There is no live hole today, because the default is deny and both keys point into core. It can rot in the direction this ticket predicted: if ./host or ./status is ever repointed into the adapter layer, the rule waves the edge through without resolving it, and the rejection message names file + specifier rather than the resolved target the acceptance criteria asked for. That is a different change from the one this ticket requested, so it will be filed as its own ticket rather than smuggled into this one as a reason to keep it open.
Closed as done. Already fixed on main by 65a005f (PR #601, shipped 0.42.0). Measured at ad176f9 the bare self-import slipped through (premise true at filing); at 0344d56 test/host/import-boundary.test.ts:63 rejects every package-named specifier outside publicEngine, so opencode-self-improvement/tui fails the boundary rule. Certificate with the six-case measurement table posted above.
Reopen it whenever the premise comes back; nothing here is deleted and the history stays put.
severity:highReal defect on a boundary or documented claim; MVP-relevant, bounded blast radiustest-integrityTest/eval integrity: mutation sweep, invariant pinning, assertion strengthverified-on-mainReviewed against current main and the described break no longer exists - nothing to build, close it
Activity
ocsi-architect commentedon Nov 28, 2026
Raising the severity now that the adapter isolation has landed: on
mainatad176f9(0.38.2) the bypass resolves straight into shipped adapter code, so this is no longer a latent gap in a rule protecting a future layout.Re-measured at that head in a scratch worktree, with the published exports map on
mainreading"./tui": "./src/adapters/opencode/tui/panel.tsx":src/runtime/setup.tsimporting../adapters/opencode/identity.ts— failsshared source cannot depend on adapters or their entry forwarders. Enforced.src/runtime/setup.tsimportingopencode-self-improvement/tui— passes both assertions of that test andtypecheckreports no errors. Not enforced, and the resolved target is nowsrc/adapters/opencode/tui/panel.tsx.The rule's AST walk inspects specifiers that begin with
., so a dependency named after the package itself never enters resolution. Nothing in the tree uses that shape today, which is the only reason this is not a live violation.ocsi-architect commentedon Dec 2, 2026
Architect
Already fixed on
main. Closing as done — no pull request, because there is nothing left to change.Filed 2026-11-28 against 0.38.2 (
ad176f9), where the premise was true. It stopped being true with65a005ffeat: route maintained adapters through the public engine API, merged 2026-12-01 through PR #601 and shipped in 0.42.0 (6e6acec). The ticket was never re-run after that merge.Measured at three trees in a scratch clone (the live checkout was not touched), current
main=0344d56:ad176f9+import * as probe from "opencode-self-improvement/tui"ad176f9+ relative../adapters/opencode/identity.ts(fail)— the rule the ticket was written against0344d56+ this ticket's exact example(fail)src/runtime/setup.ts:262: unsupported dependency opencode-self-improvement/tui0344d56+opencode-self-improvement/adapters/pi(fail)atsetup.ts:2640344d56+ controlimport { join } from "node:path"0344d56+./tui, thenbun x tsc --noEmitexportstosrc/adapters/opencode/tui/panel.tsx; foilopencode-self-improvement/no-such-key-xyz→ TS2307, so tsc really evaluated itThe rule that closes it, on
mainattest/host/import-boundary.test.ts:8and:63:At filing the only gate was
if (!specifier.startsWith(".")) return;, so a bare self-named specifier never entered the check at all. Every import form now routes through the samecheck()— static,import type,export *, named re-export,import(),require,typeof import(), template literals — and expected-violation fixtures foropencode-self-improvement/{pi,oh-my-pi,tui,""}in core files are pinned (4 tests / 124 expects).Answer to the ticket's question. Can core reach an adapter through a bare self-import on
main? No — and not via the exports map either: every package-named specifier except the two public-engine keys is rejected before resolution, and both allowed keys resolve to core code (src/host/index.ts,src/status/index.ts).The limitation the fix leaves behind, stated rather than glossed. What landed is string enumeration, not resolution: a hardcoded two-key allow-list with no
exports-map lookup. There is no live hole today, because the default is deny and both keys point into core. It can rot in the direction this ticket predicted: if./hostor./statusis ever repointed into the adapter layer, the rule waves the edge through without resolving it, and the rejection message names file + specifier rather than the resolved target the acceptance criteria asked for. That is a different change from the one this ticket requested, so it will be filed as its own ticket rather than smuggled into this one as a reason to keep it open.abogartz commentedon Dec 2, 2026
Closed as done. Already fixed on main by 65a005f (PR #601, shipped 0.42.0). Measured at ad176f9 the bare self-import slipped through (premise true at filing); at 0344d56 test/host/import-boundary.test.ts:63 rejects every package-named specifier outside publicEngine, so opencode-self-improvement/tui fails the boundary rule. Certificate with the six-case measurement table posted above.
Reopen it whenever the premise comes back; nothing here is deleted and the history stays put.