Skip to content

Commit ffae5f2

Browse files
committed
former : plan
1 parent 7881fbd commit ffae5f2

File tree

1 file changed

+32
-11
lines changed

1 file changed

+32
-11
lines changed

module/core/former/plan.md

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,47 +12,53 @@
1212
* Detailed Plan Step 1: Locate the `match &variant.fields` block in `module/core/former_meta/src/derive_former/former_enum.rs`.
1313
* Detailed Plan Step 2: **Unit Variant:** Implement logic: Check `wants_subform_scalar` -> Return `syn::Error`. Otherwise (Default/Scalar) -> Generate Direct Constructor (`Enum::variant() -> Enum`). Generate standalone constructor if enabled.
1414
* Detailed Plan Step 3: **Tuple Variant (len 0):** Implement logic: Check `wants_subform_scalar` -> Return `syn::Error`. Otherwise (Default/Scalar) -> Generate Direct Constructor (`Enum::variant() -> Enum`). Generate standalone constructor if enabled.
15+
* Detailed Plan Step 4: **Enable Tests:** Uncomment tests in `tests/inc/former_enum_tests/unit_variant_*.rs` and relevant zero-field tests in `enum_named_fields_*.rs`.
1516
* Crucial Design Rules: [Handling Panics vs Recoverable Errors](#handling-panics-vs-recoverable-errors).
16-
* Verification Strategy: Compile checks (`cargo check --package former_meta`). Verify `unit_variant_*` and relevant `enum_named_fields_*` tests pass (specifically `variant_zero_unnamed_*`).
17+
* Verification Strategy: Compile checks (`cargo check --package former_meta`). Run enabled tests (`cargo test --package former --test former_enum_test unit_variant_*, enum_named_fields_only_test::variant_zero_unnamed_*`). **Analyze logs critically.**
1718
* ⚫ Increment 7: Implement Logic for Single-Field Tuple Variants
1819
* Goal: Implement and verify logic for Tuple variants with one field.
1920
* Detailed Plan Step 1: Locate `Tuple Variant (len 1)` case in `former_enum.rs`.
2021
* Detailed Plan Step 2: Implement logic: Check `wants_scalar` and `wants_subform_scalar` -> Error.
2122
* Detailed Plan Step 3: If `wants_scalar` -> Generate Direct Constructor (`Enum::variant(InnerType) -> Enum`). Generate standalone constructor if enabled.
2223
* Detailed Plan Step 4: Otherwise (Default/`wants_subform_scalar`) -> Generate Subformer Starter (`Enum::variant() -> InnerFormer<...>`), checking path type requirement. Generate `End` struct and `impl FormingEnd`. Generate standalone constructor if enabled.
24+
* Detailed Plan Step 5: **Enable Tests:** Uncomment tests in `tests/inc/former_enum_tests/basic_*.rs`, `generics_in_tuple_variant_*.rs`, `scalar_generic_tuple_*.rs`.
2325
* Crucial Design Rules: [Handling Panics vs Recoverable Errors](#handling-panics-vs-recoverable-errors).
24-
* Verification Strategy: Compile checks. Verify relevant `basic_*` and `generics_in_tuple_variant_*` tests pass.
26+
* Verification Strategy: Compile checks. Run enabled tests (`cargo test --package former --test former_enum_test basic_*, generics_in_tuple_variant_*, scalar_generic_tuple_*`). **Analyze logs critically.**
2527
* ⚫ Increment 8: Implement Logic for Multi-Field Tuple Variants
2628
* Goal: Implement and verify logic for Tuple variants with more than one field.
2729
* Detailed Plan Step 1: Locate `Tuple Variant (len > 1)` case in `former_enum.rs`.
2830
* Detailed Plan Step 2: Implement logic: Check `wants_scalar` and `wants_subform_scalar` -> Error.
2931
* Detailed Plan Step 3: If `wants_scalar` -> Generate Direct Constructor (`Enum::variant(T1, T2, ...) -> Enum`). Generate standalone constructor if enabled.
3032
* Detailed Plan Step 4: Otherwise (Default/`wants_subform_scalar`) -> Return Error (Subformer not supported for multi-field tuple).
33+
* Detailed Plan Step 5: **Enable Tests:** Uncomment relevant multi-field tuple tests (if any) in `enum_named_fields_*.rs` or other files.
3134
* Crucial Design Rules: [Handling Panics vs Recoverable Errors](#handling-panics-vs-recoverable-errors).
32-
* Verification Strategy: Compile checks. Verify relevant `enum_named_fields_*` tests pass (expecting errors for default multi-field tuple if any exist).
35+
* Verification Strategy: Compile checks. Run enabled tests (expecting errors for default multi-field tuple if any exist). **Analyze logs critically.**
3336
* ⚫ Increment 9: Implement Logic for Zero-Field Struct Variants
3437
* Goal: Implement and verify logic for Struct variants with zero fields.
3538
* Detailed Plan Step 1: Locate `Struct Variant (len 0)` case in `former_enum.rs`.
3639
* Detailed Plan Step 2: Implement logic: Check `wants_subform_scalar` -> Error.
3740
* Detailed Plan Step 3: If `wants_scalar` -> Generate Direct Constructor (`Enum::variant {} -> Enum`). Generate standalone constructor if enabled.
3841
* Detailed Plan Step 4: Otherwise (Default) -> Return `syn::Error`.
42+
* Detailed Plan Step 5: **Enable Tests:** Uncomment relevant zero-field struct tests in `enum_named_fields_*.rs`.
3943
* Crucial Design Rules: [Handling Panics vs Recoverable Errors](#handling-panics-vs-recoverable-errors).
40-
* Verification Strategy: Compile checks. Verify relevant `enum_named_fields_*` tests pass.
44+
* Verification Strategy: Compile checks. Run enabled tests (`cargo test --package former --test former_enum_test enum_named_fields_only_test::variant_zero_scalar_*`). **Analyze logs critically.**
4145
* ⚫ Increment 10: Implement Logic for Single-Field Struct Variants
4246
* Goal: Implement and verify logic for Struct variants with one field.
4347
* Detailed Plan Step 1: Locate `Struct Variant (len 1)` case in `former_enum.rs`.
4448
* Detailed Plan Step 2: Implement logic: Check `wants_scalar` and `wants_subform_scalar` -> Error.
4549
* Detailed Plan Step 3: If `wants_scalar` -> Generate Direct Constructor (`Enum::variant { field: InnerType } -> Enum`). Generate standalone constructor if enabled.
4650
* Detailed Plan Step 4: Otherwise (Default/`wants_subform_scalar`) -> Generate Subformer Starter (`Enum::variant() -> InnerFormer<...>`), checking path type requirement. Generate `End` struct and `impl FormingEnd`. Generate standalone constructor if enabled.
51+
* Detailed Plan Step 5: **Enable Tests:** Uncomment relevant single-field struct tests in `enum_named_fields_*.rs`.
4752
* Crucial Design Rules: [Handling Panics vs Recoverable Errors](#handling-panics-vs-recoverable-errors).
48-
* Verification Strategy: Compile checks. Verify relevant `enum_named_fields_*` tests pass.
53+
* Verification Strategy: Compile checks. Run enabled tests (`cargo test --package former --test former_enum_test enum_named_fields_only_test::variant_one_*`). **Analyze logs critically.**
4954
* ⚫ Increment 11: Implement Logic for Multi-Field Struct Variants - Scalar Case
5055
* Goal: Implement and verify the `#[scalar]` case for multi-field struct variants.
5156
* Detailed Plan Step 1: Locate `Struct Variant (len > 1)` case in `former_enum.rs`.
5257
* Detailed Plan Step 2: Implement logic: Check `wants_scalar` and `wants_subform_scalar` -> Error.
5358
* Detailed Plan Step 3: If `wants_scalar` -> Generate Direct Constructor (`Enum::variant { f1: T1, ... } -> Enum`). Generate standalone constructor if enabled.
59+
* Detailed Plan Step 4: **Enable Tests:** Uncomment relevant multi-field scalar struct tests in `enum_named_fields_*.rs`.
5460
* Crucial Design Rules: [Handling Panics vs Recoverable Errors](#handling-panics-vs-recoverable-errors).
55-
* Verification Strategy: Compile checks. Verify relevant `enum_named_fields_*` tests pass.
61+
* Verification Strategy: Compile checks. Run enabled tests (`cargo test --package former --test former_enum_test enum_named_fields_only_test::variant_two_scalar_*`). **Analyze logs critically.**
5662
***Increment 12: Multi-Field Struct Variant - Subformer - Storage**
5763
* Goal: Generate the implicit storage struct for the default/subform case.
5864
* Hypothesis (H2, H6): The storage struct definition with `Option<FieldType>` for each field and `PhantomData` using `phantom::tuple(&enum_generics_ty)` compiles correctly with the necessary `where` clause (`#merged_where_clause`).
@@ -97,17 +103,31 @@
97103
* Goal: Generate the static method on the enum returning the implicit former.
98104
* Hypothesis (H1, H7, H6): Return type correctly references implicit former with generics. Body calls `ImplicitFormer::begin` correctly.
99105
* Detailed Plan: Implement Step 8h from previous plan.
100-
* Verification Strategy: Compile check. Verify `generics_shared_struct_*` tests now compile (but might fail runtime).
106+
* Verification Strategy: Compile check.
101107
***Increment 21: Multi-Field Struct Variant - Subformer - Standalone Constructor**
102108
* Goal: Generate the standalone constructor (if enabled).
103109
* Hypothesis (H6): Signature, return type (implicit former/Self), and body are correct based on `arg_for_constructor`.
104110
* Detailed Plan: Implement Step 8i from previous plan.
105111
* Verification Strategy: Compile check.
106112
* ⚫ Increment 22: Update Documentation Comment in `former_enum.rs` (Original Step 9).
107113
* ⚫ Increment 23: Verify `generics_shared_struct_*` tests pass.
108-
* ⚫ Increment 24+: Address remaining test files (Renumbered).
109-
* ⚫ Increment N: Update Documentation (`Readme.md`, `advanced.md`).
110-
* ⚫ Increment N+1: Final Verification (Full Test Suite).
114+
* Goal: Ensure the multi-field struct subformer logic works with generics.
115+
* Detailed Plan Step 1: **Enable Tests:** Uncomment tests in `tests/inc/former_enum_tests/generics_shared_struct_*.rs`.
116+
* Verification Strategy: Run enabled tests (`cargo test --package former --test former_enum_test generics_shared_struct_*`). **Analyze logs critically.**
117+
* ⚫ Increment 24: Verify `generics_independent_struct_*` tests pass.
118+
* Goal: Ensure the multi-field struct subformer logic works with independent generics.
119+
* Detailed Plan Step 1: **Enable Tests:** Uncomment tests in `tests/inc/former_enum_tests/generics_independent_struct_*.rs`.
120+
* Verification Strategy: Run enabled tests (`cargo test --package former --test former_enum_test generics_independent_struct_*`). **Analyze logs critically.**
121+
* ⚫ Increment 25: Verify `standalone_constructor_*.rs` tests pass.
122+
* Goal: Ensure standalone constructors work correctly for all implemented variant types.
123+
* Detailed Plan Step 1: **Enable Tests:** Uncomment tests in `tests/inc/former_enum_tests/standalone_constructor_*.rs` and `standalone_constructor_args_*.rs`.
124+
* Verification Strategy: Run enabled tests (`cargo test --package former --test former_enum_test standalone_constructor_*`). **Analyze logs critically.**
125+
* ⚫ Increment 26: Address remaining test files (e.g., `keyword_variant`, `subform_collection_test`).
126+
* Goal: Enable and fix any remaining enum-related tests.
127+
* Detailed Plan Step 1: **Enable Tests:** Uncomment remaining test files in `tests/inc/former_enum_tests/`.
128+
* Verification Strategy: Run enabled tests (`cargo test --package former --test former_enum_test`). **Analyze logs critically.** Fix any failures.
129+
* ⚫ Increment 27: Update Documentation (`Readme.md`, `advanced.md`).
130+
* ⚫ Increment 28: Final Verification (Full Test Suite).
111131

112132
## Notes & Insights
113133

@@ -124,4 +144,5 @@
124144
* **[2024-04-25/Inc 6 Correction 2]** Fixed regressions related to syntax errors (extra commas) and logic errors (`FormingEnd::call`) in generated code for implicit formers.
125145
* **[2024-04-25/Inc 6 Decomposition]** Decomposed Step 8 (Multi-Field Struct Variant - Subformer Case) into smaller sub-steps (8a-8i) to isolate and verify the generation of each implicit former component. Updated plan accordingly. Renumbered subsequent increments.
126146
* **[2024-04-25/Inc 6 Hypothesis]** Confirmed hypotheses for implicit former generation for multi-field struct variants. Key points: generate dedicated former ecosystem for the variant, storage holds `Option<FieldType>` for all variant fields, `preform` returns tuple, former has setters for all variant fields, `End::call` uses preformed tuple to construct variant. Generics handling (H6) and `End::call` logic (H8) require careful implementation.
127-
* **[2024-04-25/Inc 6 Plan Revision]** Further decomposed Increment 6. Will now implement logic for each variant type incrementally (Unit, Tuple(0), Tuple(1), Tuple(N), Struct(0), Struct(1), Struct(N)-Scalar). The complex Struct(N)-Subformer case is broken into multiple increments (12-21) based on verified hypotheses.
147+
* **[2024-04-25/Inc 6 Plan Revision]** Further decomposed Increment 6. Will now implement logic for each variant type incrementally (Unit, Tuple(0), Tuple(1), Tuple(N), Struct(0), Struct(1), Struct(N)-Scalar). The complex Struct(N)-Subformer case is broken into multiple increments (12-21) based on verified hypotheses.
148+
* **[2024-04-25/Plan Update 2]** Added explicit test enabling steps to increments 6-11, 23-26. Renumbered final increments.

0 commit comments

Comments
 (0)