Skip to content
TraqoraPublic

About

No description, website, or topics provided.

Resources

Contributing

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

954 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AstroML

//WIP

CI codecov Code Complexity

🌐 Languages: This README is being translated under docs/i18n/. Available so far: Español (partial). See docs/i18n/README.md to add a locale.

Dynamic Graph Machine Learning Framework for the Stellar Network

AstroML is a research-driven Python framework for building dynamic graph machine learning models on the Stellar Development Foundation Stellar blockchain.

It treats blockchain data as a multi-asset, time-evolving graph, enabling advanced ML research on transaction networks such as fraud detection, anomaly detection, and behavioral modeling.


✨ Features

AstroML provides end-to-end tooling for:

  • Ledger ingestion and normalization
  • Dynamic transaction graph construction
  • Feature engineering for blockchain accounts
  • Graph Neural Networks (GNNs)
  • Self-supervised node embeddings
  • Anomaly detection
  • Temporal modeling
  • Reproducible ML experimentation
  • LLM Agent Framework for multi-step reasoning and autonomous task execution

οΏ½ LLM Agent Framework

AstroML now includes a powerful LLM Agent Framework for autonomous task execution and multi-step reasoning:

Key Capabilities

  • Multi-step reasoning with think-act-observe loops
  • Task planning with automatic decomposition
  • Tool calling for autonomous execution
  • Memory management with conversation and vector storage
  • Pre-configured agents for fraud detection and model training

Quick Start

# Interactive agent mode
python -m astroml agent interactive --agent-type fraud-detection

# Run a single task
python -m astroml agent run \
  --agent-type model-training \
  --task "Train a fraud detection model" \
  --verbose

# List available tools
python -m astroml agent list-tools

Documentation

See AGENTS_FRAMEWORK.md for complete documentation.


�🧠 Core Idea

Blockchain networks are naturally graph-structured systems:

Blockchain Concept Graph Representation
Accounts Nodes
Transactions Directed edges
Assets Edge types
Time Dynamic dimension

Most analytics tools rely on static heuristics or SQL queries.

AstroML instead enables:

  • Dynamic graph learning
  • Temporal GNNs
  • Representation learning
  • Research-grade experimentation

🎯 Target Users

AstroML is designed for:

  • ML researchers
  • Graph ML engineers
  • Fraud detection teams
  • Blockchain data scientists

πŸ— Architecture Overview

High-Level Pipeline

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    AstroML: Ingestion β†’ Graph β†’ Train                   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

                              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                              β”‚ Stellar      β”‚
                              β”‚ Ledgers      β”‚
                              β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
                                     β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚  1. INGESTION LAYER             β”‚
                    β”‚  β”œβ”€ Ledger backfill (Polars)   β”‚
                    β”‚  β”œβ”€ Incremental ingestion      β”‚
                    β”‚  β”œβ”€ State tracking (idempotent)β”‚
                    β”‚  └─ PostgreSQL storage         β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                     β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚  2. NORMALIZATION LAYER         β”‚
                    β”‚  β”œβ”€ Raw Stellar schema          β”‚
                    β”‚  β”‚  (Ledger, Transaction, Op)   β”‚
                    β”‚  β”œβ”€ Graph mirror layer          β”‚
                    β”‚  β”‚  (GraphAccount, GraphEdge)   β”‚
                    β”‚  └─ Composite indexes           β”‚
                    β”‚     (account_id, timestamp)     β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                     β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚  3. GRAPH BUILDING LAYER        β”‚
                    β”‚  β”œβ”€ Time-windowed snapshots     β”‚
                    β”‚  β”œβ”€ Edge construction           β”‚
                    β”‚  β”œβ”€ Node indexing               β”‚
                    β”‚  └─ Graph validation            β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                     β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚  4. FEATURE ENGINEERING         β”‚
                    β”‚  β”œβ”€ Transaction frequency       β”‚
                    β”‚  β”œβ”€ Asset diversity             β”‚
                    β”‚  β”œβ”€ Structural importance       β”‚
                    β”‚  β”‚  (degree, betweenness, PR)   β”‚
                    β”‚  β”œβ”€ Feature store & versioning  β”‚
                    β”‚  └─ Point-in-time queries       β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                     β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚  5. TRAINING LAYER              β”‚
                    β”‚  β”œβ”€ Temporal train/test split   β”‚
                    β”‚  β”œβ”€ Link prediction task        β”‚
                    β”‚  β”œβ”€ Negative sampling           β”‚
                    β”‚  β”œβ”€ PyTorch Geometric models    β”‚
                    β”‚  β”‚  (GCN, GraphSAGE, GAT)       β”‚
                    β”‚  └─ Early stopping              β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                     β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚  6. BENCHMARKING & EVALUATION   β”‚
                    β”‚  β”œβ”€ Reproducible configs        β”‚
                    β”‚  β”œβ”€ Random seed tracking        β”‚
                    β”‚  β”œβ”€ Metric computation          β”‚
                    β”‚  β”‚  (AUC, Precision, Recall)    β”‚
                    β”‚  β”œβ”€ Memory profiling            β”‚
                    β”‚  └─ Result persistence          β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                     β”‚
                              β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”
                              β”‚ Baseline    β”‚
                              β”‚ Results     β”‚
                              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Data Flow Details

Stellar Ledger Data
    ↓
[Ingestion Service]
    β”œβ”€ Fetch ledgers (1000000-1100000)
    β”œβ”€ Track state (.astroml_state/ingestion_state.json)
    └─ Store in PostgreSQL
    ↓
[Database Schema]
    β”œβ”€ Raw Layer: Ledger, Transaction, Operation, Account, Asset
    β”œβ”€ Graph Layer: GraphAccount, GraphEdge, GraphTransactionDetail
    └─ Indexes: (account_id, timestamp) composite
    ↓
[Graph Snapshot]
    β”œβ”€ Query operations by time window
    β”œβ”€ Create Edge objects (src, dst, timestamp, asset, amount)
    β”œβ”€ Build node_index mapping
    └─ Validate graph (isolated nodes, self-loops, density)
    ↓
[Feature Store]
    β”œβ”€ Compute node features (frequency, diversity, centrality)
    β”œβ”€ Compute edge features (asset type, amount, direction)
    β”œβ”€ Version features with metadata
    └─ Store in SQLite + Parquet
    ↓
[Temporal Split]
    β”œβ”€ Sort edges by timestamp
    β”œβ”€ Split at cutoff (80% train, 20% test)
    └─ Ensure no future data leaks into training
    ↓
[Link Prediction Task]
    β”œβ”€ Context window: edges before cutoff
    β”œβ”€ Future window: edges after cutoff
    β”œβ”€ Positive labels: future edges
    β”œβ”€ Negative sampling: random non-edges
    └─ Binary classification objective
    ↓
[Model Training]
    β”œβ”€ LinkPredictor(encoder + decoder)
    β”œβ”€ Adam optimizer with early stopping
    β”œβ”€ Compute AUC, Precision, Recall, F1
    └─ Track training/validation losses
    ↓
[Benchmark Results]
    β”œβ”€ config.json (full configuration + seed)
    β”œβ”€ result.json (metrics + performance)
    └─ metadata.json (run_id, timestamp, linking files)

Module Organization

astroml/
β”œβ”€β”€ ingestion/           # Ledger ingestion & state tracking
β”‚   β”œβ”€β”€ service.py       # IngestionService (incremental, idempotent)
β”‚   β”œβ”€β”€ state.py         # StateStore (tracks processed ledgers)
β”‚   └── backfill.py      # Bulk ledger loading
β”œβ”€β”€ db/                  # Database layer
β”‚   β”œβ”€β”€ schema.py        # SQLAlchemy ORM models
β”‚   └── session.py       # Database connection management
β”œβ”€β”€ features/            # Feature engineering
β”‚   β”œβ”€β”€ feature_store.py # Enterprise feature management
β”‚   β”œβ”€β”€ graph/
β”‚   β”‚   └── snapshot.py  # Time-windowed graph construction
β”‚   β”œβ”€β”€ frequency.py     # Transaction frequency features
β”‚   β”œβ”€β”€ asset_diversity.py
β”‚   └── gnn/             # Graph neural network layers
β”œβ”€β”€ models/              # ML models
β”‚   β”œβ”€β”€ link_predictor.py
β”‚   β”œβ”€β”€ gcn.py
β”‚   β”œβ”€β”€ sage.py
β”‚   └── deep_svdd.py
β”œβ”€β”€ tasks/               # Training tasks
β”‚   └── link_prediction_task.py
β”œβ”€β”€ training/            # Training utilities
β”‚   β”œβ”€β”€ temporal_split.py # Prevent data leakage
β”‚   └── train_link_prediction.py
β”œβ”€β”€ benchmarking/        # Benchmarking framework
β”‚   β”œβ”€β”€ core.py          # ModelBenchmark orchestrator
β”‚   β”œβ”€β”€ config.py        # Configuration management
β”‚   └── metrics.py       # Metric computation
β”œβ”€β”€ quick_start.py       # Quick start pipeline
└── cli.py               # Command-line interface

πŸš€ Quick Start

Prerequisites

Before running AstroML ensure you have the following installed:

Requirement Minimum version Notes
Python 3.10+ 3.11 recommended; 3.12 supported
Docker & Docker Compose 24+ Optional; only needed to run local PostgreSQL/Redis services
Git any For cloning the repository
Make any Optional but recommended; used for convenience targets
CUDA toolkit 11.8+ Optional; only needed for GPU-accelerated training

Verify your Python version before proceeding:

python --version   # must print 3.10 or higher

Before running quick start, create or use a PostgreSQL database and provide its connection through config/database.yaml or ASTROML_DATABASE_URL. The database must include the AstroML schema. Quick start does not require Redis, MLflow, the API server, or a GPU.

Requirements files

Several requirements files are provided β€” pick the profile that matches your workflow:

File When to use
requirements.txt Default β€” full stack including training, without GPU
requirements-cpu.txt CPU-only training on machines without a CUDA-capable GPU
requirements-train.txt GPU training; includes PyTorch with CUDA support
requirements-api.txt API server only; excludes heavy ML dependencies
requirements-dev.txt Development + testing; adds linting/typing tools on top of requirements.txt
requirements-minimal.txt Config parsing only β€” useful in CI stages that don't run training

requirements-minimal.txt is for configuration parsing; it is not sufficient for the quick-start pipeline, which trains a model and requires a database.

See REQUIREMENTS.md for a detailed breakdown of every package.

Python-only sample workflow (no Docker)

To run the bundled sample-data ingestion/graph/features workflow, install the CPU runtime and development/test dependencies in a virtual environment. This path does not require Docker, PostgreSQL, Redis, or a live Stellar endpoint:

python -m venv .venv
source .venv/bin/activate
pip install -r requirements-cpu.txt -r requirements-dev.txt
pip install -e .
pytest tests/integration/test_e2e_sample_data.py -m e2e -q

The database-backed make quickstart and python -m astroml.quick_start commands below are a separate workflow. They require a reachable PostgreSQL database configured with ASTROML_DATABASE_URL or config/database.yaml; Docker is one way to provide that database, not a prerequisite for the Python-only sample workflow. See Contributor Onboarding for the supported boundary and test-suite notes.

Option 1: Using Make (Recommended)

# Run quick start with default settings (100 ledgers, 50 accounts, 10 epochs)
make quickstart

# Run with more data for thorough testing
make quickstart-verbose

Option 2: Using Python Module

# Run quick start with default settings
python -m astroml.quick_start

# Run with custom parameters
python -m astroml.quick_start --num-ledgers 200 --num-accounts 100 --epochs 20 --seed 42

The canonical command is the top-level CLI module:

python -m astroml quickstart --num-ledgers 100 --num-accounts 50 --epochs 10 --seed 42

Use python -m astroml.cli quickstart --help to verify the supported flags. The defaults are --num-ledgers 100, --num-accounts 50, --epochs 10, and --seed 42. Ledger, account, and epoch values must be greater than zero. Make is optional; make quickstart and make quickstart-verbose run the same CLI implementation.

What Quick Start Does

The quick start pipeline:

  1. Generates sample data: Creates 100 synthetic ledgers with 50 accounts and realistic transactions
  2. Builds transaction graph: Constructs a time-windowed graph with ~2000 edges
  3. Validates graph: Checks for isolated nodes, self-loops, and computes statistics
  4. Trains baseline model: Trains a LinkPredictor model for 10 epochs
  5. Saves reproducible results: Stores config, results, and metadata for reproducibility

Output:

benchmark_results/quickstart/
β”œβ”€β”€ config.json          # Full configuration with random seed
β”œβ”€β”€ result.json          # Training metrics and performance
└── metadata.json        # Run metadata linking config and result

Expected output (typical values β€” exact numbers vary by seed):

================================================================================
AstroML Quick Start: Ingestion β†’ Graph β†’ Train Pipeline
================================================================================

[Step 1/5] Generating sample ledger data...
Generated 100 ledgers with 50 accounts

[Step 2/5] Building transaction graph...
Built graph with 2000 edges and 50 nodes

[Step 3/5] Creating benchmark configuration...

[Step 4/5] Training baseline model...
Epoch 0: Train Loss = 0.6931, Val Loss = 0.6892
Epoch 5: Train Loss = 0.4521, Val Loss = 0.4612
Training complete. Best metrics: {'auc': 0.92, 'precision': 0.88, 'recall': 0.85}

[Step 5/5] Saving benchmark results...
Saved config to benchmark_results/quickstart/config.json
Saved result to benchmark_results/quickstart/result.json
Saved metadata to benchmark_results/quickstart/metadata.json

βœ“ Quick start completed successfully!
Results saved to: benchmark_results/quickstart
================================================================================

Expected metric ranges on 10 epochs with the default seed:

  • AUC: 0.85 – 0.96
  • Precision: 0.80 – 0.93
  • Recall: 0.78 – 0.91
  • Training time: 5 – 30 s (CPU) / 2 – 8 s (GPU)

Troubleshooting

"Port 8000 already in use"

Another process is bound to port 8000. Find and stop it:

# Find the process
lsof -i :8000          # macOS / Linux
netstat -ano | findstr :8000   # Windows

# Stop it, or change the API port in docker-compose.yml:
#   ports: ["8001:8000"]

"Database connection refused"

The PostgreSQL container is not running. Start it:

docker compose up -d db
# Wait ~10 seconds for Postgres to initialise, then retry
docker compose logs db

Also verify your DATABASE_URL in .env matches the container settings (default: postgresql://astroml:astroml@localhost:5432/astroml).

"Model training CUDA out of memory"

Reduce batch size or switch to CPU:

# configs/training/default.yaml
training:
  device: cpu          # force CPU
  batch_size: 256      # reduce from default 1024

Alternatively, use requirements-cpu.txt which installs a CPU-only PyTorch build.

"Module import errors" / ModuleNotFoundError

Ensure you are in the right virtual environment and have installed dependencies:

source venv/bin/activate          # or: conda activate astroml
pip install -r requirements.txt

If the error mentions astroml itself, install the package in editable mode:

pip install -e .

For GPU-related import errors (No module named 'torch_geometric'), install the full training requirements:

pip install -r requirements-train.txt

Quick-start produces no output / hangs

Check that the SQLite temp path is writable and that no previous benchmark result is locked:

rm -rf benchmark_results/quickstart/
make quickstart

πŸ”„ Full Setup

Using Docker (Recommended)

For the quickest setup with all dependencies, use Docker:

# Clone and navigate to repository
git clone https://github.com/Traqora/astroml.git
cd astroml

# Start with Docker
cp .env.example .env
./scripts/docker-start.sh core

# Access services
curl http://localhost:8000            # API
open http://localhost:3000            # Grafana

πŸ“š Full Docker Setup: See DOCKER.md for comprehensive documentation including:

Local Development Setup

1. Clone the repository

git clone https://github.com/Traqora/astroml.git
cd astroml

2. Create environment

python -m venv venv
source venv/bin/activate
pip install -r requirements.txt

Note: Three requirements files are available. See REQUIREMENTS.md for guidance on which to use based on your environment (GPU training, CPU-only, or minimal config-only).

3. Configure database

A Docker Compose setup can provide PostgreSQL and Redis for workflows that need those services. Start only those dependencies with:

docker compose up -d postgres redis

Alternatively, configure your own PostgreSQL database and update config/database.yaml.

For the supported v1 Docker Compose deployment profile, including named volumes, recovery procedures, and resource expectations, see V1 Persistent Volumes.

Clean local reset

For a repeatable reset of the v1 local workflow, use:

make reset-local

This stops and recreates the API, PostgreSQL, and Redis containers with docker compose while preserving PostgreSQL, Redis, feature-store, logs, models, and other named volumes. It does not start optional GPU, monitoring, production, development, or full-profile services.

The destructive equivalent is not run accidentally:

make reset-local-data

The command requires an explicit DELETE_LOCAL_USER_DATA confirmation and removes named project volumes. Back up data first. Docker must be running and at least 2 CPU cores and 4 GB RAM are recommended for the core v1 stack.


πŸ€– LLM Agent Framework

AstroML includes an LLM agent framework for multi-step reasoning and autonomous task execution over the graph pipeline. It is provider agnostic, dependency light (the core loop is standard library only) and traces every step so runs stay auditable.

# Offline smoke test with the deterministic echo provider
python -m astroml.agent "Summarise this transaction graph"

# Against a local Ollama server, with task decomposition
python -m astroml.agent --provider ollama --model llama3.1 --plan \
  "Rank the busiest accounts and flag anything unusual"

# Analyse a graph file and print the full trace as JSON
python -m astroml.agent --edges data/edges.json --json "How many accounts?"
from astroml.agent import (
    AgentConfig,
    AgentExecutor,
    build_default_registry,
    provider_from_env,
)

agent = AgentExecutor(
    llm=provider_from_env(),           # echo | scripted | openai | ollama | ...
    tools=build_default_registry(),    # graph_overview, window_stats, ...
    config=AgentConfig(mode="auto", max_steps=8),
)
result = agent.run("Which accounts look unusual?")

print(result.answer)
print(result.trace.summary())

πŸ“š Full guide: docs/agent-framework.md β€” providers, tools, memory, planning, CLI flags and design notes.


πŸ“₯ Data Ingestion

Backfill ledgers:

python -m astroml.ingestion.backfill \
  --start-ledger 1000000 \
  --end-ledger 1100000

πŸ•Έ Build Graph Snapshot

Create a rolling time window graph:

python -m astroml.graph.build_snapshot --window 30d

Ingestion-to-snapshot integration fixture

The v1 integration fixture exercises raw operation normalization, idempotent database persistence, and database-backed snapshot construction without PostgreSQL, Horizon, Redis, or other optional services:

pytest -q tests/integration/test_ingestion_to_snapshot_fixture.py

The pytest fixture is available as ingestion_to_snapshot_fixture (and the short alias ingestion_to_snapshot). It supports Horizon-style payment and path-payment operation dictionaries. It ingests operation payloads directly; it does not fetch ledgers or require network access. Missing or invalid required operation fields raise ValueError instead of producing a snapshot.


πŸ§ͺ Synthetic Fraud Pattern Injection

Create benchmark datasets by injecting controlled fraud structures into a clean ledger copy:

python -m astroml.ingestion.synthetic_fraud_injector \
  --input data/clean_ledger.jsonl \
  --output data/ledger_with_fraud.jsonl \
  --summary outputs/fraud_injection_summary.json \
  --sybil-clusters 3 \
  --sybil-cluster-size 8 \
  --wash-loops 2 \
  --wash-loop-size 5

The injector appends transactions tagged with synthetic_fraud=true and fraud_pattern (sybil_cluster or wash_trading_loop) for downstream benchmarking.


πŸ€– Train Baseline GCN

python -m astroml.training.train_gcn

πŸ“Š Example Use Cases


πŸ”¬ Research Goals

AstroML emphasizes:

  • Reproducibility
  • Modular experimentation
  • Scalable ingestion
  • Temporal graph learning
  • Production-ready ML pipelines

πŸ›  Tech Stack

  • Python
  • PyTorch / PyTorch Geometric
  • PostgreSQL
  • NetworkX / graph tooling

πŸ§ͺ Testing

The default test suite is intended to run without optional external services. Tests that require a live API, PostgreSQL, Redis, MLflow, or a deployed application are marked with external (or external_service).

# Fast, local/default suite
pytest -m "not external and not external_service"

# Run external-service tests explicitly
pytest --run-external

# Environment-based opt-in (for CI and wrappers)
ASTROML_RUN_EXTERNAL_TESTS=1 pytest

Mocked HTTP/database behavior remains in the default suite. External tests must declare their service configuration and fail or skip clearly when the service is unavailable.


πŸ“Œ Roadmap

The following are not yet supported; the consolidated list with status and notes lives in docs/ROADMAP.md.

  • Real-time streaming ingestion
  • Temporal GNN models
  • Contrastive learning pipelines

The feature store, the model benchmarking suite, and Docker deployment were previously listed here as to-dos. They have shipped β€” see docs/ROADMAP.md β€” and are no longer roadmap items.


🀝 Contributing

Contributions are welcome!

fork β†’ branch β†’ commit β†’ PR

Please open issues for bugs or feature requests.


πŸ“œ License

MIT License <<<<<

About

No description, website, or topics provided.

Resources

Contributing

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages