Files
rick 212f19ac19 Add v6-rewrite OpenSpec: proposal, design, specs, and tasks
Complete specification for rewriting Swarmops v5 as using.cash v6:
- Proposal: scope buckets (Working Rewrite / First Beyond Working / Maybe),
  non-goals (governance, geography, memberships permanently cut)
- Design: 18 architectural decisions including preserved patterns
  (Basic/Logic, stored procs, credential split), new patterns (repository
  classes, chain abstraction, rate providers), and operational concerns
  (Galera awareness, continuation transactions, VAT booking, OOD
  denormalization)
- Specs: 17 capability specifications with SHALL/MUST requirements and
  WHEN/THEN scenarios, covering accounting core, AP/AR, crypto treasury,
  exchange rates, organizations, users/auth, documents, comms, dashboard,
  end-of-month, backend worker, event bus, data migration, API layer,
  frontend app, and CI/packaging
- Tasks: 145 implementation tasks grouped by subsystem, ordered by
  dependency (migration gates API/frontend work)

Two rounds of adversarial review incorporated.

Made-with: Cursor
2026-04-08 16:02:58 +02:00

3.6 KiB

ADDED Requirements

Requirement: Background processing service

The system SHALL run a background worker as a .NET IHostedService that executes scheduled tasks on configurable intervals. The worker runs in the same process as the API (or optionally as a separate container).

Scenario: Worker starts with API

  • WHEN the application starts
  • THEN the background worker begins its processing loop

Scenario: Worker task execution

  • WHEN a scheduled interval elapses for a given task type
  • THEN the worker executes that task and logs the result

Requirement: Exchange rate snapshot task

The worker SHALL periodically capture exchange rate snapshots using the configured rate provider chain (primary + fallback).

Scenario: Scheduled rate snapshot

  • WHEN the rate snapshot interval elapses (configurable, default 15 minutes)
  • THEN the worker calls the exchange rate service to take a snapshot

Requirement: Mail queue processing task

The worker SHALL periodically process the outbound mail queue, delivering pending emails via SMTP and updating their status.

Scenario: Process mail queue

  • WHEN the mail queue check interval elapses
  • THEN the worker attempts delivery of all pending emails

Requirement: Blockchain monitoring task

The worker SHALL periodically check for new transactions to hot wallet addresses using the blockchain provider.

Scenario: Check blockchain

  • WHEN the blockchain monitoring interval elapses
  • THEN the worker queries the chain provider for new transactions to tracked addresses and ingests any deposits found

Requirement: Forex P&L recalculation task

The worker SHALL periodically (weekly) recalculate unrealized gains and losses on financial accounts denominated in a foreign currency relative to the organization's presentation currency.

Scenario: Weekly forex recalculation

  • WHEN the weekly forex P&L interval elapses
  • THEN the worker computes unrealized currency gains/losses for each foreign-currency-denominated account and records adjustment transactions

Requirement: Automated payout cycle task

The worker SHALL periodically (every 5 minutes) check for approved payouts that are ready for execution and process them automatically.

Scenario: Automated payout processing

  • WHEN the payout cycle interval elapses and there are approved payouts pending execution
  • THEN the worker executes the payouts and updates their status

Requirement: Schema version check on startup

The worker SHALL check the database schema version on startup using admin credentials. If the schema needs upgrading, it applies migrations before starting normal operations.

Scenario: Schema up to date

  • WHEN the worker starts and the schema version matches the expected version
  • THEN normal operations begin immediately

Scenario: Schema needs upgrade

  • WHEN the worker starts and the schema version is behind the expected version
  • THEN it applies pending migrations using admin credentials before starting operations

Requirement: Heartbeat

The worker SHALL periodically update a heartbeat timestamp in the database to indicate it is alive and operational. The frontend can check this timestamp to warn if the backend worker has stopped.

Scenario: Heartbeat update

  • WHEN the heartbeat interval elapses
  • THEN the worker updates the heartbeat timestamp in system settings

Scenario: Stale heartbeat detection

  • WHEN the frontend checks the heartbeat and finds it older than a threshold (e.g., 5 minutes)
  • THEN a warning is displayed to administrators