Commit 260a42a
committed
ogar-from-ruff: project Rails schema fields at lift (falsifier #1 gap-close)
Closes GAP-1/3/4 + one cosmetic found by the falsifier #1 parity probe
(WorkPackage, 18 hand-written schema columns) against the Ruby lift.
GAP-1 (lib.rs) — `lift_model_with_language` only ever called
`project_odoo_fields` for `Language::Python`; Rails' `Model::fields`
(the D-AR-3.5 physical schema stratum populated by
`ruff_ruby_spo::extract_app_with_schema`) never reached `Class` at all.
Added `project_rails_fields` (called for `Language::Ruby`), mirroring
`project_odoo_fields`'s relational/scalar/computed-field split, plus:
- `not_null` wiring onto `AttributeOptions::required`
(`Some(true)` -> `Some(true)`; `None` -> the explicit `Some(false)`,
since the schema stratum is total knowledge).
- FK-dedup (`is_fk_shadowed_by_association`): a scalar `<name>_id`
column is skipped when the model already declares an association
named `<name>` — the physical FK column and the declared
`belongs_to`/`has_many` are the SAME relation seen from two strata;
the canon keeps the AR spelling (`<name>: ToOne<X>`), not the ORM
spelling (`<name>_id: OgInt`). The literal `id` primary key is
never shadowed.
GAP-3 (emit.rs, `og_scalar_type`) — added `"string"`/`"bigint"` to the
existing `OgStr`/`OgInt` arms (the Rails migration-DSL spelling of
Odoo's `char`/`integer`), and `"decimal"` to the `monetary` -> `OgMoney`
arm. No dedicated `OgDecimal` wrapper exists in the consumer contract
today, so `decimal` shares `OgMoney` (the closest existing
Decimal-backed wrapper) rather than falling back to `OgScalar`; a
future `OgDecimal` should take over this arm without touching
`monetary`.
GAP-4 (emit.rs, `emit_rust`) — an attribute whose
`AttributeOptions::required == Some(false)` now emits wrapped in
`Option<...>`; any other value (`Some(true)`, or `None` — the Odoo
path today, which never sets `required`) emits the bare type
unchanged. Confirmed zero drift on the Odoo path with a dedicated test
(`lift_model_python_never_sets_required_zero_drift`) plus the existing
Odoo emit tests, all unchanged and green.
COSMETIC (emit.rs, all three emitters' doc-comment lines) — the
generated doc line computed "concept" as `facet_classid() as u16`,
which reads the LOW (app/render-prefix) half; post canon-high-flip the
concept is the HIGH half. Routed through `ogar_vocab::app::{concept_of,
app_of}` and print both explicitly: `classid `0x01020001` (concept
`0x0102`, app `0x0001`)`.
Dependency note: `Field::not_null` (D-AR-3.5) does not exist at the
previously-pinned ruff rev `61ce2b49`. Bumped `ogar-from-ruff` and
`ogar-from-rails` (lockstep, per their existing comment) to
`c514b96d38d764bb16ac070fb2fdbd13477f41bc` — the pushed tip of
`AdaWorldAPI/ruff@claude/odoo-rs-transcode-lf8ya5` carrying the schema
stratum this fix reads. Still the AdaWorldAPI fork, no crates.io
fallback, no coordinate substitution.
Tests: replaced the now-obsolete `lift_model_ruby_does_not_project_fields`
(pinned the pre-fix bug) with `lift_model_ruby_projects_schema_stratum_fields_with_types`,
`lift_model_ruby_fk_scalar_deduped_against_declared_association_id_kept`,
`lift_model_ruby_wires_not_null_to_required`, and the zero-drift proof
`lift_model_python_never_sets_required_zero_drift` in lib.rs; added
`emits_rust_struct_with_typed_and_optional_schema_fields_for_rails` and
`emit_rust_doc_line_prints_concept_high_and_app_low` in emit.rs.
`cargo test -p ogar-from-ruff -p ogar-vocab -p ogar-from-rails --lib`:
53 + 96 + 1 passed (17 ignored, require real source checkouts), 0
failed. `cargo clippy -p ogar-from-ruff --all-targets -- -D warnings`:
clean.
Falsifier #1 probe tally (WorkPackage, scratchpad parity-probe/):
pre-fix: attributes.len=0, associations.len=9 (0/18 schema columns
reached the lifted Class at all)
post-fix: attributes.len=10, associations.len=9 — all 10 remaining
attributes typed (id/subject:bigint,string ->OgInt,OgStr;
description/start_date/due_date/estimated_hours/done_ratio
-> Option<OgStr|OgDate|OgDate|OgFloat|OgInt>;
lock_version/created_at/updated_at -> bare OgInt/OgDateTime);
8 FK columns (project_id/type_id/status_id/priority_id/
author_id/assigned_to_id/responsible_id/parent_id) correctly
deduped into their matching `ToOne<X>` associations. 18/18
raw schema columns typed (zero OgScalar fallback) — exceeds
the ~16+/18 estimate.
Board: docs/DISCOVERY-MAP.md D-PARITY-PROBE-WP-1 (falsifier #1
measured, [G], re-runnable probe).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D9qw3LYDprZi4uts2m57iq1 parent a14bcc8 commit 260a42a
5 files changed
Lines changed: 428 additions & 41 deletions
File tree
- crates
- ogar-from-rails
- ogar-from-ruff
- src
- docs
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
25 | 28 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
26 | 34 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
30 | 33 | | |
31 | 34 | | |
32 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
33 | 44 | | |
34 | 45 | | |
35 | 46 | | |
36 | 47 | | |
37 | 48 | | |
38 | 49 | | |
| 50 | + | |
39 | 51 | | |
40 | 52 | | |
41 | 53 | | |
| |||
55 | 67 | | |
56 | 68 | | |
57 | 69 | | |
58 | | - | |
59 | | - | |
60 | | - | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
61 | 74 | | |
62 | 75 | | |
63 | | - | |
64 | | - | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
65 | 90 | | |
66 | 91 | | |
67 | | - | |
68 | | - | |
| 92 | + | |
| 93 | + | |
69 | 94 | | |
70 | | - | |
| 95 | + | |
71 | 96 | | |
72 | 97 | | |
73 | 98 | | |
| |||
258 | 283 | | |
259 | 284 | | |
260 | 285 | | |
261 | | - | |
| 286 | + | |
262 | 287 | | |
263 | 288 | | |
264 | | - | |
| 289 | + | |
| 290 | + | |
265 | 291 | | |
266 | 292 | | |
267 | 293 | | |
| |||
271 | 297 | | |
272 | 298 | | |
273 | 299 | | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
274 | 312 | | |
275 | | - | |
| 313 | + | |
276 | 314 | | |
277 | | - | |
278 | 315 | | |
279 | 316 | | |
280 | 317 | | |
| |||
322 | 359 | | |
323 | 360 | | |
324 | 361 | | |
325 | | - | |
| 362 | + | |
326 | 363 | | |
327 | 364 | | |
328 | | - | |
| 365 | + | |
| 366 | + | |
329 | 367 | | |
330 | 368 | | |
331 | 369 | | |
| |||
380 | 418 | | |
381 | 419 | | |
382 | 420 | | |
383 | | - | |
| 421 | + | |
384 | 422 | | |
385 | 423 | | |
386 | | - | |
| 424 | + | |
| 425 | + | |
387 | 426 | | |
388 | 427 | | |
389 | 428 | | |
| |||
627 | 666 | | |
628 | 667 | | |
629 | 668 | | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
630 | 780 | | |
631 | 781 | | |
632 | 782 | | |
| |||
0 commit comments