/prometheus-skill-pack:actor-modelfrom prometheus-skill-pack
Tokio-native actor model pattern for Prometheus AGS projects. Implements actors as tokio tasks communicating via mpsc channels with a typed message enum, enabling safe concurrent state management without shared locks. Used in UAR session management, pk-librarian event broadcasting, and parking-lot scheduler design. Use when a component needs to own state exclusively while serving concurrent callers.
Ships in prometheus-skill-pack. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
An actor is a tokio task that owns its state exclusively. External code communicates
with the actor through typed messages over an mpsc channel. This eliminates the
need for Arc<Mutex<T>> on complex stateful objects.
use tokio::sync::{mpsc, oneshot};
// 1. Define the message enum — each variant carries its reply channel
pub enum LibrarianMessage {
Compile {
raw: RawDoc,
reply: oneshot::Sender<anyhow::Result<WikiEntry>>,
},
Lint {
reply: oneshot::Sender<Vec<LintReport>>,
},
Focus {
topic: String,
reply: oneshot::Sender<String>,
},
Shutdown,
}
// 2. Define the actor handle — the public API
#[derive(Clone)]
pub struct LibrarianHandle {
tx: mpsc::Sender<LibrarianMessage>,
}
impl LibrarianHandle {
pub async fn compile(&self, raw: RawDoc) -> anyhow::Result<WikiEntry> {
let (reply_tx, reply_rx) = oneshot::channel();
self.tx
.send(LibrarianMessage::Compile { raw, reply: reply_tx })
.await
.map_err(|_| anyhow::anyhow!("librarian actor shut down"))?;
reply_rx.await.map_err(|_| anyhow::anyhow!("librarian did not reply"))?
}
pub async fn shutdown(&self) {
let _ = self.tx.send(LibrarianMessage::Shutdown).await;
}
}
// 3. Define the actor struct — owns its private state
struct LibrarianActor {
store: MarkdownStore,
model_router: ModelRouter,
event_tx: tokio::sync::broadcast::Sender<LibrarianEvent>,
}
impl LibrarianActor {
async fn run(mut self, mut rx: mpsc::Receiver<LibrarianMessage>) {
while let Some(msg) = rx.recv().await {
match msg {
LibrarianMessage::Compile { raw, reply } => {
let result = self.compile_inner(raw).await;
let _ = reply.send(result); // ignore if caller dropped
}
LibrarianMessage::Lint { reply } => {
let reports = self.lint_inner().await;
let _ = reply.send(reports);
}
LibrarianMessage::Focus { topic, reply } => {
let focus = self.focus_inner(&topic).await;
let _ = reply.send(focus);
}
LibrarianMessage::Shutdown => break,
}
}
tracing::info!("LibrarianActor shutting down");
}
async fn compile_inner(&mut self, raw: RawDoc) -> anyhow::Result<WikiEntry> {
// State mutation is safe — we own `self` exclusively
let entry = self.model_router.compile(&raw).await?;
self.store.upsert(&entry).await?;
let _ = self.event_tx.send(LibrarianEvent::Compiled {
entry_id: entry.id.clone(),
});
Ok(entry)
}
}
// 4. Spawn and return the handle
pub fn spawn_librarian(
store: MarkdownStore,
model_router: ModelRouter,
event_tx: tokio::sync::broadcast::Sender<LibrarianEvent>,
buffer: usize,
) -> LibrarianHandle {
let (tx, rx) = mpsc::channel(buffer);
let actor = LibrarianActor { store, model_router, event_tx };
tokio::spawn(actor.run(rx));
LibrarianHandle { tx }
}
For actors that must restart on failure, use a supervision loop:
pub async fn supervise_librarian(
make_actor: impl Fn() -> LibrarianActor + Send + 'static,
tx: mpsc::Sender<LibrarianMessage>,
mut rx: mpsc::Receiver<LibrarianMessage>,
) {
loop {
let actor = make_actor();
let result = tokio::spawn(actor.run_until_panic(/* ... */)).await;
match result {
Ok(()) => break, // clean shutdown
Err(e) => {
tracing::error!(error = ?e, "actor panicked, restarting in 1s");
tokio::time::sleep(Duration::from_secs(1)).await;
}
}
}
}
| Situation | Use |
|---|---|
| Simple data read/write, no logic | Arc<RwLock<T>> |
| Complex stateful logic with many operations | Actor pattern |
| State must be mutated in response to async I/O | Actor pattern |
| Multiple structs sharing the same data | Arc<RwLock<T>> |
| Need to serialize access to external resource | Actor pattern |
The UAR's parking-lot scheduler is an actor: it owns the job queue exclusively,
processes submissions via mpsc, and emits JobEvents on a broadcast channel.
The scheduler never shares its queue with Arc<Mutex<_>>.
reply.send() and then panicking on the error — use let _ = reply.send(...)reply sender beyond the handler — reply immediately or it leaksArc<Mutex<>> when actor pattern is cleanerunwrap() — all panics escape the task and kill the actor silentlyWhat SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub prometheus-ags/prometheus-skill-system --plugin prometheus-skill-pack218 skills in this plugin
/adversarial-reviewIsolated, cross-model adversarial review of KBD artifacts and change diffs. Dispatches a fresh-context LLM judge over an OpenAI-compatible REST gateway (openai-proxy or `liter-llm api`) with an explicit mandate to find problems — the model that produced an artifact or change is never the model that reviews it. Runs as a pipeline stage inside kbd-assess/analyze/plan (artifact mode) and kbd-execute's single phase-boundary QA step (diff mode, once over the whole phase diff). Findings are severity-bucketed (CRITICAL/WARNING/SUGGESTION) and the judge's own report is screened by sycophancy-correction before it is surfaced.
/agent-team-creatorCreate, revise, package, and deploy agent-team definitions with staged questions and native exports for UAR, Codex, Claude Code, Copilot, Kimi Code, MiniMax CLI, OpenCode and DeepSeek. Use for team definition and catalog lifecycle; use agent-team-manage for active runtime task state./agent-team-handoffPrepare and accept a durable handoff between agent roles or coding harnesses using task context, Git identity, evidence and memory references. Use when work must continue in another harness or agent; use agent-team-manage for ordinary same-owner task updates. Do not use for ordinary same-owner task updates (see agent-team-manage).Other plugins' skills for the same job
2 plugins in one repository ship this exact skill · first indexed Nov 27, 2026