Skip to content

Prove the checker-only invariants with heki and drop their src code - #7484

Merged
Koudai Aono (koxudaxi) merged 13 commits into
mainfrom
ce-src-checkers-heki
Nov 24, 2026
Merged

Koudai Aono (koxudaxi) merged 13 commits into
mainfrom
ce-src-checkers-heki

Conversation

@koxudaxi

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

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Documentation
    • Updated architecture and contributor guidance to clarify boundaries for generation-store changes, decision access, import updates, and related operations.
  • Refactor
    • Reworked internal generation and decision processing to use live model data and shared writer controls, replacing several view-based interfaces.
  • Tests
    • Expanded architecture checks for unauthorized cross-phase access and writes; removed tests for the retired guarded-view reporting behavior.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 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-24T08:44:08.358255Z 6b343e6 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 24, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The PR replaces decision-phase view protocols with live model objects and a shared decision writer. It adds heki contracts for decision reads and writes, generation-store operations, and import mutations. It also removes runtime guarded-view checks and updates related tests and documentation.

Changes: Model facts and mutation boundaries

Layer / File(s) Summary
Boundary contract metadata and checks
scripts/fact_tables.py, scripts/pass_decls.py, scripts/build_heki_contracts.py, scripts/heki.toml, scripts/heki_baseline.toml, tests/test_build_heki_contracts_script.py, docs/architecture.md, src/datamodel_code_generator/parser/_imports_plan.py, tests/checks/module_imports.py, scripts/check_architecture_boundaries.py, tests/test_architecture_boundaries.py
Fact tables and decision declarations now define decision accessors, allowed writer methods, import mutators, and permitted ledger writers. The generator and heki configuration emit checks for decision reads and writes, import mutations, and generation-store operations. Tests cover findings and invalid declarations.
Live model and data-type contracts
src/datamodel_code_generator/model/_views.py, src/datamodel_code_generator/types.py, src/datamodel_code_generator/model/base.py, src/datamodel_code_generator/model/enum.py, src/datamodel_code_generator/model/_decisions/*, src/datamodel_code_generator/parser/_passes/_shared.py, src/datamodel_code_generator/parser/_passes/imports.py, src/datamodel_code_generator/parser/_passes/render_prep.py, docs/architecture.md, scripts/decision_homes.py
The view protocols are removed. Affected model, field, reference, and data-type annotations use concrete types or a local protocol. ModelForm moves to types.py, and reference-to-model resolution uses _model_of_reference.
Shared decision writer and live facts
src/datamodel_code_generator/parser/_phases.py, src/datamodel_code_generator/parser/_pipeline.py, src/datamodel_code_generator/parser/_held_null.py, src/datamodel_code_generator/parser/_incomplete_defaults.py, src/datamodel_code_generator/parser/_serialize_as_any.py, src/datamodel_code_generator/parser/_str_like_unions.py, src/datamodel_code_generator/parser/_union_constraints.py, src/datamodel_code_generator/parser/_unique_sets.py, src/datamodel_code_generator/parser/_passes/decide.py, scripts/check_pass_pipeline.py, tests/parser/test_pipeline.py, tests/parser/test_fact_finality.py, docs/architecture.md
DecisionPass is no longer generic or configured with per-pass writer protocols. Decision callbacks use the shared _DecisionWriter and live model objects. Pipeline validation and tests no longer check writer protocols or view accessors.
Generation-store mutation path
src/datamodel_code_generator/parser/generation.py, src/datamodel_code_generator/parser/_field_copies.py, src/datamodel_code_generator/parser/base.py, src/datamodel_code_generator/parser/_rw_split.py, src/datamodel_code_generator/_target_binding.py, tests/checks/finality.py, docs/architecture.md, docs/development-contributing.md
GraphBuilder construction no longer uses _BuilderToken, and GenerationStore mutation methods are no longer marked deprecated. Inherited-field copying uses the builder. Store and builder forwarding calls no longer suppress deprecation warnings.
Finality-check migration
tests/checks/finality.py, tests/checks/parse.py, tests/checks/seams.py, tests/parser/test_fact_finality.py, tests/parser/test_fact_finality.refs, docs/architecture.md
Guarded decision views and runtime render-read reporting are removed. Finality checks use freeze_point from scripts.fact_tables; the render-read test and its snapshot references are removed.

Estimated code review effort: 4 (Complex) | ~60 minutes

Change: Refactor

Possibly related PRs

Suggested reviewers: markparonyan

Merge Risk: Minimal · up to 8034d · assessed changes only

Path filters excluded changed files. This rating applies only to the assessed changes.

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 "Prove the checker-only invariants with heki and drop their src code" matches the main change in the PR. The changes add heki contracts for checker-only invariants (generation-store operatio…
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: Title check

Explanation

The title "Prove the checker-only invariants with heki and drop their src code" matches the main change in the PR. The changes add heki contracts for checker-only invariants (generation-store operations, decision writer calls, decision reads of render facts, Imports mutations), and they remove the corresponding src code, including the _views.py protocols, the *Writer protocol classes, and the GraphBuilder token. The title is specific and single-sentence, and it names the primary change. It is a little technical, but a teammate scanning history would understand the main change.

Finishing Touches

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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between d5b1295 and 8034d83.

Files ignored due to path filters: 8

  • docs/data/migration/unreleased/src-checkers-heki-api.toml is excluded by none and included by none
  • docs/data/migration/unreleased/src-checkers-heki.toml is excluded by none and included by none
  • tests/data/expected/architecture_boundaries/architecture_boundary_source_classification.txt is excluded by !tests/data/**/*.txt and included by none
  • tests/data/expected/checks/checks/check_seams.txt is excluded by !tests/data/**/*.txt and included by none
  • tests/data/expected/main/public_api_signature_baseline/public_api_record_matches_stored_output.txt is excluded by !tests/data/**/*.txt and included by none
  • tests/data/expected/parser/fact_finality/reports_render_facts_that_decisions_read.read.txt is excluded by !tests/data/**/*.txt and included by none
  • tests/data/expected/parser/fact_finality/reports_render_facts_that_decisions_read.violations.txt is excluded by !tests/data/**/*.txt and included by none
  • tests/data/expected/parser/pipeline/decision_registry[broken].txt is excluded by !tests/data/**/*.txt and included by none
Files selected for processing: 9

  • docs/development-contributing.md
  • scripts/check_architecture_boundaries.py
  • scripts/heki.toml
  • scripts/heki_baseline.toml
  • src/datamodel_code_generator/model/base.py
  • src/datamodel_code_generator/model/enum.py
  • src/datamodel_code_generator/types.py
  • tests/parser/test_fact_finality.py
  • tests/test_architecture_boundaries.py
Files with no reviewable changes: 2

  • scripts/check_architecture_boundaries.py
  • tests/test_architecture_boundaries.py
Files skipped from review as they are similar to previous changes: 1

  • docs/development-contributing.md

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

@github-actions

Copy link
Copy Markdown
Contributor

@codspeed

codspeed Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Merging this PR will degrade performance by 13.44%

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

⚠️ 28 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

⚡ 1 improved benchmark
❌ 27 regressed benchmarks
✅ 25 untouched benchmarks
⏩ 98 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
❌ test_perf_recommend_options_full_kubernetes_style 20.9 s 27.1 s -22.98%
❌ test_perf_load_pyproject_config[config-multiple] 229.8 µs 291.2 µs -21.07%
❌ test_perf_load_pyproject_config[config-None] 215.8 µs 271.4 µs -20.49%
❌ test_perf_load_pyproject_config[mapping-multiple] 231.7 µs 289.9 µs -20.09%
❌ test_perf_load_pyproject_config[mapping-None] 223 µs 278.1 µs -19.82%
❌ test_perf_client_calls[sync] 35.5 ms 43.6 ms -18.69%
❌ test_perf_client_calls[async] 38.8 ms 47.1 ms -17.68%
❌ test_perf_extreme_large_schema 14.3 s 16.9 s -15.24%
❌ test_perf_stripe_style_pydantic_v2 2.1 s 2.5 s -14.8%
❌ test_perf_target_render[client-large] 15.7 s 18.3 s -13.94%
❌ test_perf_deep_nested 5 s 5.8 s -13.31%
❌ test_perf_openapi_large 3.1 s 3.6 s -13.3%
❌ test_perf_large_models_pydantic_v2 3.5 s 4 s -12.59%
❌ test_perf_complex_refs 2.1 s 2.4 s -12.55%
❌ test_perf_multiple_files_input 4 s 4.6 s -12.09%
❌ test_perf_graphql_style_pydantic_v2 827.8 ms 939.7 ms -11.91%
❌ test_perf_kubernetes_style_pydantic_v2 2.6 s 2.9 s -11.88%
❌ test_perf_all_options_enabled 5.9 s 6.7 s -11.67%
❌ test_perf_target_render[fastapi-large] 9.8 s 11 s -11.35%
❌ test_perf_mapped_reference_users 796.9 ms 897.3 ms -11.19%
... ... ... ... ...

ℹ️ 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 ce-src-checkers-heki (8034d83) with main (284d3cd)

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 24, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@koxudaxi

Copy link
Copy Markdown
Member Author

CodeRabbit (@coderabbitai) review

@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@koxudaxi

Copy link
Copy Markdown
Member Author

CodeRabbit (@coderabbitai) review

@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@koxudaxi
Koudai Aono (koxudaxi) merged commit a582946 into main Nov 24, 2026
154 of 155 checks passed
@koxudaxi
Koudai Aono (koxudaxi) deleted the ce-src-checkers-heki branch November 24, 2026 12:26
@github-actions

Copy link
Copy Markdown
Contributor

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

2 participants