Skip to content

refactor: rename Magic base actions to pre/post action semantics#1267

Draft
snawaz wants to merge 1 commit into
masterfrom
snawaz/actions
Draft

refactor: rename Magic base actions to pre/post action semantics#1267
snawaz wants to merge 1 commit into
masterfrom
snawaz/actions

Conversation

@snawaz
Copy link
Copy Markdown
Contributor

@snawaz snawaz commented May 29, 2026

Summary

Breaking Changes

  • None
  • Yes — migration path described below

Test Plan

Summary by CodeRabbit

  • Documentation

    • Updated action execution flow documentation to reflect refined terminology for action handling and processing order.
  • Chores

    • Reorganized internal intent action structure and processing logic across the execution pipeline.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 29, 2026

📝 Walkthrough

Walkthrough

This PR refactors base-layer action naming across the MagicBlock validator to improve semantic clarity. It renames standalone_actions to base_pre_actions (actions executing before commits) and renames commit/undelegate action variants from WithBaseActions to BasePostActions with corresponding field names (actions executing after commits/undelegates). The changes are applied consistently across API argument types, core domain objects, service orchestration layers (task builders, callback counters), and all affected test fixtures and integration tests. No functional behavior is modified; this is purely a naming and organizational refactoring.

Suggested reviewers

  • taco-paco
  • GabrielePicco
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch snawaz/actions

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.

Copy link
Copy Markdown
Contributor Author

snawaz commented May 29, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
magicblock-committor-service/src/stubs/changeset_committor_stub.rs (1)

254-297: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Include finalize intents in callback counting.

count_bundle_callbacks still ignores ib.commit_finalize and ib.commit_finalize_and_undelegate. Bundles that carry BasePostActions there will get a shorter callbacks_report from this stub than the real executor produces.

Proposed fix
 fn count_bundle_callbacks(bundle: &ScheduledIntentBundle) -> usize {
     let ib = &bundle.intent_bundle;
+    let count_actions =
+        |actions: &[magicblock_program::magic_scheduled_base_intent::BaseAction]| {
+            actions.iter().filter(|a| a.callback.is_some()).count()
+        };
+    let count_commit = |ct: &CommitType| match ct {
+        CommitType::Standalone(_) => 0,
+        CommitType::BasePostActions { base_post_actions, .. } => {
+            count_actions(base_post_actions)
+        }
+    };
+    let count_undelegate = |ut: &UndelegateType| match ut {
+        UndelegateType::Standalone => 0,
+        UndelegateType::BasePostActions(actions) => count_actions(actions),
+    };
 
-    let from_commit = ib
-        .commit
-        .as_ref()
-        .map(|ct| match ct {
-            CommitType::Standalone(_) => 0,
-            CommitType::BasePostActions {
-                base_post_actions, ..
-            } => base_post_actions
-                .iter()
-                .filter(|a| a.callback.is_some())
-                .count(),
-        })
-        .unwrap_or(0);
+    let from_commit = ib.commit.as_ref().map(count_commit).unwrap_or(0);
 
     let from_cau = ib
         .commit_and_undelegate
         .as_ref()
-        .map(|cau| {
-            let from_commit_action = match &cau.commit_action {
-                CommitType::Standalone(_) => 0,
-                CommitType::BasePostActions {
-                    base_post_actions, ..
-                } => base_post_actions
-                    .iter()
-                    .filter(|a| a.callback.is_some())
-                    .count(),
-            };
-            let from_undelegate = match &cau.undelegate_action {
-                UndelegateType::Standalone => 0,
-                UndelegateType::BasePostActions(actions) => {
-                    actions.iter().filter(|a| a.callback.is_some()).count()
-                }
-            };
-            from_commit_action + from_undelegate
-        })
+        .map(|cau| count_commit(&cau.commit_action) + count_undelegate(&cau.undelegate_action))
+        .unwrap_or(0);
+
+    let from_commit_finalize = ib
+        .commit_finalize
+        .as_ref()
+        .map(count_commit)
+        .unwrap_or(0);
+
+    let from_commit_finalize_and_undelegate = ib
+        .commit_finalize_and_undelegate
+        .as_ref()
+        .map(|cau| count_commit(&cau.commit_action) + count_undelegate(&cau.undelegate_action))
         .unwrap_or(0);
 
     let from_base_pre_actions = ib
         .base_pre_actions
         .iter()
-        .filter(|a| a.callback.is_some())
-        .count();
+        .filter(|a| a.callback.is_some())
+        .count();
 
-    from_commit + from_cau + from_base_pre_actions
+    from_commit
+        + from_cau
+        + from_commit_finalize
+        + from_commit_finalize_and_undelegate
+        + from_base_pre_actions
 }
🤖 Prompt for 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.

In `@magicblock-committor-service/src/stubs/changeset_committor_stub.rs` around
lines 254 - 297, count_bundle_callbacks currently sums callbacks from ib.commit,
ib.commit_and_undelegate, and ib.base_pre_actions but omits ib.commit_finalize
and ib.commit_finalize_and_undelegate; update the logic to include those two by
mirroring the existing counting approach: for ib.commit_finalize (and for the
commit part of ib.commit_finalize_and_undelegate) count BasePostActions entries
with a Some(callback) similar to how from_commit/from_cau are computed, and for
commit_finalize_and_undelegate also add the undelegate part (counting actions
with callback.is_some()) so the total includes finalize intents; reference the
existing variables/branches handling CommitType::BasePostActions and
UndelegateType::BasePostActions to implement this.
🤖 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.

Outside diff comments:
In `@magicblock-committor-service/src/stubs/changeset_committor_stub.rs`:
- Around line 254-297: count_bundle_callbacks currently sums callbacks from
ib.commit, ib.commit_and_undelegate, and ib.base_pre_actions but omits
ib.commit_finalize and ib.commit_finalize_and_undelegate; update the logic to
include those two by mirroring the existing counting approach: for
ib.commit_finalize (and for the commit part of
ib.commit_finalize_and_undelegate) count BasePostActions entries with a
Some(callback) similar to how from_commit/from_cau are computed, and for
commit_finalize_and_undelegate also add the undelegate part (counting actions
with callback.is_some()) so the total includes finalize intents; reference the
existing variables/branches handling CommitType::BasePostActions and
UndelegateType::BasePostActions to implement this.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 69750cb7-1f2c-42bc-9b42-21705d20ff37

📥 Commits

Reviewing files that changed from the base of the PR and between b2ab11b and d79fb64.

📒 Files selected for processing (11)
  • magicblock-committor-service/src/intent_executor/mod.rs
  • magicblock-committor-service/src/persist/commit_persister.rs
  • magicblock-committor-service/src/stubs/changeset_committor_stub.rs
  • magicblock-committor-service/src/tasks/task_builder.rs
  • magicblock-magic-program-api/src/args.rs
  • magicblock-magic-program-api/src/instruction.rs
  • programs/magicblock/src/magic_scheduled_base_intent.rs
  • programs/magicblock/src/schedule_transactions/process_schedule_commit_tests.rs
  • test-integration/programs/flexi-counter/src/processor/schedule_intent.rs
  • test-integration/test-committor-service/tests/test_intent_executor.rs
  • test-integration/test-committor-service/tests/test_transaction_preparator.rs

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.

1 participant