Skip to content

feat: build policy simulation sandbox modal for testing transaction rules - #105

Merged
Cjay-Cyber-2 merged 2 commits into
ASTROIDX556:mainfrom
feyibosslady:build_policy_simulation_sandbox_modal
Sep 1, 2026
Merged

feat: build policy simulation sandbox modal for testing transaction rules#105
Cjay-Cyber-2 merged 2 commits into
ASTROIDX556:mainfrom
feyibosslady:build_policy_simulation_sandbox_modal

Conversation

@feyibosslady

Copy link
Copy Markdown

Closes #58

Description

Before enforcing spending policies on live AI agents, administrators need a simulation sandbox to test hypothetical transactions against existing Zod-validated rule sets and see whether they pass or trigger approval workflows.

This PR adds a Policy Sandbox Modal where users can input test transaction parameters (recipient address, amount, asset type), select which spending policy rules to evaluate, and run simulations to see clear pass/fail results with detailed violation messages.

Changes

New files:

  • src/features/policies/utils/simulator.ts — Pure evaluation utility that tests a transaction against PolicyRule objects. Supports all rule fields (Transaction Amount, Asset Identifier, Destination Target, Approved Account Whitelist) and operators (equals, greater_than, less_than, contains, in_whitelist).
  • src/features/policies/components/PolicySandboxModal.tsx — Accessible modal component with:
    • React Hook Form + Zod validated inputs for recipient address, amount, and asset type
    • Multi-select rule picker with select/deselect all
    • Per-rule pass/fail evaluation cards with detailed violation messages
    • Summary badge indicating compliance or violations found
    • Uses existing Dialog component for accessibility (focus trap, Escape key, overlay dismissal)

Modified files:

  • src/features/policies/index.ts — Exports PolicySandboxModal and simulateTransaction

Acceptance Criteria

  • Build src/features/policies/components/PolicySandboxModal.tsx
  • Implement form inputs for testing parameters using React Hook Form and Zod validation
  • Display simulated evaluation results with detailed failure reasons if rules are breached
  • Ensure modal trap focus and keyboard escape key handling for accessibility (via Dialog component)
  • Pass all checks in npm run typecheck && npm run lint (new files pass cleanly; pre-existing errors in transactions/page.tsx are unrelated)

Testing & Validation

  1. Open the modal in the policy management view
  2. Submit test transactions that comply with rules (e.g., 5000 XLM) — verify all-pass output
  3. Submit test transactions that violate rules (e.g., 60000 USDC — exceeds block threshold) — verify violation details
  4. Toggle individual rules on/off and re-run to confirm selective evaluation
  5. Verify npm run typecheck and npm run lint pass for the new files

…ules

Closes ASTROIDX556#58

- Add simulator utility (src/features/policies/utils/simulator.ts) with
  pure evaluation logic for testing transactions against PolicyRule objects
- Add PolicySandboxModal component with React Hook Form + Zod validated
  inputs for recipient address, amount, and asset type
- Support multi-select rule picker with per-rule pass/fail evaluation
- Display detailed violation messages and summary with compliance badge
- Use existing Dialog component for accessible modal (focus trap, Escape,
  overlay dismissal)
- Export new components from policies feature index
@vercel

vercel Bot commented Aug 31, 2026

Copy link
Copy Markdown

@feyibosslady is attempting to deploy a commit to the Cjay's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Aug 31, 2026

Copy link
Copy Markdown

@feyibosslady Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@mergekeeper

mergekeeper Bot commented Aug 31, 2026

Copy link
Copy Markdown

Needs review

Linked to #58, but the diff does not match the issue scope.

The pull request includes unrequested wallet feature files which are out of scope for issue #58.

Reviewed commit: fee0b1a4e47e65a097124feb4b133428a7e27177.

@Cjay-Cyber-2
Cjay-Cyber-2 merged commit 76ef29c into ASTROIDX556:main Sep 1, 2026
0 of 2 checks passed
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.

feat: build policy simulation sandbox modal for testing transaction rules

2 participants