feat(#504): Add AI Contract Debugging Assistant - #586
Merged
Nanle-code merged 2 commits intoJul 23, 2026
Merged
Conversation
Implements the AI contract debugging assistant as described in issue Nanle-code#504. Changes: - src/utils/ai_debugger.rs: Rule-based AI engine with 10 Soroban error patterns (auth, arithmetic, storage, token, panic, WASM, network, TTL, test failures, type/ABI mismatches), stack trace parser, variable state inspector, and 8 unit tests covering all major code paths. - src/commands/ai_debug.rs: CLI command with four subcommands: analyse - analyse error + optional stack trace + variable state explain - explain a named error category in depth inspect - inspect name=value variable pairs for suspicious values test - analyse cargo test failure output and suggest fixes - src/commands/mod.rs: registered pub mod ai_debug - src/utils/mod.rs: registered pub mod ai_debugger - src/main.rs: added AiDebug variant to Commands enum, command_name match arm, result dispatch arm, and recovery hints - src/utils/horizon.rs: fixed pre-existing merge artifact (duplicated fetch_account body using removed ureq crate causing unclosed delimiter) Acceptance criteria met: Error explanations clear (DebugFinding.explanation field) Bug identification accurate (10 pattern matchers with deduplication) Fix suggestions working (DebugFinding.fix_suggestion field) Root cause analysis helpful (DebugFinding.root_cause field) Integration with tests (ai-debug test subcommand)
|
@Kayce10 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! 🚀 |
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.
Summary
Closes #504
Implements a local, rule-based AI debugging assistant that helps developers identify bugs in Soroban smart contracts, understand errors, get fix suggestions, and perform root-cause analysis — all without any external API dependency.
Changes
src/utils/ai_debugger.rs(new — 746 lines)Rule-based analysis engine providing:
AUTH001— Missing/failedrequire_authARITH001— Integer overflow/underflowSTORE001— Storage key not foundTOKEN001— Insufficient token balancePANIC001— Contract runtime panic (unwrap, assert)WASM001— Invalid/corrupt WASM binaryNET001— Contract not found on networkTTL001— Storage entry TTL expired/archivedTEST001— Cargo test assertion failureTYPE001— Argument type/ABI mismatchsrc/commands/ai_debug.rs(new — 365 lines)CLI command
starforge ai-debugwith four subcommands:analyseexplaininspectname=valuevariable pairs for suspicious valuestestcargo testfailure output and suggest fixesRegistration changes
src/commands/mod.rs— addedpub mod ai_debugsrc/utils/mod.rs— addedpub mod ai_debuggersrc/main.rs—AiDebugvariant inCommandsenum, command name, dispatch, and recovery hintssrc/utils/horizon.rs— fixes pre-existing merge artifactThe file contained a duplicated
fetch_accountbody using the removedureqcrate, causing an unclosed-delimiter compile error. Cleaned up to use the existingreqwest-basedHTTP_CLIENTimplementation.Usage Examples
Acceptance Criteria
DebugFindinghas a human-readableexplanationfieldfix_suggestionwith code examplesroot_causefield explains why the error occursai-debug testsubcommand analysescargo testoutput