refactor(commands): derive pass-through command bindings with a generic BoundOf helper#1368
Conversation
Size Report
Startup median (7 runs, lower is better):
Top changed chunks:
|
e42f998 to
2ed9f7c
Compare
|
Stacked on #1367 (base changed to its branch) with the |
|
|
Code review is clean at |
2ed9f7c to
4ef8a78
Compare
|
Re-review clean at |
…ic BoundOf helper The five fully pass-through families (capture, system, admin, recording, observability) hand-wrote 'key: (options) => x.key(runtime, options)' per command plus a Bound* type mirroring RuntimeCommand -> BoundRuntimeCommand field-by-field. One mapped type + one generic binder now derives both. BoundOf keeps the optional-parameter ergonomics for commands whose options include undefined, so call sites like commands.back() are unchanged. bindAppCommands stays as a spread + manual 'list' override (filter normalization); selector/interaction families stay hand-written since most of their entries reshape signatures (prepended target/text positionals).
|
Reconciled after #1367's merge: rebased with Isolated diff verified unchanged: Exact-head checks at |
4ef8a78 to
b7b00f7
Compare
|
Re-review clean at |
What
Replaces the hand-written
bind*Commandsfunctions and their mirroredBound*Commandstype declarations with one derived form, for the families that are genuinely pass-through:BoundOf<T>mapped type +bindRuntimeCommands(commands, runtime)inruntime-types.ts(~20 lines)capture,system,admin,recording,observability: bind function and mirrored type deleted;Bound*Commandsbecomes a one-lineBoundOf<...>alias,bindCommands()calls the generic directlyapps: keepsbindAppCommandsas...bindRuntimeCommands(appCommands, runtime)plus the manuallistoverride (itsresolveAppsFilternormalization is real logic, not boilerplate)selectors/interactions: untouched by design — 11 of their 17 entries prepend a positionaltarget/textargument andOmitthat field from options, which a mapped type cannot deriveNet −86 lines. From the adversarially-verified overengineering audit (follow-up to #1367; scope was verified there, including the selector/interaction exclusion).
Behavior-preservation notes
BoundOfhas anundefined extends Obranch producing(options?: O) => Promise<R>, matching the hand-written optional-parameter shape — zero-arg calls likecommands.system.back()type-check exactly as before. A naiveRuntimeCommand<O,R> → BoundRuntimeCommand<O,R>mapping would have broken them.Bound*type names were never on the published surface (onlybindCommands/BoundAgentDeviceCommandsescape, toruntime.ts).Verification
typecheck·lint·check:production-exports· full unit suite (489/489 files) ·formatNote
Stacked on #1367 (base = its branch) with the
system/runtime/index.tsoverlap already resolved as the union of both deletions. After #1367 squash-merges and GitHub retargets this PR tomain, rebase withgit rebase --onto origin/main <old-base-head>to drop the inherited commits — no conflict resolution remains.