tsagentkit 1.0.2__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 (129) hide show
  1. tsagentkit-1.0.2/.github/workflows/workflow.yml +82 -0
  2. tsagentkit-1.0.2/.gitignore +207 -0
  3. tsagentkit-1.0.2/.python-version +1 -0
  4. tsagentkit-1.0.2/AGENTS.md +43 -0
  5. tsagentkit-1.0.2/CLAUDE.md +169 -0
  6. tsagentkit-1.0.2/LICENSE +201 -0
  7. tsagentkit-1.0.2/PKG-INFO +371 -0
  8. tsagentkit-1.0.2/README.md +335 -0
  9. tsagentkit-1.0.2/docs/API_STABILITY.md +58 -0
  10. tsagentkit-1.0.2/docs/ARCHITECTURE.md +226 -0
  11. tsagentkit-1.0.2/docs/PRD.md +654 -0
  12. tsagentkit-1.0.2/docs/README.md +167 -0
  13. tsagentkit-1.0.2/docs/REBUILD_PLAN.md +146 -0
  14. tsagentkit-1.0.2/importlinter.ini +30 -0
  15. tsagentkit-1.0.2/main.py +6 -0
  16. tsagentkit-1.0.2/pyproject.toml +185 -0
  17. tsagentkit-1.0.2/skill/README.md +270 -0
  18. tsagentkit-1.0.2/skill/recipes.md +749 -0
  19. tsagentkit-1.0.2/skill/tool_map.md +718 -0
  20. tsagentkit-1.0.2/src/tsagentkit/__init__.py +126 -0
  21. tsagentkit-1.0.2/src/tsagentkit/anomaly/__init__.py +130 -0
  22. tsagentkit-1.0.2/src/tsagentkit/backtest/__init__.py +48 -0
  23. tsagentkit-1.0.2/src/tsagentkit/backtest/engine.py +788 -0
  24. tsagentkit-1.0.2/src/tsagentkit/backtest/metrics.py +244 -0
  25. tsagentkit-1.0.2/src/tsagentkit/backtest/report.py +342 -0
  26. tsagentkit-1.0.2/src/tsagentkit/calibration/__init__.py +136 -0
  27. tsagentkit-1.0.2/src/tsagentkit/contracts/__init__.py +133 -0
  28. tsagentkit-1.0.2/src/tsagentkit/contracts/errors.py +275 -0
  29. tsagentkit-1.0.2/src/tsagentkit/contracts/results.py +418 -0
  30. tsagentkit-1.0.2/src/tsagentkit/contracts/schema.py +44 -0
  31. tsagentkit-1.0.2/src/tsagentkit/contracts/task_spec.py +300 -0
  32. tsagentkit-1.0.2/src/tsagentkit/covariates/__init__.py +340 -0
  33. tsagentkit-1.0.2/src/tsagentkit/eval/__init__.py +285 -0
  34. tsagentkit-1.0.2/src/tsagentkit/features/__init__.py +20 -0
  35. tsagentkit-1.0.2/src/tsagentkit/features/covariates.py +328 -0
  36. tsagentkit-1.0.2/src/tsagentkit/features/extra/__init__.py +5 -0
  37. tsagentkit-1.0.2/src/tsagentkit/features/extra/native.py +179 -0
  38. tsagentkit-1.0.2/src/tsagentkit/features/factory.py +187 -0
  39. tsagentkit-1.0.2/src/tsagentkit/features/matrix.py +159 -0
  40. tsagentkit-1.0.2/src/tsagentkit/features/tsfeatures_adapter.py +115 -0
  41. tsagentkit-1.0.2/src/tsagentkit/features/versioning.py +203 -0
  42. tsagentkit-1.0.2/src/tsagentkit/hierarchy/__init__.py +39 -0
  43. tsagentkit-1.0.2/src/tsagentkit/hierarchy/aggregation.py +62 -0
  44. tsagentkit-1.0.2/src/tsagentkit/hierarchy/evaluator.py +400 -0
  45. tsagentkit-1.0.2/src/tsagentkit/hierarchy/reconciliation.py +232 -0
  46. tsagentkit-1.0.2/src/tsagentkit/hierarchy/structure.py +453 -0
  47. tsagentkit-1.0.2/src/tsagentkit/models/__init__.py +182 -0
  48. tsagentkit-1.0.2/src/tsagentkit/models/adapters/__init__.py +83 -0
  49. tsagentkit-1.0.2/src/tsagentkit/models/adapters/base.py +321 -0
  50. tsagentkit-1.0.2/src/tsagentkit/models/adapters/chronos.py +387 -0
  51. tsagentkit-1.0.2/src/tsagentkit/models/adapters/moirai.py +256 -0
  52. tsagentkit-1.0.2/src/tsagentkit/models/adapters/registry.py +171 -0
  53. tsagentkit-1.0.2/src/tsagentkit/models/adapters/timesfm.py +440 -0
  54. tsagentkit-1.0.2/src/tsagentkit/models/baselines.py +207 -0
  55. tsagentkit-1.0.2/src/tsagentkit/models/sktime.py +307 -0
  56. tsagentkit-1.0.2/src/tsagentkit/monitoring/__init__.py +51 -0
  57. tsagentkit-1.0.2/src/tsagentkit/monitoring/alerts.py +302 -0
  58. tsagentkit-1.0.2/src/tsagentkit/monitoring/coverage.py +203 -0
  59. tsagentkit-1.0.2/src/tsagentkit/monitoring/drift.py +330 -0
  60. tsagentkit-1.0.2/src/tsagentkit/monitoring/report.py +214 -0
  61. tsagentkit-1.0.2/src/tsagentkit/monitoring/stability.py +275 -0
  62. tsagentkit-1.0.2/src/tsagentkit/monitoring/triggers.py +423 -0
  63. tsagentkit-1.0.2/src/tsagentkit/qa/__init__.py +347 -0
  64. tsagentkit-1.0.2/src/tsagentkit/router/__init__.py +37 -0
  65. tsagentkit-1.0.2/src/tsagentkit/router/bucketing.py +489 -0
  66. tsagentkit-1.0.2/src/tsagentkit/router/fallback.py +132 -0
  67. tsagentkit-1.0.2/src/tsagentkit/router/plan.py +23 -0
  68. tsagentkit-1.0.2/src/tsagentkit/router/router.py +271 -0
  69. tsagentkit-1.0.2/src/tsagentkit/series/__init__.py +26 -0
  70. tsagentkit-1.0.2/src/tsagentkit/series/alignment.py +206 -0
  71. tsagentkit-1.0.2/src/tsagentkit/series/dataset.py +449 -0
  72. tsagentkit-1.0.2/src/tsagentkit/series/sparsity.py +261 -0
  73. tsagentkit-1.0.2/src/tsagentkit/series/validation.py +393 -0
  74. tsagentkit-1.0.2/src/tsagentkit/serving/__init__.py +39 -0
  75. tsagentkit-1.0.2/src/tsagentkit/serving/orchestration.py +943 -0
  76. tsagentkit-1.0.2/src/tsagentkit/serving/packaging.py +73 -0
  77. tsagentkit-1.0.2/src/tsagentkit/serving/provenance.py +317 -0
  78. tsagentkit-1.0.2/src/tsagentkit/serving/tsfm_cache.py +214 -0
  79. tsagentkit-1.0.2/src/tsagentkit/skill/README.md +135 -0
  80. tsagentkit-1.0.2/src/tsagentkit/skill/__init__.py +8 -0
  81. tsagentkit-1.0.2/src/tsagentkit/skill/recipes.md +429 -0
  82. tsagentkit-1.0.2/src/tsagentkit/skill/tool_map.md +21 -0
  83. tsagentkit-1.0.2/src/tsagentkit/time/__init__.py +134 -0
  84. tsagentkit-1.0.2/src/tsagentkit/utils/__init__.py +20 -0
  85. tsagentkit-1.0.2/src/tsagentkit/utils/quantiles.py +83 -0
  86. tsagentkit-1.0.2/src/tsagentkit/utils/signature.py +47 -0
  87. tsagentkit-1.0.2/src/tsagentkit/utils/temporal.py +41 -0
  88. tsagentkit-1.0.2/tests/anomaly/test_detection.py +29 -0
  89. tsagentkit-1.0.2/tests/backtest/test_engine.py +293 -0
  90. tsagentkit-1.0.2/tests/backtest/test_metrics.py +239 -0
  91. tsagentkit-1.0.2/tests/backtest/test_report.py +251 -0
  92. tsagentkit-1.0.2/tests/contracts/test_errors.py +92 -0
  93. tsagentkit-1.0.2/tests/contracts/test_results.py +252 -0
  94. tsagentkit-1.0.2/tests/contracts/test_schema.py +327 -0
  95. tsagentkit-1.0.2/tests/contracts/test_task_spec.py +88 -0
  96. tsagentkit-1.0.2/tests/covariates/test_align_covariates.py +104 -0
  97. tsagentkit-1.0.2/tests/features/__init__.py +0 -0
  98. tsagentkit-1.0.2/tests/features/test_covariates.py +230 -0
  99. tsagentkit-1.0.2/tests/features/test_factory.py +356 -0
  100. tsagentkit-1.0.2/tests/features/test_matrix.py +197 -0
  101. tsagentkit-1.0.2/tests/features/test_versioning.py +182 -0
  102. tsagentkit-1.0.2/tests/hierarchy/test_aggregation.py +81 -0
  103. tsagentkit-1.0.2/tests/hierarchy/test_evaluator.py +251 -0
  104. tsagentkit-1.0.2/tests/hierarchy/test_reconciliation.py +220 -0
  105. tsagentkit-1.0.2/tests/hierarchy/test_structure.py +341 -0
  106. tsagentkit-1.0.2/tests/models/adapters/test_adapters.py +260 -0
  107. tsagentkit-1.0.2/tests/models/adapters/test_base.py +326 -0
  108. tsagentkit-1.0.2/tests/models/adapters/test_tsfm_runtime.py +76 -0
  109. tsagentkit-1.0.2/tests/models/test_baselines.py +219 -0
  110. tsagentkit-1.0.2/tests/models/test_sktime_adapter.py +49 -0
  111. tsagentkit-1.0.2/tests/monitoring/test_coverage.py +136 -0
  112. tsagentkit-1.0.2/tests/monitoring/test_drift.py +221 -0
  113. tsagentkit-1.0.2/tests/monitoring/test_stability.py +331 -0
  114. tsagentkit-1.0.2/tests/monitoring/test_triggers.py +325 -0
  115. tsagentkit-1.0.2/tests/qa/test_qa.py +92 -0
  116. tsagentkit-1.0.2/tests/router/test_bucketing.py +363 -0
  117. tsagentkit-1.0.2/tests/router/test_fallback.py +69 -0
  118. tsagentkit-1.0.2/tests/router/test_plan.py +28 -0
  119. tsagentkit-1.0.2/tests/router/test_router.py +42 -0
  120. tsagentkit-1.0.2/tests/series/test_alignment.py +176 -0
  121. tsagentkit-1.0.2/tests/series/test_dataset.py +245 -0
  122. tsagentkit-1.0.2/tests/series/test_sparsity.py +176 -0
  123. tsagentkit-1.0.2/tests/serving/test_orchestration.py +263 -0
  124. tsagentkit-1.0.2/tests/serving/test_packaging.py +139 -0
  125. tsagentkit-1.0.2/tests/serving/test_provenance.py +319 -0
  126. tsagentkit-1.0.2/tests/test_integration_v1.py +386 -0
  127. tsagentkit-1.0.2/tests/test_v02_integration.py +401 -0
  128. tsagentkit-1.0.2/tests/utils/test_quantiles.py +51 -0
  129. tsagentkit-1.0.2/uv.lock +4062 -0
@@ -0,0 +1,82 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ tags:
8
+ - 'v*'
9
+ pull_request:
10
+ branches:
11
+ - main
12
+
13
+ jobs:
14
+ test:
15
+ runs-on: ubuntu-latest
16
+ strategy:
17
+ matrix:
18
+ python-version: ['3.11', '3.12']
19
+
20
+ steps:
21
+ - uses: actions/checkout@v4
22
+
23
+ - name: Install uv
24
+ uses: astral-sh/setup-uv@v3
25
+ with:
26
+ version: 'latest'
27
+
28
+ - name: Set up Python
29
+ uses: actions/setup-python@v5
30
+ with:
31
+ python-version: ${{ matrix.python-version }}
32
+
33
+ - name: Install dependencies
34
+ run: uv sync --extra dev
35
+
36
+ - name: Run type checks
37
+ run: uv run mypy src/tsagentkit
38
+
39
+ - name: Run linting
40
+ run: uv run ruff check src/
41
+
42
+ - name: Run tests
43
+ run: uv run pytest --cov=src/tsagentkit -v
44
+
45
+ build:
46
+ runs-on: ubuntu-latest
47
+ needs: test
48
+ if: startsWith(github.ref, 'refs/tags/v')
49
+
50
+ steps:
51
+ - uses: actions/checkout@v4
52
+
53
+ - name: Install uv
54
+ uses: astral-sh/setup-uv@v3
55
+ with:
56
+ version: 'latest'
57
+
58
+ - name: Build package
59
+ run: uv build
60
+
61
+ - name: Upload distributions
62
+ uses: actions/upload-artifact@v4
63
+ with:
64
+ name: dist
65
+ path: dist/
66
+
67
+ publish:
68
+ runs-on: ubuntu-latest
69
+ needs: build
70
+ if: startsWith(github.ref, 'refs/tags/v')
71
+ permissions:
72
+ id-token: write
73
+
74
+ steps:
75
+ - name: Download distributions
76
+ uses: actions/download-artifact@v4
77
+ with:
78
+ name: dist
79
+ path: dist/
80
+
81
+ - name: Publish to PyPI
82
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,207 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ #uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ #poetry.lock
109
+ #poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ #pdm.lock
116
+ #pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ #pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # SageMath parsed files
135
+ *.sage.py
136
+
137
+ # Environments
138
+ .env
139
+ .envrc
140
+ .venv
141
+ env/
142
+ venv/
143
+ ENV/
144
+ env.bak/
145
+ venv.bak/
146
+
147
+ # Spyder project settings
148
+ .spyderproject
149
+ .spyproject
150
+
151
+ # Rope project settings
152
+ .ropeproject
153
+
154
+ # mkdocs documentation
155
+ /site
156
+
157
+ # mypy
158
+ .mypy_cache/
159
+ .dmypy.json
160
+ dmypy.json
161
+
162
+ # Pyre type checker
163
+ .pyre/
164
+
165
+ # pytype static type analyzer
166
+ .pytype/
167
+
168
+ # Cython debug symbols
169
+ cython_debug/
170
+
171
+ # PyCharm
172
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
173
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
174
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
175
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
176
+ #.idea/
177
+
178
+ # Abstra
179
+ # Abstra is an AI-powered process automation framework.
180
+ # Ignore directories containing user credentials, local state, and settings.
181
+ # Learn more at https://abstra.io/docs
182
+ .abstra/
183
+
184
+ # Visual Studio Code
185
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
186
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
187
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
188
+ # you could uncomment the following to ignore the entire vscode folder
189
+ # .vscode/
190
+
191
+ # Ruff stuff:
192
+ .ruff_cache/
193
+
194
+ # PyPI configuration file
195
+ .pypirc
196
+
197
+ # Cursor
198
+ # Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
199
+ # exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
200
+ # refer to https://docs.cursor.com/context/ignore-files
201
+ .cursorignore
202
+ .cursorindexingignore
203
+
204
+ # Marimo
205
+ marimo/_static/
206
+ marimo/_lsp/
207
+ __marimo__/
@@ -0,0 +1 @@
1
+ 3.11
@@ -0,0 +1,43 @@
1
+ # Repository Guidelines
2
+
3
+ ## Python Environment
4
+
5
+ - Python version: 3.11
6
+ - Dependencies: Listed in `pyproject.toml`.
7
+ - Always use `uv` to manage dependencies.
8
+ - Add packages to `pyproject.toml` as needed.
9
+ - Use `uv sync` to install dependencies.
10
+ - Use `uv run <command>` to run commands with the correct environment.
11
+
12
+ ## Project Structure & Module Organization
13
+ This repository contains implementation and documentation:
14
+ - `docs/PRD.md`: Technical requirements and module layout.
15
+ - `src/tsagentkit/`: Core Python packages such as `contracts/`, `qa/`, `series/`, `features/`, `router/`, `models/`, `backtest/`, `serving/`, `monitoring/`, and `skill/`.
16
+ - `tests/`: Test suite mirroring the package structure (e.g., `tests/contracts/`).
17
+
18
+ ## Build, Test, and Development Commands
19
+ - Run unit/integration tests: `uv run pytest`
20
+ - Run real TSFM smoke tests (downloads models): `TSFM_RUN_REAL=1 uv run pytest -m tsfm`
21
+ - Prefer single-entry commands (e.g., `python -m pytest`) over custom scripts unless needed.
22
+
23
+ ## Coding Style & Naming Conventions
24
+ `tsagentkit` is intended to be a Python library (see `docs/PRD.md`). Until tooling is added, follow standard Python conventions:
25
+ - Indentation: 4 spaces; no tabs.
26
+ - Naming: `snake_case` for functions/variables, `PascalCase` for classes, `UPPER_SNAKE_CASE` for constants.
27
+ - Types: add type hints for public APIs and key data structures.
28
+
29
+ ## Testing Guidelines
30
+ - Prefer deterministic, time-order-safe cases (no random splits; see `E_SPLIT_RANDOM_FORBIDDEN` in the PRD).
31
+ - Name tests descriptively (e.g., `test_router_fallback_ladder`).
32
+ - Document test runner commands in this file and in the README.
33
+
34
+ ## Commit & Pull Request Guidelines
35
+ Git history is minimal and uses short, plain summaries (e.g., “init”, “Initial commit”), so no formal convention is established. Use clear, imperative subject lines and keep each commit focused.
36
+
37
+ For PRs:
38
+ - Describe the change, scope, and any new modules.
39
+ - Link related issues or PRDs when applicable.
40
+ - Call out any deviations from the PRD or new guardrail behavior.
41
+
42
+ ## Agent-Specific Instructions
43
+ If you add or update agent-facing documentation, place it under `skill/` and keep the “What/When/Inputs/Workflow” format described in `docs/PRD.md`.
@@ -0,0 +1,169 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Project Overview
6
+
7
+ `tsagentkit` is a Python library that serves as a robust execution engine for external coding agents (LLMs/AI agents) performing time-series forecasting tasks. It provides strict guardrails to enforce proper time-series practices (preventing data leakage, enforcing temporal integrity, etc.).
8
+
9
+ **Version**: 1.0.2 (Released)
10
+
11
+ ## Python Environment
12
+
13
+ - Python version: 3.11
14
+ - Dependencies: Listed in `pyproject.toml`.
15
+ - Always use `uv` to manage dependencies.
16
+ - Add packages to `pyproject.toml` as needed.
17
+ - Use `uv sync` to install dependencies.
18
+ - Use `uv run <command>` to run commands with the correct environment.
19
+
20
+ ## Architecture
21
+
22
+ The codebase follows this workflow pipeline:
23
+
24
+ ```
25
+ validate -> QA -> series -> route -> backtest -> fit -> predict -> package
26
+ ```
27
+
28
+ ### Module Structure
29
+
30
+ | Module | Responsibility | Key Output |
31
+ |--------|---------------|------------|
32
+ | `contracts/` | Data validation, task specifications | `ValidationReport`, `TaskSpec` |
33
+ | `qa/` | Data quality checks, leakage detection | `QAReport` |
34
+ | `series/` | Time alignment, resampling, sparsity ID | `TSDataset`, `SparsityProfile` |
35
+ | `features/` | Feature engineering, covariate alignment | `FeatureMatrix`, signatures |
36
+ | `router/` | Model selection, fallback strategies | `Plan` |
37
+ | `models/` | Model adapters and baselines | `ModelArtifact`, `ForecastResult` |
38
+ | `backtest/` | Rolling window backtesting | `BacktestReport`, `SegmentMetrics`, `TemporalMetrics` |
39
+ | `serving/` | Batch inference | `RunArtifact` |
40
+ | `monitoring/` | Drift detection, retrain triggers | `DriftReport` |
41
+ | `skill/` | Documentation and recipes for AI agents | Recipes, tool maps |
42
+ | `hierarchy/` | Hierarchical forecasting | `HierarchyStructure`, reconciliation methods |
43
+
44
+ ### Key Design Principles
45
+
46
+ 1. **TSFM-first Strategy**: Time-Series Foundation Models are the primary choice, with automatic fallback to simpler models on failure.
47
+
48
+ 2. **Fallback Ladder**: TSFM -> Lightweight (optional) -> Tree/Baseline -> Naive
49
+
50
+ 3. **Strict Guardrails**:
51
+ - `E_SPLIT_RANDOM_FORBIDDEN`: Random train/test splits are banned
52
+ - `E_COVARIATE_LEAKAGE`: Future leakage detection
53
+ - Temporal integrity enforced throughout
54
+
55
+ 4. **Provenance**: Full traceability with signatures for data, features, model config, and plan
56
+
57
+ ## Build, Test, and Development Commands
58
+
59
+ ### Running Tests
60
+
61
+ ```bash
62
+ # Run all tests
63
+ uv run python -m pytest
64
+
65
+ # Run tests with coverage
66
+ uv run python -m pytest --cov=src/tsagentkit --cov-report=term-missing
67
+
68
+ # Run specific test file
69
+ uv run python -m pytest tests/contracts/test_task_spec.py -v
70
+
71
+ # Run tests for a specific module
72
+ uv run python -m pytest tests/backtest/ -v
73
+ ```
74
+
75
+ ### Type Checking
76
+
77
+ ```bash
78
+ # Run mypy type checker
79
+ uv run mypy src/tsagentkit
80
+ ```
81
+
82
+ ### Code Formatting and Linting
83
+
84
+ ```bash
85
+ # Format code with ruff
86
+ uv run ruff format src/
87
+
88
+ # Check code with ruff
89
+ uv run ruff check src/
90
+
91
+ # Fix auto-fixable issues
92
+ uv run ruff check src/ --fix
93
+ ```
94
+
95
+ ### Running Examples
96
+
97
+ ```bash
98
+ # Run a quick forecast example
99
+ uv run python -c "
100
+ import pandas as pd
101
+ from tsagentkit import TaskSpec, run_forecast
102
+
103
+ df = pd.DataFrame({
104
+ 'unique_id': ['A'] * 30,
105
+ 'ds': pd.date_range('2024-01-01', periods=30),
106
+ 'y': range(30)
107
+ })
108
+ result = run_forecast(df, TaskSpec(h=7, freq='D'))
109
+ print(result.summary())
110
+ "
111
+ ```
112
+
113
+ ## Coding Conventions
114
+
115
+ - **Language**: Python
116
+ - **Indentation**: 4 spaces; no tabs
117
+ - **Naming**: `snake_case` for functions/variables, `PascalCase` for classes, `UPPER_SNAKE_CASE` for constants
118
+ - **Types**: Add type hints for public APIs and key data structures
119
+
120
+ ## Testing Guidelines
121
+
122
+ - Place tests in a top-level `tests/` directory that mirrors the package structure (e.g., `tests/contracts/`)
123
+ - Prefer deterministic, time-order-safe cases (no random splits; see `E_SPLIT_RANDOM_FORBIDDEN` in the PRD)
124
+ - Name tests descriptively (e.g., `test_router_fallback_ladder`)
125
+
126
+ ## Key Documentation
127
+
128
+ - `docs/PRD.md`: Technical requirements and architecture document
129
+ - `AGENTS.md`: Repository guidelines for AI agents
130
+ - `skill/README.md`: Agent documentation with module guide
131
+ - `skill/tool_map.md`: Complete API reference
132
+ - `skill/recipes.md`: Runnable end-to-end examples
133
+
134
+ ## Version Roadmap
135
+
136
+ - **v0.1** ✅: Minimum loop (contracts, qa, series, basic router, baseline models, rolling backtest)
137
+ - **v0.2** ✅: Enhanced robustness (monitoring, advanced router, feature hashing)
138
+ - **v1.0** ✅: Ecosystem (external adapters, hierarchical reconciliation, structured logging)
139
+
140
+ ## Quick Reference
141
+
142
+ ### Common Imports
143
+
144
+ ```python
145
+ from tsagentkit import (
146
+ TaskSpec, # Define forecasting tasks
147
+ validate_contract, # Validate input data
148
+ run_forecast, # Main entry point
149
+ TSDataset, # Time series dataset
150
+ Plan, # Execution plan
151
+ BacktestReport, # Backtest results
152
+ # Errors
153
+ ESplitRandomForbidden,
154
+ ECovariateLeakage,
155
+ )
156
+ ```
157
+
158
+ ### Main Entry Point
159
+
160
+ ```python
161
+ from tsagentkit import TaskSpec, run_forecast
162
+
163
+ spec = TaskSpec(h=7, freq="D", quantiles=[0.1, 0.5, 0.9])
164
+ result = run_forecast(data, spec, mode="standard")
165
+
166
+ # Access results
167
+ forecast_df = result.forecast.df
168
+ backtest_metrics = result.backtest_report.aggregate_metrics
169
+ ```