claude-dev-env 8.115.0 → 8.116.1
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/bin/install.prompt-context.test.mjs +5 -6
- package/docs/rule-guides/verified-work.md +1 -1
- package/hooks/advisory/commit_and_pull_request_words.py +346 -0
- package/hooks/advisory/piece_clauses.py +248 -0
- package/hooks/advisory/pieces_per_level_analysis.py +192 -0
- package/hooks/advisory/pieces_per_level_note.py +265 -0
- package/hooks/advisory/test_commit_and_pull_request_words.py +126 -0
- package/hooks/advisory/test_piece_clauses.py +183 -0
- package/hooks/advisory/test_pieces_per_level_note.py +389 -0
- package/hooks/advisory/test_pieces_per_level_note_bounds.py +215 -0
- package/hooks/advisory/test_pieces_per_level_note_deadline.py +282 -0
- package/hooks/blocking/final_reply_gate.py +7 -29
- package/hooks/blocking/test_final_reply_gate.py +4 -196
- package/hooks/features/README.md +1 -1
- package/hooks/features/conduct-gates.md +5 -12
- package/hooks/features/session-context.md +4 -1
- package/hooks/hooks.json +10 -41
- package/hooks/hooks_constants/background_silence_prompt_constants.py +2 -0
- package/hooks/hooks_constants/pieces_per_level_note_constants.py +255 -0
- package/hooks/hooks_constants/resolve_thread_reply_gate_constants.py +0 -8
- package/hooks/hooks_constants/shell_command_wrappers.py +20 -8
- package/hooks/hooks_constants/test_shell_command_wrappers.py +7 -0
- package/hooks/session/background_silence_prompt.py +1 -1
- package/hooks/test_context_budget_hooks.py +0 -1
- package/package.json +1 -1
- package/scripts/durable_post_lint.py +0 -12
- package/scripts/durable_post_lint_config/config/constants.py +1 -2
- package/scripts/policy_lint/adapter_configuration.py +0 -2
- package/scripts/policy_lint/config/constants.py +0 -2
- package/scripts/test_durable_post_lint.py +0 -53
- package/scripts/tests/test_adapter_configuration.py +0 -16
- package/scripts/tests/test_verified_work_rule.py +13 -0
- package/hooks/blocking/chat_reply_gate.py +0 -260
- package/hooks/blocking/reply_length_gate.py +0 -804
- package/hooks/blocking/test_chat_reply_gate.py +0 -302
- package/hooks/blocking/test_reply_length_gate.py +0 -1324
- package/hooks/hooks_constants/chat_reply_gate_constants.py +0 -60
- package/hooks/hooks_constants/reply_length_gate_constants.py +0 -203
- package/hooks/hooks_constants/test_reply_length_gate_constants.py +0 -81
- package/hooks/hooks_constants/test_visual_reply_rules_constants.py +0 -50
- package/hooks/hooks_constants/visual_reply_rules_constants.py +0 -106
- package/hooks/test_visual_reply_rules.py +0 -362
- package/hooks/visual_reply_rules.py +0 -478
- package/rules/visual-reply-rules.json +0 -56
|
@@ -1,362 +0,0 @@
|
|
|
1
|
-
"""Behavior tests for the visual reply rule list."""
|
|
2
|
-
|
|
3
|
-
import json
|
|
4
|
-
import sys
|
|
5
|
-
from pathlib import Path
|
|
6
|
-
|
|
7
|
-
_hooks_directory = str(Path(__file__).resolve().parent)
|
|
8
|
-
if _hooks_directory not in sys.path:
|
|
9
|
-
sys.path.insert(0, _hooks_directory)
|
|
10
|
-
|
|
11
|
-
from hooks_constants.visual_reply_rules_constants import RULES_FILE_PATH
|
|
12
|
-
from visual_reply_rules import (
|
|
13
|
-
abbreviation_violation,
|
|
14
|
-
attaches_picture,
|
|
15
|
-
hook_supplied_text,
|
|
16
|
-
load_rules,
|
|
17
|
-
mode_enabled,
|
|
18
|
-
replies_sent_this_turn,
|
|
19
|
-
reports_results,
|
|
20
|
-
results_picture_violation,
|
|
21
|
-
second_reply_violation,
|
|
22
|
-
successful_result_text,
|
|
23
|
-
visual_shown_this_turn,
|
|
24
|
-
visual_violation,
|
|
25
|
-
widget_anchor_violation,
|
|
26
|
-
widget_flowchart_advice,
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
SHIPPED_RULES = load_rules()
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
def prompt_line(text: str) -> str:
|
|
33
|
-
return json.dumps({"type": "user", "message": {"content": text}})
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
def tool_line(tool_name: str) -> str:
|
|
37
|
-
return json.dumps(
|
|
38
|
-
{"type": "assistant", "message": {"content": [{"type": "tool_use", "name": tool_name}]}}
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
def test_shipped_rule_file_parses_with_a_label_and_reminder_per_rule() -> None:
|
|
43
|
-
rules = load_rules()
|
|
44
|
-
assert rules is not None
|
|
45
|
-
assert {each.key for each in rules.all_rules} >= {"one_item", "no_picture", "abbreviations"}
|
|
46
|
-
assert all(each.label and each.reminder for each in rules.all_rules)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
def test_load_rules_returns_none_when_a_needed_rule_is_missing(tmp_path: Path) -> None:
|
|
50
|
-
rules_path = tmp_path / "rules.json"
|
|
51
|
-
rules_path.write_text(
|
|
52
|
-
json.dumps({"rules": [{"key": "no_picture", "label": "No picture", "reminder": "Draw it."}]}),
|
|
53
|
-
encoding="utf-8",
|
|
54
|
-
)
|
|
55
|
-
assert load_rules(rules_path) is None
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
def test_load_rules_returns_none_when_only_the_results_picture_rule_is_missing(tmp_path: Path) -> None:
|
|
59
|
-
all_other_keys = ("one_item", "no_picture", "abbreviations")
|
|
60
|
-
rules_path = tmp_path / "rules.json"
|
|
61
|
-
rules_path.write_text(
|
|
62
|
-
json.dumps({"rules": [{"key": each, "label": "Label", "reminder": "Remind."} for each in all_other_keys]}),
|
|
63
|
-
encoding="utf-8",
|
|
64
|
-
)
|
|
65
|
-
assert load_rules(rules_path) is None
|
|
66
|
-
rules_path.write_text(
|
|
67
|
-
json.dumps(
|
|
68
|
-
{
|
|
69
|
-
"rules": [
|
|
70
|
-
{"key": each, "label": "Label", "reminder": "Remind."}
|
|
71
|
-
for each in (*all_other_keys, "results_picture")
|
|
72
|
-
]
|
|
73
|
-
}
|
|
74
|
-
),
|
|
75
|
-
encoding="utf-8",
|
|
76
|
-
)
|
|
77
|
-
assert load_rules(rules_path) is not None
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
def test_mode_is_off_without_a_switch_file(tmp_path: Path) -> None:
|
|
81
|
-
assert mode_enabled(tmp_path) is False
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
def test_mode_is_on_when_the_switch_file_says_so(tmp_path: Path) -> None:
|
|
85
|
-
(tmp_path / "visual-reply-mode.json").write_text('{"enabled": true}', encoding="utf-8")
|
|
86
|
-
assert mode_enabled(tmp_path) is True
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
def test_abbreviation_violation_names_the_abbreviation_and_allows_listed_words() -> None:
|
|
90
|
-
assert SHIPPED_RULES is not None
|
|
91
|
-
assert 'Abbreviation "UI"' in str(abbreviation_violation("The UI is done.", SHIPPED_RULES))
|
|
92
|
-
assert abbreviation_violation("OK, I merged it.", SHIPPED_RULES) is None
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
def test_abbreviation_violation_flags_a_lowercase_abbreviation_and_a_tracker_number() -> None:
|
|
96
|
-
assert SHIPPED_RULES is not None
|
|
97
|
-
assert 'Abbreviation "e.g."' in str(abbreviation_violation("Logs, e.g. the error log.", SHIPPED_RULES))
|
|
98
|
-
assert 'Tracker number "card 12"' in str(abbreviation_violation("See card 12.", SHIPPED_RULES))
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
def test_abbreviation_violation_names_every_abbreviation_and_tracker_number_on_its_own_line() -> None:
|
|
102
|
-
assert SHIPPED_RULES is not None
|
|
103
|
-
violation = str(abbreviation_violation("The UI and the API, e.g. card 12 and card 13.", SHIPPED_RULES))
|
|
104
|
-
all_lines = violation.splitlines()
|
|
105
|
-
assert len(all_lines) == 5
|
|
106
|
-
assert 'Abbreviation "UI"' in all_lines[0]
|
|
107
|
-
assert 'Abbreviation "API"' in all_lines[1]
|
|
108
|
-
assert 'Abbreviation "e.g."' in all_lines[2]
|
|
109
|
-
assert 'Tracker number "card 12"' in all_lines[3]
|
|
110
|
-
assert 'Tracker number "card 13"' in all_lines[4]
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
def test_widget_anchor_violation_reads_only_widget_calls() -> None:
|
|
114
|
-
anchor_input = {"widget_code": '<a href="https://example.com">page</a>'}
|
|
115
|
-
assert widget_anchor_violation("mcp__hearthbot__post_widget", anchor_input) is not None
|
|
116
|
-
assert widget_anchor_violation("mcp__hearthbot__reply", anchor_input) is None
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
def test_visual_shown_this_turn_counts_only_calls_after_the_last_prompt() -> None:
|
|
120
|
-
assert visual_shown_this_turn([prompt_line("status"), tool_line("Artifact")])
|
|
121
|
-
assert not visual_shown_this_turn(
|
|
122
|
-
[prompt_line("status"), tool_line("mcp__hearthbot__post_widget"), prompt_line("next")]
|
|
123
|
-
)
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
def test_visual_violation_reads_the_transcript_file(tmp_path: Path) -> None:
|
|
127
|
-
assert SHIPPED_RULES is not None
|
|
128
|
-
transcript_path = tmp_path / "t.jsonl"
|
|
129
|
-
transcript_path.write_text(prompt_line("status"), encoding="utf-8")
|
|
130
|
-
assert visual_violation(2, str(transcript_path), SHIPPED_RULES) is not None
|
|
131
|
-
assert visual_violation(1, str(transcript_path), SHIPPED_RULES) is None
|
|
132
|
-
assert visual_violation(2, str(tmp_path / "missing.jsonl"), SHIPPED_RULES) is None
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
def reply_use_line(tool_use_id: str) -> str:
|
|
136
|
-
return json.dumps(
|
|
137
|
-
{
|
|
138
|
-
"type": "assistant",
|
|
139
|
-
"message": {
|
|
140
|
-
"content": [{"type": "tool_use", "id": tool_use_id, "name": "mcp__thread__reply"}]
|
|
141
|
-
},
|
|
142
|
-
}
|
|
143
|
-
)
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
def result_line(tool_use_id: str, is_error: bool) -> str:
|
|
147
|
-
return json.dumps(
|
|
148
|
-
{
|
|
149
|
-
"type": "user",
|
|
150
|
-
"message": {
|
|
151
|
-
"content": [{"type": "tool_result", "tool_use_id": tool_use_id, "is_error": is_error}]
|
|
152
|
-
},
|
|
153
|
-
}
|
|
154
|
-
)
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
def test_replies_sent_this_turn_counts_delivered_replies_after_the_last_prompt() -> None:
|
|
158
|
-
all_lines = [
|
|
159
|
-
prompt_line("earlier"),
|
|
160
|
-
reply_use_line("a"),
|
|
161
|
-
result_line("a", False),
|
|
162
|
-
prompt_line("status"),
|
|
163
|
-
reply_use_line("b"),
|
|
164
|
-
result_line("b", True),
|
|
165
|
-
reply_use_line("c"),
|
|
166
|
-
result_line("c", False),
|
|
167
|
-
reply_use_line("d"),
|
|
168
|
-
]
|
|
169
|
-
assert replies_sent_this_turn(all_lines) == 1
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
def widget_use_line(tool_use_id: str) -> str:
|
|
173
|
-
return json.dumps(
|
|
174
|
-
{
|
|
175
|
-
"type": "assistant",
|
|
176
|
-
"message": {
|
|
177
|
-
"content": [
|
|
178
|
-
{"type": "tool_use", "id": tool_use_id, "name": "mcp__hearthbot__post_widget"}
|
|
179
|
-
]
|
|
180
|
-
},
|
|
181
|
-
}
|
|
182
|
-
)
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
def test_visual_shown_this_turn_skips_a_widget_that_came_back_with_an_error() -> None:
|
|
186
|
-
assert not visual_shown_this_turn(
|
|
187
|
-
[prompt_line("status"), widget_use_line("w"), result_line("w", True)]
|
|
188
|
-
)
|
|
189
|
-
assert visual_shown_this_turn([prompt_line("status"), widget_use_line("w"), result_line("w", False)])
|
|
190
|
-
assert visual_shown_this_turn([prompt_line("status"), widget_use_line("w")])
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
def test_second_reply_violation_denies_only_after_a_delivered_reply(tmp_path: Path) -> None:
|
|
194
|
-
transcript_path = tmp_path / "transcript.jsonl"
|
|
195
|
-
transcript_path.write_text(
|
|
196
|
-
"\n".join([prompt_line("status"), reply_use_line("a"), result_line("a", True)]),
|
|
197
|
-
encoding="utf-8",
|
|
198
|
-
)
|
|
199
|
-
assert second_reply_violation(str(transcript_path), SHIPPED_RULES) is None
|
|
200
|
-
transcript_path.write_text(
|
|
201
|
-
"\n".join([prompt_line("status"), reply_use_line("a"), result_line("a", False)]),
|
|
202
|
-
encoding="utf-8",
|
|
203
|
-
)
|
|
204
|
-
assert second_reply_violation(str(transcript_path), SHIPPED_RULES) is not None
|
|
205
|
-
assert second_reply_violation(str(tmp_path / "missing.jsonl"), SHIPPED_RULES) is None
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
FLOWCHART_CODE = (
|
|
209
|
-
'<svg><path d="M0 20L40 0L80 20L40 40Z"/>'
|
|
210
|
-
'<path d="M80 20H120" marker-end="url(#a)"/></svg>'
|
|
211
|
-
)
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
def test_widget_flowchart_advice_should_pass_an_svg_with_a_diamond_and_arrows() -> None:
|
|
215
|
-
rules = load_rules()
|
|
216
|
-
assert rules is not None
|
|
217
|
-
nested_input = {"input": {"widget_code": FLOWCHART_CODE}}
|
|
218
|
-
assert widget_flowchart_advice("mcp__hearthbot__post_widget", nested_input, rules) is None
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
def test_widget_flowchart_advice_should_advise_on_cards_and_shapes_without_a_decision() -> None:
|
|
222
|
-
rules = load_rules()
|
|
223
|
-
assert rules is not None
|
|
224
|
-
card_input = {"widget_code": "<div class='card'>Merged</div>"}
|
|
225
|
-
no_diamond_input = {"widget_code": '<svg><path marker-end="url(#a)"/></svg>'}
|
|
226
|
-
arrowhead_only_input = {
|
|
227
|
-
"widget_code": '<svg><marker id="a"><polygon points="0 0,9 5,0 9"/></marker>'
|
|
228
|
-
'<rect/><path marker-end="url(#a)"/></svg>'
|
|
229
|
-
}
|
|
230
|
-
for each_input in (card_input, no_diamond_input, arrowhead_only_input):
|
|
231
|
-
reason = widget_flowchart_advice("mcp__hearthbot__post_widget", each_input, rules)
|
|
232
|
-
assert reason is not None and "diamond" in reason
|
|
233
|
-
assert widget_flowchart_advice("mcp__hearthbot__reply", card_input, rules) is None
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
def test_widget_flowchart_advice_should_stay_quiet_when_the_rule_list_has_no_flowchart_rule(
|
|
237
|
-
tmp_path: Path,
|
|
238
|
-
) -> None:
|
|
239
|
-
shipped_document = json.loads(RULES_FILE_PATH.read_text(encoding="utf-8"))
|
|
240
|
-
shipped_document["rules"] = [
|
|
241
|
-
each for each in shipped_document["rules"] if each["key"] != "not_flowchart"
|
|
242
|
-
]
|
|
243
|
-
rules_path = tmp_path / "rules.json"
|
|
244
|
-
rules_path.write_text(json.dumps(shipped_document), encoding="utf-8")
|
|
245
|
-
rules = load_rules(rules_path)
|
|
246
|
-
assert rules is not None
|
|
247
|
-
card_input = {"widget_code": "<div class='card'>Merged</div>"}
|
|
248
|
-
assert widget_flowchart_advice("mcp__hearthbot__post_widget", card_input, rules) is None
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
def test_successful_result_text_joins_only_results_without_an_error(tmp_path: Path) -> None:
|
|
252
|
-
all_entries = [
|
|
253
|
-
{"type": "user", "message": {"content": "run 111 from the prompt"}},
|
|
254
|
-
{"type": "user", "message": {"content": [{"type": "tool_result", "content": "run 222 ok"}]}},
|
|
255
|
-
{
|
|
256
|
-
"type": "user",
|
|
257
|
-
"message": {
|
|
258
|
-
"content": [
|
|
259
|
-
{"type": "tool_result", "content": [{"type": "text", "text": "run 333 ok"}]},
|
|
260
|
-
{"type": "tool_result", "is_error": True, "content": "run 444 failed"},
|
|
261
|
-
]
|
|
262
|
-
},
|
|
263
|
-
},
|
|
264
|
-
]
|
|
265
|
-
transcript_path = tmp_path / "s.jsonl"
|
|
266
|
-
transcript_path.write_text("\n".join(json.dumps(each) for each in all_entries), encoding="utf-8")
|
|
267
|
-
assert successful_result_text(str(transcript_path)) == "run 222 ok\nrun 333 ok"
|
|
268
|
-
assert successful_result_text(str(tmp_path / "missing.jsonl")) is None
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
def test_hook_supplied_text_joins_hook_and_harness_text_only(tmp_path: Path) -> None:
|
|
272
|
-
all_entries = [
|
|
273
|
-
{"type": "user", "message": {"content": "pull/1 from the prompt"}},
|
|
274
|
-
{"type": "user", "isMeta": True, "message": {"content": "Stop hook feedback:\npull/2 open"}},
|
|
275
|
-
{"type": "user", "isMeta": True, "message": {"content": [{"type": "text", "text": "Base directory for this skill: pull/11"}]}},
|
|
276
|
-
{"type": "user", "isMeta": True, "message": {"content": "<system-reminder>\npull/12 watched\n</system-reminder>"}},
|
|
277
|
-
{"type": "user", "origin": {"kind": "task-notification"}, "message": {"content": "pull/3 done"}},
|
|
278
|
-
{"type": "attachment", "attachment": {"type": "hook_additional_context", "content": ["pull/4 ctx"]}},
|
|
279
|
-
{"type": "attachment", "attachment": {"type": "hook_system_message", "content": "pull/5 msg"}},
|
|
280
|
-
{
|
|
281
|
-
"type": "attachment",
|
|
282
|
-
"attachment": {"type": "queued_command", "origin": {"kind": "task-notification"}, "prompt": "pull/6 queued"},
|
|
283
|
-
},
|
|
284
|
-
{"type": "attachment", "attachment": {"type": "queued_command", "origin": {"kind": "human"}, "prompt": "pull/9 typed"}},
|
|
285
|
-
{"type": "attachment", "attachment": {"type": ["hook_additional_context"], "content": "pull/10 odd"}},
|
|
286
|
-
{"type": "attachment", "attachment": {"type": "hook_blocking_error", "blockingError": {"blockingError": "pull/7"}}},
|
|
287
|
-
{"type": "user", "message": {"content": [{"type": "tool_result", "content": "pull/8 result"}]}},
|
|
288
|
-
]
|
|
289
|
-
transcript_path = tmp_path / "s.jsonl"
|
|
290
|
-
transcript_path.write_text("\n".join(json.dumps(each) for each in all_entries), encoding="utf-8")
|
|
291
|
-
assert hook_supplied_text(str(transcript_path)) == (
|
|
292
|
-
"Stop hook feedback:\npull/2 open\n<system-reminder>\npull/12 watched\n</system-reminder>\npull/3 done\npull/4 ctx\npull/5 msg\npull/6 queued"
|
|
293
|
-
)
|
|
294
|
-
assert hook_supplied_text(str(tmp_path / "missing.jsonl")) is None
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
def test_reports_results_flags_a_markdown_table_and_three_figures() -> None:
|
|
298
|
-
assert reports_results("| Check | Result |\n|---|---|\n| Unit tests | passed |")
|
|
299
|
-
assert reports_results("The run shows 65 passed, 0 failed, and 3 skipped.")
|
|
300
|
-
assert not reports_results("The run shows 65 passed and 3 skipped.")
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
def test_reports_results_counts_a_multiplier_such_as_2_5x_as_a_figure() -> None:
|
|
304
|
-
assert reports_results("Latency fell 2.5x and throughput rose 3x and errors fell 4x.")
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
def test_reports_results_counts_no_figure_in_a_long_run_or_job_identifier() -> None:
|
|
308
|
-
assert not reports_results("Run 24011273, job 24011274 and check 24011275 are green.")
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
def test_reports_results_counts_a_negative_figure_as_a_figure() -> None:
|
|
312
|
-
assert reports_results("Deltas were -2, -5 and -7 this week.")
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
def test_reports_results_counts_no_figure_in_a_date_or_a_pull_request_number() -> None:
|
|
316
|
-
assert not reports_results("Shipped on 2026-10-29 in #2224.")
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
def test_reports_results_counts_no_figure_in_a_clock_time_or_a_list_number() -> None:
|
|
320
|
-
assert not reports_results("The run started at 10:30 and ended at 11:45.")
|
|
321
|
-
assert not reports_results("1. Checked the hook.\n2. Checked the rule.\n3. Checked the test.")
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
def test_reports_results_flags_a_markdown_table_written_without_leading_pipes() -> None:
|
|
325
|
-
assert reports_results("Check | Result\n--- | ---\nUnit tests | passed")
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
def test_attaches_picture_ignores_a_picture_shown_only_inside_a_code_fence() -> None:
|
|
329
|
-
assert not attaches_picture("Example:\n```\n\n```\nDone.", {})
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
def test_attaches_picture_accepts_a_markdown_picture_with_a_title_or_a_query_string() -> None:
|
|
333
|
-
assert attaches_picture('Results.\n\n', {})
|
|
334
|
-
assert attaches_picture("Results.\n\n", {})
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
def test_attaches_picture_accepts_an_image_file_or_a_markdown_picture_only() -> None:
|
|
338
|
-
assert attaches_picture("Results.", {"attached_outputs": [{"kind": "file", "ref": "/mnt/chart.svg"}]})
|
|
339
|
-
assert attaches_picture("", {})
|
|
340
|
-
assert not attaches_picture("Results.", {"attached_outputs": [{"kind": "file", "ref": "results.md"}]})
|
|
341
|
-
assert not attaches_picture("Results.", {"attached_outputs": [{"kind": "link", "ref": "https://x.example/c.png"}]})
|
|
342
|
-
assert not attaches_picture("Results.", {})
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
def test_attaches_picture_accepts_a_published_frame_of_any_name() -> None:
|
|
346
|
-
assert attaches_picture(
|
|
347
|
-
"Results.", {"attached_outputs": [{"kind": "frame", "ref": "https://claude.ai/artifact/dashboard"}]}
|
|
348
|
-
)
|
|
349
|
-
assert not attaches_picture(
|
|
350
|
-
"Results.", {"attached_outputs": [{"kind": "other", "ref": "https://claude.ai/artifact/dashboard"}]}
|
|
351
|
-
)
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
def test_results_picture_violation_names_the_picture_rule_and_allows_an_attached_chart() -> None:
|
|
355
|
-
assert SHIPPED_RULES is not None
|
|
356
|
-
results_text = "The run shows 65 passed, 0 failed, and 3 skipped."
|
|
357
|
-
violation = results_picture_violation(results_text, results_text, {}, SHIPPED_RULES)
|
|
358
|
-
assert violation is not None
|
|
359
|
-
assert "reports results with no picture attached" in violation
|
|
360
|
-
chart_input = {"attached_outputs": [{"kind": "file", "ref": "chart.svg"}]}
|
|
361
|
-
assert results_picture_violation(results_text, results_text, chart_input, SHIPPED_RULES) is None
|
|
362
|
-
assert results_picture_violation(results_text, results_text, {}, None) is None
|