Skip to content

feat(analysis): Stellar-aware issue and PR analysis - #206

Open
ZacLou wants to merge 1 commit into
AyinkxLab:mainfrom
ZacLou:feature/stellar-aware-analysis
Open

feat(analysis): Stellar-aware issue and PR analysis#206
ZacLou wants to merge 1 commit into
AyinkxLab:mainfrom
ZacLou:feature/stellar-aware-analysis

Conversation

@ZacLou

@ZacLou ZacLou commented Aug 28, 2026

Copy link
Copy Markdown

Summary

This PR implements detection-driven Stellar/Soroban awareness for the existing Phase 6 issue and PR analysis flows (#203, #204). When Stellar signals are detected in the repository or PR diff, a Stellar-aware section is appended to the prompt covering contract-specific concerns. When not detected, behavior is identical to the current generic review.

Changes

app/services/analysis.py (+140/-5)

  • _FileAdapter — Adapts GitHub file dicts (filename/patch) into detection-compatible objects with .path and .content attributes, so detect_stellar_project() can consume them without re-implementing detection.
  • _adapt_pr_files() — Converts PR changed-file dicts into adapter objects for detection.
  • _adapt_repo_files() — Converts repo file dicts or tuples into adapter objects for detection (supports both dict and tuple forms).
  • _safe_detect() — Wraps detect_stellar_project() with try/except so detection failure never crashes analysis (falls back to generic).
  • analyze_pull_request() — Automatically runs detection on PR files via the adapter. When Stellar signals are found, appends a Soroban review section covering authorization patterns, panic!/unwrap in contract paths, storage keys, extend_ttl, cross-contract calls, and Stellar config files. Returns a stellar_detected boolean flag.
  • analyze_issue() — Accepts an optional repo_files keyword argument. When provided and detection is positive, appends a Stellar guidance section covering Soroban SDK/XDR concerns, contract structure, and network behaviour.

tests/test_stellar_aware_analysis.py (new, 29 tests)

Covers all acceptance criteria from both issues:

#203 (PR analysis):

  • Stellar/Soroban PR receives Stellar-aware review section
  • Non-Stellar PR receives generic review unchanged
  • Detection failure handled safely (generic fallback, no crash)
  • AI failure returns error message (existing behavior)
  • Empty files -> generic review
  • stellar.toml config file triggers detection
  • stellar_detected flag correct in both cases

#204 (Issue analysis):

  • Stellar project issue receives Stellar-aware analysis
  • Non-Stellar project issue excludes Stellar section
  • No repo_files / None / empty -> generic analysis
  • Detection uncertainty falls back safely (no false claims)
  • Detection failure falls back to generic
  • AI failure returns error message
  • Tuple-form repo_files also works

Adapter tests:

  • _FileAdapter path/content attributes
  • Adapter works directly with detect_stellar_project()
  • Missing filename skipped, None patch handled, empty list

Backward compatibility:

  • analyze_issue() without repo_files works as before
  • analyze_pull_request() return dict has expected keys

Design decisions

  1. Detection-driven, not manual flag — Stellar context is derived from file content via detect_stellar_project(), not a manual stellar=true parameter (per Stellar-aware issue analysis #204 requirement).
  2. Adapter pattern_FileAdapter bridges the gap between GitHub API dicts (filename/patch) and the detection module's interface (.path/.content), without modifying detection.
  3. Safe fallback — Any detection failure (exception, no files, low confidence) silently falls back to the generic review. Analysis never crashes.
  4. Prompt injection unchanged — The [CONFIRMED]/[SUGGESTION] labeling and uncertainty framing are preserved in all prompts.
  5. No new data access — Detection only reads data the caller already holds (PR file dicts or repo file lists). No new API calls or permission changes.

Closes #203, Closes #204

…yinkxLab#204)

Add detection-driven Stellar/Soroban awareness to the existing Phase 6
issue and PR analysis flows. When Stellar signals are detected in the
repository or PR diff, a Stellar-aware section is appended to the prompt
covering contract-specific concerns (authorization, storage keys,
extend_ttl, panic!/unwrap in contract paths, cross-contract calls).
When not detected, behavior is identical to the current generic review.

Changes:
- _FileAdapter: adapts GitHub file dicts (filename/patch) into detection-
  compatible objects with .path and .content attributes
- _adapt_pr_files: converts PR changed-file dicts for detect_stellar_project
- _adapt_repo_files: converts repo file dicts/tuples for detection
- _safe_detect: wraps detection with try/except, never crashes analysis
- analyze_pull_request: runs detection on PR files, appends Stellar review
  section when detected, returns stellar_detected flag
- analyze_issue: accepts optional repo_files param, appends Stellar guidance
  section when detection is positive

Tests (29, all passing):
- _PRFileAdapter and adapter coverage
- Stellar PR includes section, non-Stellar PR excludes it
- stellar_detected flag true/false cases
- Detection failure falls back to generic
- AI failure returns error message
- Stellar issue includes section, non-Stellar excludes it
- Detection uncertainty falls back safely
- Backward compatibility (no repo_files = generic)

Closes AyinkxLab#203, Closes AyinkxLab#204
@ZacLou

ZacLou commented Aug 31, 2026

Copy link
Copy Markdown
Author

Hi @AyinkxLab team 👋

A quick follow-up as the Stellar Wave 8 deadline is today (August 31, 2026). If there's any feedback or requested changes, I'm ready to address them right away.

Thank you for reviewing!

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.

Stellar-aware issue analysis Stellar-aware pull request analysis

1 participant