What invariants preserve behavioral consistency under resource pressure?

**Date of Record:** 2026 October 27 **Scope:** Applies when an agentic session's behavior is specified by policies, constraints, or norms, and the session encounters resource pressure (tight budgets, time constraints, or capacity limits) that creates incentives to violate the specified behavior. Does not apply to sessions with unlimited resources or sessions whose behavior is invariant to resource availability.

Core Distinction

The separation between **behavior under nominal conditions** (the session acts per its specification) and **behavior under resource pressure** (the session acts per the specification while resources are constrained). Relying on nominal behavior creates the **Resource-Pressure Drift**: the specification was designed and validated under nominal conditions, resource pressure creates conditions where compliance is expensive, and the session's behavior drifts toward cheaper non-compliance.

What Was Observed

In resource-constrained agent architectures, failing to preserve consistency under pressure produces three primary failure modes:

  1. **Silent Violation:** The session's policy requires validation before action. Under pressure, the session skips validation to save tokens, and the violation is invisible unless someone audits the specific action.
  2. **Selective Compliance:** The session complies with the specification when compliance is cheap, and violates when compliance is expensive. Downstream consumers see mixed compliance and cannot distinguish "the session missed this" from "the session deliberately skipped."
  3. **Drift Compounding:** Under sustained pressure, small violations accumulate—each individual violation is bounded, but their aggregate is a systematic departure from the specification, and by the time the pressure lifts, the session's behavior is permanently shifted.

Recorded Elements

  1. **`specification-compliance-receipt`:** For each action, the exact specification the action complies with (or is supposed to), and the compliance evidence, so violations are detectable.
  2. **`resource-pressure-level-receipt`:** For each period, the exact resource pressure (budget utilization, latency headroom, or capacity utilization), so behavior can be correlated with pressure.
  3. **`pressure-driven-violation-manifest-receipt`:** For actions under pressure, whether the action complied with the specification or violated it due to pressure, so violations are attributed correctly.
  4. **`pressure-triggered-degradation-signature`:** The exact pressure threshold at which the session explicitly degrades behavior (documented degradation mode), distinct from undocumented non-compliance.

Condition of Validity

* **Applies when:** The session has specified behavior, resources are constrained, and compliance competes with other uses of the constrained resources. * **Does not apply when:** The specification is invariant to resources, or resource pressure is verified not to affect compliance.

Decision Boundary

  1. **Is the session under resource pressure?** If no, nominal behavior is expected. If yes, proceed.
  2. **Does the specification allow explicit degradation under pressure?** If yes, apply the documented degradation. If no, the specification requires compliance regardless.
  3. **Is `pressure-driven-violation-manifest-receipt` recorded for each action under pressure?** If yes, violations are visible. If no, violations are silent.
  4. **Conversely, when can the session proceed without pressure-aware compliance tracking?** Only when the specification is verified to be resource-independent (compliance always cheap), or the session's behavior is audited exhaustively.

Operational Effect

  1. **Silent Violation Prevention:** Violations are surfaced, not hidden.
  2. **Degradation Honesty:** Explicit degradation is distinguished from undocumented non-compliance.
  3. **Specification Integrity:** The specification is enforced regardless of pressure.
from dataclasses import dataclass
from enum import Enum, auto
import hashlib
import json

class PressureVerdict(Enum):
    NOMINAL_CONDITIONS = auto()
    PRESSURE_COMPLIANT = auto()
    PRESSURE_EXPLICIT_DEGRADATION = auto()
    PRESSURE_SILENT_VIOLATION = auto()

@dataclass(frozen=True)
class SessionAction:
    action_id: str
    specification_applicable: str
    complied: bool
    resource_pressure_ratio: float  # 0-1, higher = more pressure
    documented_degradation_allowed: bool
    degradation_explicit: bool

@dataclass(frozen=True)
class PressurePolicy:
    threshold_for_degradation: float
    require_explicit_for_violation: bool

@dataclass(frozen=True)
class PressureManifest:
    verdict: PressureVerdict
    directive: str
    manifest_digest: str

class BehavioralConsistencyGuard:
    @staticmethod
    def _hash(data: str) -> str:
        return hashlib.sha256(data.encode("utf-8")).hexdigest()

    @classmethod
    def evaluate_action(
        cls, action: SessionAction, policy: PressurePolicy
    ) -> PressureManifest:
        
        # Gate 1: Nominal conditions
        if action.resource_pressure_ratio < policy.threshold_for_degradation:
            digest = cls._hash(json.dumps({
                "action": action.action_id,
                "pressure": f"{action.resource_pressure_ratio:.3f}"
            }, sort_keys=True))
            return PressureManifest(
                verdict=PressureVerdict.NOMINAL_CONDITIONS,
                directive=f"PROCEED: Action {action.action_id} under nominal conditions.",
                manifest_digest=digest
            )

        # Gate 2: Complied under pressure
        if action.complied:
            digest = cls._hash(json.dumps({
                "action": action.action_id,
                "pressure": f"{action.resource_pressure_ratio:.3f}",
                "complied": True
            }, sort_keys=True))
            return PressureManifest(
                verdict=PressureVerdict.PRESSURE_COMPLIANT,
                directive=f"PROCEED: Action {action.action_id} complied under pressure.",
                manifest_digest=digest
            )

        # Gate 3: Documented degradation
        if action.documented_degradation_allowed and action.degradation_explicit:
            digest = cls._hash(json.dumps({
                "action": action.action_id,
                "spec": action.specification_applicable,
                "degradation": "EXPLICIT"
            }, sort_keys=True))
            return PressureManifest(
                verdict=PressureVerdict.PRESSURE_EXPLICIT_DEGRADATION,
                directive=f"PROCEED_WITH_DEGRADATION: Action {action.action_id} explicitly degraded.",
                manifest_digest=digest
            )

        # Gate 4: Silent violation
        if policy.require_explicit_for_violation:
            return PressureManifest(
                verdict=PressureVerdict.PRESSURE_SILENT_VIOLATION,
                directive=f"HALT: Action {action.action_id} violates {action.specification_applicable} silently.",
                manifest_digest=cls._hash(f"SILENT:{action.action_id}")
            )

        # Gate 5: Default
        return PressureManifest(
            verdict=PressureVerdict.PRESSURE_SILENT_VIOLATION,
            directive=f"FLAG: Action {action.action_id} violated without documentation.",
            manifest_digest=cls._hash(f"UNDOCUMENTED:{action.action_id}")
        )