fba-bench-core 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. fba_bench_core-1.0.0/LICENSE +21 -0
  2. fba_bench_core-1.0.0/PKG-INFO +152 -0
  3. fba_bench_core-1.0.0/README.md +125 -0
  4. fba_bench_core-1.0.0/pyproject.toml +112 -0
  5. fba_bench_core-1.0.0/src/fba_bench_core/__init__.py +11 -0
  6. fba_bench_core-1.0.0/src/fba_bench_core/agents/__init__.py +15 -0
  7. fba_bench_core-1.0.0/src/fba_bench_core/agents/base.py +83 -0
  8. fba_bench_core-1.0.0/src/fba_bench_core/agents/registry.py +16 -0
  9. fba_bench_core-1.0.0/src/fba_bench_core/benchmarking/__init__.py +6 -0
  10. fba_bench_core-1.0.0/src/fba_bench_core/benchmarking/core/__init__.py +1 -0
  11. fba_bench_core-1.0.0/src/fba_bench_core/benchmarking/engine/__init__.py +12 -0
  12. fba_bench_core-1.0.0/src/fba_bench_core/benchmarking/engine/core.py +135 -0
  13. fba_bench_core-1.0.0/src/fba_bench_core/benchmarking/engine/models.py +62 -0
  14. fba_bench_core-1.0.0/src/fba_bench_core/benchmarking/metrics/__init__.py +30 -0
  15. fba_bench_core-1.0.0/src/fba_bench_core/benchmarking/metrics/accuracy_score.py +27 -0
  16. fba_bench_core-1.0.0/src/fba_bench_core/benchmarking/metrics/aggregate.py +39 -0
  17. fba_bench_core-1.0.0/src/fba_bench_core/benchmarking/metrics/completeness.py +38 -0
  18. fba_bench_core-1.0.0/src/fba_bench_core/benchmarking/metrics/cost_efficiency.py +32 -0
  19. fba_bench_core-1.0.0/src/fba_bench_core/benchmarking/metrics/custom_scriptable.py +17 -0
  20. fba_bench_core-1.0.0/src/fba_bench_core/benchmarking/metrics/keyword_coverage.py +41 -0
  21. fba_bench_core-1.0.0/src/fba_bench_core/benchmarking/metrics/policy_compliance.py +18 -0
  22. fba_bench_core-1.0.0/src/fba_bench_core/benchmarking/metrics/registry.py +57 -0
  23. fba_bench_core-1.0.0/src/fba_bench_core/benchmarking/metrics/robustness.py +27 -0
  24. fba_bench_core-1.0.0/src/fba_bench_core/benchmarking/metrics/technical_performance.py +16 -0
  25. fba_bench_core-1.0.0/src/fba_bench_core/benchmarking/registry.py +48 -0
  26. fba_bench_core-1.0.0/src/fba_bench_core/benchmarking/scenarios/__init__.py +1 -0
  27. fba_bench_core-1.0.0/src/fba_bench_core/benchmarking/scenarios/base.py +36 -0
  28. fba_bench_core-1.0.0/src/fba_bench_core/benchmarking/scenarios/complex_marketplace.py +181 -0
  29. fba_bench_core-1.0.0/src/fba_bench_core/benchmarking/scenarios/multiturn_tool_use.py +176 -0
  30. fba_bench_core-1.0.0/src/fba_bench_core/benchmarking/scenarios/registry.py +18 -0
  31. fba_bench_core-1.0.0/src/fba_bench_core/benchmarking/scenarios/research_summarization.py +141 -0
  32. fba_bench_core-1.0.0/src/fba_bench_core/benchmarking/validators/__init__.py +24 -0
  33. fba_bench_core-1.0.0/src/fba_bench_core/benchmarking/validators/determinism_check.py +95 -0
  34. fba_bench_core-1.0.0/src/fba_bench_core/benchmarking/validators/fairness_balance.py +75 -0
  35. fba_bench_core-1.0.0/src/fba_bench_core/benchmarking/validators/outlier_detection.py +53 -0
  36. fba_bench_core-1.0.0/src/fba_bench_core/benchmarking/validators/registry.py +57 -0
  37. fba_bench_core-1.0.0/src/fba_bench_core/benchmarking/validators/reproducibility_metadata.py +74 -0
  38. fba_bench_core-1.0.0/src/fba_bench_core/benchmarking/validators/schema_adherence.py +59 -0
  39. fba_bench_core-1.0.0/src/fba_bench_core/benchmarking/validators/structural_consistency.py +74 -0
  40. fba_bench_core-1.0.0/src/fba_bench_core/config.py +154 -0
  41. fba_bench_core-1.0.0/src/fba_bench_core/domain/__init__.py +75 -0
  42. fba_bench_core-1.0.0/src/fba_bench_core/domain/events/__init__.py +230 -0
  43. fba_bench_core-1.0.0/src/fba_bench_core/domain/events/analytics.py +69 -0
  44. fba_bench_core-1.0.0/src/fba_bench_core/domain/events/base.py +59 -0
  45. fba_bench_core-1.0.0/src/fba_bench_core/domain/events/inventory.py +119 -0
  46. fba_bench_core-1.0.0/src/fba_bench_core/domain/events/marketing.py +102 -0
  47. fba_bench_core-1.0.0/src/fba_bench_core/domain/events/pricing.py +179 -0
  48. fba_bench_core-1.0.0/src/fba_bench_core/domain/models.py +296 -0
  49. fba_bench_core-1.0.0/src/fba_bench_core/exceptions/__init__.py +9 -0
  50. fba_bench_core-1.0.0/src/fba_bench_core/exceptions/base.py +46 -0
  51. fba_bench_core-1.0.0/src/fba_bench_core/services/__init__.py +12 -0
  52. fba_bench_core-1.0.0/src/fba_bench_core/services/base.py +52 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 FBA-Bench Core Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,152 @@
1
+ Metadata-Version: 2.4
2
+ Name: fba-bench-core
3
+ Version: 1.0.0
4
+ Summary: Core interfaces, data models, and events for the FBA-Bench simulation platform.
5
+ License: Apache-2.0
6
+ License-File: LICENSE
7
+ Keywords: benchmarking,simulation,fba,pydantic,typing
8
+ Author: FBA Team
9
+ Author-email: devnull@example.com
10
+ Requires-Python: >=3.11,<4.0
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: Apache Software License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Programming Language :: Python :: 3.14
18
+ Classifier: Topic :: Software Development :: Libraries
19
+ Classifier: Typing :: Typed
20
+ Requires-Dist: pydantic (>=2.0,<3.0)
21
+ Project-URL: Documentation, https://your-org.github.io/fba-bench-core
22
+ Project-URL: Homepage, https://github.com/your-org/fba-bench-core
23
+ Project-URL: Issues, https://github.com/your-org/fba-bench-core/issues
24
+ Project-URL: Repository, https://github.com/your-org/fba-bench-core
25
+ Description-Content-Type: text/markdown
26
+
27
+ # FBA-Bench Core — Contract-first Core Library
28
+
29
+ Overview
30
+
31
+ FBA-Bench Core is a compact, contract-first library for building and
32
+ simulating Fulfillment-By-Amazon-style (FBA) business automation scenarios.
33
+ The rebuilt core emphasizes explicit, versioned contracts (Pydantic v2 models)
34
+ for domain models, events, commands, and typed configuration objects so
35
+ downstream projects can reliably validate and integrate simulation logic.
36
+
37
+ Key principles
38
+
39
+ - Contract-first: canonical Pydantic v2 models are the single source of truth.
40
+ - Typed, immutable configs: configuration objects are frozen models; use
41
+ model_copy(update={...}) to derive modified instances.
42
+ - Explicit events/commands: typed discriminated unions with strict validation
43
+ (extra="forbid") to make integration predictable.
44
+
45
+ Core modules
46
+
47
+ - Domain models: [`src/fba_bench_core/domain/models.py`](src/fba_bench_core/domain/models.py:1)
48
+ - Product, InventorySnapshot, CompetitorListing, Competitor, DemandProfile
49
+ - Events & Commands: [`src/fba_bench_core/domain/events.py`](src/fba_bench_core/domain/events.py:1)
50
+ - Typed BaseEvent/BaseCommand hierarchy and concrete events like SaleOccurred,
51
+ StockReplenished, PromotionLaunched; commands like AdjustPriceCommand,
52
+ PlaceReplenishmentOrderCommand.
53
+ - Agent/service base classes: [`src/fba_bench_core/agents/base.py`](src/fba_bench_core/agents/base.py:1)
54
+ and [`src/fba_bench_core/services/base.py`](src/fba_bench_core/services/base.py:1)
55
+ - Typed configs: [`src/fba_bench_core/config.py`](src/fba_bench_core/config.py:1)
56
+ - BaseAgentConfig, BaseServiceConfig (immutable, extra="forbid")
57
+
58
+ Quick start (Poetry)
59
+
60
+ Clone and install with Poetry:
61
+
62
+ ```bash
63
+ git clone <repo-url>
64
+ cd FBA-Bench-core
65
+ poetry install
66
+ ```
67
+
68
+ Run the test suite:
69
+
70
+ ```bash
71
+ poetry run pytest -q
72
+ ```
73
+
74
+ Using Core from another project
75
+
76
+ 1. Add FBA-Bench Core as a dependency (editable/local for development):
77
+
78
+ ```bash
79
+ pip install -e /path/to/FBA-Bench-core
80
+ ```
81
+
82
+ 2. Import domain models and instantiate typed configs:
83
+
84
+ ```python
85
+ from fba_bench_core.domain.models import Product
86
+ from fba_bench_core.config import BaseAgentConfig
87
+
88
+ p = Product(product_id="sku-1", cost="1.00", price="2.00", stock=10)
89
+ cfg = BaseAgentConfig(agent_id="pricing-agent", poll_interval_seconds=30)
90
+ ```
91
+
92
+ Migration guidance
93
+
94
+ If you are upgrading from a legacy core:
95
+ - See the migration guide: [`docs/migration-guide.md`](docs/migration-guide.md:1)
96
+ - Key actions: import canonical models, convert numeric values to Decimal,
97
+ and replace mutable dict-based configs with typed Base*Config models.
98
+
99
+ Tests, linting and quality commands
100
+
101
+ The CI pipeline runs formatting, linting, type-checking and tests. Locally you
102
+ can run the same commands via Poetry:
103
+
104
+ ```bash
105
+ poetry run black src tests
106
+ poetry run isort src tests
107
+ poetry run flake8 src tests
108
+ poetry run mypy
109
+ poetry run pytest
110
+ ```
111
+
112
+ Packaging & versioning workflow
113
+
114
+ - CHANGELOG.md is generated from small towncrier fragments placed under
115
+ [`newsfragments/`](newsfragments/:1) and built with `towncrier`.
116
+ - To add a changelog fragment: create a brief file `newsfragments/NN.description`
117
+ then run `poetry run towncrier build --yes`.
118
+ - Version tooling: this repository includes [.bumpver.toml](.bumpver.toml:1)
119
+ and uses dynamic versioning in the packaging pipeline. Follow project policy
120
+ for release tagging and bumping; maintainers should prefer automated tools
121
+ (bumpver) that integrate with CI.
122
+
123
+ Architecture and contracts
124
+
125
+ See the in-repo architecture notes for the rebuilt core:
126
+ - Core contracts: [`docs/architecture/core-contracts.md`](docs/architecture/core-contracts.md:1)
127
+ - Architecture overview: [`docs/architecture.md`](docs/architecture.md:1)
128
+
129
+ Documentation & rescue log
130
+
131
+ The rescue log contains per-phase notes about the rebuild:
132
+ - [`docs/rescue_log.md`](docs/rescue_log.md:1)
133
+ - Phase G′ (Phase G-prime) documents updated documentation artifacts and
134
+ provides migration guidance for consumers; see [`docs/migration-guide.md`](docs/migration-guide.md:1).
135
+
136
+ Contributing
137
+
138
+ Please follow Conventional Commits for PRs, include tests for contract changes,
139
+ and place towncrier fragments under `newsfragments/` for changelog entries.
140
+ See [`docs/README.md`](docs/README.md:1) for broader documentation contribution
141
+ guidelines.
142
+
143
+ Tooling
144
+
145
+ - Pre-commit hooks are configured in [`.pre-commit-config.yaml`](.pre-commit-config.yaml:1).
146
+ - Towncrier configuration is in [`.towncrier.toml`](.towncrier.toml:1).
147
+
148
+ License & contact
149
+
150
+ - License: MIT — see [`LICENSE`](LICENSE:1)
151
+ - Contact: project maintainers via repository issues or `press@fba-bench.ai`.
152
+
@@ -0,0 +1,125 @@
1
+ # FBA-Bench Core — Contract-first Core Library
2
+
3
+ Overview
4
+
5
+ FBA-Bench Core is a compact, contract-first library for building and
6
+ simulating Fulfillment-By-Amazon-style (FBA) business automation scenarios.
7
+ The rebuilt core emphasizes explicit, versioned contracts (Pydantic v2 models)
8
+ for domain models, events, commands, and typed configuration objects so
9
+ downstream projects can reliably validate and integrate simulation logic.
10
+
11
+ Key principles
12
+
13
+ - Contract-first: canonical Pydantic v2 models are the single source of truth.
14
+ - Typed, immutable configs: configuration objects are frozen models; use
15
+ model_copy(update={...}) to derive modified instances.
16
+ - Explicit events/commands: typed discriminated unions with strict validation
17
+ (extra="forbid") to make integration predictable.
18
+
19
+ Core modules
20
+
21
+ - Domain models: [`src/fba_bench_core/domain/models.py`](src/fba_bench_core/domain/models.py:1)
22
+ - Product, InventorySnapshot, CompetitorListing, Competitor, DemandProfile
23
+ - Events & Commands: [`src/fba_bench_core/domain/events.py`](src/fba_bench_core/domain/events.py:1)
24
+ - Typed BaseEvent/BaseCommand hierarchy and concrete events like SaleOccurred,
25
+ StockReplenished, PromotionLaunched; commands like AdjustPriceCommand,
26
+ PlaceReplenishmentOrderCommand.
27
+ - Agent/service base classes: [`src/fba_bench_core/agents/base.py`](src/fba_bench_core/agents/base.py:1)
28
+ and [`src/fba_bench_core/services/base.py`](src/fba_bench_core/services/base.py:1)
29
+ - Typed configs: [`src/fba_bench_core/config.py`](src/fba_bench_core/config.py:1)
30
+ - BaseAgentConfig, BaseServiceConfig (immutable, extra="forbid")
31
+
32
+ Quick start (Poetry)
33
+
34
+ Clone and install with Poetry:
35
+
36
+ ```bash
37
+ git clone <repo-url>
38
+ cd FBA-Bench-core
39
+ poetry install
40
+ ```
41
+
42
+ Run the test suite:
43
+
44
+ ```bash
45
+ poetry run pytest -q
46
+ ```
47
+
48
+ Using Core from another project
49
+
50
+ 1. Add FBA-Bench Core as a dependency (editable/local for development):
51
+
52
+ ```bash
53
+ pip install -e /path/to/FBA-Bench-core
54
+ ```
55
+
56
+ 2. Import domain models and instantiate typed configs:
57
+
58
+ ```python
59
+ from fba_bench_core.domain.models import Product
60
+ from fba_bench_core.config import BaseAgentConfig
61
+
62
+ p = Product(product_id="sku-1", cost="1.00", price="2.00", stock=10)
63
+ cfg = BaseAgentConfig(agent_id="pricing-agent", poll_interval_seconds=30)
64
+ ```
65
+
66
+ Migration guidance
67
+
68
+ If you are upgrading from a legacy core:
69
+ - See the migration guide: [`docs/migration-guide.md`](docs/migration-guide.md:1)
70
+ - Key actions: import canonical models, convert numeric values to Decimal,
71
+ and replace mutable dict-based configs with typed Base*Config models.
72
+
73
+ Tests, linting and quality commands
74
+
75
+ The CI pipeline runs formatting, linting, type-checking and tests. Locally you
76
+ can run the same commands via Poetry:
77
+
78
+ ```bash
79
+ poetry run black src tests
80
+ poetry run isort src tests
81
+ poetry run flake8 src tests
82
+ poetry run mypy
83
+ poetry run pytest
84
+ ```
85
+
86
+ Packaging & versioning workflow
87
+
88
+ - CHANGELOG.md is generated from small towncrier fragments placed under
89
+ [`newsfragments/`](newsfragments/:1) and built with `towncrier`.
90
+ - To add a changelog fragment: create a brief file `newsfragments/NN.description`
91
+ then run `poetry run towncrier build --yes`.
92
+ - Version tooling: this repository includes [.bumpver.toml](.bumpver.toml:1)
93
+ and uses dynamic versioning in the packaging pipeline. Follow project policy
94
+ for release tagging and bumping; maintainers should prefer automated tools
95
+ (bumpver) that integrate with CI.
96
+
97
+ Architecture and contracts
98
+
99
+ See the in-repo architecture notes for the rebuilt core:
100
+ - Core contracts: [`docs/architecture/core-contracts.md`](docs/architecture/core-contracts.md:1)
101
+ - Architecture overview: [`docs/architecture.md`](docs/architecture.md:1)
102
+
103
+ Documentation & rescue log
104
+
105
+ The rescue log contains per-phase notes about the rebuild:
106
+ - [`docs/rescue_log.md`](docs/rescue_log.md:1)
107
+ - Phase G′ (Phase G-prime) documents updated documentation artifacts and
108
+ provides migration guidance for consumers; see [`docs/migration-guide.md`](docs/migration-guide.md:1).
109
+
110
+ Contributing
111
+
112
+ Please follow Conventional Commits for PRs, include tests for contract changes,
113
+ and place towncrier fragments under `newsfragments/` for changelog entries.
114
+ See [`docs/README.md`](docs/README.md:1) for broader documentation contribution
115
+ guidelines.
116
+
117
+ Tooling
118
+
119
+ - Pre-commit hooks are configured in [`.pre-commit-config.yaml`](.pre-commit-config.yaml:1).
120
+ - Towncrier configuration is in [`.towncrier.toml`](.towncrier.toml:1).
121
+
122
+ License & contact
123
+
124
+ - License: MIT — see [`LICENSE`](LICENSE:1)
125
+ - Contact: project maintainers via repository issues or `press@fba-bench.ai`.
@@ -0,0 +1,112 @@
1
+ [tool.poetry]
2
+ name = "fba-bench-core"
3
+ version = "1.0.0"
4
+ description = "Core interfaces, data models, and events for the FBA-Bench simulation platform."
5
+ authors = ["FBA Team <devnull@example.com>"]
6
+ license = "Apache-2.0"
7
+ readme = "README.md"
8
+ packages = [{ include = "fba_bench_core", from = "src" }]
9
+ keywords = ["benchmarking", "simulation", "fba", "pydantic", "typing"]
10
+ classifiers = [
11
+ "Programming Language :: Python :: 3.11",
12
+ "License :: OSI Approved :: Apache Software License",
13
+ "Intended Audience :: Developers",
14
+ "Topic :: Software Development :: Libraries",
15
+ "Typing :: Typed",
16
+ ]
17
+
18
+ [tool.poetry.urls]
19
+ Homepage = "https://github.com/your-org/fba-bench-core"
20
+ Repository = "https://github.com/your-org/fba-bench-core"
21
+ Documentation = "https://your-org.github.io/fba-bench-core"
22
+ Issues = "https://github.com/your-org/fba-bench-core/issues"
23
+
24
+ [tool.poetry.dependencies]
25
+ python = "^3.11"
26
+ pydantic = "^2.0"
27
+
28
+ [tool.poetry.group.dev.dependencies]
29
+ pytest = "^8.0"
30
+ pytest-asyncio = "^0.23.0"
31
+ black = "^24.3.0"
32
+ flake8 = "^6.1.0"
33
+ mypy = "^1.8.0"
34
+ pre-commit = "^3.6.0"
35
+ poetry-dynamic-versioning = "^0.19.0"
36
+ towncrier = "^21.0.0"
37
+ bumpver = "^2023.1128"
38
+ pip-audit = "^2.9.0"
39
+
40
+ [build-system]
41
+ requires = ["poetry-core"]
42
+ build-backend = "poetry.core.masonry.api"
43
+
44
+ # --------------------
45
+ # Dynamic versioning
46
+ # --------------------
47
+ [tool.poetry-dynamic-versioning]
48
+ enable = true
49
+ vcs = "git"
50
+ fallback-version = "0.0.0"
51
+
52
+ # --------------------
53
+ # Towncrier changelog
54
+ # --------------------
55
+ [tool.towncrier]
56
+ package = "fba_bench_core"
57
+ directory = "newsfragments"
58
+ filename = "CHANGELOG.md"
59
+
60
+ # --------------------
61
+ # Ruff config (linter + import sorter + formatter)
62
+ # --------------------
63
+ [tool.ruff]
64
+ target-version = "py311"
65
+ line-length = 88
66
+ src = ["src"]
67
+ extend-exclude = ["tests/data", "build", "dist"]
68
+
69
+ [tool.ruff.lint]
70
+ select = ["E", "F", "UP"]
71
+ ignore = ["E501"]
72
+ fixable = ["ALL"]
73
+ unfixable = []
74
+
75
+ [tool.ruff.lint.isort]
76
+ combine-as-imports = true
77
+ known-first-party = ["fba_bench_core"]
78
+ force-single-line = false
79
+
80
+ # --------------------
81
+ # Black config
82
+ # --------------------
83
+ [tool.black]
84
+ line-length = 88
85
+ target-version = ["py311"]
86
+ skip-string-normalization = true
87
+
88
+ # --------------------
89
+ # Flake8 config
90
+ # --------------------
91
+ [tool.flake8]
92
+ max-line-length = 88
93
+ extend-ignore = ["E203", "W503"]
94
+
95
+ # --------------------
96
+ # Mypy config
97
+ # --------------------
98
+ [tool.mypy]
99
+ python_version = "3.11"
100
+ ignore_missing_imports = true
101
+ pretty = true
102
+ warn_unused_ignores = true
103
+ files = ["src/fba_bench_core", "tests"]
104
+
105
+ # --------------------
106
+ # Pytest config
107
+ # --------------------
108
+ [tool.pytest.ini_options]
109
+ minversion = "7.0"
110
+ addopts = "-ra --cov=src/fba_bench_core --cov-report=term-missing --cov-report=html"
111
+ testpaths = ["tests"]
112
+ asyncio_mode = "auto"
@@ -0,0 +1,11 @@
1
+ """Phase 2 scaffold for the fba_bench_core package.
2
+
3
+ This module is a minimal placeholder created during Phase 2 of the
4
+ core rebuild. It intentionally contains no runtime logic; only the
5
+ package-level metadata required to allow safe imports and satisfy
6
+ linters during the rescue process.
7
+ """
8
+
9
+ __all__ = []
10
+
11
+ __version__ = "1.0.0"
@@ -0,0 +1,15 @@
1
+ """Package exports for fba_bench_core.agents.
2
+
3
+ Exports the BaseAgent abstract class and exposes the registry module to allow
4
+ external code to discover and register agent implementations. Also export the
5
+ typed base configuration model to make it easy for downstream users to extend.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ from fba_bench_core.config import BaseAgentConfig
11
+
12
+ from . import registry
13
+ from .base import BaseAgent
14
+
15
+ __all__ = ["BaseAgent", "registry", "BaseAgentConfig"]
@@ -0,0 +1,83 @@
1
+ """Typed BaseAgent for fba_bench_core.
2
+
3
+ Phase D change:
4
+ - Replace legacy **kwargs configuration with a typed Pydantic configuration
5
+ object. Downstream implementations should subclass the provided config model
6
+ for specialized parameters.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ from abc import ABC, abstractmethod
12
+
13
+ from fba_bench_core.config import BaseAgentConfig
14
+ from fba_bench_core.domain.events import BaseEvent, Command
15
+
16
+
17
+ class BaseAgent(ABC):
18
+ """Abstract base class for agents that receive a validated configuration.
19
+
20
+ Rationale:
21
+ Using a typed configuration object prevents downstream implementations
22
+ from hiding untyped parameters behind `Any` and enables validation at
23
+ construction time. Implementations that require additional fields may
24
+ subclass `BaseAgentConfig` (see examples in the config module).
25
+
26
+ Initialization:
27
+ The agent receives a single `config: BaseAgentConfig` argument. The
28
+ `agent_id` is expected to be present on that config and becomes the
29
+ agent's immutable identifier.
30
+
31
+ Immutability:
32
+ The provided config model is frozen (Pydantic frozen model). The agent
33
+ stores the config object directly and exposes it via a read-only
34
+ property to avoid accidental mutation.
35
+ """
36
+
37
+ def __init__(self, config: BaseAgentConfig) -> None:
38
+ """Initialize the base agent with a validated, typed configuration.
39
+
40
+ Parameters:
41
+ config: An instance of BaseAgentConfig or a subclass thereof. The
42
+ model is validated by Pydantic prior to construction.
43
+
44
+ Notes:
45
+ - Do not accept `**kwargs` here: typed configs are required.
46
+ - The agent keeps a reference to the provided config (which is
47
+ immutable/frozen). Use `agent.config.model_copy()` to obtain a
48
+ mutable copy if necessary.
49
+ """
50
+ self._config = config
51
+ self._agent_id = config.agent_id
52
+
53
+ @property
54
+ def agent_id(self) -> str:
55
+ """Return the agent's unique identifier (from config.agent_id)."""
56
+ return self._agent_id
57
+
58
+ @property
59
+ def config(self) -> BaseAgentConfig:
60
+ """Return the typed configuration object for this agent.
61
+
62
+ The returned object is immutable (Pydantic frozen model). Downstream
63
+ code that needs to modify configuration should create a new instance
64
+ (e.g., via `model_copy(update={...})`).
65
+ """
66
+ return self._config
67
+
68
+ def get_config(self) -> dict:
69
+ """Return a serializable shallow mapping of the configuration.
70
+
71
+ Returns:
72
+ A dict produced by Pydantic's model_dump() representing the config.
73
+ """
74
+ return self._config.model_dump()
75
+
76
+ @abstractmethod
77
+ async def decide(self, events: list[BaseEvent]) -> list[Command]:
78
+ """Decide on a list of Commands given observed domain events.
79
+
80
+ Implementations must be async coroutines and must not mutate the
81
+ provided `events` list.
82
+ """
83
+ raise NotImplementedError
@@ -0,0 +1,16 @@
1
+ """Phase 5 placeholder for the agent registry.
2
+
3
+ This module will hold mappings of agent names to agent classes and will be
4
+ populated during Phase 5. It intentionally contains no runtime logic now.
5
+ """
6
+
7
+ AGENT_REGISTRY: dict[str, type] = {} # Populated in a later phase (Phase 5)
8
+
9
+
10
+ def create_runner(key: str, config: dict):
11
+ """Stub function for creating runners."""
12
+
13
+ class DummyRunner:
14
+ agent_id = config.get("agent_id", "dummy")
15
+
16
+ return DummyRunner()
@@ -0,0 +1,6 @@
1
+ """Benchmarking module for FBA Bench Core.
2
+
3
+ This module provides benchmarking functionality including engine, scenarios, metrics, and validators.
4
+ """
5
+
6
+ __all__ = []
@@ -0,0 +1 @@
1
+ # Benchmarking core module
@@ -0,0 +1,12 @@
1
+ """Public API for the FBA-Bench Benchmarking Engine."""
2
+
3
+ from .core import Engine
4
+ from .models import EngineConfig, EngineReport, RunnerSpec, ScenarioSpec
5
+
6
+ __all__ = [
7
+ "Engine",
8
+ "EngineConfig",
9
+ "EngineReport",
10
+ "RunnerSpec",
11
+ "ScenarioSpec",
12
+ ]