Skip to content

Record the builder homes of L1 and guard their bypasses - #7294

Merged
Koudai Aono (koxudaxi) merged 4 commits into
mainfrom
e4-builder-homes
Nov 21, 2026
Merged

Koudai Aono (koxudaxi) merged 4 commits into
mainfrom
e4-builder-homes

Conversation

@koxudaxi

@koxudaxi Koudai Aono (koxudaxi) commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Fixes: #7289

Summary by CodeRabbit

  • Documentation
    • Clarified the documented rules and limitations for how parsed outputs are built and handed off.
  • Tests
    • Expanded automated checks for builder conventions, dispatch-table usage, and documented exceptions, including seeded test cases. These checks help catch missing or outdated records and inconsistencies.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-21T11:25:27.433712Z 4333738 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.

@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Explain Change →

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.

Walkthrough

This change adds builder-home records and AST-based checks for builder ownership, dispatch-table use, and marked outputs. It documents the checks, records current bypasses, and includes the bypass allowlist in ratchet counts.

Changes: Builder home guard

Layer / File(s) Summary
Define builder-home records
scripts/decision_homes.py
Adds and exports Mark, BuilderHome, and BUILDER_HOMES records for parser outputs and their builders.
Validate builder homes and bypasses
tests/test_decision_homes.py
Adds AST-based validation for builder records and bypass detection. Seeded tests cover dispatch tables, marked outputs, and invalid or missing records.
Document and track bypasses
docs/architecture.md, tests/decision_home_allowlist.py, scripts/check_ratchets.py, tests/test_decision_homes.py
Documents the checks and their syntactic limits. Adds the BUILDER_BYPASSES baseline and includes it in ratchet counts. Tests compare discovered bypasses with the baseline.

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

Change: Other

Merge Risk: Minimal · previous review 43337

This change adds test-only guards that record where L1 builders live and flag direct calls that bypass them. It adds no runtime behavior. The guard tests were not run in this review, so confirm they pass in CI before merging.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "Record the builder homes of L1 and guard their bypasses" matches the main change. The PR adds BuilderHome and Mark records and BUILDER_HOMES in scripts/decision_homes.py, adds BUILDER_BYPAS…
Linked Issues check Passed [#7289] The issue asks for three things: (1) builder homes recorded as data next to the decision homes, (2) a generated guard per record in tests/test_decision_homes.py, (3) a shrinking baseline with …
Out of Scope Changes check Passed All changed areas trace to #7289. scripts/decision_homes.py adds the records the issue requests. tests/test_decision_homes.py adds the guards that read those records. tests/decision_home_allowlist.py …
Full details: Title check

Explanation

The title "Record the builder homes of L1 and guard their bypasses" matches the main change. The PR adds BuilderHome and Mark records and BUILDER_HOMES in scripts/decision_homes.py, adds BUILDER_BYPASSES in tests/decision_home_allowlist.py, and adds AST-based guard tests in tests/test_decision_homes.py. The title is short, specific, and uses the same terms as the linked issue #7289.

Full details: Linked Issues check

Explanation

[#7289] The issue asks for three things: (1) builder homes recorded as data next to the decision homes, (2) a generated guard per record in tests/test_decision_homes.py, (3) a shrinking baseline with a ratchet key, as in #7253.

(1) Recorded as data: scripts/decision_homes.py adds the Mark and BuilderHome record types and a BUILDER_HOMES tuple. The tuple covers the three homes named in the issue: parse methods held by the dispatch tables in parser/_schema_dispatch.py (via the table field, with JsonSchemaParser._DEFINITION_TABLE, _FIELD_TABLE, _OBJECT_KIND_TABLE and OpenAPIParser._OPENAPI_OPERATION_TABLE), the object-map dict (JsonSchemaParser._parse_object_map with marks and parts), and model-reference registration (ModelResolver.add with Reference marks and a _register_reference part). Each record names the passage of docs/architecture.md that states the home.

(2) Guards: per the summary, tests/test_decision_homes.py adds AST-based checks that read these records. They cover table-held parse methods reached only through recorded tables, table reads inside the builder (except typed_children), and marked outputs built only in the builder or its parts. Seeded-package tests exercise the checks. I did not run the tests, and no test results appear in the PR text. The guard logic is therefore established from the summary and the record definitions, not from execution.

(3) Ratchet: BUILDER_BYPASSES is added in tests/decision_home_allowlist.py, and scripts/check_ratchets.py counts it alongside UNLISTED_CALLERS. This matches the baseline requirement.

No concrete unmet coding requirement from #7289 is evident at head. The related issue #7253 is context only; its code was not needed for this verdict.

Full details: Out of Scope Changes check

Explanation

All changed areas trace to #7289. scripts/decision_homes.py adds the records the issue requests. tests/test_decision_homes.py adds the guards that read those records. tests/decision_home_allowlist.py adds the BUILDER_BYPASSES baseline. scripts/check_ratchets.py counts that baseline as a ratchet. docs/architecture.md adds prose that describes the new checks and points to the baseline. The existing DECISION_HOMES content in scripts/decision_homes.py is unchanged apart from the export list and module docstring. I found no change unrelated to the issue. The guard tests were not executed, so their correctness is not confirmed by execution.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
Fix failing CI checks

  • 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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 4cf6021 and 4333738.

Files selected for processing: 5

  • docs/architecture.md
  • scripts/check_ratchets.py
  • scripts/decision_homes.py
  • tests/decision_home_allowlist.py
  • tests/test_decision_homes.py

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

@github-actions

Copy link
Copy Markdown
Contributor

@codspeed

codspeed Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Merging this PR will improve performance by 46.06%

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

⚠️ 53 benchmarks with a significant change ran on different hardware

Their base and head results were measured on machines with a different CPU, core count or memory, so the changes might not come from the code. Run base and head on the same runner type.

Learn more about Macro Runners

See affected benchmarks

⚡ 53 improved benchmarks
⏩ 98 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
⚡ test_perf_simple_msgspec_unset_field_rendering 619.2 ms 345 ms +79.5%
⚡ test_perf_client_calls[sync] 44.5 ms 25 ms +77.77%
⚡ test_perf_client_calls[async] 48.1 ms 28.1 ms +70.95%
⚡ test_perf_load_pyproject_config[mapping-None] 273.3 µs 165.1 µs +65.51%
⚡ test_perf_load_pyproject_config[config-None] 272 µs 165.3 µs +64.48%
⚡ test_perf_scalar_root_collapsed_builtin 264.8 ms 161.7 ms +63.79%
⚡ test_perf_load_pyproject_config[config-multiple] 288 µs 176.2 µs +63.41%
⚡ test_perf_load_pyproject_config[mapping-multiple] 288.6 µs 177 µs +63.07%
⚡ test_perf_unique_items_collapsed_builtin 339.9 ms 211 ms +61.1%
⚡ test_perf_unique_items_schema_validators 437.8 ms 277.8 ms +57.61%
⚡ test_perf_large_models_msgspec 2.9 s 1.8 s +56.84%
⚡ test_perf_large_models_typed_dict[legacy-requiredness] 1,441.4 ms 943.1 ms +52.84%
⚡ test_perf_mapped_reference_users 911.4 ms 596.8 ms +52.71%
⚡ test_perf_local_reference_file_resolution 159.1 ms 104.5 ms +52.24%
⚡ test_perf_large_models_single_module_stdout 2 s 1.3 s +51.81%
⚡ test_perf_graphql_style_pydantic_v2 934.5 ms 621.1 ms +50.47%
⚡ test_perf_ordinary_array_constraint_generation 3 s 2 s +49.39%
⚡ test_perf_large_models_dataclass_builtin 1.7 s 1.1 s +48.8%
⚡ test_perf_large_models_pydantic_v2_builtin 1.7 s 1.2 s +48.5%
⚡ test_perf_inherited_required_fields[partial-derived-first] 1.6 s 1.1 s +48.37%
... ... ... ... ...

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

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing e4-builder-homes (db85e7c) with main (01df8d5)

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 Nov 21, 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 30ae06f into main Nov 21, 2026
113 checks passed
@koxudaxi
Koudai Aono (koxudaxi) deleted the e4-builder-homes branch November 21, 2026 12:31
@github-actions

Copy link
Copy Markdown
Contributor

Breaking Change Analysis

Result: No breaking changes detected

Reasoning: The PR only touches internal developer tooling, tests and docs: docs/architecture.md, scripts/check_ratchets.py, scripts/decision_homes.py, scripts/ratchet_approvals.toml, tests/decision_home_allowlist.py and tests/test_decision_homes.py. It adds BuilderHome and Mark records, a BUILDER_BYPASSES allowlist and new architecture guard tests that check builder homes and dispatch tables. Nothing under src/datamodel_code_generator changed, so generated code, templates, the CLI, the public Python API, defaults, supported Python versions and error handling all stay the same. The behaviour diff gate did not run, which fits a PR with no source changes.


This analysis was produced by the release draft workflow

@github-actions

Copy link
Copy Markdown
Contributor

🎉 Released in 0.100.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.

Check that the builder homes of L1 are the only builders of their outputs

1 participant