feat: command-descriptor registry (additive, parity-tested) — Phase 1 step 1
Merged
TH
5mo ago+799+799+012345678901234567890123456789-3-3-0123456789
What
ADR-0008 Phase 1 step 1: introduce a single CommandDescriptor registry as the strangler-fig foundation for the command-descriptor migration. This is purely additive and dormant — nothing reads the new registry yet; it exists only to be proven byte-equal to today's hand tables.
New files (src/commands/descriptor/)
types.ts—CommandDescriptortype +defineCommandDescriptor(). Per command it carries the daemon route + request-policy traits (reusing the existingDaemonCommandDescriptorshape including the closure traitsallowSessionlessDefaultDevice/skipSessionlessProviderDevice, not flattened), an optionalCommandCapabilityentry, andbatchable/mcpExposedflags.registry.ts—commandDescriptors, the additive single source. Covers the full daemon key space (public + internal + gesture-alias names) plus the two capability/batch-only commands (app-switcher,install-from-source). Daemon traits, capability, andbatchableare copied verbatim fromDAEMON_COMMAND_DESCRIPTORS,BASE_COMMAND_CAPABILITY_MATRIX, andSTRUCTURED_BATCH_COMMAND_NAMES.derive.ts— pure folds:deriveDaemonCommandDescriptors,deriveCapabilityMatrix,deriveStructuredBatchCommandNames.__tests__/parity.test.ts— asserts each derived table matches the live hand table. Function-valued traits (daemon closures + capabilitysupports/unsupportedHint) are compared by presence + behavior on a representative request/device sample (mirroringdaemon-command-registry.test.ts); every other field isdeepEqual'd.
Derivations proven byte-equal
- Daemon descriptors — order-exact
deepEqualagainstDAEMON_COMMAND_DESCRIPTORS(closures by behavior). - Capability matrix —
deepEqualagainstBASE_COMMAND_CAPABILITY_MATRIX(supports/unsupportedHint by behavior across 11 sample devices). - Structured-batch names — membership-equal to
STRUCTURED_BATCH_COMMAND_NAMES. (Order is not reproduced: the daemon and batch hand tables are independently ordered, so one registry table cannot reproduce both array orders; the consumer dedupes into aSet, so ordering is cosmetic and deferred to a later slice.)
Additive / dormant guarantee
No consumers changed, nothing deleted, no import-graph inversion. The only edits outside src/commands/descriptor/ add an export keyword to three existing tables so the parity tests can read them: DAEMON_COMMAND_DESCRIPTORS + the DaemonCommandDescriptor type (daemon-command-registry.ts) and BASE_COMMAND_CAPABILITY_MATRIX (capabilities.ts). No behavior change.
Verification
tsc --noEmit✅oxfmt --write+oxlint --deny-warnings✅vitest run commands/descriptor daemon-command-registry capabilities batch→ 7 files / 42 tests ✅