Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,20 @@ class ModelDelegationRequest(BaseModel):
default=None,
description="File context for the delegation, if any.",
)
context_pack: str = Field(
default="",
description=(
"Optional assembled context injected ahead of the prompt for context "
"ON/OFF experiments. Empty string means no context pack."
),
)
context_pack_hash: str = Field(
default="",
description=(
"Stable hash of context_pack for projection readback and ROI "
"measurement. Empty string means no context pack was injected."
),
)
correlation_id: UUID = Field(
...,
description="Unique identifier for tracking through the pipeline.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ class ModelTaskDelegatedEvent(BaseModel):
default=None,
description="Raw response received from the delegated model.",
)
context_pack_hash: str = Field(
default="",
description=(
"Stable hash of the context pack injected into the delegated prompt. "
"Empty string means the OFF arm or no context pack."
),
)
pricing_manifest_version: int = Field(
default=0,
ge=0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,19 @@ def test_basic_construction(self) -> None:
r = self._make()
assert r.task_type == "test"

def test_context_pack_hash_defaults_to_off_arm(self) -> None:
r = self._make()
assert r.context_pack == ""
assert r.context_pack_hash == ""

def test_context_pack_hash_is_accepted(self) -> None:
r = self._make(
context_pack="Relevant repo facts.",
context_pack_hash="sha256:abc123",
)
assert r.context_pack == "Relevant repo facts."
assert r.context_pack_hash == "sha256:abc123"

def test_compliance_budget_required_when_schema_key_set(self) -> None:
with pytest.raises(ValueError, match="compliance_budget is required"):
self._make(output_schema_key="some_schema")
Expand Down Expand Up @@ -607,6 +620,18 @@ def test_default_topic(self) -> None:
)
assert event.topic == TASK_DELEGATED_TOPIC_V1
assert event.escalation_count == 0
assert event.context_pack_hash == ""

def test_carries_context_pack_hash(self) -> None:
event = ModelTaskDelegatedEvent(
timestamp="2026-05-26T00:00:00Z",
correlation_id=uuid.uuid4(),
task_type="test",
delegated_to="local_qwen3",
quality_gate_passed=True,
context_pack_hash="sha256:ctx",
)
assert event.context_pack_hash == "sha256:ctx"

def test_rejects_invalid_topic_and_negative_metrics(self) -> None:
with pytest.raises(ValidationError):
Expand Down
Loading