Skip to content

Share the operation planning the client and the server compute the same way, with one policy row per difference - #5474

Merged
Koudai Aono (koxudaxi) merged 6 commits into
dry-a9bfrom
plat-t6a
Oct 29, 2026
Merged

Koudai Aono (koxudaxi) merged 6 commits into
dry-a9bfrom
plat-t6a

Conversation

@koxudaxi

@koxudaxi Koudai Aono (koxudaxi) commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Refactor
    • Client and server operation planning now uses consistent shared rules for operation labels, names, settings, parameters, and path placeholders.
    • Client and FastAPI targets retain their distinct validation and diagnostic behavior.
    • Operation grouping and route placeholder handling now follow the same conventions across targets.

@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between c65fa26 and dc29e2c.

Files ignored due to path filters: 1
  • docs/llms-full.txt is excluded by none and included by none
Files selected for processing: 16
  • docs/architecture.md
  • scripts/check_architecture_boundaries.py
  • scripts/decision_homes.toml
  • src/datamodel_code_generator/_client/caching.py
  • src/datamodel_code_generator/_client/fields.py
  • src/datamodel_code_generator/_client/pagination.py
  • src/datamodel_code_generator/_client/plan.py
  • src/datamodel_code_generator/_client/protocol_plan.py
  • src/datamodel_code_generator/_client/security.py
  • src/datamodel_code_generator/_client/target.py
  • src/datamodel_code_generator/_fastapi/plan.py
  • src/datamodel_code_generator/_fastapi/render.py
  • src/datamodel_code_generator/_fastapi/routes.py
  • src/datamodel_code_generator/_fastapi/target.py
  • src/datamodel_code_generator/_target_naming.py
  • src/datamodel_code_generator/_target_operations.py

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

Walkthrough

The PR adds shared operation-planning utilities with client and server policies. It updates client and FastAPI planners and supporting modules to use the shared helpers, and updates architecture tracking to identify the shared module as the core.

Changes: Operation Planning

Layer / File(s) Summary
Shared operation contracts and utilities
src/datamodel_code_generator/_target_operations.py, src/datamodel_code_generator/_target_naming.py, docs/architecture.md, scripts/check_architecture_boundaries.py, scripts/decision_homes.toml
Adds shared planning helpers and target-specific policies. Updates the architecture documentation, boundary checker, and T-operation registry to identify the shared core and its adapters.
Client planner adoption
src/datamodel_code_generator/_client/plan.py, src/datamodel_code_generator/_client/caching.py, src/datamodel_code_generator/_client/fields.py, src/datamodel_code_generator/_client/pagination.py, src/datamodel_code_generator/_client/protocol_plan.py, src/datamodel_code_generator/_client/security.py, src/datamodel_code_generator/_client/target.py
Client planning and supporting modules use shared operation labels, settings, naming, fact access, type-use lookup, aliases, and placeholder validation.
FastAPI planner adoption
src/datamodel_code_generator/_fastapi/plan.py, src/datamodel_code_generator/_fastapi/routes.py, src/datamodel_code_generator/_fastapi/render.py, src/datamodel_code_generator/_fastapi/target.py
FastAPI planning and route code use shared operation helpers, server policies, naming, aliases, type-use lookup, and path-placeholder matching.

Priority: Low

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Refactor

Possibly related issues

  • Issue 5421: The PR updates the architecture model to describe shared operation planning and policy rows, which relates to the issue’s concern about policy rows in the architecture documentation.

Possibly related PRs

Merge Risk: Minimal · previous review dc29e

The shared operation-planning changes have no identified merge-blocking issue. Merge after normal checks pass.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly describes the main change: sharing operation planning between client and server while representing target-specific differences through policy rows.
Docstring Coverage Passed Docstring coverage is 93.33% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentati…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 93.33% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 60 functions across 14 files. (2 skipped: 2 unsupported.)

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-29T02:26:48.585623Z dc29e2c PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown
Contributor

@codspeed

codspeed Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Merging this PR will degrade performance by 20.86%

2 warnings

⚠️ Walltime results may be unreliable

Some benchmarks used the Walltime instrument outside CodSpeed Macro Runners, which can make the results inconsistent.

Learn more about Macro Runners

See affected benchmarks

⚠️ Base and head ran on different runner types

Some benchmarks with significant performance changes were compared across different runner types, so the changes might not come from the code. Run base and head on the same runner type, or use CodSpeed Macro Runners for more stable results.

Learn more about Macro Runners

Open the report in CodSpeed to investigate

❌ 52 regressed benchmarks
⏩ 98 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
❌ test_perf_empty_pydantic_v2_field_render_plans 27.5 ms 36.7 ms -24.86%
❌ test_perf_unique_items_runtime_scalar_validation 2.5 ms 3.2 ms -24.04%
❌ test_perf_load_pyproject_config[mapping-multiple] 237.5 µs 311.9 µs -23.86%
❌ test_perf_target_render[client-small] 23.2 ms 30.2 ms -23.32%
❌ test_perf_load_pyproject_config[config-None] 226.4 µs 294.6 µs -23.15%
❌ test_perf_load_pyproject_config[config-multiple] 238.2 µs 309.8 µs -23.12%
❌ test_perf_pattern_properties_adapter_reuse 3 ms 3.8 ms -23.11%
❌ test_perf_client_calls[sync] 24.6 ms 31.9 ms -23.06%
❌ test_perf_recommend_options_full_kubernetes_style 9.9 s 12.8 s -23.04%
❌ test_perf_pydantic_field_name_resolution 1.5 ms 2 ms -22.91%
❌ test_perf_complex_refs 1.5 s 1.9 s -22.79%
❌ test_perf_unique_items_permuted_object_validation 54.8 ms 70.9 ms -22.72%
❌ test_perf_load_pyproject_config[mapping-None] 230.4 µs 297.1 µs -22.46%
❌ test_perf_client_calls[async] 27.6 ms 35.6 ms -22.37%
❌ test_perf_unique_items_runtime_nested_object_validation 5.5 ms 7.1 ms -22.35%
❌ test_perf_duplicate_names 753.6 ms 969.4 ms -22.26%
❌ test_perf_target_render[fastapi-large] 4.6 s 6 s -21.97%
❌ test_perf_large_models_pydantic_v2 2.6 s 3.4 s -21.81%
❌ test_perf_local_reference_file_resolution 81.1 ms 103.5 ms -21.62%
❌ test_perf_openapi_large 2.3 s 3 s -21.59%
... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing plat-t6a (0498a3c) with dry-a9b (494ef9c)

Open in CodSpeed

Footnotes

  1. 98 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@codecov

codecov Bot commented Oct 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@koxudaxi
Koudai Aono (koxudaxi) merged commit 2860d37 into main Oct 29, 2026
163 of 164 checks passed
@koxudaxi
Koudai Aono (koxudaxi) deleted the plat-t6a branch October 29, 2026 03:18
@github-actions

Copy link
Copy Markdown
Contributor

Breaking Change Analysis

Result: No breaking changes detected

Reasoning: This PR is an internal refactor that moves logic shared by the client and FastAPI targets into a new private module, _target_operations.py. The moved pieces are PlanError, fact, label, type_uses, first_use, local, declared_by, tags, group_tag, derived_name, type_names, argument_names, alias, resolve_settings, placeholder_problems, BODYLESS_STATUSES and LOCATIONS. Where the two targets behaved differently, each difference is kept as a row in a TargetPolicy for CLIENT and SERVER. Comparing the removed code with the new code line by line shows the same behaviour. The diagnostic codes, stages and messages are unchanged: the client still reports E_METADATA_REQUIRED for path placeholders and includes the operation label, while the server still reports F_ROUTE_INVALID without the label on the first message. The duplicate-setting errors keep their codes and wording (E_CONFIG_CONFLICT with Two settings name for the client, E_CONFIG_VALUE with The option setting names key twice for the server). The stage rules are the same, and the aliases-entry checks use the same source locations. Argument, operation and type naming calls the same claim logic with the same scopes. Only modules with an underscore prefix are touched, so no public Python API or CLI option changes. No templates, Python version support or defaults change either. The behaviour diff gate does list accepted output changes, but all of them are about allOf and JSON Schema intersection handling, which the notes credit to other work, and this PR does not touch the parser or model code. The rest of the diff only updates architecture docs, the decision-homes toml allowlist and the boundary-check script.


This analysis was produced by the release draft workflow

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

🎉 Released in 0.88.0

This PR is now available in the latest release. See the release notes for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant