aethis-cli 0.44.0__tar.gz → 0.45.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 (114) hide show
  1. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/PKG-INFO +1 -1
  2. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/aethis_cli/_version.py +1 -1
  3. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/aethis_cli/client.py +1 -1
  4. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/aethis_cli/commands/generate_cmd.py +7 -1
  5. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/aethis_cli.egg-info/PKG-INFO +1 -1
  6. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/aethis_cli.egg-info/SOURCES.txt +1 -0
  7. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/pyproject.toml +1 -1
  8. aethis_cli-0.45.0/tests/test_field_dependency_and_identity_transport.py +229 -0
  9. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/LICENSE +0 -0
  10. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/README.md +0 -0
  11. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/aethis_cli/__init__.py +0 -0
  12. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/aethis_cli/__main__.py +0 -0
  13. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/aethis_cli/_terminal_safe.py +0 -0
  14. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/aethis_cli/auth.py +0 -0
  15. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/aethis_cli/auth_helpers.py +0 -0
  16. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/aethis_cli/auth_providers.py +0 -0
  17. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/aethis_cli/commands/__init__.py +0 -0
  18. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/aethis_cli/commands/_id_utils.py +0 -0
  19. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/aethis_cli/commands/account_cmd.py +0 -0
  20. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/aethis_cli/commands/cancel_cmd.py +0 -0
  21. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/aethis_cli/commands/decide_cmd.py +0 -0
  22. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/aethis_cli/commands/explain_cmd.py +0 -0
  23. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/aethis_cli/commands/fields_cmd.py +0 -0
  24. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/aethis_cli/commands/guidance_cmd.py +0 -0
  25. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/aethis_cli/commands/init_cmd.py +0 -0
  26. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/aethis_cli/commands/login_cmd.py +0 -0
  27. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/aethis_cli/commands/mcp_cmd.py +0 -0
  28. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/aethis_cli/commands/profile_cmd.py +0 -0
  29. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/aethis_cli/commands/projects_cmd.py +0 -0
  30. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/aethis_cli/commands/publish_cmd.py +0 -0
  31. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/aethis_cli/commands/refine_cmd.py +0 -0
  32. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/aethis_cli/commands/review_cmd.py +0 -0
  33. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/aethis_cli/commands/rulebooks_cmd.py +0 -0
  34. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/aethis_cli/commands/rulesets_cmd.py +0 -0
  35. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/aethis_cli/commands/status_cmd.py +0 -0
  36. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/aethis_cli/commands/test_cmd.py +0 -0
  37. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/aethis_cli/commands/update_cmd.py +0 -0
  38. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/aethis_cli/commands/usage_cmd.py +0 -0
  39. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/aethis_cli/commands/whoami_cmd.py +0 -0
  40. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/aethis_cli/config.py +0 -0
  41. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/aethis_cli/contract.py +0 -0
  42. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/aethis_cli/decision_view.py +0 -0
  43. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/aethis_cli/errors.py +0 -0
  44. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/aethis_cli/generation_status.py +0 -0
  45. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/aethis_cli/main.py +0 -0
  46. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/aethis_cli/output.py +0 -0
  47. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/aethis_cli/prompts.py +0 -0
  48. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/aethis_cli/py.typed +0 -0
  49. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/aethis_cli/render.py +0 -0
  50. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/aethis_cli/source_safeguards.py +0 -0
  51. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/aethis_cli/source_targets.py +0 -0
  52. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/aethis_cli/update_check.py +0 -0
  53. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/aethis_cli.egg-info/dependency_links.txt +0 -0
  54. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/aethis_cli.egg-info/entry_points.txt +0 -0
  55. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/aethis_cli.egg-info/requires.txt +0 -0
  56. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/aethis_cli.egg-info/top_level.txt +0 -0
  57. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/setup.cfg +0 -0
  58. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_acceptance_contract.py +0 -0
  59. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_account_cmd.py +0 -0
  60. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_auth.py +0 -0
  61. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_auth_providers.py +0 -0
  62. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_cancel_cmd.py +0 -0
  63. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_capability_boundary.py +0 -0
  64. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_client.py +0 -0
  65. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_config.py +0 -0
  66. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_contract_decide.py +0 -0
  67. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_contract_identity_and_sources.py +0 -0
  68. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_contract_request_surface.py +0 -0
  69. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_contract_rulebook_decide.py +0 -0
  70. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_credential_server.py +0 -0
  71. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_credential_url_parser.py +0 -0
  72. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_decide_cmd.py +0 -0
  73. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_documented_commands_run.py +0 -0
  74. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_empty_input_guards.py +0 -0
  75. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_explain_cmd.py +0 -0
  76. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_field_behaviour_metadata_transport.py +0 -0
  77. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_field_display_metadata_transport.py +0 -0
  78. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_field_notes_validation.py +0 -0
  79. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_fields_cmd.py +0 -0
  80. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_generate_failure_reporting.py +0 -0
  81. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_generate_fields.py +0 -0
  82. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_generate_no_publish.py +0 -0
  83. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_generate_replace_tests.py +0 -0
  84. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_generation_models.py +0 -0
  85. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_generation_status.py +0 -0
  86. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_guidance_cli.py +0 -0
  87. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_id_utils.py +0 -0
  88. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_init.py +0 -0
  89. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_json_projection_pinning.py +0 -0
  90. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_lazy_auth.py +0 -0
  91. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_login_headless.py +0 -0
  92. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_main.py +0 -0
  93. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_mcp_cmd.py +0 -0
  94. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_output.py +0 -0
  95. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_profiles.py +0 -0
  96. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_project_file_trust.py +0 -0
  97. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_prompts.py +0 -0
  98. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_publish_force.py +0 -0
  99. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_publish_rulebook_flags.py +0 -0
  100. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_publish_source_targets.py +0 -0
  101. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_release_tooling.py +0 -0
  102. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_render.py +0 -0
  103. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_review_cmd.py +0 -0
  104. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_rulebooks_cmd.py +0 -0
  105. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_rulesets_b1b_lifecycle.py +0 -0
  106. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_source_safeguards.py +0 -0
  107. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_spacecraft_example_pin.py +0 -0
  108. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_status_cmd.py +0 -0
  109. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_transport_error_rendering.py +0 -0
  110. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_update_check.py +0 -0
  111. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_update_cmd.py +0 -0
  112. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_usage.py +0 -0
  113. {aethis_cli-0.44.0 → aethis_cli-0.45.0}/tests/test_value_space_transport.py +0 -0
  114. {aethis_cli-0.44.0 → aethis_cli-0.45.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.45.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.45.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.
@@ -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:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aethis-cli
3
- Version: 0.44.0
3
+ Version: 0.45.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
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "aethis-cli"
3
- version = "0.44.0"
3
+ version = "0.45.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()
File without changes
File without changes
File without changes