refactor(gestures): move gesture algorithms out of contracts into @agent-device/gestures

Merged
TH
7d ago
+599-376

Summary

packages/contracts is the shared vocabulary package, but R18 only banned host, process, and timer calls, so pure logic lived there against the rule's own statement that contracts owns vocabulary only. Plugin bundling is unchanged: a plugin inlines every @agent-device/* package it imports.

This PR moves one slice: gesture payload reading, public gesture normalization, and gesture plan geometry now live in a new private package, @agent-device/gestures (depends only on contracts and kernel). The payload and plan types stay in contracts. Exported names are unchanged; consumers change only import specifiers. No behaviour or wire change, so this is not device-facing.

A new package is needed because ad-script (contracts + kernel only) and the platform packages call these functions, and no existing package is below both.

  • refactor(move): gesture-plan.ts, gesture-normalization.ts, tests, fixtures, package wiring. R13 names gestures as platform substrate.
  • refactor(gestures): readGesturePayload leaves contracts/gesture-input; types stay.
  • docs(adr): ADR 0033 amendment with rejected alternatives and ordered follow-up slices.
  • chore(gates): R18 rejects any function in a contracts gesture input, plan, or normalization module.

Value

Measure (production files)base c9cce06head 4ccfbbc
contracts lines26,73625,187
contracts function declarations621552
contracts files211209
depgraph modularity (declared / detected)0.367 / 0.5420.367 / 0.542

R4 cycles 0 and R5 back-edges 0 at both.

Validation

At 4ccfbbc, locally: pnpm build, check:quick, check:layering (513 pass), check:fallow, check:production-exports, check:package, check:adr-citations, eager-closure budget test (no budget changed), pnpm format. Targeted vitest for gestures, contracts, ad-script, command-surface, command-runtime, daemon, maestro, replay-port, platform-android, platform-apple, platform-linux, provider-webdriver, src/mcp: all pass. The full unit suite and integration lanes are left to CI.

🤖 Generated with Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.