You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(python): payload_vo_generator + switch output_parser to import-style
Close the cross-port FR-006 gap for Python: a payload-VO generator now
emits typed Pydantic v2 models per template (prompt + output + toolcall),
mirroring what Kotlin / C# / TS already ship. The cross-port doc
(`docs/features/templates-and-payloads.md`) was correctly flagging
"Payload-VO codegen is not yet emitted — consumers pass a dict"; that's
no longer true.
Two changes:
1. **New `payload_vo_generator.py`** — class `PayloadVoGenerator`
following the existing generator interface. Iterates ALL `MetaTemplate`
(prompt + output + toolcall) — no subtype filter, matching the Kotlin
reference (KotlinPayloadGenerator). Resolves `@payloadRef` to its
`object.value` (skips entities and missing refs defensively). Emits one
`<template_name_snake>_payload.py` per template containing the
`<TemplateName>Payload` Pydantic v2 model.
Origin.* resolution mirrors Kotlin:
- `origin.passthrough @from "Entity.field"` → source field's Python type
- `origin.aggregate @agg count` → `int`; `@agg avg` → `float`;
`sum/min/max` → source `@of` field's type
- `origin.collection @via "Parent.rel"` → walks the relationship to the
target → recursive nested-model emission (deduped by FQN per-run) →
`list[<TargetShortName>Payload>]`. Nested payloads land in the same
file as the owning payload so the import is implicit.
2. **`output_parser_generator.py` switched from embedded to import-style**
per its own docstring plan. The emitted module now does
`from .<template_name>_payload import <TemplateName>Payload` and the
parser becomes a thin `parse_<template_name>(text: str) ->
<TemplateName>Payload` wrapping `<TemplateName>Payload.model_validate_json(text)`.
Embedded inline model definitions removed. Module docstring updated to
reflect the new contract (kept the throw-only design note —
Python-ecosystem norm per Pydantic).
Tests: codegen suite 72/72 green (added comprehensive coverage:
prompt + output + toolcall emission, scalar field type mapping,
all three origin subtypes, nested-collection dedupe across templates).
Cross-port conformance suite 109/109 green — no regressions.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0 commit comments