@yahyahammad/venastine 0.2.0 → 0.3.9
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.
- package/.env.example +9 -4
- package/CONFIG_ARCHITECTURE.md +2030 -0
- package/LICENSE +201 -201
- package/NOTICE +1 -1
- package/README.md +1034 -895
- package/agents/builtin/build.md +73 -0
- package/agents/builtin/compactor.md +75 -75
- package/agents/builtin/explore.md +77 -77
- package/agents/builtin/general.md +80 -0
- package/agents/builtin/pipeline-reviewer.md +100 -100
- package/agents/builtin/plan.md +106 -88
- package/agents/builtin/review.md +74 -74
- package/agents/builtin/test.md +65 -0
- package/agents/builtin/writer.md +67 -0
- package/agents/manager.py +68 -2
- package/agents/subagent_tool.py +472 -238
- package/agents/tui_commands.py +238 -151
- package/bin/venastine.mjs +150 -4
- package/bin/venastine.py +71 -0
- package/cli_commands.py +838 -0
- package/config.py +95 -1198
- package/config.yaml +1103 -0
- package/config_edit.py +1301 -0
- package/config_schema.py +971 -0
- package/config_update.py +749 -0
- package/core/agent_activity.py +256 -118
- package/core/ansi.py +452 -0
- package/core/approval.py +137 -115
- package/core/call_view.py +364 -0
- package/core/cancel.py +121 -0
- package/core/chatgpt_auth.py +747 -0
- package/core/claims_view.py +107 -0
- package/core/client.py +2715 -1559
- package/core/commands.py +460 -0
- package/core/compaction.py +1735 -971
- package/core/config_loader.py +1982 -1563
- package/core/connect.py +686 -0
- package/core/events.py +123 -61
- package/core/file_mentions.py +280 -0
- package/core/interaction.py +411 -328
- package/core/line_pattern.py +128 -0
- package/core/loop.py +2566 -1490
- package/core/memory.py +482 -370
- package/core/pipeline_models.py +190 -176
- package/core/provider_errors.py +234 -0
- package/core/reasoning/authorization.py +130 -130
- package/core/reasoning/base.py +219 -219
- package/core/reasoning/confidence_scoring.py +484 -468
- package/core/reasoning/events.py +149 -149
- package/core/reasoning/json_retry.py +19 -1
- package/core/reasoning/orchestrator.py +1561 -1382
- package/core/reasoning/output_writer.py +345 -286
- package/core/reasoning/payload_validation.py +524 -398
- package/core/reasoning/pipeline_storage.py +88 -22
- package/core/reasoning/review.py +659 -615
- package/core/reasoning/scholar.py +458 -434
- package/core/reasoning/source_corpus.py +433 -327
- package/core/reasoning/source_scoring.py +855 -855
- package/core/replay.py +315 -183
- package/core/session.py +36 -12
- package/core/session_view.py +259 -0
- package/core/session_wake.py +259 -0
- package/core/shell_sessions.py +1553 -0
- package/core/workspace_trust.py +1 -1
- package/credentials.py +148 -20
- package/database.py +333 -252
- package/{PRIVACY.md → docs/PRIVACY.md} +78 -66
- package/docs/SECURITY.md +108 -0
- package/docs/THIRD_PARTY_NOTICES.md +148 -0
- package/env_secrets.py +50 -9
- package/json_store.py +343 -123
- package/logging_setup.py +295 -185
- package/main.py +3433 -1961
- package/mcp_client/client.py +733 -499
- package/mcp_client/config.py +126 -21
- package/mcp_client/registration.py +343 -182
- package/memories/manager.py +147 -132
- package/memories/tui_commands.py +319 -244
- package/package.json +303 -73
- package/project_init/config_files.py +282 -278
- package/project_init/generator.py +728 -564
- package/project_init/manifest.py +18 -6
- package/project_init/tui_commands.py +147 -144
- package/prompts/critic_pass.md +24 -24
- package/prompts/revalidate.md +25 -25
- package/prompts/revise.md +2 -0
- package/prompts/source_grounding.md +66 -66
- package/prompts/system_prompts.py +316 -262
- package/providers.json.example +4 -2
- package/pyproject.toml +149 -100
- package/requirements.txt +295 -72
- package/safety/policy_enforcement.py +1082 -746
- package/security/askpass.py +419 -0
- package/security/capability.py +207 -177
- package/security/confine.py +484 -0
- package/security/hosted.py +182 -0
- package/security/permissions.py +237 -190
- package/security/posture.py +124 -12
- package/security/protected_paths.py +501 -309
- package/security/sandbox.py +4108 -985
- package/security/secrets.py +855 -0
- package/skills/builtin/math/formal-specification.md +67 -67
- package/skills/builtin/math/numerical-methods.md +66 -66
- package/skills/builtin/research/experiment-design.md +62 -62
- package/skills/builtin/research/reproducibility.md +55 -55
- package/skills/builtin/research/source-evaluation.md +70 -70
- package/skills/builtin/research/statistical-inference.md +63 -63
- package/skills/builtin/research/technical-writing.md +59 -59
- package/skills/builtin/software/code-review.md +61 -61
- package/skills/builtin/software/debugging.md +61 -61
- package/skills/builtin/software/test-design.md +67 -67
- package/skills/tui_commands.py +110 -111
- package/storage.py +1338 -1005
- package/tools/base.py +161 -1
- package/tools/builtin/_math_common.py +667 -377
- package/tools/builtin/_net_common.py +225 -19
- package/tools/builtin/arxiv.py +497 -39
- package/tools/builtin/ask_user.py +231 -213
- package/tools/builtin/discrete_math.py +35 -4
- package/tools/builtin/fetch_url.py +371 -153
- package/tools/builtin/file_ops.py +720 -412
- package/tools/builtin/geometry.py +48 -12
- package/tools/builtin/get_time.py +2 -2
- package/tools/builtin/linear_algebra.py +66 -23
- package/tools/builtin/load_skill.py +76 -66
- package/tools/builtin/logic.py +171 -12
- package/tools/builtin/pin.py +227 -193
- package/tools/builtin/probability_stats.py +12 -16
- package/tools/builtin/project_docs.py +464 -405
- package/tools/builtin/remember.py +175 -158
- package/tools/builtin/shell.py +980 -461
- package/tools/builtin/shell_sessions.py +613 -0
- package/tools/builtin/symbolic_math.py +80 -10
- package/tools/builtin/todo.py +149 -147
- package/tools/builtin/web_search.py +191 -13
- package/tools/context.py +159 -136
- package/tools/isolation.py +107 -34
- package/tools/registry.py +1242 -925
- package/tui/app.py +8318 -4100
- package/tui/app.tcss +747 -556
- package/tui/commands.py +26 -170
- package/tui/diffs.py +34 -13
- package/tui/history.py +128 -128
- package/tui/hosted_driver.py +102 -0
- package/tui/markdown.py +1329 -1279
- package/tui/meters.py +364 -268
- package/tui/ravens.py +146 -146
- package/tui/screens.py +1255 -943
- package/tui/themes.py +599 -559
- package/tui/widgets.py +3813 -2332
- package/SECURITY.md +0 -88
- package/THIRD_PARTY_NOTICES.md +0 -100
package/tools/builtin/logic.py
CHANGED
|
@@ -11,6 +11,18 @@ first-order proof assistant -- it can't verify a multi-step natural-
|
|
|
11
11
|
deduction proof or reason over quantifiers. What it CAN do is give the
|
|
12
12
|
model a deterministic ground-truth check for a specific logical claim,
|
|
13
13
|
which is still real uplift over the model reasoning about it unaided.
|
|
14
|
+
|
|
15
|
+
AND THAT IS WHY THE DOMAIN IS CHECKED (batch 143). `safe_parse` admits
|
|
16
|
+
the whole 230-name allowlist, so `expression` need not be Boolean, and no
|
|
17
|
+
operation used to look. SymPy's `truth_table` substitutes 0/1 and coerces
|
|
18
|
+
the arithmetic value through `bool()`, so `x - 1` was returned as a
|
|
19
|
+
confident NOT table and `x + y` as the truth table of OR -- which has a
|
|
20
|
+
plausible caller, because in GF(2) and in coding theory `x + y` IS XOR.
|
|
21
|
+
`bool()` of an arithmetic value is not a ground-truth check for a logical
|
|
22
|
+
claim; it is a coincidence that agrees with OR for `+` and with AND for
|
|
23
|
+
`*` and diverges elsewhere. A tool whose stated value is that it is
|
|
24
|
+
mechanical has to refuse the inputs it cannot be mechanical about, so
|
|
25
|
+
`_require_boolean` is the paragraph above enforced rather than asserted.
|
|
14
26
|
"""
|
|
15
27
|
|
|
16
28
|
from __future__ import annotations
|
|
@@ -18,24 +30,69 @@ from __future__ import annotations
|
|
|
18
30
|
from typing import Literal, Optional
|
|
19
31
|
|
|
20
32
|
import sympy
|
|
21
|
-
from sympy.logic.boolalg import simplify_logic, truth_table
|
|
22
|
-
from sympy.logic.inference import satisfiable
|
|
23
33
|
from pydantic import BaseModel, Field
|
|
34
|
+
from sympy.logic.boolalg import Boolean, simplify_logic, truth_table
|
|
35
|
+
from sympy.logic.inference import satisfiable
|
|
24
36
|
|
|
25
|
-
from tools.builtin._math_common import
|
|
37
|
+
from tools.builtin._math_common import (
|
|
38
|
+
MathParseError,
|
|
39
|
+
_split_warnings,
|
|
40
|
+
parse_params,
|
|
41
|
+
safe_parse,
|
|
42
|
+
)
|
|
26
43
|
|
|
27
44
|
_OPERATIONS = Literal["simplify", "equivalent", "satisfiable", "tautology", "truth_table"]
|
|
28
45
|
|
|
46
|
+
# THE OUTPUT BOUND (batch 143), on the INPUT rather than on the rendered
|
|
47
|
+
# output, because this is the one math operation whose size is predictable
|
|
48
|
+
# before anything is computed: `truth_table` materialises 2**n rows into a
|
|
49
|
+
# list where n comes from a model-supplied string. H5's move -- refuse at
|
|
50
|
+
# the boundary rather than pay a full budget to learn the answer cannot be
|
|
51
|
+
# returned -- and it does NOT touch H4 ("no maximum on any math
|
|
52
|
+
# parameter"), because the symbol count is derived from the expression and
|
|
53
|
+
# is not a parameter anyone can cap.
|
|
54
|
+
#
|
|
55
|
+
# Measured on the real `logic.run`, with `config.MAX_READ_CHARS` (50,000)
|
|
56
|
+
# as the ceiling the other five tools get in `serialize`:
|
|
57
|
+
#
|
|
58
|
+
# columns rows chars returned secs
|
|
59
|
+
# 7 128 15,207 0.01
|
|
60
|
+
# 8 256 33,575 0.01 <- the last one under
|
|
61
|
+
# 9 512 73,511 0.03
|
|
62
|
+
# 10 1,024 159,783 0.06
|
|
63
|
+
# 14 16,384 3,440,679 1.36 <- returned to the model
|
|
64
|
+
# 15 32,768 7,323,687 3.03 before this bound
|
|
65
|
+
#
|
|
66
|
+
# So 8 is where a character cap would have landed anyway; stating it in
|
|
67
|
+
# columns is what lets the refusal name the number the caller controls.
|
|
68
|
+
# Nothing in the suite's own battery exceeds 3 columns.
|
|
69
|
+
_MAX_TRUTH_TABLE_SYMBOLS = 8
|
|
70
|
+
|
|
29
71
|
|
|
30
72
|
class LogicParams(BaseModel):
|
|
31
73
|
operation: _OPERATIONS = Field(..., description="Which operation to perform")
|
|
32
74
|
expression: str = Field(
|
|
33
75
|
...,
|
|
34
|
-
description=
|
|
76
|
+
description=(
|
|
77
|
+
"Boolean expression using variables and operators & (and), "
|
|
78
|
+
"| (or), ~ (not), >> (implies), Xor, Equivalent -- or a "
|
|
79
|
+
"comparison such as Eq(x, 5) or x > 0. It must be a "
|
|
80
|
+
"PROPOSITION: an arithmetic expression like 'x + y' has no "
|
|
81
|
+
"truth value and is refused."
|
|
82
|
+
),
|
|
35
83
|
)
|
|
36
84
|
expression_b: Optional[str] = Field(None, description="Second expression, for the 'equivalent' operation")
|
|
37
85
|
variables: Optional[list[str]] = Field(
|
|
38
|
-
None,
|
|
86
|
+
None,
|
|
87
|
+
description=(
|
|
88
|
+
"Variable names. A name listed here is kept WHOLE -- that is "
|
|
89
|
+
"the load-bearing half: any multi-character name NOT listed is "
|
|
90
|
+
"read as a product of single letters, so 'rain' alone becomes "
|
|
91
|
+
"a*i*n*r (a 16-row table over a, i, n, r) and 'rain & snow' is "
|
|
92
|
+
"a parse error. It also sets the column set and order for "
|
|
93
|
+
"truth_table, and a listed name that does not occur in the "
|
|
94
|
+
"expression becomes a constant column."
|
|
95
|
+
),
|
|
39
96
|
)
|
|
40
97
|
|
|
41
98
|
|
|
@@ -51,12 +108,93 @@ TOOL_SCHEMA = {
|
|
|
51
108
|
}
|
|
52
109
|
|
|
53
110
|
|
|
111
|
+
def _require_boolean(expr, field: str, rewritten: set) -> None:
|
|
112
|
+
"""Refuse an expression that is not a proposition. See the module docstring.
|
|
113
|
+
|
|
114
|
+
ONE `isinstance`, not a union of four types, and that was measured
|
|
115
|
+
rather than assumed: `Symbol`, `BooleanTrue`, `BooleanFalse` and every
|
|
116
|
+
`Relational` are already `Boolean` subclasses, so the single check
|
|
117
|
+
accepts `a & b`, `a >> b`, `~a`, `Xor(a, b)`, `ITE(a, b, c)`,
|
|
118
|
+
`Eq(x, 5)`, `x > 0`, `a`, `true`, `1 = 1` and refuses `x - 1`,
|
|
119
|
+
`x + y`, `x**2`, `pi`, `2`, `Matrix([[1]])`. One name is also CLOSED
|
|
120
|
+
over whatever Boolean type a future SymPy adds, which an enumeration
|
|
121
|
+
of four would not be.
|
|
122
|
+
|
|
123
|
+
`a & 1` and `a | 0` never reach here -- SymPy's own `&` raises on an
|
|
124
|
+
Integer operand, so an arithmetic constant inside a formula was
|
|
125
|
+
already refused loudly (batch 143).
|
|
126
|
+
"""
|
|
127
|
+
if isinstance(expr, Boolean):
|
|
128
|
+
return
|
|
129
|
+
message = (
|
|
130
|
+
"%s parsed as %s, which has no truth value. This tool checks "
|
|
131
|
+
"PROPOSITIONAL claims: combine variables with & (and), | (or), "
|
|
132
|
+
"~ (not), >> (implies), Xor or Equivalent, or use a comparison "
|
|
133
|
+
"such as Eq(x, 5) or x > 0. Substituting 0 and 1 into an "
|
|
134
|
+
"arithmetic expression answers a different question -- 'x + y' "
|
|
135
|
+
"would come back as the truth table of OR."
|
|
136
|
+
% (field, type(expr).__name__))
|
|
137
|
+
# The commonest way to land here is not an arithmetic expression at
|
|
138
|
+
# all: `truth_table expression="rain"` parses as `a*i*n*r`, a Mul, so
|
|
139
|
+
# the domain refusal fires on a perfectly good propositional name. The
|
|
140
|
+
# cause the caller can act on is the SPLIT, so it is appended rather
|
|
141
|
+
# than left for them to infer from "Mul" (batch 143).
|
|
142
|
+
if rewritten:
|
|
143
|
+
message += " " + " ".join(_split_warnings(rewritten, "variables"))
|
|
144
|
+
raise MathParseError(message)
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def _truth_table_columns(expr, declared: list[str]) -> list:
|
|
148
|
+
"""The column set and order for a truth table.
|
|
149
|
+
|
|
150
|
+
The declared names FIRST, in the order given, then every free symbol
|
|
151
|
+
the caller did not declare, sorted. The second half is not optional and
|
|
152
|
+
is why this is a function: handed a list that does not cover every free
|
|
153
|
+
symbol, SymPy's `truth_table` leaves the rest UNSUBSTITUTED and returns
|
|
154
|
+
the symbol itself as the output -- measured, `truth_table(a & b, [a])`
|
|
155
|
+
gives `([1], b)`, and `bool(Symbol('b'))` is then drawn as `true`. So
|
|
156
|
+
"the declared names" alone would have replaced an ignored parameter
|
|
157
|
+
with a wrong table.
|
|
158
|
+
|
|
159
|
+
A declared name absent from the expression becomes a constant column,
|
|
160
|
+
which is what a caller asking for an explicit order wants (batch 143).
|
|
161
|
+
"""
|
|
162
|
+
free = {str(s): s for s in expr.free_symbols}
|
|
163
|
+
columns, seen = [], set()
|
|
164
|
+
for name in declared:
|
|
165
|
+
if name not in seen:
|
|
166
|
+
seen.add(name)
|
|
167
|
+
columns.append(free[name] if name in free else sympy.Symbol(name))
|
|
168
|
+
for name in sorted(free):
|
|
169
|
+
if name not in seen:
|
|
170
|
+
seen.add(name)
|
|
171
|
+
columns.append(free[name])
|
|
172
|
+
return columns
|
|
173
|
+
|
|
174
|
+
|
|
54
175
|
def run(params: dict) -> dict:
|
|
55
|
-
|
|
176
|
+
try:
|
|
177
|
+
parsed = parse_params(LogicParams, params)
|
|
178
|
+
except MathParseError as e:
|
|
179
|
+
return {"error": str(e)}
|
|
180
|
+
|
|
181
|
+
# The fourth parsing tool reports a split name too. Batch 131 added
|
|
182
|
+
# this to the three tools that could not reach `symbols=` at all and
|
|
183
|
+
# left this one out, because `variables` already reached it -- but a
|
|
184
|
+
# caller who does not pass it still gets an answer about a product of
|
|
185
|
+
# single letters, and in the FUNCTIONAL spellings that answer is
|
|
186
|
+
# Boolean and therefore silent: `Xor(rain, b)`, `Not(rain)`,
|
|
187
|
+
# `Eq(rain, 5)` and `Implies(rain, b)` all parse, all pass the domain
|
|
188
|
+
# check, and `truth_table` then draws 16 rows over a, i, n, r as a
|
|
189
|
+
# success. Only the infix spellings (`rain & b`) fail loudly, and they
|
|
190
|
+
# fail naming SymPy's operand types (batch 143).
|
|
191
|
+
rewritten: set = set()
|
|
56
192
|
|
|
57
193
|
try:
|
|
58
194
|
var_names = parsed.variables or []
|
|
59
|
-
expr = safe_parse(parsed.expression, symbols=var_names
|
|
195
|
+
expr = safe_parse(parsed.expression, symbols=var_names,
|
|
196
|
+
rewritten=rewritten)
|
|
197
|
+
_require_boolean(expr, "expression", rewritten)
|
|
60
198
|
op = parsed.operation
|
|
61
199
|
|
|
62
200
|
if op == "simplify":
|
|
@@ -65,7 +203,9 @@ def run(params: dict) -> dict:
|
|
|
65
203
|
elif op == "equivalent":
|
|
66
204
|
if not parsed.expression_b:
|
|
67
205
|
return {"error": "expression_b is required for 'equivalent'"}
|
|
68
|
-
expr_b = safe_parse(parsed.expression_b, symbols=var_names
|
|
206
|
+
expr_b = safe_parse(parsed.expression_b, symbols=var_names,
|
|
207
|
+
rewritten=rewritten)
|
|
208
|
+
_require_boolean(expr_b, "expression_b", rewritten)
|
|
69
209
|
result = simplify_logic(expr) == simplify_logic(expr_b)
|
|
70
210
|
|
|
71
211
|
elif op == "satisfiable":
|
|
@@ -75,11 +215,27 @@ def run(params: dict) -> dict:
|
|
|
75
215
|
result = not satisfiable(sympy.Not(expr))
|
|
76
216
|
|
|
77
217
|
elif op == "truth_table":
|
|
78
|
-
|
|
79
|
-
|
|
218
|
+
# `variables` decides the columns when it is given, which is
|
|
219
|
+
# the half of its description that used to be inert: this list
|
|
220
|
+
# was `sorted(expr.free_symbols, key=str)` regardless, so
|
|
221
|
+
# neither the requested SET nor the requested ORDER had any
|
|
222
|
+
# effect, while the field was silently load-bearing for the
|
|
223
|
+
# parse (batch 143).
|
|
224
|
+
columns = _truth_table_columns(expr, var_names)
|
|
225
|
+
if len(columns) > _MAX_TRUTH_TABLE_SYMBOLS:
|
|
226
|
+
return {"error":
|
|
227
|
+
"truth_table would need %d columns, which is 2**%d "
|
|
228
|
+
"rows -- too large to return. The ceiling is %d "
|
|
229
|
+
"columns (%d rows). Ask about fewer variables, or "
|
|
230
|
+
"use 'satisfiable' or 'tautology', which answer "
|
|
231
|
+
"whether a row exists without enumerating any."
|
|
232
|
+
% (len(columns), len(columns),
|
|
233
|
+
_MAX_TRUTH_TABLE_SYMBOLS,
|
|
234
|
+
2 ** _MAX_TRUTH_TABLE_SYMBOLS)}
|
|
235
|
+
rows = list(truth_table(expr, columns))
|
|
80
236
|
result = [
|
|
81
237
|
{
|
|
82
|
-
"inputs": {str(s): bool(v) for s, v in zip(
|
|
238
|
+
"inputs": {str(s): bool(v) for s, v in zip(columns, row[0])},
|
|
83
239
|
"output": bool(row[1]),
|
|
84
240
|
}
|
|
85
241
|
for row in rows
|
|
@@ -93,4 +249,7 @@ def run(params: dict) -> dict:
|
|
|
93
249
|
except Exception as e:
|
|
94
250
|
return {"error": f"Computation failed: {e}"}
|
|
95
251
|
|
|
96
|
-
|
|
252
|
+
out: dict = {"result": result, "operation": op}
|
|
253
|
+
if rewritten:
|
|
254
|
+
out["warnings"] = _split_warnings(rewritten, "variables")
|
|
255
|
+
return out
|