Skip to content

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

Merged
thymikee merged 8 commits into
mainfrom
t3/contracts-vocabulary-only-gestures
Nov 20, 2026
Merged

thymikee merged 8 commits into
mainfrom
t3/contracts-vocabulary-only-gestures

Conversation

@thymikee

@thymikee thymikee commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

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 c9cce06 head 4ccfbbc
contracts lines 26,736 25,187
contracts function declarations 621 552
contracts files 211 209
depgraph modularity (declared / detected) 0.367 / 0.542 0.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.

View guided diff Turn on auto-fix

@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 6.47 MB 6.47 MB -7 B
Package (unpacked) 6.47 MB 6.47 MB -7 B
Package (download) 1.97 MB 1.97 MB -8 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 33.3 ms 43.9 ms +10.6 ms
CLI --help 70.1 ms 75.2 ms +5.1 ms

@thymikee

Copy link
Copy Markdown
Member Author

This PR is ready at 6131f8c. The move is clean: the gesture reader, normalization and plan geometry now live in the new package, the types stay in contracts, and exported names are unchanged. Smoke Tests (ios), Smoke Tests (macos), Coverage and Ownership and context budgets pass at this commit; one Smoke Tests job was still running at review time, so merge once it is green.

Not verified here: the diff was read and CI was relied on for the unit suite and layering; the counts in the PR body were not re-measured.

Not blocking, take or leave:

  • The ADR line at docs/adr/0033-collocation-decision-table.md#L41 says plugins bundle their own copy of contracts code. Plugin bundling already includes every @agent-device/* package, so the move does not change that; the layering rule alone is the better rationale.
  • Two modules now share the gesture-input name (the contracts types and the gestures reader). A later slice could name the reader for what it does.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 20, 2026
@apex-sentinel-staging

This comment has been minimized.

@thymikee

Copy link
Copy Markdown
Member Author

Optional note applied at a611da8aa5: the ADR line and the PR body no longer give plugin bundling as the reason. A plugin inlines every @agent-device/* package it imports, so the move does not change that. The stated rationale is now the layering rule: R18 says contracts owns vocabulary only. Docs-only change.

@apex-sentinel-staging

This comment has been minimized.

@thymikee thymikee removed the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 20, 2026
thymikee and others added 7 commits November 20, 2026 17:36
…ice/gestures

Contracts is the shared vocabulary package, but gesture-plan.ts and
gesture-normalization.ts held pure algorithms. They move unchanged, with
their tests and fixtures, to a new private package that depends only on
contracts and kernel. ad-script and the platform packages call these
functions, so no existing package is below every consumer.

The gesture plan and payload types stay in contracts. Consumers change
only their import specifiers. R13 names gestures as platform substrate.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
readGesturePayload and its validators are logic, so they join the
gesture algorithms in @agent-device/gestures with their test. The payload
types and the gesture kind lists stay in contracts/gesture-input, where
client-gesture and other vocabularies name them.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…esture algorithms

Amend ADR 0033 with the owner rule for pure algorithms over a contracts
vocabulary, the rejected alternatives, and the ordered follow-up slices
for the logic that remains in contracts.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…s (R18)

R18 banned only host, process, and timer calls, so pure gesture logic
could return to contracts unnoticed. A contracts gesture input, plan, or
normalization module now fails the check when it declares any function.
The other contracts logic files stay out of scope until their slices move.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…lgorithms

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@thymikee
thymikee force-pushed the t3/contracts-vocabulary-only-gestures branch from a611da8 to 5e95c4b Compare November 20, 2026 16:39
@thymikee

Copy link
Copy Markdown
Member Author

Second optional note taken at 5e95c4bec2 (rebased onto current main): the reader in @agent-device/gestures is now gesture-payload-reader, so only the contracts types module is called gesture-input. Rename plus five import specifiers and the package export; no content change.

@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of 5e95c4b

Since the review of a611da8: 0 new · 0 still open · 0 no longer raised

No open findings.

Not in the reviewers' prompt (1 file)
  • pnpm-lock.yaml: generated or a lockfile, so its lines were left out

Reviewed with this repository's own Sentinel configuration (0731b7a06858).

💬 Talking to Sentinel

In a finding's thread, reply with:

Command What it does
@apex-sentinel-staging note <context> Adds context; Sentinel re-checks the cited code
@apex-sentinel-staging pivot <why> Says the finding is wrong; Sentinel re-checks the cited code
@apex-sentinel-staging like Marks the finding as useful
@apex-sentinel-staging dislike <why> Marks it as not useful, so it is not raised again

On this conversation, comment @apex-sentinel-staging review to run a full review once again.

@thymikee

Copy link
Copy Markdown
Member Author

This PR is ready at 5e95c4b. The earlier review of 6131f8c found nothing to fix, and the changes since then are an ADR sentence and a module rename; the rename leaves no stale importers. All checks pass and there are no conflicts.

Not blocking, take or leave: the R18 path matcher at https://github.com/callstack/agent-device/blob/5e95c4b/scripts/layering/contracts-implementation-policy.ts#L36 still targets the old gesture-input name and omits gesture-payload-reader.ts. The reader source passed as packages/contracts/src/gesture-payload-reader.ts returns zero violations, while the same source passed as gesture-input.ts triggers R18. Adding gesture-payload-reader to the matcher and to the existing rejection test would close that gap.

Not verified here: typecheck and tests were not run locally; this relies on CI and on a search that found no old-path imports.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 20, 2026
…s under R18

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@thymikee

Copy link
Copy Markdown
Member Author

Optional note taken at 571a612208: the R18 matcher now also names gesture-payload-reader, and the rejection test covers it, so the reader cannot return to contracts under its new name. Gate-only change.

@thymikee
thymikee merged commit 07a4cdb into main Nov 20, 2026
24 of 25 checks passed
@thymikee
thymikee deleted the t3/contracts-vocabulary-only-gestures branch November 20, 2026 17:11
thymikee added a commit that referenced this pull request Nov 20, 2026
…nts-main

* origin/main:
  refactor(contracts): bind only the interactor families an owner implements (#4821)
  refactor(gestures): move gesture algorithms out of contracts into @agent-device/gestures (#4823)
  docs(command-docs): add the shared option table and per-action option tables (#4824)
  docs(agents): hold a review to the PR's invariant and stop at a third round (#4835)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant