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
18 changes: 12 additions & 6 deletions src/agent_comms/execution/native_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,17 @@
from abc import ABC, abstractmethod
from collections.abc import AsyncIterator, Callable, Iterator, Mapping, Sequence
from contextlib import AbstractAsyncContextManager, asynccontextmanager
from dataclasses import dataclass, replace
from dataclasses import dataclass
from functools import reduce
from pathlib import Path
from typing import TYPE_CHECKING, ClassVar
from typing import TYPE_CHECKING, ClassVar, Self

from agent_comms.coordination.errors import IdentityConflict
from agent_comms.execution.context_sizes import ContextSizes
from agent_comms.execution.launch_runtime import LaunchRuntime
from agent_comms.execution.pi_vocabulary import NoThinkingOverride, ThinkingChoice, ThinkingLevel
from agent_comms.nominal.declared_family import DeclaredFamily
from agent_comms.nominal.field_codec import FieldCodec, NullMember, SingleFieldValue, SubclassUnion
from agent_comms.team.rule_deal import OffDealMode, UndealtRecord
from agent_comms.transport.native_tool_mode import NativeToolMode

if TYPE_CHECKING:
Expand Down Expand Up @@ -196,6 +195,13 @@ async def slot_turn(
TurnHost.here = ClientHost()


class UndealtRuleDeal(ABC):
"""A session's undealt rule-gate record, owning how it disables its own mode."""

@abstractmethod
def disabled(self) -> Self: ...


class ModelProvider(DeclaredFamily, affix="Provider"):
"""Provider declarations own the native extensions and the action space their models
require."""
Expand All @@ -222,7 +228,7 @@ def native_tool_mode(cls, mode: NativeToolMode, owner: CodingToolOwner) -> Nativ
return mode

@classmethod
def undealt(cls, record: UndealtRecord) -> UndealtRecord:
def undealt[Record: UndealtRuleDeal](cls, record: Record) -> Record:
"""The rule-gate settings a never-dealt thread on this provider starts from."""
return record

Expand Down Expand Up @@ -329,11 +335,11 @@ def native_tool_mode(cls, mode: NativeToolMode, owner: CodingToolOwner) -> Nativ
return ContextLanguageModelMode(owner)

@classmethod
def undealt(cls, record: UndealtRecord) -> UndealtRecord:
def undealt[Record: UndealtRuleDeal](cls, record: Record) -> Record:
"""No papers, rules or audit by default (Tristan, 2026-11-20): the deal is context the
checkpoint never saw and its window cannot hold, and its audit is not its protocol."""

return replace(record, mode=OffDealMode)
return record.disabled()

# The conversations' recorded contexts and the slot's holder: durable state, outside the
# bus root, which is carried between bus versions by its own roster.
Expand Down
8 changes: 1 addition & 7 deletions src/agent_comms/planning/goal_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from agent_comms.planning.goal_scope import GoalScope
from agent_comms.planning.goals import GoalDeclaration, NoGoal
from agent_comms.planning.recorded_goal_revision import RecordedGoalRevision, RevisionKind
from agent_comms.registry.registry_privacy import PrivateRegistry
from agent_comms.storage.locked_store import DurableFile
from agent_comms.storage.store_files import AtomicFile
from agent_comms.storage.typed_table import (
Expand Down Expand Up @@ -224,13 +223,8 @@ def _transaction(self) -> Iterator[GoalHistoryTransaction]:

def _sync_visible_registry(self) -> None:
"""Adopt a visible post-crash registry value before attesting an intent."""
targets = [self.registry_path]
guard = PrivateRegistry.path_in(self.registry_path.parent)
if guard.exists():
targets.append(guard)
try:
for target in targets:
AtomicFile(target).sync()
AtomicFile(self.registry_path).sync()
except OSError as error:
raise GoalHistoryError("Cannot sync visible goal authority.") from error

Expand Down
6 changes: 5 additions & 1 deletion src/agent_comms/team/rule_deal.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

from agent_comms.execution.compaction_redeal import CompactionRedeal
from agent_comms.execution.context_reading import ContextUsage
from agent_comms.execution.native_arguments import UndealtRuleDeal
from agent_comms.nominal.configuration_record import ConfigurationRecord
from agent_comms.nominal.declared_family import DeclaredFamily
from agent_comms.nominal.field_codec import (
Expand Down Expand Up @@ -841,12 +842,15 @@ def while_supplied(self) -> DealRecord:


@dataclass(frozen=True)
class UndealtRecord(DealRecord):
class UndealtRecord(DealRecord, UndealtRuleDeal):
"""The record of a session with no deal on disk: nothing dealt, nothing due."""

dealt: tuple[Path, ...] = ()
due: AuditDue = AuditDue(())

def disabled(self) -> Self:
return replace(self, mode=OffDealMode)

def for_model(self, provider) -> DealRecord:
"""A session never dealt starts from its model's defaults (ModelProvider.undealt)."""
return provider.undealt(self)
Expand Down
Loading