Skip to content

feat: enforce runtime domain invariants#45

Merged
ebarti merged 1 commit into
mainfrom
agent/stack-05-domain-invariants
Jul 10, 2026
Merged

feat: enforce runtime domain invariants#45
ebarti merged 1 commit into
mainfrom
agent/stack-05-domain-invariants

Conversation

@ebarti

@ebarti ebarti commented Jul 10, 2026

Copy link
Copy Markdown
Owner

What

  • reject blank task, session, MCP, tool, artifact, and result identities
  • require positive execution hints and finite non-negative budgets/counts
  • reject ambiguous session start/resume state, duplicate MCP names, and conflicting tool filters
  • canonicalize sequence value fields while rejecting scalar strings
  • add AgentResult.is_success
  • represent unknown Usage and cost as None while preserving reported zero
  • preserve partial provider telemetry without inventing cache counts
  • fix Claude resume result fallback when the SDK omits its session id

Why

Several invalid or ambiguous states were constructible, and missing telemetry was indistinguishable from a real zero.

Root cause

The frozen dataclasses provided immutability but did not own their cross-field invariants, while adapter coercion helpers normalized missing and malformed counters to zero.

Checks

  • 321 passed, 12 skipped
  • independent domain audit completed
  • ruff check src tests
  • mypy
  • uv lock --check
  • wheel and sdist build

Compatibility

This intentionally rejects previously accepted invalid constructor inputs and changes unknown Usage fields from zero to None.

Stack

@ebarti ebarti force-pushed the agent/stack-04-provider-output-validation branch from e43a071 to 54a7f40 Compare July 10, 2026 22:43
Base automatically changed from agent/stack-04-provider-output-validation to main July 10, 2026 22:44
@ebarti ebarti force-pushed the agent/stack-05-domain-invariants branch from d0f2673 to da08b3d Compare July 10, 2026 22:44
@ebarti ebarti marked this pull request as ready for review July 10, 2026 22:44
@ebarti ebarti merged commit 1863b05 into main Jul 10, 2026
11 checks passed
@ebarti ebarti deleted the agent/stack-05-domain-invariants branch July 10, 2026 22:45
ebarti added a commit that referenced this pull request Jul 10, 2026
## What

- adds side-effect-free `TaskSupportReport` preflight for built-in and
third-party runtimes
- keeps `AgentRuntime` migration-compatible through the optional
`TaskSupportProvider` protocol
- reports granular task capability gaps, configured model allow-list
mismatches, and static Antigravity constraints
- makes built-in dispatch consume the same support report used by public
preflight
- adds a machine-readable compatibility manifest tied to
`pyproject.toml` and exact `uv.lock` versions

## Why

Capability booleans and per-adapter rejection branches had drifted
apart. Callers could not discover all incompatible fields before
starting a run, provider-specific rules were delayed until dispatch, and
compatibility ranges/tested runtime binaries existed only as duplicated
prose and package metadata.

## Root cause

Task support was encoded in several imperative adapter paths rather than
one additive preflight contract. An initial implementation also made
`validate_task` mandatory on `AgentRuntime`, which would have broken
existing structural third-party runtimes; this PR uses an optional
extension plus a declared-capability fallback instead.

## Checks

- `ruff check src tests`
- `mypy`
- `pytest -q --cov=agent_runtime_kit --cov-report=term-missing
--cov-fail-under=85` (340 passed, 3 skipped; 90.86%)
- installed SDK contracts: 19 passed
- `uv lock --check`
- `uv build`

## Stack

- Base: #45
- Next: #47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant