feat(pulumi): add CLI filters for preview/up/destroy/refresh/stack#1334
feat(pulumi): add CLI filters for preview/up/destroy/refresh/stack#1334wlami wants to merge 5 commits into
Conversation
Adds 5 TOML filters for the Pulumi CLI, matching the existing OpenTofu/ Ansible/Terraform TOML-based pattern. Filters strip known noise (header banners, View Live URLs, policy pack loading, @ progress spinners, intermediate creating/updating/deleting rows, Duration, Node.js stack trace frames) while preserving resource change rows, policy violations, diagnostics, outputs, and summaries. Measured savings on a real neo-migration AWS project (~30 resources, Pulumi Cloud backend): pulumi up 65.8%, pulumi destroy 72.3%, preview --refresh 40.7%, refresh 34.9%, stack 29.3%. Lower savings on already- compact output (clean preview ~9%) because remaining content is signal per the correctness-over-compression design philosophy. Registers matching RtkRule in src/discover/rules.rs so the rewrite hook transparently proxies `pulumi <subcmd>` through `rtk pulumi`. Bumps BUILTIN_TOML filter count 59 -> 64 and updates the expected-filter list and concat-discoverability test. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Hey @wlami , glad to have you here contributing to RTK Here are few things to be addressed before merging :
Thanks for this addition ! |
- Revert CHANGELOG.md (release-please CICD generates from commit msg) - Narrow pulumi-stack match_command to explicit subcommand whitelist (bare stack, ls, output, history, select, init, rm, rename, tag, unselect, change-secrets-provider). Excludes export (JSON state) and graph (DOT), which now passthrough unfiltered. - Lower savings_pct 70 -> 45 (measured mean across 5 subcommands). Populate subcmd_savings with measured values: up=66, destroy=72, refresh=35, preview=25, stack=29. JSON-safety (self-found during review validation): - All 5 pulumi subcommands support -j/--json; Rust regex crate has no lookahead so match_command can't negatively exclude --json. - Remove max_lines from all 5 filters; strip patterns don't match JSON structure so JSON passes through unfiltered. - Remove ^\\s*\\}\\s*$ strip pattern (was targeting Node.js stack trace trailers, but also matched legitimate JSON closing braces). Verified on neo-migration stack: - pulumi stack ls/output/history/export, preview --json, stack graph: byte-identical with RTK_NO_TOML=1 baseline (filter transparent). - Human-readable preview still compresses (~20% on clean state). - 10/10 inline pulumi tests pass; 1449/0 full cargo test suite. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Hey, thanks for the quick review! Pushed 888d1a8, which addresses all 3 points:
One extra thing I caught while looking at point 2: every pulumi subcommand supports Let me know if there is anything else! |
…cli-filters # Conflicts: # src/core/toml_filter.rs
|
Hey @wlami, thanks for this PR. One change before merge: pulumi-stack strips Current stack is : and Last updated:. Confirmed on real output, stack is read-only (exit 0), so there's no tee fallback and the active-stack identity is irreversibly dropped. It also orphans the indented Managed by line under the removed header. Please keep Current stack is X: (and ideally Last updated:). I'm not a pulumi user so open to any thoughts about this, but RTK principle is stripping noise without loosing signals. |
Stop stripping `Current stack is X:` and `Last updated:`. pulumi stack is read-only (exit 0) so there's no tee fallback; dropping the active stack identity was irreversible signal loss. Keeping the header also fixes the orphaned indented `Managed by <user>` line. Owner: and Pulumi version used: remain stripped as noise. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Good catch, fixed in 1f6e36b.
|
|
Honestly hard to know like this since i'm not working often with pulumi CLI , since you are an pulumi any thoughts on this ? Missing signals can trigger more api turns because agents will retry with "rtk proxy" to get the raw output, which cost more in the end. Waiting for your call, if we already filter enough, we may want to keep this to avoid this |
|
@wlami sorry little missclick on the close button, PR LGTM , about the Owner filter we can drop it if rtk already correct saves on pulumi since we have many signal lost issue and that is a challenge for rtk, i'm in favor of not taking this risk for now and keeping Owner: information |
Per review: avoid signal loss that pushes agents to retry with `rtk proxy`. pulumi-stack now keeps the full stack identity block (Owner:, Pulumi version used:) alongside the header and Last updated:. Only interactive prompt and help-footer noise is stripped. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Agree on the signal-loss risk. pulumi-stack now keeps the full identity block. |
Summary
Adds 5 TOML filters for the Pulumi CLI, matching the existing OpenTofu/ Ansible/Terraform TOML-based pattern. Filters strip known noise (header banners, View Live URLs, policy pack loading, @ progress spinners, intermediate creating/updating/deleting rows, Duration, Node.js stack trace frames) while preserving resource change rows, policy violations, diagnostics, outputs, and summaries.
Registers matching RtkRule in src/discover/rules.rs so the rewrite hook transparently proxies
pulumi <subcmd>throughrtk pulumi. Bumps BUILTIN_TOML filter count 59 -> 64 and updates the expected-filter list and concat-discoverability test.What the filters strip
Verified against real Pulumi Cloud backend output:
Previewing update,Updating (stack),Destroying (stack),Refreshing (stack))View Live:/View in Browser:URL linesLoading policy packs...loader lines@ Previewing update.../@ Updating...progress spinnersDuration:timing footerMore information at:/Usepulumi ...`` hint linescreating (0s)/updating (0s)/deleting (0s)/refreshing (0s)progress rows (finalcreated (0.03s)rows preserve same info)at /path/to/node_modules/...,promise: Promise,[Circular *1])Resources:block)Current stack is dev:/Owner:/Last updated:metadata (stack command)What the filters preserve
Per RTK's correctness-over-compression design philosophy:
+/~/-/+-/++)Resources: + N to createsummarypulumi stackcommand)Measured savings (neo-migration, ~30 AWS resources, Pulumi Cloud backend)
pulumi up(create from empty)pulumi destroy(teardown 30 resources)pulumi preview --refreshpulumi refresh(drift detection)pulumi stackpulumi preview(clean, no noise)Savings are input-dependent: create/destroy lifecycle operations hit >60% because they emit substantial intermediate progress noise. Steady-state operations (clean preview,
stack) produce mostly-signal output where aggressive compression would drop correctness — the filter deliberately stops there.Test plan
[[tests.pulumi-*]]blocks (2 per filter) — all pass viartk verify --filter pulumi-*BUILTIN_TOMLfilter count bumped 59 → 64test_builtin_all_expected_filters_presentupdated with 5 new namestest_new_filter_discoverable_after_concatupdated 60 → 65cargo fmt --all --check— cleancargo clippy --all-targets— 0 errors (only pre-existing warnings untouched)cargo test— 1449 passed, 0 failedrtk pulumi preview|up|destroy|refresh|stackagainst real neo-migration AWS project with 33 resources