da-daken opened a new pull request, #1454:
URL: https://github.com/apache/flink-agents/pull/1454

   Linked issue: #1452
   
   ### Purpose of change
   
   The Java and Python YAML loaders conflated two independent questions: 
whether a resource kind is supported by that loader, and whether a short name 
is a registered alias for that language. The Java branch validated the language 
kind but not the loader capability. Both branches passed an alias miss through 
as a custom fully-qualified class, so a short alias from the other language 
became an invalid delayed class lookup.
   
   This change gives each loader one explicit capability table keyed by 
implementation language and keeps alias lookup separate. It also makes 
alias-table ownership explicit: a short alias registered only for the other 
language is rejected during YAML loading, while a genuine custom 
fully-qualified class still passes through.
   
   Runtime flow:
   
   1. The loader resolves `type`, defaulting to Python.
   2. It checks the resource kind against the loader capability table for that 
language.
   3. It rejects a short alias owned only by the other language.
   4. It resolves a valid alias or passes through a custom class, then builds 
the language-specific descriptor.
   
   Key decisions:
   
   - `CLAZZ_ALIASES` remains an alias table, not a resource-support table. Java 
decision models and external sub-agents have supported descriptors without Java 
short aliases, so deriving support from alias keys would reject valid YAML.
   - External sub-agents are Java-only and remain in the Java capability set; 
Python descriptors for `AGENT` remain rejected.
   - Python `model_routers` remain Python-only; Java `model_routers` remain 
Java-only.
   - Java `MCP_SERVER` remains unsupported, matching the Python-side 
cross-language boundary.
   
   ### Behavioral Semantics
   
   #### Interaction decisions
   
   | Declaration | Result |
   | --- | --- |
   | `mcp_servers` with `type: java` | Rejected as an unsupported Java resource 
kind |
   | `decision_model_*` with `type: java` and a custom Java class | Accepted as 
a Java descriptor |
   | External sub-agent with `type: java` and a custom Java class | Accepted as 
a Java descriptor |
   | Python-only alias used with `type: java` (for example `dashscope`, 
`chroma`) | Rejected with `Unknown Java alias ...` |
   | Java-only alias used with Python (for example `gemini`, `bedrock`) | 
Rejected with `Unknown Python alias ...` |
   | Fully-qualified custom class when the alias miss is not owned by the other 
language | Accepted unchanged |
   
   #### Behavioral contracts
   
   1. Unsupported `(language, resource kind)` pairs fail during YAML loading 
with `type='<language>' is not supported for <resource kind>`.
   2. A short alias owned only by the other language fails with `Unknown 
<Language> alias '<alias>' for <resource kind>`; it is never emitted as a class 
name.
   3. Custom fully-qualified Java classes remaining valid for the 
Java-supported kinds, including both decision-model sections.
   4. Java external sub-agents remain valid; Python external sub-agents remain 
invalid for `AGENT`.
   5. Source-compatible models stay valid: Python `MODEL_ROUTER` without `type` 
and Java `MODEL_ROUTER` with `type: java`.
   
   #### Failure behavior
   
   Capability and alias-ownership failures raise the loader's existing 
configuration exception (`IllegalArgumentException` in Java, `ValueError` in 
Python). A fully-qualified class that is absent from the runtime classpath 
still fails later during resource construction; the loader does not load 
classes merely to validate YAML.
   
   ### Tests
   
   | Contract | Tests |
   | --- | --- |
   | Java rejects Python-only kinds | 
`YamlLoaderBuildersTest.descriptorJavaRejectedForPythonOnlyKinds` |
   | Java rejects Python-only aliases | 
`YamlLoaderBuildersTest.descriptorJavaRejectedForPythonOnlyAlias`, 
`YamlLoaderBuildAgentsTest.javaDeclarationsRejectAliasesThatResolveOnlyInPython`
 |
   | Python rejects Java-only aliases | 
`YamlLoaderBuildersTest.descriptorPythonRejectedForJavaOnlyAlias`, 
`YamlLoaderBuildAgentsTest.pythonDeclarationsRejectAliasesThatResolveOnlyInJava`,
 `test_build_agents_rejects_java_only_aliases_for_python_declarations` |
   | Custom Java classes pass through | 
`YamlLoaderBuildAgentsTest.javaDeclarationsAcceptCustomFullyQualifiedClasses`, 
`test_build_agents_accepts_custom_java_classes` |
   | Java decision models stay valid | 
`decisionModelJavaDeclarationsLoadCustomImplementations`, 
`descriptorJavaSupportsCustomDecisionImplementations`, plus the existing 
Python-side rejection test |
   | Java external sub-agents and the Python router default stay valid | 
Existing `YamlSubagentTest` and Python YAML loader suites |
   
   Coverage by risk: the tests exercise the descriptor helper and full 
`buildAgents(Path)` loading for both directions, including multiple resource 
sections. They also pin sub-agent and model-router regressions found while 
implementing the capability split.
   
   Not verified: constructing a custom Java decision model or external 
sub-agent from the YAML result; this remains classpath-dependent and is covered 
separately by programmatic plan tests.
   
   Verification:
   
   - Java API module: `mvn -pl api test -q` passed.
   - Python YAML tests for aliases, loader, and sub-agents: 121 passed.
   - Ruff check passed for the touched Python source and alias tests. The 
existing `test_loader.py` coincidentally has unrelated pre-existing Ruff 
findings at lines 92-107 and 858.
   - The full Python YAML directory has one pre-existing schema-manifest 
failure: the checked-in `docs/yaml-schema.json` blob SHA does not match 
`dev/agent-skills/flink-agents-dev/assets/yaml-contracts.yaml`; this change 
does not touch either file.
   
   ### API
   
   No public method signatures change. Alias lookup gains internal helpers used 
by both loaders. The observable change is earlier, clearer rejection of 
cross-language short aliases instead of an unresolved class name reaching 
runtime.
   
   ### Documentation
   
   - [ ] `doc-needed`
   - [x] `doc-not-needed`
   - [ ] `doc-included`
   
   The behavior agrees with the existing YAML language and alias tables. The 
N/A docs checkbox is omitted because it is not part of the template.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   - [x] Yes
   - [ ] No
   
   Generated-by: OpenAI Codex (GPT-5.2)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to