brewsorted-cli 0.8.4__py3-none-any.whl

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.
@@ -0,0 +1,534 @@
1
+ import json
2
+ from pathlib import Path
3
+
4
+
5
+ SKILL_ROOT = Path(__file__).resolve().parents[1]
6
+
7
+
8
+ def test_skill_covers_safe_agent_scenarios():
9
+ instructions = " ".join(
10
+ (SKILL_ROOT / "SKILL.md").read_text(encoding="utf-8").lower().split()
11
+ )
12
+ reference = (SKILL_ROOT / "references/cli.md").read_text(encoding="utf-8")
13
+
14
+ for expected in (
15
+ "brewsorted status",
16
+ "brewsorted context",
17
+ "one-shot bootload",
18
+ "backend is unavailable",
19
+ "resolve user-provided names",
20
+ "candidate ids, types, and tags",
21
+ "resolve `brew-methods list --q`",
22
+ "equipment never selects a method",
23
+ "does not make that method eligible for suggestions",
24
+ "recipes list --q",
25
+ "recipe is a reusable default, not evidence",
26
+ "always run `brewsorted recipes preview id`",
27
+ "show every returned issue",
28
+ "user confirms the resolved draft",
29
+ "both a primary slot and extras",
30
+ "do not invent missing bounds",
31
+ "clearly call it unresolved",
32
+ "never invent",
33
+ "use only the url emitted by the cli",
34
+ "do not retry a mutation",
35
+ "complete capability surface",
36
+ "capability-gap report",
37
+ "recent context is bounded",
38
+ "separately authorized repository-development",
39
+ "do not reload the complete context before every mutation",
40
+ "distorted spoken name",
41
+ "ambiguous numbers or units",
42
+ "read the exact returned id",
43
+ "recency alone does not identify",
44
+ "write succeeded but read-back failed",
45
+ "user-stated facts, transparent calculations, hypotheses, and unresolved inputs",
46
+ "expected flavors, agent hypotheses, and brewing advice are not observed outcomes",
47
+ "never substitute a different coffee",
48
+ "leave optional classification unset",
49
+ "actual brew execution observations",
50
+ "brew tasting through `brew-ratings`",
51
+ "keep hypotheses outside tasting records",
52
+ "exactly one of `water_g` or `ratio`",
53
+ "brew patch may omit both",
54
+ "never replay a read or preview response",
55
+ "actual marketed `name`",
56
+ "existing id",
57
+ "delete only after an explicit user request",
58
+ "use `rules.filter-dial-in.v1` by default",
59
+ "facts, analysis method, inference, proposed change, uncertainty",
60
+ "state the returned reason and explanation plainly",
61
+ "ask whether that brew tried the proposed direction",
62
+ "feedback only from an explicit `yes`, `no`, or `unclear`",
63
+ "never select feedback",
64
+ ):
65
+ assert expected in instructions
66
+
67
+ for command in (
68
+ "brews history",
69
+ "brews latest",
70
+ "brews compare",
71
+ "brewsorted context",
72
+ "brew-ratings create",
73
+ "coffee-ratings create",
74
+ "brew-methods create",
75
+ "recipes preview",
76
+ "recipes apply",
77
+ "suggestion-strategies list",
78
+ "suggestions create",
79
+ "suggestion-attempts create",
80
+ "suggestion-feedback create",
81
+ ):
82
+ assert command in reference
83
+
84
+ assert "never request or invent a score" in instructions
85
+ assert "overall is optional" in reference.lower()
86
+ assert "brewsorted_web_url" in reference.lower()
87
+ assert "web_url" in reference
88
+ assert "brewsorted images upload path" in instructions
89
+ assert "never invent or" in instructions
90
+ assert "--product-url" in reference
91
+ assert "--image-id" in reference
92
+ assert "jpeg, png, or webp" in reference.lower()
93
+ assert "never alter a brew dose" in instructions
94
+ assert "--remaining-weight-g" in instructions
95
+ assert "user explicitly wants the bag finished" in instructions
96
+ assert "bag-adjustments create" in reference
97
+ assert "adjustments are immutable" in reference.lower()
98
+ assert "equipment list --q" in reference
99
+ assert "--additional-equipment-id" in reference
100
+ assert "step alignment starts" in reference.lower()
101
+ assert "legacy_grind_setting" in reference
102
+ assert "--brew-device-id" not in reference
103
+ assert "brewsorted devices create" not in reference
104
+ assert "brewsorted grinders create" not in reference
105
+
106
+
107
+ def test_m1_authentication_and_qualified_identity_guidance():
108
+ instructions = " ".join(
109
+ (SKILL_ROOT / "SKILL.md").read_text(encoding="utf-8").lower().split()
110
+ )
111
+ reference = (SKILL_ROOT / "references/cli.md").read_text(encoding="utf-8")
112
+
113
+ for expected in (
114
+ "never ask for, print, store, paste, or echo an access token",
115
+ "username/number",
116
+ "resolve names only from the authenticated user",
117
+ "treat `401` as an authentication failure",
118
+ "`403` as a capability/state denial",
119
+ "`404` as absent or inaccessible",
120
+ "`422 invalid_reference`",
121
+ ):
122
+ assert expected in instructions
123
+ assert "brewsorted login" in reference
124
+ assert "Bearer credential" in reference
125
+ assert "brewsorted brews get alex/41" in reference
126
+ assert "brewsorted brews get 41" not in reference
127
+
128
+ scenarios = json.loads(
129
+ (SKILL_ROOT / "tests/acceptance_scenarios.json").read_text(
130
+ encoding="utf-8"
131
+ )
132
+ )
133
+ issue_scenarios = [scenario for scenario in scenarios if scenario["issue"] == 108]
134
+ assert {scenario["name"] for scenario in issue_scenarios} == {
135
+ "authenticated mutation keeps and verifies Qualified identity",
136
+ "revoked connection never enters chat",
137
+ "foreign Qualified ID remains undisclosed",
138
+ "invalid foreign reference is re-resolved locally",
139
+ }
140
+ for scenario in issue_scenarios:
141
+ assert all(command.startswith("brewsorted ") for command in scenario["expected_commands"])
142
+ assert all("ct_" not in command for command in scenario["expected_commands"])
143
+
144
+
145
+ def test_v021_headless_installation_and_acceptance_guidance():
146
+ instructions = " ".join(
147
+ (SKILL_ROOT / "SKILL.md").read_text(encoding="utf-8").lower().split()
148
+ )
149
+ reference = " ".join(
150
+ (SKILL_ROOT / "references/cli.md").read_text(encoding="utf-8").lower().split()
151
+ )
152
+
153
+ for expected in (
154
+ "brewsorted login --device",
155
+ "keep the process alive",
156
+ "exact verification url and short code",
157
+ "intended user",
158
+ "their own browser",
159
+ "never authorize on their behalf",
160
+ "ssh access",
161
+ "password",
162
+ "recovery link",
163
+ "mode-`0700`",
164
+ "brewsorted_state_file",
165
+ "healthy `brewsorted status` is not authentication evidence",
166
+ ):
167
+ assert expected in instructions
168
+ assert "personal token" not in instructions
169
+ assert "brewsorted_api_token" not in instructions
170
+ assert "brewsorted login --device" in reference
171
+ assert "status` is anonymous service health" in reference
172
+ assert "disposable crud with exact qualified ids" in reference
173
+
174
+ scenarios = json.loads(
175
+ (SKILL_ROOT / "tests/acceptance_scenarios.json").read_text(encoding="utf-8")
176
+ )
177
+ issue_scenarios = [scenario for scenario in scenarios if scenario["issue"] == 153]
178
+ assert {scenario["name"] for scenario in issue_scenarios} == {
179
+ "headless device login stays alive for User authorization",
180
+ "healthy service remains distinct from authenticated context",
181
+ "refresh is proven by authenticated use after access expiry",
182
+ "disposable acceptance CRUD uses one complete Qualified ID",
183
+ }
184
+ crud = next(
185
+ scenario for scenario in issue_scenarios
186
+ if scenario["name"] == "disposable acceptance CRUD uses one complete Qualified ID"
187
+ )
188
+ for command in crud["expected_commands"][1:]:
189
+ assert "alex/52" in command
190
+ assert not command.endswith(" 52")
191
+
192
+
193
+ def test_grounded_suggestion_scenarios_keep_authority_and_provenance():
194
+ scenarios = json.loads(
195
+ (SKILL_ROOT / "tests/acceptance_scenarios.json").read_text(encoding="utf-8")
196
+ )
197
+ issue_scenarios = [scenario for scenario in scenarios if scenario["issue"] == 51]
198
+ by_name = {scenario["name"]: scenario for scenario in issue_scenarios}
199
+ assert {
200
+ "grounded Suggestion preserves facts inference citations and link",
201
+ "insufficient Suggestion stops without fallback advice",
202
+ "Attempt requires explicit direction confirmation",
203
+ "confirmed Attempt is written once and verified",
204
+ "explicit Feedback appends and verifies",
205
+ "score change never infers Feedback",
206
+ "uncertain Suggestion create is not retried",
207
+ "external strategy waits for explicit selection and consent",
208
+ } <= by_name.keys()
209
+
210
+ for scenario in issue_scenarios:
211
+ assert scenario["request"]
212
+ assert scenario["controlled_cli_results"]
213
+ assert scenario["expected_outcome"]
214
+ assert scenario["forbidden_actions"]
215
+ assert isinstance(scenario["confirmation_required"], bool)
216
+ assert scenario["mutation_outcome"]
217
+ assert all(
218
+ command.startswith("brewsorted ")
219
+ for command in scenario["expected_commands"]
220
+ )
221
+ mutations = [
222
+ command for command in scenario["expected_commands"]
223
+ if len(command.split()) > 2 and command.split()[2] == "create"
224
+ ]
225
+ assert len(mutations) <= 1
226
+
227
+ proposed = by_name[
228
+ "grounded Suggestion preserves facts inference citations and link"
229
+ ]
230
+ assert proposed["expected_commands"][-1] == "brewsorted suggestions get alex/9"
231
+ assert "exact Suggestion web_url" in proposed["expected_outcome"]
232
+
233
+ insufficient = by_name[
234
+ "insufficient Suggestion stops without fallback advice"
235
+ ]
236
+ assert "fallback" in insufficient["expected_outcome"]
237
+
238
+ pending = by_name["Attempt requires explicit direction confirmation"]
239
+ assert pending["confirmation_required"] is True
240
+ assert all(
241
+ "suggestion-attempts create" not in command
242
+ for command in pending["expected_commands"]
243
+ )
244
+
245
+ confirmed = by_name["confirmed Attempt is written once and verified"]
246
+ assert confirmed["expected_commands"][-1] == (
247
+ "brewsorted suggestion-attempts get alex/3"
248
+ )
249
+
250
+ score = by_name["score change never infers Feedback"]
251
+ assert all(
252
+ "suggestion-feedback create" not in command
253
+ for command in score["expected_commands"]
254
+ )
255
+
256
+ uncertain = by_name["uncertain Suggestion create is not retried"]
257
+ assert uncertain["mutation_outcome"] == "uncertain"
258
+ assert sum(
259
+ "suggestions create" in command for command in uncertain["expected_commands"]
260
+ ) == 1
261
+
262
+ external = by_name[
263
+ "external strategy waits for explicit selection and consent"
264
+ ]
265
+ assert external["confirmation_required"] is True
266
+ assert all(
267
+ "suggestions create" not in command
268
+ for command in external["expected_commands"]
269
+ )
270
+
271
+
272
+ def test_skill_resources_resolve_inside_client_bundle():
273
+ receipt = SKILL_ROOT / "brewsorted-install.json"
274
+ if receipt.exists():
275
+ installed = json.loads(receipt.read_text(encoding="utf-8"))
276
+ assert installed["cli_version"]
277
+ assert "references/cli.md" in installed["files"]
278
+ assert "tests/acceptance_scenarios.json" in installed["files"]
279
+ else:
280
+ assert SKILL_ROOT.parent.name == "skills"
281
+ assert SKILL_ROOT.parent.parent.name == "cli" or SKILL_ROOT.parent.parent.name.startswith("brewsorted-client-")
282
+ assert (SKILL_ROOT / "references/cli.md").is_file()
283
+ assert (SKILL_ROOT / "tests/acceptance_scenarios.json").is_file()
284
+
285
+
286
+ def test_capability_boundary_acceptance_scenarios_are_actionable():
287
+ scenarios = json.loads(
288
+ (SKILL_ROOT / "tests/acceptance_scenarios.json").read_text(encoding="utf-8")
289
+ )
290
+ issue_scenarios = [scenario for scenario in scenarios if scenario["issue"] == 93]
291
+
292
+ assert len(issue_scenarios) >= 3
293
+ for scenario in issue_scenarios:
294
+ assert scenario["request"]
295
+ assert scenario["controlled_cli_results"]
296
+ assert scenario["expected_commands"]
297
+ assert scenario["expected_outcome"]
298
+ assert scenario["forbidden_actions"]
299
+ assert all(
300
+ command.startswith("brewsorted ")
301
+ for command in scenario["expected_commands"]
302
+ )
303
+
304
+ unsupported = next(
305
+ scenario
306
+ for scenario in issue_scenarios
307
+ if scenario["name"] == "unsupported merge stops at the operational boundary"
308
+ )
309
+ assert set(unsupported["capability_gap"]) == {
310
+ "requested_outcome",
311
+ "current_supported_behavior",
312
+ "observed_limitation",
313
+ "user_impact",
314
+ "desired_capability",
315
+ "known_affected_records",
316
+ }
317
+ assert "without mutation" in unsupported["expected_outcome"].lower()
318
+
319
+ missing_from_context = next(
320
+ scenario
321
+ for scenario in issue_scenarios
322
+ if scenario["name"] == "bounded context is followed by catalog search"
323
+ )
324
+ assert missing_from_context["expected_commands"] == [
325
+ "brewsorted context",
326
+ 'brewsorted brew-methods list --q "Aeropress inverted"',
327
+ ]
328
+
329
+ supported_create = next(
330
+ scenario
331
+ for scenario in issue_scenarios
332
+ if scenario["name"] == "genuinely new catalog entry uses supported creation"
333
+ )
334
+ assert supported_create["expected_commands"] == [
335
+ 'brewsorted drink-types list --q "Espresso tonic"',
336
+ 'brewsorted drink-types create --name "Espresso tonic"',
337
+ ]
338
+
339
+
340
+ def test_identity_and_verification_scenarios_cover_expected_outcomes():
341
+ scenarios = json.loads(
342
+ (SKILL_ROOT / "tests/acceptance_scenarios.json").read_text(encoding="utf-8")
343
+ )
344
+ issue_scenarios = [scenario for scenario in scenarios if scenario["issue"] == 94]
345
+ by_name = {scenario["name"]: scenario for scenario in issue_scenarios}
346
+
347
+ required_names = {
348
+ "clear authorized Brew is written once and read back",
349
+ "two open Bags require physical Bag choice",
350
+ "ambiguous Equipment names require ID choice",
351
+ "distinctive token resolves distorted spoken name",
352
+ "suspicious number is clarified instead of corrected",
353
+ "entity absent from context is found in full catalog",
354
+ "successful update is read back by returned ID",
355
+ "read-back mismatch is reported without correction",
356
+ "successful write with failed read-back stays successful but unverified",
357
+ "uncertain create with zero matches stops",
358
+ "uncertain create with one exact match is verified",
359
+ "uncertain create with multiple matches stays uncertain",
360
+ "Recipe apply is verified through returned Brew",
361
+ }
362
+ assert required_names <= by_name.keys()
363
+
364
+ for scenario in issue_scenarios:
365
+ assert scenario["request"]
366
+ assert scenario["controlled_cli_results"]
367
+ assert scenario["expected_commands"]
368
+ assert scenario["expected_outcome"]
369
+ assert scenario["forbidden_actions"]
370
+ assert isinstance(scenario["clarification_required"], bool)
371
+ assert scenario["mutation_outcome"]
372
+ assert scenario["expected_commands"].count("brewsorted context") <= 1
373
+ mutations = [
374
+ command
375
+ for command in scenario["expected_commands"]
376
+ if len(command.split()) > 2
377
+ and command.split()[2] in {"create", "update", "apply"}
378
+ ]
379
+ assert len(mutations) <= 1
380
+
381
+ clear_brew = by_name["clear authorized Brew is written once and read back"]
382
+ assert clear_brew["expected_commands"][-1] == "brewsorted brews get alex/41"
383
+ assert "brewsorted context" not in clear_brew["expected_commands"]
384
+ assert clear_brew["clarification_required"] is False
385
+
386
+ two_bags = by_name["two open Bags require physical Bag choice"]
387
+ assert two_bags["clarification_required"] is True
388
+ assert all(
389
+ "brews create" not in command for command in two_bags["expected_commands"]
390
+ )
391
+
392
+ spoken_name = by_name["distinctive token resolves distorted spoken name"]
393
+ assert spoken_name["clarification_required"] is False
394
+ assert spoken_name["expected_commands"] == [
395
+ 'brewsorted equipment list --q "C40" --type grinder'
396
+ ]
397
+
398
+ mismatch = by_name["read-back mismatch is reported without correction"]
399
+ assert mismatch["mutation_outcome"] == "mismatch"
400
+ assert (
401
+ sum("equipment update" in command for command in mismatch["expected_commands"])
402
+ == 1
403
+ )
404
+
405
+ failed_readback = by_name[
406
+ "successful write with failed read-back stays successful but unverified"
407
+ ]
408
+ assert failed_readback["mutation_outcome"] == "write_succeeded_verification_failed"
409
+
410
+ uncertain = {
411
+ name: by_name[name]
412
+ for name in (
413
+ "uncertain create with zero matches stops",
414
+ "uncertain create with one exact match is verified",
415
+ "uncertain create with multiple matches stays uncertain",
416
+ )
417
+ }
418
+ assert (
419
+ uncertain["uncertain create with zero matches stops"]["mutation_outcome"]
420
+ == "uncertain"
421
+ )
422
+ assert uncertain["uncertain create with one exact match is verified"][
423
+ "expected_commands"
424
+ ][-1] == "brewsorted brews get alex/42"
425
+ assert (
426
+ uncertain["uncertain create with multiple matches stays uncertain"][
427
+ "mutation_outcome"
428
+ ]
429
+ == "uncertain"
430
+ )
431
+ for scenario in uncertain.values():
432
+ assert sum("brews create" in command for command in scenario["expected_commands"]) == 1
433
+
434
+ recipe = by_name["Recipe apply is verified through returned Brew"]
435
+ assert recipe["expected_commands"][-1] == "brewsorted brews get alex/43"
436
+ assert sum("recipes apply" in command for command in recipe["expected_commands"]) == 1
437
+
438
+
439
+ def test_semantic_payload_scenarios_preserve_user_facts():
440
+ scenarios = json.loads(
441
+ (SKILL_ROOT / "tests/acceptance_scenarios.json").read_text(encoding="utf-8")
442
+ )
443
+ issue_scenarios = [scenario for scenario in scenarios if scenario["issue"] == 95]
444
+ by_name = {scenario["name"]: scenario for scenario in issue_scenarios}
445
+
446
+ required_names = {
447
+ "measured dose and water omit redundant ratio",
448
+ "ratio target omits water input",
449
+ "notes-only Brew PATCH preserves liquid values",
450
+ "Recipe may omit both liquid defaults",
451
+ "expected sweetness does not become a Tasting",
452
+ "actual sensory notes need no score",
453
+ "unavailable method is omitted without substitution",
454
+ "known brewer does not imply method or Drink type",
455
+ "Coffee identity does not choose a physical Bag",
456
+ "Coffee product name and attributes stay separate",
457
+ "Equipment metadata update retains identity",
458
+ }
459
+ assert required_names <= by_name.keys()
460
+
461
+ for scenario in issue_scenarios:
462
+ assert scenario["request"]
463
+ assert scenario["controlled_cli_results"]
464
+ assert scenario["expected_outcome"]
465
+ assert scenario["expected_omitted_fields"]
466
+ assert scenario["forbidden_actions"]
467
+ assert all(
468
+ command.startswith("brewsorted ")
469
+ for command in scenario["expected_commands"]
470
+ )
471
+ payload = scenario["expected_payload"]
472
+ if payload is not None:
473
+ assert set(payload).isdisjoint(scenario["expected_omitted_fields"])
474
+ mutations = [
475
+ command
476
+ for command in scenario["expected_commands"]
477
+ if len(command.split()) > 2
478
+ and command.split()[2] in {"create", "update", "apply"}
479
+ ]
480
+ assert len(mutations) <= 1
481
+
482
+ measured = by_name["measured dose and water omit redundant ratio"]
483
+ assert measured["expected_payload"] == {
484
+ "coffee_bag_id": "alex/21",
485
+ "dose_g": 15,
486
+ "water_g": 240,
487
+ }
488
+ assert "--ratio" not in measured["expected_commands"][0]
489
+
490
+ ratio = by_name["ratio target omits water input"]
491
+ assert ratio["expected_payload"]["ratio"] == 16
492
+ assert "--water-g" not in ratio["expected_commands"][0]
493
+
494
+ notes_patch = by_name["notes-only Brew PATCH preserves liquid values"]
495
+ assert notes_patch["expected_payload"] == {"notes": "Fast drawdown"}
496
+ assert {"dose_g", "water_g", "ratio"} <= set(
497
+ notes_patch["expected_omitted_fields"]
498
+ )
499
+
500
+ recipe = by_name["Recipe may omit both liquid defaults"]
501
+ assert {"water_g", "ratio"} <= set(recipe["expected_omitted_fields"])
502
+
503
+ expectation = by_name["expected sweetness does not become a Tasting"]
504
+ assert expectation["expected_commands"] == []
505
+ assert expectation["expected_payload"] is None
506
+
507
+ tasting = by_name["actual sensory notes need no score"]
508
+ assert {"overall", "author"} <= set(tasting["expected_omitted_fields"])
509
+ assert "--overall" not in tasting["expected_commands"][1]
510
+
511
+ unavailable_method = by_name["unavailable method is omitted without substitution"]
512
+ assert "brew_method_id" in unavailable_method["expected_omitted_fields"]
513
+ assert "--brew-method-id" not in unavailable_method["expected_commands"][1]
514
+
515
+ equipment_only = by_name["known brewer does not imply method or Drink type"]
516
+ assert {"brew_method_id", "drink_type_id"} <= set(
517
+ equipment_only["expected_omitted_fields"]
518
+ )
519
+
520
+ ambiguous_bag = by_name["Coffee identity does not choose a physical Bag"]
521
+ assert ambiguous_bag["expected_payload"] is None
522
+ assert all(
523
+ "brews create" not in command for command in ambiguous_bag["expected_commands"]
524
+ )
525
+
526
+ coffee = by_name["Coffee product name and attributes stay separate"]
527
+ assert coffee["expected_payload"]["name"] == "Worka Sakaro"
528
+ assert coffee["expected_payload"]["producer_farm"] == "Worka"
529
+
530
+ equipment = by_name["Equipment metadata update retains identity"]
531
+ assert equipment["expected_payload"] == {"notes": "Travel grinder"}
532
+ assert equipment["expected_commands"][1].startswith(
533
+ "brewsorted equipment update alex/7"
534
+ )