Improve macro compile-time diagnostics and key resolution validation#73
Improve macro compile-time diagnostics and key resolution validation#73
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
18044ea to
29bad92
Compare
There was a problem hiding this comment.
adiman9 has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.
29bad92 to
8f23f4c
Compare
Greptile SummaryThis PR introduces a substantial compile-time validation pipeline for Key observations:
Confidence Score: 3/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[#hyperstack macro invoked] --> B{ItemMod or ItemStruct?}
B -->|ItemMod| C[process_module]
B -->|ItemStruct| D[process_entity_struct_with_idl]
D --> E[Parse field attributes\n#map #event #aggregate #resolve #view]
E --> F{parse_recognized_field_attribute}
F -->|Map/FromInstruction| G[parse_map_attribute\nvalidate strategy / condition / join_on]
F -->|Event| H[parse_event_attribute\nvalidate from / lookup_by]
F -->|Resolve| I[parse_resolve_attribute\nvalidate URL template / resolver type]
G & H & I --> J[Accumulate:\nsources_by_type\nevents_by_instruction\nderive_from_mappings\naggregate_conditions]
J --> K[validate_semantics]
K --> L[validate_key_resolution_paths]
L --> L1[validate_source_handler_keys\ncheck primary_key / lookup_by / join_on / resolver_hook]
L --> L2[validate_event_handler_keys\ncheck lookup_by / join_on / capture_fields]
L --> L3[validate_instruction_hook_keys\ncheck derive_from field or lookup_by]
K --> M[validate_mapping_references\nIDL field validation per source type]
K --> N[validate_event_references\nIDL capture_field validation per instruction]
K --> O[validate_derive_from_references\nIDL field lookup per instruction hook]
K --> P[validate_aggregate_conditions\ncondition leaf vs IDL instruction/account fields]
K --> Q[validate_resolve_specs\nfrom / schedule_at / condition vs entity fields]
K --> R[validate_views\nSort/MaxBy/MinBy/Filter field vs entity fields\nduplicate ID check]
K --> S[validate_computed_fields\nfield refs vs entity fields\ncycle detection]
K -->|All errors collected| T{ErrorCollector.finish}
T -->|errors empty| U[Proceed to codegen]
T -->|errors present| V[combine_errors → compile error with spans]
Prompt To Fix All With AIThis is a comment left during a code review.
Path: docs/plans/entropy-capture-implementation.md
Line: 1-5
Comment:
**Planning document accidentally included in the PR**
The PR description explicitly states:
> "this branch was rewritten to remove accidentally committed planning docs and IDL fixtures, so the PR now reflects only the compiler and runtime changes still intended for merge"
Despite this, `docs/plans/entropy-capture-implementation.md` (1,252 lines) has been added to the diff. Its status header reads `Status: Planning`, confirming this is an internal design document that was not intended for this PR.
This should be removed from the branch before merging.
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: hyperstack-macros/src/validation/mod.rs
Line: 158-162
Comment:
**Contradictory `is_event_source` comments introduced in the same PR**
Two new comments added in this PR directly contradict each other.
`validation/mod.rs` (here, lines 159–160) says:
```rust
// Event-derived MapAttributes are validated here first (before being merged into
// sources_by_type for codegen). They have is_event_source=true and are created
// in handlers.rs, while other mappings in entity.rs have is_event_source=false.
```
`stream_spec/entity.rs` (lines 101–105, also new in this PR) says:
```rust
// NOTE: is_event_source=false is correct here.
// ...
// is_event_source=true and validated separately via validate_event_handler_keys
is_event_source: false,
```
One comment says event-derived `MapAttribute` values have `is_event_source=true`; the other says `false` is correct. Both are new in this PR. Neither is accurate: every construction site sets `is_event_source: false`, and no code path ever sets it to `true`.
The comment here should be updated to match `entity.rs`, for example:
```rust
// Event-derived MapAttributes live in `events_by_instruction` and are validated
// via `validate_event_handler_keys`. Sources in `sources_by_type` always have
// `is_event_source=false`; the guard below (`all(|m| m.is_event_source)`) is
// intentionally dead scaffolding for a future migration path.
```
Or, if the dead guard is not intended for future use, remove it along with the misleading comment.
How can I resolve this? If you propose a fix, please make it concise.Reviews (54): Last reviewed commit: "chore: Update stacks" | Re-trigger Greptile |
- Add IDL validation for capture_fields_legacy (was silently bypassed) - Store per-transform key_span in ViewTransform variants (Sort, MaxBy, MinBy) - Report field errors at the correct transform location instead of sharing a single sort_key_span across all key-bearing transforms
- Update version numbers from 0.2 to 0.5 - Fix broken docs/quickstart/react.mdx link path - Add missing hyperstack-idl to packages table - Update repository and project structure sections - Add note about hyperstack-idl independent versioning
- Add attr_span tiebreaker to stable_event_mapping_cmp for total order - Move join_on validation to pre-loop pass so errors aren't masked by IDL failures
- Add __account_address lookup-path bypass to validate_event_handler_keys - Add attr_span tiebreaker to stable_map_attribute_cmp for total order - Remove redundant IDL re-resolution for legacy events - Improve TODO comment for event aggregate conditions
- Check field_transforms to verify __account_address is mapped to a lookup-index-backed target field, rather than incorrectly checking capture_fields for lookup-index fields
- Fix __account_address check to handle default identity mapping - Add warning for event-backed aggregate conditions with no IDL source - Combine ItemMod and ItemStruct parse errors for clearer diagnostics
The warning was printing on every build for users with valid event-driven aggregates. Remove it and rely on the TODO comment to track the gap.
- Add round-trip deserialization check for embedded stream specs - Warn about non-resolving lookup_by when join_on handles key resolution - Add debug_assert! to document is_event_source defensive guard
- Change misleading 'Warn' comments to 'Error' where hard errors are emitted - Add FIXME note about eprintln! that should become a proper diagnostic - Expand TODO with detailed explanation and issue reference placeholder
- Use precise span for join_on errors (token span instead of attribute span) - Add defensive debug_assert for aggregate conditions with mismatched sources - Deduplicate capture_fields errors across events in a group
- Fix debug_assert to check specific bare field targets instead of all mappings - Add __ prefix filtering for condition leaf validation to avoid false-positive errors on sentinel fields
- Remove dead parse_condition_expression wrapper that silently discarded errors - Update tests and docs to use parse_condition_expression_strict instead
6a44347 to
286cf5e
Compare
286cf5e to
2f838c7
Compare
|
Greptile encountered an error while reviewing this PR. Please reach out to support@greptile.com for assistance. |
Summary
hyperstack-macrosvalidation pipeline so attribute parsing preserves source spans, validates arguments eagerly, and reports actionable compile-time errors instead of opaque expansion failures#[map],#[resolve],#[aggregate],#[event],#[view], and top-level macro arguments, plus resolver and computed-field validation paths#[derive_from]hooks so entities must prove a path back to their primary key_addressas aliases for the underlying lookup field when resolving handlersWhat Changed
hyperstack-macrosto accumulate and surface multiple validation errors with source-aware spanslookup_by, or resolver hooksCommit Breakdown
fix: surface hyperstack macro validation failures during expansionchore: refresh ore generated stack artifactschore: format touched runtime cratesfix: validate handler key resolution paths during macro expansionReviewer Notes
bb6d515and8f23f4c; the other two commits are generated artifact refreshes and formatting follow-upTesting
hyperstack-macros/tests/