Skip to content

refactor: consolidate public SDK entry barrels into src/sdk/ — Phase 5#986

Merged
thymikee merged 1 commit into
mainfrom
phase5-sdk-barrels
Jul 1, 2026
Merged

refactor: consolidate public SDK entry barrels into src/sdk/ — Phase 5#986
thymikee merged 1 commit into
mainfrom
phase5-sdk-barrels

Conversation

@thymikee

@thymikee thymikee commented Jul 1, 2026

Copy link
Copy Markdown
Member

What

Consolidates the package's public entry points into a dedicated src/sdk/ folder so the public surface lives in one clearly-owned place, per plans/perfect-shape.md §5.5 ("sdk/ = re-export barrels only") and the §3 target DAG. This is the next Phase-5 layering item after remote/ (#951) and client/ (#960), and follows the same behaviorless path-codemod pattern.

The published npm surface is byte-identical — this is pure internal reorganization behind the same public contract.

Barrel structure

All 11 public subpaths (., ./io, ./artifacts, ./metro, ./batch, ./remote-config, ./install-source, ./android-adb, ./contracts, ./selectors, ./finders) now resolve through src/sdk/:

  • 9 already-thin barrels moved verbatim (git rename; internal import paths re-depthed by one ../): index, artifacts, metro, batch, remote-config, install-source, android-adb, contracts, selectors.
  • io and finders keep their implementation at src/ root (they contain real logic + have internal importers). src/sdk/io.ts and src/sdk/finders.ts re-export them (export *), so src/sdk/ stays barrels-only.

package.json exports diff

None — unchanged. Because each rslib entry key is preserved (index, io, …), dist output stays dist/src/<name>.{js,d.ts}. The published subpaths and files do not move, so no exports/main/types rewrite was needed (same technique #960 used for internal/companion-tunnel). This is the safest possible outcome: the exports map is provably identical.

rslib.config.ts:  index: 'src/index.ts'  ->  index: 'src/sdk/index.ts'   (key 'index' unchanged)
                  io:    'src/io.ts'      ->  io:    'src/sdk/io.ts'      (key 'io' unchanged)
                  ... all 11 public entries; 5 internal/* entries untouched

npm pack --dry-run before / after (proving identical public surface)

baseline (origin/main) after
packed files 146 146
package.json exports/main/types (unchanged) identical
public .d.ts (all 11) byte-identical
public .js (11) 10 byte-identical; selectors.js differs only by 1 internal chunk ref

The only delta in the entire tarball: one internal code-split chunk was renumbered dist/src/9836.js -> dist/src/893.js (byte-identical content; a deterministic rspack chunk-id shift from the module-graph move). Every chunk that imports it just updates that one ./9836.js -> ./893.js reference. No public subpath, symbol, or .d.ts changed.

--- baseline/pack-files.txt
+++ after/pack-files.txt
> dist/src/893.js
< dist/src/9836.js       (same content, renamed)

Repoints (all internal / test — no public change)

  • rslib.config.ts: 11 entry sources -> src/sdk/*.ts (keys unchanged).
  • 7 public *-test imports -> src/sdk/*.
  • 3 internal src importers of the selectors barrel (daemon/handlers/find.ts, commands/interaction/runtime/{selector-read,resolution}.ts) split to import impl directly (utils/selectors-parse.ts + daemon/selectors.ts) — removes internal dependence on the public barrel.
  • .fallowrc.json entrypoints + vitest.config.ts coverage exclude (src/sdk/** glob).

Package-subpath consumers (agent-device/io, website client-api.md, installed-package-metro.test.ts) reference the unchanged subpaths — untouched.

Verification

  • tsc -p tsconfig.json --noEmit -> 0
  • rslib build -> 0; dist entry list identical (98 files), all 22 public entry files present
  • npm pack --dry-run -> file list + exports identical (see above)
  • oxfmt + oxlint --deny-warnings -> clean
  • fallow audit --base origin/main -> no issues in 31 changed files
  • vitest run --project unit -> 2883 passed
  • (scripts/layering/check.ts not present in repo)

Move the package's public entry points into a dedicated src/sdk/ folder so the
public surface lives in one clearly-owned place, per plans/perfect-shape.md §5.5
("sdk/ = re-export barrels only") and the §3 target DAG. Follows the #951/#960
pattern (behaviorless path codemod; rslib entry KEYS unchanged so dist output
paths — and therefore package.json `exports` — stay byte-identical).

Barrel structure (all 11 public subpaths now resolve through src/sdk/):
- 9 already-thin barrels moved verbatim (git rename, internal import paths
  re-depthed by one ../): index, artifacts, metro, batch, remote-config,
  install-source, android-adb, contracts, selectors.
- io and finders keep their implementation at src root (real logic + internal
  importers); src/sdk/io.ts and src/sdk/finders.ts re-export them (export *).

package.json exports/main/types: UNCHANGED. Each rslib entry key is preserved
(index, io, ...), so dist output stays dist/src/<name>.{js,d.ts} and the
published subpaths + files do not move. No exports rewrite was needed.

Repoints:
- rslib.config.ts: 11 entry sources -> src/sdk/*.ts (keys unchanged).
- 7 public *-test imports -> src/sdk/*.
- 3 internal src importers of the selectors barrel (find.ts, selector-read.ts,
  resolution.ts) split to import impl directly (utils/selectors-parse.ts +
  daemon/selectors.ts) — removes internal dependence on the public barrel.
- .fallowrc.json entrypoints + vitest coverage exclude (src/sdk/** glob).

Published-surface verification (npm pack --dry-run before/after):
- exports map identical; 146 packed files identical EXCEPT one internal
  code-split chunk renumbered (dist/src/9836.js -> 893.js, byte-identical
  content).
- All 11 public .d.ts byte-identical; 10/11 public .js byte-identical;
  selectors.js differs only by that internal chunk reference. Same symbols.

Gates: tsc 0 · rslib build 0 · oxfmt/oxlint clean · fallow audit (31 files) clean
· vitest unit 2883 pass.
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

Size Report

Metric Base Current Diff
JS raw 1.4 MB 1.4 MB -8 B
JS gzip 450.5 kB 450.5 kB -11 B
npm tarball 549.9 kB 549.9 kB -16 B
npm unpacked 1.9 MB 1.9 MB -8 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 26.4 ms 27.0 ms +0.6 ms
CLI --help 47.1 ms 47.8 ms +0.7 ms

Top changed chunks:

Chunk Raw diff Gzip diff
dist/src/cli.js -1 B -3 B
dist/src/9722.js -1 B -2 B
dist/src/selector-runtime.js -1 B -2 B
dist/src/session.js -1 B -1 B
dist/src/2577.js -1 B -1 B

@thymikee

thymikee commented Jul 1, 2026

Copy link
Copy Markdown
Member Author

Reviewed #986 against plans/perfect-shape.md Phase 5 §5.5 and the package-surface constraints. I don't see actionable blockers: this is a public SDK barrel relocation, the rslib entry keys remain unchanged, package.json exports are untouched, src/sdk/** stays re-export-only, implementation-bearing io and finders remain behind SDK re-export barrels, and internal command/daemon code no longer depends on the public selectors barrel. Checks are green, including Typecheck, Unit Tests, Integration Tests, Fallow Code Quality, Layering Guard, Lint & Format, Smoke Tests, Bundle Size, and CodeQL. No live device evidence requested because this PR changes packaging/module locations, not device-facing behavior.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Jul 1, 2026
@thymikee thymikee merged commit 87c4356 into main Jul 1, 2026
21 checks passed
@thymikee thymikee deleted the phase5-sdk-barrels branch July 1, 2026 08:04
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-07-01 08:04 UTC

thymikee added a commit that referenced this pull request Jul 1, 2026
…#987)

#984 added the R3 platforms-seam layering rule and #986 moved the public SDK
entry barrels into src/sdk/; the two merged mutually inconsistent, so the
Layering Guard is failing on main. sdk/ are public re-export barrels that
legitimately expose platform symbols and are off the CLI cold path (not imported
by bin.ts), so they are a correct R3 exemption alongside core/interactors and the
daemon server — not a cold-start regression.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant