Skip to contents

A security wrapper for AgentState that restricts access based on node_id. Implements "True Privacy" for inter-agent communication.

Value

A `RestrictedState` object.

Public fields

state

AgentState. The underlying global state.

node_id

String. The ID of the currently executing node.

read_only

Logical. If TRUE, set() and update() are blocked.

logger

MessageLog. Audit log for communication.

Methods


Method new()

Initialize RestrictedState

Usage

RestrictedState$new(state, node_id, logger = NULL, read_only = FALSE)

Arguments

state

AgentState object.

node_id

String node ID.

logger

Optional MessageLog object.

read_only

Logical. If TRUE, blocks all write operations. Restricted Get


Method get()

Usage

RestrictedState$get(key, default = NULL)

Arguments

key

String.

default

Default value. Restricted Set


Method set()

Usage

RestrictedState$set(key, value)

Arguments

key

String.

value

Any. Forward Update


Method update()

Usage

RestrictedState$update(updates)

Arguments

updates

List. Send Private Message


Method send_message()

Usage

RestrictedState$send_message(to, content, ...)

Arguments

to

String. Target node ID.

content

Any. Message content.

...

Additional metadata. Receive Private Messages


Method receive_messages()

Usage

RestrictedState$receive_messages()

Returns

List of messages for this node. Clear Own Inbox


Method clear_inbox()

Removes all messages from the node's own inbox. Filtered Get All

Usage

RestrictedState$clear_inbox()


Method get_all()

Usage

RestrictedState$get_all()

Returns

List. All public state variables (no private inboxes).


Method clone()

The objects of this class are cloneable with this method.

Usage

RestrictedState$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

if (FALSE) { # \dontrun{
# 1. Secure state wrapper for a specific node
global_state <- AgentState$new(initial_data = list(x = 1))
node_state <- RestrictedState$new(state = global_state, node_id = "agent_01")

# 2. Inter-agent private messaging (True Privacy)
node_state$send_message(to = "agent_02", content = "Secret instructions")

# 3. Recipient reads their own inbox
recipient_state <- RestrictedState$new(state = global_state, node_id = "agent_02")
messages <- recipient_state$receive_messages()
} # }