Stage 6 of the realism migration. User-class file bodies (note, todo, draft, script) optionally get LLM-authored content; system classes (cron / daemon logs, /tmp caches) stay template-only because formulaic *is* the right look for them. New surface: - realism.llm.circuit.LLMCircuitBreaker — process-local sliding-window breaker. 3 consecutive failures trip open; 60s cooldown to half-open; half-open success closes, failure re-opens. Protects the orchestrator tick from sustained Ollama wedges (per-call timeout already covers one-shot hangs). - realism.prompts._style — em-dash suppression lifted from the email prompt. Persona.uses_llms_heavily opts out per the feedback_em_dash_llm_tell.md memory. Includes strip_em_dashes belt-and-braces sub for output that slipped past the prompt rule. - realism.prompts.filebody — class-conditioned prompts (note / todo / draft / script) with persona context, language pinning, output shape rule. - realism.bodies.make_body_with_llm — async wrapper around make_body that calls the LLM when one is provided AND the breaker allows. Falls back to template on timeout / error / empty / system-class. Wiring: - scheduler.pick_file accepts optional llm + llm_breaker + llm_timeout. When the planner picks a create action and the content_class is a user-class, the body_hint is replaced with the LLM-authored body (or falls back to the deterministic body_hint). - orchestrator.worker constructs get_llm() at startup gated by DECNET_REALISM_LLM env var (any non-empty value enables; empty / "off" / "none" / "0" disables). Passes llm + breaker through every tick. - decnet orchestrate gains --llm/--no-llm flag overriding the env var.
56 lines
1.8 KiB
Python
56 lines
1.8 KiB
Python
from __future__ import annotations
|
|
|
|
from typing import Optional
|
|
|
|
import typer
|
|
|
|
from . import utils as _utils
|
|
from .utils import console, log
|
|
|
|
|
|
def register(app: typer.Typer) -> None:
|
|
@app.command(name="orchestrate")
|
|
def orchestrate_cmd(
|
|
interval: int = typer.Option(
|
|
60, "--interval", "-i",
|
|
help="Seconds between synthetic activity ticks",
|
|
),
|
|
daemon: bool = typer.Option(
|
|
False, "--daemon", "-d",
|
|
help="Detach to background as a daemon process",
|
|
),
|
|
llm: Optional[bool] = typer.Option(
|
|
None, "--llm/--no-llm",
|
|
help=(
|
|
"Enable / disable LLM enrichment of user-class file "
|
|
"bodies. Default reads $DECNET_REALISM_LLM (any "
|
|
"non-empty value enables; 'off' / unset disables)."
|
|
),
|
|
),
|
|
) -> None:
|
|
"""Inject synthetic life (inter-decky traffic + file ops + email) into the fleet."""
|
|
import asyncio
|
|
from decnet.orchestrator import orchestrator_worker
|
|
from decnet.web.dependencies import repo
|
|
|
|
if daemon:
|
|
log.info("orchestrator daemonizing interval=%d", interval)
|
|
_utils._daemonize()
|
|
|
|
log.info(
|
|
"orchestrator starting interval=%d llm=%s",
|
|
interval, "default" if llm is None else ("on" if llm else "off"),
|
|
)
|
|
console.print(
|
|
f"[bold cyan]Orchestrator starting[/] (interval: {interval}s)"
|
|
)
|
|
|
|
async def _run() -> None:
|
|
await repo.initialize()
|
|
await orchestrator_worker(repo, interval=interval, llm_enabled=llm)
|
|
|
|
try:
|
|
asyncio.run(_run())
|
|
except KeyboardInterrupt:
|
|
console.print("\n[yellow]Orchestrator stopped.[/]")
|