CoolFace
Apppublic

anthonym21/slipstream-governance-openenv

sourceHugging Facebsd-3-clauseupdated 8mo agoView on Hugging Face
0likes
models.py48 linesDownload Raw Back to root
1# Copyright (c) Meta Platforms, Inc. and affiliates.2# All rights reserved.3#4# This source code is licensed under the BSD-style license found in the5# LICENSE file in the root directory of this source tree.6 7"""Data models for the Slipstream Governance Environment."""8 9from __future__ import annotations10 11from typing import Any, Dict, List, Optional12 13from pydantic import Field14 15try:16    # When running with openenv-core installed17    from openenv.core.env_server.types import Action, Observation, State18except ImportError:  # pragma: no cover19    from openenv.core.env_server.types import Action, Observation, State20 21 22class SlipstreamAction(Action):23    """Action for SlipstreamGov: the model's message to send through the governor."""24 25    message: str = Field(..., min_length=1, description="Model output containing a SLIP message")26 27 28class SlipstreamObservation(Observation):29    """Observation returned by the governor after validation + scoring."""30 31    # On reset32    task_prompt: Optional[str] = Field(default=None, description="Prompt for the model (natural-language intent + constraints)")33 34    # On step (evaluation)35    parsed_slip: Optional[str] = Field(default=None, description="Extracted SLIP line (normalized)")36    expected_anchor: Optional[str] = Field(default=None, description="Scenario's expected anchor")37    predicted_anchor: Optional[str] = Field(default=None, description="Anchor parsed from model output")38    arg_overlap: float = Field(default=0.0, ge=0.0, le=1.0, description="Fraction of expected args present in output")39    violations: List[str] = Field(default_factory=list, description="Rule violations detected by the governor")40    metrics: Dict[str, Any] = Field(default_factory=dict, description="Extra metrics for debugging / dashboards")41 42 43class SlipstreamState(State):44    """Environment state."""45 46    scenario_id: Optional[int] = Field(default=None, description="Current scenario id")47    attack: bool = Field(default=False, description="Whether this episode included a secret-injection attack")48