On this page

Workstation๏ƒ

Use md.Workstation from the public package namespace.

Implementation source

class Workstation(owner_space_id: str, *, default_weak_ref_bindings: bool = False, event_publisher: Callable[[Dict[str, object]], None] | None = None, rift_gate: RiftGate | None = None)[source]๏ƒ

Internal

Room-local binding canvas owned by one RiftSpace.

Purpose:

Provide the local operating canvas inside one room where saved objects, saved attribute/value bindings, saved method/callable bindings, and the active target can be retained across steps.

Contract:

  • Stores only room-local bindings; it does not discover or resolve new targets from Melder/Nexus.

  • Keeps object, attribute/value, and method/callable bindings in separate logical stores.

  • Each logical store supports both strong and weak backing storage.

  • Bind calls accept weak_ref=True, weak_ref=False, or weak_ref=None.

  • weak_ref=None resolves through the room-local default captured when this workstation is created.

  • Explicit weak binding raises when the supplied value cannot be weak-referenced; it never silently degrades to strong storage.

  • Tracks at most one active target binding at a time.

  • cleanup_target(...) acts only on the target selected when it starts and then clears target selection, unless another agent selected a different target meanwhile.

  • call_target(...) invokes the currently selected callable target and may bind the return value back into the workstation.

  • Cleanup clears workstation-owned binding state but does not attempt to cleanup every stored binding automatically.

Lifecycle:

Owned by one RiftSpace. Cleanup is idempotent and clears binding stores plus active-target state.

Registration:

MELDER KERNEL - guarded. Created by the owning RiftSpace; users reach it through space.workstation.

Subsystem Context:

The BINDING CANVAS of a room, third beside FrameViewer (reads) and CommandSystem (mediated actions). Commands deliberately do not store results, so this is where anything worth keeping lands.

System Context:

The weak/strong storage model is the core of this class and it is where room posture becomes concrete. weak_ref=None resolves through the ROOM-LOCAL DEFAULT captured at construction - weak in static rooms, strong in capability rooms - so the same call in different rooms correctly produces different lifetime semantics without the caller restating policy. Explicit weak binding RAISES when a value cannot be weak-referenced and never silently degrades to strong. That refusal is the important one: a silent downgrade would hand back a binding whose lifetime contract is the opposite of what was requested, and the caller would have no way to detect it. Separating object, attribute, and method stores keeps those namespaces from colliding, and the single active target keeps target-relative commands unambiguous - a canvas with several simultaneous "current" things would make every one of them ambiguous. Agents working in one room share that one target (see Threading).

Threading:

One workstation per room, shared by every agent working in that room (the owner, 2026-11-08: agents can work in the same workstation at the same time). They share its one active target and its binding names, so one agent can select another target, or rebind a name, under another; coordinating that is the agents' business. The workstation lock keeps the binding stores and the selection consistent and is never held while agent code runs: call_target and cleanup_target resolve the target under it and call the target, or its cleanup methods, after releasing it (GitHub #274, W5), so agents' calls run concurrently. Whether the target's own methods are safe to call from several threads at once is the target's business, not Melder's (the owner, 2026-11-08). Every public method below - the binds, get, release, describe_bindings and the target methods - is an agent door: when the room hands the workstation its Rift gate, the method holds the calling thread's gate ticket for its whole run, call_target and cleanup_target across the agent code too (GitHub #274, step 3). A removal of the Rift therefore waits for them and refuses new ones, and an ACL refresh drains them; a call nested in another call of the same Rift passes by re-entry. The weak-binding collection callback and the identity properties take no ticket.

AGENT_ACCESS: public

AGENT_PURPOSE:

access: public. The room-local binding canvas (space.workstation): save objects, attribute and method bindings (strong or weak) and one active target across steps. Commands do not store their results, so this is where you keep what matters.

cleanup() → None[source]๏ƒ

Internal

Idempotently clear workstation binding state.

Contract:

  • Safe to call more than once.

  • Clears strong and weak binding stores.

  • Clears active-target state.

  • Does not attempt to cleanup every stored binding automatically; explicit target cleanup is a separate operation.

  • Drops the borrowed Rift gate reference without cleaning the gate, which the owning Rift owns.

Returns:

None.

property workstation_id: str๏ƒ

Return the stable workstation identifier.

Contract:

  • Identifies THIS WORKSTATION, distinct from owner_space_id - the space that hosts it.

Threading:

Reads under self._lock, so the result is a coherent snapshot.

Lifecycle / Cleanup:

Guarded by check_cleaned().

Raises:

RuntimeError -- If the object has been cleaned.

Returns:

Stable workstation id.

Return type:

str

property owner_space_id: str๏ƒ

Return the owning room identifier.

Contract:

  • The rift space hosting this workstation, fixed at construction. A workstation is never re-homed to another space.

Threading:

Reads under self._lock, so the result is a coherent snapshot.

Lifecycle / Cleanup:

Guarded by check_cleaned().

Raises:

RuntimeError -- If the object has been cleaned.

Returns:

Owning RiftSpace id.

Return type:

str

bind_object(name: str, value: object, *, weak_ref: bool | None = None) → None[source]๏ƒ

Store one object binding by name.

Contract:

Delegates to the shared _bind(...) helper using the objects store and the requested reference mode.

Parameters:
  • name -- Binding name.

  • value -- Bound object value.

  • weak_ref -- Explicit reference-mode override. True forces weak storage, False forces strong storage, and None uses the room-local workstation default.

Returns:

None.

Raises:
  • ValueError -- If name is empty.

  • TypeError -- If weak storage is requested for a value that cannot be weak-referenced.

  • RuntimeError -- If the workstation is cleaned, or the room's Rift gate refuses the call.

Threading:

An agent door: holds the room's Rift gate ticket for the call (GitHub #274, step 3) and writes under the workstation lock.

bind_attribute(name: str, value: object, *, weak_ref: bool | None = None) → None[source]๏ƒ

Store one attribute/value binding by name.

Contract:

Delegates to the shared _bind(...) helper using the attributes store and the requested reference mode.

Parameters:
  • name -- Binding name.

  • value -- Bound attribute/value.

  • weak_ref -- Explicit reference-mode override. True forces weak storage, False forces strong storage, and None uses the room-local workstation default.

Returns:

None.

Raises:
  • ValueError -- If name is empty.

  • TypeError -- If weak storage is requested for a value that cannot be weak-referenced.

  • RuntimeError -- If the workstation is cleaned, or the room's Rift gate refuses the call.

Threading:

An agent door: holds the room's Rift gate ticket for the call (GitHub #274, step 3) and writes under the workstation lock.

bind_method(name: str, value: object, *, weak_ref: bool | None = None) → None[source]๏ƒ

Store one method/callable binding by name.

Contract:

Delegates to the shared _bind(...) helper using the methods store and the requested reference mode.

Parameters:
  • name -- Binding name.

  • value -- Bound method/callable.

  • weak_ref -- Explicit reference-mode override. True forces weak storage, False forces strong storage, and None uses the room-local workstation default.

Returns:

None.

Raises:
  • ValueError -- If name is empty.

  • TypeError -- If weak storage is requested for a value that cannot be weak-referenced.

  • RuntimeError -- If the workstation is cleaned, or the room's Rift gate refuses the call.

Threading:

An agent door: holds the room's Rift gate ticket for the call (GitHub #274, step 3) and writes under the workstation lock.

get(name: str, *, store: str | None = None) → object[source]๏ƒ

Return one saved binding by name.

Parameters:
  • name -- Binding name to resolve.

  • store -- Optional explicit store name (objects, attributes, methods). When omitted, the binding must resolve uniquely across the logical stores.

Returns:

Saved binding value.

Return type:

object

Raises:
  • ValueError -- If name is empty, the binding is missing, or the name is ambiguous across the logical stores.

  • RuntimeError -- If the workstation is cleaned, or the room's Rift gate refuses the call.

Threading:

An agent door: holds the room's Rift gate ticket for the call (GitHub #274, step 3) and reads under the workstation lock.

release(name: str, *, store: str | None = None) → object[source]๏ƒ

Remove one saved binding and return the removed value.

Parameters:
  • name -- Binding name to remove.

  • store -- Optional explicit store name. When omitted, the binding must resolve uniquely across the logical stores.

Returns:

Removed binding value.

Return type:

object

Raises:
  • ValueError -- If the binding cannot be resolved.

  • RuntimeError -- If the workstation is cleaned, or the room's Rift gate refuses the call.

Threading:

An agent door: holds the room's Rift gate ticket for the call (GitHub #274, step 3) and writes under the workstation lock.

describe_bindings() → Dict[str, List[str]][source]๏ƒ

Return a detached summary of saved binding names by logical store.

Contract:

  • Returns a FIVE-KEY summary - objects, attributes, methods, target_name and target_store - always with all five keys present, so callers can index them without a get.

  • target_name and target_store are normalized to LISTS for shape consistency with the other three: empty when no target is bound, single-element when one is. Neither is a list of many targets. target_store names WHICH store the active target came from, so a caller can round-trip it back through get(name, store=...).

  • Names only, not values: this describes what is bound, not what those bindings currently hold.

Threading:

An agent door: holds the room's Rift gate ticket for the call (GitHub #274, step 3). Reads under self._lock, so the result is a coherent snapshot.

Lifecycle / Cleanup:

Guarded by check_cleaned().

Raises:

RuntimeError -- If the object has been cleaned, or the room's Rift gate refuses the call.

Returns:

Binding names grouped by logical store.

Return type:

Dict[str, List[str]]

set_target(name: str, *, store: str | None = None) → None[source]๏ƒ

Select one saved binding as the active target.

Parameters:
  • name -- Binding name to select.

  • store -- Optional explicit store name. When omitted, the binding must resolve uniquely across the logical stores.

Returns:

None.

Raises:
  • ValueError -- If the binding cannot be resolved.

  • RuntimeError -- If the workstation is cleaned, or the room's Rift gate refuses the call.

Threading:

An agent door: holds the room's Rift gate ticket for the call (GitHub #274, step 3) and selects under the workstation lock.

get_target() → object[source]๏ƒ

Return the currently selected target value.

Returns:

Current target value.

Return type:

object

Raises:
  • ValueError -- If no target is selected.

  • RuntimeError -- If the workstation is cleaned, or the room's Rift gate refuses the call.

Threading:

An agent door: holds the room's Rift gate ticket for the call (GitHub #274, step 3) and reads under the workstation lock; call_target reaches it by re-entry.

clear_target() → None[source]๏ƒ

Clear the current active-target selection only.

Contract:

  • Leaves all stored bindings intact.

  • Resets only the active-target pointers.

Returns:

None.

Raises:

RuntimeError -- If the workstation is cleaned, or the room's Rift gate refuses the call.

Threading:

An agent door: holds the room's Rift gate ticket for the call (GitHub #274, step 3) and clears under the workstation lock.

cleanup_target(*method_names: str) → None[source]๏ƒ

Call cleanup methods on the current target and then clear target selection.

Contract:

  • Cleans the target selected when the call starts; the cleanup methods run in the order given.

  • Clears the selection afterwards only while it still names the binding just cleaned (by name and store): a target another agent selected while the cleanup methods ran stays selected.

  • Returns without clearing when a teardown cleaned the workstation meanwhile: the calling thread's own removal of its Rift, or one that did not wait for it (a Nexus cleanup past its drain deadline, a direct Rift.cleanup); one of the latter landing just before the lock raises AttributeError.

Parameters:

*method_names -- Optional ordered cleanup method names. When omitted, the workstation uses the default sequence: cleanup, close, dispose.

Returns:

None.

Raises:
  • ValueError -- If no target is selected, a method name is empty, or no cleanup method can be resolved on the current target.

  • RuntimeError -- If the workstation is cleaned, one resolved cleanup method is not callable, or the room's Rift gate refuses the call.

Threading:

An agent door: holds the room's Rift gate ticket for its whole run, the cleanup methods included (GitHub #274, step 3), so a removal of the Rift waits for them. Resolves the target under the workstation lock and runs its cleanup methods - agent code - after releasing it, so another agent's use of this workstation does not wait on them and a cleanup method that uses this room cannot freeze against it (GitHub #274, W5). The selection is cleared under the lock again.

call_target(*args: Any, bind_as_name: str | None = None, bind_as_store: str = 'objects', **kwargs: Any) → object[source]๏ƒ

Invoke the current target and optionally bind the return value.

Contract:

  • Resolves the current target through the logical store layer and calls the target selected when the call starts; another agent selecting a different target meanwhile does not change it.

  • When bind_as_name is supplied, the return value is rebound through the normal workstation bind path with weak_ref=None, which means the room default applies.

Parameters:
  • *args -- Positional arguments passed to the target.

  • bind_as_name -- Optional workstation binding name for the return value.

  • bind_as_store -- Store to use when binding the return value: objects, attributes, or methods.

  • **kwargs -- Keyword arguments passed to the target.

Returns:

Target return value.

Return type:

object

Raises:
  • ValueError -- If no target is selected or bind_as_store is invalid.

  • RuntimeError -- If the target is not callable, the room's Rift gate refuses the call, or the workstation is cleaned - also when the target removed its own Rift and bind_as_name asks to bind the result.

Threading:

An agent door: holds the room's Rift gate ticket for its whole run, the target included (GitHub #274, step 3), so a removal of the Rift waits for the target to return and an ACL refresh drains it; a target that calls back into its own Rift passes by re-entry, and one that removes its own Rift is not waited for. Resolves the target under the workstation lock and calls it - agent code - after releasing it, so agents sharing this workstation run their calls concurrently and a target that uses this room through a command cannot freeze against another command reading the target (GitHub #274, W5).

Topic reference ยท Full contents