Skip to content

Document composite models (composable APIs stage 1) - #5583

Draft
Eliza Farley (elizafarley) wants to merge 2 commits into
mainfrom
claude/composable-apis-docs-review-b61b4f
Draft

Eliza Farley (elizafarley) wants to merge 2 commits into
mainfrom
claude/composable-apis-docs-review-b61b4f

Conversation

@elizafarley

@elizafarley Eliza Farley (elizafarley) commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Stage 1 of the composable APIs docs (DOCS-5003; covers DOCS-5117, DOCS-5118, and the config parts of DOCS-5119). This documents composite models: one model that serves several resource APIs, shipped in rdk v1.17.0 with registry support in the app.

The Viam app UI for composites (app #13952 and the PRs stacked on it) hasn't merged, so this PR documents only what users have today: Go authoring, meta.json, the CLI, the registry, JSON config, data capture, and SDK access. The "Use a composite model" page and the UI updates are stage 2, DOCS-5140.

New pages

  • build-modules/composite-models.md (explanation): what a composite is, how clients reach each API, which API handles shared methods, why one resource instead of several, composites versus separate models, and limits.
  • build-modules/build-a-composite-model.md (how-to): register with RegisterMultiAPI and ExpandModel, implement every API on one struct with Compose and AsSub, add facades for colliding methods, declare apis in meta.json, run it with viam module reload-local, and test each API from Go.
  • reference/glossary/composite.md: new glossary term.

Edits

  • build-modules/module-reference.md: models[].apis in the meta.json schema; a table of the Go functions for composites.
  • build-modules/module-anatomy.md: apis in the meta.json field summary.
  • build-modules/deploy-a-module.md: a composite model README template, with a DoCommand section and a table of which API each capturable method is tagged with.
  • build-modules/write-a-driver-module.md, build-modules/overview.md: pointers to composite models.
  • cli/reference.md: what update-models writes for a composite.
  • data/capture-sync/capture-and-sync-data.md: new "Capture from a composite" section, covering per-API tagging and how to pin a shared method to an API.
  • data/reference.md, data/schema.md: the capture name pin and component_type for composites.
  • hardware/machine-configuration.md: api can be any one of a composite's APIs.
  • motion-planning/frame-system/overview.md: a composite has one frame.
  • Glossary api-namespace-triplet.md, resource.md, model.md: removed "each resource implements one and only one API".
Verification

Verified against source (rdk v1.17.0 unless noted):

  • RegisterMultiAPI signature, wrapping, and the kinematic panic: resource/resource_registry.go:345-372
  • Compose, AsSub, canonical API for DoCommand/Status, Close once per distinct part: resource/multiapi.go:33-140
  • NamedFromProvider, AsType, APIsOf: resource/resource.go:131, :324, :355; AsType on a client composite: robot/client/client.go:942-993, robot/impl/multiapi_composite_test.go:89-94
  • Per-API AsSub helpers: components/*/<api>.go (for example, components/camera/camera.go:81)
  • ExpandModel and example structure: examples/customresources/demos/simplecombomodule/simplecombomodule.go, complexcombomodule/complexcombomodule.go
  • Startup errors: module/resources.go:386, :389
  • meta.json apis, CLI warning, update-models collapsing to one entry with the sorted-first api: cli/module_registry.go:52-67, :405-412, :1102-1115; cli/module.schema.json:122-130
  • reload --model-name writes one entry with the manifest api: cli/module_reload.go:284-345
  • Registry rejects api not in apis: viamrobotics/app data/registry_item.go (app #13968, merged 2026-11-19)
  • Capture owning-API resolution and pin errors: services/datamanager/builtin/capture/collector_metadata.go:76-110; pin read from name: services/datamanager/data_manager.go:141-175; failed resolution logs a warning and skips the method: services/datamanager/builtin/builtin.go:531-534
  • Frame system single-kinematic check: robot/framesystem/framesystem.go:55-74
  • Release: all rdk composite PRs (#6520, #6521, #6539-#6543, #6636, #6645) are in v1.17.0; api Capitalize Data Management #924 is in v0.1.607.
  • Production: app #13968, #13971, #13972 (registry) and #14053 (datasync) are in the production deploy of f3e348f41c (2026-11-20, status success) and in later deploys.

Run, against rdk v1.17.0 (viam-server and CLI built from go.viam.com/rdk@v1.17.0, local machine with no cloud connection):

  • Steps 1 and 2 (RegisterMultiAPI, ExpandModel, one struct with Compose), step 3 (facades and constructor), and step 6 (client body) compile as written. Step 3 needs the shared struct's non-colliding camera and movement sensor methods, which the page points to in complexcombomodule.
  • Step 4: viam module update-models --binary writes exactly the entry shown (api = rdk:component:button, apis = button and sensor). For the facade module it writes api = camera, apis = camera and movement_sensor.
  • Step 5's config entry plus step 6's client: output lists my-combo under button and sensor, serves [rdk:component:button rdk:component:sensor], readings: map[reading:7], and button pushed.
  • The facade module configured with "api": "rdk:component:movement_sensor" (not the sorted-first API) serves both APIs; camera.FromProvider and movementsensor.FromProvider each return their own facade's Properties.
  • Step 6's snippet, inserted into the app's CONNECT tab Go template (ui/src/routes/(auth-required)/machine/[machine_id]/connect/code-sample/golang/template.go) after defer machine.Close(ctx), compiles with the imports the page names.
  • DoCommand routing, with a test composite whose sensor and button parts are different structs: a call through the sensor client reaches the sensor part, through the button client the button part, and on the NamedFromProvider handle the canonical (button) part.
  • Data capture, with the data manager on the same local machine (sync disabled) and the composite configured under rdk:component:button: unpinned Readings is written under rdk_component_sensor; unpinned DoCommand under rdk_component_button; DoCommand with "name": "rdk:component:sensor/my-combo" under rdk_component_sensor; Readings pinned to the button API logs pins API "rdk:component:button", which does not capture method "Readings" and captures nothing.
  • Python SDK: per-API getters key resources by full name including API (viam-python-sdk src/viam/resource/manager.py:50), so the pages claim Go and Python only.

Unverified:

  • "A composite has one frame" (frame system overview, explanation page): from the content plan and the single config entry, not traced through the frame system builder.
  • What an older viam-server does with a composite module. The pages only state the v1.17.0 minimum.

Not run: viam module reload-local in step 5 (needs a cloud machine). C++, TypeScript, and Flutter clients against a composite are not checked, so the pages don't claim them.

Checks: prettier 3.2.5, markdownlint, vale 3.12.0 (0 errors), scripts/frontmatter_rules.py, make build-prod. The how-to checker reports no findings. The explanation checker reports one CV-11 warning that's a false positive: `resource.AsType[T](res)` in a code span reads as a link.

🤖 Generated with Claude Code

Add an explanation of composite models and a Go how-to for building one,
and update the meta.json, Go function, CLI, data capture, machine config,
frame system, and glossary docs for models that serve more than one API.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@viambot viambot added the safe to build This pull request is marked safe to build from a trusted zone label Nov 23, 2026
@netlify

netlify Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for viam-docs ready!

Name Link
🔨 Latest commit f22b682
🔍 Latest deploy log https://app.netlify.com/projects/viam-docs/deploys/6b04aaf6148206198cdc3a35
😎 Deploy Preview https://deploy-preview-5583--viam-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 41 (🟢 up 7 from production)
Accessibility: 100 (no change from production)
Best Practices: 100 (🟢 up 8 from production)
SEO: 92 (no change from production)
PWA: 60 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

Add concrete examples to the composite models page, define kinematic APIs,
fold the comparison table into the "why" section, add context before the
facade example, and add DoCommand and per-method capture sections to the
composite README template. Correct how DoCommand and Status route (per-API
calls reach that API's part), fix where the step 6 test code goes in the
CONNECT tab sample, and narrow SDK claims to Go and Python.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to build This pull request is marked safe to build from a trusted zone

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants