@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.
Files changed (152) hide show
  1. package/.env.example +9 -4
  2. package/CONFIG_ARCHITECTURE.md +2030 -0
  3. package/LICENSE +201 -201
  4. package/NOTICE +1 -1
  5. package/README.md +1034 -895
  6. package/agents/builtin/build.md +73 -0
  7. package/agents/builtin/compactor.md +75 -75
  8. package/agents/builtin/explore.md +77 -77
  9. package/agents/builtin/general.md +80 -0
  10. package/agents/builtin/pipeline-reviewer.md +100 -100
  11. package/agents/builtin/plan.md +106 -88
  12. package/agents/builtin/review.md +74 -74
  13. package/agents/builtin/test.md +65 -0
  14. package/agents/builtin/writer.md +67 -0
  15. package/agents/manager.py +68 -2
  16. package/agents/subagent_tool.py +472 -238
  17. package/agents/tui_commands.py +238 -151
  18. package/bin/venastine.mjs +150 -4
  19. package/bin/venastine.py +71 -0
  20. package/cli_commands.py +838 -0
  21. package/config.py +95 -1198
  22. package/config.yaml +1103 -0
  23. package/config_edit.py +1301 -0
  24. package/config_schema.py +971 -0
  25. package/config_update.py +749 -0
  26. package/core/agent_activity.py +256 -118
  27. package/core/ansi.py +452 -0
  28. package/core/approval.py +137 -115
  29. package/core/call_view.py +364 -0
  30. package/core/cancel.py +121 -0
  31. package/core/chatgpt_auth.py +747 -0
  32. package/core/claims_view.py +107 -0
  33. package/core/client.py +2715 -1559
  34. package/core/commands.py +460 -0
  35. package/core/compaction.py +1735 -971
  36. package/core/config_loader.py +1982 -1563
  37. package/core/connect.py +686 -0
  38. package/core/events.py +123 -61
  39. package/core/file_mentions.py +280 -0
  40. package/core/interaction.py +411 -328
  41. package/core/line_pattern.py +128 -0
  42. package/core/loop.py +2566 -1490
  43. package/core/memory.py +482 -370
  44. package/core/pipeline_models.py +190 -176
  45. package/core/provider_errors.py +234 -0
  46. package/core/reasoning/authorization.py +130 -130
  47. package/core/reasoning/base.py +219 -219
  48. package/core/reasoning/confidence_scoring.py +484 -468
  49. package/core/reasoning/events.py +149 -149
  50. package/core/reasoning/json_retry.py +19 -1
  51. package/core/reasoning/orchestrator.py +1561 -1382
  52. package/core/reasoning/output_writer.py +345 -286
  53. package/core/reasoning/payload_validation.py +524 -398
  54. package/core/reasoning/pipeline_storage.py +88 -22
  55. package/core/reasoning/review.py +659 -615
  56. package/core/reasoning/scholar.py +458 -434
  57. package/core/reasoning/source_corpus.py +433 -327
  58. package/core/reasoning/source_scoring.py +855 -855
  59. package/core/replay.py +315 -183
  60. package/core/session.py +36 -12
  61. package/core/session_view.py +259 -0
  62. package/core/session_wake.py +259 -0
  63. package/core/shell_sessions.py +1553 -0
  64. package/core/workspace_trust.py +1 -1
  65. package/credentials.py +148 -20
  66. package/database.py +333 -252
  67. package/{PRIVACY.md → docs/PRIVACY.md} +78 -66
  68. package/docs/SECURITY.md +108 -0
  69. package/docs/THIRD_PARTY_NOTICES.md +148 -0
  70. package/env_secrets.py +50 -9
  71. package/json_store.py +343 -123
  72. package/logging_setup.py +295 -185
  73. package/main.py +3433 -1961
  74. package/mcp_client/client.py +733 -499
  75. package/mcp_client/config.py +126 -21
  76. package/mcp_client/registration.py +343 -182
  77. package/memories/manager.py +147 -132
  78. package/memories/tui_commands.py +319 -244
  79. package/package.json +303 -73
  80. package/project_init/config_files.py +282 -278
  81. package/project_init/generator.py +728 -564
  82. package/project_init/manifest.py +18 -6
  83. package/project_init/tui_commands.py +147 -144
  84. package/prompts/critic_pass.md +24 -24
  85. package/prompts/revalidate.md +25 -25
  86. package/prompts/revise.md +2 -0
  87. package/prompts/source_grounding.md +66 -66
  88. package/prompts/system_prompts.py +316 -262
  89. package/providers.json.example +4 -2
  90. package/pyproject.toml +149 -100
  91. package/requirements.txt +295 -72
  92. package/safety/policy_enforcement.py +1082 -746
  93. package/security/askpass.py +419 -0
  94. package/security/capability.py +207 -177
  95. package/security/confine.py +484 -0
  96. package/security/hosted.py +182 -0
  97. package/security/permissions.py +237 -190
  98. package/security/posture.py +124 -12
  99. package/security/protected_paths.py +501 -309
  100. package/security/sandbox.py +4108 -985
  101. package/security/secrets.py +855 -0
  102. package/skills/builtin/math/formal-specification.md +67 -67
  103. package/skills/builtin/math/numerical-methods.md +66 -66
  104. package/skills/builtin/research/experiment-design.md +62 -62
  105. package/skills/builtin/research/reproducibility.md +55 -55
  106. package/skills/builtin/research/source-evaluation.md +70 -70
  107. package/skills/builtin/research/statistical-inference.md +63 -63
  108. package/skills/builtin/research/technical-writing.md +59 -59
  109. package/skills/builtin/software/code-review.md +61 -61
  110. package/skills/builtin/software/debugging.md +61 -61
  111. package/skills/builtin/software/test-design.md +67 -67
  112. package/skills/tui_commands.py +110 -111
  113. package/storage.py +1338 -1005
  114. package/tools/base.py +161 -1
  115. package/tools/builtin/_math_common.py +667 -377
  116. package/tools/builtin/_net_common.py +225 -19
  117. package/tools/builtin/arxiv.py +497 -39
  118. package/tools/builtin/ask_user.py +231 -213
  119. package/tools/builtin/discrete_math.py +35 -4
  120. package/tools/builtin/fetch_url.py +371 -153
  121. package/tools/builtin/file_ops.py +720 -412
  122. package/tools/builtin/geometry.py +48 -12
  123. package/tools/builtin/get_time.py +2 -2
  124. package/tools/builtin/linear_algebra.py +66 -23
  125. package/tools/builtin/load_skill.py +76 -66
  126. package/tools/builtin/logic.py +171 -12
  127. package/tools/builtin/pin.py +227 -193
  128. package/tools/builtin/probability_stats.py +12 -16
  129. package/tools/builtin/project_docs.py +464 -405
  130. package/tools/builtin/remember.py +175 -158
  131. package/tools/builtin/shell.py +980 -461
  132. package/tools/builtin/shell_sessions.py +613 -0
  133. package/tools/builtin/symbolic_math.py +80 -10
  134. package/tools/builtin/todo.py +149 -147
  135. package/tools/builtin/web_search.py +191 -13
  136. package/tools/context.py +159 -136
  137. package/tools/isolation.py +107 -34
  138. package/tools/registry.py +1242 -925
  139. package/tui/app.py +8318 -4100
  140. package/tui/app.tcss +747 -556
  141. package/tui/commands.py +26 -170
  142. package/tui/diffs.py +34 -13
  143. package/tui/history.py +128 -128
  144. package/tui/hosted_driver.py +102 -0
  145. package/tui/markdown.py +1329 -1279
  146. package/tui/meters.py +364 -268
  147. package/tui/ravens.py +146 -146
  148. package/tui/screens.py +1255 -943
  149. package/tui/themes.py +599 -559
  150. package/tui/widgets.py +3813 -2332
  151. package/SECURITY.md +0 -88
  152. package/THIRD_PARTY_NOTICES.md +0 -100
@@ -28,9 +28,11 @@ WHAT THE GUARANTEE IS, AND IS NOT
28
28
  Stated precisely, because a half-understood control is worse than none
29
29
  (UN4). The posture CANNOT be changed by:
30
30
 
31
- * any tool call -- nothing writes `config.py` without an approval
32
- prompt, since it is outside the workspace and `_file_approval_check`
33
- hard-returns True there;
31
+ * any tool call -- nothing writes `config.yaml`, where the values
32
+ live, or `config.py`, which reads them, without an approval prompt:
33
+ both are outside the workspace and `_file_approval_check`
34
+ hard-returns True there. `write` and `edit` are globally denied on
35
+ top of that;
34
36
  * `settings.json` at either tier -- the keys are rejected BY NAME, the
35
37
  way G7 rejects `shell_approval_mode`, because a project's settings
36
38
  beat the user's and arrive with a directory you cloned;
@@ -50,10 +52,29 @@ ORDERING IS SELF-ENFORCING (UN2)
50
52
  --------------------------------
51
53
  `current()` marks the posture bound. `apply_cli()` raises if folding in
52
54
  the command line would now CHANGE it. So a wrong call order in `main.py`
53
- is a LOUD startup failure rather than a silently stale posture -- which
54
- matters because the failure mode of getting it wrong is a run that
55
+ would be a LOUD startup failure rather than a silently stale posture --
56
+ which matters because the failure mode of getting it wrong is a run that
55
57
  believes it is safer than it is, and that is invisible.
56
58
 
59
+ AND THAT GUARD IS DORMANT ON EVERY SHIPPED LAUNCH (batch 142).
60
+ `main.py` calls `apply_cli()` with NO ARGUMENTS -- it is the only
61
+ production call -- so `supplied` is always empty, `candidate` always
62
+ equals `_posture`, and `candidate != _posture` is never true. Measured:
63
+ `current()` then `apply_cli()` does not raise, while the control
64
+ `apply_cli(shell_approval_mode="never")` does. There is no live harm and
65
+ that is the same fact as the finding -- with nothing folded in, a
66
+ premature reader reads the right value anyway -- but a reader creeping
67
+ above that line today produces nothing at all.
68
+
69
+ WHAT ENFORCES UN2 TODAY is
70
+ `test_posture.py::test_no_module_reads_the_posture_at_import`, a source
71
+ scan, which is what AGENTS.md names as the pin. The scan covers IMPORT
72
+ time only, not a reader placed inside `main()` above the `apply_cli()`
73
+ call. The guard below becomes live the day the first posture flag
74
+ exists (`--unsafe` is written about in this module and in
75
+ `test_posture.py` as though it did), and `TestApplyCliOrdering` keeps it
76
+ working for that day -- which is why it is kept rather than removed.
77
+
57
78
  The predicate is "a change after a read", not "a read", and the
58
79
  difference is not a softening. The guard exists to catch *something acted
59
80
  on the config-only value*; if the command line produces the posture that
@@ -68,7 +89,10 @@ Never calling `apply_cli()` at all -- a library import, a bare test --
68
89
  leaves the config-derived default, which is the safe posture.
69
90
 
70
91
  This module imports `config` and the stdlib and nothing else, per
71
- ARCHITECTURE's rule for `security/`.
92
+ ARCHITECTURE's rule for `security/`. Note that `config` is now a shim over
93
+ `config.yaml` and so pulls in `ruamel.yaml` and `pydantic` transitively --
94
+ the rule this sentence states is about what `security/` may NAME, and that
95
+ is unchanged: `config` and the stdlib.
72
96
  """
73
97
 
74
98
  from __future__ import annotations
@@ -76,8 +100,9 @@ from __future__ import annotations
76
100
  import contextlib
77
101
  import dataclasses
78
102
  import os
103
+ from collections.abc import Iterator
79
104
  from dataclasses import dataclass
80
- from typing import Any, Iterator
105
+ from typing import Any
81
106
 
82
107
  import config
83
108
 
@@ -95,7 +120,7 @@ class Posture:
95
120
  legal statement anywhere in the process.
96
121
  """
97
122
 
98
- # "always" / "tiered" / "never" -- validated at bind time, so a typo
123
+ # "always" / "tiered" / "contained" / "never" -- validated at bind time, so a typo
99
124
  # is a startup failure and never a policy that quietly means
100
125
  # something else (the argument capability.validate_mode makes).
101
126
  shell_approval_mode: str
@@ -104,6 +129,19 @@ class Posture:
104
129
  # records that it is not defended against because it cannot be.
105
130
  allow_insecure_fallback: bool
106
131
  auto_approve_fallback: bool
132
+ # ROADMAP_v3 §49 slice 3 (SS35). Whether a command may run in WSL at
133
+ # all. Frozen here rather than read live for the reason the whole
134
+ # module exists, and the reason it belongs here rather than beside
135
+ # `wsl_distro` in plain config: a distro NAME decides where a command
136
+ # lands, and this decides whether it may leave the container.
137
+ allow_wsl_backend: bool
138
+ # ROADMAP_v3 §49 slice 4 (SS46). Whether a command may run on the
139
+ # configured remote host at all. Here rather than beside `ssh_host` in
140
+ # plain config for `allow_wsl_backend`'s reason, with one more: the
141
+ # other SSH keys say WHERE a command would land, and this one says
142
+ # whether this machine may run agent commands on a machine it cannot
143
+ # inspect.
144
+ allow_ssh_backend: bool
107
145
  # Master switch for pattern-based redaction of what leaves a tool.
108
146
  redact_tool_outputs: bool
109
147
  # VENASTINE_REDACT_OFF, the per-run weakening of the line above.
@@ -152,7 +190,24 @@ class Posture:
152
190
  "SHELL_APPROVAL_MODE is 'never' -- no shell command is "
153
191
  "ever asked about, including one that reads outside the "
154
192
  "workspace on the host"))
155
- if self.allow_insecure_fallback and self.auto_approve_fallback:
193
+ elif self.shell_approval_mode == "contained":
194
+ # §48 (CE4). Not a network or host-read weakening -- both still
195
+ # ask -- but anything the container confines runs unasked,
196
+ # including code the agent wrote itself, and in a workspace that
197
+ # holds a `.venastine/` that code can read it.
198
+ reasons.append((
199
+ "shell: contained",
200
+ "SHELL_APPROVAL_MODE is 'contained' -- a command that runs "
201
+ "in the container without network runs without asking, "
202
+ "including code the agent wrote itself; host reads and "
203
+ "network commands still ask"))
204
+ # §48 (CE6). Under "always" the pair is NOT "no ask": the mode check
205
+ # returns before the fallback opt-in is ever read, so every command
206
+ # asks, the host fallback included. Measured, and the badge said
207
+ # otherwise -- so under "always" the pair reports as the fallback
208
+ # alone, which is what it actually is.
209
+ if (self.allow_insecure_fallback and self.auto_approve_fallback
210
+ and self.shell_approval_mode != "always"):
156
211
  reasons.append((
157
212
  "host shell, no ask",
158
213
  "ALLOW_INSECURE_SANDBOX_FALLBACK and "
@@ -162,9 +217,58 @@ class Posture:
162
217
  elif self.allow_insecure_fallback:
163
218
  reasons.append((
164
219
  "host shell fallback",
165
- "ALLOW_INSECURE_SANDBOX_FALLBACK is on -- if Docker is "
166
- "down, commands run on the host with no filesystem or "
167
- "network isolation"))
220
+ "ALLOW_INSECURE_SANDBOX_FALLBACK is on -- if no container "
221
+ "runtime (Docker or Podman) can run the sandbox, commands "
222
+ "run on the host with no filesystem or network isolation"))
223
+ # ROADMAP_v3 §49 slice 3 (SS41). Reported when it is ENABLED rather
224
+ # than when it is used: the badge describes what this process may
225
+ # do, and a user reading it after a WSL command has already run has
226
+ # read it too late. It is its own pair rather than folded into the
227
+ # fallback's, because the two are different weakenings -- the
228
+ # fallback is the host when there is no container, and this is a
229
+ # Linux userland the agent can ask for while one is running.
230
+ if self.allow_wsl_backend:
231
+ # ROADMAP_v3 §49 slice 5b (SS65). The last clause used to read
232
+ # "Only a read-only command inside the workspace runs there
233
+ # without asking" unconditionally, and that is FALSE when the
234
+ # fallback opt-in is on -- measured against the real gate, where
235
+ # `rm -rf /home` on WSL answers asks=False, because WSL is
236
+ # UNCONTAINED and the opt-in sits above the capability rule.
237
+ # A badge that overstates what asks is worse than no badge, and
238
+ # this is §48 (CE6)'s correction applied to a second pair.
239
+ if (self.auto_approve_fallback
240
+ and self.shell_approval_mode not in ("always", "never")):
241
+ asking = ("AUTO_APPROVE_SANDBOX_FALLBACK is on as well, so "
242
+ "NOTHING there asks first -- that opt-in answers "
243
+ "for the whole backend, not only for the host "
244
+ "fallback it is named after. Running as root is "
245
+ "the one exception and always asks")
246
+ else:
247
+ asking = ("Only a read-only command inside the workspace "
248
+ "runs there without asking, and a command that "
249
+ "runs as root always asks")
250
+ reasons.append((
251
+ "wsl backend",
252
+ "ALLOW_WSL_BACKEND is on -- the agent can ask for a command "
253
+ "to run in WSL, which is not a sandbox: it reaches this "
254
+ "harness's own config and authority files, has no memory or "
255
+ "process limits, and can start Windows programs with your "
256
+ "full authority. " + asking))
257
+ # SS55. A THIRD pair, not a widening of the WSL one, because the
258
+ # three weakenings are different: the fallback is the host when
259
+ # there is no container, WSL is a Linux userland beside a running
260
+ # one, and this is a machine that is not this machine at all. A
261
+ # user who reads "uncontained" has to be able to tell which.
262
+ if self.allow_ssh_backend:
263
+ reasons.append((
264
+ "ssh backend",
265
+ "ALLOW_SSH_BACKEND is on -- the agent can ask for a command "
266
+ "to run on the configured remote host, which this harness "
267
+ "cannot inspect: no isolation, no memory or process limits, "
268
+ "and credentials it did not issue. Nothing runs there "
269
+ "without asking you first -- running as root included "
270
+ "(slice 5b) -- and `write` still saves locally while the "
271
+ "shell runs remotely"))
168
272
  if not self.redact_tool_outputs:
169
273
  reasons.append((
170
274
  "no redaction",
@@ -197,6 +301,8 @@ def _from_config() -> Posture:
197
301
  shell_approval_mode=config.SHELL_APPROVAL_MODE,
198
302
  allow_insecure_fallback=bool(config.ALLOW_INSECURE_SANDBOX_FALLBACK),
199
303
  auto_approve_fallback=bool(config.AUTO_APPROVE_SANDBOX_FALLBACK),
304
+ allow_wsl_backend=bool(config.ALLOW_WSL_BACKEND),
305
+ allow_ssh_backend=bool(config.ALLOW_SSH_BACKEND),
200
306
  redact_tool_outputs=bool(config.REDACT_TOOL_OUTPUTS),
201
307
  redact_off_env=_redact_off_from_env(),
202
308
  )
@@ -261,6 +367,12 @@ def apply_cli(**overrides: Any) -> Posture:
261
367
  # the read alone would also make `main()` un-callable twice in one
262
368
  # interpreter, which the suite does constantly -- and a guard that
263
369
  # forces the tests to work around it stops being read as a guard.
370
+ #
371
+ # DORMANT UNTIL THE FIRST POSTURE FLAG EXISTS (batch 142). No shipped
372
+ # launch passes an override, so `supplied` is {} and this cannot
373
+ # fire. The predicate is NOT the thing to revisit -- raising on the
374
+ # read alone was tried and was wrong twice, and the paragraph above
375
+ # is why. See the module docstring for what enforces UN2 meanwhile.
264
376
  if _read and candidate != _posture:
265
377
  raise RuntimeError(
266
378
  "security.posture.apply_cli() would CHANGE the posture after it "