feat: implement AI-assisted social & economic impact analysis subcommand - #66
Merged
Merged
Conversation
Contributor
Author
|
@Nanle-code Please review |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
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.CLI Registration (
src/commands/ai/mod.rs):starforge ai impactcommand.--file,--profile,--compare,--format,--output, and--deterministic.CI pipeline & Quality Improvements:
🧪 Verification & Testing
1. Automated Test Suite
All unit, integration, doc, and E2E smoke tests pass cleanly:
cargo test ./scripts/e2e-smoke.sh