Repository navigation
Document composite models (composable APIs stage 1) - #5583
Draft
Eliza Farley (elizafarley) wants to merge 2 commits into
Draft
Eliza Farley (elizafarley) wants to merge 2 commits into
Eliza Farley (elizafarley) wants to merge 2 commits into
Conversation
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>
✅ Deploy Preview for viam-docs ready!
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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 withRegisterMultiAPIandExpandModel, implement every API on one struct withComposeandAsSub, add facades for colliding methods, declareapisinmeta.json, run it withviam module reload-local, and test each API from Go.reference/glossary/composite.md: new glossary term.Edits
build-modules/module-reference.md:models[].apisin themeta.jsonschema; a table of the Go functions for composites.build-modules/module-anatomy.md:apisin themeta.jsonfield 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: whatupdate-modelswrites 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 capturenamepin andcomponent_typefor composites.hardware/machine-configuration.md:apican be any one of a composite's APIs.motion-planning/frame-system/overview.md: a composite has one frame.api-namespace-triplet.md,resource.md,model.md: removed "each resource implements one and only one API".Verification
Verified against source (rdk
v1.17.0unless noted):RegisterMultiAPIsignature, wrapping, and the kinematic panic:resource/resource_registry.go:345-372Compose,AsSub, canonical API forDoCommand/Status,Closeonce per distinct part:resource/multiapi.go:33-140NamedFromProvider,AsType,APIsOf:resource/resource.go:131,:324,:355;AsTypeon a client composite:robot/client/client.go:942-993,robot/impl/multiapi_composite_test.go:89-94AsSubhelpers:components/*/<api>.go(for example,components/camera/camera.go:81)ExpandModeland example structure:examples/customresources/demos/simplecombomodule/simplecombomodule.go,complexcombomodule/complexcombomodule.gomodule/resources.go:386,:389meta.jsonapis, CLI warning,update-modelscollapsing to one entry with the sorted-firstapi:cli/module_registry.go:52-67,:405-412,:1102-1115;cli/module.schema.json:122-130reload --model-namewrites one entry with the manifestapi:cli/module_reload.go:284-345apinot inapis: viamrobotics/appdata/registry_item.go(app #13968, merged 2026-11-19)services/datamanager/builtin/capture/collector_metadata.go:76-110; pin read fromname:services/datamanager/data_manager.go:141-175; failed resolution logs a warning and skips the method:services/datamanager/builtin/builtin.go:531-534robot/framesystem/framesystem.go:55-74v1.17.0; api Capitalize Data Management #924 is inv0.1.607.f3e348f41c(2026-11-20, statussuccess) and in later deploys.Run, against rdk v1.17.0 (
viam-serverand CLI built fromgo.viam.com/rdk@v1.17.0, local machine with no cloud connection):RegisterMultiAPI,ExpandModel, one struct withCompose), 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 incomplexcombomodule.viam module update-models --binarywrites exactly the entry shown (api=rdk:component:button,apis= button and sensor). For the facade module it writesapi= camera,apis= camera and movement_sensor.my-combounder button and sensor,serves [rdk:component:button rdk:component:sensor],readings: map[reading:7], andbutton pushed."api": "rdk:component:movement_sensor"(not the sorted-first API) serves both APIs;camera.FromProviderandmovementsensor.FromProvidereach return their own facade'sProperties.ui/src/routes/(auth-required)/machine/[machine_id]/connect/code-sample/golang/template.go) afterdefer machine.Close(ctx), compiles with the imports the page names.DoCommandrouting, 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 theNamedFromProviderhandle the canonical (button) part.rdk:component:button: unpinnedReadingsis written underrdk_component_sensor; unpinnedDoCommandunderrdk_component_button;DoCommandwith"name": "rdk:component:sensor/my-combo"underrdk_component_sensor;Readingspinned to the button API logspins API "rdk:component:button", which does not capture method "Readings"and captures nothing.viam-python-sdksrc/viam/resource/manager.py:50), so the pages claim Go and Python only.Unverified:
viam-serverdoes with a composite module. The pages only state the v1.17.0 minimum.Not run:
viam module reload-localin 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