aethis-cli 0.53.0__tar.gz → 0.53.2__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.
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/PKG-INFO +1 -1
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/aethis_cli/_version.py +1 -1
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/aethis_cli/commands/generate_cmd.py +42 -7
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/aethis_cli.egg-info/PKG-INFO +1 -1
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/pyproject.toml +1 -1
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_generate_fields.py +128 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_release_tooling.py +115 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/LICENSE +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/README.md +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/aethis_cli/__init__.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/aethis_cli/__main__.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/aethis_cli/_terminal_safe.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/aethis_cli/auth.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/aethis_cli/auth_helpers.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/aethis_cli/auth_providers.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/aethis_cli/client.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/aethis_cli/commands/__init__.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/aethis_cli/commands/_id_utils.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/aethis_cli/commands/account_cmd.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/aethis_cli/commands/cancel_cmd.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/aethis_cli/commands/decide_cmd.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/aethis_cli/commands/explain_cmd.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/aethis_cli/commands/fields_cmd.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/aethis_cli/commands/guidance_cmd.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/aethis_cli/commands/init_cmd.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/aethis_cli/commands/login_cmd.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/aethis_cli/commands/mcp_cmd.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/aethis_cli/commands/profile_cmd.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/aethis_cli/commands/projects_cmd.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/aethis_cli/commands/publish_cmd.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/aethis_cli/commands/refine_cmd.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/aethis_cli/commands/review_cmd.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/aethis_cli/commands/rulebooks_cmd.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/aethis_cli/commands/rulesets_cmd.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/aethis_cli/commands/status_cmd.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/aethis_cli/commands/test_cmd.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/aethis_cli/commands/update_cmd.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/aethis_cli/commands/usage_cmd.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/aethis_cli/commands/whoami_cmd.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/aethis_cli/config.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/aethis_cli/contract.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/aethis_cli/decision_view.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/aethis_cli/errors.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/aethis_cli/generation_status.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/aethis_cli/main.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/aethis_cli/output.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/aethis_cli/prompts.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/aethis_cli/py.typed +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/aethis_cli/render.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/aethis_cli/source_safeguards.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/aethis_cli/source_targets.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/aethis_cli/update_check.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/aethis_cli.egg-info/SOURCES.txt +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/aethis_cli.egg-info/dependency_links.txt +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/aethis_cli.egg-info/entry_points.txt +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/aethis_cli.egg-info/requires.txt +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/aethis_cli.egg-info/top_level.txt +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/setup.cfg +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_acceptance_contract.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_account_cmd.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_auth.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_auth_providers.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_cancel_cmd.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_capability_boundary.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_client.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_collection_computed_prerequisite_transport.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_config.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_contract_decide.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_contract_identity_and_sources.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_contract_request_surface.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_contract_rulebook_decide.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_credential_server.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_credential_url_parser.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_decide_cmd.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_documented_commands_run.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_empty_input_guards.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_explain_cmd.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_fact_links_transport.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_field_behaviour_metadata_transport.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_field_dependency_and_identity_transport.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_field_display_metadata_transport.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_field_notes_validation.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_fields_cmd.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_generate_display_name.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_generate_failure_reporting.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_generate_no_publish.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_generate_replace_tests.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_generation_models.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_generation_status.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_guidance_cli.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_id_utils.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_init.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_json_projection_pinning.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_lazy_auth.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_login_headless.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_main.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_mcp_cmd.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_output.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_presence_default_basis_transport.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_profiles.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_project_file_trust.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_prompts.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_publish_display_name.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_publish_force.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_publish_rulebook_flags.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_publish_source_targets.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_render.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_review_cmd.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_rulebooks_cmd.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_rulesets_b1b_lifecycle.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_source_safeguards.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_spacecraft_example_pin.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_status_cmd.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_transport_error_rendering.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_update_check.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_update_cmd.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_usage.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_value_space_transport.py +0 -0
- {aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_whoami_cmd.py +0 -0
|
@@ -543,10 +543,18 @@ def _upload_sources(client: AethisClient, pid: str, project_dir: Path) -> Upload
|
|
|
543
543
|
}
|
|
544
544
|
replacements: list[tuple[Path, dict]] = []
|
|
545
545
|
ordinary: list[Path] = []
|
|
546
|
+
unknown: list[tuple[Path, dict]] = []
|
|
546
547
|
for path in to_upload:
|
|
547
548
|
active = active_by_filename.get(path.name)
|
|
548
549
|
digest = hashlib.sha256(path.read_bytes()).hexdigest()
|
|
549
|
-
if
|
|
550
|
+
if not active:
|
|
551
|
+
ordinary.append(path)
|
|
552
|
+
elif active.get("raw_sha256") is None:
|
|
553
|
+
# Uploaded before the engine recorded file digests, so whether the
|
|
554
|
+
# file changed is unknown. Upload it normally first so the engine
|
|
555
|
+
# can keep the same source id when it is the same file.
|
|
556
|
+
unknown.append((path, active))
|
|
557
|
+
elif active["raw_sha256"] != digest:
|
|
550
558
|
replacements.append((path, active))
|
|
551
559
|
else:
|
|
552
560
|
ordinary.append(path)
|
|
@@ -556,6 +564,21 @@ def _upload_sources(client: AethisClient, pid: str, project_dir: Path) -> Upload
|
|
|
556
564
|
counts = _upload_counts(client.upload_sources(pid, batch) or {})
|
|
557
565
|
summary = UploadSummary(new=summary.new + counts.new, reused=summary.reused + counts.reused)
|
|
558
566
|
|
|
567
|
+
# One at a time, so a refusal names exactly one file. Only the engine's
|
|
568
|
+
# "this name already holds different content" refusal means the file did
|
|
569
|
+
# change; that one goes through the replacement flow below.
|
|
570
|
+
for path, prior in unknown:
|
|
571
|
+
try:
|
|
572
|
+
response = client.upload_sources(pid, [path]) or {}
|
|
573
|
+
except AethisAPIError as exc:
|
|
574
|
+
detail = exc.detail if isinstance(exc.detail, Mapping) else {}
|
|
575
|
+
if exc.status_code == 409 and detail.get("reason_code") == "active_filename_has_changed_content":
|
|
576
|
+
replacements.append((path, prior))
|
|
577
|
+
continue
|
|
578
|
+
raise
|
|
579
|
+
counts = _upload_counts(response)
|
|
580
|
+
summary = UploadSummary(new=summary.new + counts.new, reused=summary.reused + counts.reused)
|
|
581
|
+
|
|
559
582
|
for path, prior in replacements:
|
|
560
583
|
prior_id = prior.get("source_id")
|
|
561
584
|
if not isinstance(prior_id, str) or not prior_id:
|
|
@@ -778,7 +801,7 @@ def _safe_field_type(raw_type: Optional[str], enum_values: Optional[list]) -> st
|
|
|
778
801
|
return t
|
|
779
802
|
|
|
780
803
|
|
|
781
|
-
def validate_fields_list(fields: list) -> list[str]:
|
|
804
|
+
def validate_fields_list(fields: list, items_required_for: Optional[set] = None) -> list[str]:
|
|
782
805
|
"""Return human-readable validation errors for a ``fields.yaml`` field list.
|
|
783
806
|
|
|
784
807
|
Checks: every entry has a key, no duplicate keys, the ``type`` is one of
|
|
@@ -789,6 +812,12 @@ def validate_fields_list(fields: list) -> list[str]:
|
|
|
789
812
|
the field does not have — a mislabelled key is silently inert on the
|
|
790
813
|
engine, so it is caught here. ``canonical_field`` must be a non-empty
|
|
791
814
|
string. An empty return means the list is valid.
|
|
815
|
+
|
|
816
|
+
``items_required_for`` limits the "a collection needs ``items``" check to
|
|
817
|
+
those keys. ``None`` (the default) checks every collection. A member
|
|
818
|
+
section passes its own keys when validating its rulebook's file: the
|
|
819
|
+
rulebook may hold collection rows whose items its release step fills in,
|
|
820
|
+
and a section never sends a rulebook-only row.
|
|
792
821
|
"""
|
|
793
822
|
errors: list[str] = []
|
|
794
823
|
seen: set[str] = set()
|
|
@@ -824,7 +853,8 @@ def validate_fields_list(fields: list) -> list[str]:
|
|
|
824
853
|
for prop in _ENGINE_SHAPED_FIELD_KEYS:
|
|
825
854
|
if prop in f and f[prop] is not None and not isinstance(f[prop], dict):
|
|
826
855
|
errors.append(f"Field {key!r} declares {prop} but it is not a mapping.")
|
|
827
|
-
|
|
856
|
+
items_checked = items_required_for is None or key in items_required_for
|
|
857
|
+
if ftype == "collection" and items_checked and not isinstance(f.get("items"), dict):
|
|
828
858
|
errors.append(f"Field {key!r} is type 'collection' but declares no items mapping.")
|
|
829
859
|
if f.get("items") is not None and ftype != "collection":
|
|
830
860
|
errors.append(f"Field {key!r} declares items but is type {ftype!r} — only collection fields may.")
|
|
@@ -1204,14 +1234,19 @@ def _validate_project_fields(project_dir: Path) -> None:
|
|
|
1204
1234
|
# each contributing file's RAW list so duplicate keys *within a file* surface
|
|
1205
1235
|
# — the merged map would silently collapse them. A key shared between the
|
|
1206
1236
|
# rulebook and the ruleset is intentional (rulebook wins), not a duplicate.
|
|
1237
|
+
# The rulebook's file is checked in full, except that a collection row the
|
|
1238
|
+
# section does not declare (so never sends) may leave ``items`` to the
|
|
1239
|
+
# rulebook's own release step.
|
|
1240
|
+
own_path = project_dir / "fields" / "fields.yaml"
|
|
1241
|
+
contributing: list[tuple[Path, Optional[set]]] = [(own_path, None)]
|
|
1207
1242
|
rb_dir = _parent_rulebook_dir(project_dir)
|
|
1208
|
-
contributing = [project_dir / "fields" / "fields.yaml"]
|
|
1209
1243
|
if rb_dir is not None:
|
|
1210
|
-
|
|
1211
|
-
|
|
1244
|
+
own_keys = set(_parse_fields_yaml(own_path)) if own_path.exists() else set()
|
|
1245
|
+
contributing.insert(0, (rb_dir / "fields" / "fields.yaml", own_keys))
|
|
1246
|
+
for path, items_required_for in contributing:
|
|
1212
1247
|
if not path.exists():
|
|
1213
1248
|
continue
|
|
1214
|
-
errors = validate_fields_list(_load_yaml_file(path).get("fields") or [])
|
|
1249
|
+
errors = validate_fields_list(_load_yaml_file(path).get("fields") or [], items_required_for=items_required_for)
|
|
1215
1250
|
if errors:
|
|
1216
1251
|
console.print(f"[red]{path} is invalid:[/red]")
|
|
1217
1252
|
for e in errors:
|
|
@@ -12,6 +12,7 @@ import typer
|
|
|
12
12
|
|
|
13
13
|
from aethis_cli.commands import generate_cmd
|
|
14
14
|
from aethis_cli.config import read_state, write_state
|
|
15
|
+
from aethis_cli.errors import AethisAPIError
|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
# --- helpers ---------------------------------------------------------------
|
|
@@ -323,6 +324,87 @@ def test_changed_source_is_superseded_then_linked_to_replacement(tmp_path):
|
|
|
323
324
|
]
|
|
324
325
|
|
|
325
326
|
|
|
327
|
+
@pytest.mark.parametrize("legacy_row", [{"raw_sha256": None}, {}], ids=["raw-none", "raw-absent"])
|
|
328
|
+
def test_active_source_without_raw_digest_is_uploaded_not_superseded(tmp_path, legacy_row):
|
|
329
|
+
# aethis-core#572: a source uploaded before the engine kept raw digests has
|
|
330
|
+
# no raw_sha256. That means "unknown", not "changed": upload it as normal so
|
|
331
|
+
# the engine can reuse the same source id, never supersede it first.
|
|
332
|
+
src = tmp_path / "sources"
|
|
333
|
+
src.mkdir()
|
|
334
|
+
(src / "law.md").write_text("same law")
|
|
335
|
+
client = MagicMock()
|
|
336
|
+
client.list_sources.return_value = {
|
|
337
|
+
"sources": [{"source_id": "src_july", "filename": "law.md", "status": "active", **legacy_row}]
|
|
338
|
+
}
|
|
339
|
+
client.upload_sources.return_value = {
|
|
340
|
+
"new": 0,
|
|
341
|
+
"reused": 1,
|
|
342
|
+
"sources": [{"source_id": "src_july", "filename": "law.md", "reused": True}],
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
summary = generate_cmd._upload_sources(client, "proj_1", tmp_path)
|
|
346
|
+
|
|
347
|
+
assert summary == generate_cmd.UploadSummary(new=0, reused=1)
|
|
348
|
+
client.update_source.assert_not_called()
|
|
349
|
+
assert client.upload_sources.call_count == 1
|
|
350
|
+
[(_, sent), _] = client.upload_sources.call_args
|
|
351
|
+
assert [p.name for p in sent] == ["law.md"]
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
def test_changed_source_without_raw_digest_falls_back_to_replacement(tmp_path):
|
|
355
|
+
# No recorded digest and the file really changed: the engine refuses the
|
|
356
|
+
# ordinary upload with 409, and the CLI then replaces the source as before.
|
|
357
|
+
src = tmp_path / "sources"
|
|
358
|
+
src.mkdir()
|
|
359
|
+
(src / "law.md").write_text("edited law")
|
|
360
|
+
client = MagicMock()
|
|
361
|
+
client.list_sources.return_value = {
|
|
362
|
+
"sources": [{"source_id": "src_july", "filename": "law.md", "status": "active", "raw_sha256": None}]
|
|
363
|
+
}
|
|
364
|
+
refusal = AethisAPIError(
|
|
365
|
+
409,
|
|
366
|
+
{"error": "conflict", "reason_code": "active_filename_has_changed_content", "source_id": "src_july"},
|
|
367
|
+
)
|
|
368
|
+
client.upload_sources.side_effect = [
|
|
369
|
+
refusal,
|
|
370
|
+
{"new": 1, "reused": 0, "sources": [{"source_id": "src_new", "filename": "law.md", "reused": False}]},
|
|
371
|
+
]
|
|
372
|
+
|
|
373
|
+
summary = generate_cmd._upload_sources(client, "proj_1", tmp_path)
|
|
374
|
+
|
|
375
|
+
assert summary == generate_cmd.UploadSummary(new=1, reused=0)
|
|
376
|
+
assert client.upload_sources.call_count == 2
|
|
377
|
+
assert client.update_source.call_args_list == [
|
|
378
|
+
(("proj_1", "src_july"), {"status": "superseded"}),
|
|
379
|
+
(("proj_1", "src_july"), {"status": "superseded", "superseded_by": "src_new"}),
|
|
380
|
+
]
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
@pytest.mark.parametrize(
|
|
384
|
+
"refusal",
|
|
385
|
+
[
|
|
386
|
+
AethisAPIError(409, {"reason_code": "source_reactivation_required"}),
|
|
387
|
+
AethisAPIError(500, {"reason_code": "active_filename_has_changed_content"}),
|
|
388
|
+
AethisAPIError(409, "plain text conflict"),
|
|
389
|
+
],
|
|
390
|
+
ids=["other-409", "not-409", "unstructured"],
|
|
391
|
+
)
|
|
392
|
+
def test_other_errors_on_digestless_upload_are_raised_without_superseding(tmp_path, refusal):
|
|
393
|
+
src = tmp_path / "sources"
|
|
394
|
+
src.mkdir()
|
|
395
|
+
(src / "law.md").write_text("law")
|
|
396
|
+
client = MagicMock()
|
|
397
|
+
client.list_sources.return_value = {
|
|
398
|
+
"sources": [{"source_id": "src_july", "filename": "law.md", "status": "active"}]
|
|
399
|
+
}
|
|
400
|
+
client.upload_sources.side_effect = refusal
|
|
401
|
+
|
|
402
|
+
with pytest.raises(AethisAPIError):
|
|
403
|
+
generate_cmd._upload_sources(client, "proj_1", tmp_path)
|
|
404
|
+
|
|
405
|
+
client.update_source.assert_not_called()
|
|
406
|
+
|
|
407
|
+
|
|
326
408
|
def test_failed_replacement_upload_reactivates_old_source(tmp_path):
|
|
327
409
|
src = tmp_path / "sources"
|
|
328
410
|
src.mkdir()
|
|
@@ -545,6 +627,52 @@ class TestSectionPinIsOwnFields:
|
|
|
545
627
|
m = _merged_field_map(section)
|
|
546
628
|
assert m["pi.nat"].get("enum_values") == ["canonical"], m
|
|
547
629
|
|
|
630
|
+
def test_rulebook_only_collection_without_items_does_not_block_a_section(self, tmp_path):
|
|
631
|
+
"""A rulebook may hold a collection row whose items its own release
|
|
632
|
+
step fills in. The section never sends that row, so its missing
|
|
633
|
+
``items`` must not stop the section's generate."""
|
|
634
|
+
from aethis_cli.commands.generate_cmd import _validate_project_fields
|
|
635
|
+
|
|
636
|
+
section = self._tree(
|
|
637
|
+
tmp_path,
|
|
638
|
+
own_fields=[{"key": "ref.x", "type": "Bool"}],
|
|
639
|
+
rb_fields=[
|
|
640
|
+
{"key": "app.history", "type": "Collection"},
|
|
641
|
+
{"key": "ref.x", "type": "Bool"},
|
|
642
|
+
],
|
|
643
|
+
)
|
|
644
|
+
_validate_project_fields(section) # must not raise
|
|
645
|
+
|
|
646
|
+
def test_shared_collection_without_items_still_blocks_a_section(self, tmp_path):
|
|
647
|
+
"""Negative control: a collection row the section DOES send (a shared
|
|
648
|
+
key, where the rulebook definition wins) still needs ``items``."""
|
|
649
|
+
import typer
|
|
650
|
+
|
|
651
|
+
from aethis_cli.commands.generate_cmd import _validate_project_fields
|
|
652
|
+
|
|
653
|
+
section = self._tree(
|
|
654
|
+
tmp_path,
|
|
655
|
+
own_fields=[{"key": "app.history", "type": "Collection", "items": {"sort": "String"}}],
|
|
656
|
+
rb_fields=[{"key": "app.history", "type": "Collection"}],
|
|
657
|
+
)
|
|
658
|
+
with pytest.raises(typer.Exit):
|
|
659
|
+
_validate_project_fields(section)
|
|
660
|
+
|
|
661
|
+
def test_rulebook_only_row_is_still_checked_for_everything_else(self, tmp_path):
|
|
662
|
+
"""Only the missing-items check is scoped; a bad type on a rulebook-only
|
|
663
|
+
row still fails, as before."""
|
|
664
|
+
import typer
|
|
665
|
+
|
|
666
|
+
from aethis_cli.commands.generate_cmd import _validate_project_fields
|
|
667
|
+
|
|
668
|
+
section = self._tree(
|
|
669
|
+
tmp_path,
|
|
670
|
+
own_fields=[{"key": "ref.x", "type": "Bool"}],
|
|
671
|
+
rb_fields=[{"key": "app.other", "type": "Nonsense"}, {"key": "ref.x", "type": "Bool"}],
|
|
672
|
+
)
|
|
673
|
+
with pytest.raises(typer.Exit):
|
|
674
|
+
_validate_project_fields(section)
|
|
675
|
+
|
|
548
676
|
def test_section_without_own_fields_pins_nothing(self, tmp_path):
|
|
549
677
|
from aethis_cli.commands.generate_cmd import _merged_field_map
|
|
550
678
|
|
|
@@ -177,3 +177,118 @@ def test_scripts_emit_machine_readable_records(tmp_path):
|
|
|
177
177
|
(dist / f"aethis_cli-{version}-py3-none-any.whl").write_bytes(b"y")
|
|
178
178
|
record = integrity.build_record(dist, verify_registry=False)
|
|
179
179
|
assert json.loads(json.dumps(record)) == record
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
# ---------------------------------------------------------------------------
|
|
183
|
+
# Published-digest verification (registry index lags an upload)
|
|
184
|
+
# ---------------------------------------------------------------------------
|
|
185
|
+
|
|
186
|
+
verify_published = _load("verify_published_digests", "verify-published-digests.py")
|
|
187
|
+
|
|
188
|
+
_BUILT = {"wheel": {"sha256": "aaa"}, "sdist": {"sha256": "bbb"}}
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
def _files(wheel="aaa", sdist="bbb"):
|
|
192
|
+
return [
|
|
193
|
+
{"packagetype": "bdist_wheel", "filename": "w.whl", "digests": {"sha256": wheel}},
|
|
194
|
+
{"packagetype": "sdist", "filename": "s.tar.gz", "digests": {"sha256": sdist}},
|
|
195
|
+
]
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
def _run(readings, attempts=4):
|
|
199
|
+
calls, sleeps = [], []
|
|
200
|
+
|
|
201
|
+
def fetch(version):
|
|
202
|
+
calls.append(version)
|
|
203
|
+
return readings[min(len(calls), len(readings)) - 1]
|
|
204
|
+
|
|
205
|
+
failures = verify_published.verify("1.0.0", _BUILT, fetch=fetch, sleep=sleeps.append, attempts=attempts)
|
|
206
|
+
return failures, len(calls), sleeps
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
def test_verify_retries_until_files_appear():
|
|
210
|
+
failures, calls, sleeps = _run([[], _files()[:1], _files()])
|
|
211
|
+
assert failures == []
|
|
212
|
+
assert calls == 3 and len(sleeps) == 2
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
def test_verify_digest_mismatch_fails_immediately():
|
|
216
|
+
failures, calls, sleeps = _run([_files(sdist="evil")])
|
|
217
|
+
assert calls == 1 and sleeps == []
|
|
218
|
+
assert failures and "sdist digest mismatch" in failures[0]
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
def test_verify_missing_forever_fails_after_the_bound():
|
|
222
|
+
failures, calls, sleeps = _run([[]], attempts=4)
|
|
223
|
+
assert calls == 4 and len(sleeps) == 3
|
|
224
|
+
assert sorted(failures) == ["sdist missing from the registry", "wheel missing from the registry"]
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
def test_verify_empty_distribution_fails_closed():
|
|
228
|
+
assert verify_published.verify("1.0.0", {}, fetch=lambda v: _files(), sleep=lambda d: None)
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
@pytest.mark.parametrize("code", [429, 500, 503])
|
|
232
|
+
def test_fetch_treats_transient_http_errors_as_retryable(monkeypatch, code):
|
|
233
|
+
import urllib.error
|
|
234
|
+
|
|
235
|
+
def boom(*a, **k):
|
|
236
|
+
raise urllib.error.HTTPError("u", code, "x", None, None)
|
|
237
|
+
|
|
238
|
+
monkeypatch.setattr(verify_published.urllib.request, "urlopen", boom)
|
|
239
|
+
assert verify_published.fetch_files("1.0.0") == []
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
def test_fetch_other_http_errors_still_raise(monkeypatch):
|
|
243
|
+
import urllib.error
|
|
244
|
+
|
|
245
|
+
def boom(*a, **k):
|
|
246
|
+
raise urllib.error.HTTPError("u", 403, "x", None, None)
|
|
247
|
+
|
|
248
|
+
monkeypatch.setattr(verify_published.urllib.request, "urlopen", boom)
|
|
249
|
+
with pytest.raises(urllib.error.HTTPError):
|
|
250
|
+
verify_published.fetch_files("1.0.0")
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
# ---------------------------------------------------------------------------
|
|
254
|
+
# Hermetic registry install (index lags an upload)
|
|
255
|
+
# ---------------------------------------------------------------------------
|
|
256
|
+
|
|
257
|
+
_LAG = " x No solution found when resolving dependencies:\n `-> there is no version of aethis-cli==1.0.0"
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
def _install_run(results, retry_lag=True, attempts=4):
|
|
261
|
+
import subprocess
|
|
262
|
+
|
|
263
|
+
calls, sleeps = [], []
|
|
264
|
+
|
|
265
|
+
def run(argv, env, timeout=0):
|
|
266
|
+
calls.append(argv)
|
|
267
|
+
rc, err = results[min(len(calls), len(results)) - 1]
|
|
268
|
+
return subprocess.CompletedProcess(argv, rc, "", err)
|
|
269
|
+
|
|
270
|
+
out = hermetic._install(
|
|
271
|
+
["uv"], {}, version="1.0.0", retry_lag=retry_lag, run=run, sleep=sleeps.append, attempts=attempts
|
|
272
|
+
)
|
|
273
|
+
return out, len(calls), sleeps
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
def test_install_retries_registry_lag_then_passes():
|
|
277
|
+
out, calls, sleeps = _install_run([(1, _LAG), (1, _LAG), (0, "")])
|
|
278
|
+
assert out.returncode == 0 and calls == 3 and len(sleeps) == 2
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
def test_install_registry_lag_forever_fails_after_the_bound():
|
|
282
|
+
out, calls, sleeps = _install_run([(1, _LAG)], attempts=4)
|
|
283
|
+
assert out.returncode == 1 and calls == 4 and len(sleeps) == 3
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
def test_install_other_errors_fail_immediately():
|
|
287
|
+
conflict = "No solution found: aethis-cli==1.0.0 depends on httpx>=9, which cannot be satisfied"
|
|
288
|
+
out, calls, sleeps = _install_run([(1, conflict)])
|
|
289
|
+
assert out.returncode == 1 and calls == 1 and sleeps == []
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
def test_install_from_dist_never_retries():
|
|
293
|
+
out, calls, sleeps = _install_run([(1, _LAG)], retry_lag=False)
|
|
294
|
+
assert calls == 1 and sleeps == []
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_collection_computed_prerequisite_transport.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{aethis_cli-0.53.0 → aethis_cli-0.53.2}/tests/test_field_dependency_and_identity_transport.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|