1
0
* polish: streamline nav, extract inline styles, improve tablet UX

- Restructure desktop nav from 8+ flat links + overflow dropdown into
  5 grouped dropdowns (Core, Agents, Intel, System, More) matching
  the mobile menu structure to reduce decision fatigue
- Extract all inline styles from mission_control.html and base.html
  notification elements into mission-control.css with semantic classes
- Replace JS-built innerHTML with secure DOM construction in
  notification loader and chat history
- Add CONNECTING state to connection indicator (amber) instead of
  showing OFFLINE before WebSocket connects
- Add tablet breakpoint (1024px) with larger touch targets for
  Apple Pencil / stylus use and safe-area padding for iPad toolbar
- Add active-link highlighting in desktop dropdown menus
- Rename "Mission Control" page title to "System Overview" to
  disambiguate from the chat home page
- Add "Home — Timmy Time" page title to index.html

https://claude.ai/code/session_015uPUoKyYa8M2UAcyk5Gt6h

* fix(security): move auth-gate credentials to environment variables

Hardcoded username, password, and HMAC secret in auth-gate.py replaced
with os.environ lookups. Startup now refuses to run if any variable is
unset. Added AUTH_GATE_SECRET/USER/PASS to .env.example.

https://claude.ai/code/session_015uPUoKyYa8M2UAcyk5Gt6h

* refactor(tooling): migrate from black+isort+bandit to ruff

Replace three separate linting/formatting tools with a single ruff
invocation. Updates tox.ini (lint, format, pre-push, pre-commit envs),
.pre-commit-config.yaml, and CI workflow. Fixes all ruff errors
including unused imports, missing raise-from, and undefined names.
Ruff config maps existing bandit skips to equivalent S-rules.

https://claude.ai/code/session_015uPUoKyYa8M2UAcyk5Gt6h

---------

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Alexander Whitestone
2026-03-11 12:23:35 -04:00
committed by GitHub
parent 708c8a2477
commit 9d78eb31d1
149 changed files with 884 additions and 962 deletions

View File

@@ -12,7 +12,6 @@ No cloud by default — tries local first, falls back through configured options
import logging
from dataclasses import dataclass, field
from enum import Enum, auto
from typing import Optional
from config import settings
@@ -278,7 +277,7 @@ class ModelInfo:
capabilities: set[ModelCapability] = field(default_factory=set)
is_available: bool = False
is_pulled: bool = False
size_mb: Optional[int] = None
size_mb: int | None = None
description: str = ""
def supports(self, capability: ModelCapability) -> bool:
@@ -296,7 +295,7 @@ class MultiModalManager:
4. Routes requests to appropriate models based on content type
"""
def __init__(self, ollama_url: Optional[str] = None) -> None:
def __init__(self, ollama_url: str | None = None) -> None:
self.ollama_url = ollama_url or settings.ollama_url
self._available_models: dict[str, ModelInfo] = {}
self._fallback_chains: dict[ModelCapability, list[str]] = dict(DEFAULT_FALLBACK_CHAINS)
@@ -366,8 +365,8 @@ class MultiModalManager:
return [info for info in self._available_models.values() if capability in info.capabilities]
def get_best_model_for(
self, capability: ModelCapability, preferred_model: Optional[str] = None
) -> Optional[str]:
self, capability: ModelCapability, preferred_model: str | None = None
) -> str | None:
"""Get the best available model for a specific capability.
Args:
@@ -407,7 +406,7 @@ class MultiModalManager:
def pull_model_with_fallback(
self,
primary_model: str,
capability: Optional[ModelCapability] = None,
capability: ModelCapability | None = None,
auto_pull: bool = True,
) -> tuple[str, bool]:
"""Pull a model with automatic fallback if unavailable.
@@ -505,7 +504,7 @@ class MultiModalManager:
def get_model_for_content(
self,
content_type: str, # "text", "image", "audio", "multimodal"
preferred_model: Optional[str] = None,
preferred_model: str | None = None,
) -> tuple[str, bool]:
"""Get appropriate model based on content type.
@@ -543,7 +542,7 @@ class MultiModalManager:
# Module-level singleton
_multimodal_manager: Optional[MultiModalManager] = None
_multimodal_manager: MultiModalManager | None = None
def get_multimodal_manager() -> MultiModalManager:
@@ -555,15 +554,15 @@ def get_multimodal_manager() -> MultiModalManager:
def get_model_for_capability(
capability: ModelCapability, preferred_model: Optional[str] = None
) -> Optional[str]:
capability: ModelCapability, preferred_model: str | None = None
) -> str | None:
"""Convenience function to get best model for a capability."""
return get_multimodal_manager().get_best_model_for(capability, preferred_model)
def pull_model_with_fallback(
primary_model: str,
capability: Optional[ModelCapability] = None,
capability: ModelCapability | None = None,
auto_pull: bool = True,
) -> tuple[str, bool]:
"""Convenience function to pull model with fallback."""

View File

@@ -11,20 +11,17 @@ model roles (student, teacher, judge/PRM) run on dedicated resources.
import logging
import sqlite3
import threading
from dataclasses import dataclass, field
from datetime import datetime, timezone
from enum import Enum
from dataclasses import dataclass
from datetime import UTC, datetime
from enum import StrEnum
from pathlib import Path
from typing import Optional
from config import settings
logger = logging.getLogger(__name__)
DB_PATH = Path("data/swarm.db")
class ModelFormat(str, Enum):
class ModelFormat(StrEnum):
"""Supported model weight formats."""
GGUF = "gguf" # Ollama-compatible quantised weights
@@ -33,7 +30,7 @@ class ModelFormat(str, Enum):
OLLAMA = "ollama" # Already loaded in Ollama by name
class ModelRole(str, Enum):
class ModelRole(StrEnum):
"""Role a model can play in the system (OpenClaw-RL style)."""
GENERAL = "general" # Default agent inference
@@ -60,7 +57,7 @@ class CustomModel:
def __post_init__(self):
if not self.registered_at:
self.registered_at = datetime.now(timezone.utc).isoformat()
self.registered_at = datetime.now(UTC).isoformat()
def _get_conn() -> sqlite3.Connection:
@@ -178,11 +175,11 @@ class ModelRegistry:
logger.info("Unregistered model: %s", name)
return True
def get(self, name: str) -> Optional[CustomModel]:
def get(self, name: str) -> CustomModel | None:
"""Look up a model by name."""
return self._models.get(name)
def list_models(self, role: Optional[ModelRole] = None) -> list[CustomModel]:
def list_models(self, role: ModelRole | None = None) -> list[CustomModel]:
"""List all registered models, optionally filtered by role."""
models = list(self._models.values())
if role is not None:
@@ -212,7 +209,7 @@ class ModelRegistry:
if model_name not in self._models:
return False
with self._lock:
now = datetime.now(timezone.utc).isoformat()
now = datetime.now(UTC).isoformat()
conn = _get_conn()
conn.execute(
"""
@@ -243,7 +240,7 @@ class ModelRegistry:
del self._agent_assignments[agent_id]
return True
def get_agent_model(self, agent_id: str) -> Optional[CustomModel]:
def get_agent_model(self, agent_id: str) -> CustomModel | None:
"""Get the model assigned to an agent, or None for default."""
model_name = self._agent_assignments.get(agent_id)
if model_name:
@@ -256,13 +253,13 @@ class ModelRegistry:
# ── Role-based lookups ─────────────────────────────────────────────────
def get_reward_model(self) -> Optional[CustomModel]:
def get_reward_model(self) -> CustomModel | None:
"""Get the active reward/PRM model, if any."""
reward_models = self.list_models(role=ModelRole.REWARD)
active = [m for m in reward_models if m.active]
return active[0] if active else None
def get_teacher_model(self) -> Optional[CustomModel]:
def get_teacher_model(self) -> CustomModel | None:
"""Get the active teacher model for distillation."""
teacher_models = self.list_models(role=ModelRole.TEACHER)
active = [m for m in teacher_models if m.active]