Repository navigation
Declare records with one kiwi_records! row per definition - #7
Conversation
The definition table and both constant modules wrote the schema out twice more, the table one struct field per line. The record runtime now defines kiwi_records!, which expands a row per definition, its fields and enum values one per line, into the same table and constants.
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Expand record schema rows codegen/kiwi_codec/rustler_generator/templates/records.rs |
The new kiwi_records! macro builds the definition table, definition-index constants, field and enum constants, and record structs from schema rows. |
Emit schema rows codegen/kiwi_codec/rustler_generator/records.ex, CHANGELOG.md |
fragments/2 now emits a kiwi_records! row for each definition and removes the previous table and constant generators. The changelog records the output change and the reported Figma schema size reduction. |
Priority:
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Refactor
Possibly related PRs
- open-pencil/kiwi_codec#1: Introduced the records generator and runtime definition types used by this change.
- open-pencil/kiwi_codec#5: Moved the record runtime into
templates/records.rs, where this change addskiwi_records!. - open-pencil/kiwi_codec#6: Established the generated constant paths and names that
kiwi_records!retains.
Merge Risk: 
Minimal · up to e15f7
-
The change appears mergeable after normal checks; no concrete issue requiring a fix has been established.
Pre-merge checks: 
5
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. (1 skipped: 1 unsupported.)
-
Finishing Touches
-
📝 Generate docstrings
-
- Commit to this branch
- Create a new PR
🧪 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.
Comment @coderabbitai help to get the list of available commands.
The records feature used to write the schema out twice. The definition table took one struct field per line, about 6 lines per schema field, and the `kiwi_record_definitions` and `kiwi_records` constants repeated the same ids and values.
The record runtime template now defines a `kiwi_records!` macro, and the generator emits one call to it, with one row per definition and one line per field or enum value:
```rust
kiwi_records! {
MessageType MESSAGE_TYPE 0 0 "MessageType" "Elixir.Figler.Schema.MessageType" [] [
JOIN_START 0 "join_start";
...
];
...
}
```
The call expands to the same `KIWI_RECORD_DEFINITIONS` table and the same constant modules, so code using them doesn't change.
With Figma's schema, Figler's `generated.rs` drops from about 1.7 MB to 1.06 MB, together with Figler's own attribute-chain change. Both `mix ci` here and Figler's `mix ci` pass, apart from Figler's package tests, which can't build a Hex package while dependencies are local paths. The native records crate in the tests builds and round-trips data through the new macro.
Summary by CodeRabbit