@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
@@ -1,177 +1,207 @@
1
- """
2
- security/capability.py
3
-
4
- ROADMAP_v2 §28. The generic half of the shell approval gate: what a call
5
- is able to do (`CommandProfile`), what the harness can confine it to
6
- (`CONTAINED` / `UNCONTAINED` / `UNAVAILABLE`), and the one rule that turns
7
- those two into "does a human have to say yes".
8
-
9
- Nothing here knows what a shell command is. That is deliberate (G2):
10
- `write`, `edit` and MCP tools have the same shape of question -- this call
11
- can reach these things, and the harness can confine it this far -- and the
12
- audit found the same defect (#67/#133) twice already by letting each site
13
- answer it separately. The SHELL-specific part, deciding which capabilities
14
- a particular command string has, lives in security/sandbox.py.
15
-
16
- Note the direction of the dependency: sandbox.py imports this module, not
17
- the other way round. A second producer of profiles must not have to import
18
- the shell sandbox to describe a file write.
19
- """
20
-
21
- from __future__ import annotations
22
-
23
- from dataclasses import dataclass
24
-
25
- # ---------------------------------------------------------------------------
26
- # ---- Containment ----------------------------------------------------------
27
- # ---------------------------------------------------------------------------
28
-
29
- # How far the harness can confine a call it is about to make. Three values,
30
- # not a boolean, because "cannot run this at all" is a real third answer and
31
- # it changes what the gate should do: asking about a call that is going to
32
- # fail regardless burns a turn and teaches the model to retry.
33
- CONTAINED = "contained" # confined to the workspace (a Docker container)
34
- UNCONTAINED = "uncontained" # runs with the user's own authority (host)
35
- UNAVAILABLE = "unavailable" # no backend can run it
36
-
37
- # ---------------------------------------------------------------------------
38
- # ---- Approval modes -------------------------------------------------------
39
- # ---------------------------------------------------------------------------
40
-
41
- ALWAYS = "always"
42
- TIERED = "tiered"
43
- NEVER = "never"
44
-
45
- APPROVAL_MODES = (ALWAYS, TIERED, NEVER)
46
-
47
-
48
- def validate_mode(value: str, setting_name: str) -> str:
49
- """Return *value*, or raise if it is not an approval mode.
50
-
51
- Called at IMPORT time by whoever owns the setting, which is D24's
52
- posture applied to a value rather than a field: a typo in a security
53
- setting must not be resolved by falling back to a default. The two
54
- directions a typo can fail are not symmetric -- silently reading
55
- `"teired"` as anything other than an error either asks about
56
- everything (annoying, visible) or asks about nothing (catastrophic,
57
- invisible), and there is no way to pick a default that is safe under
58
- both readings. So there is no default.
59
- """
60
- if value not in APPROVAL_MODES:
61
- raise ValueError(
62
- f"{setting_name} must be one of {', '.join(APPROVAL_MODES)}, "
63
- f"got {value!r}")
64
- return value
65
-
66
-
67
- # ---------------------------------------------------------------------------
68
- # ---- Capability profile ---------------------------------------------------
69
- # ---------------------------------------------------------------------------
70
-
71
-
72
- @dataclass(frozen=True)
73
- class CommandProfile:
74
- """What one call is able to do, as a capability SET rather than a
75
- trust level (G1).
76
-
77
- A linear tier ordering was the obvious design and it is wrong here,
78
- because it orders harms that are not comparable: `rm -rf /workspace`
79
- (writes, no network) and `curl https://x` (no writes, network) are
80
- different harms, not more and less of one thing. Ranking them forces
81
- an answer to a question nobody asked, and a new dimension later
82
- renumbers every tier. A set lets policy read exactly the dimension it
83
- cares about and lets a dimension arrive without touching the others.
84
-
85
- `tier` survives as a LABEL -- it names the profile for the approval
86
- prompt and the record, and nothing branches on it. If you find
87
- yourself writing `if profile.tier == ...` in policy, the field you
88
- actually wanted is missing.
89
-
90
- Every field is an UPPER BOUND. `writes` means "not known to be
91
- read-only", not "will write" -- knowing which would mean parsing the
92
- command, and refusing to parse is the property that makes the
93
- classifier sound (G2).
94
- """
95
-
96
- tier: str
97
- # Whether the classifier could characterise this call AT ALL.
98
- #
99
- # A separate dimension from the capabilities, and the one the `tier`
100
- # label was standing in for: "read-only, nothing leaves the workspace"
101
- # and "we could not tell" are different claims, and only the first is
102
- # a reason to skip a human. Without this field the containment
103
- # argument silently covers the second -- an unmeasurable call inside a
104
- # network-less container satisfies every capability test by returning
105
- # False to all of them, which is the vacuity class this audit keeps
106
- # finding: a check that passes because its input was empty.
107
- #
108
- # It is also what batch 9 needs. A model-based classifier's "I am not
109
- # sure" has to land somewhere that cannot be argued away by
110
- # containment, and this is that place.
111
- measured: bool
112
- # Some argument resolves outside the workspace. Only meaningful where
113
- # the workspace is the boundary -- under CONTAINED the container's
114
- # filesystem is not the host's, so this says nothing useful there.
115
- escapes_workspace: bool
116
- # Not known to be read-only.
117
- writes: bool
118
- # The sandbox will GRANT this call network access. One fact for both
119
- # consumers, deliberately: the executor uses it to decide whether to
120
- # pass `--network`, and the gate uses it to decide whether to ask.
121
- # Splitting it into a permissive routing answer and a pessimistic
122
- # approval answer is exactly the shape of #67/#133 -- sharing the
123
- # mechanism is not sharing the policy -- inside the module written to
124
- # close that.
125
- network: bool
126
- # Why the classifier said what it said. Shown in the approval prompt,
127
- # so it is written for the person answering it, not for a log.
128
- reason: str
129
-
130
-
131
- # ---------------------------------------------------------------------------
132
- # ---- The rule -------------------------------------------------------------
133
- # ---------------------------------------------------------------------------
134
-
135
-
136
- def auto_approved(profile: CommandProfile, containment: str) -> bool:
137
- """Whether *profile* is covered by *containment* without asking anyone.
138
-
139
- One branch per containment, rather than one predicate ANDed across
140
- all of them, because the dimensions that matter genuinely differ:
141
-
142
- CONTAINED the container bounds the filesystem, so
143
- `escapes_workspace` says nothing -- `cat /etc/passwd`
144
- in a container reads the container's. What the
145
- container does NOT bound is egress, and that is the
146
- half the pre-§28 gate never looked at (#157 hole 2).
147
-
148
- UNCONTAINED nothing is bounded, so everything must be clear: no
149
- argument leaving the workspace (#157 hole 1), nothing
150
- that might write, no network.
151
-
152
- UNAVAILABLE the call cannot run, so it is not covered either.
153
- Note this is NOT "do not ask": False here means ASK,
154
- like every other False. A caller that would rather stay
155
- silent about a call which is going to fail regardless
156
- has to say so itself -- shell does, and the two
157
- polarities meeting is worth the one explicit branch
158
- rather than a second meaning smuggled into this return.
159
-
160
- `measured` gates all three. A call the classifier could not
161
- characterise must not be auto-approved by a containment argument,
162
- because every capability test passes vacuously on a profile that
163
- knows nothing.
164
-
165
- This function reads no config and knows about no tool. A caller with
166
- an explicit documented override (`AUTO_APPROVE_SANDBOX_FALLBACK` is
167
- the only one today) applies it before calling here, where it is
168
- visible, rather than passing a flag in to be honoured out of sight.
169
- """
170
- if not profile.measured:
171
- return False
172
- if containment == CONTAINED:
173
- return not profile.network
174
- if containment == UNCONTAINED:
175
- return not (profile.escapes_workspace or profile.writes
176
- or profile.network)
177
- return False
1
+ """
2
+ security/capability.py
3
+
4
+ ROADMAP_v2 §28. The generic half of the shell approval gate: what a call
5
+ is able to do (`CommandProfile`), what the harness can confine it to
6
+ (`CONTAINED` / `UNCONTAINED` / `UNAVAILABLE`), and the one rule that turns
7
+ those two into "does a human have to say yes".
8
+
9
+ Nothing here knows what a shell command is. That is deliberate (G2):
10
+ `write`, `edit` and MCP tools have the same shape of question -- this call
11
+ can reach these things, and the harness can confine it this far -- and the
12
+ audit found the same defect (#67/#133) twice already by letting each site
13
+ answer it separately. The SHELL-specific part, deciding which capabilities
14
+ a particular command string has, lives in security/sandbox.py.
15
+
16
+ Note the direction of the dependency: sandbox.py imports this module, not
17
+ the other way round. A second producer of profiles must not have to import
18
+ the shell sandbox to describe a file write.
19
+ """
20
+
21
+ from __future__ import annotations
22
+
23
+ from dataclasses import dataclass
24
+
25
+ # ---------------------------------------------------------------------------
26
+ # ---- Containment ----------------------------------------------------------
27
+ # ---------------------------------------------------------------------------
28
+
29
+ # How far the harness can confine a call it is about to make. Three values,
30
+ # not a boolean, because "cannot run this at all" is a real third answer and
31
+ # it changes what the gate should do: asking about a call that is going to
32
+ # fail regardless burns a turn and teaches the model to retry.
33
+ CONTAINED = "contained" # confined to the workspace (a Docker or Podman container)
34
+ UNCONTAINED = "uncontained" # runs with the user's own authority (host)
35
+ UNAVAILABLE = "unavailable" # no backend can run it
36
+
37
+ # ---------------------------------------------------------------------------
38
+ # ---- Approval modes -------------------------------------------------------
39
+ # ---------------------------------------------------------------------------
40
+
41
+ ALWAYS = "always"
42
+ TIERED = "tiered"
43
+ # §48 (CE2). The pre-§48 `tiered` rule, kept under its own name: anything
44
+ # the container confines and that gets no network runs unasked.
45
+ #
46
+ # NOT called CONTAINED, and the reason is a hazard rather than a style
47
+ # point: `CONTAINED = "contained"` above is a CONTAINMENT value, and the
48
+ # two vocabularies share a spelling. A mode compared against the
49
+ # containment constant would read as correct and match, so the Python
50
+ # names must differ even though the strings cannot.
51
+ CONTAINED_MODE = "contained"
52
+ NEVER = "never"
53
+
54
+ # Strictest first. The order is what validate_mode's message lists, so a
55
+ # reader of the error sees the modes the way config.yaml describes them.
56
+ APPROVAL_MODES = (ALWAYS, TIERED, CONTAINED_MODE, NEVER)
57
+
58
+
59
+ def validate_mode(value: str, setting_name: str) -> str:
60
+ """Return *value*, or raise if it is not an approval mode.
61
+
62
+ Called at IMPORT time by whoever owns the setting, which is D24's
63
+ posture applied to a value rather than a field: a typo in a security
64
+ setting must not be resolved by falling back to a default. The two
65
+ directions a typo can fail are not symmetric -- silently reading
66
+ `"teired"` as anything other than an error either asks about
67
+ everything (annoying, visible) or asks about nothing (catastrophic,
68
+ invisible), and there is no way to pick a default that is safe under
69
+ both readings. So there is no default.
70
+ """
71
+ if value not in APPROVAL_MODES:
72
+ raise ValueError(
73
+ f"{setting_name} must be one of {', '.join(APPROVAL_MODES)}, "
74
+ f"got {value!r}")
75
+ return value
76
+
77
+
78
+ # ---------------------------------------------------------------------------
79
+ # ---- Capability profile ---------------------------------------------------
80
+ # ---------------------------------------------------------------------------
81
+
82
+
83
+ @dataclass(frozen=True)
84
+ class CommandProfile:
85
+ """What one call is able to do, as a capability SET rather than a
86
+ trust level (G1).
87
+
88
+ A linear tier ordering was the obvious design and it is wrong here,
89
+ because it orders harms that are not comparable: `rm -rf /workspace`
90
+ (writes, no network) and `curl https://x` (no writes, network) are
91
+ different harms, not more and less of one thing. Ranking them forces
92
+ an answer to a question nobody asked, and a new dimension later
93
+ renumbers every tier. A set lets policy read exactly the dimension it
94
+ cares about and lets a dimension arrive without touching the others.
95
+
96
+ `tier` survives as a LABEL -- it names the profile for the approval
97
+ prompt and the record, and nothing branches on it. If you find
98
+ yourself writing `if profile.tier == ...` in policy, the field you
99
+ actually wanted is missing.
100
+
101
+ Every field is an UPPER BOUND. `writes` means "not known to be
102
+ read-only", not "will write" -- knowing which would mean parsing the
103
+ command, and refusing to parse is the property that makes the
104
+ classifier sound (G2).
105
+ """
106
+
107
+ tier: str
108
+ # Whether the classifier could characterise this call AT ALL.
109
+ #
110
+ # A separate dimension from the capabilities, and the one the `tier`
111
+ # label was standing in for: "read-only, nothing leaves the workspace"
112
+ # and "we could not tell" are different claims, and only the first is
113
+ # a reason to skip a human. Without this field the containment
114
+ # argument silently covers the second -- an unmeasurable call inside a
115
+ # network-less container satisfies every capability test by returning
116
+ # False to all of them, which is the vacuity class this audit keeps
117
+ # finding: a check that passes because its input was empty.
118
+ #
119
+ # It is also what batch 9 needs. A model-based classifier's "I am not
120
+ # sure" has to land somewhere that cannot be argued away by
121
+ # containment, and this is that place.
122
+ measured: bool
123
+ # Some argument resolves outside the workspace. Only meaningful where
124
+ # the workspace is the boundary -- under CONTAINED the container's
125
+ # filesystem is not the host's, so this says nothing useful there.
126
+ escapes_workspace: bool
127
+ # Not known to be read-only.
128
+ writes: bool
129
+ # Not known to be free of code execution: the call may run code its own
130
+ # tokens do not show -- an interpreter's `-c`, a script on disk, a
131
+ # Makefile, a test runner's conftest.py (§48, CE7). An UPPER BOUND like
132
+ # every field here, and its own dimension although every shell profile
133
+ # today sets it alike with `writes`: changing a file and running a
134
+ # program are different harms, and a future write/edit profile changes
135
+ # a file without running anything. Required, with no default, so a
136
+ # producer cannot leave it unsaid.
137
+ runs_code: bool
138
+ # The sandbox will GRANT this call network access. One fact for both
139
+ # consumers, deliberately: the executor uses it to decide whether to
140
+ # pass `--network`, and the gate uses it to decide whether to ask.
141
+ # Splitting it into a permissive routing answer and a pessimistic
142
+ # approval answer is exactly the shape of #67/#133 -- sharing the
143
+ # mechanism is not sharing the policy -- inside the module written to
144
+ # close that.
145
+ network: bool
146
+ # Why the classifier said what it said. Shown in the approval prompt,
147
+ # so it is written for the person answering it, not for a log.
148
+ reason: str
149
+
150
+
151
+ # ---------------------------------------------------------------------------
152
+ # ---- The rule -------------------------------------------------------------
153
+ # ---------------------------------------------------------------------------
154
+
155
+
156
+ def auto_approved(profile: CommandProfile, containment: str) -> bool:
157
+ """Whether *profile* is covered by *containment* without asking anyone.
158
+
159
+ One branch per containment, rather than one predicate ANDed across
160
+ all of them, because the dimensions that matter genuinely differ:
161
+
162
+ CONTAINED the container bounds the filesystem, so
163
+ `escapes_workspace` says nothing -- `cat /etc/passwd`
164
+ in a container reads the container's. What the
165
+ container does NOT bound is egress, and that is the
166
+ half the pre-§28 gate never looked at (#157 hole 2).
167
+ Nor does it make running code harmless (§48, CE1,
168
+ amending G4, which approved anything contained without
169
+ network): the classifier cannot see what a `-c`, a
170
+ script or a Makefile will do, a protected segment read
171
+ through one carries no token to catch, and code is
172
+ where a way out of the container starts. So
173
+ `runs_code` asks here too.
174
+
175
+ UNCONTAINED nothing is bounded, so everything must be clear: no
176
+ argument leaving the workspace (#157 hole 1), nothing
177
+ that might write, no network.
178
+
179
+ UNAVAILABLE the call cannot run, so it is not covered either.
180
+ Note this is NOT "do not ask": False here means ASK,
181
+ like every other False. A caller that would rather stay
182
+ silent about a call which is going to fail regardless
183
+ has to say so itself -- shell does, and the two
184
+ polarities meeting is worth the one explicit branch
185
+ rather than a second meaning smuggled into this return.
186
+
187
+ `measured` gates all three. A call the classifier could not
188
+ characterise must not be auto-approved by a containment argument,
189
+ because every capability test passes vacuously on a profile that
190
+ knows nothing.
191
+
192
+ This function reads no config and knows about no tool. A caller with
193
+ an explicit documented override applies it before calling here, where
194
+ it is visible, rather than passing a flag in to be honoured out of
195
+ sight. There are two today, both in shell's `_shell_approval_check`:
196
+ `AUTO_APPROVE_SANDBOX_FALLBACK`, and the `contained` approval mode
197
+ (§48, CE2), which is this rule's CONTAINED branch as it read before
198
+ `runs_code` joined it.
199
+ """
200
+ if not profile.measured:
201
+ return False
202
+ if containment == CONTAINED:
203
+ return not (profile.network or profile.runs_code)
204
+ if containment == UNCONTAINED:
205
+ return not (profile.escapes_workspace or profile.writes
206
+ or profile.runs_code or profile.network)
207
+ return False