Skip to content

Batch-1 hardening: emit_python Optional+ogar_runtime, FK-dedup consolidation, WoA harvest v2 (151 models, import-gate closed)#165

Merged
AdaWorldAPI merged 6 commits into
mainfrom
claude/b1-integration
Jul 6, 2026
Merged

Batch-1 hardening: emit_python Optional+ogar_runtime, FK-dedup consolidation, WoA harvest v2 (151 models, import-gate closed)#165
AdaWorldAPI merged 6 commits into
mainfrom
claude/b1-integration

Conversation

@AdaWorldAPI

Copy link
Copy Markdown
Owner

What

Batch-1 hardening — closes three named follow-ups from #158's honesty drift-list, spec'd (Opus) → ground (Sonnet ×3) → reviewed + integration-probed (Opus), rebased onto #164.

Item 1 — emit_python: Optional[] + real imports (drift entry → CLOSED)

  • required == Some(false)Optional[…] — exact mirror of emit_rust's rule; all three required states tested (Rails Some(true)/Some(false), Odoo None).
  • New emit_python_prelude(): emitted modules import from ogar_runtime (design decision: symmetric to the Rust side — the consumer pulls the wrapper contract, never re-mints inline; reference crates/ogar-from-ruff/python/ogar_runtime.py ships alongside). Completeness-checked: every name og_scalar_type can emit resolves — no NameError possible.
  • The parity probe's wrap_module crutch is deleted; DRIFT print now honestly reads emit_python Optional[]-Nullability: GESCHLOSSEN, leaving the classid alias as the sole remaining drift.

Item 2 — FK-dedup consolidation (kills the lockstep copy)

project_rails_fields → shared pub(crate) project_total_schema_fields; the SQLAlchemy copy collapses to a thin wrapper, is_fk_shadowed_by_association single-sourced (explicit foreign_key: first). New cross-producer test pins identical dedup semantics on both paths (identical attribute sets, BTreeSet equality). Review bonus: consolidation silently fixed a dormant many2many→BelongsTo mismap in the old copy.

Item 3 — WoA harvest v2 (.claude/harvest/woa-rs/)

models.py + woa/models_shop.py151 models, 2154 attrs, 112 assocs (0 dangling), 6 aliased / 145 bootstrap. Emitted with the new prelude: HARVEST gap #3 (import-gate) closed for real — python3 -c "import models"IMPORT_OK 176, ogar_runtime.py shipped alongside. Gap #2 (models_shop) closed. WoA-side release copy already pushed (claude/woa-repo-backup-update-qb1enp @ 4061c68).

Ledger

Two append-only docs/DISCOVERY-MAP.md entries (Item 1 + Item 2), added post-review-sign-off per house rule; HARVEST.md v2 carries the metric table v1→v2.

Verified (post-#164 merge)

cargo test --workspace → 42 suites, 0 failed (incl. 71 ogar-from-ruff tests with the new Optional/prelude/cross-producer pins and #164's CompiledClass.actions coexisting). cargo clippy -p ogar-from-ruff --all-targets --all-features -- -D warnings clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Cg8DSUz1U4AvKqXiy9Xx2f

claude added 6 commits July 6, 2026 19:56
…tal_schema_fields

SPEC-B1-2: kill the sqlalchemy.rs lockstep copy of project_rails_fields /
is_fk_shadowed_by_association. Rename project_rails_fields to
pub(crate) project_total_schema_fields (body unchanged), make
is_fk_shadowed_by_association pub(crate), and route both the Rails (Ruby)
and SQLAlchemy (Python) producers through the single lib.rs implementation.
sqlalchemy.rs's project_sqlalchemy_fields collapses to a thin delegating
wrapper; its own is_fk_shadowed_by_association copy is deleted.

Adds both_producers_share_explicit_foreign_key_dedup, lifting one Model
through both the Ruby and SQLAlchemy entry points and asserting identical
FK-dedup outcomes (PR #156 finding (b): explicit foreign_key, not just the
<name>_id convention) and identical attribute name sets, proving the shared
semantics.

classify_woa_domain (a separate lockstep copy of classify_domain) is left
untouched per spec — out of scope for this item.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…_module crutch

SPEC-B1-1 (Batch-1 Item 1). emit_python now mirrors emit_rust's Option<...>
rule exactly: an attribute with `required == Some(false)` wraps in
`Optional[...]`; `Some(true)`/`None` (the Odoo path, which never sets
`required`) stay bare, so Odoo emit output is bit-for-bit stable.

New `emit_python_prelude()` emits the module-level wrapper-contract import
block once per module (`from ogar_runtime import (...)`), design option (a)
from three considered: inlining aliases per class (b) re-mints a parallel
schema truth per file, and a `try/except import *` shim (c) masks import
errors — both rejected per "pull, never re-mint". A shipped reference
`crates/ogar-from-ruff/python/ogar_runtime.py` supplies the wrapper types
so the emitted module py_compiles and imports standalone without any
consumer setup.

woa_parity_probe.rs: deleted the `wrap_module` hand-rolled import-and-alias
crutch; `woa_dataclass_py_compiles_and_instantiates` now composes
`emit_python_prelude()` + `emit_python()` and copies the shipped
`ogar_runtime.py` next to the emitted module. `instantiate_check.py` adds
the emitted module's dir to `sys.path` and registers the module in
`sys.modules` before `exec_module` — required because the prelude's
`from __future__ import annotations` (PEP 563) makes `dataclasses` resolve
ClassVar/InitVar via `sys.modules[cls.__module__]`, which is `None` for a
`spec_from_file_location`-loaded module unless registered first (a real
mechanical necessity for the mandated prelude content, not a design change).

DRIFT list entry flips from "Lücke" to GESCHLOSSEN; `created_at` now emits
`Optional[OgDateTime]`. The classid alias line (WOA_ALIASES convergence pin)
remains the sole open drift on this fixture.

Added `emit_python_wraps_nullable_in_optional_bare_otherwise` (Rails
Some(true)/Some(false) + Odoo None, all three required-states) and
`emit_python_prelude_imports_from_ogar_runtime`.

cargo test -p ogar-from-ruff: 66 + 3 tests green (probe metric + py_compile +
instantiate gate). cargo test --workspace: no regressions (all suites green).
cargo clippy -p ogar-from-ruff --all-targets --all-features -D warnings: clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…nsolidated

Two append-only Nachträge on D-PARITY-PROBE-WOA-1:
- Item 1: emit_python now wraps required==Some(false) in Optional[…]
  (mirror emit_rust), prelude imports from ogar_runtime, wrap_module crutch
  deleted; emitted @DataClass py_compiles + imports standalone.
- Item 2: sqlalchemy.rs FK-dedup lockstep copy consolidated onto shared
  pub(crate) project_total_schema_fields / is_fk_shadowed_by_association.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…dels)

Regenerate the WoA sink-in substrate harvest against the CURRENT
ogar-from-ruff (post Batch-1 Item 1 emit_python prelude+Optional[], Item 2
FK-dedup consolidation): the scratch driver at /tmp/harvest-woa now extracts
both models.py (139) and woa/models_shop.py (12) via
ruff_sqlalchemy_spo::extract_file, merges via ModelGraph.models.extend()
(same "woa" namespace) before minting, and regenerates all four artifacts.

Metrics (driver stderr, not hand-estimated): 151 classes, 2154 attributes,
112 associations, 6 aliased / 145 bootstrap, 0/112 dangling .spo edges.

v1 gap #2 (models_shop.py out of scope) and gap #3 (emit_python's import
list incomplete -> NameError on import) are both RESOLVED: the emitted
models.py now carries emit_python_prelude()'s imports, ogar_runtime.py
(Item 1's reference wrapper-contract) ships alongside it in this directory,
and `python3 -c "import models"` passes (not just py_compile) -- verified
directly in this harvest dir, not only in the /tmp scratch driver's out/.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…-integration

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@cursor

cursor Bot commented Jul 6, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_d7d009a0-6a75-456f-9973-14d780843d56)

@AdaWorldAPI AdaWorldAPI merged commit 0dad0c3 into main Jul 6, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants