165 lines
5.3 KiB
Python
165 lines
5.3 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
fleet_milestones.py — Print milestone messages when fleet achievements trigger.
|
|
Refs: timmy-home #557, FLEET-004
|
|
"""
|
|
import json
|
|
import os
|
|
import sys
|
|
from pathlib import Path
|
|
from datetime import datetime
|
|
|
|
STATE_FILE = Path("/var/lib/timmy/milestones.json")
|
|
LOG_FILE = Path("/var/log/timmy/fleet_milestones.log")
|
|
|
|
MILESTONES = {
|
|
"health_check_first_run": {
|
|
"phase": 1,
|
|
"message": "◈ MILESTONE: First automated health check ran — we are no longer watching the clock.",
|
|
},
|
|
"auto_restart_3am": {
|
|
"phase": 2,
|
|
"message": "◈ MILESTONE: A process failed at 3am and restarted itself before anyone woke up.",
|
|
},
|
|
"backup_first_success": {
|
|
"phase": 2,
|
|
"message": "◈ MILESTONE: First automated backup completed — fleet state is no longer ephemeral.",
|
|
},
|
|
"ci_green_main": {
|
|
"phase": 2,
|
|
"message": "◈ MILESTONE: CI pipeline kept main green for 24 hours straight.",
|
|
},
|
|
"pr_auto_merged": {
|
|
"phase": 2,
|
|
"message": "◈ MILESTONE: An agent PR passed review and merged without human hands.",
|
|
},
|
|
"dns_self_healed": {
|
|
"phase": 2,
|
|
"message": "◈ MILESTONE: DNS outage detected and resolved automatically.",
|
|
},
|
|
"runner_self_healed": {
|
|
"phase": 2,
|
|
"message": "◈ MILESTONE: CI runner died and resurrected itself within 60 seconds.",
|
|
},
|
|
"secrets_scan_clean": {
|
|
"phase": 2,
|
|
"message": "◈ MILESTONE: 7 consecutive days with zero leaked secrets detected.",
|
|
},
|
|
"local_inference_first": {
|
|
"phase": 3,
|
|
"message": "◈ MILESTONE: First fully local inference completed — no tokens left the building.",
|
|
},
|
|
"ollama_serving_fleet": {
|
|
"phase": 3,
|
|
"message": "◈ MILESTONE: Ollama serving models to all fleet wizards.",
|
|
},
|
|
"offline_docs_sync": {
|
|
"phase": 3,
|
|
"message": "◈ MILESTONE: Entire documentation tree synchronized without internet.",
|
|
},
|
|
"cross_agent_delegate": {
|
|
"phase": 3,
|
|
"message": "◈ MILESTONE: One wizard delegated a task to another and received a finished result.",
|
|
},
|
|
"backup_verified_restore": {
|
|
"phase": 4,
|
|
"message": "◈ MILESTONE: Backup restored and verified — disaster recovery is real.",
|
|
},
|
|
"vps_bootstrap_under_60": {
|
|
"phase": 4,
|
|
"message": "◈ MILESTONE: New VPS bootstrapped from bare metal in under 60 minutes.",
|
|
},
|
|
"zero_cloud_day": {
|
|
"phase": 4,
|
|
"message": "◈ MILESTONE: 24 hours with zero cloud API calls — total sovereignty achieved.",
|
|
},
|
|
"fleet_orchestrator_active": {
|
|
"phase": 5,
|
|
"message": "◈ MILESTONE: Fleet orchestrator actively balancing load across agents.",
|
|
},
|
|
"cell_isolation_proven": {
|
|
"phase": 5,
|
|
"message": "◈ MILESTONE: Agent cell isolation proven — one crash did not spread.",
|
|
},
|
|
"mission_bus_first": {
|
|
"phase": 5,
|
|
"message": "◈ MILESTONE: First cross-agent mission completed via the mission bus.",
|
|
},
|
|
"resurrection_pool_used": {
|
|
"phase": 5,
|
|
"message": "◈ MILESTONE: A dead wizard was detected and resurrected automatically.",
|
|
},
|
|
"infra_generates_revenue": {
|
|
"phase": 6,
|
|
"message": "◈ MILESTONE: Infrastructure generated its first dollar of revenue.",
|
|
},
|
|
"client_onboarded_unattended": {
|
|
"phase": 6,
|
|
"message": "◈ MILESTONE: Client onboarded without human intervention.",
|
|
},
|
|
"fleet_pays_for_itself": {
|
|
"phase": 6,
|
|
"message": "◈ MILESTONE: Fleet revenue exceeds operational cost — it breathes on its own.",
|
|
},
|
|
}
|
|
|
|
|
|
def load_state() -> dict:
|
|
if STATE_FILE.exists():
|
|
return json.loads(STATE_FILE.read_text())
|
|
return {}
|
|
|
|
|
|
def save_state(state: dict):
|
|
STATE_FILE.parent.mkdir(parents=True, exist_ok=True)
|
|
STATE_FILE.write_text(json.dumps(state, indent=2))
|
|
|
|
|
|
def log(msg: str):
|
|
LOG_FILE.parent.mkdir(parents=True, exist_ok=True)
|
|
entry = f"[{datetime.utcnow().isoformat()}Z] {msg}"
|
|
print(entry)
|
|
with LOG_FILE.open("a") as f:
|
|
f.write(entry + "\n")
|
|
|
|
|
|
def trigger(key: str, dry_run: bool = False):
|
|
if key not in MILESTONES:
|
|
print(f"Unknown milestone: {key}", file=sys.stderr)
|
|
sys.exit(1)
|
|
state = load_state()
|
|
if state.get(key):
|
|
if not dry_run:
|
|
print(f"Milestone {key} already triggered. Skipping.")
|
|
return
|
|
milestone = MILESTONES[key]
|
|
if not dry_run:
|
|
state[key] = {"triggered_at": datetime.utcnow().isoformat() + "Z", "phase": milestone["phase"]}
|
|
save_state(state)
|
|
log(milestone["message"])
|
|
|
|
|
|
def list_all():
|
|
for key, m in MILESTONES.items():
|
|
print(f"{key} (phase {m['phase']}): {m['message']}")
|
|
|
|
|
|
def main():
|
|
import argparse
|
|
parser = argparse.ArgumentParser(description="Fleet milestone tracker")
|
|
parser.add_argument("--trigger", help="Trigger a milestone by key")
|
|
parser.add_argument("--dry-run", action="store_true", help="Show but do not record")
|
|
parser.add_argument("--list", action="store_true", help="List all milestones")
|
|
args = parser.parse_args()
|
|
|
|
if args.list:
|
|
list_all()
|
|
elif args.trigger:
|
|
trigger(args.trigger, dry_run=args.dry_run)
|
|
else:
|
|
parser.print_help()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|