Skip to content

refactor: move errors/redaction/device into src/kernel — Phase 5 slice 3#940

Open
thymikee wants to merge 2 commits into
mainfrom
refactor/phase5-kernel-primitives
Open

refactor: move errors/redaction/device into src/kernel — Phase 5 slice 3#940
thymikee wants to merge 2 commits into
mainfrom
refactor/phase5-kernel-primitives

Conversation

@thymikee

Copy link
Copy Markdown
Member

What

Relocates the foundational primitive trio — errors.ts, redaction.ts, device.ts — from src/utils/ into the kernel/ layer (joining snapshot.ts from slice 2 / #932), per the target folder DAG in plans/perfect-shape.md §5.5.

A pure path codemod, no behavior change.

Why these three, atomically

They form a closed clusterdevice → errors → redaction, with redaction a leaf — so kernel/ takes no upward dependency, and every importer becomes a clean downward import toward kernel. errors.ts is the most-imported module in the tree (321 importers); device.ts is the §5.5-named headliner (144). Moving all three in one atomic move avoids a half-state where one would import another across the utils/kernel/ boundary.

How

Imports were rewritten by a resolve-based codemod: it compares each specifier's resolved absolute path to the moved files before rewriting, so unrelated same-named files (commands/management/device.ts, etc.) are left untouched. 481 import sites across 400 files. Intra-cluster imports (device → ./errors, errors → ./redaction) need no change — the three stay co-located in kernel/.

Also updated: two platform-descriptor doc comments, the fallow health-baseline key for device.ts, and the contracts-schema-public guard (asserting the error helpers pull no diagnostics/node: deps) now reads kernel/errors.ts.

Verification

  • tsc --noEmit exit 0; kernel/ files import only within kernel (no upward deps)
  • oxfmt + oxlint src --deny-warnings clean (no unrelated drift — every changed file's diff is an import rewrite)
  • rslib build exit 0
  • full vitest run → 2870 pass. The only failures were the known-flaky android-fill timing tests under full-suite CPU load (5s timeouts); they pass 92/92 in isolation, and a pure import-path move cannot affect fill logic.
  • fallow audit --base origin/main → ✓ no issues in 406 changed files
  • Layering Guard grep empty; no stale utils/{errors,redaction,device}.ts references anywhere (src, test, configs, baselines)

Note

Large but mechanical (the inherent cost of relocating the most-imported foundational modules) — best merged promptly to avoid import-drift conflicts. kernel/ now holds snapshot · errors · redaction · device; remaining kernel members (contracts.ts, and command-result/capabilities once their core/-descriptor coupling is broken) follow in later slices.

@github-actions

github-actions Bot commented Jun 29, 2026

Copy link
Copy Markdown

Size Report

Metric Base Current Diff
JS raw 1.4 MB 1.4 MB 0 B
JS gzip 453.3 kB 453.3 kB -14 B
npm tarball 558.5 kB 558.6 kB +21 B
npm unpacked 2.0 MB 2.0 MB 0 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 27.4 ms 27.5 ms +0.1 ms
CLI --help 48.2 ms 48.1 ms -0.2 ms

Top changed chunks:

Chunk Raw diff Gzip diff
dist/src/9722.js 0 B +3 B
dist/src/2577.js 0 B -2 B
dist/src/cli.js 0 B +2 B
dist/src/9919.js 0 B -2 B
dist/src/apps.js 0 B -2 B

@thymikee

Copy link
Copy Markdown
Member Author

I checked the path-move surface and the source imports look mechanically clean: the three files are 100% renames into src/kernel/, git diff --check is clean, there are no remaining source/test imports of src/utils/{device,errors,redaction}.ts, and src/kernel does not import upward.

One cleanup before merge: there are still current repo guidance/doc references to the old paths:

  • AGENTS.md still names src/utils/device.ts in the Apple-family sync rule and src/utils/errors.ts for normalizeError.
  • docs/adr/0009-apple-platform-consolidation.md still points resolveApplePlatformName at src/utils/device.ts.
  • plans/apple-platform-consolidation.md still labels DeviceInfo as src/utils/device.ts.

plans/perfect-shape.md also still has a historical utils/device.ts mention; that one may be intentionally describing the pre-move diagnosis, but the current guidance files above should move to src/kernel/device.ts / src/kernel/errors.ts so future agents do not follow stale paths.

@thymikee

Copy link
Copy Markdown
Member Author

Done — pushed c2c7d56. Updated the three current guidance files to point at the new src/kernel/ paths:

  • AGENTS.md: Apple-family sync rule → src/kernel/device.ts; normalizeErrorsrc/kernel/errors.ts
  • docs/adr/0009-apple-platform-consolidation.md: resolveApplePlatformNamesrc/kernel/device.ts
  • plans/apple-platform-consolidation.md: DeviceInfosrc/kernel/device.ts

Left plans/perfect-shape.md's utils/device.ts mention as-is per your note — it's in the §3 diagnosis describing the pre-move state (the §5.5 DAG already documents the kernel destination). Happy to update that too if you'd prefer it reflect the post-move reality.

@thymikee

Copy link
Copy Markdown
Member Author

Thanks, the stale-path cleanup from the prior review is addressed in c2c7d56. One remaining sequencing blocker: GitHub now reports this branch as DIRTY against current main, so it needs a rebase/conflict cleanup before it can be considered ready-for-human. I am leaving the ready label off until the branch is clean again.

thymikee added 2 commits June 29, 2026 20:56
Relocates the foundational primitive trio from src/utils/ into the kernel/ layer
(joining snapshot.ts from slice 2), per the target folder DAG in
plans/perfect-shape.md §5.5. A pure path codemod, no behavior change.

They form a closed cluster — device -> errors -> redaction, with redaction a
leaf — so kernel/ takes no upward dependency, and every importer becomes a clean
downward import toward kernel. errors.ts is the most-imported module in the
tree; device.ts the §5.5-named headliner. Moving all three atomically avoids a
half-state where one would import another across the utils/kernel boundary.

Imports rewritten by a resolve-based codemod (compares each specifier's resolved
path to the moved files, so the unrelated commands/management/device.ts and
other same-named files are untouched): 483 sites across 402 files. The two
platform-descriptor doc comments and the fallow health baseline key for
device.ts are updated to the new path; the contracts-schema-public guard that
asserts the error helpers pull no diagnostics/node: deps now reads kernel/.

Verified: tsc --noEmit, oxfmt + oxlint --deny-warnings, rslib build, full vitest
suite (2877 pass), fallow audit clean (411 changed files), Layering Guard empty;
kernel/ files import only within kernel.
…move

AGENTS.md (Apple-family sync rule + normalizeError), ADR-0009, and
plans/apple-platform-consolidation.md still named the old src/utils/ paths.
Point them at src/kernel/. plans/perfect-shape.md's utils/device.ts mention is
left as-is — it describes the pre-move diagnosis.
@thymikee thymikee force-pushed the refactor/phase5-kernel-primitives branch from c2c7d56 to e196be5 Compare June 29, 2026 18:56
@thymikee

Copy link
Copy Markdown
Member Author

Re-checked current clean head e196be5 after the rebase. The prior stale-path cleanup is present, the PR is now CLEAN, all 21 checks are green, git diff --check is clean, and the current merge diff remains the intended mechanical utils/{device,errors,redaction}kernel/ move plus import rewrites/doc path updates. I do not see remaining actionable blockers, so I am marking this ready-for-human.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Jun 29, 2026
@thymikee

Copy link
Copy Markdown
Member Author

Rebased onto current main and force-pushed (e196be5). Because main had advanced (#933 + #936 added new files importing the old utils/{errors,device} paths), I redid the move fresh on the new base so the resolve-based codemod picked up the new importers — 483 sites across 402 files. The branch is now MERGEABLE (no longer DIRTY). Re-verified on the new base: tsc 0, oxfmt+oxlint clean, rslib build 0, full vitest 2877 pass, fallow ✓ no issues in 411 changed files, Layering Guard empty, no stale utils/{device,errors,redaction} references (except the intentional perfect-shape.md diagnosis mention).

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