brain-framework 21.0.1__tar.gz → 21.2.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.
- {brain_framework-21.0.1 → brain_framework-21.2.0}/PKG-INFO +2 -2
- {brain_framework-21.0.1 → brain_framework-21.2.0}/README.md +1 -1
- {brain_framework-21.0.1 → brain_framework-21.2.0}/THIRD_PARTY_NOTICES.md +24 -24
- {brain_framework-21.0.1 → brain_framework-21.2.0}/pyproject.toml +2 -2
- {brain_framework-21.0.1 → brain_framework-21.2.0}/pyproject.toml.orig +2 -2
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/__init__.py +1 -1
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/assistants.py +11 -4
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/cli.py +29 -33
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/collect.py +1 -2
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/health.py +6 -6
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/index.py +6 -4
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/markdown.py +2 -1
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/models.py +7 -2
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/pages.py +19 -36
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/records.py +24 -5
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/runtime.py +28 -12
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/skills/bf-maintain/references/integrations.md +1 -3
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/skills/bf-use/SKILL.md +1 -1
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/skills/bf-use/references/evidence.md +6 -19
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/skills/bf-use/references/links.md +4 -4
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/skills/bf-use/references/retrieval.md +1 -1
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/skills/bf-use/scripts/evidence.py +48 -6
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/skills/bf-use/templates/concept.md +1 -1
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/starter/evals/retrieval.yaml +4 -1
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/storage.py +8 -0
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/update.py +16 -3
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/validate.py +3 -2
- {brain_framework-21.0.1 → brain_framework-21.2.0}/LICENSE +0 -0
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/__main__.py +0 -0
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/channels.py +0 -0
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/config.py +0 -0
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/evaluate.py +0 -0
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/graph.py +0 -0
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/history.py +0 -0
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/install.py +0 -0
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/links.py +0 -0
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/mcp.py +0 -0
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/messages.py +0 -0
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/ontology.py +0 -0
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/py.typed +0 -0
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/replies.py +0 -0
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/retrieve.py +0 -0
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/schemas.py +0 -0
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/skills/README.md +0 -0
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/skills/bf-action/SKILL.md +0 -0
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/skills/bf-action/references/actions.md +0 -0
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/skills/bf-action/references/context.md +0 -0
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/skills/bf-action/references/handoff.md +0 -0
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/skills/bf-action/scripts/check-handoff.py +0 -0
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/skills/bf-action/scripts/new-action.py +0 -0
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/skills/bf-action/templates/action.md +0 -0
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/skills/bf-maintain/SKILL.md +0 -0
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/skills/bf-maintain/references/conflicts.md +0 -0
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/skills/bf-maintain/references/operations.md +0 -0
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/skills/bf-setup/SKILL.md +0 -0
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/skills/bf-setup/references/discovery.md +0 -0
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/skills/bf-setup/references/import.md +0 -0
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/skills/bf-setup/references/scan.md +0 -0
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/skills/bf-setup/scripts/inventory.py +0 -0
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/skills/bf-use/references/consolidate.md +0 -0
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/skills/bf-use/references/decisions.md +0 -0
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/skills/bf-use/references/learn.md +0 -0
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/skills/bf-use/references/review.md +0 -0
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/skills/bf-use/references/share.md +0 -0
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/skills/bf-use/scripts/guarded-write.py +0 -0
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/skills/bf-use/templates/project.md +0 -0
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/starter/AGENTS.md +0 -0
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/starter/concepts/index.md +0 -0
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/starter/concepts/welcome.md +0 -0
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/starter/gitignore +0 -0
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/usage.py +0 -0
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/watch.py +0 -0
- {brain_framework-21.0.1 → brain_framework-21.2.0}/src/bf/watch_settings.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: brain-framework
|
|
3
|
-
Version: 21.0
|
|
3
|
+
Version: 21.2.0
|
|
4
4
|
Summary: 🧠 Brain Framework: from information to informed actions.
|
|
5
5
|
Keywords: ai,ai-agents,agent-memory,context-engineering,knowledge-management,local-first,mcp,model-context-protocol,python,second-brain
|
|
6
6
|
Author: Médéric Hurier
|
|
@@ -218,7 +218,7 @@ Use the brain with [Claude Code](https://code.claude.com/docs/en/overview), [Cod
|
|
|
218
218
|
|
|
219
219
|
> Use the bf CLI. Find why we chose a single product page. Read the source, cite its ref and tell me the project's next action.
|
|
220
220
|
|
|
221
|
-
It should cite `projects/new-website.md#decision` and name “Draft the product page.” For ongoing use, install the packaged skills into your host
|
|
221
|
+
It should cite `projects/new-website.md#decision` and name “Draft the product page.” For ongoing use, install the packaged skills into the folder your host discovers (`~/.agents/skills` below; Claude Code uses `~/.claude/skills`):
|
|
222
222
|
|
|
223
223
|
```bash
|
|
224
224
|
bf skills ~/.agents/skills
|
|
@@ -188,7 +188,7 @@ Use the brain with [Claude Code](https://code.claude.com/docs/en/overview), [Cod
|
|
|
188
188
|
|
|
189
189
|
> Use the bf CLI. Find why we chose a single product page. Read the source, cite its ref and tell me the project's next action.
|
|
190
190
|
|
|
191
|
-
It should cite `projects/new-website.md#decision` and name “Draft the product page.” For ongoing use, install the packaged skills into your host
|
|
191
|
+
It should cite `projects/new-website.md#decision` and name “Draft the product page.” For ongoing use, install the packaged skills into the folder your host discovers (`~/.agents/skills` below; Claude Code uses `~/.claude/skills`):
|
|
192
192
|
|
|
193
193
|
```bash
|
|
194
194
|
bf skills ~/.agents/skills
|
|
@@ -72,15 +72,15 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
72
72
|
SOFTWARE.
|
|
73
73
|
```
|
|
74
74
|
|
|
75
|
-
## anyio 4.
|
|
75
|
+
## anyio 4.16.0
|
|
76
76
|
|
|
77
77
|
Source: <https://github.com/agronholm/anyio>
|
|
78
78
|
|
|
79
79
|
License: `MIT`
|
|
80
80
|
|
|
81
|
-
Evidence: `anyio-4.
|
|
81
|
+
Evidence: `anyio-4.16.0.dist-info/licenses/LICENSE`
|
|
82
82
|
|
|
83
|
-
### anyio-4.
|
|
83
|
+
### anyio-4.16.0.dist-info/licenses/LICENSE
|
|
84
84
|
|
|
85
85
|
```text
|
|
86
86
|
The MIT License (MIT)
|
|
@@ -173,15 +173,15 @@ documentation is licensed as follows:
|
|
|
173
173
|
DEALINGS IN THE SOFTWARE.
|
|
174
174
|
```
|
|
175
175
|
|
|
176
|
-
## click 8.5.
|
|
176
|
+
## click 8.5.1
|
|
177
177
|
|
|
178
178
|
Source: <https://github.com/pallets/click/>
|
|
179
179
|
|
|
180
180
|
License: `BSD-3-Clause`
|
|
181
181
|
|
|
182
|
-
Evidence: `click-8.5.
|
|
182
|
+
Evidence: `click-8.5.1.dist-info/licenses/LICENSE.txt`
|
|
183
183
|
|
|
184
|
-
### click-8.5.
|
|
184
|
+
### click-8.5.1.dist-info/licenses/LICENSE.txt
|
|
185
185
|
|
|
186
186
|
```text
|
|
187
187
|
Copyright 2014 Pallets
|
|
@@ -872,15 +872,15 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
|
872
872
|
IN THE SOFTWARE.
|
|
873
873
|
```
|
|
874
874
|
|
|
875
|
-
## opentelemetry-api 1.45.
|
|
875
|
+
## opentelemetry-api 1.45.2
|
|
876
876
|
|
|
877
877
|
Source: <https://github.com/open-telemetry/opentelemetry-python>
|
|
878
878
|
|
|
879
879
|
License: `Apache-2.0`
|
|
880
880
|
|
|
881
|
-
Evidence: `opentelemetry_api-1.45.
|
|
881
|
+
Evidence: `opentelemetry_api-1.45.2.dist-info/licenses/LICENSE`
|
|
882
882
|
|
|
883
|
-
### opentelemetry_api-1.45.
|
|
883
|
+
### opentelemetry_api-1.45.2.dist-info/licenses/LICENSE
|
|
884
884
|
|
|
885
885
|
```text
|
|
886
886
|
Apache License
|
|
@@ -1126,15 +1126,15 @@ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
|
|
1126
1126
|
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
1127
1127
|
```
|
|
1128
1128
|
|
|
1129
|
-
## pydantic 2.14.
|
|
1129
|
+
## pydantic 2.14.3
|
|
1130
1130
|
|
|
1131
1131
|
Source: <https://github.com/pydantic/pydantic>
|
|
1132
1132
|
|
|
1133
1133
|
License: `MIT`
|
|
1134
1134
|
|
|
1135
|
-
Evidence: `pydantic-2.14.
|
|
1135
|
+
Evidence: `pydantic-2.14.3.dist-info/licenses/LICENSE`
|
|
1136
1136
|
|
|
1137
|
-
### pydantic-2.14.
|
|
1137
|
+
### pydantic-2.14.3.dist-info/licenses/LICENSE
|
|
1138
1138
|
|
|
1139
1139
|
```text
|
|
1140
1140
|
The MIT License (MIT)
|
|
@@ -1160,15 +1160,15 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
1160
1160
|
SOFTWARE.
|
|
1161
1161
|
```
|
|
1162
1162
|
|
|
1163
|
-
## pydantic-core 2.50.
|
|
1163
|
+
## pydantic-core 2.50.4
|
|
1164
1164
|
|
|
1165
1165
|
Source: <https://github.com/pydantic/pydantic/tree/main/pydantic-core>
|
|
1166
1166
|
|
|
1167
1167
|
License: `MIT`
|
|
1168
1168
|
|
|
1169
|
-
Evidence: `pydantic_core-2.50.
|
|
1169
|
+
Evidence: `pydantic_core-2.50.4.dist-info/licenses/LICENSE`
|
|
1170
1170
|
|
|
1171
|
-
### pydantic_core-2.50.
|
|
1171
|
+
### pydantic_core-2.50.4.dist-info/licenses/LICENSE
|
|
1172
1172
|
|
|
1173
1173
|
```text
|
|
1174
1174
|
The MIT License (MIT)
|
|
@@ -1266,15 +1266,15 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
1266
1266
|
SOFTWARE.
|
|
1267
1267
|
```
|
|
1268
1268
|
|
|
1269
|
-
## python-multipart 0.0.
|
|
1269
|
+
## python-multipart 0.0.33
|
|
1270
1270
|
|
|
1271
1271
|
Source: <https://github.com/Kludex/python-multipart>
|
|
1272
1272
|
|
|
1273
1273
|
License: `Apache-2.0`
|
|
1274
1274
|
|
|
1275
|
-
Evidence: `python_multipart-0.0.
|
|
1275
|
+
Evidence: `python_multipart-0.0.33.dist-info/licenses/LICENSE.txt`
|
|
1276
1276
|
|
|
1277
|
-
### python_multipart-0.0.
|
|
1277
|
+
### python_multipart-0.0.33.dist-info/licenses/LICENSE.txt
|
|
1278
1278
|
|
|
1279
1279
|
```text
|
|
1280
1280
|
Apache License
|
|
@@ -1749,7 +1749,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
1749
1749
|
THE SOFTWARE.
|
|
1750
1750
|
```
|
|
1751
1751
|
|
|
1752
|
-
## typer 0.
|
|
1752
|
+
## typer 0.28.0
|
|
1753
1753
|
|
|
1754
1754
|
Source: <https://github.com/fastapi/typer>
|
|
1755
1755
|
|
|
@@ -1757,9 +1757,9 @@ License: `MIT`
|
|
|
1757
1757
|
|
|
1758
1758
|
The distribution vendors code adapted from Click in `typer/_click/`; its bundled `BSD-3-Clause` license is included below.
|
|
1759
1759
|
|
|
1760
|
-
Evidence: `typer-0.
|
|
1760
|
+
Evidence: `typer-0.28.0.dist-info/licenses/LICENSE`
|
|
1761
1761
|
|
|
1762
|
-
### typer-0.
|
|
1762
|
+
### typer-0.28.0.dist-info/licenses/LICENSE
|
|
1763
1763
|
|
|
1764
1764
|
```text
|
|
1765
1765
|
The MIT License (MIT)
|
|
@@ -2112,15 +2112,15 @@ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
2112
2112
|
PERFORMANCE OF THIS SOFTWARE.
|
|
2113
2113
|
```
|
|
2114
2114
|
|
|
2115
|
-
## typing-inspection 0.4.
|
|
2115
|
+
## typing-inspection 0.4.5
|
|
2116
2116
|
|
|
2117
2117
|
Source: <https://github.com/pydantic/typing-inspection>
|
|
2118
2118
|
|
|
2119
2119
|
License: `MIT`
|
|
2120
2120
|
|
|
2121
|
-
Evidence: `typing_inspection-0.4.
|
|
2121
|
+
Evidence: `typing_inspection-0.4.5.dist-info/licenses/LICENSE`
|
|
2122
2122
|
|
|
2123
|
-
### typing_inspection-0.4.
|
|
2123
|
+
### typing_inspection-0.4.5.dist-info/licenses/LICENSE
|
|
2124
2124
|
|
|
2125
2125
|
```text
|
|
2126
2126
|
MIT License
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "brain-framework"
|
|
3
|
-
version = "21.0
|
|
3
|
+
version = "21.2.0"
|
|
4
4
|
description = "🧠 Brain Framework: from information to informed actions."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.14"
|
|
@@ -170,5 +170,5 @@ dev = [
|
|
|
170
170
|
"ruff>=0.16.6",
|
|
171
171
|
"ty>=0.0.70,<0.1",
|
|
172
172
|
"validate-pyproject[all]>=0.25",
|
|
173
|
-
"zensical>=0.0
|
|
173
|
+
"zensical>=0.1.0,<0.2",
|
|
174
174
|
]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# https://packaging.python.org/en/latest/specifications/pyproject-toml/
|
|
2
2
|
[project]
|
|
3
3
|
name = "brain-framework"
|
|
4
|
-
version = "21.0
|
|
4
|
+
version = "21.2.0"
|
|
5
5
|
description = "🧠 Brain Framework: from information to informed actions."
|
|
6
6
|
readme = "README.md"
|
|
7
7
|
requires-python = ">=3.14"
|
|
@@ -74,7 +74,7 @@ dev = [
|
|
|
74
74
|
"ty>=0.0.70,<0.1",
|
|
75
75
|
# The extra validates classifiers offline instead of downloading them or skipping the check.
|
|
76
76
|
"validate-pyproject[all]>=0.25",
|
|
77
|
-
"zensical>=0.0
|
|
77
|
+
"zensical>=0.1.0,<0.2",
|
|
78
78
|
]
|
|
79
79
|
|
|
80
80
|
[tool.ruff]
|
|
@@ -48,6 +48,7 @@ from bf.models import (
|
|
|
48
48
|
decode,
|
|
49
49
|
digest,
|
|
50
50
|
encode,
|
|
51
|
+
retried,
|
|
51
52
|
timestamp,
|
|
52
53
|
)
|
|
53
54
|
from bf.replies import ASSISTANT
|
|
@@ -485,14 +486,16 @@ def _execute(store: Store, key: str, runner: Runner) -> dict[str, object]:
|
|
|
485
486
|
else "assistant execution or saved reply failed; inspect its local log"
|
|
486
487
|
)
|
|
487
488
|
if current["state"] not in {"complete", "cancelled"}:
|
|
488
|
-
# A harness that never started cannot have acted: its job fails plainly instead of uncertainly
|
|
489
|
-
# failed gate retries by itself: no
|
|
489
|
+
# A harness that never started cannot have acted: its job fails plainly instead of uncertainly, and
|
|
490
|
+
# retries like a failed attempt when the run is idempotent. A failed gate retries by itself: no
|
|
491
|
+
# harness ran.
|
|
492
|
+
idempotent = retried(work.settings.idempotent, work.kind)
|
|
490
493
|
queue.fail(
|
|
491
494
|
key,
|
|
492
495
|
message,
|
|
493
496
|
uncertain=current["state"] == "running" and not isinstance(error, NotStartedError),
|
|
494
|
-
idempotent=
|
|
495
|
-
retry=isinstance(error, GateError),
|
|
497
|
+
idempotent=idempotent,
|
|
498
|
+
retry=isinstance(error, GateError) or (idempotent and isinstance(error, NotStartedError)),
|
|
496
499
|
)
|
|
497
500
|
with suppress(Error, OSError):
|
|
498
501
|
append_log(store, work.assistant, message)
|
|
@@ -525,6 +528,10 @@ def deliver(
|
|
|
525
528
|
key, name = str(delivery["id"]), str(delivery["channel"])
|
|
526
529
|
lock = f".delivery-{digest(key.encode())}"
|
|
527
530
|
with collecting(store, lock):
|
|
531
|
+
# Read it again under the lock: another process may have sent, failed or rescheduled it meanwhile.
|
|
532
|
+
delivery = queue.delivery(job=job, key=key, names=names)
|
|
533
|
+
if delivery is None:
|
|
534
|
+
return False
|
|
528
535
|
try:
|
|
529
536
|
try:
|
|
530
537
|
command = Send.model_validate_json(str(delivery["command"]))
|
|
@@ -190,6 +190,13 @@ def emit(value: object, *, reply: bool = True) -> None:
|
|
|
190
190
|
_write(terminal(present(value) if reply else value))
|
|
191
191
|
|
|
192
192
|
|
|
193
|
+
def _finish(value: object, *, failed: bool) -> None:
|
|
194
|
+
"""Print a reply, then exit 1 when it reports a failed operation: the reply says what failed."""
|
|
195
|
+
emit(value)
|
|
196
|
+
if failed:
|
|
197
|
+
raise typer.Exit(1)
|
|
198
|
+
|
|
199
|
+
|
|
193
200
|
def _write(data: bytes, *, flush: bool = True) -> None:
|
|
194
201
|
"""Write reply bytes; standard output that cannot take them, such as a full disk, fails the command."""
|
|
195
202
|
try:
|
|
@@ -275,7 +282,7 @@ _PEOPLE = {
|
|
|
275
282
|
"author": "Account explicitly credited as author; authorship is not ownership.",
|
|
276
283
|
"owner": "Account or organization the provider declares responsible for the item.",
|
|
277
284
|
"assignee": "Account assigned responsibility for the item.",
|
|
278
|
-
"participant": "Any account in a message, event or meeting;
|
|
285
|
+
"participant": "Any account in a message, event or meeting; its narrower relations, such as sender, list here too.",
|
|
279
286
|
}
|
|
280
287
|
_ROLES = {
|
|
281
288
|
"sender": "Account that sent the message.",
|
|
@@ -459,9 +466,7 @@ def install(
|
|
|
459
466
|
from bf.install import skills
|
|
460
467
|
|
|
461
468
|
result = skills(destination, check=check, force=force)
|
|
462
|
-
|
|
463
|
-
if not result["ok"]:
|
|
464
|
-
raise typer.Exit(1)
|
|
469
|
+
_finish(result, failed=not result["ok"])
|
|
465
470
|
|
|
466
471
|
|
|
467
472
|
@app.command("schema", rich_help_panel="Set up")
|
|
@@ -645,6 +650,9 @@ def forget_records(
|
|
|
645
650
|
"""Remove collected records and keep their sensors from storing them again; Git history keeps old copies."""
|
|
646
651
|
targets: dict[str, dict[str, str]] = {}
|
|
647
652
|
for ref in refs:
|
|
653
|
+
# The UTF-8 check of single values skips arguments that take several, as `run` passes Git's arguments as given.
|
|
654
|
+
if _surrogates(ref):
|
|
655
|
+
raise typer.BadParameter("expected UTF-8 text", param_hint="REF")
|
|
648
656
|
try:
|
|
649
657
|
source, entry = records.target(ref)
|
|
650
658
|
except Error as error:
|
|
@@ -664,7 +672,8 @@ def forget_records(
|
|
|
664
672
|
result: dict[str, object] = {"ok": True, "dry_run": dry_run, "records": removed}
|
|
665
673
|
if not dry_run:
|
|
666
674
|
result["index"] = index.refresh(store, recover=True)
|
|
667
|
-
|
|
675
|
+
# Like build and update: a skipped file hides evidence, and bf validate names it.
|
|
676
|
+
_finish(result, failed=bool(cast("dict[str, int]", result.get("index", {})).get("skipped")))
|
|
668
677
|
|
|
669
678
|
|
|
670
679
|
@app.command("run", rich_help_panel="Collect and automate")
|
|
@@ -724,22 +733,20 @@ def perform(
|
|
|
724
733
|
except UnicodeError as error:
|
|
725
734
|
raise Error("assistant input must be UTF-8 text") from error
|
|
726
735
|
result = run_assistant(store, names[0], text=text, dry_run=dry_run)
|
|
727
|
-
|
|
728
|
-
if not result["ok"]:
|
|
729
|
-
raise typer.Exit(1)
|
|
736
|
+
_finish(result, failed=not result["ok"])
|
|
730
737
|
return
|
|
731
738
|
# Git closes a hook's input; an agent's shell can hold its own open, so a direct run reads it only on request,
|
|
732
739
|
# and a hook only for the routines it runs: a hook that no routine lists succeeds at once.
|
|
733
740
|
stdin = _input() if forward or (hook and hooked(config, hook)) else b""
|
|
734
741
|
result = run_routines(store, names=names, hook=hook, args=args, stdin=stdin, dry_run=dry_run)
|
|
735
|
-
|
|
736
|
-
if not result["ok"]:
|
|
737
|
-
raise typer.Exit(1)
|
|
742
|
+
_finish(result, failed=not result["ok"])
|
|
738
743
|
|
|
739
744
|
|
|
740
745
|
@app.command("channel", rich_help_panel="Collect and automate")
|
|
741
746
|
def channel_command(
|
|
742
|
-
action: Annotated[
|
|
747
|
+
action: Annotated[
|
|
748
|
+
Literal["read", "send"], typer.Argument(metavar="ACTION", help="Read a bounded batch or send one message.")
|
|
749
|
+
],
|
|
743
750
|
name: Annotated[str, typer.Argument(metavar="CHANNEL", help="A configured channel name.")],
|
|
744
751
|
brain: RunOption = "",
|
|
745
752
|
since: Annotated[str, typer.Option(help="Required start of a read window.")] = "",
|
|
@@ -791,9 +798,7 @@ def channel_command(
|
|
|
791
798
|
)
|
|
792
799
|
if saved["receipt"]:
|
|
793
800
|
saved["receipt"] = decode(saved["receipt"])
|
|
794
|
-
|
|
795
|
-
if saved["state"] != "delivered":
|
|
796
|
-
raise typer.Exit(1)
|
|
801
|
+
_finish(saved, failed=saved["state"] != "delivered")
|
|
797
802
|
|
|
798
803
|
|
|
799
804
|
@app.command("queue", rich_help_panel="Collect and automate")
|
|
@@ -818,9 +823,9 @@ def queue_command(
|
|
|
818
823
|
if retry and "channel" in saved:
|
|
819
824
|
assistants.deliver(queue.brain, key=key)
|
|
820
825
|
saved = queue.inspect(key)
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
826
|
+
_finish(
|
|
827
|
+
{"id": key, "status": saved["state"]}, failed=retry and "channel" in saved and saved["state"] != "delivered"
|
|
828
|
+
)
|
|
824
829
|
elif key:
|
|
825
830
|
row = queue.inspect(key)
|
|
826
831
|
for name in ("payload", "prepared", "command", "receipt"):
|
|
@@ -857,9 +862,7 @@ def refresh(
|
|
|
857
862
|
assistants=tuple(assistant or ()),
|
|
858
863
|
kinds=kinds,
|
|
859
864
|
)
|
|
860
|
-
|
|
861
|
-
if not result["ok"]:
|
|
862
|
-
raise typer.Exit(1)
|
|
865
|
+
_finish(result, failed=not result["ok"])
|
|
863
866
|
|
|
864
867
|
|
|
865
868
|
def _kinds(values: list[str]) -> frozenset[ProgramKind]:
|
|
@@ -941,18 +944,14 @@ def report(
|
|
|
941
944
|
observe(one(brain), observe=True)
|
|
942
945
|
return
|
|
943
946
|
result = health.report(select(brain))
|
|
944
|
-
|
|
945
|
-
if check and not result["healthy"]:
|
|
946
|
-
raise typer.Exit(1)
|
|
947
|
+
_finish(result, failed=check and not result["healthy"])
|
|
947
948
|
|
|
948
949
|
|
|
949
950
|
@app.command("validate", rich_help_panel="Check and repair")
|
|
950
951
|
def check(brain: OneBrainOption = "") -> None:
|
|
951
952
|
"""Check OKF projects, concepts and ACTION.md notes, links, record files and program files; exit 1 on problems."""
|
|
952
953
|
result = validate(one(brain))
|
|
953
|
-
|
|
954
|
-
if not result["valid"]:
|
|
955
|
-
raise typer.Exit(1)
|
|
954
|
+
_finish(result, failed=not result["valid"])
|
|
956
955
|
|
|
957
956
|
|
|
958
957
|
@app.command("eval", rich_help_panel="Check and repair")
|
|
@@ -972,9 +971,7 @@ def acceptance(
|
|
|
972
971
|
_option("--path", relative, path)
|
|
973
972
|
previous = _option("--baseline", load_baseline, str(baseline)) if baseline else None
|
|
974
973
|
result = evaluate(one(brain), path, previous)
|
|
975
|
-
|
|
976
|
-
if not result["passed"]:
|
|
977
|
-
raise typer.Exit(1)
|
|
974
|
+
_finish(result, failed=not result["passed"])
|
|
978
975
|
|
|
979
976
|
|
|
980
977
|
@app.command("build", rich_help_panel="Check and repair")
|
|
@@ -1002,9 +999,7 @@ def rebuild(
|
|
|
1002
999
|
result = remap(store, reproject, dry_run=dry_run)
|
|
1003
1000
|
if not dry_run:
|
|
1004
1001
|
result["index"] = index.refresh(store, recover=True)
|
|
1005
|
-
|
|
1006
|
-
if result["failed"] or cast("dict[str, int]", result.get("index", {})).get("skipped"):
|
|
1007
|
-
raise typer.Exit(1)
|
|
1002
|
+
_finish(result, failed=bool(result["failed"] or cast("dict[str, int]", result.get("index", {})).get("skipped")))
|
|
1008
1003
|
return
|
|
1009
1004
|
result = index.refresh(store, full=True)
|
|
1010
1005
|
emit(result)
|
|
@@ -1064,6 +1059,7 @@ def _input() -> bytes:
|
|
|
1064
1059
|
_GIVEN = {
|
|
1065
1060
|
"--brain": "give a brain name or path; an empty value would select another brain",
|
|
1066
1061
|
"--hook": "give an event name; an empty value would run the first argument as a routine",
|
|
1062
|
+
"--input": "give a file, or - for stdin; an empty value would run the sensor",
|
|
1067
1063
|
"--assistant": "give an assistant name; an empty value names none",
|
|
1068
1064
|
"--reproject": "give a sensor name; an empty value would rebuild the cache instead",
|
|
1069
1065
|
"--routine": "give a routine name; an empty value names none",
|
|
@@ -518,8 +518,7 @@ def collect(
|
|
|
518
518
|
# Forgotten and expired records leave on purpose: only other removals need --allow-removal.
|
|
519
519
|
if snapshot and not allow_removal and (refusal := _shrink(store, name, kept)):
|
|
520
520
|
raise Error(refusal)
|
|
521
|
-
records.
|
|
522
|
-
result.update(records.upsert(store, name, kept.kept, snapshot=snapshot))
|
|
521
|
+
result.update(records.upsert(store, name, kept.kept, snapshot=snapshot, removals=kept.removals))
|
|
523
522
|
result.update(records=len(kept.kept), **_retention(kept))
|
|
524
523
|
committed = True
|
|
525
524
|
result["elapsed_seconds"] = round(time.monotonic() - measured, 6)
|
|
@@ -14,8 +14,8 @@ from bf import __version__, index, usage
|
|
|
14
14
|
from bf.config import Selection, brain_name, load, related
|
|
15
15
|
from bf.history import ASSISTANTS, ROUTINES, log_path, state
|
|
16
16
|
from bf.models import CACHE, Assistant, Config, Error, Program, Sensor, decode, timestamp
|
|
17
|
-
from bf.runtime import
|
|
18
|
-
from bf.storage import Store
|
|
17
|
+
from bf.runtime import Queue, check_schema, check_version
|
|
18
|
+
from bf.storage import QUEUE, Store
|
|
19
19
|
|
|
20
20
|
# Counters of the last committed collection, reported apart from indexed totals.
|
|
21
21
|
_COUNTERS = (
|
|
@@ -163,20 +163,20 @@ class _Reader(Queue):
|
|
|
163
163
|
def exists(self) -> bool:
|
|
164
164
|
# Execution creates the file, then commits its schema: until then the queue holds nothing.
|
|
165
165
|
try:
|
|
166
|
-
return self.store.lstat(
|
|
166
|
+
return self.store.lstat(QUEUE).st_size > 0
|
|
167
167
|
except FileNotFoundError:
|
|
168
168
|
return False
|
|
169
169
|
|
|
170
170
|
@contextmanager
|
|
171
171
|
def connect(self) -> Generator[sqlite3.Connection]:
|
|
172
|
-
info = self.store.lstat(
|
|
172
|
+
info = self.store.lstat(QUEUE)
|
|
173
173
|
if info.st_uid != os.getuid() or info.st_mode & 0o077:
|
|
174
174
|
raise Error("assistant queue must be a private regular file owned by you")
|
|
175
175
|
for suffix in ("-wal", "-shm", "-journal"):
|
|
176
176
|
with suppress(FileNotFoundError):
|
|
177
|
-
self.store.lstat(
|
|
177
|
+
self.store.lstat(QUEUE + suffix)
|
|
178
178
|
try:
|
|
179
|
-
uri = (self.store.root /
|
|
179
|
+
uri = (self.store.root / QUEUE).as_uri() + "?mode=ro"
|
|
180
180
|
connection = sqlite3.connect(uri, uri=True, timeout=10, isolation_level=None)
|
|
181
181
|
try:
|
|
182
182
|
connection.row_factory = sqlite3.Row
|
|
@@ -881,7 +881,7 @@ def _replace(store: Store) -> None:
|
|
|
881
881
|
live.execute("PRAGMA journal_mode=DELETE")
|
|
882
882
|
break
|
|
883
883
|
except sqlite3.OperationalError as error:
|
|
884
|
-
if error.sqlite_errorcode not in {sqlite3.SQLITE_BUSY, sqlite3.SQLITE_LOCKED}:
|
|
884
|
+
if error.sqlite_errorcode & 0xFF not in {sqlite3.SQLITE_BUSY, sqlite3.SQLITE_LOCKED}:
|
|
885
885
|
raise
|
|
886
886
|
if time.monotonic() >= deadline:
|
|
887
887
|
raise BusyError("readers kept the search cache open; retry bf build") from error
|
|
@@ -1168,9 +1168,10 @@ _ROW = f"{_FIELDS},'' AS fragment,i.title,i.lead AS excerpt,i.tasks_open,i.tasks
|
|
|
1168
1168
|
def within(column: str, note: str) -> str:
|
|
1169
1169
|
"""Fixed SQL: whether `column` names a section of `note`, a note path or BF address, as `note#fragment` does.
|
|
1170
1170
|
|
|
1171
|
-
A range over the column's index: `$` follows `#`, so every `note#...` sorts between them.
|
|
1171
|
+
A range over the column's index: `$` follows `#`, so every `note#...` sorts between them. A fragment never ends
|
|
1172
|
+
in `.md`, so a path such as `a.md#x.md` names another note, not a section of `a.md`.
|
|
1172
1173
|
"""
|
|
1173
|
-
return f"{column}>{note}||'#' AND {column}<{note}||'$'"
|
|
1174
|
+
return f"{column}>{note}||'#' AND {column}<{note}||'$' AND substr({column},-3)!='.md'"
|
|
1174
1175
|
|
|
1175
1176
|
|
|
1176
1177
|
# Fixed SQL: each name of the JSON array :names that exactly one item holds, with that item. A name that several
|
|
@@ -1775,7 +1776,8 @@ def status(store: Store) -> dict[str, object]:
|
|
|
1775
1776
|
sizes = dict(
|
|
1776
1777
|
connection.execute(
|
|
1777
1778
|
"SELECT substr(path,10,instr(substr(path,10),'/')-1),sum(size) FROM files "
|
|
1778
|
-
|
|
1779
|
+
# A size of -1 marks a file a transient error left unstated.
|
|
1780
|
+
"WHERE path GLOB 'memories/?*/*' AND size>=0 GROUP BY 1"
|
|
1779
1781
|
).fetchall()
|
|
1780
1782
|
)
|
|
1781
1783
|
for source, entry in counts.items():
|
|
@@ -647,7 +647,8 @@ def validate_okf(path: str, data: bytes | Markdown) -> None:
|
|
|
647
647
|
return
|
|
648
648
|
if not isinstance(attributes.get("type"), str) or not str(attributes["type"]).strip():
|
|
649
649
|
raise Error(f"{path}: OKF documents require a nonempty type in YAML frontmatter")
|
|
650
|
-
|
|
650
|
+
status = attributes.get("status", "stable")
|
|
651
|
+
if not isinstance(status, str) or status not in {"draft", "stable", "deprecated"}:
|
|
651
652
|
raise Error(f"{path}: OKF status must be draft, stable or deprecated")
|
|
652
653
|
aliases = attributes.get("aliases", [])
|
|
653
654
|
if not isinstance(aliases, list) or not all(isinstance(v, str) and re.fullmatch(IDENTITY, v) for v in aliases):
|
|
@@ -991,6 +991,11 @@ class AssistantInput(Model):
|
|
|
991
991
|
Invocation = Literal["input", "schedule", "manual", "wake"]
|
|
992
992
|
|
|
993
993
|
|
|
994
|
+
def retried(idempotent: object, kind: str) -> bool:
|
|
995
|
+
"""Whether a failed attempt of a run of this kind retries by itself: `idempotent` is true or lists the kind."""
|
|
996
|
+
return idempotent is True or (isinstance(idempotent, list) and kind in idempotent)
|
|
997
|
+
|
|
998
|
+
|
|
994
999
|
class Gate(Command):
|
|
995
1000
|
"""A deterministic check that runs before the harness and lists the events worth a model run."""
|
|
996
1001
|
|
|
@@ -1140,10 +1145,10 @@ class Assistant(Command):
|
|
|
1140
1145
|
description="Keep this many newest run records in memories/NAME/; older ones are removed after a run. Unset "
|
|
1141
1146
|
"keeps every run.",
|
|
1142
1147
|
)
|
|
1143
|
-
idempotent: bool = Field(
|
|
1148
|
+
idempotent: bool | Annotated[list[Invocation], Field(max_length=4)] = Field(
|
|
1144
1149
|
default=False,
|
|
1145
1150
|
description="Retry failed or interrupted pre-answer harness attempts automatically with backoff instead of "
|
|
1146
|
-
"leaving the job uncertain.",
|
|
1151
|
+
"leaving the job uncertain: true for every run, or the run kinds to retry, such as [schedule, wake].",
|
|
1147
1152
|
)
|
|
1148
1153
|
inputs: Annotated[list[AssistantInput], Field(max_length=32)] = Field(default_factory=list)
|
|
1149
1154
|
post: Name | None = Field(
|
|
@@ -831,48 +831,31 @@ def memories(
|
|
|
831
831
|
return None
|
|
832
832
|
return {"sources": [{"source": source, **count, **source_health(store, {source: count}, now=now)[source]}]}
|
|
833
833
|
|
|
834
|
+
window = None
|
|
834
835
|
if len(parts) == 2:
|
|
835
836
|
# A record's time is its stored instant: ordering by the column walks items_kind_source_time.
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
"i.kind='record' AND i.source=:source",
|
|
839
|
-
{"source": source},
|
|
840
|
-
"i.time DESC,i.ref DESC",
|
|
841
|
-
_time_key,
|
|
842
|
-
SECTION,
|
|
843
|
-
offset,
|
|
844
|
-
counted=counted,
|
|
845
|
-
kind="source",
|
|
846
|
-
summary=coverage,
|
|
847
|
-
)
|
|
848
|
-
if not found:
|
|
849
|
-
# An unknown source is a missing page, never an empty answer.
|
|
850
|
-
raise absent(reply, _MISSING + suggest(source, known, prefix="memories/"))
|
|
851
|
-
return {"page": "/".join(parts), "sources": _gather(found, "sources"), **reply}
|
|
852
|
-
name = parts[2]
|
|
853
|
-
window = None if name.endswith(".json") else period(name, now)
|
|
854
|
-
if window:
|
|
855
|
-
where = f"i.kind='record' AND i.source=:source AND {index.PERIOD_WITHIN}"
|
|
856
|
-
params = {"source": source, "since": window.since, "until": window.until}
|
|
857
|
-
elif name == "undated":
|
|
858
|
-
where, params = "i.kind='record' AND i.source=:source AND i.time=''", {"source": source}
|
|
859
|
-
elif re.fullmatch(r"[0-9a-f]{64}\.json", name):
|
|
860
|
-
where, params = "i.kind='record' AND i.path=:path", {"path": f"memories/{source}/{name}"}
|
|
837
|
+
where, params = "i.kind='record' AND i.source=:source", {"source": source}
|
|
838
|
+
order, key, budget, kind = "i.time DESC,i.ref DESC", _time_key, SECTION, "source"
|
|
861
839
|
else:
|
|
862
|
-
|
|
840
|
+
name = parts[2]
|
|
841
|
+
window = None if name.endswith(".json") else period(name, now)
|
|
842
|
+
if window:
|
|
843
|
+
where = f"i.kind='record' AND i.source=:source AND {index.PERIOD_WITHIN}"
|
|
844
|
+
params = {"source": source, "since": window.since, "until": window.until}
|
|
845
|
+
elif name == "undated":
|
|
846
|
+
where, params = "i.kind='record' AND i.source=:source AND i.time=''", {"source": source}
|
|
847
|
+
elif re.fullmatch(r"[0-9a-f]{64}\.json", name):
|
|
848
|
+
where, params = "i.kind='record' AND i.path=:path", {"path": f"memories/{source}/{name}"}
|
|
849
|
+
else:
|
|
850
|
+
raise NotFoundError(_MISSING)
|
|
851
|
+
order = f"({index.PERIOD_TIME}) DESC,i.ref DESC" if window else "i.time DESC,i.ref DESC"
|
|
852
|
+
key, budget = (_period_key if window else _time_key), PAGE
|
|
853
|
+
kind = "source-period" if window or name == "undated" else "record"
|
|
863
854
|
reply, found = _listing(
|
|
864
|
-
stores,
|
|
865
|
-
where,
|
|
866
|
-
params,
|
|
867
|
-
f"({index.PERIOD_TIME}) DESC,i.ref DESC" if window else "i.time DESC,i.ref DESC",
|
|
868
|
-
_period_key if window else _time_key,
|
|
869
|
-
PAGE,
|
|
870
|
-
offset,
|
|
871
|
-
counted=counted,
|
|
872
|
-
kind="source-period" if window or name == "undated" else "record",
|
|
873
|
-
summary=coverage,
|
|
855
|
+
stores, where, params, order, key, budget, offset, counted=counted, kind=kind, summary=coverage
|
|
874
856
|
)
|
|
875
857
|
if not found:
|
|
858
|
+
# An unknown source is a missing page, never an empty answer.
|
|
876
859
|
raise absent(reply, _MISSING + suggest(source, known, prefix="memories/"))
|
|
877
860
|
return {
|
|
878
861
|
"page": "/".join(parts),
|