keble-task 2.22.0__tar.gz → 2.24.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.
- keble_task-2.24.0/AGENTS.md +46 -0
- keble_task-2.24.0/AiAgentChangesLogs.md +99 -0
- keble_task-2.24.0/CLAUDE.md +5 -0
- keble_task-2.24.0/PKG-INFO +94 -0
- keble_task-2.24.0/README.md +78 -0
- {keble_task-2.22.0 → keble_task-2.24.0}/keble_task/main.py +7 -8
- {keble_task-2.22.0 → keble_task-2.24.0}/keble_task/schemas/__init__.py +435 -110
- keble_task-2.24.0/keble_task/testing/__init__.py +12 -0
- keble_task-2.24.0/keble_task/testing/config.py +169 -0
- keble_task-2.24.0/keble_task/testing/factories.py +67 -0
- keble_task-2.22.0/AiAgentChangesLogs.md → keble_task-2.24.0/logs/AiAgentChangesLogs.20260630.md +13 -0
- {keble_task-2.22.0 → keble_task-2.24.0}/pyproject.poetry.toml +2 -2
- {keble_task-2.22.0 → keble_task-2.24.0}/pyproject.toml +4 -6
- {keble_task-2.22.0 → keble_task-2.24.0}/tests/conftest.py +61 -45
- {keble_task-2.22.0/tests → keble_task-2.24.0/tests/contract/events}/test_emit_drain_contract.py +1 -1
- {keble_task-2.22.0/tests → keble_task-2.24.0/tests/contract/schemas}/test_metadata_jsonable_read.py +1 -2
- {keble_task-2.22.0/tests → keble_task-2.24.0/tests/integration/actions}/test_task_actions.py +1 -1
- {keble_task-2.22.0/tests → keble_task-2.24.0/tests/integration/agent}/test_agent_query_registry.py +3 -5
- {keble_task-2.22.0/tests → keble_task-2.24.0/tests/integration/agent}/test_agent_registry.py +1 -1
- {keble_task-2.22.0/tests → keble_task-2.24.0/tests/integration/core}/test_main.py +1 -1
- {keble_task-2.22.0/tests → keble_task-2.24.0/tests/integration/costs}/test_task_costs.py +30 -14
- {keble_task-2.22.0/tests → keble_task-2.24.0/tests/integration/relations}/test_task_relations.py +1 -1
- {keble_task-2.22.0/tests → keble_task-2.24.0/tests/integration/tree}/test_tree_and_public_id_edges.py +1 -1
- {keble_task-2.22.0/tests → keble_task-2.24.0/tests/live/llm}/test_agent_registry_live.py +5 -4
- {keble_task-2.22.0/tests → keble_task-2.24.0/tests/unit/core}/test_metadata_flow.py +3 -49
- {keble_task-2.22.0/tests → keble_task-2.24.0/tests/unit/core}/test_retry_attempt_logging.py +1 -1
- {keble_task-2.22.0/tests → keble_task-2.24.0/tests/unit/schemas}/test_schemas.py +52 -0
- keble_task-2.24.0/tests/unit/schemas/test_task_cost_token_rates.py +292 -0
- keble_task-2.24.0/tests/unit/testing/test_config.py +96 -0
- {keble_task-2.22.0 → keble_task-2.24.0}/uv.lock +13 -78
- keble_task-2.22.0/AGENTS.md +0 -18
- keble_task-2.22.0/CLAUDE.md +0 -15
- keble_task-2.22.0/PKG-INFO +0 -1083
- keble_task-2.22.0/README.md +0 -1067
- keble_task-2.22.0/tests/config.py +0 -85
- keble_task-2.22.0/tests/pytest.ini +0 -3
- keble_task-2.22.0/tests/schemas/__init__.py +0 -0
- keble_task-2.22.0/tests/utils.py +0 -3
- {keble_task-2.22.0 → keble_task-2.24.0}/.gitattributes +0 -0
- {keble_task-2.22.0 → keble_task-2.24.0}/.gitignore +0 -0
- {keble_task-2.22.0 → keble_task-2.24.0}/.python-version +0 -0
- {keble_task-2.22.0 → keble_task-2.24.0}/deps/keble_typing-0.3.3-py3-none-any.whl +0 -0
- {keble_task-2.22.0 → keble_task-2.24.0}/improve.README.md +0 -0
- {keble_task-2.22.0 → keble_task-2.24.0}/keble_task/__init__.py +0 -0
- {keble_task-2.22.0 → keble_task-2.24.0}/keble_task/actions.py +0 -0
- {keble_task-2.22.0 → keble_task-2.24.0}/keble_task/agent/__init__.py +0 -0
- {keble_task-2.22.0 → keble_task-2.24.0}/keble_task/agent/chat_provider.py +0 -0
- {keble_task-2.22.0 → keble_task-2.24.0}/keble_task/agent/deps.py +0 -0
- {keble_task-2.22.0 → keble_task-2.24.0}/keble_task/agent/tools/__init__.py +0 -0
- {keble_task-2.22.0 → keble_task-2.24.0}/keble_task/agent/tools/mutation.py +0 -0
- {keble_task-2.22.0 → keble_task-2.24.0}/keble_task/agent/tools/query.py +0 -0
- {keble_task-2.22.0 → keble_task-2.24.0}/keble_task/crud.py +0 -0
- {keble_task-2.22.0 → keble_task-2.24.0}/keble_task/exceptions.py +0 -0
- {keble_task-2.22.0 → keble_task-2.24.0}/keble_task/schemas/for_agent.py +0 -0
- {keble_task-2.22.0 → keble_task-2.24.0}/keble_task/task_tree.py +0 -0
- {keble_task-2.22.0 → keble_task-2.24.0}/keble_task/utils.py +0 -0
- {keble_task-2.22.0 → keble_task-2.24.0}/poetry.lock +0 -0
- {keble_task-2.22.0 → keble_task-2.24.0}/pyrightconfig.json +0 -0
- {keble_task-2.22.0/tests → keble_task-2.24.0/tests/contract/schemas}/__init__.py +0 -0
- {keble_task-2.22.0/tests → keble_task-2.24.0/tests/contract}/schemas/test_for_agent.py +0 -0
- {keble_task-2.22.0/tests → keble_task-2.24.0/tests/contract/schemas}/test_no_local_datetime_helpers.py +0 -0
- {keble_task-2.22.0/tests → keble_task-2.24.0/tests/integration/public}/test_public_indexable.py +0 -0
- {keble_task-2.22.0/tests → keble_task-2.24.0/tests/unit/agent}/test_agent_chat_provider.py +0 -0
- {keble_task-2.22.0/tests → keble_task-2.24.0/tests/unit/core}/test_exceptions.py +0 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Keble Task Agent Instructions
|
|
2
|
+
|
|
3
|
+
Follow the root `TESTING_GUIDELINE.md` when changing tests in this repo.
|
|
4
|
+
|
|
5
|
+
## Testing Rules
|
|
6
|
+
|
|
7
|
+
- The normal Keble local development command is local-full and should run
|
|
8
|
+
Mongo/Redis-heavy tests by default:
|
|
9
|
+
`RUN_INTEGRATION=1 RUN_REAL_DB=1 RUN_LOCAL_STACK=1 RUN_DB_STACK=1 uv run pytest -q -m "not live and not container"`.
|
|
10
|
+
- Keep the portable-offline fallback available for machines without local DBs:
|
|
11
|
+
`uv run pytest -q -m "not live and not slow and not eval and not local_stack and not db_stack and not container"`.
|
|
12
|
+
- The live LLM test must stay marked `live` and `llm` and must require
|
|
13
|
+
`RUN_LLM_LIVE=1`.
|
|
14
|
+
- Put executable tests under canonical layer folders only: `tests/unit/`,
|
|
15
|
+
`tests/contract/`, `tests/integration/`, `tests/live/`, `tests/evals/`, or
|
|
16
|
+
`tests/db_stack/`.
|
|
17
|
+
- Do not add flat `tests/test_*.py`, `tests/schemas/`, `tests/mock/`, or
|
|
18
|
+
`tests/irl/` folders.
|
|
19
|
+
- Do not recreate root-level `tests/config.py`, `tests/utils.py`, or an
|
|
20
|
+
importable root `tests` package. Shared test doubles and settings belong in
|
|
21
|
+
`keble_task.testing`.
|
|
22
|
+
- Tests that use Mongo/Redis fixtures are local-stack integration DB tests and
|
|
23
|
+
must be marked with `integration`, `db`, `mongo`, `redis`, and `local_stack`;
|
|
24
|
+
they must run under the local-full command and must not be selected by the
|
|
25
|
+
portable-offline command.
|
|
26
|
+
- Selected DB tests must fail with a clear missing-config message when Mongo or
|
|
27
|
+
Redis cannot be resolved; do not hide selected DB coverage behind lazy skips.
|
|
28
|
+
- Use `keble_task.testing.config` for test credentials. It reads explicit env /
|
|
29
|
+
`tests/.env` / the umbrella `keble.backend/.env`, maps backend Azure provider
|
|
30
|
+
lists into the live LLM canary, and keeps test database names isolated.
|
|
31
|
+
- Use shared fixtures from `keble_db.testing` as the DB testing toolkit expands;
|
|
32
|
+
do not introduce ad-hoc shared local database writes.
|
|
33
|
+
- Put quality/regression suites under `tests/evals/` and mark them `eval`.
|
|
34
|
+
Selecting `uv run pytest -q -m eval` is the eval opt-in; do not add a generic
|
|
35
|
+
`RUN_EVALS` skip gate. Provider-backed evals also need `live` plus the
|
|
36
|
+
provider marker and provider-specific env gate.
|
|
37
|
+
- Do not add empty pytest lifecycle hooks, empty test folders, `pass`, `...`, or
|
|
38
|
+
status-only tests as placeholders. Add meaningful assertions or remove the
|
|
39
|
+
placeholder module.
|
|
40
|
+
- Do not add full stack or live-provider behavior to the default test command.
|
|
41
|
+
- Run the local-full command, portable-offline fallback, `uv run pytest -q -m eval`,
|
|
42
|
+
changed layer selectors, and `npx --yes pyright .` after
|
|
43
|
+
test-infrastructure changes.
|
|
44
|
+
- Update `README.md`, `AGENTS.md`, `CLAUDE.md`, and `AiAgentChangesLogs.md`
|
|
45
|
+
whenever testing behavior, markers, fixtures, commands, or dependencies
|
|
46
|
+
change.
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
## 2026-07-08 — 2.23.0 (TaskBase.thinking_mode, Program AP)
|
|
2
|
+
State: branch feature/task-thinking-mode off main a071a29.
|
|
3
|
+
|
|
4
|
+
zma: user-selectable thinking mode (speed-first vs quality-first) must be explicitly recorded at the keble-task level and inherited task->subtasks.
|
|
5
|
+
|
|
6
|
+
Ai: TaskBase gains first-class `thinking_mode: Optional[str]` (open str per the framework-fields-stay-str convention; camelCase wire `thinkingMode`; None = legacy = QUALITY_FIRST downstream) beside `language`; `TaskClient.acreate` gains the `thinking_mode` kwarg threaded into TaskBase. Tests: camelCase round-trip + legacy-dump-None. 49 offline pass; pyright 0.
|
|
7
|
+
|
|
8
|
+
# Ai Agent Changes Logs
|
|
9
|
+
|
|
10
|
+
Historical entries before 2026-06-30 23:13 were moved to `logs/AiAgentChangesLogs.20260630.md`.
|
|
11
|
+
|
|
12
|
+
## 2026-07-18 04:25 CST
|
|
13
|
+
State: `fix/review2-exact-task-cost-rates`; REVIEW2 WP2 task-cost dependency
|
|
14
|
+
correction implemented and verified before backend consumer migration.
|
|
15
|
+
|
|
16
|
+
zma:
|
|
17
|
+
- Continue the finalized Data Infra REVIEW2 plan, double-check every edge case,
|
|
18
|
+
and leave all repositories wired, released, and merged only after full proof.
|
|
19
|
+
|
|
20
|
+
Ai:
|
|
21
|
+
- Corrected a WP0 census miss: per-million token prices cannot use ISO `Money`
|
|
22
|
+
because valid prices such as USD 0.075 require fractional cents.
|
|
23
|
+
- Reused shared `LlmTokenPriceBand` integer micros inside `TaskCostTokenRates`,
|
|
24
|
+
added a bounded 2.24.x reader for legacy Money-shaped rows, and locked removal
|
|
25
|
+
to 2.25.0 after the repair sweep.
|
|
26
|
+
- Added exact Decimal FX, exponent-0/2/3 additional-cost decoding, cached-input
|
|
27
|
+
de-duplication, typed missing-price failures, and rejection of sub-micro or
|
|
28
|
+
mixed-currency rates. Removed the public-package local source override and
|
|
29
|
+
resolved the released `keble-helpers 1.54.0` artifact.
|
|
30
|
+
- Proof: 9 focused unit tests, 58 portable tests, 14 cost integrations, and 172
|
|
31
|
+
isolated local-full tests passed; Pyright and Ruff checks passed on source,
|
|
32
|
+
and isolated Mongo/Redis collections were empty before container removal.
|
|
33
|
+
|
|
34
|
+
## 2026-07-02 21:12 CST
|
|
35
|
+
State: branch `refactor/local-db-evals-keble-task`; local-full pytest default and eval selector cleanup.
|
|
36
|
+
|
|
37
|
+
zma:
|
|
38
|
+
- Change the testing standard so local DB-heavy tests run by default in the Keble local-full lane.
|
|
39
|
+
- Keep portable-offline tests available, move quality/eval tests to the eval layer, and run eval selections separately.
|
|
40
|
+
|
|
41
|
+
Ai:
|
|
42
|
+
- Removed the legacy `RUN_INTEGRATION` collection skip from Mongo/Redis integration tests; local-stack integration tests now run when selected by the local-full command or `-m integration`.
|
|
43
|
+
- Changed missing Mongo/Redis config in selected DB fixtures from lazy skip to clear pytest failure, while keeping live LLM gated by `RUN_LLM_LIVE=1`.
|
|
44
|
+
- Updated README, AGENTS, and CLAUDE testing instructions with the local-full command, portable-offline fallback, direct `-m eval` selection, and no generic `RUN_EVALS` gate.
|
|
45
|
+
- Proof: local-full `161 passed, 1 deselected` in pytest `2.74s` / wall `21.35s`; portable-offline `47 passed, 115 deselected` in pytest `0.35s` / wall `1.92s`; unit `35 passed, 127 deselected`; contract `12 passed, 150 deselected`; integration `114 passed, 48 deselected`; eval and db_stack selected no tests; `npx --yes pyright .` `0 errors`; `uv build` produced `keble_task-2.22.1`.
|
|
46
|
+
|
|
47
|
+
## 2026-07-02 15:29 CST
|
|
48
|
+
State: branch `refactor/harden-pytests-keble-task`; marker tightening for the cross-repo pytest hardening follow-up.
|
|
49
|
+
|
|
50
|
+
zma:
|
|
51
|
+
- Continue the repo-by-repo pytest hardening.
|
|
52
|
+
- Ensure default tests stay offline while DB/LLM tests remain useful and explicitly marked.
|
|
53
|
+
|
|
54
|
+
Ai:
|
|
55
|
+
- Marked Mongo/Redis integration and live LLM tests as `local_stack` in the collection hook.
|
|
56
|
+
- Added `RUN_INTEGRATION=1` gating for Mongo/Redis integration tests so default pytest no longer runs real local-stack services opportunistically.
|
|
57
|
+
- Updated README, AGENTS, and CLAUDE testing instructions with the stricter command split.
|
|
58
|
+
- Proof: default `47 passed, 115 deselected in 0.28s`; unit `35 passed, 127 deselected in 0.27s`; contract `12 passed, 150 deselected in 0.24s`; integration with `RUN_INTEGRATION=1` `114 passed, 48 deselected in 1.87s`; `db` `114 passed, 1 skipped, 47 deselected in 1.90s`; `mongo` `114 passed, 1 skipped, 47 deselected in 1.90s`; `redis` `114 passed, 1 skipped, 47 deselected in 1.87s`; `local_stack` `114 passed, 1 skipped, 47 deselected in 1.84s`; live guard `1 skipped, 161 deselected in 0.19s`; live LLM with `RUN_LLM_LIVE=1` `1 passed, 161 deselected in 7.18s`; asyncio with `RUN_INTEGRATION=1` `103 passed, 1 skipped, 58 deselected in 1.94s`; `npx --yes pyright .` `0 errors`; `uv build` succeeded.
|
|
59
|
+
|
|
60
|
+
## 2026-07-02 00:58 CST
|
|
61
|
+
State: branch `refactor/harden-pytests-keble-task`; pytest hardening follow-up for `prompts/202060701/1.5-harden-pytests-and-remove-redundant.md`.
|
|
62
|
+
|
|
63
|
+
zma:
|
|
64
|
+
- Execute the cross-repo pytest hardening plan repo by repo.
|
|
65
|
+
- Reconsider over-trimmed IRL tests, remove weak placeholders, and use `keble.backend/.env` credentials instead of skipping DB/LLM tests for missing repo-local env.
|
|
66
|
+
|
|
67
|
+
Ai:
|
|
68
|
+
- Bumped `keble-task` to `2.22.1` and raised the `keble-db` dependency to `>=1.8.1`.
|
|
69
|
+
- Updated `keble_task.testing.config` to read explicit env / `tests/.env` / backend `.env` for Mongo and Redis, and to map the first backend Azure endpoint/token/deployment into the live LLM canary.
|
|
70
|
+
- Added unit coverage for backend env fallback, Azure provider-list mapping, and explicit-env precedence.
|
|
71
|
+
- Removed empty pytest lifecycle hooks from `tests/conftest.py` and updated docs to forbid placeholder test modules/hooks.
|
|
72
|
+
- Proof: config focus `3 passed`; default pytest `161 passed, 1 deselected`; unit `35 passed, 127 deselected`; contract `12 passed, 150 deselected`; integration `114 passed, 48 deselected`; live LLM guard `1 skipped, 161 deselected`; opt-in live LLM `1 passed, 161 deselected`; pyright `0 errors`; `uv build` succeeded.
|
|
73
|
+
|
|
74
|
+
## 2026-07-01 03:32
|
|
75
|
+
State: Strict testing-folder follow-up for `keble-task`; no runtime task API behavior, schemas, or dependencies changed.
|
|
76
|
+
|
|
77
|
+
zma:
|
|
78
|
+
- Continue the cross-repo testing refactor after tightening `TESTING_GUIDELINE.md` marker and folder allowances.
|
|
79
|
+
- Enforce canonical test layer folders and package-owned shared test helpers.
|
|
80
|
+
|
|
81
|
+
Ai:
|
|
82
|
+
- Moved test settings into `keble_task.testing.config`.
|
|
83
|
+
- Moved shared in-memory task test doubles and factories into `keble_task.testing.factories`.
|
|
84
|
+
- Removed root `tests/config.py`, `tests/utils.py`, `tests/pytest.ini`, and `tests/__init__.py` so tests no longer import through `tests.*`.
|
|
85
|
+
- Updated docs to keep future shared task test helpers under `keble_task.testing`.
|
|
86
|
+
|
|
87
|
+
## 2026-06-30 23:13
|
|
88
|
+
State: Documentation-only README compaction and AI log archival; no runtime code, schemas, dependencies, or tests were changed.
|
|
89
|
+
|
|
90
|
+
zma:
|
|
91
|
+
- Auto compact and summarize README.md files across repos unless already small.
|
|
92
|
+
- Cross-check retained README information for validity and keep only critical, necessary information.
|
|
93
|
+
- Move lengthy AiAgentChangesLogs.md files into repo-local logs/AiAgentChangesLogs.2026****.md.
|
|
94
|
+
- Merge the documentation changes to main repo by repo.
|
|
95
|
+
|
|
96
|
+
Ai:
|
|
97
|
+
- Archived the previous long agent change log into `logs/AiAgentChangesLogs.20260630.md`.
|
|
98
|
+
- Compacted `README.md` to current purpose, validated wiring, install/test gates, and high-risk side effects.
|
|
99
|
+
- Kept only critical current README facts cross-checked against manifests, config, source roots, compose scripts, or existing guideline files.
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: keble-task
|
|
3
|
+
Version: 2.24.0
|
|
4
|
+
Author-email: zhenhao-ma <bob0103779@gmail.com>
|
|
5
|
+
Requires-Python: <3.14,>=3.13
|
|
6
|
+
Requires-Dist: keble-db<2.0.0,>=1.8.1
|
|
7
|
+
Requires-Dist: keble-helpers<2.0.0,>=1.54.0
|
|
8
|
+
Requires-Dist: pydantic-ai-slim<2.0.0,>=1.41.0
|
|
9
|
+
Requires-Dist: tenacity<10.0.0,>=9
|
|
10
|
+
Provides-Extra: test
|
|
11
|
+
Requires-Dist: httpx[socks]<1.0.0,>=0.27; extra == 'test'
|
|
12
|
+
Requires-Dist: pydantic-ai-slim[openai]<2.0.0,>=1.41.0; extra == 'test'
|
|
13
|
+
Requires-Dist: pytest-asyncio<1.0.0,>=0; extra == 'test'
|
|
14
|
+
Requires-Dist: pytest<9.0.0,>=8; extra == 'test'
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
|
|
17
|
+
# keble-task
|
|
18
|
+
|
|
19
|
+
`keble-task` owns generic Keble task schemas, task relations, task-room graph
|
|
20
|
+
context, lifecycle/action events, task cost records, and agent query/mutation
|
|
21
|
+
tool contracts.
|
|
22
|
+
|
|
23
|
+
## Verified State
|
|
24
|
+
|
|
25
|
+
Checked on 2026-07-18 against `pyproject.toml`, package exports,
|
|
26
|
+
`keble_task/`, and tests.
|
|
27
|
+
|
|
28
|
+
- Package: `keble-task 2.24.0`
|
|
29
|
+
- Python: `>=3.13,<3.14`
|
|
30
|
+
- Critical deps: `keble-helpers`, `keble-db`, `pydantic-ai-slim`, `tenacity`
|
|
31
|
+
- Source roots: `schemas/`, `actions/`, `crud/`, `main/`, `agent/`, `utils/`
|
|
32
|
+
- Public exports: `TaskClient`, CRUD classes, task/task-relation schemas,
|
|
33
|
+
task-cost schemas, lifecycle/action events, and agent tool providers.
|
|
34
|
+
|
|
35
|
+
## Runtime Contract
|
|
36
|
+
|
|
37
|
+
- Task identity, stage, relations, and cost accounting belong here. Feature
|
|
38
|
+
packages should attach domain metadata instead of redefining task rows.
|
|
39
|
+
- First-class long-running features should be real `TaskType` flows in the
|
|
40
|
+
consuming service, not generic subagent workflows plus parallel adapters.
|
|
41
|
+
- Lifecycle and action events must stay typed and stable for backend
|
|
42
|
+
websocket fanout and frontend task-list rendering.
|
|
43
|
+
- Mongo CRUD changes must expose indexed query shapes directly and keep index
|
|
44
|
+
creation in startup wiring, not request handlers.
|
|
45
|
+
- Token rates are stored as native-currency micros per million tokens through
|
|
46
|
+
the shared `LlmTokenPriceBand`; ISO `Money` remains the contract for concrete
|
|
47
|
+
additional spend. This separation preserves prices such as USD 0.075 without
|
|
48
|
+
rounding them to cents and prevents cached input from being billed twice.
|
|
49
|
+
- Version 2.24.x reads the legacy Money-per-counter rate shape only for migration
|
|
50
|
+
and writes the canonical `currency + priceBand` shape. Migrate stored rows and
|
|
51
|
+
old admin clients before removing that reader in 2.25.0.
|
|
52
|
+
|
|
53
|
+
## Testing
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
uv sync --group test
|
|
57
|
+
RUN_INTEGRATION=1 RUN_REAL_DB=1 RUN_LOCAL_STACK=1 RUN_DB_STACK=1 uv run pytest -q -m "not live and not container"
|
|
58
|
+
uv run pytest -q -m "not live and not slow and not eval and not local_stack and not db_stack and not container"
|
|
59
|
+
uv run pytest -q -m eval
|
|
60
|
+
uv run pytest -q -m integration
|
|
61
|
+
RUN_LLM_LIVE=1 uv run pytest -m "live and llm"
|
|
62
|
+
uv run npx --yes pyright .
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Package-owned test helpers live under `keble_task.testing`; do not recreate
|
|
66
|
+
root-level `tests/config.py`, `tests/utils.py`, root test packages, or legacy
|
|
67
|
+
source folders such as `tests/schemas/`.
|
|
68
|
+
|
|
69
|
+
Mongo/Redis integration settings load explicit process env first, then
|
|
70
|
+
`tests/.env`, then the umbrella `keble.backend/.env` through
|
|
71
|
+
`keble_db.testing.resolve_test_env`. Live LLM settings load explicit `LIVE_LLM_*`
|
|
72
|
+
values first and otherwise map the first backend Azure endpoint/token/deployment
|
|
73
|
+
entry. Set `KEBLE_BACKEND_ENV_FILE=/path/to/.env` from unusual worktree or CI
|
|
74
|
+
layouts. Mongo/Redis tests are `integration`, `db`, `mongo`, `redis`, and
|
|
75
|
+
`local_stack`; they run in the local-full Keble command and stay out of the
|
|
76
|
+
portable-offline fallback command. Selecting integration tests without configured
|
|
77
|
+
Mongo/Redis now fails with a clear environment requirement instead of silently
|
|
78
|
+
skipping. Eval tests use `tests/evals/` plus `eval`; selecting `-m eval` is the
|
|
79
|
+
eval opt-in, with no generic `RUN_EVALS` gate. Keep the package-owned test
|
|
80
|
+
database and collection names isolated.
|
|
81
|
+
|
|
82
|
+
## Change Logs
|
|
83
|
+
|
|
84
|
+
Historical release notes and long AI change history live under `logs/`.
|
|
85
|
+
|
|
86
|
+
## Side Effect If Changes
|
|
87
|
+
|
|
88
|
+
- Backend task APIs, owner task lists, task room sockets, cost accounting,
|
|
89
|
+
and frontend task rows depend on these schemas/events.
|
|
90
|
+
- Backend pricing configuration and task-cost admin clients must use the exact
|
|
91
|
+
micro-rate wire introduced in 2.24.0; optional missing prices are unknown, not
|
|
92
|
+
free usage.
|
|
93
|
+
- Relation or graph-context changes can affect all feature rooms that load
|
|
94
|
+
child tasks or background sessions.
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# keble-task
|
|
2
|
+
|
|
3
|
+
`keble-task` owns generic Keble task schemas, task relations, task-room graph
|
|
4
|
+
context, lifecycle/action events, task cost records, and agent query/mutation
|
|
5
|
+
tool contracts.
|
|
6
|
+
|
|
7
|
+
## Verified State
|
|
8
|
+
|
|
9
|
+
Checked on 2026-07-18 against `pyproject.toml`, package exports,
|
|
10
|
+
`keble_task/`, and tests.
|
|
11
|
+
|
|
12
|
+
- Package: `keble-task 2.24.0`
|
|
13
|
+
- Python: `>=3.13,<3.14`
|
|
14
|
+
- Critical deps: `keble-helpers`, `keble-db`, `pydantic-ai-slim`, `tenacity`
|
|
15
|
+
- Source roots: `schemas/`, `actions/`, `crud/`, `main/`, `agent/`, `utils/`
|
|
16
|
+
- Public exports: `TaskClient`, CRUD classes, task/task-relation schemas,
|
|
17
|
+
task-cost schemas, lifecycle/action events, and agent tool providers.
|
|
18
|
+
|
|
19
|
+
## Runtime Contract
|
|
20
|
+
|
|
21
|
+
- Task identity, stage, relations, and cost accounting belong here. Feature
|
|
22
|
+
packages should attach domain metadata instead of redefining task rows.
|
|
23
|
+
- First-class long-running features should be real `TaskType` flows in the
|
|
24
|
+
consuming service, not generic subagent workflows plus parallel adapters.
|
|
25
|
+
- Lifecycle and action events must stay typed and stable for backend
|
|
26
|
+
websocket fanout and frontend task-list rendering.
|
|
27
|
+
- Mongo CRUD changes must expose indexed query shapes directly and keep index
|
|
28
|
+
creation in startup wiring, not request handlers.
|
|
29
|
+
- Token rates are stored as native-currency micros per million tokens through
|
|
30
|
+
the shared `LlmTokenPriceBand`; ISO `Money` remains the contract for concrete
|
|
31
|
+
additional spend. This separation preserves prices such as USD 0.075 without
|
|
32
|
+
rounding them to cents and prevents cached input from being billed twice.
|
|
33
|
+
- Version 2.24.x reads the legacy Money-per-counter rate shape only for migration
|
|
34
|
+
and writes the canonical `currency + priceBand` shape. Migrate stored rows and
|
|
35
|
+
old admin clients before removing that reader in 2.25.0.
|
|
36
|
+
|
|
37
|
+
## Testing
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
uv sync --group test
|
|
41
|
+
RUN_INTEGRATION=1 RUN_REAL_DB=1 RUN_LOCAL_STACK=1 RUN_DB_STACK=1 uv run pytest -q -m "not live and not container"
|
|
42
|
+
uv run pytest -q -m "not live and not slow and not eval and not local_stack and not db_stack and not container"
|
|
43
|
+
uv run pytest -q -m eval
|
|
44
|
+
uv run pytest -q -m integration
|
|
45
|
+
RUN_LLM_LIVE=1 uv run pytest -m "live and llm"
|
|
46
|
+
uv run npx --yes pyright .
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Package-owned test helpers live under `keble_task.testing`; do not recreate
|
|
50
|
+
root-level `tests/config.py`, `tests/utils.py`, root test packages, or legacy
|
|
51
|
+
source folders such as `tests/schemas/`.
|
|
52
|
+
|
|
53
|
+
Mongo/Redis integration settings load explicit process env first, then
|
|
54
|
+
`tests/.env`, then the umbrella `keble.backend/.env` through
|
|
55
|
+
`keble_db.testing.resolve_test_env`. Live LLM settings load explicit `LIVE_LLM_*`
|
|
56
|
+
values first and otherwise map the first backend Azure endpoint/token/deployment
|
|
57
|
+
entry. Set `KEBLE_BACKEND_ENV_FILE=/path/to/.env` from unusual worktree or CI
|
|
58
|
+
layouts. Mongo/Redis tests are `integration`, `db`, `mongo`, `redis`, and
|
|
59
|
+
`local_stack`; they run in the local-full Keble command and stay out of the
|
|
60
|
+
portable-offline fallback command. Selecting integration tests without configured
|
|
61
|
+
Mongo/Redis now fails with a clear environment requirement instead of silently
|
|
62
|
+
skipping. Eval tests use `tests/evals/` plus `eval`; selecting `-m eval` is the
|
|
63
|
+
eval opt-in, with no generic `RUN_EVALS` gate. Keep the package-owned test
|
|
64
|
+
database and collection names isolated.
|
|
65
|
+
|
|
66
|
+
## Change Logs
|
|
67
|
+
|
|
68
|
+
Historical release notes and long AI change history live under `logs/`.
|
|
69
|
+
|
|
70
|
+
## Side Effect If Changes
|
|
71
|
+
|
|
72
|
+
- Backend task APIs, owner task lists, task room sockets, cost accounting,
|
|
73
|
+
and frontend task rows depend on these schemas/events.
|
|
74
|
+
- Backend pricing configuration and task-cost admin clients must use the exact
|
|
75
|
+
micro-rate wire introduced in 2.24.0; optional missing prices are unknown, not
|
|
76
|
+
free usage.
|
|
77
|
+
- Relation or graph-context changes can affect all feature rooms that load
|
|
78
|
+
child tasks or background sessions.
|
|
@@ -25,20 +25,18 @@ from keble_db import AgentDbDeps, ExtendedAsyncRedis, QueryBase
|
|
|
25
25
|
from keble_helpers import (
|
|
26
26
|
AgenticActionEventStatus,
|
|
27
27
|
AgenticEventEmitter,
|
|
28
|
-
Currency,
|
|
29
28
|
ExchangeRateInUsd,
|
|
30
29
|
Language,
|
|
31
30
|
Money,
|
|
32
31
|
ObjectId,
|
|
33
32
|
PydanticModelConfig,
|
|
34
33
|
SharingScope,
|
|
35
|
-
UsageAccountingRecorderProtocol,
|
|
36
34
|
UsageAccountingSource,
|
|
37
35
|
utc_now,
|
|
38
36
|
)
|
|
39
37
|
from motor.motor_asyncio import AsyncIOMotorClient
|
|
40
38
|
from neo4j import AsyncDriver as Neo4jAsyncDriver
|
|
41
|
-
from pydantic import BaseModel, ConfigDict
|
|
39
|
+
from pydantic import BaseModel, ConfigDict
|
|
42
40
|
from pydantic_ai.usage import RunUsage
|
|
43
41
|
from pymongo import ASCENDING, DESCENDING
|
|
44
42
|
from pymongo.errors import DuplicateKeyError
|
|
@@ -632,6 +630,9 @@ class TaskClient:
|
|
|
632
630
|
subtitle: Optional[str] = None,
|
|
633
631
|
metadata: Optional[TaskMetadata] = None,
|
|
634
632
|
language: Optional[Language] = None,
|
|
633
|
+
# Program AP (2.23.0): the run's thinking mode (keble_helpers
|
|
634
|
+
# AgentThinkingMode wire values); the framework stores it verbatim.
|
|
635
|
+
thinking_mode: Optional[str] = None,
|
|
635
636
|
task_type: str,
|
|
636
637
|
timeout_mins: int = 120,
|
|
637
638
|
sharing_scope: SharingScope = SharingScope.PRIVATE,
|
|
@@ -689,6 +690,7 @@ class TaskClient:
|
|
|
689
690
|
subtitle=subtitle,
|
|
690
691
|
metadata=metadata,
|
|
691
692
|
language=language,
|
|
693
|
+
thinking_mode=thinking_mode,
|
|
692
694
|
owner=str(owner),
|
|
693
695
|
consumed_token=consumed_token,
|
|
694
696
|
expected_token=expected_token,
|
|
@@ -2338,8 +2340,7 @@ class TaskClient:
|
|
|
2338
2340
|
aneo4j=aneo4j,
|
|
2339
2341
|
qdrant_client=qdrant_client,
|
|
2340
2342
|
task_handler_metadata=task_handler_metadata,
|
|
2341
|
-
event_emitter=task_lifecycle_event_emitter
|
|
2342
|
-
or AgenticEventEmitter(),
|
|
2343
|
+
event_emitter=task_lifecycle_event_emitter or AgenticEventEmitter(),
|
|
2343
2344
|
)
|
|
2344
2345
|
except Exception as exc:
|
|
2345
2346
|
logger.critical(
|
|
@@ -2390,9 +2391,7 @@ class TaskClient:
|
|
|
2390
2391
|
):
|
|
2391
2392
|
"""Retry all undone tasks asynchronously."""
|
|
2392
2393
|
# fetch all undone
|
|
2393
|
-
after = utc_now() - timedelta(
|
|
2394
|
-
minutes=include_tasks_created_within_minutes
|
|
2395
|
-
)
|
|
2394
|
+
after = utc_now() - timedelta(minutes=include_tasks_created_within_minutes)
|
|
2396
2395
|
db_objs = await self.crud_task.aget_multi(
|
|
2397
2396
|
amongo,
|
|
2398
2397
|
query=QueryBase(
|