mirror of
https://github.com/turnstonelabs/turnstone.git
synced 2026-08-23 04:14:47 -06:00
3ce66960bc
* feat: modular system message composition with admin prompt policies (#267) Replace the monolithic persona+tools block in _init_system_messages() with a modular composition harness (turnstone/prompts/). System messages are now assembled from five typed layers: BASE (persona), ENV (client surface — web/cli/chat), CONTEXT (datetime, timezone, username), TOOLS (usage patterns), and POLICIES (behavioral rules with tool gating). Prompt policies are admin-managed via a new Prompts tab in the Governance group (CRUD with modal forms, tool gating, priority ordering, enable/disable). DB policies override file-based defaults by name; file-based policies serve as deployment defaults. Migration 031 adds the prompt_policies table. ClientType is threaded end-to-end from channel adapters through the SDK, HTTP API, WorkstreamManager, and session factory to ChatSession. Discord sessions now receive chat-optimized formatting (no tables, no Mermaid, concise output) instead of the web UI's rich markdown instructions. * fix: address CI failures and Copilot review feedback - Add client_type param to CLI session_factory (mypy protocol match) - Add prompt policy CRUD to PostgreSQL backend (test-postgres CI) - Fix ClientType resolution: compare against enum values, not members - Fix null client_type coercion (body.get returns None, not "") - Use local time with astimezone() instead of UTC with local tz name - Sanitize tool_gate in update endpoint (coerce null to empty string)