Skip to content

feat: fail early when an export cannot fit its index - #120

Merged
peter-gy merged 2 commits into
mainfrom
pgy/plan-index-budget
Oct 25, 2026
Merged

peter-gy merged 2 commits into
mainfrom
pgy/plan-index-budget

Conversation

@peter-gy

Copy link
Copy Markdown
Collaborator

The index value and byte limits were only enforced when index.json was written, after every state had been prepared. A large state space could run for many minutes before it failed on a limit it was always going to exceed.

The producer now projects the fewest values and bytes the index can hold and checks that bound three times:

  • Before any notebook runs, from the spec alone. Build, prepare, plan, and capture fail with export_invalid in about a second, with a message that suggests how many states to keep and the same details keys as ExportIndex.to_bytes().
  • After planning resolves the complete input vectors.
  • After each prepared state commits, counting that state at its exact cost. Preparation stops as soon as the remaining states cannot fit, and the states it already prepared stay reusable for a smaller spec.

The projection measures real index records with the counters to_bytes() uses. Each unprepared output counts at the cheapest entry it can write, so optional outputs count at their unavailable entry. ExportPlan reports the bound as index_budget and lists optional_outputs, and marimo-export plan prints it on an Index line.

The index value and byte limits were only checked when index.json was
written, after every state had been prepared. Planning now projects the
fewest values and bytes the index can hold and fails with export_invalid
before any notebook runs, from the spec alone and again from the resolved
plan. Preparation measures each committed state with the counters
ExportIndex.to_bytes() uses and stops as soon as the remaining states cannot
fit, keeping prepared states reusable. Optional outputs count at their
cheapest unavailable entry. ExportPlan reports the bound as index_budget and
lists optional_outputs, and the CLI plan summary prints it.
Copilot AI balanced review requested due to automatic review settings October 25, 2026 15:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@peter-gy
peter-gy merged commit 86b3eb0 into main Oct 25, 2026
35 of 38 checks passed
@peter-gy
peter-gy deleted the pgy/plan-index-budget branch October 25, 2026 17:19
@github-actions

Copy link
Copy Markdown

marimo-export 0.2.3.dev13 from this pull request is available as a preview build:

uv pip install "marimo-export @ https://github.com/marimo-team/marimo-export/releases/download/preview/marimo_export-0.2.3.dev13-py3-none-any.whl"
pnpm add "https://github.com/marimo-team/marimo-export/releases/download/preview/marimo-team-marimo-export-0.2.3-dev.13.tgz"

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.

2 participants