feat: additive CommandResult type spine — Phase 1 step 6#911
Merged
Conversation
Size Report
Startup median (7 runs, lower is better):
Top changed chunks: no changes in the largest emitted chunks. |
ce9217a to
bae3034
Compare
3dca1c8 to
f938536
Compare
bae3034 to
9be0b60
Compare
f938536 to
e8e4a81
Compare
9be0b60 to
b3dd13c
Compare
e8e4a81 to
ef61c90
Compare
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.
b3dd13c to
0c56eb2
Compare
ef61c90 to
3d4fcb2
Compare
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds the typed-result spine for the command-descriptor migration (ADR-0008, Phase 1 step 6), stacked on #910.
src/core/command-descriptor/command-result.ts:interface CommandResultMap— seeded from the per-command result types that already exist insrc/contracts/*. Today that is the interaction trio (press: PressCommandResult,fill: FillCommandResult,longpress: LongPressCommandResultfromcontracts/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 toRecord<string, unknown>, so the mapping is total over every command name.__tests__/command-result.test.ts— type-level assertions (enforced bytsc --noEmit) that each seeded command resolves to exactly its contract type, and that an unmigrated/unknown name falls back to theRecord<string, unknown>bag.Why
This is purely additive and dormant — nothing consumes
CommandResultMap/CommandResultyet. Same dormant-but-proven pattern as the #906 descriptor registry. It is the foundation the next slices consume to deriveclient-types.tsand delete the hand-authored*Resultmirror (−550).No consumer changes, no deletions, no behavior change.
client-types.ts, dispatch, daemon andcontracts.tsare untouched. The slice adds files only undersrc/core, so the Layering Guard stays empty.Verification
tsc -p tsconfig.json --noEmit— exit 0oxfmt --write+oxlint --deny-warningson the new files — exit 0vitest run core/command-descriptor— green (incl. the new test)git grep— emptyStacked on #910.