Documentation for Suggestionbuffer Module¶
SuggestionBuffer
¶
Singleton class that manages the coordination of suggestions from Situational Awareness (SA) agents.
The SuggestionBuffer stores, synchronizes, and tracks command suggestions issued by agents in response to specific node events. It ensures that all expected agents have submitted their input before triggering arbitration. Internally, it maintains buffers for suggestions, synchronization locks, and agent-specific notifications to guarantee consistency in distributed settings.
Main Responsibilities: - Register expected agents for an event and track their completion. - Store and retrieve suggestions for arbitration. - Signal the arbitrator once all expected suggestions have been received. - Support safe concurrent access through async-aware locking mechanisms.
Source code in nebula/core/situationalawareness/awareness/suggestionbuffer.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
|
__init__(arbitrator_notification, verbose)
¶
Initializes the suggestion buffer with thread-safe synchronization.
Source code in nebula/core/situationalawareness/awareness/suggestionbuffer.py
43 44 45 46 47 48 49 50 51 52 53 |
|
get_instance()
classmethod
¶
Obtain SuggestionBuffer instance
Source code in nebula/core/situationalawareness/awareness/suggestionbuffer.py
36 37 38 39 40 41 |
|
get_suggestions(event_type)
async
¶
Retrieve and return all suggestions for a given event type.
Also clears the buffer after reading.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event_type
|
Type[NodeEvent]
|
The event whose suggestions are requested. |
required |
Returns:
Type | Description |
---|---|
list[tuple[SAModuleAgent, SACommand]]
|
list[tuple[SAModuleAgent, SACommand]]: List of (agent, suggestion) pairs. |
Source code in nebula/core/situationalawareness/awareness/suggestionbuffer.py
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
|
notify_all_suggestions_done_for_agent(saa, event_type)
async
¶
Notify that a specific SA agent has completed its suggestion submission for an event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
saa
|
SAModuleAgent
|
The notifying agent. |
required |
event_type
|
Type[NodeEvent]
|
The related event type. |
required |
Source code in nebula/core/situationalawareness/awareness/suggestionbuffer.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
|
register_event_agents(event_type, agent)
async
¶
Register a Situational Awareness (SA) agent as an expected participant for a given event type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event_type
|
Type[NodeEvent]
|
The type of event being registered. |
required |
agent
|
SAModuleAgent
|
The agent expected to submit suggestions for the event. |
required |
Source code in nebula/core/situationalawareness/awareness/suggestionbuffer.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
|
register_suggestion(event_type, agent, suggestion)
async
¶
Register a suggestion issued by a specific SA agent for a given event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event_type
|
Type[NodeEvent]
|
The event type for which the suggestion is made. |
required |
agent
|
SAModuleAgent
|
The agent submitting the suggestion. |
required |
suggestion
|
SACommand
|
The command being suggested. |
required |
Source code in nebula/core/situationalawareness/awareness/suggestionbuffer.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
|
set_event_waited(event_type)
async
¶
Set the event type that the SuggestionBuffer will wait for.
Used to indicate that arbitration should proceed when all suggestions for this event are received.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event_type
|
Type[NodeEvent]
|
The event type to monitor. |
required |
Source code in nebula/core/situationalawareness/awareness/suggestionbuffer.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
|