Files
hermes-agent/gateway/hosted_room_task_input.py
TekniumandDavid Dudok de Wit 4afe99baf2 fix(groups): preserve frozen admissions across history cache rebuilds
Salvage the derived-history and frozen-input safeguards from #98072 at fd37e34d, including the later 9a3664a8 admission-preservation repair. Recover canonical input and partially published replies without changing the admitted task or executing again. Keep attachment APIs and execution migration outside this cache-only carve.

Co-authored-by: David Dudok de Wit <5354424+dokterdok@users.noreply.github.com>
2026-09-10 12:41:31 -07:00

25 lines
969 B
Python

"""Bounded immutable input references carried by compacting policy callers."""
from typing import Any
MAX_TASK_INPUT_EVENTS = 128
def validate_task_input(value: Any) -> dict[str, Any]:
if not isinstance(value, dict) or set(value) != {"watermark", "event_seqs"}:
raise ValueError("invalid task input context")
watermark = value["watermark"]
seqs = value["event_seqs"]
if type(watermark) is not int or watermark < 0:
raise ValueError("invalid task input watermark")
if not isinstance(seqs, list) or not 1 <= len(seqs) <= MAX_TASK_INPUT_EVENTS:
raise ValueError("task input context exceeded its bound")
previous = watermark
for seq in seqs:
if type(seq) is not int or not previous < seq <= 2**63 - 1:
raise ValueError(
"task input sequences must be increasing after the watermark"
)
previous = seq
return {"watermark": watermark, "event_seqs": list(seqs)}