Skip to content

Plan the remote lock and stage its update in one place each - #5591

Merged
Koudai Aono (koxudaxi) merged 1 commit into
impl-optionsfrom
impl-lock
Oct 29, 2026
Merged

Koudai Aono (koxudaxi) merged 1 commit into
impl-optionsfrom
impl-lock

Conversation

@koxudaxi

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

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Bug Fixes

    • Improved consistency in how lockfile locations and policies are handled across generation workflows.
    • Remote lockfile updates are staged before publication, reducing the risk of incomplete updates if staging fails.
  • Documentation

    • Expanded architecture guidance on lockfile location, policy selection, and publication behavior.

@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

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 eb5d5c9 and 7bf660c.

Files ignored due to path filters: 1
  • docs/llms-full.txt is excluded by none and included by none
Files selected for processing: 7
  • docs/architecture.md
  • scripts/decision_homes.toml
  • src/datamodel_code_generator/__init__.py
  • src/datamodel_code_generator/__main__.py
  • src/datamodel_code_generator/_api_generation.py
  • src/datamodel_code_generator/_lock_plan.py
  • src/datamodel_code_generator/remote_lock.py

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

Walkthrough

Remote lock path and policy selection now use a shared planning module. CLI and API generation paths use shared helpers to reserve private staging and prepare staged lock files for publication.

Changes: Remote lock handling

Layer / File(s) Summary
Centralize remote lock planning
src/datamodel_code_generator/_lock_plan.py, src/datamodel_code_generator/__main__.py, src/datamodel_code_generator/__init__.py, src/datamodel_code_generator/_api_generation.py, scripts/decision_homes.toml, docs/architecture.md
The new planning module defines path-spelling rules and lock policies. CLI and API generation paths use its helpers to select lock paths and determine update ownership. The decision records and architecture table document the planning rules.
Share lock staging and publication
src/datamodel_code_generator/remote_lock.py, src/datamodel_code_generator/__main__.py, src/datamodel_code_generator/__init__.py, src/datamodel_code_generator/_api_generation.py, scripts/decision_homes.toml, docs/architecture.md
Shared helpers acquire the publication anchor, reserve private staging, and prepare staged lock files. Generation and commit paths use the helpers; the decision records and architecture table document lock staging.

Priority: Low

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

Change: Refactor

Possibly related issues

  • Issue 5584: The PR centralizes lock path planning across CLI and API paths, which relates to the reported differences in how lockfile spellings resolve.
  • Issue 5585: The PR uses a shared lock parent and planning path, which relates to the reported difference in lockfile location between CLI and generate().
  • Issue 5583: The PR changes lock planning and staging for API updates without an output file, matching the reported symlinked-lockfile scenario.
Merge Risk: Minimal · up to 7bf66

The change centralizes remote-lock planning and staging. No concrete merge-blocking regression is established; 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 summarizes the main changes: centralizing remote-lock planning and staging. It is concise and specific.
Docstring Coverage Passed Docstring coverage is 100.00% 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. Documentat…
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 100.00% 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 14 functions across 5 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-29T20:21:57.284188Z 7bf660c 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 31.8%

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_client_calls[sync] 23.9 ms 43.3 ms -44.83%
❌ test_perf_client_calls[async] 26.6 ms 47.7 ms -44.25%
❌ test_perf_simple_msgspec_unset_field_rendering 296.9 ms 532 ms -44.19%
❌ test_perf_load_pyproject_config[config-multiple] 234.2 µs 385.1 µs -39.19%
❌ test_perf_load_pyproject_config[mapping-multiple] 239.2 µs 388.6 µs -38.46%
❌ test_perf_load_pyproject_config[mapping-None] 230.1 µs 373.6 µs -38.42%
❌ test_perf_load_pyproject_config[config-None] 228.5 µs 370.7 µs -38.36%
❌ test_perf_large_models_typed_dict[legacy-requiredness] 754.2 ms 1,219.2 ms -38.14%
❌ test_perf_large_models_dataclass_builtin 895.6 ms 1,430.3 ms -37.38%
❌ test_perf_large_models_msgspec 1.3 s 2.1 s -36.77%
❌ test_perf_large_models_pydantic_v2_builtin_double_quotes 881.3 ms 1,383.6 ms -36.31%
❌ test_perf_scalar_root_collapsed_builtin 138.9 ms 217.9 ms -36.26%
❌ test_perf_large_models_single_module_stdout 995.6 ms 1,556.9 ms -36.06%
❌ test_perf_large_models_pydantic_v2_builtin 850.8 ms 1,322.8 ms -35.68%
❌ test_perf_large_models_typed_dict[total-false-requiredness] 772 ms 1,198.3 ms -35.57%
❌ test_perf_local_reference_file_resolution 87.2 ms 133.1 ms -34.5%
❌ test_perf_large_models_pydantic_v2_noformat 872.6 ms 1,323 ms -34.05%
❌ test_perf_large_models_pydantic_v2 2.6 s 3.9 s -33.94%
❌ test_perf_multiple_files_input 2.7 s 4 s -33.65%
❌ test_perf_deep_nested 3.9 s 5.8 s -33.39%
... ... ... ... ...

ℹ️ 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 impl-lock (7bf660c) with impl-options (eb5d5c9)

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 73f0ebc into main Oct 29, 2026
163 of 164 checks passed
@koxudaxi
Koudai Aono (koxudaxi) deleted the impl-lock branch October 29, 2026 23:51
@github-actions

Copy link
Copy Markdown
Contributor

Breaking Change Analysis

Result: No breaking changes detected

Reasoning: This PR is an internal refactor. It moves the remote lock path and policy logic into a new private module, _lock_plan.py, with remote_lock_plan, owns_lock_update and models_lockfile. It also adds private helpers _open_lock_staging and _staged_lock in remote_lock.py for lock staging, and adds the matching docs and decision-home table rows. I checked each old path against its replacement. The command-line lexical spelling still applies abspath and then resolve. The atomic generate() update still joins a relative lockfile to the caller directory and resolves it. The other generate() runs still use an absolute lockfile as written, and that is kept on purpose under the new legacy-api-lockfile-as-written row. The policy is still update, then locked, then verify if the file exists, then inactive. The target lockfile handoff and RemoteReferenceLock.commit produce the same paths and staged files as before. The only removed items are private: the _RemoteLockPlan NamedTuple in main, which is now imported from _lock_plan, and some inline staging code. No CLI option, public API, template, default value or Python version support changes. The one small runtime difference is that the publication anchor is now released if lock staging cannot be created. That is a cleanup fix, not a change in how errors are reported. The behaviour diff gate does list accepted cells, but all of them are about allOf scalar and array root handling, and their notes credit a separate earlier change. This diff touches no parser or model code, so those output changes do not come from this PR.


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