Core interfaces, data models, and events for the FBA-Bench simulation platform.
Project description
FBA-Bench Core — Contract-first Core Library
Overview
FBA-Bench Core is a compact, contract-first library for building and simulating Fulfillment-By-Amazon-style (FBA) business automation scenarios. The rebuilt core emphasizes explicit, versioned contracts (Pydantic v2 models) for domain models, events, commands, and typed configuration objects so downstream projects can reliably validate and integrate simulation logic.
Key principles
- Contract-first: canonical Pydantic v2 models are the single source of truth.
- Typed, immutable configs: configuration objects are frozen models; use model_copy(update={...}) to derive modified instances.
- Explicit events/commands: typed discriminated unions with strict validation (extra="forbid") to make integration predictable.
Core modules
- Domain models:
src/fba_bench_core/domain/models.py- Product, InventorySnapshot, CompetitorListing, Competitor, DemandProfile
- Events & Commands:
src/fba_bench_core/domain/events.py- Typed BaseEvent/BaseCommand hierarchy and concrete events like SaleOccurred, StockReplenished, PromotionLaunched; commands like AdjustPriceCommand, PlaceReplenishmentOrderCommand.
- Agent/service base classes:
src/fba_bench_core/agents/base.pyandsrc/fba_bench_core/services/base.py - Typed configs:
src/fba_bench_core/config.py- BaseAgentConfig, BaseServiceConfig (immutable, extra="forbid")
Quick start (Poetry)
Clone and install with Poetry:
git clone <repo-url>
cd FBA-Bench-core
poetry install
Run the test suite:
poetry run pytest -q
Using Core from another project
- Add FBA-Bench Core as a dependency (editable/local for development):
pip install -e /path/to/FBA-Bench-core
- Import domain models and instantiate typed configs:
from fba_bench_core.domain.models import Product
from fba_bench_core.config import BaseAgentConfig
p = Product(product_id="sku-1", cost="1.00", price="2.00", stock=10)
cfg = BaseAgentConfig(agent_id="pricing-agent", poll_interval_seconds=30)
Migration guidance
If you are upgrading from a legacy core:
- See the migration guide:
docs/migration-guide.md - Key actions: import canonical models, convert numeric values to Decimal, and replace mutable dict-based configs with typed Base*Config models.
Tests, linting and quality commands
The CI pipeline runs formatting, linting, type-checking and tests. Locally you can run the same commands via Poetry:
poetry run black src tests
poetry run isort src tests
poetry run flake8 src tests
poetry run mypy
poetry run pytest
Packaging & versioning workflow
- CHANGELOG.md is generated from small towncrier fragments placed under
newsfragments/and built withtowncrier. - To add a changelog fragment: create a brief file
newsfragments/NN.descriptionthen runpoetry run towncrier build --yes. - Version tooling: this repository includes .bumpver.toml and uses dynamic versioning in the packaging pipeline. Follow project policy for release tagging and bumping; maintainers should prefer automated tools (bumpver) that integrate with CI.
Architecture and contracts
See the in-repo architecture notes for the rebuilt core:
- Core contracts:
docs/architecture/core-contracts.md - Architecture overview:
docs/architecture.md
Documentation & rescue log
The rescue log contains per-phase notes about the rebuild:
docs/rescue_log.md- Phase G′ (Phase G-prime) documents updated documentation artifacts and
provides migration guidance for consumers; see
docs/migration-guide.md.
Contributing
Please follow Conventional Commits for PRs, include tests for contract changes,
and place towncrier fragments under newsfragments/ for changelog entries.
See docs/README.md for broader documentation contribution
guidelines.
Tooling
- Pre-commit hooks are configured in
.pre-commit-config.yaml. - Towncrier configuration is in
.towncrier.toml.
License & contact
- License: MIT — see
LICENSE - Contact: project maintainers via repository issues or
press@fba-bench.ai.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fba_bench_core-1.0.0.tar.gz.
File metadata
- Download URL: fba_bench_core-1.0.0.tar.gz
- Upload date:
- Size: 31.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.12.10 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e9da43b8e1ca79704213d67c0fb87e249584b659e5c6163528a0219da9941a4e
|
|
| MD5 |
04f8c7268ec2086fca4ed72106c2ba91
|
|
| BLAKE2b-256 |
700f9d62a8ac78d5cf6f50c788346a9efb459f49bfef1fd642b13002b05d4024
|
File details
Details for the file fba_bench_core-1.0.0-py3-none-any.whl.
File metadata
- Download URL: fba_bench_core-1.0.0-py3-none-any.whl
- Upload date:
- Size: 48.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.12.10 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7152cacb06fdf6a18c44be536d71d422ac016dd2d1e3f0cb06594b9e88a5ec30
|
|
| MD5 |
640406ff4db97db8a42a2766f9653778
|
|
| BLAKE2b-256 |
3c93a767b549872c0e82e0a33cdc47e953c860bb062c07cdd1ef3f4bafb356eb
|