aethis-cli 0.44.0__tar.gz → 0.46.0__tar.gz

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 (115) hide show
  1. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/PKG-INFO +1 -1
  2. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/aethis_cli/_version.py +1 -1
  3. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/aethis_cli/client.py +6 -1
  4. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/aethis_cli/commands/generate_cmd.py +7 -1
  5. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/aethis_cli/commands/publish_cmd.py +10 -0
  6. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/aethis_cli/config.py +12 -0
  7. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/aethis_cli.egg-info/PKG-INFO +1 -1
  8. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/aethis_cli.egg-info/SOURCES.txt +2 -0
  9. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/pyproject.toml +1 -1
  10. aethis_cli-0.46.0/tests/test_field_dependency_and_identity_transport.py +229 -0
  11. aethis_cli-0.46.0/tests/test_publish_display_name.py +77 -0
  12. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_source_safeguards.py +3 -1
  13. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/LICENSE +0 -0
  14. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/README.md +0 -0
  15. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/aethis_cli/__init__.py +0 -0
  16. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/aethis_cli/__main__.py +0 -0
  17. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/aethis_cli/_terminal_safe.py +0 -0
  18. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/aethis_cli/auth.py +0 -0
  19. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/aethis_cli/auth_helpers.py +0 -0
  20. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/aethis_cli/auth_providers.py +0 -0
  21. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/aethis_cli/commands/__init__.py +0 -0
  22. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/aethis_cli/commands/_id_utils.py +0 -0
  23. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/aethis_cli/commands/account_cmd.py +0 -0
  24. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/aethis_cli/commands/cancel_cmd.py +0 -0
  25. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/aethis_cli/commands/decide_cmd.py +0 -0
  26. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/aethis_cli/commands/explain_cmd.py +0 -0
  27. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/aethis_cli/commands/fields_cmd.py +0 -0
  28. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/aethis_cli/commands/guidance_cmd.py +0 -0
  29. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/aethis_cli/commands/init_cmd.py +0 -0
  30. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/aethis_cli/commands/login_cmd.py +0 -0
  31. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/aethis_cli/commands/mcp_cmd.py +0 -0
  32. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/aethis_cli/commands/profile_cmd.py +0 -0
  33. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/aethis_cli/commands/projects_cmd.py +0 -0
  34. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/aethis_cli/commands/refine_cmd.py +0 -0
  35. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/aethis_cli/commands/review_cmd.py +0 -0
  36. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/aethis_cli/commands/rulebooks_cmd.py +0 -0
  37. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/aethis_cli/commands/rulesets_cmd.py +0 -0
  38. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/aethis_cli/commands/status_cmd.py +0 -0
  39. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/aethis_cli/commands/test_cmd.py +0 -0
  40. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/aethis_cli/commands/update_cmd.py +0 -0
  41. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/aethis_cli/commands/usage_cmd.py +0 -0
  42. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/aethis_cli/commands/whoami_cmd.py +0 -0
  43. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/aethis_cli/contract.py +0 -0
  44. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/aethis_cli/decision_view.py +0 -0
  45. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/aethis_cli/errors.py +0 -0
  46. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/aethis_cli/generation_status.py +0 -0
  47. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/aethis_cli/main.py +0 -0
  48. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/aethis_cli/output.py +0 -0
  49. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/aethis_cli/prompts.py +0 -0
  50. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/aethis_cli/py.typed +0 -0
  51. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/aethis_cli/render.py +0 -0
  52. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/aethis_cli/source_safeguards.py +0 -0
  53. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/aethis_cli/source_targets.py +0 -0
  54. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/aethis_cli/update_check.py +0 -0
  55. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/aethis_cli.egg-info/dependency_links.txt +0 -0
  56. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/aethis_cli.egg-info/entry_points.txt +0 -0
  57. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/aethis_cli.egg-info/requires.txt +0 -0
  58. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/aethis_cli.egg-info/top_level.txt +0 -0
  59. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/setup.cfg +0 -0
  60. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_acceptance_contract.py +0 -0
  61. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_account_cmd.py +0 -0
  62. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_auth.py +0 -0
  63. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_auth_providers.py +0 -0
  64. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_cancel_cmd.py +0 -0
  65. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_capability_boundary.py +0 -0
  66. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_client.py +0 -0
  67. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_config.py +0 -0
  68. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_contract_decide.py +0 -0
  69. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_contract_identity_and_sources.py +0 -0
  70. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_contract_request_surface.py +0 -0
  71. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_contract_rulebook_decide.py +0 -0
  72. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_credential_server.py +0 -0
  73. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_credential_url_parser.py +0 -0
  74. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_decide_cmd.py +0 -0
  75. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_documented_commands_run.py +0 -0
  76. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_empty_input_guards.py +0 -0
  77. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_explain_cmd.py +0 -0
  78. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_field_behaviour_metadata_transport.py +0 -0
  79. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_field_display_metadata_transport.py +0 -0
  80. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_field_notes_validation.py +0 -0
  81. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_fields_cmd.py +0 -0
  82. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_generate_failure_reporting.py +0 -0
  83. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_generate_fields.py +0 -0
  84. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_generate_no_publish.py +0 -0
  85. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_generate_replace_tests.py +0 -0
  86. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_generation_models.py +0 -0
  87. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_generation_status.py +0 -0
  88. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_guidance_cli.py +0 -0
  89. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_id_utils.py +0 -0
  90. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_init.py +0 -0
  91. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_json_projection_pinning.py +0 -0
  92. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_lazy_auth.py +0 -0
  93. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_login_headless.py +0 -0
  94. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_main.py +0 -0
  95. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_mcp_cmd.py +0 -0
  96. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_output.py +0 -0
  97. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_profiles.py +0 -0
  98. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_project_file_trust.py +0 -0
  99. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_prompts.py +0 -0
  100. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_publish_force.py +0 -0
  101. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_publish_rulebook_flags.py +0 -0
  102. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_publish_source_targets.py +0 -0
  103. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_release_tooling.py +0 -0
  104. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_render.py +0 -0
  105. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_review_cmd.py +0 -0
  106. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_rulebooks_cmd.py +0 -0
  107. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_rulesets_b1b_lifecycle.py +0 -0
  108. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_spacecraft_example_pin.py +0 -0
  109. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_status_cmd.py +0 -0
  110. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_transport_error_rendering.py +0 -0
  111. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_update_check.py +0 -0
  112. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_update_cmd.py +0 -0
  113. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_usage.py +0 -0
  114. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_value_space_transport.py +0 -0
  115. {aethis_cli-0.44.0 → aethis_cli-0.46.0}/tests/test_whoami_cmd.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aethis-cli
3
- Version: 0.44.0
3
+ Version: 0.46.0
4
4
  Summary: CLI for the Aethis developer API — author, test, and publish rulesets
5
5
  Author-email: Aethis <eng@aethis.ai>
6
6
  License-Expression: MIT
@@ -1,3 +1,3 @@
1
1
  """Version info — updated per release."""
2
2
 
3
- __version__ = "0.44.0"
3
+ __version__ = "0.46.0"
@@ -422,7 +422,7 @@ class AethisClient:
422
422
  """Pin the project's expected field vocabulary (key + type + enum values).
423
423
 
424
424
  Each entry is ``{key, sort, enum_values?, value_space?, enum_labels?,
425
- canonical_field?}``. This constrains generation
425
+ canonical_field?, options_by?, ...}``. This constrains generation
426
426
  to the declared field keys so the same field (e.g. date of birth) is not
427
427
  re-invented under a different key. Field hints / questions are carried as
428
428
  guidance, not here — this endpoint only fixes the vocabulary.
@@ -550,10 +550,15 @@ class AethisClient:
550
550
  rulebook_id: str | None = None,
551
551
  ruleset_name: str | None = None,
552
552
  source_targets: dict[str, dict] | None = None,
553
+ name: str | None = None,
553
554
  ) -> dict:
554
555
  body: dict = {}
555
556
  if slug is not None:
556
557
  body["slug"] = slug
558
+ # Human-readable ruleset name. Omitted unless given, so the request is
559
+ # unchanged for callers that do not set it.
560
+ if name is not None:
561
+ body["name"] = name
557
562
  if force_unsafe:
558
563
  # Tell the server-side TDD gate (aethis-core 0.11+) to refuse a
559
564
  # publish when stored test cases fail; force_unsafe=True records
@@ -676,6 +676,7 @@ _FIELD_KEY_ORDER = (
676
676
  "value_space",
677
677
  "enum_labels",
678
678
  "canonical_field",
679
+ "options_by",
679
680
  "weight",
680
681
  "elicitation_owner",
681
682
  "injection_source",
@@ -692,6 +693,9 @@ _FIELD_KEY_ORDER = (
692
693
  _ENGINE_GATED_FIELD_KEYS = (
693
694
  "enum_labels",
694
695
  "canonical_field",
696
+ # ``{field, map}``: narrows this enum field's suggested options by the
697
+ # answer to an earlier field. Opaque to the CLI; the engine validates it.
698
+ "options_by",
695
699
  "label",
696
700
  "question",
697
701
  "weight",
@@ -707,7 +711,9 @@ _ENGINE_GATED_FIELD_KEYS = (
707
711
  # capability gate scoped to properties that RulebookFieldSpec actually carries;
708
712
  # otherwise a project-only property in a shared authoring file would make the
709
713
  # rulebook command refuse an engine that is fully compatible with that route.
710
- _RULEBOOK_GATED_FIELD_KEYS = ("enum_labels", "canonical_field")
714
+ # ``input_role`` and ``identity_binding`` are rulebook vocabulary properties
715
+ # only: a project pin does not carry them, so they are not in the pin set.
716
+ _RULEBOOK_GATED_FIELD_KEYS = ("enum_labels", "canonical_field", "input_role", "identity_binding")
711
717
 
712
718
 
713
719
  def _normalise_field_type(t: Optional[str]) -> str:
@@ -125,6 +125,15 @@ def publish(
125
125
  "namespace is reserved for official rulesets."
126
126
  ),
127
127
  ),
128
+ name: Optional[str] = typer.Option(
129
+ None,
130
+ "--name",
131
+ help=(
132
+ "Human-readable name for this ruleset, shown to end users in "
133
+ "rulebook responses. Overrides an optional 'display_name:' key in "
134
+ "aethis.yaml. When neither is set the engine keeps its default name."
135
+ ),
136
+ ),
128
137
  rulebook: Optional[str] = typer.Option(
129
138
  None,
130
139
  "--rulebook",
@@ -259,6 +268,7 @@ def publish(
259
268
  rulebook_id=rulebook,
260
269
  ruleset_name=ruleset_name,
261
270
  source_targets=wire_targets or None,
271
+ name=name if name is not None else cfg.display_name,
262
272
  )
263
273
  except AethisAPIError as e:
264
274
  error_panel(e)
@@ -64,6 +64,7 @@ class ProjectConfig:
64
64
  config_path: Path = field(default_factory=lambda: Path.cwd())
65
65
  deepseek_key_env: str = "DEEPSEEK_API_KEY"
66
66
  project_base_url: Optional[str] = None # the project file's own value, exactly as written
67
+ display_name: Optional[str] = None # optional human-readable ruleset name, sent on publish
67
68
 
68
69
 
69
70
  def resolve_base_url_with_source() -> tuple[str, str]:
@@ -510,9 +511,20 @@ def load_project_config(path: Optional[Path] = None) -> ProjectConfig:
510
511
  project_id=project_id,
511
512
  config_path=project_dir,
512
513
  project_base_url=project_url,
514
+ display_name=_display_name_value(raw, yaml_path),
513
515
  )
514
516
 
515
517
 
518
+ def _display_name_value(raw: dict, yaml_path: Path) -> Optional[str]:
519
+ """The optional ``display_name`` key: a non-empty string, or absent."""
520
+ value = raw.get("display_name")
521
+ if value is None:
522
+ return None
523
+ if not isinstance(value, str) or not value.strip():
524
+ raise ConfigError(f"'display_name' in {yaml_path} must be a non-empty string.")
525
+ return value.strip()
526
+
527
+
516
528
  _ENV_REFUSED = (
517
529
  "{where} names a non-default key variable that you have not designated, so it was not read. Environment "
518
530
  "variables are read as keys only if you name them yourself: set {setting} to the variable name in your own "
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aethis-cli
3
- Version: 0.44.0
3
+ Version: 0.46.0
4
4
  Summary: CLI for the Aethis developer API — author, test, and publish rulesets
5
5
  Author-email: Aethis <eng@aethis.ai>
6
6
  License-Expression: MIT
@@ -71,6 +71,7 @@ tests/test_documented_commands_run.py
71
71
  tests/test_empty_input_guards.py
72
72
  tests/test_explain_cmd.py
73
73
  tests/test_field_behaviour_metadata_transport.py
74
+ tests/test_field_dependency_and_identity_transport.py
74
75
  tests/test_field_display_metadata_transport.py
75
76
  tests/test_field_notes_validation.py
76
77
  tests/test_fields_cmd.py
@@ -92,6 +93,7 @@ tests/test_output.py
92
93
  tests/test_profiles.py
93
94
  tests/test_project_file_trust.py
94
95
  tests/test_prompts.py
96
+ tests/test_publish_display_name.py
95
97
  tests/test_publish_force.py
96
98
  tests/test_publish_rulebook_flags.py
97
99
  tests/test_publish_source_targets.py
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "aethis-cli"
3
- version = "0.44.0"
3
+ version = "0.46.0"
4
4
  description = "CLI for the Aethis developer API — author, test, and publish rulesets"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
@@ -0,0 +1,229 @@
1
+ """Authored ``options_by``, ``input_role`` and ``identity_binding`` reach the engine.
2
+
3
+ ``options_by`` is a project field-pin property (``ExpectedFieldSpec``): it rides
4
+ ``aethis generate`` exactly as ``enum_labels`` does. ``input_role`` and
5
+ ``identity_binding`` are rulebook vocabulary properties (``RulebookFieldSpec``):
6
+ ``aethis rulebooks set-fields`` posts them as authored. On both paths an engine
7
+ that does not model the property would accept the upload and drop it, so the
8
+ push is refused first.
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ from unittest.mock import MagicMock
14
+
15
+ import pytest
16
+ import typer
17
+ import yaml
18
+
19
+ from aethis_cli.commands import generate_cmd, rulebooks_cmd
20
+
21
+ PIN_BASE = {"key", "sort", "enum_values", "value_space", "enum_labels", "canonical_field"}
22
+ PIN_WITH_OPTIONS_BY = PIN_BASE | {"options_by"}
23
+
24
+ RULEBOOK_BASE = {"key", "sort", "enum_values", "enum_labels", "canonical_field"}
25
+ RULEBOOK_WITH_IDENTITY = RULEBOOK_BASE | {"input_role", "identity_binding"}
26
+
27
+ OPTIONS_BY = {
28
+ "field": "vehicle.make",
29
+ "map": {"ford": ["focus", "fiesta"], "tesla": ["model_3", "model_y"]},
30
+ }
31
+
32
+ DEPENDENT_FIELDS = """\
33
+ fields:
34
+ - key: vehicle.make
35
+ type: enum
36
+ enum_values: [ford, tesla]
37
+ - key: vehicle.model
38
+ type: enum
39
+ enum_values: [focus, fiesta, model_3, model_y]
40
+ options_by:
41
+ field: vehicle.make
42
+ map:
43
+ ford: [focus, fiesta]
44
+ tesla: [model_3, model_y]
45
+ """
46
+
47
+ PLAIN_FIELDS = """\
48
+ fields:
49
+ - key: vehicle.make
50
+ type: enum
51
+ enum_values: [ford, tesla]
52
+ - key: vehicle.model
53
+ type: enum
54
+ enum_values: [focus, fiesta, model_3, model_y]
55
+ """
56
+
57
+ IDENTITY_FIELDS = [
58
+ {"key": "owner.age", "sort": "Int"},
59
+ {
60
+ "key": "owner.given_names",
61
+ "sort": "String",
62
+ "input_role": "factual",
63
+ "identity_binding": {"subject": "application_subject", "component": "given_names"},
64
+ },
65
+ ]
66
+
67
+
68
+ def _project(tmp_path, body: str):
69
+ path = tmp_path / "fields" / "fields.yaml"
70
+ path.parent.mkdir(parents=True)
71
+ path.write_text(body)
72
+ return tmp_path
73
+
74
+
75
+ def _pin_client(properties) -> MagicMock:
76
+ client = MagicMock()
77
+ client.expected_field_spec_properties.return_value = properties
78
+ client.rulebook_field_spec_properties.return_value = RULEBOOK_WITH_IDENTITY
79
+ client.base_url = "https://engine.example"
80
+ return client
81
+
82
+
83
+ def _rulebook_client(properties) -> MagicMock:
84
+ client = MagicMock()
85
+ client.rulebook_field_spec_properties.return_value = properties
86
+ client.expected_field_spec_properties.return_value = PIN_WITH_OPTIONS_BY
87
+ client.base_url = "https://engine.example"
88
+ client.set_rulebook_fields.return_value = {"fields": IDENTITY_FIELDS, "field_lock_state": "unlocked"}
89
+ return client
90
+
91
+
92
+ def _pushed(client) -> list[dict]:
93
+ _, expected_fields = client.set_field_spec.call_args.args
94
+ return expected_fields
95
+
96
+
97
+ # --- options_by on the generation pin ---------------------------------------
98
+
99
+
100
+ def test_options_by_is_projected_onto_the_pin(tmp_path):
101
+ client = _pin_client(PIN_WITH_OPTIONS_BY)
102
+
103
+ generate_cmd._upload_field_vocabulary(client, "proj_1", _project(tmp_path, DEPENDENT_FIELDS))
104
+
105
+ assert _pushed(client) == [
106
+ {"key": "vehicle.make", "sort": "enum", "enum_values": ["ford", "tesla"]},
107
+ {
108
+ "key": "vehicle.model",
109
+ "sort": "enum",
110
+ "enum_values": ["focus", "fiesta", "model_3", "model_y"],
111
+ "options_by": OPTIONS_BY,
112
+ },
113
+ ]
114
+
115
+
116
+ def test_options_by_against_an_engine_without_it_is_refused_before_the_push(tmp_path, capsys):
117
+ client = _pin_client(PIN_BASE)
118
+
119
+ with pytest.raises(typer.Exit):
120
+ generate_cmd._upload_field_vocabulary(client, "proj_1", _project(tmp_path, DEPENDENT_FIELDS))
121
+
122
+ client.set_field_spec.assert_not_called()
123
+ client.add_guidance.assert_not_called()
124
+ assert "options_by" in " ".join(capsys.readouterr().out.split())
125
+
126
+
127
+ def test_absent_options_by_leaves_the_pin_unchanged_and_never_probes(tmp_path):
128
+ client = _pin_client(PIN_BASE)
129
+
130
+ generate_cmd._upload_field_vocabulary(client, "proj_1", _project(tmp_path, PLAIN_FIELDS))
131
+
132
+ assert _pushed(client) == [
133
+ {"key": "vehicle.make", "sort": "enum", "enum_values": ["ford", "tesla"]},
134
+ {"key": "vehicle.model", "sort": "enum", "enum_values": ["focus", "fiesta", "model_3", "model_y"]},
135
+ ]
136
+ client.expected_field_spec_properties.assert_not_called()
137
+
138
+
139
+ @pytest.mark.parametrize("value", [OPTIONS_BY, {}, None])
140
+ def test_options_by_is_written_back_by_presence_next_to_the_display_metadata(value):
141
+ """An explicit empty or null declaration is kept, as for enum_labels, and
142
+ the key is written in its place rather than after the unknown keys."""
143
+ field = {
144
+ "key": "vehicle.model",
145
+ "type": "enum",
146
+ "enum_values": ["focus"],
147
+ "canonical_field": "car.model",
148
+ "options_by": value,
149
+ "weight": 2,
150
+ }
151
+
152
+ out = generate_cmd._field_to_yaml_dict(field)
153
+
154
+ assert out["options_by"] == value
155
+ keys = list(out)
156
+ assert keys[keys.index("canonical_field") + 1] == "options_by"
157
+
158
+
159
+ def test_rulebook_identity_keys_are_not_projected_onto_the_pin(tmp_path):
160
+ """input_role / identity_binding live on the rulebook model; the project pin
161
+ does not carry them, so they neither ride the pin nor gate it."""
162
+ client = _pin_client(PIN_BASE)
163
+ project = _project(
164
+ tmp_path,
165
+ """\
166
+ fields:
167
+ - key: owner.given_names
168
+ type: string
169
+ input_role: factual
170
+ identity_binding: {subject: application_subject, component: given_names}
171
+ """,
172
+ )
173
+
174
+ generate_cmd._upload_field_vocabulary(client, "proj_1", project)
175
+
176
+ assert _pushed(client) == [{"key": "owner.given_names", "sort": "string"}]
177
+ client.expected_field_spec_properties.assert_not_called()
178
+
179
+
180
+ # --- input_role / identity_binding on rulebooks set-fields -------------------
181
+
182
+
183
+ @pytest.mark.parametrize("missing", ["input_role", "identity_binding"])
184
+ def test_set_fields_refuses_an_engine_missing_an_identity_key(missing, tmp_path, monkeypatch, capsys):
185
+ client = _rulebook_client(RULEBOOK_WITH_IDENTITY - {missing})
186
+ monkeypatch.setattr(rulebooks_cmd, "load_client_or_fallback", lambda: (None, client))
187
+ path = tmp_path / "fields.yaml"
188
+ path.write_text(yaml.safe_dump({"fields": IDENTITY_FIELDS}))
189
+
190
+ with pytest.raises(typer.Exit):
191
+ rulebooks_cmd.set_fields("rb_1", path)
192
+
193
+ client.set_rulebook_fields.assert_not_called()
194
+ assert f"does not carry {missing}" in " ".join(capsys.readouterr().out.split())
195
+
196
+
197
+ def test_set_fields_posts_identity_keys_as_authored(tmp_path, monkeypatch):
198
+ client = _rulebook_client(RULEBOOK_WITH_IDENTITY)
199
+ monkeypatch.setattr(rulebooks_cmd, "load_client_or_fallback", lambda: (None, client))
200
+ path = tmp_path / "fields.yaml"
201
+ path.write_text(yaml.safe_dump({"fields": IDENTITY_FIELDS}))
202
+
203
+ rulebooks_cmd.set_fields("rb_1", path)
204
+
205
+ client.set_rulebook_fields.assert_called_once_with("rb_1", IDENTITY_FIELDS)
206
+
207
+
208
+ def test_set_fields_without_identity_keys_never_probes(tmp_path, monkeypatch):
209
+ client = _rulebook_client(RULEBOOK_BASE)
210
+ monkeypatch.setattr(rulebooks_cmd, "load_client_or_fallback", lambda: (None, client))
211
+ plain = [{"key": "owner.age", "sort": "Int"}]
212
+ path = tmp_path / "fields.yaml"
213
+ path.write_text(yaml.safe_dump({"fields": plain}))
214
+
215
+ rulebooks_cmd.set_fields("rb_1", path)
216
+
217
+ client.set_rulebook_fields.assert_called_once_with("rb_1", plain)
218
+ client.rulebook_field_spec_properties.assert_not_called()
219
+
220
+
221
+ def test_set_fields_does_not_gate_on_the_project_only_options_by():
222
+ """options_by is a pin property; a shared authoring file carrying it must
223
+ not make the rulebook command refuse an engine compatible with that route."""
224
+ client = _rulebook_client(RULEBOOK_BASE)
225
+ fields = [{"key": "vehicle.model", "sort": "Enum", "enum_values": ["focus"], "options_by": OPTIONS_BY}]
226
+
227
+ generate_cmd.check_display_metadata_support(client, fields, rulebook=True)
228
+
229
+ client.rulebook_field_spec_properties.assert_not_called()
@@ -0,0 +1,77 @@
1
+ """`aethis publish --name` and the optional `display_name:` key in aethis.yaml.
2
+
3
+ Both set the human-readable ruleset name sent on publish. Absent => the
4
+ request is byte-identical to before.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ from unittest.mock import MagicMock, patch
10
+
11
+ from typer.testing import CliRunner
12
+
13
+
14
+ def _invoke(args):
15
+ from aethis_cli.main import app
16
+
17
+ return CliRunner().invoke(app, args, catch_exceptions=False, env={})
18
+
19
+
20
+ def _project(tmp_path, extra=""):
21
+ (tmp_path / "aethis.yaml").write_text("project: test-project\napi_key_env: AETHIS_API_KEY\n" + extra)
22
+ (tmp_path / ".aethis").mkdir()
23
+ (tmp_path / ".aethis" / "state.json").write_text('{"project_id": "proj_test"}')
24
+
25
+
26
+ def _run(tmp_path, monkeypatch, args, extra=""):
27
+ monkeypatch.chdir(tmp_path)
28
+ monkeypatch.setenv("AETHIS_API_KEY", "ak_test")
29
+ _project(tmp_path, extra)
30
+ client = MagicMock()
31
+ client.run_tests.return_value = {"passed": 1, "failed": 0, "errors": 0, "total": 1}
32
+ client.publish.return_value = {"ruleset_id": "rs_x"}
33
+ with patch("aethis_cli.client.AethisClient", return_value=client):
34
+ result = _invoke(["publish", *args])
35
+ assert result.exit_code == 0, result.output
36
+ return client.publish.call_args.kwargs
37
+
38
+
39
+ def test_name_flag_is_sent(tmp_path, monkeypatch):
40
+ assert _run(tmp_path, monkeypatch, ["--name", "Life in the UK"])["name"] == "Life in the UK"
41
+
42
+
43
+ def test_display_name_key_is_sent(tmp_path, monkeypatch):
44
+ kw = _run(tmp_path, monkeypatch, [], extra="display_name: English language\n")
45
+ assert kw["name"] == "English language"
46
+
47
+
48
+ def test_flag_overrides_yaml(tmp_path, monkeypatch):
49
+ kw = _run(tmp_path, monkeypatch, ["--name", "Flag"], extra="display_name: Yaml\n")
50
+ assert kw["name"] == "Flag"
51
+
52
+
53
+ def test_absent_means_no_name(tmp_path, monkeypatch):
54
+ assert _run(tmp_path, monkeypatch, [])["name"] is None
55
+
56
+
57
+ def _body(**kw):
58
+ from aethis_cli.client import AethisClient
59
+
60
+ captured: dict = {}
61
+
62
+ class _Stub(AethisClient):
63
+ def _request(self, method, path, **k):
64
+ captured["kwargs"] = k
65
+ return {}
66
+
67
+ _Stub(base_url="http://test.invalid", api_key="ak_test").publish("proj_x", **kw)
68
+ return captured["kwargs"]
69
+
70
+
71
+ def test_client_sends_name_in_body():
72
+ assert _body(name="Personal information")["json"] == {"name": "Personal information"}
73
+
74
+
75
+ def test_client_body_unchanged_without_name():
76
+ assert "json" not in _body()
77
+ assert _body(slug="a/b")["json"] == {"slug": "a/b"}
@@ -178,7 +178,9 @@ def test_warning_text_is_never_parsed_as_markup(capsys):
178
178
 
179
179
 
180
180
  def _publish(publish_response: dict) -> str:
181
- cfg = SimpleNamespace(base_url="http://engine.test", project_id="proj_test", config_path="/tmp/.aethis")
181
+ cfg = SimpleNamespace(
182
+ base_url="http://engine.test", project_id="proj_test", config_path="/tmp/.aethis", display_name=None
183
+ )
182
184
  client = MagicMock()
183
185
  client.run_tests.return_value = {"passed": 1, "total": 1, "failed": 0, "errors": 0, "results": []}
184
186
  client.publish.return_value = publish_response
File without changes
File without changes
File without changes