Skip to content

feat(lint): expose scheduled_events() query function in Starlark rules#692

Open
Andries-Smit wants to merge 2 commits into
mendixlabs:mainfrom
Andries-Smit:feat/lint-scheduledevents-query-function
Open

feat(lint): expose scheduled_events() query function in Starlark rules#692
Andries-Smit wants to merge 2 commits into
mendixlabs:mainfrom
Andries-Smit:feat/lint-scheduledevents-query-function

Conversation

@Andries-Smit

Copy link
Copy Markdown
Contributor

Adds a new scheduled_events() built-in to the linter's Starlark API so star rules can inspect scheduled event configuration (name, microflow, interval, enabled flag).

  • Extends LintReader with ListScheduledEvents() (already implemented by MprBackend and MockBackend — no concrete changes needed there)
  • Adds ScheduledEvent struct and ScheduledEvents() iter.Seq on LintContext; resolves module names from the catalog modules table and converts interval+type to seconds via intervalToSeconds()
  • Registers scheduled_events builtin and adds scheduledEventToStarlark conversion in starlark.go

Adds a new `scheduled_events()` built-in to the linter's Starlark API so
star rules can inspect scheduled event configuration (name, microflow,
interval, enabled flag).

- Extends `LintReader` with `ListScheduledEvents()` (already implemented
  by MprBackend and MockBackend — no concrete changes needed there)
- Adds `ScheduledEvent` struct and `ScheduledEvents() iter.Seq` on
  `LintContext`; resolves module names from the catalog `modules` table
  and converts interval+type to seconds via `intervalToSeconds()`
- Registers `scheduled_events` builtin and adds `scheduledEventToStarlark`
  conversion in `starlark.go`

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

AI Code Review

Review Summary

Moderate Issues

  • Missing test coverage: The PR adds new linter functionality (scheduled_events() Starlark built-in) but includes no test files. According to the checklist, new functionality should have test coverage. Unit tests are needed for:
    • ScheduledEvent struct
    • intervalToSeconds() function
    • ScheduledEvents() method on LintContext
    • Starlark built-in integration

Minor Issues

  • Error handling in intervalToSeconds: Returns 0 for unknown interval types without logging or indication of error. Consider at least documenting this behavior or returning a default with warning.
  • MicroflowName assignment: Sets MicroflowName: string(e.MicroflowID) but MicroflowID is likely a model.ID. Verify this produces the expected qualified name (other similar fields in codebase may provide guidance).

What Looks Good

  • Clean implementation following existing linter patterns (similar to Snippets() method)
  • Proper nil reader handling and error checking
  • Correct catalog usage for module name resolution (moduleName + "." + e.Name)
  • Consistent exclusion pattern (ctx.excluded[moduleName] check)
  • Starlark integration cleanly follows existing built-in patterns
  • Struct includes all relevant fields (name, qualified_name, module_name, microflow_name, interval_seconds, enabled)

Recommendation

Request changes to add appropriate test coverage for the new functionality. The implementation is fundamentally sound and follows project conventions, but lacks the required tests per the checklist. Once tests are added, this PR would be ready for approval.


Automated review via OpenRouter (Nemotron Super 120B) — workflow source

…tion

- Resolve MicroflowID UUID to qualified name via catalog microflows table,
  falling back to raw UUID when catalog is not built
- Document intervalToSeconds zero-return for unrecognised interval types
- Add 5 tests: intervalToSeconds, MicroflowName resolution, excluded modules,
  nil reader, and Starlark builtin end-to-end

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J8txDneDb92yxMgD2LCPkR
@github-actions

Copy link
Copy Markdown

AI Code Review

Critical Issues

None found.

Moderate Issues

None found.

Minor Issues

  • Potential integer overflow in intervalToSeconds: The function intervalToSeconds(interval int, intervalType string) int multiplies interval by large constants (e.g., 31536000 for years) without overflow checking. While Mendix scheduled events typically use small interval values (minutes, hours, days), extremely large values could cause integer overflow and incorrect results. This is low-risk but worth noting.

What Looks Good

  • Comprehensive test coverage: The new test file starlark_scheduledevents_test.go thoroughly tests interval conversion, microflow name resolution, excluded modules, nil reader handling, and Starlark built-in functionality.
  • Clean implementation: The code follows established patterns in the linter package, properly extending LintReader and LintContext with minimal, focused changes.
  • Proper fallback behavior: When catalog queries fail, the code gracefully falls back to using raw IDs rather than crashing.
  • Correct Starlark integration: The built-in function is properly registered and converts ScheduledEvent structs to Starlark values with all relevant fields.
  • No MDL syntax changes: As this is a linter/Starlark API extension (not an MDL feature), it correctly avoids touching the MDL pipeline (grammar, AST, visitor, executor).
  • Scoped changes: The PR is focused on a single feature - exposing scheduled events to Starlark rules - with no unrelated modifications.

Recommendation

Approve. The PR is well-implemented with excellent test coverage and follows project conventions. The minor integer overflow concern is extremely low-risk given the expected values for scheduled event intervals in Mendix applications. No changes are required before merging.


Automated review via OpenRouter (Nemotron Super 120B) — workflow source

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.

1 participant