Skip to content

fix: models module hardening#705

Merged
Muizzkolapo merged 2 commits into
mainfrom
fix/models-hardening
Jun 19, 2026
Merged

fix: models module hardening#705
Muizzkolapo merged 2 commits into
mainfrom
fix/models-hardening

Conversation

@Muizzkolapo

Copy link
Copy Markdown
Owner

Summary

Models module hardening review (Clone 6). All findings from hardening/reviews/models-review.md addressed.

Fix #1 — Wrong FieldSource for input fields (P1)

workflow/schema_service.py tagged every input field as FieldSource.TOOL_OUTPUT, but that value describes how an output is produced. Inputs now use a new FieldSource.INPUT member, which honestly says "this is consumed, not produced here." Renderers ignore .source on inputs today, but future consumers of input_field.source will no longer get the wrong answer.

Fix #2FieldInfo.to_dict() asymmetric key (P1)

field_type (attribute) ↔ "type" (dict key) blocked round-trip:
FieldInfo(**d) raised TypeError. The dict key is now "field_type",
matching the attribute, and FieldInfo.from_dict() round-trips
f == FieldInfo.from_dict(f.to_dict()). No external consumer asserts the
prior "type" key — verified via repo grep.

Fix #3ActionKind.SEED documentation (P2)

SEED is valid in user YAML (Pydantic accepts kind: seed) but the
runtime data-flow graph never assigns DataFlowNode.agent_kind = ActionKind.SEED — seed data is wired through the "seed" prompt-context
namespace. Documented in ARCHITECTURE.md so future readers don't
mistake it for a graph-time kind. Removing SEED outright would break
config validation.

Fix #4 — Re-export shim (P2)

The noqa: F401 on from agent_actions.config.schema import ActionKind
is replaced with an explicit __all__ block listing the four public
symbols. The re-export is intentional and now declared as such.

Fix #6 — Stale test docstrings (P3)

TestActionKind / TestFieldSource docstrings now match the actual
member counts (5 and 5 after adding INPUT).

Verification

  • ruff format --check agent_actions tests — 955 files formatted
  • ruff check on touched files — clean (pre-existing F601 in test_delta_storage.py untouched, outside scope)
  • pytest tests/ — 7455 passed, 2 skipped (1 unrelated pre-existing failure in test_delta_storage.py about stderr capture)
  • pytest tests/unit/models/ — 45 passed (includes new test_to_dict_round_trip_via_from_dict and test_from_dict_uses_defaults_for_missing_optional_keys)
  • Pi consensus review: 4/5 YES, 1 reviewer errored (not NO)
  • Smoke test: unrelated Ollama Cloud rate-limit failure (no LLM/runtime code touched in this diff)

…ialization

- FieldSource.INPUT replaces FieldSource.TOOL_OUTPUT for action input fields.
  TOOL_OUTPUT describes output provenance; tagging inputs with it silently
  produced wrong semantics for any future consumer of input_field.source.

- FieldInfo.to_dict() now emits "field_type" matching the dataclass attribute,
  and adds FieldInfo.from_dict() so the serialization round-trips. The prior
  "type" key broke FieldInfo(**d) reconstruction.

- ActionKind re-export is now declared via __all__ instead of a noqa F401
  shim, making the public surface explicit.

- ARCHITECTURE.md documents that ActionKind.SEED is config-only (Pydantic
  validates "kind: seed", but DataFlowNode.agent_kind never carries SEED;
  seed data is wired via the "seed" prompt-context namespace).

- Tests cover the new round-trip path and the updated enum count.
Code-review findings on PR #705. The previous commit renamed the
FieldInfo.to_dict() wire key from "type" to "field_type" to achieve
serialization symmetry, but the docs frontend reads f.type from
catalog.json (tooling/docs/frontend/lib/transformers.ts:143,
catalog-client.ts:89, actions-screen.tsx:577). The shipped frontend
bundle in tooling/docs/frontend/out/ — which CLAUDE.md forbids modifying
— also reads the old key. The rename was a wire-format break.

- Restore "type" as the to_dict() wire key. The dataclass attribute
  stays field_type to avoid shadowing the builtin; from_dict() now
  translates "type" → field_type on read, so round-trip still holds.
- Lock the contract with test_to_dict_wire_key_is_type_not_field_type.
- Fix sibling pattern in tests/cli/renderers/test_schema_renderer.py:
  input_fields constructed with FieldSource.TOOL_OUTPUT now use
  FieldSource.INPUT, matching the production fix.
- Add regression: test_tool_action_input_fields_use_input_source pins
  WorkflowSchemaService.get_action_schema(...) to emit FieldSource.INPUT
  on tool input_fields end-to-end.
- ARCHITECTURE.md now documents the attribute-vs-wire asymmetry as the
  reason for the from_dict() translation.
@Muizzkolapo Muizzkolapo merged commit ff64040 into main Jun 19, 2026
5 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 19, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant