Skip to content

item-identity Specification

Purpose

Workers, triggers and groups are identified the same way: by an id that is generated unless the caller gives one, that is never duplicated and never changes, with the display name as a tag, so scripts never collide on text names.

Requirements

Requirement: Item Ids

Every worker, trigger and group SHALL be identified by an id alone, unique among items of its kind in the context, and every call SHALL reference the item by it. An id SHALL never change; there SHALL be no rename. The display name SHALL be the infra tag name (standard-tags), not a field.

Scenario: Renaming a trigger

  • WHEN a client sets the name tag of trigger t to "Every minute"
  • THEN its id, schedule, groups and next firing SHALL be unchanged

Requirement: Generated Ids

CreateWorker, ScheduleTrigger and CreateGroup without an id SHALL generate a UUID of version 7 as the id; each such call SHALL create a new item.

Scenario: A trigger without an id

  • WHEN a script calls ScheduleTrigger{schedule: "0 * * * * *", target_topic: "t"} without an id
  • THEN the answer SHALL carry a generated UUID of version 7, and GetTrigger with it SHALL return the trigger

Scenario: Two scripts create items of the same name

  • WHEN two scripts each call CreateGroup{tags: {name: "Momentum"}} without an id
  • THEN two groups SHALL exist, each with its own generated id

Requirement: Given Ids Are Never Duplicated

A caller MAY give an id, which SHALL be a UUID (any version) for workers, triggers and groups alike. An id that must be found again by rule SHALL be derived with the shared generator's version 5 (DerivedId) from a namespace and a text, for example the scenario tooling's group for scenario S1. A create whose given id already exists for an item of that kind SHALL fail with ALREADY_EXISTS naming the id and SHALL change nothing, whatever the request's other values.

Scenario: A rule-derived id twice

  • WHEN the scenario tooling calls CreateGroup{id: DerivedId(scenario namespace, "S1")} and then again with the same id
  • THEN the second call SHALL fail with ALREADY_EXISTS naming that id, and the first group SHALL be unchanged

Scenario: A trigger's given id twice

  • WHEN a script calls ScheduleTrigger{id: <a UUID>, ...} while a trigger with that id exists
  • THEN the call SHALL fail with ALREADY_EXISTS naming the id, and the existing trigger SHALL keep its schedule and next firing

Scenario: A given id that is no UUID

  • WHEN a script calls CreateWorker{id: "momentum.btc", ...}, ScheduleTrigger{id: "tick.1m", ...} or CreateGroup{id: "scenario.S1", ...}
  • THEN each call SHALL fail with INVALID_ARGUMENT naming the field id

Requirement: Readable Labels in Examples

Where these specs name an item by a readable label (for example group momentum-btc or trigger tick.1m), the label SHALL stand for the item's UUID id and its name tag; ids themselves SHALL always be UUIDs.

Scenario: Reading an example

  • WHEN a scenario says "group momentum-btc"
  • THEN it SHALL mean the group whose name tag is momentum-btc, addressed by its UUID id

Requirement: One Id Generator per Language

Ids SHALL be generated through one shared helper per language (C#, Python, TypeScript) in the infra libraries: UUID version 7 for record, event and correlation ids, version 4 for tokens (such as lease tokens), and version 5 for ids that must be derived the same way every time. Ordering SHALL NOT rely on ids; timestamps SHALL stay the source of truth for time.

Scenario: A new record id

  • WHEN the WorkManager creates a worker without a given id
  • THEN the id SHALL come from the shared helper and be a UUID of version 7

Scenario: A lease token

  • WHEN the Runtime takes a worker's lease
  • THEN its token SHALL be a UUID of version 4

Requirement: Uniform Creates

CreateWorker, ScheduleTrigger and CreateGroup SHALL each take an optional id, optional tags and optional groups (parents for a group), and SHALL answer {id}.

Scenario: A trigger created into a group

  • WHEN a script calls ScheduleTrigger{tags: {name: "tick"}, groups: ["momentum-btc"], ...}
  • THEN the answer SHALL carry the trigger's id, and the trigger SHALL belong to momentum-btc

Requirement: Uniform Reads

Workers, triggers and groups SHALL each be read by GetWorker, GetTrigger, GetGroup (by id) and listed by ListWorkers, ListTriggers, ListGroups, each with tag_filters (exact match, all must match), plus group for workers and triggers or parent for groups.

Scenario: Same filter on every kind

  • WHEN a client lists workers, triggers and groups with tag_filters managed-by=rebalance-notebook
  • THEN each list SHALL return exactly the items of its kind carrying that tag

Requirement: Uniform Tag Updates and Deletes

Tags SHALL be changed by UpdateWorkerTags, UpdateTriggerTags and UpdateGroupTags, and items deleted by DeleteWorker, DeleteTrigger and DeleteGroup, each by id.

Scenario: Deleting a trigger by id

  • WHEN a client calls DeleteTrigger{id} with a trigger's id
  • THEN the trigger SHALL be deleted and GetTrigger with that id SHALL fail with NOT_FOUND

Requirement: Atomic Tag Updates

Update<Kind>Tags{id, set, remove} SHALL set the keys in set and remove the keys in remove in one atomic step, leaving other keys, the item's groups and everything else unchanged, and SHALL publish the kind's change event. There SHALL be no call that replaces all tags at once.

Scenario: Two scripts change different keys

  • WHEN one script sets world=hyp and another sets managed-by=sweep on the same worker at the same time
  • THEN the worker SHALL carry both tags afterwards