Skip to content

feat: adding expensive AI deployment - #1

Closed
cloudsealed wants to merge 31 commits into
mainfrom
demo-viral-firewall
Closed

cloudsealed wants to merge 31 commits into
mainfrom
demo-viral-firewall

Conversation

@cloudsealed

Copy link
Copy Markdown
Owner

No description provided.

cloudsealed and others added 30 commits March 21, 2026 22:55
Expanded the README to provide a detailed overview of the JIT-Optimization-Engine, including technical architecture, application in FinOps, and quick start instructions.
Library, CLI and FastAPI service sharing one analysis core:
- parsing.py normalises AWS CUR / GCP / Azure / generic exports into a
  gap-free daily series, counting rejected rows instead of dropping them.
- kernels.py: centred rolling median, MAD, modified z-score; numba-
  compiled when available with an identical pure-NumPy fallback.
- analysis.py: day-of-week baseline, robust anomaly detection, waste
  metric and derived recommendations that state their assumptions.
- cli.py and api.py expose the same analyze() with no second code path.

Packaged for PyPI as cloudsealed-jit; 27 tests over parsing, analysis
and the HTTP API.
- Dockerfile: multi-stage build, unprivileged runtime user, exposes 8091.
- CI runs the test suite on Python 3.10-3.12 and reproduces the method
  benchmark as a regression gate.
- CODE_OF_CONDUCT / COMMUNITY / CONTRIBUTING for open-source consumers.
benchmarks/masking_benchmark.py quantifies, on synthetic bills whose
anomalies are known by construction (fixed seed, no private data), the
advantage of the robust method over the textbook mean+stddev z-score:
end-to-end F1 0.667 -> 1.000. Isolated scenarios attribute the gain to
the MAD scale (masking) and the day-of-week baseline (seasonality)
separately. --check runs in CI and fails on regression.

METHODOLOGY.md documents the derivation and cites Iglewicz & Hoaglin
(1993); architecture.md replaces the legacy HPMCE description with the
real module layout.
The proven adoption pattern for this category (Infracost) is showing
the finding where the developer already is, before merge — not a
tool they have to remember to run. This composite action wraps the
published cloudsealed-jit package: analyse a billing CSV in CI and
post/update a single PR comment with the anomaly table and top
recommendations (scripts/post_pr_comment.py, stdlib-only). An optional
fail-on-severity gate blocks the merge on anomalies at or above a
chosen severity (scripts/severity_gate.py).

The repository dogfoods its own action in
.github/workflows/example-usage.yml against examples/sample-billing.csv
on every push, so the action is exercised by a real workflow run, not
just unit tests.
Description/topics on GitHub still referenced the old LLVM/HFT scaffold;
fixed via API to match the current billing anomaly detection scope.
Dead code from before the project became cloudsealed_jit — not referenced
by the package, tests, CI, or docs (pyproject.toml already excludes src/
from the build). Confusing for external readers evaluating the repo.
Follow-up to ca09dec: this test only exercised the removed HFT scaffold,
not the real cloudsealed_jit package. 27 tests pass without it.
- notify.py: optional webhookUrl on the API request and --webhook-url CLI
  flag, auto-detects Slack incoming webhooks, POSTs the full result to any
  other listener (Teams/PagerDuty/custom). Fires only on HIGH/CRITICAL
  anomalies; network failures never fail the analysis.
- report.py: --html CLI flag writes a self-contained report (inline CSS,
  no CDN) for demos and sharing.

Both were the most commonly cited gaps against commercial FinOps tools
(Vantage, CloudZero, Finout) without pulling in a database or a served
dashboard, which this project deliberately avoids.
FOCUS (FinOps Open Cost and Usage Specification) is the vendor-neutral
billing format AWS/GCP/Azure/OCI now export natively. Recognizes its
canonical columns (ChargePeriodStart, BilledCost/EffectiveCost, ServiceName),
so one analysis runs across any cloud's export unchanged — the foundation
for vendor-neutral multi-cloud analysis. The ISO-8601 date parser already
handled FOCUS timestamps; this is column detection only. 2 new tests (39).

AGENTS.md gives AI coding agents explicit when-to-use / when-not-to-use
guidance so they pick this tool instead of re-deriving the method. Bump 0.2.2.
Anomaly detection is reactive — it reports a spike after it happens. The
forecast is proactive: it extrapolates the observed level trend (rolling-
median slope) forward, carries the same weekday seasonality the baseline
uses, and — given a budget — predicts the day the trend crosses it. On a
rising series this beats the old flat mean*30 run rate, which understates
growth.

It is a mechanical extrapolation, not a probabilistic prediction: the
Forecast object exposes projectedSpend, dailyTrend, and budgetBreachDay so
the number is auditable. Wired through CLI (--budget), API (optional budget
field), and the MCP tool. The API response includes forecast only when
requested (response_model_exclude_none), keeping the frozen Framework4D
contract byte-identical. 44 tests + masking benchmark green. Bump 0.3.0.
Add two companion benchmarks alongside masking_benchmark.py so the IEEE
Access paper's comparison against established detectors is reproducible
from the repo:

- sota_comparison.py: full shipped method vs Isolation Forest,
  STL residual + 3-sigma, and Seasonal-Hybrid ESD on the same three
  scenarios (same seeds, same ground-truth scoring).
- montecarlo_robustness.py: repeats each scenario over N randomized
  trials (random spike positions, jittered magnitudes, fresh noise) and
  reports mean +/- std F1 plus the win rate of the shipped method.

Extra detectors live behind a new optional 'bench' extra
(scikit-learn, statsmodels, scipy); the core package and the headline
masking benchmark keep numpy as their only runtime dependency, so CI is
unaffected.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Shape the synthetic end-to-end bill from a real Google Cloud service mix
(gcp_calibrated_profile.json: service-level proportions only, no account
or project identifiers, no amounts) so the benchmark's structure -- a
~79% always-on database floor plus ~21% deploy/traffic-driven services --
is real rather than invented.

Only the structure is calibrated from real data; the weekly seasonality
and labeled anomalies are injected synthetically, keeping ground truth
exact. On this harder, more realistic series the shipped method still
leads every detector (mean F1 1.000 vs 0.968 for the next best over 300
randomized runs).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…e historical baseline and AI Firewall features
@github-actions

Copy link
Copy Markdown

💰 cloudsealed-jit — billing waste audit

Analysed 31 day(s) of billing (124 line items) totalling USD 23,990.88. Mean daily spend USD 773.90, stability ratio 1.86. 3 anomalous day(s) detected; 11.9% of total spend sits above the modelled baseline. Identified up to USD 16,341.33 in addressable monthly spend.

Waste Avg daily cost Stability Anomalies
11.9% $773.90 1.86 3

Anomalies

Date Severity z-score Deviation
2026-07-19 CRITICAL 165.6 +327.1% Spend above the day-of-week baseline by USD 2,229.69 (327.1%).
2026-07-27 CRITICAL 47.2 +87.9% Spend above the day-of-week baseline by USD 635.37 (87.9%).
2026-07-26 LOW -3.7 -7.1% Spend below the day-of-week baseline by USD 50.33 (7.1%).

Top recommendations

  • Sustained baseline eligible for commitment pricing — $4,919.93/mo, effort MEDIUM
  • Idle weekend spend in EC2 — $4,731.92/mo, effort LOW
  • Investigate spend above the modelled baseline — $2,772.64/mo, effort MEDIUM
  • Idle weekend spend in RDS — $1,628.87/mo, effort LOW
  • Spend concentrated in EC2 — $1,224.27/mo, effort MEDIUM

Generated by cloudsealed-jit — rolling-median baseline + MAD z-score, method in METHODOLOGY.md.

@cloudsealed
cloudsealed deleted the demo-viral-firewall branch October 21, 2026 11:02
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.

1 participant