Skip to content

fix: batch issues 1126, 1127, 1134, 1140 - #1175

Merged
vjuliaife merged 1 commit into
vjuliaife:mainfrom
dimka90:feat/issues-1126-1127-1134-1140
Aug 30, 2026
Merged

fix: batch issues 1126, 1127, 1134, 1140#1175
vjuliaife merged 1 commit into
vjuliaife:mainfrom
dimka90:feat/issues-1126-1127-1134-1140

Conversation

@dimka90

@dimka90 dimka90 commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Closes #1126
Closes #1127
Closes #1134
Closes #1140

Summary

One batched PR delivering the four open TariffShield issues:

#1126 — Audit-log write-path latency (investigation)

  • Adds apps/api/tests/benchmarks/audit-log-write-path.js (local Postgres-only harness).
  • Documents findings in docs/investigations/audit-log-write-path.md: the audit append is O(1) (flat 1.2–1.4ms mean at 1× vs ~11× rows); it is ~half of the request's DB write latency because it is a second autocommit round-trip; wrapping read/write + logAudit in one transaction buys atomicity (latency delta within noise).

#1127 — deposit_reserve cost vs prior deposits (investigation)

  • Adds benchmark_deposit_cost_vs_prior_deposit_count test + deposit_cost_after_prior_deposits/deposit_cost_isolated/DepositKind in contracts/tariff-shield/src/test.rs.
  • Documents findings in docs/investigations/deposit-reserve-cost.md: both deposit_reserve and deposit_collateral are O(1) in prior deposit count — flat ~282k CPU/47k memory isolated at prior=1/100/1000; identical per-kind behavior end to end.

#1134.env.local standardization (docs)

  • docs/FAQ.md and docs/environment-variables.md updated so web env setup uses apps/web/.env.local consistently.

#1140 — Shortfall auto top-up demo tooling

  • scripts/seed.ts: new --shortfall flag seeds a demo importer whose required collateral (80 XLM) exceeds deposited collateral (30 XLM) with 100 XLM in reserve → exactly 50 XLM auto_top_up, matching the README.
  • scripts/admin.ts: new auto-top-up --importer-id <id> [--execute] command — computes the shortfall from DB ledger events (or live on-chain account when reachable), dry-runs by default, and with --execute submits the on-chain call and records the auto_top_up contract event.
  • docs/local-dev.md: shortfall demo section in the Smoke Test Workflow.

Verification

  • cargo test — new benchmark test passes (42 passed; benchmark_bulk_enforcement_paths fails on main too — pre-existing, unrelated).
  • Scripts tests: 75/75 pass.
  • apps/api typecheck + lint pass; @tariffshield/sdk built locally for the typecheck.
  • Seeder + auto-top-up dry-run exercised against local docker Postgres 17 (required 80 / collateral 30 / reserve 100 → move 50 XLM ✓).

Note: no .env, .env.local, or package-lock.json changes are included (local-only).

…1140 (investigations + seed/admin shortfall tooling)

- vjuliaife#1126: audit-log write-path benchmark harness and investigation doc
- vjuliaife#1127: deposit_reserve cost benchmark test and investigation doc
- vjuliaife#1134: doc env standardization (apps/web/.env.local)
- vjuliaife#1140: seed --shortfall demo + admin auto-top-up dry-run/execute command
@drips-wave

drips-wave Bot commented Aug 28, 2026

Copy link
Copy Markdown

@dimka90 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! 🚀

Learn more about application limits

@vercel

vercel Bot commented Aug 28, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
tariff-shield-web Error Error Aug 28, 2026 6:37pm

@dimka90

dimka90 commented Aug 28, 2026

Copy link
Copy Markdown
Contributor Author

Batch deliverable for #1126 #1127 #1134 #1140 — four investigation/tooling workstreams landed as one PR. Green: new tests pass, 75/75 script tests, api typecheck+lint clean, seed --shortfall + auto-top-up dry-run verified against docker Postgres. Merging per prior directive.

@vjuliaife
vjuliaife merged commit 5e221a5 into vjuliaife:main Aug 30, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment