F019: List Guardrails Endpoint
Context
Section titled “Context”Agents currently check guardrails blindly using checkGuardrails (or check in CLI). They do not know which rules are active or what the specific criteria are without reading the raw YAML files on the server (which they might not have access to).
Requirement
Section titled “Requirement”Expose an API endpoint to list all active guardrails loaded by the CSTP server.
Specification
Section titled “Specification”1. JSON-RPC Method
Section titled “1. JSON-RPC Method”Method: cstp.listGuardrails
Params:
scope(optional, string): Filter by project/scope. If provided, only returns guardrails that apply to this scope (or global ones).
Returns:
{ "guardrails": [ { "id": "no-high-stakes-low-confidence", "description": "Prevent high-stakes actions without high confidence", "action": "block", "scope": [], # Empty = global "conditions": [ {"field": "stakes", "operator": "eq", "value": "high"}, {"field": "confidence", "operator": "lt", "value": 0.5} ], "requirements": [] } ], "count": 1}2. Python Service Layer
Section titled “2. Python Service Layer”Add list_guardrails function to guardrails_service.py:
def list_guardrails(scope: str | None = None) -> list[dict[str, Any]]: """List active guardrails, optionally filtered by scope."""3. CLI Command
Section titled “3. CLI Command”Add list-guardrails command to cstp.py:
uv run scripts/cstp.py list-guardrails# Output:# ACTIVE GUARDRAILS (5):# - no-high-stakes-low-confidence (block): Prevent high-stakes actions...# - require-code-review (block): Production code requires review...Security
Section titled “Security”- Read-only endpoint.
- Available to all authenticated agents.