Skip to content

storm analyze: one command for entity graph cost and the design budget #503

Description

@zantvoort

Two separate pieces of planned work describe the same command.

Part 2 of #325 proposes storm analyze: read the compile-time metamodel index and report, per entity, the eager select join count and a ranked list of Ref candidates by how many joins each cut would save.

docs/entity-design.md describes the entity design budget, a per-table invariant that the inline closure adds at most 10 joins and at most 96 columns beyond the table's own. Generation applies it; enforcement against an existing model was deferred. When it lands it reads the same index and answers the same question, in the same register.

Ship one command, not two verbs that disagree at the margins.

What it reports

Per entity, from the metamodel index:

  • the eager select join count, and the inline closure column count
  • whether either budget is exceeded, and by how much
  • Ref candidates ranked by what each cut removes, in joins and in columns

The win for a field is the size of the subtree that cutting its edge makes unreachable. A table reached by several paths is joined once per path, so cutting a shared hub is worth more than its own size suggests, and the ranking should show that rather than leave it to be inferred.

Reported, never flipped

The command does not rewrite code. An entity over budget produces a diagnostic naming the table and the overrun, and the code is left as written, matching what generation already does when it runs against entities that exist. An entity that diverges is assumed to be doing so deliberately.

Advisory framing throughout: this reports the shape of a graph, it does not prescribe a model.

Opt-in, and gateable

Run on demand, never at boot. A non-zero exit when something is over budget lets a project put it in CI if it wants to; nothing about it fires unless someone asks.

Placement

The npm CLI runs on Node and does init, demo, update, db and mcp. This analysis needs the JVM-side metamodel index, so the analysis itself belongs with the codegen module from #211, with the CLI fronting it and a Maven goal and Gradle task for projects that would rather not add a Node dependency. Sequence it after that module exists.

Relationship to #325

This supersedes part 2 of #325. Part 1 of that issue, the query-time fail-fast when a select would exceed the database's hard join limit, stays there: it is framework work, it runs at query build time rather than on demand, and it is independent of this command.

Tasks

  • Static join-graph analysis over the metamodel index: per-entity join count, closure column count, ranked Ref candidates by win
  • Budget evaluation (10 joins, 96 columns) reported against existing entities, never applied
  • Maven goal and Gradle task, plus the storm CLI front end
  • Non-zero exit on overrun, off unless asked for
  • Docs: reading the report, in entity-design.md

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions