3tears-agent-wake 0.14.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.
- 3tears_agent_wake-0.14.0/.gitignore +216 -0
- 3tears_agent_wake-0.14.0/LICENSE +21 -0
- 3tears_agent_wake-0.14.0/PKG-INFO +103 -0
- 3tears_agent_wake-0.14.0/README.md +73 -0
- 3tears_agent_wake-0.14.0/pyproject.toml +71 -0
- 3tears_agent_wake-0.14.0/src/threetears/agent/wake/__init__.py +272 -0
- 3tears_agent_wake-0.14.0/src/threetears/agent/wake/api_models.py +311 -0
- 3tears_agent_wake-0.14.0/src/threetears/agent/wake/collections.py +1607 -0
- 3tears_agent_wake-0.14.0/src/threetears/agent/wake/config.py +205 -0
- 3tears_agent_wake-0.14.0/src/threetears/agent/wake/dispatch.py +475 -0
- 3tears_agent_wake-0.14.0/src/threetears/agent/wake/entities.py +850 -0
- 3tears_agent_wake-0.14.0/src/threetears/agent/wake/events.py +70 -0
- 3tears_agent_wake-0.14.0/src/threetears/agent/wake/hmac_util.py +91 -0
- 3tears_agent_wake-0.14.0/src/threetears/agent/wake/metrics.py +436 -0
- 3tears_agent_wake-0.14.0/src/threetears/agent/wake/migrations/__init__.py +132 -0
- 3tears_agent_wake-0.14.0/src/threetears/agent/wake/migrations/v001_create_agent_wake_schedules.py +148 -0
- 3tears_agent_wake-0.14.0/src/threetears/agent/wake/migrations/v002_create_wake_fires.py +144 -0
- 3tears_agent_wake-0.14.0/src/threetears/agent/wake/migrations/v003_create_webhook_subscriptions.py +143 -0
- 3tears_agent_wake-0.14.0/src/threetears/agent/wake/migrations/v004_add_dispatching_status.py +81 -0
- 3tears_agent_wake-0.14.0/src/threetears/agent/wake/migrations/v005_open_verification_scheme_check.py +85 -0
- 3tears_agent_wake-0.14.0/src/threetears/agent/wake/migrations/v006_add_include_conversation_history.py +48 -0
- 3tears_agent_wake-0.14.0/src/threetears/agent/wake/py.typed +0 -0
- 3tears_agent_wake-0.14.0/src/threetears/agent/wake/rate_limit.py +489 -0
- 3tears_agent_wake-0.14.0/src/threetears/agent/wake/tables.py +462 -0
- 3tears_agent_wake-0.14.0/src/threetears/agent/wake/tick.py +481 -0
- 3tears_agent_wake-0.14.0/src/threetears/agent/wake/tools/__init__.py +109 -0
- 3tears_agent_wake-0.14.0/src/threetears/agent/wake/tools/resolve.py +73 -0
- 3tears_agent_wake-0.14.0/src/threetears/agent/wake/tools/schedule_tools.py +1294 -0
- 3tears_agent_wake-0.14.0/src/threetears/agent/wake/tools/validators.py +316 -0
- 3tears_agent_wake-0.14.0/src/threetears/agent/wake/tools/webhook_tools.py +840 -0
- 3tears_agent_wake-0.14.0/src/threetears/agent/wake/types.py +326 -0
- 3tears_agent_wake-0.14.0/src/threetears/agent/wake/webhook_adapter.py +591 -0
- 3tears_agent_wake-0.14.0/tests/enforcement/test_partition_column_walker.py +80 -0
- 3tears_agent_wake-0.14.0/tests/enforcement/test_uuidv7_persisted_ids.py +75 -0
- 3tears_agent_wake-0.14.0/tests/integration/conftest.py +79 -0
- 3tears_agent_wake-0.14.0/tests/integration/test_check_constraints.py +440 -0
- 3tears_agent_wake-0.14.0/tests/integration/test_claim_and_reschedule.py +235 -0
- 3tears_agent_wake-0.14.0/tests/integration/test_composite_pk_lookup.py +634 -0
- 3tears_agent_wake-0.14.0/tests/integration/test_dispatch_e2e.py +994 -0
- 3tears_agent_wake-0.14.0/tests/integration/test_fk_cascade.py +298 -0
- 3tears_agent_wake-0.14.0/tests/integration/test_migrations_apply.py +298 -0
- 3tears_agent_wake-0.14.0/tests/integration/test_schedule_cap_race.py +282 -0
- 3tears_agent_wake-0.14.0/tests/integration/test_skill_id_fk_targets.py +181 -0
- 3tears_agent_wake-0.14.0/tests/integration/test_sqlalchemy_table_parity.py +462 -0
- 3tears_agent_wake-0.14.0/tests/integration/test_tools_e2e.py +697 -0
- 3tears_agent_wake-0.14.0/tests/integration/test_wake_tick_loop.py +363 -0
- 3tears_agent_wake-0.14.0/tests/integration/test_webhook_receive.py +455 -0
- 3tears_agent_wake-0.14.0/tests/unit/test_api_models.py +404 -0
- 3tears_agent_wake-0.14.0/tests/unit/test_collection_methods.py +293 -0
- 3tears_agent_wake-0.14.0/tests/unit/test_dispatch_flow.py +529 -0
- 3tears_agent_wake-0.14.0/tests/unit/test_entities.py +433 -0
- 3tears_agent_wake-0.14.0/tests/unit/test_metrics_cardinality.py +149 -0
- 3tears_agent_wake-0.14.0/tests/unit/test_metrics_emit.py +218 -0
- 3tears_agent_wake-0.14.0/tests/unit/test_rate_limit.py +365 -0
- 3tears_agent_wake-0.14.0/tests/unit/test_silent_suppression.py +57 -0
- 3tears_agent_wake-0.14.0/tests/unit/test_tick_adapters.py +580 -0
- 3tears_agent_wake-0.14.0/tests/unit/test_tick_degrade_open.py +120 -0
- 3tears_agent_wake-0.14.0/tests/unit/test_tool_descriptions.py +192 -0
- 3tears_agent_wake-0.14.0/tests/unit/test_tools_factories.py +1515 -0
- 3tears_agent_wake-0.14.0/tests/unit/test_validators.py +295 -0
- 3tears_agent_wake-0.14.0/tests/unit/test_webhook_adapter.py +42 -0
|
@@ -0,0 +1,216 @@
|
|
|
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__/
|
|
208
|
+
|
|
209
|
+
# Claude Code local state
|
|
210
|
+
.claude/
|
|
211
|
+
|
|
212
|
+
# prawduct session evidence (local governance artifacts, never shipped)
|
|
213
|
+
.prawduct/
|
|
214
|
+
|
|
215
|
+
# macOS folder metadata
|
|
216
|
+
.DS_Store
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mark Pace
|
|
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,103 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: 3tears-agent-wake
|
|
3
|
+
Version: 0.14.0
|
|
4
|
+
Summary: Long-running-agent foundation -- wake schedules, fires, webhook subscriptions
|
|
5
|
+
Project-URL: Repository, https://github.com/pacepace/3tears
|
|
6
|
+
Author: pace
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Framework :: AsyncIO
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
14
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
15
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
16
|
+
Classifier: Typing :: Typed
|
|
17
|
+
Requires-Python: >=3.14
|
|
18
|
+
Requires-Dist: 3tears
|
|
19
|
+
Requires-Dist: 3tears-agent-skills
|
|
20
|
+
Requires-Dist: 3tears-observe
|
|
21
|
+
Requires-Dist: 3tears-scheduled-jobs
|
|
22
|
+
Requires-Dist: apscheduler>=3.10
|
|
23
|
+
Requires-Dist: jinja2>=3
|
|
24
|
+
Requires-Dist: langchain-core
|
|
25
|
+
Requires-Dist: pydantic>=2
|
|
26
|
+
Requires-Dist: uuid-utils
|
|
27
|
+
Provides-Extra: prometheus
|
|
28
|
+
Requires-Dist: prometheus-client>=0.20; extra == 'prometheus'
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
|
|
31
|
+
# 3tears-agent-wake
|
|
32
|
+
|
|
33
|
+
Long-running-agent foundation for 3tears-based agents. This package
|
|
34
|
+
ships the schema + Collection layer for three platform tables:
|
|
35
|
+
|
|
36
|
+
- `agent_wake_schedules` -- one row per active wake schedule for a
|
|
37
|
+
conversation (cron / one-shot / random-window / etc). Carries a
|
|
38
|
+
nullable `skill_id` FK referencing the cross-package
|
|
39
|
+
`agent_skills.skill_id` standalone UNIQUE.
|
|
40
|
+
- `wake_fires` -- one row per wake fire (history; status enum spans
|
|
41
|
+
`'fired'`, `'fired_silent'`, `'yielded'`, `'skipped_busy'`,
|
|
42
|
+
`'skipped_rate_limit'`, `'skipped_cap'`, `'skipped_no_handler'`,
|
|
43
|
+
`'failed'`).
|
|
44
|
+
- `webhook_subscriptions` -- one row per inbound HTTP webhook
|
|
45
|
+
subscription. Carries nullable `default_skill_id` FK to
|
|
46
|
+
`agent_skills.skill_id` and Fernet-encrypted `secret_ciphertext`.
|
|
47
|
+
|
|
48
|
+
Plus three `BaseEntity` subclasses, three `BaseCollection` subclasses,
|
|
49
|
+
and an agent-scope migration registration declaring
|
|
50
|
+
`depends_on=("conversations", "agent_skills")`.
|
|
51
|
+
|
|
52
|
+
No tick engine, no dispatch handler, no agent tools, and no Pydantic
|
|
53
|
+
API models live in this package.
|
|
54
|
+
|
|
55
|
+
## Partitioning
|
|
56
|
+
|
|
57
|
+
All three tables partition by `conversation_id` (wake operations are
|
|
58
|
+
conversation-scoped). The Collections expose `partition_column =
|
|
59
|
+
"conversation_id"` so the workspace partition-column enforcement walker
|
|
60
|
+
audits every SQL string touching these tables for the predicate.
|
|
61
|
+
|
|
62
|
+
There is intentionally NO database-level FK on `conversation_id` ->
|
|
63
|
+
`conversations(conversation_id)`. The 3tears `conversations` table
|
|
64
|
+
carries a composite PK `(agent_id, conversation_id)` and no standalone
|
|
65
|
+
`UNIQUE (conversation_id)` constraint, so a single-column FK is not
|
|
66
|
+
legal. The same precedent applies in `packages/agent/tools/`
|
|
67
|
+
(`context_items.conversation_id`) and `packages/agent/skills/`
|
|
68
|
+
(`agent_skill_invocations.conversation_id`). Conversation lifecycle is
|
|
69
|
+
governed by app-level cascade through `ConversationsCollection`.
|
|
70
|
+
|
|
71
|
+
**Orphan-row implication.** Because there is no DB-level FK, deleting a
|
|
72
|
+
row from `conversations` does NOT automatically remove the wake
|
|
73
|
+
schedules, fires, or webhook subscriptions for that conversation.
|
|
74
|
+
They become orphans (rows whose `conversation_id` no longer resolves).
|
|
75
|
+
The partition-column enforcement walker keeps the application blind to
|
|
76
|
+
orphans (every query is filtered by `conversation_id` so an orphan is
|
|
77
|
+
invisible at the read path), but the rows still occupy storage. This
|
|
78
|
+
is the same trade-off agent-tools and agent-skills make. A future
|
|
79
|
+
cross-package cleanup (a TRIGGER on `conversations`-delete that fans
|
|
80
|
+
out to dependent tables, or a periodic GC job in `ConversationsCollection`)
|
|
81
|
+
would close the gap; that work is intentionally cross-cutting and
|
|
82
|
+
out of scope for this package.
|
|
83
|
+
|
|
84
|
+
## Migration registration
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
from threetears.agent.wake import register as register_wake
|
|
88
|
+
from threetears.core.data.migrations import MigrationRunner
|
|
89
|
+
|
|
90
|
+
runner = MigrationRunner()
|
|
91
|
+
register_wake(runner)
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Migrations are agent-scoped and declare
|
|
95
|
+
`depends_on=("conversations", "agent_skills")` -- the canonical
|
|
96
|
+
`MigrationRunner` topologically orders the agent-scope pass so the
|
|
97
|
+
`conversations` + `agent_skills` migrations apply before any wake
|
|
98
|
+
table is created.
|
|
99
|
+
|
|
100
|
+
## Design references
|
|
101
|
+
|
|
102
|
+
See `docs/agent-wake/README.md` for the package overview and the
|
|
103
|
+
locked design decisions.
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# 3tears-agent-wake
|
|
2
|
+
|
|
3
|
+
Long-running-agent foundation for 3tears-based agents. This package
|
|
4
|
+
ships the schema + Collection layer for three platform tables:
|
|
5
|
+
|
|
6
|
+
- `agent_wake_schedules` -- one row per active wake schedule for a
|
|
7
|
+
conversation (cron / one-shot / random-window / etc). Carries a
|
|
8
|
+
nullable `skill_id` FK referencing the cross-package
|
|
9
|
+
`agent_skills.skill_id` standalone UNIQUE.
|
|
10
|
+
- `wake_fires` -- one row per wake fire (history; status enum spans
|
|
11
|
+
`'fired'`, `'fired_silent'`, `'yielded'`, `'skipped_busy'`,
|
|
12
|
+
`'skipped_rate_limit'`, `'skipped_cap'`, `'skipped_no_handler'`,
|
|
13
|
+
`'failed'`).
|
|
14
|
+
- `webhook_subscriptions` -- one row per inbound HTTP webhook
|
|
15
|
+
subscription. Carries nullable `default_skill_id` FK to
|
|
16
|
+
`agent_skills.skill_id` and Fernet-encrypted `secret_ciphertext`.
|
|
17
|
+
|
|
18
|
+
Plus three `BaseEntity` subclasses, three `BaseCollection` subclasses,
|
|
19
|
+
and an agent-scope migration registration declaring
|
|
20
|
+
`depends_on=("conversations", "agent_skills")`.
|
|
21
|
+
|
|
22
|
+
No tick engine, no dispatch handler, no agent tools, and no Pydantic
|
|
23
|
+
API models live in this package.
|
|
24
|
+
|
|
25
|
+
## Partitioning
|
|
26
|
+
|
|
27
|
+
All three tables partition by `conversation_id` (wake operations are
|
|
28
|
+
conversation-scoped). The Collections expose `partition_column =
|
|
29
|
+
"conversation_id"` so the workspace partition-column enforcement walker
|
|
30
|
+
audits every SQL string touching these tables for the predicate.
|
|
31
|
+
|
|
32
|
+
There is intentionally NO database-level FK on `conversation_id` ->
|
|
33
|
+
`conversations(conversation_id)`. The 3tears `conversations` table
|
|
34
|
+
carries a composite PK `(agent_id, conversation_id)` and no standalone
|
|
35
|
+
`UNIQUE (conversation_id)` constraint, so a single-column FK is not
|
|
36
|
+
legal. The same precedent applies in `packages/agent/tools/`
|
|
37
|
+
(`context_items.conversation_id`) and `packages/agent/skills/`
|
|
38
|
+
(`agent_skill_invocations.conversation_id`). Conversation lifecycle is
|
|
39
|
+
governed by app-level cascade through `ConversationsCollection`.
|
|
40
|
+
|
|
41
|
+
**Orphan-row implication.** Because there is no DB-level FK, deleting a
|
|
42
|
+
row from `conversations` does NOT automatically remove the wake
|
|
43
|
+
schedules, fires, or webhook subscriptions for that conversation.
|
|
44
|
+
They become orphans (rows whose `conversation_id` no longer resolves).
|
|
45
|
+
The partition-column enforcement walker keeps the application blind to
|
|
46
|
+
orphans (every query is filtered by `conversation_id` so an orphan is
|
|
47
|
+
invisible at the read path), but the rows still occupy storage. This
|
|
48
|
+
is the same trade-off agent-tools and agent-skills make. A future
|
|
49
|
+
cross-package cleanup (a TRIGGER on `conversations`-delete that fans
|
|
50
|
+
out to dependent tables, or a periodic GC job in `ConversationsCollection`)
|
|
51
|
+
would close the gap; that work is intentionally cross-cutting and
|
|
52
|
+
out of scope for this package.
|
|
53
|
+
|
|
54
|
+
## Migration registration
|
|
55
|
+
|
|
56
|
+
```python
|
|
57
|
+
from threetears.agent.wake import register as register_wake
|
|
58
|
+
from threetears.core.data.migrations import MigrationRunner
|
|
59
|
+
|
|
60
|
+
runner = MigrationRunner()
|
|
61
|
+
register_wake(runner)
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Migrations are agent-scoped and declare
|
|
65
|
+
`depends_on=("conversations", "agent_skills")` -- the canonical
|
|
66
|
+
`MigrationRunner` topologically orders the agent-scope pass so the
|
|
67
|
+
`conversations` + `agent_skills` migrations apply before any wake
|
|
68
|
+
table is created.
|
|
69
|
+
|
|
70
|
+
## Design references
|
|
71
|
+
|
|
72
|
+
See `docs/agent-wake/README.md` for the package overview and the
|
|
73
|
+
locked design decisions.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "3tears-agent-wake"
|
|
7
|
+
version = "0.14.0"
|
|
8
|
+
description = "Long-running-agent foundation -- wake schedules, fires, webhook subscriptions"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.14"
|
|
11
|
+
authors = [{name = "pace"}]
|
|
12
|
+
license = "MIT"
|
|
13
|
+
license-files = ["LICENSE"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 3 - Alpha",
|
|
16
|
+
"Framework :: AsyncIO",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Programming Language :: Python :: 3.14",
|
|
20
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
21
|
+
"Topic :: Software Development :: Libraries",
|
|
22
|
+
"Typing :: Typed",
|
|
23
|
+
]
|
|
24
|
+
dependencies = [
|
|
25
|
+
"3tears",
|
|
26
|
+
"3tears-agent-skills",
|
|
27
|
+
"3tears-observe",
|
|
28
|
+
# The cross-pod tick pump (lock + due-scan + CAS-claim + reschedule math)
|
|
29
|
+
# lives in the generic scheduled-jobs core since S-2; wake's tick is a thin
|
|
30
|
+
# adapter over it. The transitive ``3tears-nats`` dep (cross-pod lock) now
|
|
31
|
+
# belongs to that core, not to wake.
|
|
32
|
+
"3tears-scheduled-jobs",
|
|
33
|
+
"uuid-utils",
|
|
34
|
+
# APScheduler is used as a pure utility by the cron-expression validator
|
|
35
|
+
# (``tools/validators.py`` -- ``CronTrigger.from_crontab``; lazy local
|
|
36
|
+
# import so non-cron call paths pay zero import cost). The reschedule
|
|
37
|
+
# math's ``cron`` branch moved to ``3tears-scheduled-jobs`` in S-2, but the
|
|
38
|
+
# tools layer still validates cron exprs here. Hard dep rather than an extra
|
|
39
|
+
# so the public ``ScheduleType`` Literal (which includes ``'cron'``) Just
|
|
40
|
+
# Works without extras-install ceremony.
|
|
41
|
+
"apscheduler>=3.10",
|
|
42
|
+
# LangChain BaseTool is the surface every factory returns (mirrors
|
|
43
|
+
# ``3tears-agent-skills``'s tools layer). Pydantic is the input
|
|
44
|
+
# schema toolkit. Both are stable, widely-installed wheels.
|
|
45
|
+
"langchain-core",
|
|
46
|
+
"pydantic>=2",
|
|
47
|
+
# Jinja2's SandboxedEnvironment renders the webhook payload
|
|
48
|
+
# template (shard 04's ``webhook_subscription_create`` validation
|
|
49
|
+
# path + ``webhook_receive``'s render). Bounded payload + sandbox
|
|
50
|
+
# mean the dep is opt-in for safety, not power-tool risk.
|
|
51
|
+
"jinja2>=3",
|
|
52
|
+
]
|
|
53
|
+
|
|
54
|
+
[project.optional-dependencies]
|
|
55
|
+
# ``prometheus_client`` is optional at runtime -- the metrics module
|
|
56
|
+
# degrades gracefully to no-op when the wheel is absent (mirrors
|
|
57
|
+
# ``3tears-models``'s ``prometheus`` extra). Consumers that want the
|
|
58
|
+
# locked ``3tears_agent_wake_*`` instruments install the extra.
|
|
59
|
+
prometheus = ["prometheus-client>=0.20"]
|
|
60
|
+
|
|
61
|
+
[project.urls]
|
|
62
|
+
Repository = "https://github.com/pacepace/3tears"
|
|
63
|
+
|
|
64
|
+
[tool.hatch.build.targets.wheel]
|
|
65
|
+
packages = ["src/threetears"]
|
|
66
|
+
|
|
67
|
+
[tool.uv.sources]
|
|
68
|
+
"3tears-agent-skills" = { workspace = true }
|
|
69
|
+
3tears = { workspace = true }
|
|
70
|
+
3tears-observe = { workspace = true }
|
|
71
|
+
"3tears-scheduled-jobs" = { workspace = true }
|