Module workspace

Source
Expand description

§Workspace Management

Provides a global workspace for managing agentic workflows within a hierarchical file structure. The workspace coordinates concurrent access to workflows and maintains the relationship between workflow nodes and their corresponding file system structure.

§Overview

The workspace serves as a singleton container that manages the active workflow and its associated file system paths. It implements a multi-version concurrency control (MVCC) pattern where:

  • Non-blocking reads: Multiple readers can access workflow snapshots concurrently
  • Atomic writes: Writers operate on isolated copies before publishing changes
  • Global coordination: Centralized management of workflow file operations

§Architecture

The workspace maintains:

  • A single global Workflow instance representing the current state
  • Filesystem path mappings for workflow nodes and their journal files
  • Concurrency-safe access patterns using Arc<RwLock>

§File Structure

Workflows are stored in a hierarchical directory structure where each node corresponds to a workflow file with its own version history:

workspace.aim     # Root workspace workflow
workspace.jnl     # Root workspace journal
workspace/
├── parent.aim    # Parent workflow node
├── parent.jnl    # Parent journal
├── parent/
│   ├── child.aim # Child workflow node
│   ├── child.jnl # Child journal
│   ├── sibling.aim
│   └── sibling.jnl
├── uncle.aim
└── uncle.jnl

§Examples

use std::path::Path;
use aimx::workspace::{load_workspace, get_workspace, create_path, add_node_rule};
use aimx::Reference;

// Load a workspace from a file
// load_workspace(Path::new("my_workspace.aim")).unwrap();

// Get a read-only snapshot of the current workspace
let workflow = get_workspace();
let rule_count = workflow.rule_count();

// Create a path for a workflow reference
let reference = Reference::new("my_node");
// let path = create_path(&reference).unwrap();

// Add a new node rule to the workspace
// add_node_rule("new_node").unwrap();

Functions§

add_node_rule
Adds a new Node Rule to the workspace, creating the necessary file structure.
create_path
Creates a filesystem path for a workflow reference.
delete_node_rule
Deletes a Node Rule and its associated files and directory structure.
get_workspace
Returns a read-only snapshot of the current workspace.
load_workspace
Loads a workspace file from disk.
rename_node_rule
Renames a Node Rule, updating its associated files and directory structure.