Repository navigation
Conversation
…s materials
PyLabRobot 1.0 serializes a Well's height_volume_data as {float: float}
(and legacy liquid handler channel state is keyed by int). Those keys
reached the registry template sync through config_info, where
normalize_json (orjson without OPT_NON_STR_KEYS) stopped the Host at
startup with "Dict key must be str"; the local registry snapshot report
failed the same way, so authoring reported registry_not_reported. The
strict canonical encoder rejects such keys as well.
material_serialization, the boundary where a PLR serialize() result
becomes material config/data, now turns dict keys into JSON keys
("0.45"). That is the form they already have after any JSON round trip,
and PyLabRobot restores them on deserialization (Container does
float(h), channels are read back with int()).
normalize_json also gets OPT_NON_STR_KEYS, matching its own stdlib json
fallback, because registry entries reach it without passing that
boundary: config_info cached by an earlier build is reused while the
resource module's source hash is unchanged, and registry YAML may use
numeric mapping keys. The strict encoder is left unchanged.
…a device
A transfer whose owner is the device itself (an arm whose gripper site
hangs on the device) resolved the slot by fetching the device tree from
the authority and indexing to_plr_resources()[0]. Devices are not PLR
materials and to_plr_resources() skips device trees, so the action
failed with IndexError before the driver was called.
A slot whose tree root is a device now gives the driver
{uuid, id, name, type: "device"}, the same shape as a {uuid} reference,
on HostLink and on ROS 2 (reference, flattened tree and batch sync
paths). A tree that still yields no PLR material raises a clear error
naming the reference instead of IndexError.
…tenance mode Only a device whose held materials could not be built went into maintenance mode. Any other failure while bringing up a device that runs inside the Host process - its authority state not fitting the registry (e.g. a site missing from available_sites), its driver module failing to import, its constructor raising, or post_init / setup / initialize raising on HostLink - escaped populate_runtime / HostLinkLocalRuntime.start or HostNode.__init__ and stopped the whole Host. DeviceStartupError (stage definition / construct / initialize) now shares the maintenance base and record with DeviceMaterialError: the device and its sub-devices stay down (sub-devices already started are stopped), the reason reaches /api/v1/devices and /api/v1/health, and the Host and the other devices keep running. The ROS 2 HostNode handles definition and construction failures of its local devices the same way. The isolation applies only to the Host process (HostLinkLocalRuntime(isolate_device_failures=True) for the HostLink Host; HostNode.initialize_device for ROS 2). A Slave, including a managed one under --root_devices_as_slaves, still fails and exits so the restart policy of its managed process applies. Graph configuration errors (missing registry entry, invalid template name) still fail the HostLink startup.
Graph reconciliation marked a site occupied whenever a child of the site's owner sat at the same coordinates. A device's gripper site is often a zero placeholder at the device origin, so a deck or store carrier mounted at that origin was recorded as held by the gripper and transfers through that gripper waited on gripper_site_occupied forever; the same happened to any plain child that happened to share a site's coordinates. Site occupancy now comes only from an explicit occupied_material_uuid (legacy occupied_by is still converted at the legacy read boundary) and from the PLR structure itself (occupants under carrier holders, sites serialized from native PLR sites).
A ResourceSlot only names a material. Handing a driver a device reference dict when a ResourceSlot resolved to a device (previous commit) made the parameter polymorphic; HostLink and ROS 2 now raise before the driver is called, naming the parameter and the device and pointing to DeviceSlot (whose value, the device id, reaches the driver unchanged). The clear error for a tree that yields no PLR material stays.
Workflow material inputs had no way to restrict their templates: an Annotated[ResourceSlot, AllowedResourceTemplates(...)] input was rejected because the symbols could not be bound to the registry. @workflow(allowed_templates={input: [registry resource id, ...]}) now carries the restriction while the input stays a plain ResourceSlot / List[ResourceSlot]: - the decorator and static compilation (workflow_ast) read the literal; a key that is not a ResourceSlot input fails registration; - publishing (template payload, authoring compile) resolves the ids to resource template uuids through the materials authority - the community.<package>. prefix may be omitted when unique - and fails on an unknown id; the uuids land in the input (and implicit output) schema extension allowed_resource_template_uuids already used by composite handles, so workflow details and the template catalog carry them for frontend filtering; - run preflight and task creation reject a site-bound input whose occupant has another template (material_site_invalid / invalid_material_site, reason template_mismatch) and a {uuid} input of another template (material_template_mismatch / invalid_material_template). AllowedResourceTemplates on a workflow input still fails, now pointing to @workflow(allowed_templates=...).
Material declares the real material actions of an action: move, two-step pick / place and dispense, with sites given as SiteSlot (site uuid), the owner derived from the site and the carrier a DeviceSlot defaulting to the executing device. Device tenancy, in-place checks, the site picker hint and order sensitivity stay in material= as experimental. Parameters are locked by type (ResourceSlot material lock, DeviceSlot device lock, SiteSlot site lock); Material.uses is removed. Also document how declared Material relates to the runtime materials helpers: a declared move is settled by the core, so the driver must not also transfer / assign the same material. Record the one-time incompatible change and the old-to-new mapping.
… place / dispense
Material now declares the real material actions of an action:
- Material.move(material, *, to_site, from_site=None, carrier_device=None)
normalizes to the transfer contract with no owner parameters (the owner
is derived from the site uuid), gripper role "gripper" and an optional
carrier_device_param;
- Material.pick / place(material, *, from_site / to_site, carrier_device)
normalize to transfer_step with an empty owner and an empty carrier list
meaning the executing device;
- Material.dispense(*, from_material, to_materials) is the old aliquot.
Device tenancy, in-place checks, the site picker hint
(Material.site_picker, occupied="hide" | "show" | "allow", the
x-unilabos-site-selector shape unchanged, owner may be a DeviceSlot or
null for the executing device) and order sensitivity stay in material=
and warn once per definition as experimental. load / unload take
DeviceSlot devices and default to the executing device ("$executor" in
the contract).
Registration checks every referenced parameter against the signature in
both the decorator and the AST scan: materials are ResourceSlot, sites
SiteSlot, devices DeviceSlot. Material.transfer / aliquot / site / uses
and pick / place with owner / site / carriers fail with the new
spelling. DeviceSlot / SiteSlot fields carry x-unilabos-slot so the
scheduler can lock them by type; the AST cache version is bumped.
The physical contract now accepts the normalized Material.move / pick / place shapes: - a target or source given as a SiteSlot (site uuid) derives its owner (a carrier or a device root) from the materials authority instead of a separate owner parameter; - move checks a given from_site against the authoritative location, and pick without from_site grabs from the authoritative location; - the carrier is the executing device unless carrier_device names a DeviceSlot, whose device id resolves to that device's material; the material rides on the carrier's "gripper" site. Contracts with explicit ResourceSlot owners keep working.
Parameters are locked by their type instead of Material.uses: - every DeviceSlot / list[DeviceSlot] value must name a registered device and adds a device lock (device_claims); - every SiteSlot value that is a registered site uuid adds a site lock on "owner material + site" (new site_claims on the resource request, part of the interval admission keys); site labels and empty values are not locked. Material.load / unload without a device hold the executing device (the "$executor" marker in the tenancy contract).
validate_resource_values (run preflight, scheduler dispatch and the Host gate) now: - checks every DeviceSlot / list[DeviceSlot] value names a registered, usable device whenever a materials authority is available; - takes the executing device id, so a Material.site_picker without `of` checks the selected site against the executing device's root, and an `of` that is a DeviceSlot checks it against that device's root.
…river receipts A succeeded action whose Material.move / pick / place was frozen before dispatch now settles at the frozen source and target when the driver result carries no material_transfer_receipts; receipts that are given must still match the frozen plan exactly. Manual settlement after a terminal task and dispense (actual amounts) still require receipts.
Site uuids are issued by the materials authority when a tree is created, so a workflow cannot hard-code the uuid of a station position. A SiteSlot parameter with a Material.site_picker(of=...) relation may now carry a Site label (or index) of that owner: run preflight and dispatch match it uniquely under the owner (a ResourceSlot, a DeviceSlot root or the executing device root) and use the resolved Site for the ownership / occupancy check, the site lock and the Material.move / place target and from_site. A label without a site_picker relation still fails before dispatch and takes no site lock.
A SiteSlot parameter with a Material.site_picker relation no longer gets
format: uuid in its goal schema, so a workflow can pass the Site label of
the picker's owner (resolved before dispatch); a Site uuid and the
{"owner_uuid": ...} selection keep working. The x-unilabos-site-selector
extension is unchanged; the AST cache version is bumped.
…experimental materials= takes the same value as before (one Material.xxx(...) call or a list). The whole field is experimental: any use warns once per definition, listing the declarations used, including move / pick / place / dispense. The old material= fails in the decorator and in the AST scan with a hint to materials=. AST scan cache version 29.
The guides, skills and AGENTS.md now use materials=, drop the stable / experimental split inside the field, and list the old material= in the breaking-changes table.
996fc43 declares the reactor actions with @action(materials=). The commit has to be on the demo's origin before the pinned clone can fetch it.
…ial_contract= @action(material_contract=...) takes the same value as before (one Material.xxx(...) call or a list) and still warns once per definition as experimental. Both material= (on dev) and the short-lived materials= fail in the decorator and in the AST scan with a hint to material_contract=. The decorator imports the normalizing material_contract() under an alias so it does not shadow the parameter. AST scan cache version 30.
The guides, skills and AGENTS.md use material_contract=. The breaking-changes row for material= now points at material_contract=; the short-lived materials= is mentioned as rejected but has no row of its own.
… main d25221c declares the reactor actions with @action(material_contract=). The commit has to be on the demo's origin before the pinned clone can fetch it.
The factory methods move / pick / place / dispense / load / unload / in_place / site_picker / order_sensitive now live on the frozen MaterialRole dataclass they return, so there is one public name, easy to tell apart from the runtime unilabos.resources.materials module. Material (on dev since #372) stays importable from unilabos.registry.decorators and material_roles only as a stub: any Material.xxx(...) fails at import time, and the AST scan rejects it, both with a hint to MaterialRole.xxx(...). The AST scan only calls the declaration factories, never instance methods or fields. Messages say MaterialRole. AST scan cache version 31.
The guides, skills and AGENTS.md use MaterialRole; the removed old forms keep their original Material. spelling. The breaking-changes table gets a row for the Material class name, and the material= row points at material_contract=MaterialRole.xxx(...).
c84ca2a declares the reactor actions with MaterialRole.xxx(...). The commit has to be on the demo's origin before the pinned clone can fetch it.
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.
Redesigns the
@actionresource-semantics helpers so that a declaration states the material action the driver actually performs, renames the field frommaterial=tomaterial_contract=and the declaration class fromMaterialtoMaterialRole, marks the field experimental, and moves resource locking onto parameter types. Rules and the breaking-changes table are indocs/developer_guide/action_standard.md.MaterialRole.move(material, to_site=, from_site=, carrier_device=)declares a one-action transfer,MaterialRole.pick/MaterialRole.placethe two-step form, andMaterialRole.dispense(from_material=, to_materials=)a content transfer settled from the driver'sAliquotReceipt. Site parameters areSiteSlot(site uuid) and the owner is taken from the site; an omittedcarrier_devicemeans the executing device, and the carrier's gripper site role is alwaysgripper.load/unload/in_place/site_picker/order_sensitiveare the declarations that are not material actions. The decorator and the AST scan share one implementation (registry/material_roles.py).material_contract=, experimental. The field is now@action(material_contract=...); the value is unchanged (oneMaterialRole.xxx(...)call or a list). The whole field is experimental: any use warns once per definition, listing the declarations used, includingmove/pick/place/dispense. The oldmaterial=(on dev since feat(registry)!: one standard for every JSON action and a single material= field #372) and the short-livedmaterials=from earlier commits on this branch both fail in the decorator and in the AST scan with a hint tomaterial_contract=; neither is silently ignored. The normalizing functionmaterial_contract()keeps its name; the decorator imports it under an alias so it does not shadow the parameter.MaterialRole, one public name. The factory methods (move/pick/place/dispense/load/unload/in_place/site_picker/order_sensitive) live on the frozenMaterialRoledataclass they return, named apart from the runtimeunilabos.resources.materialsmodule. The old class nameMaterial(on dev since feat(registry)!: one standard for every JSON action and a single material= field #372) is still importable fromunilabos.registry.decorators/material_roles, but only as a stub: anyMaterial.xxx(...)fails at import time, and the AST scan rejects it, both with a hint toMaterialRole.xxx(...). The AST scan only calls the declaration factories, never instance methods or fields. AST scan cache version 31.Material.transfer→MaterialRole.move,aliquot→dispense,site→site_picker,uses→ removed;pick/placeno longer takeowner/site/carriers/gripper.ResourceSlot→ material lock,DeviceSlot→ device lock,SiteSlot→ site lock.DeviceSlotvalues and device-owned site pickers are checked before dispatch.site_pickerowner. Site uuids are regenerated whenever the materials database is rebuilt, so workflow source cannot hold fixed site uuids. ASiteSlotthat hasMaterialRole.site_picker(of=...)also accepts a site name under that owner, resolved to the uuid before dispatch.dispensestill require a receipt (a driver running in a separate Slave process cannot look up its gripper site's uuid).@workflow(allowed_templates=...), and gap fixes found on the way (aResourceSlotthat resolves to a device is rejected, site occupancy is no longer inferred from equal coordinates, a device whose startup fails inside the Host goes into maintenance mode, non-str keys are turned into JSON keys where PLR data enters materials).Deployments: the transfer gripper Site role is now
gripper. A materials database that still has the old role name (e.g.robot.gripper) must be rebuilt or edited; startup does not migrate it.Known follow-ups (not changed here): type-based locks also lock devices passed to read-only actions (the
always_freediagnostichost_node.test_resource, LockDemo's read-only audit); no exemptions were added and no deadlocks showed up. The static helperresource_plan._compile_transfer_pairs, not on the normal path, still uses the old parameter names.Tests: full suite on Windows (PLR 1.0.0b1 venv): 3592 passed, 27 skipped, 6 failures that also fail on the parent commit in this environment (3 database lock, 1 symlink, 2 process-lifetime), plus one ROS 2 detection test that is flaky in the full run and passes alone. 12 new tests in
tests/server/test_material_actions.py; tests for thematerial_contract=field, theMaterialRolefactories, the rejection ofmaterial=/materials=and ofMaterial.xxx(...)(at import and in the AST scan) and the experimental warning intests/registry/test_action_resource_contract.py. The README demo e2e pins LabDeviceComplexWorkflowDemo to itsMaterialRolemain (c84ca2a); all README demos pass against local checkouts.material_contract=definitions warns once, namingMaterialRole..--check_mode; the HostLink smoke and their own pytest pass for 6. For LabDeviceComplexWorkflowDemo the smoke run itself passes (same settlement as before), but the temporary-directory cleanup hits a Windows file lock, in the standalone smoke and in itstest_hostlink_smoke(same on the parent commit). ROS 2 was not run locally; CI's registry-check (humble / jazzy) covers it.