Skip to content

feat: implement AI-assisted social & economic impact analysis subcommand - #66

Merged
Nanle-code merged 1 commit into
StarsForges:masterfrom
BigFundz:feat/impact-analysis
Aug 20, 2026
Merged

feat: implement AI-assisted social & economic impact analysis subcommand#66
Nanle-code merged 1 commit into
StarsForges:masterfrom
BigFundz:feat/impact-analysis

Conversation

@BigFundz

Copy link
Copy Markdown
Contributor

Closes #52

PR Description: AI-Assisted Social & Economic Impact Analysis Subcommand

Summary

This PR implements a modular, production-grade Social and Economic Impact Analysis Subcommand (starforge ai impact) to evaluate Soroban/Stellar smart contracts. The subsystem calculates multi-dimensional impact scores (0–100) using a local deterministic engine with optional AI narrative interpretation and robust, dual-layer secret redaction.


Key Features

  1. Modular Architecture (src/commands/ai/impact/):

    • analyzer.rs: Features a static scanner that inspects Rust files for storage operations, loops, and control signatures (e.g. KYC, fee gates, or upgrades), combined with a rule-based evaluation engine.
    • profile.rs: Defines 4 key policy profiles (community, enterprise, public-sector, protocol-maintainer), each specifying unique score thresholds and weights.
    • redactor.rs: An automated sanitizer that redacts home directories, absolute file paths, Stellar Secret Keys (S...), 64-char Hex Keys, and Bearer tokens before forwarding queries to external AI APIs.
    • ai_client.rs: Integrates with OpenAI's API (gpt-4) to produce natural language narratives, fully instrumented with telemetry.
    • mod.rs: Handles metadata file parsing (JSON/TOML), formats output reports (Markdown & JSON), and calculates comparisons between versions of reports.
  2. CLI Registration (src/commands/ai/mod.rs):

    • Registers the starforge ai impact command.
    • Configures argument flags: --file, --profile, --compare, --format, --output, and --deterministic.
  3. CI pipeline & Quality Improvements:

    • Added exhaustive unit tests covering source scanning, scoring limits, missing metadata fallbacks, and redaction patterns.
    • Resolved all pre-existing and new clippy warnings and formatting guidelines.

🧪 Verification & Testing

1. Automated Test Suite

All unit, integration, doc, and E2E smoke tests pass cleanly:

cargo test
./scripts/e2e-smoke.sh

@BigFundz

Copy link
Copy Markdown
Contributor Author

@Nanle-code Please review

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.

[AI-019] Develop AI System for Analyzing Social and Economic Impact of Soroban Contracts

2 participants