Module service

Module service 

Source

Structsยง

AgentContext ๐Ÿ”’
The agent paneโ€™s place in the object tree, resolved from its block id. Powers GET /api/v1/self and lets naming verbs default to โ€œmy own Xโ€.

Staticsยง

ZOOM_MIRROR_GEN ๐Ÿ”’
Dispatch a command into the srv reducer and return the emitted events. Locks the reducer mutex briefly; the lock is released before any I/O (caller is responsible for publishing the events to the broadcast bus). Per-agent_id debounce generation for zoom mirroring. Each term:zoom change bumps the agentโ€™s generation; the spawned trailing-write task only commits if its captured generation is still current 300ms later, so a Ctrl+Wheel burst collapses into a single durable write (+ one global def-registry re-mirror). See SPEC_AGENT_ZOOM_PERSISTENCE ยง4.3.

Functionsยง

agent_layout ๐Ÿ”’
Read-only snapshot of the window โ†’ workspace โ†’ tab โ†’ pane tree, for agent introspection (GET /api/v1/layout). Pure wstore reads โ€” no reducer, so itโ€™s hermetic and safe. Lookups use linear scans (a handful of objects).
agent_tabs ๐Ÿ”’
Flat list of tabs (id, name, pane count). When workspace_id is given, only that workspaceโ€™s tabs are returned.
agent_windows ๐Ÿ”’
Flat list of all windows (id, display name, assigned workspace).
agent_workspaces ๐Ÿ”’
Flat list of all workspaces (id, name, tab count, active tab).
compensate_via_reducer ๐Ÿ”’
Compensation helper: dispatch a command into the reducer and apply its emitted events to wstore best-effort. Used when an earlier sync apply partially wrote SQLite and we need to undo the leaked rows. SQLite errors during compensation are logged but ignored โ€” the caller is already returning an error to the client; throwing on the cleanup just hides the original cause. (codex P1 + reagent P2 #616 โ€” partial-write cleanup.)
dispatch_service ๐Ÿ”’
dispatch_to_reducer ๐Ÿ”’
find_tab_for_layout ๐Ÿ”’
Phase E.4 (Option A) โ€” reverse lookup: given a LayoutState.oid, find the Tab.oid that owns it (i.e., the tab whose layoutstate field matches). Returns None when the layout is unowned (legacy or partially-migrated row) or the wstore read fails โ€” caller treats either as โ€œskip the reducer dispatch and fall through to the wcore write.โ€ Linear scan over all tabs; acceptable here because the layout-update path is low-frequency relative to drag-resize and the reducer mutex itself is held for sub-millisecond intervals.
get_object_by_oref ๐Ÿ”’
Resolve an โ€œotype:oidโ€ string to the corresponding wave object JSON.
handle_client_service ๐Ÿ”’
handle_misc_service ๐Ÿ”’
handle_object_service ๐Ÿ”’
handle_service ๐Ÿ”’
handle_window_service ๐Ÿ”’
handle_workspace_service ๐Ÿ”’
publish_events ๐Ÿ”’
Publish each event on the srv broadcast bus. Failures (no subscribers) are non-fatal.
queue_source_layout_delete ๐Ÿ”’
Phase E.5.5 โ€” append a layout-delete action to the source tabโ€™s LayoutState.pendingbackendactions so the source windowโ€™s frontend tears the moved block out of its layout tree on next poll. Mirrors the action-queueing portion of wcore::tear_off_block. Layout migration is E.4.
queue_target_layout_insert ๐Ÿ”’
Floating-pane re-dock โ€” enqueue an โ€œinsertโ€ action on the TARGET tabโ€™s LayoutState.pendingbackendactions so the target windowโ€™s frontend adds a new leaf for the redocked block through its LayoutTreeActionType.InsertNode reducer pathway.
resolve_agent_context ๐Ÿ”’
Walk block โ†’ tab โ†’ workspace โ†’ window from an agent paneโ€™s block id.
run_service_call ๐Ÿ”’
Dispatch a service call and broadcast any resulting WaveObjUpdates to the event bus โ€” the shared core of handle_service. Factored out so the typed first-class agent-API verbs (e.g. /api/v1/window/name) get byte-identical persistence + broadcast to a raw /agentmux/service call without re-implementing it. See SPEC_AGENT_API_FIRST_CLASS_SURFACE_2026_06_17.md.
schedule_agent_zoom_mirror ๐Ÿ”’
Debounced trailing mirror of an agent blockโ€™s term:zoom into the per-agent ui:zoom content blob. zoom = Some(z) upserts; zoom = None (term:zoom reset to null / 1.0) deletes the row so a default agent persists nothing.
setup_torn_off_block_layout ๐Ÿ”’
Phase E.5.5 โ€” set up the layout tree for a tab that just received its first block via the TearOffBlock saga. Called from the TearOffBlock RPC handler after the sagaโ€™s reducer-state portion (CreateTab + MoveBlock) completes. Mirrors the layout-rootnode
update_object ๐Ÿ”’
Update a wave object by replacing it wholesale in the store. The incoming value must have otype and oid fields. Matches Goโ€™s ObjectService.UpdateObject behavior. Returns (otype, oid, updated_value_with_new_version) on success.
update_object_meta ๐Ÿ”’
Update object meta by oref string. Merges meta into existing object.
workspace_id_for_tab ๐Ÿ”’
Find the id of the workspace that owns tab_id (in tabids or pinnedtabids), or None if no workspace references it.
wstore_workspace_exists ๐Ÿ”’
Existence check used by DeleteWorkspace to decide whether to run the wcore delete path. Propagates StoreError so the caller can surface real I/O / corruption failures instead of misclassifying them as โ€œnot foundโ€ (codex P2 #615 carryover โ€” the prior bool return collapsed Err(_) into false, which led to silent successes when SQLite was unhealthy: reducer would delete its own copy and report success while the disk row was never touched).
zoom_mirror_gen ๐Ÿ”’