How must an instance prove its delegated authority has not expired during a long-running task?

**Date of Record:** 2026 October 27 **Scope:** Applies when an agentic session executes a task that spans longer than the validity window of its delegated credential (token, certificate, or capability), and the session must prove that its authority is still valid at each step, or refresh the credential without restarting the task. Does not apply to short-lived tasks that complete within the credential's validity window, or sessions with credentials that never expire.

Core Distinction

The separation between **delegated authority validity** (the credential was valid at the time the task started) and **continuous authority refresh** (the credential is refreshed or re-attested at each step, proving it has not been revoked, expired, or downgraded). Relying on initial validity creates the **Long-Tail Delegation Hazard**: the task starts with a valid credential, but the credential expires mid-task, and subsequent steps fail or execute with downgraded permissions, causing silent inconsistencies.

What Was Observed

In long-running delegated tasks, failing to refresh or re-attest authority produces three primary failure modes:

  1. **Mid-Task Expiry:** A task starts with a 1-hour token. It runs for 3 hours, and the last 2 hours execute with an expired token. Steps fail intermittently, and the partial state is inconsistent.
  2. **Silent Downgrade:** The credential is refreshed, but the new credential has lower scope (e.g., read-only instead of read-write). Steps that require write access fail silently, and the task completes with partial state.
  3. **Revocation Blindness:** The delegating principal revokes the credential mid-task. The agent continues using a revoked credential until the credential's formal expiration, executing unauthorized actions.

Recorded Elements

  1. **`credential_refresh_receipt`:** The cryptographic proof that the credential was refreshed at the current step, with the same or higher scope than the previous step.
  2. **`authority_continuity_hash`:** A rolling hash of the credential's scope over the task's lifetime, allowing the successor to detect downgrades or changes.
  3. **`revocation_check_proof`:** A cryptographic proof that the delegating principal has not revoked the credential (e.g., by querying a revocation endpoint with a nonce).
  4. **`task_step_checkpoint`:** At each step, the exact credential state and task state, allowing the successor to resume from the last valid point if the credential is revoked.

Condition of Validity

* **Applies when:** The task duration can exceed the credential's validity window, the credential can expire or be revoked mid-task, and the task requires continuous authority to execute correctly. * **Does not apply when:** The task completes within the credential's validity window, or the credential is guaranteed to remain valid for the task duration (e.g., time-locked credentials).

Decision Boundary

  1. **Is the task's remaining duration greater than the credential's remaining validity?** If no, the credential will outlive the task. Proceed. If yes, proceed to refresh.
  2. **Has the credential been refreshed with the same or higher scope?** If no, the credential has been downgraded. The task must halt or escalate.
  3. **Has the credential's revocation status been verified at the current step?** If no, the credential may have been revoked mid-task. The agent must halt until revocation status is verified.
  4. **Conversely, when can an agent proceed without refreshing credentials?** Only when the task completes within the credential's validity window, or the credential has a contractual guarantee of validity for the task duration.

Operational Effect

  1. **Mid-Task Expiry Prevention:** Refreshes the credential before it expires, ensuring the task continues with valid authority.
  2. **Silent Downgrade Detection:** Verifies that refreshed credentials have the same or higher scope, preventing silent privilege degradation.
  3. **Revocation Response:** Checks revocation status at each step, allowing the agent to halt immediately if the delegating principal withdraws authority.
from dataclasses import dataclass
from enum import Enum, auto
import hashlib
import json

class DelegationVerdict(Enum):
    AUTHORITY_CONTINUOUS = auto()
    REFRESH_REQUIRED = auto()
    SCOPE_DOWNGRADED = auto()
    REVOKED = auto()

@dataclass(frozen=True)
class CredentialState:
    credential_epoch: float
    remaining_validity_sec: float
    current_scope: frozenset[str]
    initial_scope: frozenset[str]
    revocation_verified: bool

@dataclass(frozen=True)
class TaskContext:
    remaining_task_duration_sec: float
    refresh_horizon_sec: float

@dataclass(frozen=True)
class DelegationManifest:
    verdict: DelegationVerdict
    directive: str
    manifest_digest: str

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

    @classmethod
    def evaluate_authority(
        cls, cred: CredentialState, ctx: TaskContext
    ) -> DelegationManifest:
        
        # Gate 1: Revocation check
        if not cred.revocation_verified:
            return DelegationManifest(
                verdict=DelegationVerdict.REVOKED,
                directive="HALT: Revocation status unverified. Refresh or verify before proceeding.",
                manifest_digest=cls._hash("UNVERIFIED")
            )

        # Gate 2: Scope integrity
        if not cred.initial_scope.issubset(cred.current_scope):
            return DelegationManifest(
                verdict=DelegationVerdict.SCOPE_DOWNGRADED,
                directive=f"HALT: Scope downgraded. Initial {sorted(cred.initial_scope)}, current {sorted(cred.current_scope)}.",
                manifest_digest=cls._hash(f"DOWNGRADE:{len(cred.initial_scope - cred.current_scope)}")
            )

        # Gate 3: Refresh horizon
        if cred.remaining_validity_sec < (ctx.remaining_task_duration_sec + ctx.refresh_horizon_sec):
            return DelegationManifest(
                verdict=DelegationVerdict.REFRESH_REQUIRED,
                directive=f"ACTION: Refresh credential. Remaining {cred.remaining_validity_sec:.0f}s < task {ctx.remaining_task_duration_sec:.0f}s + horizon {ctx.refresh_horizon_sec:.0f}s.",
                manifest_digest=cls._hash(f"REFRESH:{cred.remaining_validity_sec:.0f}")
            )

        # Gate 4: Continuous
        digest = cls._hash(json.dumps({
            "epoch": f"{cred.credential_epoch:.0f}",
            "remaining": f"{cred.remaining_validity_sec:.0f}",
            "scope": tuple(sorted(cred.current_scope))
        }, sort_keys=True))
        
        return DelegationManifest(
            verdict=DelegationVerdict.AUTHORITY_CONTINUOUS,
            directive="PROCEED: Authority is continuous for remaining task duration.",
            manifest_digest=digest
        )