refactor: move errors/redaction/device into src/kernel — Phase 5 slice 3#940
Conversation
Size Report
Startup median (7 runs, lower is better):
Top changed chunks:
|
|
I checked the path-move surface and the source imports look mechanically clean: the three files are 100% renames into One cleanup before merge: there are still current repo guidance/doc references to the old paths:
|
|
Done — pushed c2c7d56. Updated the three current guidance files to point at the new
Left |
|
Thanks, the stale-path cleanup from the prior review is addressed in |
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.
c2c7d56 to
e196be5
Compare
|
Re-checked current clean head |
|
Rebased onto current |
|
…943) #941 (MCP outputSchema) and #940 (errors/redaction/device -> src/kernel) merged in an order where #940's import codemod never saw #941's new command-output-schemas.ts, so it still imports '../utils/device.ts' — which no longer exists. tsc/build on main is red. Repoint the import at '../kernel/device.ts'. The only stale reference on main.
…ase 4 (#942) * feat: leveled response views + --level knob, with a snapshot digest — Phase 4 Add the agent-cost leveled-response system: a responseLevel knob (digest | default | full) plumbed end to end behind a global --level flag (mirroring --cost), and a per-command ResponseView registry applied in the router on the success path. - contracts: RESPONSE_LEVELS/ResponseLevel + meta.responseLevel + boundary schema whitelist. Plumbing mirrors --cost: cli-flags FlagDefinition + GLOBAL_FLAG_KEYS, AgentDeviceClientConfig + overrides, buildClientConfig, buildMeta. ResponseLevel exported from the public root. - src/daemon/response-views.ts: the ResponseView registry. Seeds the snapshot digest — the full node tree (the dominant token sink) collapses to { nodeCount, refs: first 12 hittable/non-occluded refs with labels } plus the cheap top-level signals (truncated/visibility/snapshotQuality). full returns today's shape (nothing richer is computed yet). - router graft (applyResponseLevelView + applyAgentCostGrafts): composes with the existing cost block. With responseLevel default (or unset) AND no registered view AND no --cost, the original response is returned UNCHANGED — byte-identical to today (Maestro .ad recompare safe). cost.nodeCount reads the original node tree so it stays accurate even after a digest. Tests: snapshot view unit test (digest filters hittable/occluded, drops the tree, keeps cheap signals; default/full passthrough); router graft test via an injected view (default identity byte-identical, digest applies, full passthrough, digest+cost composition, unregistered-command passthrough, boundary parse). Verified: tsc, oxfmt + oxlint --deny-warnings, fallow audit clean, rslib build, Layering Guard empty, 1106 daemon/contracts/client tests pass (incl. the existing cost/typed-error grafts after the restructure). * fix: repoint MCP output-schemas import to kernel/device (rebase fixup) The kernel move (#940) deleted src/utils/device.ts; #941's command-output-schemas.ts (merged after #940's codemod ran) still imported the old path. Same one-line fix as #943; de-dups once that lands. * fix: re-classify responseLevel flag in integration-progress model The --level/responseLevel flag is a diagnostics/output flag (not device- observable), classified in the exclusion bucket alongside --cost. (Lost in an earlier rebase; re-applying.)
What
Relocates the foundational primitive trio —
errors.ts,redaction.ts,device.ts— fromsrc/utils/into thekernel/layer (joiningsnapshot.tsfrom slice 2 / #932), per the target folder DAG inplans/perfect-shape.md§5.5.A pure path codemod, no behavior change.
Why these three, atomically
They form a closed cluster —
device → errors → redaction, withredactiona leaf — sokernel/takes no upward dependency, and every importer becomes a clean downward import toward kernel.errors.tsis the most-imported module in the tree (321 importers);device.tsis the §5.5-named headliner (144). Moving all three in one atomic move avoids a half-state where one would import another across theutils/↔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 inkernel/.Also updated: two
platform-descriptordoc comments, the fallow health-baseline key fordevice.ts, and thecontracts-schema-publicguard (asserting the error helpers pull nodiagnostics/node:deps) now readskernel/errors.ts.Verification
tsc --noEmitexit 0;kernel/files import only within kernel (no upward deps)oxfmt+oxlint src --deny-warningsclean (no unrelated drift — every changed file's diff is an import rewrite)rslib buildexit 0vitest 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 filesutils/{errors,redaction,device}.tsreferences 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 holdssnapshot · errors · redaction · device; remaining kernel members (contracts.ts, andcommand-result/capabilitiesonce theircore/-descriptor coupling is broken) follow in later slices.