Skip to content

feat: additive CommandResult type spine — Phase 1 step 6#911

Merged
thymikee merged 2 commits into
mainfrom
feat/command-result-spine
Jun 27, 2026
Merged

feat: additive CommandResult type spine — Phase 1 step 6#911
thymikee merged 2 commits into
mainfrom
feat/command-result-spine

Conversation

@thymikee

Copy link
Copy Markdown
Member

What

Adds the typed-result spine for the command-descriptor migration (ADR-0008, Phase 1 step 6), stacked on #910.

  • New src/core/command-descriptor/command-result.ts:
    • interface CommandResultMapseeded from the per-command result types that already exist in src/contracts/*. Today that is the interaction trio (press: PressCommandResult, fill: FillCommandResult, longpress: LongPressCommandResult from contracts/interaction.ts). Screenshot/perf/logs/app-inventory have no contracts-layer result type yet, so they are deliberately omitted rather than given an invented shape.
    • type CommandResult<N extends string> — resolves a seeded name to its contract result type and defaults every other (unmigrated) command to Record<string, unknown>, so the mapping is total over every command name.
  • New __tests__/command-result.test.ts — type-level assertions (enforced by tsc --noEmit) that each seeded command resolves to exactly its contract type, and that an unmigrated/unknown name falls back to the Record<string, unknown> bag.

Why

This is purely additive and dormant — nothing consumes CommandResultMap/CommandResult yet. Same dormant-but-proven pattern as the #906 descriptor registry. It is the foundation the next slices consume to derive client-types.ts and delete the hand-authored *Result mirror (−550).

No consumer changes, no deletions, no behavior change. client-types.ts, dispatch, daemon and contracts.ts are untouched. The slice adds files only under src/core, so the Layering Guard stays empty.

Verification

  • tsc -p tsconfig.json --noEmit — exit 0
  • oxfmt --write + oxlint --deny-warnings on the new files — exit 0
  • vitest run core/command-descriptor — green (incl. the new test)
  • Layering Guard git grep — empty

Stacked on #910.

@github-actions

github-actions Bot commented Jun 27, 2026

Copy link
Copy Markdown

Size Report

Metric Base Current Diff
JS raw 1.4 MB 1.4 MB 0 B
JS gzip 445.5 kB 445.5 kB 0 B
npm tarball 584.7 kB 584.7 kB 0 B
npm unpacked 2.0 MB 2.0 MB 0 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 28.7 ms 29.0 ms +0.3 ms
CLI --help 50.3 ms 49.8 ms -0.4 ms

Top changed chunks: no changes in the largest emitted chunks.

@thymikee thymikee force-pushed the feat/command-descriptor-dispatch-map branch from ce9217a to bae3034 Compare June 27, 2026 16:25
@thymikee thymikee force-pushed the feat/command-result-spine branch from 3dca1c8 to f938536 Compare June 27, 2026 16:25
@thymikee thymikee force-pushed the feat/command-descriptor-dispatch-map branch from bae3034 to 9be0b60 Compare June 27, 2026 18:07
@thymikee thymikee force-pushed the feat/command-result-spine branch from f938536 to e8e4a81 Compare June 27, 2026 18:07
@thymikee thymikee force-pushed the feat/command-descriptor-dispatch-map branch from 9be0b60 to b3dd13c Compare June 27, 2026 18:24
@thymikee thymikee force-pushed the feat/command-result-spine branch from e8e4a81 to ef61c90 Compare June 27, 2026 18:24
Part A (enabler): make commandDescriptors `as const` so each entry keeps its
literal `name`, and export `Command` — the literal command-name union.

Part B: replace the dispatchKnownCommand switch with a
`Record<DispatchCommand, DispatchHandler>` lookup table. The Record type forces
every dispatch command to have a handler (a missing entry is now a COMPILE
error, replacing the runtime `default: throw` as the coverage net); an
`Object.hasOwn` guard preserves the identical INVALID_ARGS error for unknown
commands. DispatchCommand is hand-authored to match the switch cases verbatim
(it is not the registry `generic` route, and `swipe-preset`/`read` aren't
registry names). Strictly behaviorless: same routing, same handler args, same
results.
@thymikee thymikee force-pushed the feat/command-descriptor-dispatch-map branch from b3dd13c to 0c56eb2 Compare June 27, 2026 18:47
@thymikee thymikee force-pushed the feat/command-result-spine branch from ef61c90 to 3d4fcb2 Compare June 27, 2026 18:54
Base automatically changed from feat/command-descriptor-dispatch-map to main June 27, 2026 18:59
@thymikee thymikee merged commit c4d6c8a into main Jun 27, 2026
15 checks passed
@thymikee thymikee deleted the feat/command-result-spine branch June 27, 2026 19:02
@github-actions

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-06-27 19:02 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant