Skip to content

Add preview mode for update actions#1945

Open
MrAnayDongre wants to merge 2 commits into
cocoindex-io:mainfrom
MrAnayDongre:anay/issue-1890-preview-clean
Open

Add preview mode for update actions#1945
MrAnayDongre wants to merge 2 commits into
cocoindex-io:mainfrom
MrAnayDongre:anay/issue-1890-preview-clean

Conversation

@MrAnayDongre
Copy link
Copy Markdown
Contributor

@MrAnayDongre MrAnayDongre commented May 6, 2026

Summary

Adds preview mode for update actions in both the Python API and CLI.

With preview enabled, CocoIndex computes the same target actions as a normal update, but does not apply them to real targets and does not commit internal tracking state.

Closes #1890.

API and CLI

Preview is supported in:

  • App.update(..., preview=True)
  • App.update_blocking(..., preview=True)
  • cocoindex update --preview

For the Python API, preview returns the planned action objects.
For the CLI, preview prints the planned actions.

Implementation

This reuses the existing planning path instead of introducing a separate planner.

In preview mode:

  • reconciliation still runs through pre_commit(...)
  • planning runs in a standalone write transaction
  • that transaction is dropped without commit
  • sink.apply(...) is skipped
  • the later commit phase is skipped

This keeps preview aligned with normal update behavior while remaining read-only.

First pass scope

This first pass supports flat / leaf target actions only.

If a target requires child target providers, preview fails clearly instead of returning partial output.

CLI behavior

Added:

  • cocoindex update ... --preview

Tests

Added coverage for:

  • sync preview returns actions without writing
  • async preview returns actions without writing
  • preview rejects child target providers
  • CLI preview prints planned actions

Validation

Ran locally:

  • cargo fmt --check
  • cargo test
  • uv run mypy
  • uv run pytest python/tests/core -q
  • uv run pytest python/tests/internal -q
  • uv run pytest python/tests/cli/test_cli.py -q

MrAnayDongre and others added 2 commits May 5, 2026 22:15
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@MrAnayDongre MrAnayDongre marked this pull request as ready for review May 7, 2026 22:16
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.

[FEATURE] support shadow run / preview

1 participant