Zhuoxi2000 opened a new pull request, #1517:
URL: https://github.com/apache/flink-agents/pull/1517

   <!--
   * Thank you very much for contributing to Flink Agents.
   * Please add the relevant components in the PR title. E.g., [api], 
[runtime], [java], [python], [hotfix], etc.
   -->
   
   <!-- Please link the PR to the relevant issue(s). Hotfix doesn't need this. 
-->
   Linked issue: #1458
   
   ### Purpose of change
   
   <!-- What is the purpose of this change? -->
   
   Step 2 of #1458: unit tests that check the stability markers from #1491 
against the scope in `API.md`, in the existing Java and Python CI lanes. They 
fail when a covered declaration has no classification or when a marker carries 
invalid metadata.
   
   **Baseline (open question from #1458).** Nothing is classified yet, so each 
language has a checked-in list of currently unclassified declarations under 
`tools/api-stability/`. An unlisted declaration without a marker fails, and so 
does a listed one that is now classified or removed, so the lists only shrink 
as Step 3 marks modules. Deleting the two files switches this to merging after 
Step 3, with no code change.
   
   #### Runtime flow
   
   1. Java (`ApiStabilityMarkerCheckTest`, `api` module): loads the module's 
compiled classes under `org.apache.flink.agents.api` and resolves each public 
type's classification from its own marker or the nearest enclosing type's. 
Explicit markers on types and on public (and, for non-final types, protected) 
members are checked for valid metadata.
   2. Python (`test_api_stability_markers.py`): reads `flink_agents/api` 
sources with `ast`, without importing them, and does the same for public 
classes (including nested ones) and module-level functions, recognizing the 
`flink_agents.api.stability` decorators and `Annotated` metadata under any 
import alias.
   3. Members use their type's classification, so only types (Java) and classes 
and module-level functions (Python) can be unclassified. `ConfigOption` and 
`ResourceName` constants are covered through their classes.
   4. `-Dregenerate.snapshots=true` (Java) and `REGENERATE_SNAPSHOTS=1` 
(Python) rewrite the baselines, as the snapshot tests do.
   
   #### Key decisions
   
   * **Type-level baselines**: 281 Java types and 259 Python declarations, 
rather than every member, so the lists stay reviewable. They include the 15 
`api` files still using Flink's `@Internal` and the marker types themselves; 
both leave the lists once classified.
   * **No imports in the Python check**, so it needs no optional dependencies 
and has no import side effects.
   * **No new dependencies and no workflow changes.**
   * The baselines carry the license header as comments, so `.rat-excludes` is 
unchanged.
   
   Out of scope, for follow-ups: YAML (marker format still TODO), 
`ResourceOption` (TODO), and the cross-version rule that new members of 
published types must be `Experimental`, which needs a published baseline.
   
   Rules I chose that you may want different:
   
   1. `since` must match `X.Y.Z`, such as `1.0.0`.
   2. `@Deprecated` and `deprecated` must set `since`. `api` has no 
`@Deprecated` today.
   3. Protected nested Java types are not checked; public nested types resolve 
through the enclosing type.
   4. Python's top-level public names follow `__all__` when a module defines 
it, else the leading underscore. Declarations inside `if TYPE_CHECKING:` or 
`try:` blocks are not scanned.
   5. 43 module-level Python variables (type aliases such as 
`DataContentBlock`, constants, `TypeVar`s) are not checked. How should those be 
marked?
   
   ### Behavioral Semantics
   
   <!-- For a non-trivial code change whose implementation is largely 
AI-assisted: interaction decisions, behavioral contracts, and failure behavior. 
See `contribution-guides/ai-assisted-pr.md`. Remove this heading and this 
comment otherwise. -->
   
   #### Behavioral contracts
   
   1. A covered declaration with no own or enclosing classification fails the 
check unless it is in the baseline.
   2. A baseline entry that is now classified or no longer exists fails the 
check.
   3. More than one classification on a declaration fails, as does `Stable` or 
deprecation without a release-version `since`, `Experimental` with both `since` 
and `inProgress` / `in_progress`, or with neither.
   4. Production code and behavior are unchanged.
   
   #### Failure behavior
   
   Failures name every offending declaration and the file or rule to fix: mark 
it, or delete its baseline line.
   
   ### Tests
   
   <!-- How is this change verified? -->
   
   | Contract | Java | Python |
   |---|---|---|
   | 1, 2 | `everyApiTypeResolvesAClassification` | 
`test_every_api_declaration_resolves_a_classification` |
   | 3 | `everyMarkerCarriesValidMetadata`, 
`reportsInvalidMetadataAndResolvesEnclosingClassification` (fixture classes) | 
`test_every_marker_carries_valid_metadata`, `test_checker_rules` (source 
fixtures, including aliased, module and relative imports) |
   
   Checked manually in both languages: adding an unmarked public type fails 
with its name, and marking a listed type fails until its line is deleted. 
Verified locally on main: `api` module (988 tests, spotless), the Python check 
with ruff, and `tools/check-license.sh`.
   
   ### API
   
   <!-- Does this change touches any public APIs? -->
   
   No API change. New test-only files, two baselines and a "Marker checks" 
section in `contribution-guides/api-stability-guidelines.md`.
   
   ### Documentation
   
   <!-- Do not remove this section. Check the proper box only. -->
   
   - [ ] `doc-needed` <!-- Your PR changes impact docs -->
   - [ ] `doc-not-needed` <!-- Your PR changes do not impact docs -->
   - [x] `doc-included` <!-- Your PR already contains the necessary 
documentation updates -->
   
   "Marker checks" in `contribution-guides/api-stability-guidelines.md`.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   <!-- Do not remove this section. Check the proper box only. -->
   
   - [x] Yes
   - [ ] No
   
   If yes, include a `Generated-by: <tool name and version> (<model name and 
version>)` line, for example `Generated-by: Claude Code 2.1.226 (Claude Opus 
4.6)`, in the commit message so it reaches Git history. Repeat the same line 
here for reviewer visibility. See the [ASF generative tooling 
guidance](https://www.apache.org/legal/generative-tooling.html).
   
   Generated-by: Claude Code 2.1.259 (Claude Opus 5.5)
   


-- 
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