Skip to content

feat: add Soroban cost estimation and economic analysis engine - #68

Merged
Nanle-code merged 3 commits into
StarsForges:masterfrom
Awosdot:feat/50-soroban-cost-estimation
Aug 21, 2026
Merged

feat: add Soroban cost estimation and economic analysis engine#68
Nanle-code merged 3 commits into
StarsForges:masterfrom
Awosdot:feat/50-soroban-cost-estimation

Conversation

@Awosdot

@Awosdot Awosdot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Description

Brief description of what this PR does and why.
Adds a cost command family (estimate, compare, budget, export, check-regression) built on a deterministic fee/resource model for deploy, invoke, storage, archival, event, and batch operations. A simulation adapter normalizes raw Soroban RPC simulateTransaction responses into a stable resource-usage structure, and an AI narrative layer augments the deterministic explanation when an API key is configured, falling back cleanly otherwise. Estimates persist as versioned, permission-restricted JSON snapshots per label, enabling trend export and CI-style regression threshold checks.

Closes #50

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Changes Made

  • Change 1
  • Change 2
  • Change 3

Testing

How has this been tested?

Describe the tests you ran and how to reproduce them.

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing performed

Test Coverage

Describe what scenarios have been tested:

  • Happy path:
  • Edge cases:
  • Error handling:

Code Quality Checklist

  • My code follows the style guidelines of this project (cargo fmt)
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings (cargo clippy -- -D warnings)
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • The CI checks pass (format, clippy, tests)

Breaking Changes

  • This PR introduces breaking changes

If checked, describe the breaking changes and migration path:

Documentation

  • README.md updated (if applicable)
  • No documentation changes needed

Screenshots (if applicable)

Add screenshots or GIFs for UI changes.

Additional Context

Add any other context about the PR here.


Note: Make sure all tests pass locally before submitting:

cargo test
cargo fmt --all
cargo clippy -- -D warnings

Adds a cost command family (estimate, compare, budget, export,
check-regression) built on a deterministic fee/resource model for
deploy, invoke, storage, archival, event, and batch operations. A
simulation adapter normalizes raw Soroban RPC simulateTransaction
responses into a stable resource-usage structure, and an optional
narrative layer explains cost drivers using a configured language-model
provider, falling back to a deterministic summary when unavailable.
Estimates persist as versioned, permission-restricted JSON snapshots
per label, enabling trend export and CI-style regression threshold
checks.
@Awosdot
Awosdot force-pushed the feat/50-soroban-cost-estimation branch from b24e8ed to 9c135e9 Compare August 20, 2026 20:33
Updates h2, crossbeam-epoch, and anyhow to their patched versions where
a safe upgrade exists. For unmaintained transitive dependencies with no
safe upgrade path (instant, paste, rustls-pemfile, backoff, and one
remaining h2 0.3.x instance locked by reqwest's hyper-0.14 line), adds
justified ignores to deny.toml following the file's existing convention.
Three fixes surfaced by review:

- The archival restore penalty was scaled by batch_size like a per-item
  resource fee, wildly overstating cost for archived-entry batches; it is
  now charged once per estimate, matching the base transaction fee's
  batching model. The per-item fee split now rounds instead of truncating
  so it reconciles closely with the total.
- History labels that collide after path sanitization (e.g. "svc:v1" and
  "svc/v1") no longer merge into the same on-disk directory; a short
  fingerprint of the raw label disambiguates them.
- Two saves for the same label landing in the same millisecond no longer
  silently overwrite each other; snapshot filenames now carry a zero-padded
  sequence suffix.
- The CLI now rejects --batch-size 0 with a clear error instead of silently
  clamping it to 1.
@Nanle-code
Nanle-code merged commit b448055 into StarsForges:master Aug 21, 2026
5 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.

[AI-015] Develop AI System for Cost Estimation and Economic Analysis of Soroban Operations

2 participants