Workspace/Coding labs
Loading progress

Select a unique target from a semantic snapshot

Intermediate45 min

Implement select_target(nodes, role, name, scope, observed_revision, current_revision). Return a unique actionable node ID, return None for no match, and raise ValueError for ambiguity or stale observations.

Your task

  1. Match role, name, and scope exactly; consider only visible and enabled nodes.
  2. Reject stale revisions before selecting a target.
  3. Raise ValueError if more than one actionable target matches.
  4. Return None for zero matches and leave node dictionaries unchanged.

Examples

EXAMPLE 1

InputOne visible, enabled Save button in invoice scope at revision 4; current revision 4

Output'x'

Identity, scope, actionability, and freshness all match.
solution.pyPython 3.12