Skip to content

feat(cli): Add prune summary information#3456

Merged
c-r33d merged 2 commits into
mainfrom
summary-prune
May 11, 2026
Merged

feat(cli): Add prune summary information#3456
c-r33d merged 2 commits into
mainfrom
summary-prune

Conversation

@c-r33d

@c-r33d c-r33d commented May 11, 2026

Copy link
Copy Markdown
Contributor

Proposed Changes

1.) Add code for outputting a prune summary
2.) Break up summary information for prune and migration
3.) Add a summary renderer in-charge of styling and outputting the overall structure of the different information

Summary by CodeRabbit

Release Notes

  • New Features

    • Prune operations now track and display execution results in summaries.
    • Enhanced structured formatting for policy migration and prune summaries with styled presentation.
  • Improvements

    • Refined review descriptions for pruned policy items with consistent key-value formatting.
    • Optimized nil handling in action retrieval logic.

Review Change Stack

@c-r33d
c-r33d requested a review from a team as a code owner May 11, 2026 13:20
@coderabbitai

coderabbitai Bot commented May 11, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This PR refactors the namespaced policy migration and prune summary/review rendering infrastructure. It introduces a unified summary rendering pipeline (summary_renderer.go), adds Execution result tracking to prune plans, implements structured detail formatting for prune operations (prune_details.go and prune_summary.go), and updates migration summary logic to use the new pipeline while adding styled display support for policy objects.

Changes

Namespaced Policy Summary & Review Rendering Refactor

Layer / File(s) Summary
Data Model Extensions
otdfctl/migrations/namespacedpolicy/prune_plan.go
Five prune plan structs gain an Execution *ExecutionResult field with accessor methods. TargetRef.String() is refactored to a compact id: "..." namespace: "..." format with a targetRefSummary helper.
Summary Rendering Framework
otdfctl/migrations/namespacedpolicy/summary_renderer.go
New file implements renderSummaryDocument to build human-readable summary strings with titles, scopes, counts, and per-status item sections, supporting both migration and prune operations via operation-kind abstraction.
Prune Detail Formatting
otdfctl/migrations/namespacedpolicy/prune_details.go
New file provides helpers to format prune-detail key/value pairs (source ID, attribute value, actions, context, targets) in both plain and styled forms, and implements pruneDetails methods on each prune plan type.
Prune Summary Rendering
otdfctl/migrations/namespacedpolicy/prune_summary.go
New file exports RenderNamespacedPolicyPruneSummary/RenderNamespacedPolicyPruneSummaryWithResult and provides section summarizers for each prune scope with execution classification and per-item status rendering.
Migration Summary Refactoring
otdfctl/migrations/namespacedpolicy/migration_summary.go
renderNamespacedPolicySummary delegates to renderSummaryDocument via planScopes helper. All summarize* functions use the new constructSummary/summaryLines structure and recordConstructTargetStatus for counting. Execution classification updated to operationExecutionState.
Display Styling
otdfctl/migrations/namespacedpolicy/policy_formatting.go
Adds styledPolicyActionNamesSummary, styledRegisteredResourceSourceSummary, styledRegisteredResourceValuesSummary, and styledRegisteredResourceActionAttributeValuesSummary functions using DisplayStyles. Updates client ID formatting to use : delimiter.
Review & Interactive Wiring
otdfctl/migrations/namespacedpolicy/prune_review.go
reviewSummary() implementations for all prune types now call shared renderPruneReviewDescription instead of building descriptions inline. Removed text constants, strings import, and targetRefsSummary helper.
Plan Actions Cleanup
otdfctl/migrations/namespacedpolicy/prune_planner.go
Removes nil check in action loop condition; now skips only empty-ID actions.
Migration Review Cleanup
otdfctl/migrations/namespacedpolicy/migration_review.go
Removes unused actionLabel helper function.
Tests & Helpers
otdfctl/migrations/namespacedpolicy/*_test.go, otdfctl/migrations/namespacedpolicy/summary_test_helpers_test.go
Deletes TestFormatSummaryCounts, TestRecordTargetStatus and related test helpers from migration_summary_test.go. Moves stripANSI to summary_test_helpers_test.go. Updates test expectations for TargetRef string format and prune review descriptions to structured key/value style. Adds comprehensive prune summary test coverage (dry-run, committed, per-scope, mismatch scenarios).

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • opentdf/platform#3411: Introduced prune plan types and planner; this PR extends prune types with Execution fields and adds summary/rendering support.
  • opentdf/platform#3360: Makes overlapping changes to namespacedpolicy migration rendering, display styles, and target/execution status handling.
  • opentdf/platform#3304: Modifies migration plan execution model with ExecutionResult fields and target-stringification logic.

Suggested labels

comp:policy, size/xl

Suggested reviewers

  • elizabethhealy
  • alkalescent
  • jakedoublev

Poem

🐰 From scattered labels to a unified pen,
The summary renderers gather up again,
With ExecutionResult fields shining bright,
Prune details styled both left and right,
A migration dance in structured light! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(cli): Add prune summary information' clearly reflects the main changeset, which adds new prune summary rendering functionality and refactors migration summaries.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch summary-prune

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

Copy link
Copy Markdown
Contributor
Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 144.433712ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 70.62363ms

Benchmark Statistics

Name № Requests Avg Duration Min Duration Max Duration

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 357.68578ms
Throughput 279.57 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 36.022291446s
Average Latency 358.892379ms
Throughput 138.80 requests/second

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@otdfctl/migrations/namespacedpolicy/summary_test_helpers_test.go`:
- Around line 5-8: Rename and reuse the compiled regex in stripANSI: move the
regexp.MustCompile(`\x1b\[[0-9;]*m`) out of the stripANSI function into a
package-level variable (e.g., ansiEscapeRE or ansiEscapeRegexp) so it is
compiled once, replace the local tidyWhitespace name with that clearer
identifier, and have stripANSI call ansiEscapeRE.ReplaceAllString(value, "") to
remove ANSI sequences; ensure you use regexp.MustCompile for initialization so
failures are caught at startup.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: e9f1d83c-7f9f-4559-b1ec-39e250954a8d

📥 Commits

Reviewing files that changed from the base of the PR and between 6a0b3c6 and c98dc7b.

📒 Files selected for processing (15)
  • otdfctl/migrations/namespacedpolicy/migration_review.go
  • otdfctl/migrations/namespacedpolicy/migration_summary.go
  • otdfctl/migrations/namespacedpolicy/migration_summary_test.go
  • otdfctl/migrations/namespacedpolicy/policy_formatting.go
  • otdfctl/migrations/namespacedpolicy/policy_formatting_test.go
  • otdfctl/migrations/namespacedpolicy/prune_details.go
  • otdfctl/migrations/namespacedpolicy/prune_plan.go
  • otdfctl/migrations/namespacedpolicy/prune_plan_test.go
  • otdfctl/migrations/namespacedpolicy/prune_planner.go
  • otdfctl/migrations/namespacedpolicy/prune_review.go
  • otdfctl/migrations/namespacedpolicy/prune_review_test.go
  • otdfctl/migrations/namespacedpolicy/prune_summary.go
  • otdfctl/migrations/namespacedpolicy/prune_summary_test.go
  • otdfctl/migrations/namespacedpolicy/summary_renderer.go
  • otdfctl/migrations/namespacedpolicy/summary_test_helpers_test.go
💤 Files with no reviewable changes (2)
  • otdfctl/migrations/namespacedpolicy/migration_review.go
  • otdfctl/migrations/namespacedpolicy/migration_summary_test.go

Comment thread otdfctl/migrations/namespacedpolicy/summary_test_helpers_test.go
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Govulncheck found vulnerabilities ⚠️

The following modules have known vulnerabilities:

  • examples
  • otdfctl
  • sdk
  • service
  • lib/fixtures
  • tests-bdd

See the workflow run for details.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

Gemini encountered an error creating the summary. You can try again by commenting /gemini summary.

@c-r33d
c-r33d added this pull request to the merge queue May 11, 2026
Merged via the queue into main with commit c900c53 May 11, 2026
43 checks passed
@c-r33d
c-r33d deleted the summary-prune branch May 11, 2026 16:32
JBCongdon pushed a commit to JBCongdon/platform that referenced this pull request May 24, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.32.0](opentdf/platform@otdfctl/v0.31.0...otdfctl/v0.32.0)
(2026-05-19)


### Features

* **cli:** Add better unit testing.
([opentdf#3378](opentdf#3378))
([3ad33dc](opentdf@3ad33dc))
* **cli:** Add interactive review for prune plans
([opentdf#3421](opentdf#3421))
([c11680b](opentdf@c11680b))
* **cli:** Add prune confirmation.
([opentdf#3469](opentdf#3469))
([c6d47ec](opentdf@c6d47ec))
* **cli:** Add prune planner.
([opentdf#3411](opentdf#3411))
([3e294e6](opentdf@3e294e6))
* **cli:** Add prune summary information
([opentdf#3456](opentdf#3456))
([c900c53](opentdf@c900c53))
* **cli:** add sensitive flag annotation to DocFlag
([opentdf#3457](opentdf#3457))
([98f48d2](opentdf@98f48d2))
* **cli:** Confirm and execute pruning of legacy objects
([opentdf#3458](opentdf#3458))
([24c09dd](opentdf@24c09dd))
* **cli:** Print report on failure
([opentdf#3365](opentdf#3365))
([05a4473](opentdf@05a4473))
* **cli:** Sort parameters.
([opentdf#3478](opentdf#3478))
([73ad878](opentdf@73ad878))
* **policy:** Add FQN to RegisteredResourceValues
([opentdf#3446](opentdf#3446))
([3199583](opentdf@3199583))
* **policy:** Add resource mapping group FQNs
([opentdf#3447](opentdf#3447))
([6a0b3c6](opentdf@6a0b3c6))


### Bug Fixes

* **cli:** Prune was not classifying multi-namespaced RRs properly.
([opentdf#3488](opentdf#3488))
([eae8645](opentdf@eae8645))
* **cli:** support json profile output
([opentdf#3448](opentdf#3448))
([61f194c](opentdf@61f194c))
* **deps:** bump github.com/opentdf/platform/lib/identifier from 0.3.0
to 0.4.0 in /otdfctl
([opentdf#3367](opentdf#3367))
([aa23179](opentdf@aa23179))
* **deps:** bump github.com/opentdf/platform/protocol/go from 0.27.0 to
0.28.0 in /otdfctl
([opentdf#3419](opentdf#3419))
([c80374f](opentdf@c80374f))
* **deps:** bump github.com/opentdf/platform/sdk from 0.16.0 to 0.17.0
in /otdfctl ([opentdf#3397](opentdf#3397))
([bb9fcd6](opentdf@bb9fcd6))
* **deps:** bump go.opentelemetry.io/otel from 1.40.0 to 1.41.0 in
/otdfctl ([opentdf#3400](opentdf#3400))
([5631c37](opentdf@5631c37))
* **deps:** bump module protocol/go to v0.30.0 throughout
([opentdf#3459](opentdf#3459))
([8eaa502](opentdf@8eaa502))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: opentdf-automation[bot] <149537512+opentdf-automation[bot]@users.noreply.github.com>
Co-authored-by: Chris Reed <87077975+c-r33d@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants