@yahyahammad/venastine 0.3.11 → 0.3.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yahyahammad/venastine",
3
- "version": "0.3.11",
3
+ "version": "0.3.13",
4
4
  "description": "A from-scratch agentic harness: tool-using chat plus a ten-pass self-critiquing research pipeline.",
5
5
  "keywords": [
6
6
  "agent",
@@ -8,7 +8,24 @@
8
8
  "research",
9
9
  "anthropic",
10
10
  "openai",
11
- "mcp"
11
+ "mcp",
12
+ "agentic-ai",
13
+ "ai-agent",
14
+ "agent-harness",
15
+ "llm-agent",
16
+ "research-agent",
17
+ "deep-research",
18
+ "fact-checking",
19
+ "tool-use",
20
+ "model-context-protocol",
21
+ "gemini",
22
+ "deepseek",
23
+ "openrouter",
24
+ "hugging-face",
25
+ "modelscope",
26
+ "security",
27
+ "cli",
28
+ "tui"
12
29
  ],
13
30
  "homepage": "https://github.com/YahyaHammad/Venastine-Research-Harness#readme",
14
31
  "bugs": {
package/pyproject.toml CHANGED
@@ -18,9 +18,17 @@ build-backend = "setuptools.build_meta"
18
18
 
19
19
  [project]
20
20
  name = "venastine-research-harness"
21
- version = "0.3.11"
21
+ version = "0.3.13"
22
22
  description = "A from-scratch agentic harness: tool-using chat plus a ten-pass self-critiquing research pipeline."
23
23
  readme = "README.md"
24
+ # The same words as package.json's `keywords`, in the same order: what a
25
+ # package index searches. test_docs_consistency.py holds the two lists equal.
26
+ keywords = [
27
+ "agent", "llm", "research", "anthropic", "openai", "mcp", "agentic-ai",
28
+ "ai-agent", "agent-harness", "llm-agent", "research-agent", "deep-research",
29
+ "fact-checking", "tool-use", "model-context-protocol", "gemini", "deepseek",
30
+ "openrouter", "hugging-face", "modelscope", "security", "cli", "tui",
31
+ ]
24
32
  requires-python = ">=3.11"
25
33
  # PEP 639: a bare SPDX expression, not the deprecated `{ text = ... }` table, and no
26
34
  # `License :: OSI Approved ::` classifier -- PEP 639 supersedes those and setuptools warns on
@@ -39,6 +47,9 @@ classifiers = [
39
47
  "Programming Language :: Python :: 3.11",
40
48
  "Programming Language :: Python :: 3.12",
41
49
  "Programming Language :: Python :: 3.13",
50
+ "Environment :: Console",
51
+ "Operating System :: OS Independent",
52
+ "Intended Audience :: Developers",
42
53
  "Intended Audience :: Science/Research",
43
54
  "Topic :: Scientific/Engineering :: Artificial Intelligence",
44
55
  ]
@@ -63,6 +74,9 @@ dynamic = ["dependencies"]
63
74
  Homepage = "https://github.com/YahyaHammad/Venastine-Research-Harness"
64
75
  Repository = "https://github.com/YahyaHammad/Venastine-Research-Harness"
65
76
  Issues = "https://github.com/YahyaHammad/Venastine-Research-Harness/issues"
77
+ Documentation = "https://github.com/YahyaHammad/Venastine-Research-Harness#readme"
78
+ Changelog = "https://github.com/YahyaHammad/Venastine-Research-Harness/releases"
79
+ Demo = "https://huggingface.co/spaces/SolenopsisCampo/VenastineHarnessDemo"
66
80
 
67
81
  [project.optional-dependencies]
68
82
  # markitdown's only consumer is tools/builtin/file_ops.py, which implements
package/requirements.txt CHANGED
@@ -21,10 +21,10 @@
21
21
  # test_sdk_conformance.py re-checks the shapes. What to re-measure when
22
22
  # these move: that the stream, the effort query and the error types still
23
23
  # match, since the suite fakes both packages everywhere else.
24
- anthropic==2.1.0
25
- ddgs==9.16.0
24
+ anthropic==2.5.0
25
+ ddgs==9.16.1
26
26
  httpx==0.28.1
27
- openai==3.36.0
27
+ openai==3.45.0
28
28
  # ROADMAP_v3 §82 (GS1), batch 172: 1.0.0 -> 2.29.0, the owner's choice.
29
29
  # Gemini 3 refuses a request whose current turn holds a function call
30
30
  # without the thought signature it came with; 1.0.0's Part had no field
@@ -37,7 +37,7 @@ openai==3.36.0
37
37
  # transport is httpx now, not requests. 2.32.0 since batch 234, the newest
38
38
  # release at least two weeks old; test_sdk_conformance.py is the evidence,
39
39
  # with no live Gemini call (no key on this machine).
40
- google-genai==2.32.0
40
+ google-genai==2.34.0
41
41
  # Batch 208, from Dependabot's group, the owner's choice of which: the
42
42
  # packages below are ones the suite runs for real rather than faking, so
43
43
  # a green suite is evidence about them, and each release was at least two
@@ -52,7 +52,7 @@ google-genai==2.32.0
52
52
  # core/reasoning/output_writer.py draws the chart as SVG with the standard
53
53
  # library now. pillow's floor (batch 201) went with it: nothing else here
54
54
  # reaches pillow.
55
- pydantic==2.14.1
55
+ pydantic==2.14.2
56
56
  sympy==1.14.0
57
57
  # 0.0.48 since batch 234: test_storage_e2e.py runs it for real.
58
58
  sqlmodel==0.0.48
@@ -122,7 +122,7 @@ textual==8.2.8
122
122
  # without declaring, i.e. the one place such a migration would be silent.
123
123
  # The FLOOR is textual's, not a guess: 8.2.8 requires `rich>=14.2.0`, so
124
124
  # `>=13` stated a version this project can no longer be installed with.
125
- rich>=14.2,<16
125
+ rich>=15.0.0,<16
126
126
 
127
127
  # ROADMAP_v2 §17 MCP client. Upper-bounded per D22 -- and D22 exists
128
128
  # BECAUSE of this package: it was mid-major-version transition when §17
@@ -239,7 +239,7 @@ google-re2==1.1.20251105
239
239
  # message (the store relies on the three failure causes being
240
240
  # indistinguishable), and the wheel list still covers this project's
241
241
  # platforms.
242
- cryptography>=50.0.0,<52
242
+ cryptography>=50.0.2,<52
243
243
 
244
244
  # ROADMAP_v3 §83 (CG6, CG16). Checks the ID token a ChatGPT-plan sign-in
245
245
  # returns against OpenAI's published keys: RS256, issuer, audience, expiry
@@ -266,7 +266,7 @@ cryptography>=50.0.0,<52
266
266
  # moves: `jwt.decode` still refuses an algorithm outside the list it is
267
267
  # given (the `none` and HS256 tests in tests/test_chatgpt_auth.py), and
268
268
  # `PyJWKSet` still reads OpenAI's JWKS.
269
- PyJWT>=2.15.0,<3
269
+ PyJWT>=2.15.1,<3
270
270
 
271
271
  # TECHNICAL_DEBT 18, batch 116. A PRODUCTION dependency: `arxiv.py` imports
272
272
  # it at module load, and pyproject.toml reads this file for its dependency
@@ -49,11 +49,17 @@ TIERED = "tiered"
49
49
  # containment constant would read as correct and match, so the Python
50
50
  # names must differ even though the strings cannot.
51
51
  CONTAINED_MODE = "contained"
52
+ # ROADMAP_v3 §56 (JV11). `tiered`, plus a decision model asked about the
53
+ # calls `tiered` would ask about -- and only the single, contained ones
54
+ # (JV12). `tiered` itself is unchanged (JV1): this is a mode beside it.
55
+ CLASSIFIED_MODE = "classified"
52
56
  NEVER = "never"
53
57
 
54
58
  # Strictest first. The order is what validate_mode's message lists, so a
55
59
  # reader of the error sees the modes the way config.yaml describes them.
56
- APPROVAL_MODES = (ALWAYS, TIERED, CONTAINED_MODE, NEVER)
60
+ # `classified` sits after `tiered` because it asks about a subset of what
61
+ # `tiered` asks about, and before `contained`, which asks about less.
62
+ APPROVAL_MODES = (ALWAYS, TIERED, CLASSIFIED_MODE, CONTAINED_MODE, NEVER)
57
63
 
58
64
 
59
65
  def validate_mode(value: str, setting_name: str) -> str:
@@ -111,6 +111,67 @@ import config
111
111
  # ---------------------------------------------------------------------------
112
112
 
113
113
 
114
+ @dataclass(frozen=True)
115
+ class ClassifierSettings:
116
+ """The `classified` mode's decision model, as launch bound it
117
+ (ROADMAP_v3 §56, JV8).
118
+
119
+ Frozen here beside `shell_approval_mode`, and for its reason: every one
120
+ of these is an authority key, and a value bound at import cannot be
121
+ moved by an environment variable or a `config.X = ...` later in the
122
+ process. `core/decision_classifier.py` is what asks the model; this is
123
+ only what it is told. No key: `credential` NAMES the providers.json
124
+ entry, which is read when a request is made and never held.
125
+ """
126
+
127
+ style: str = "systemone"
128
+ url: str = ""
129
+ model: str = ""
130
+ credential: str = ""
131
+ timeout_s: float = 10.0
132
+ on_fail: str = "ask"
133
+ # ((metric name, threshold), ...), in core/decision_classifier.METRICS
134
+ # order. A test holds the names and keys below against that table.
135
+ thresholds: tuple = ()
136
+
137
+ @property
138
+ def configured(self) -> bool:
139
+ """Whether there is anything to ask. An unconfigured classifier is
140
+ not a launch failure (JV20): every question it would have answered
141
+ asks, which is `tiered`, and `/classifier` and the badge say so."""
142
+ return bool(self.url.strip() and self.model.strip())
143
+
144
+ def threshold(self, name: str) -> float:
145
+ for metric_name, value in self.thresholds:
146
+ if metric_name == name:
147
+ return float(value)
148
+ raise KeyError(name)
149
+
150
+
151
+ #: (metric name, config.py name) for the four thresholds. The metric names
152
+ #: are core/decision_classifier.METRICS's, re-stated rather than imported
153
+ #: for the layering reason in ClassifierSettings' docstring, and pinned.
154
+ CLASSIFIER_THRESHOLD_KEYS = (
155
+ ("containedness", "SHELL_CLASSIFIER_MIN_CONTAINEDNESS"),
156
+ ("risk", "SHELL_CLASSIFIER_MAX_RISK"),
157
+ ("modification", "SHELL_CLASSIFIER_MAX_MODIFICATION"),
158
+ ("network", "SHELL_CLASSIFIER_MAX_NETWORK"),
159
+ )
160
+
161
+
162
+ def classifier_from_config() -> ClassifierSettings:
163
+ return ClassifierSettings(
164
+ style=config.SHELL_CLASSIFIER_STYLE,
165
+ url=config.SHELL_CLASSIFIER_URL,
166
+ model=config.SHELL_CLASSIFIER_MODEL,
167
+ credential=config.SHELL_CLASSIFIER_CREDENTIAL,
168
+ timeout_s=float(config.SHELL_CLASSIFIER_TIMEOUT_S),
169
+ on_fail=config.SHELL_CLASSIFIER_ON_FAIL,
170
+ thresholds=tuple((name, float(getattr(config, key)))
171
+ for name, key in CLASSIFIER_THRESHOLD_KEYS),
172
+ )
173
+
174
+
114
175
  @dataclass(frozen=True)
115
176
  class Posture:
116
177
  """What this process is allowed to do to itself and its host.
@@ -120,7 +181,8 @@ class Posture:
120
181
  legal statement anywhere in the process.
121
182
  """
122
183
 
123
- # "always" / "tiered" / "contained" / "never" -- validated at bind time, so a typo
184
+ # "always" / "tiered" / "classified" / "contained" / "never" --
185
+ # validated at bind time, so a typo
124
186
  # is a startup failure and never a policy that quietly means
125
187
  # something else (the argument capability.validate_mode makes).
126
188
  shell_approval_mode: str
@@ -160,6 +222,11 @@ class Posture:
160
222
  # real distinction: the constant is the permanent answer and this is
161
223
  # one run's, and the environment may only ever turn redaction OFF.
162
224
  redact_off_env: bool
225
+ # ROADMAP_v3 §56 (JV8). The decision model `classified` asks. Defaulted,
226
+ # unlike the fields above, because it is read only under one mode and
227
+ # every other mode is complete without it; `_from_config` always
228
+ # supplies it.
229
+ shell_classifier: ClassifierSettings = ClassifierSettings()
163
230
 
164
231
  def unsafe_reasons(self) -> list[tuple[str, str]]:
165
232
  """Every active posture that weakens the shipped defaults, as
@@ -201,6 +268,22 @@ class Posture:
201
268
  "in the container without network runs without asking, "
202
269
  "including code the agent wrote itself; host reads and "
203
270
  "network commands still ask"))
271
+ elif self.shell_approval_mode == "classified":
272
+ # ROADMAP_v3 §56 (JV11, JV12). The first layer in the harness
273
+ # that WIDENS rather than tightens, by design -- so it is on the
274
+ # badge whenever it is on, and says who decides.
275
+ settings = self.shell_classifier
276
+ who = (f"{settings.model} at {settings.url}"
277
+ if settings.configured else
278
+ "none is configured yet, so everything it would answer "
279
+ "asks, as under tiered")
280
+ reasons.append((
281
+ "shell: classified",
282
+ "SHELL_APPROVAL_MODE is 'classified' -- a decision model "
283
+ f"({who}) decides whether a single command that runs in the "
284
+ "container, and that tiered would ask about, runs without "
285
+ "asking; compound commands, host reads, the host fallback, "
286
+ "WSL and SSH still ask"))
204
287
  # §48 (CE6). Under "always" the pair is NOT "no ask": the mode check
205
288
  # returns before the fallback opt-in is ever read, so every command
206
289
  # asks, the host fallback included. Measured, and the badge said
@@ -305,6 +388,7 @@ def _from_config() -> Posture:
305
388
  allow_ssh_backend=bool(config.ALLOW_SSH_BACKEND),
306
389
  redact_tool_outputs=bool(config.REDACT_TOOL_OUTPUTS),
307
390
  redact_off_env=_redact_off_from_env(),
391
+ shell_classifier=classifier_from_config(),
308
392
  )
309
393
 
310
394
 
@@ -1622,6 +1622,30 @@ def _feed_sudo_password(proc, secret) -> None:
1622
1622
  # a reason to make the guard start its life with an exception.
1623
1623
  _SHELL_METACHARACTERS = re.compile(r"""[;|&$`><(){}!#~'"\\]""")
1624
1624
 
1625
+
1626
+ def single_command(command) -> bool:
1627
+ """Whether *command* is ONE command a decision model may be asked
1628
+ about (ROADMAP_v3 §56, JV12).
1629
+
1630
+ ROADMAP_v2 §28 recorded this limit before §56 existed -- "the model
1631
+ never sees compound shell" -- because routing compound commands to a
1632
+ model to save prompts "collapses the injection argument entirely". So:
1633
+ no shell metacharacter, quoting and escaping included, exactly the set
1634
+ `_is_inert` refuses; and no control or invisible character, because a
1635
+ newline is a command separator to `sh -c`, which every non-inert
1636
+ command reaches. The set above does not list one only because an INERT
1637
+ command never reaches a shell.
1638
+
1639
+ Total: the gate hands this whatever the model emitted.
1640
+ """
1641
+ if not isinstance(command, str):
1642
+ return False
1643
+ stripped = command.strip()
1644
+ if not stripped or _SHELL_METACHARACTERS.search(stripped):
1645
+ return False
1646
+ return all(ch == " " or (ch.isprintable() and not ch.isspace())
1647
+ for ch in stripped)
1648
+
1625
1649
  # Dangerous flags for commands that remain in INERT_COMMANDS.
1626
1650
  #
1627
1651
  # BATCH 117 MADE THIS TABLE TRUE, because it was not. The claim beside
@@ -81,6 +81,7 @@ from typing import Literal
81
81
  from pydantic import BaseModel, Field, StrictBool
82
82
 
83
83
  import config
84
+ from core import decision_classifier
84
85
  from security import capability, posture
85
86
  from security.capability import (
86
87
  UNAVAILABLE,
@@ -111,6 +112,7 @@ from security.sandbox import (
111
112
  is_docker_available,
112
113
  known_runtime,
113
114
  run_sandboxed,
115
+ single_command,
114
116
  ssh_enabled,
115
117
  ssh_target,
116
118
  ssh_unavailable_reason,
@@ -454,6 +456,106 @@ def _command_names_root(command) -> bool:
454
456
  return False
455
457
 
456
458
 
459
+ def classifier_key(command, backend: str, network: bool = False,
460
+ needs_root: bool = False):
461
+ """The question the `classified` mode puts to its decision model for
462
+ this call, as a cache key -- or None when it puts none (ROADMAP_v3 §56).
463
+
464
+ ONE answer for the gate, the handlers and the notice, because a
465
+ `reject` the gate decides is enforced by `run` and the session starts
466
+ reading the verdict the gate stored (JV14). Three sites working out
467
+ "was the model asked about this" separately would be #157's shape.
468
+
469
+ None unless every one holds:
470
+
471
+ * the mode is `classified`;
472
+ * nothing above the opt-ins in `_shell_approval_check` answers for
473
+ the call -- not root, not a protected segment, not SSH or WSL
474
+ (JV2). Re-checked here rather than trusted, because the handlers
475
+ call this too and reach it by another road;
476
+ * it runs in the CONTAINER and was characterised (`measured`) --
477
+ ROADMAP_v2 §28's ceiling, "certain safe must not authorise a host
478
+ read", which keeps a host read, the host fallback and WSL out
479
+ (JV12);
480
+ * it is a single command (`single_command`) -- §28's other limit,
481
+ "the model never sees compound shell" (JV12);
482
+ * `tiered` would ASK about it (JV11). What `tiered` already runs
483
+ unasked never waits on a network call.
484
+
485
+ The key is the command, the project, the backend and the declared
486
+ network: everything the answer depends on.
487
+ """
488
+ if posture.current().shell_approval_mode != capability.CLASSIFIED_MODE:
489
+ return None
490
+ return classifier_question(command, backend, network, needs_root)[0]
491
+
492
+
493
+ def classifier_question(command, backend: str, network: bool = False,
494
+ needs_root: bool = False):
495
+ """`classifier_key` without the mode, and with the reason when there is
496
+ no question: `(key, "")` or `(None, why)`. `/classifier test` reads the
497
+ reason, under any mode, to say what `classified` would do."""
498
+ if not isinstance(command, str) or not command.strip():
499
+ return None, "there is no command"
500
+ if backend != BACKEND_CONTAINER:
501
+ return None, (f"it asks for the {backend} backend, which is never "
502
+ f"sent to the decision model")
503
+ if needs_root or _command_names_root(command):
504
+ return None, "it runs as root, which always asks"
505
+ if _command_touches_protected(command) is not None:
506
+ return None, "it names a protected path, which always asks"
507
+ if not single_command(command):
508
+ return None, ("it is not a single command: it contains a shell "
509
+ "metacharacter, a quote, an escape or a control "
510
+ "character, and the decision model never sees one")
511
+ network = bool(network)
512
+ profile, containment = _profile_and_containment(command, network, backend)
513
+ if containment != capability.CONTAINED:
514
+ return None, ("it would not run in a container (no container "
515
+ "runtime answered), and only a contained command is "
516
+ "sent to the decision model")
517
+ if not profile.measured:
518
+ return None, "the harness could not characterise it"
519
+ if auto_approved(profile, containment):
520
+ return None, ("tiered already runs it without asking, so the "
521
+ "decision model is not consulted")
522
+ return (command, config.WORKSPACE_DIR, backend, network), ""
523
+
524
+
525
+ def classifier_refusal(command, backend: str, network: bool = False,
526
+ needs_root: bool = False) -> str | None:
527
+ """Why the decision model's verdict stops this call, or None
528
+ (ROADMAP_v3 §56, JV14, JV18).
529
+
530
+ The handler half of `reject`: the gate answered "nothing to ask" and
531
+ this is what keeps the call from running. A verdict that is no longer
532
+ held -- `/classifier clear` between the gate and the run -- refuses
533
+ rather than runs, `fallback_changed_refusal`'s shape, because a call
534
+ nobody judged must not run on the strength of having been judged.
535
+
536
+ It names no number and no threshold (JV15): the model reads this, and
537
+ the numbers are a gradient a hijacked agent could climb.
538
+ """
539
+ key = classifier_key(command, backend, network, needs_root)
540
+ if key is None:
541
+ return None
542
+ settings = posture.current().shell_classifier
543
+ if settings.on_fail != decision_classifier.ON_FAIL_REJECT:
544
+ return None
545
+ verdict = decision_classifier.CACHE.get(key)
546
+ if verdict is None:
547
+ return ("This command was judged by the decision model and that "
548
+ "verdict has since been cleared, so it was not run. Retry, "
549
+ "and it will be judged again.")
550
+ if verdict.refuses(settings):
551
+ return ("Refused without asking: the decision model judged this "
552
+ "command outside what may run unprompted, and the harness "
553
+ "is set to refuse such commands rather than ask "
554
+ "(shell_classifier_on_fail: reject). Do the work another "
555
+ "way, or ask the user to run it.")
556
+ return None
557
+
558
+
457
559
  def _shell_approval_check(tool_name: str, params: dict) -> bool:
458
560
  """Whether this shell call needs a human to say yes (ROADMAP_v2 §28).
459
561
 
@@ -497,6 +599,15 @@ def _shell_approval_check(tool_name: str, params: dict) -> bool:
497
599
  under `tiered` and `contained` alike (§48, CE5): it is written on
498
600
  purpose and already flagged. Under `always` it is never reached,
499
601
  because step 1 returned (CE6).
602
+ 4a. The `classified` mode (ROADMAP_v3 §56, JV11-JV14) asks its
603
+ decision model about the calls `classifier_key` admits: single,
604
+ contained, and ones `tiered` would ask about. A PASS runs
605
+ unasked; a FAIL asks, or under `on_fail: reject` answers "nothing
606
+ to ask" and `run` refuses it; no verdict asks (JV10, JV13).
607
+ Below every refusal and always-ask above, which is JV2 -- the
608
+ reason a steered verdict cannot reach `.venastine/`, root or
609
+ another machine. Every call `classifier_key` refuses falls
610
+ through to step 5, which is `tiered`.
500
611
  4. The `contained` mode (§48, CE2) is the second visible opt-in, and
501
612
  applied here for the same reason: a command the container
502
613
  confines and that gets no network runs unasked. Below the
@@ -608,6 +719,19 @@ def _shell_approval_check(tool_name: str, params: dict) -> bool:
608
719
  and active.auto_approve_fallback):
609
720
  return False
610
721
 
722
+ # Step 4a, ROADMAP_v3 §56. The only step in this function that can turn
723
+ # an "ask" into "run unasked" on a model's word -- the first layer in
724
+ # the harness that widens rather than tightens, which breaks D14's
725
+ # one-way ratchet as a NAMED decision (ROADMAP_v2 §28 required one).
726
+ if mode == capability.CLASSIFIED_MODE:
727
+ key = classifier_key(command, backend, declared_network(params),
728
+ declared_root(params))
729
+ if key is not None:
730
+ settings = active.shell_classifier
731
+ verdict = decision_classifier.verdict_for(
732
+ key, command, config.WORKSPACE_DIR, settings)
733
+ return verdict.asks(settings)
734
+
611
735
  # Step 4, §48 (CE2): the rule `tiered` had before §48, under the name
612
736
  # that says what it trusts. `measured` first, for G5's reason -- the
613
737
  # container must not argue an uncharacterised call through.
@@ -693,6 +817,16 @@ def _shell_approval_notice(params: dict, _context=None) -> str:
693
817
  # look like a false positive to the person answering.
694
818
  notice += (f" It names {segment}/, a protected path that always "
695
819
  "requires approval.")
820
+ # ROADMAP_v3 §56 (JV15). The verdict is for the person answering, and
821
+ # this prompt is the one place they read it -- the model's result never
822
+ # carries it. Read from the cache the gate filled, never fetched here.
823
+ key = classifier_key(command, backend, declared_network(params),
824
+ declared_root(params))
825
+ if key is not None:
826
+ verdict = decision_classifier.CACHE.get(key)
827
+ if verdict is not None:
828
+ notice += " " + decision_classifier.describe(
829
+ verdict, posture.current().shell_classifier)
696
830
  return notice
697
831
 
698
832
 
@@ -943,6 +1077,11 @@ def run(params: dict) -> dict:
943
1077
  parsed.needs_root)
944
1078
  if refusal is not None:
945
1079
  return {"error": refusal}
1080
+ # ROADMAP_v3 §56 (JV14): a `reject` the gate decided is refused here.
1081
+ refusal = classifier_refusal(parsed.command, parsed.backend,
1082
+ parsed.requires_network, parsed.needs_root)
1083
+ if refusal is not None:
1084
+ return {"error": refusal}
946
1085
 
947
1086
  # Not probed for a WSL or SSH call, and not merely to save the 0.43s:
948
1087
  # the TOCTOU guard below is about a container runtime disappearing
@@ -504,6 +504,15 @@ def _start(name: str, model, params: dict, memory, call_id) -> dict:
504
504
  refusal = shell.uncontained_refusal(parsed.command, backend, needs_root)
505
505
  if refusal is not None:
506
506
  return {"error": refusal}
507
+ # ROADMAP_v3 §56 (JV14): a background or monitor start the decision
508
+ # model refused under `reject`. Not an interactive one: its gate is
509
+ # `_interactive_approval_check`, which never asks the model, and
510
+ # `classifier_key` would judge only its first line.
511
+ if name != INTERACTIVE:
512
+ refusal = shell.classifier_refusal(
513
+ parsed.command, backend, parsed.requires_network, needs_root)
514
+ if refusal is not None:
515
+ return {"error": refusal}
507
516
  # See `shell.run` for why an uncontained call does not probe: the guard
508
517
  # the probe feeds is about the insecure fallback, which it cannot take.
509
518
  docker_up = (True if backend != shell.BACKEND_CONTAINER
package/tui/app.py CHANGED
@@ -6139,6 +6139,39 @@ def _cmd_window(app: VenastineApp, args: str) -> None:
6139
6139
  "value.")
6140
6140
 
6141
6141
 
6142
+ def _cmd_classifier(app: VenastineApp, args: str) -> None:
6143
+ """ROADMAP_v3 §56 (JV19): the shell's decision model -- its settings
6144
+ and held verdicts, `test <command>` to see a verdict without running
6145
+ anything, `clear` to ask it again. The text is
6146
+ `core.decision_classifier`'s, which the CLI prints too; `test` is a
6147
+ network call, so it runs in a worker."""
6148
+ from core import decision_classifier
6149
+
6150
+ word, _, rest = args.strip().partition(" ")
6151
+ if word != "test":
6152
+ for line in decision_classifier.command_lines(args):
6153
+ app._transcript.write_system(line)
6154
+ return
6155
+ command = rest.strip()
6156
+ if not command:
6157
+ app._transcript.write_system(decision_classifier.USAGE)
6158
+ return
6159
+
6160
+ def show(lines: list) -> None:
6161
+ for line in lines:
6162
+ app._transcript.write_system(line)
6163
+
6164
+ def work() -> None:
6165
+ try:
6166
+ lines = decision_classifier.test_lines(command)
6167
+ except Exception as exc: # noqa: BLE001 - reported to the user
6168
+ lines = [f"/classifier test failed: {exc}"]
6169
+ app.call_from_thread(show, lines)
6170
+
6171
+ app.run_worker(work, thread=True, exit_on_error=False,
6172
+ name="classifier-test")
6173
+
6174
+
6142
6175
  def _cmd_network(app: VenastineApp, args: str) -> None:
6143
6176
  """ROADMAP_v3 §53 (IO13): every network meter, its use and its room.
6144
6177
 
@@ -8327,6 +8360,7 @@ def register_builtin_commands() -> None:
8327
8360
  bind("window", _cmd_window),
8328
8361
  bind("trigger", _cmd_trigger),
8329
8362
  bind("network", _cmd_network),
8363
+ bind("classifier", _cmd_classifier),
8330
8364
  bind("config", _cmd_config, complete=_config_rows),
8331
8365
  bind("secrets", _cmd_secrets),
8332
8366
  bind("claims", _cmd_claims),