sanka-cli 0.2.5__tar.gz → 0.2.7__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 (140) hide show
  1. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/PKG-INFO +8 -1
  2. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/README.md +7 -0
  3. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/pyproject.toml +1 -1
  4. sanka_cli-0.2.7/src/sanka/cli/_compact.py +103 -0
  5. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka/runtime/execution/report_codec.py +10 -0
  6. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka_cli/__init__.py +1 -1
  7. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/tests/test_cli.py +1 -1
  8. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/tests/test_cli_developer_experience.py +75 -0
  9. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/tests/test_execution_report_codec.py +55 -1
  10. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/tests/test_mcp.py +2 -2
  11. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/tests/test_sanka_facade.py +1 -1
  12. sanka_cli-0.2.5/src/sanka/cli/_compact.py +0 -50
  13. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/.gitignore +0 -0
  14. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/LICENSES/AGPL-3.0-only.txt +0 -0
  15. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/LICENSES/Apache-2.0.txt +0 -0
  16. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/NOTICE +0 -0
  17. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka/__init__.py +0 -0
  18. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka/_client.py +0 -0
  19. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka/cli/__init__.py +0 -0
  20. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka/cli/_output.py +0 -0
  21. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka/cli/_research.py +0 -0
  22. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka/cli/py.typed +0 -0
  23. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka/connector/__init__.py +0 -0
  24. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka/connector/py.typed +0 -0
  25. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka/runtime/__about__.py +0 -0
  26. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka/runtime/__init__.py +0 -0
  27. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka/runtime/concurrency.py +0 -0
  28. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka/runtime/connector_client.py +0 -0
  29. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka/runtime/connector_host.py +0 -0
  30. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka/runtime/engine.py +0 -0
  31. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka/runtime/execution/__init__.py +0 -0
  32. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka/runtime/execution/continuous.py +0 -0
  33. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka/runtime/execution/errors.py +0 -0
  34. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka/runtime/execution/local.py +0 -0
  35. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka/runtime/execution/model.py +0 -0
  36. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka/runtime/execution/routes.py +0 -0
  37. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka/runtime/execution/scope.py +0 -0
  38. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka/runtime/execution/state.py +0 -0
  39. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka/runtime/execution/validate.py +0 -0
  40. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka/runtime/extensions/__init__.py +0 -0
  41. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka/runtime/extensions/discovery.py +0 -0
  42. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka/runtime/extensions/lifecycle.py +0 -0
  43. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka/runtime/extensions/model.py +0 -0
  44. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka/runtime/extensions/runner.py +0 -0
  45. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka/runtime/extensions/store.py +0 -0
  46. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka/runtime/hashing.py +0 -0
  47. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka/runtime/mapping/__init__.py +0 -0
  48. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka/runtime/mapping/errors.py +0 -0
  49. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka/runtime/mapping/mapping_candidates.py +0 -0
  50. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka/runtime/mapping/model.py +0 -0
  51. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka/runtime/mapping/owner_mapping.py +0 -0
  52. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka/runtime/mapping/pending_relationships.py +0 -0
  53. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka/runtime/mapping/record_mapping.py +0 -0
  54. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka/runtime/planner.py +0 -0
  55. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka/runtime/private_sqlite.py +0 -0
  56. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka/runtime/py.typed +0 -0
  57. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka/runtime/registry.py +0 -0
  58. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka/runtime/safe_local_io.py +0 -0
  59. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka/runtime/spec.py +0 -0
  60. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka/runtime/state.py +0 -0
  61. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka_cli/__main__.py +0 -0
  62. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka_cli/bundle.py +0 -0
  63. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka_cli/certificates.py +0 -0
  64. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka_cli/client.py +0 -0
  65. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka_cli/commands/__init__.py +0 -0
  66. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka_cli/commands/ai.py +0 -0
  67. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka_cli/commands/auth.py +0 -0
  68. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka_cli/commands/cloud.py +0 -0
  69. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka_cli/commands/cloud_fleet.py +0 -0
  70. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka_cli/commands/cloud_migrate.py +0 -0
  71. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka_cli/commands/code.py +0 -0
  72. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka_cli/commands/migrate.py +0 -0
  73. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka_cli/commands/profiles.py +0 -0
  74. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka_cli/commands/resources.py +0 -0
  75. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka_cli/commands/skill.py +0 -0
  76. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka_cli/commands/workflows.py +0 -0
  77. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka_cli/config.py +0 -0
  78. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka_cli/main.py +0 -0
  79. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka_cli/mcp/__init__.py +0 -0
  80. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka_cli/mcp/client.py +0 -0
  81. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka_cli/mcp/render.py +0 -0
  82. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka_cli/mcp/server.py +0 -0
  83. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka_cli/output.py +0 -0
  84. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka_cli/runtime.py +0 -0
  85. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka_cli/skills/sanka-cli/SKILL.md +0 -0
  86. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka_cli/state.py +0 -0
  87. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka_connector/__about__.py +0 -0
  88. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka_connector/__init__.py +0 -0
  89. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka_connector/credentials.py +0 -0
  90. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka_connector/errors.py +0 -0
  91. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka_connector/protocols.py +0 -0
  92. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka_connector/provisioning.py +0 -0
  93. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka_connector/py.typed +0 -0
  94. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka_connector/records.py +0 -0
  95. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka_connector/registration.py +0 -0
  96. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/src/sanka_connector/schema.py +0 -0
  97. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/tests/conftest.py +0 -0
  98. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/tests/fixtures/extension_drf_project/api/__init__.py +0 -0
  99. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/tests/fixtures/extension_drf_project/api/serializers.py +0 -0
  100. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/tests/fixtures/extension_drf_project/api/views.py +0 -0
  101. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/tests/fixtures/extension_drf_project/config/__init__.py +0 -0
  102. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/tests/fixtures/extension_drf_project/config/settings.py +0 -0
  103. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/tests/fixtures/extension_drf_project/config/urls.py +0 -0
  104. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/tests/fixtures/extension_drf_project/manage.py +0 -0
  105. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/tests/fixtures/extension_marketplace/drf-to-fastapi.json +0 -0
  106. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/tests/fixtures/extension_marketplace/marketplace.json +0 -0
  107. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/tests/test_code_bundle.py +0 -0
  108. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/tests/test_code_commands.py +0 -0
  109. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/tests/test_concurrency.py +0 -0
  110. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/tests/test_connector_client.py +0 -0
  111. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/tests/test_connector_host.py +0 -0
  112. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/tests/test_credential_provider.py +0 -0
  113. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/tests/test_engine_e2e.py +0 -0
  114. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/tests/test_engine_execution_adoption.py +0 -0
  115. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/tests/test_engine_pg_to_clickhouse_e2e.py +0 -0
  116. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/tests/test_engine_postgres_e2e.py +0 -0
  117. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/tests/test_execution_continuous.py +0 -0
  118. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/tests/test_execution_exact_scope.py +0 -0
  119. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/tests/test_execution_local_store.py +0 -0
  120. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/tests/test_execution_routes.py +0 -0
  121. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/tests/test_execution_scope.py +0 -0
  122. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/tests/test_execution_seam.py +0 -0
  123. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/tests/test_execution_validate.py +0 -0
  124. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/tests/test_extension_discovery.py +0 -0
  125. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/tests/test_extension_lifecycle.py +0 -0
  126. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/tests/test_extension_runner.py +0 -0
  127. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/tests/test_extension_store.py +0 -0
  128. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/tests/test_extension_wheel_acceptance.py +0 -0
  129. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/tests/test_hashing.py +0 -0
  130. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/tests/test_hosted_cli.py +0 -0
  131. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/tests/test_mapping_candidates.py +0 -0
  132. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/tests/test_mapping_owner_mapping.py +0 -0
  133. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/tests/test_mapping_pending_relationships.py +0 -0
  134. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/tests/test_mapping_record_mapping.py +0 -0
  135. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/tests/test_planner.py +0 -0
  136. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/tests/test_registry.py +0 -0
  137. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/tests/test_safe_local_io.py +0 -0
  138. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/tests/test_skill_commands.py +0 -0
  139. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/tests/test_spec.py +0 -0
  140. {sanka_cli-0.2.5 → sanka_cli-0.2.7}/tests/test_state_store.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: sanka-cli
3
- Version: 0.2.5
3
+ Version: 0.2.7
4
4
  Summary: Sanka command-line interface and migration runtime
5
5
  Project-URL: Repository, https://github.com/sankaHQ/sanka
6
6
  Project-URL: Issues, https://github.com/sankaHQ/sanka/issues
@@ -176,6 +176,13 @@ contents and route source code are replaced by explicit omission counts and file
176
176
  names. Read the returned artifact for those details; a compact summary is not a
177
177
  replacement for the full report. `data.plan_hash` becomes the `plan_hash` line;
178
178
  use that core hash for apply, not a nested extension hash.
179
+ Successful scan/plan inventories replace descriptive serializer, view, OPTIONS,
180
+ parity-note and fingerprint-evidence metadata with counts and artifact references.
181
+ Identical core/extension scan fields appear once. Route decisions, adaptation
182
+ reasons, hashes and diagnostics remain inline; metadata containing diagnostics
183
+ also stays inline. Full `--json` output and saved artifacts are unchanged, and
184
+ results without artifacts retain their details.
185
+
179
186
 
180
187
  Keep the lifecycle: scan → plan → apply → test → verify. An applied scaffold with
181
188
  manual gaps is not complete. Test establishes generated scope; scenario verification
@@ -145,6 +145,13 @@ contents and route source code are replaced by explicit omission counts and file
145
145
  names. Read the returned artifact for those details; a compact summary is not a
146
146
  replacement for the full report. `data.plan_hash` becomes the `plan_hash` line;
147
147
  use that core hash for apply, not a nested extension hash.
148
+ Successful scan/plan inventories replace descriptive serializer, view, OPTIONS,
149
+ parity-note and fingerprint-evidence metadata with counts and artifact references.
150
+ Identical core/extension scan fields appear once. Route decisions, adaptation
151
+ reasons, hashes and diagnostics remain inline; metadata containing diagnostics
152
+ also stays inline. Full `--json` output and saved artifacts are unchanged, and
153
+ results without artifacts retain their details.
154
+
148
155
 
149
156
  Keep the lifecycle: scan → plan → apply → test → verify. An applied scaffold with
150
157
  manual gaps is not complete. Test establishes generated scope; scenario verification
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "sanka-cli"
3
- version = "0.2.5"
3
+ version = "0.2.7"
4
4
  description = "Sanka command-line interface and migration runtime"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.12"
@@ -0,0 +1,103 @@
1
+ # SPDX-License-Identifier: AGPL-3.0-only
2
+ """Model-facing presentation of the existing result, with JSON-escaped values."""
3
+
4
+ from __future__ import annotations
5
+
6
+ import json
7
+ from typing import Any
8
+
9
+ _DIAGNOSTICS = {"error", "failures", "warnings", "risks", "coverage_issues", "limitations"}
10
+
11
+
12
+ def _has_diagnostics(value: Any) -> bool:
13
+ if isinstance(value, dict):
14
+ return any(
15
+ (name in _DIAGNOSTICS and bool(item)) or _has_diagnostics(item)
16
+ for name, item in value.items()
17
+ )
18
+ return isinstance(value, list) and any(_has_diagnostics(item) for item in value)
19
+
20
+
21
+ def _summary(
22
+ value: Any, *, path: tuple[str, ...] = (), artifacts: bool = False, inventory: bool = False
23
+ ) -> Any:
24
+ if isinstance(value, dict):
25
+ if path in {("files",), ("extension", "files")} and artifacts:
26
+ return {"names": sorted(value), "omitted_file_contents": len(value)}
27
+ result: dict[str, Any] = {}
28
+ for name, item in value.items():
29
+ if inventory and artifacts:
30
+ if not path and name == "extensions" and isinstance(item, list):
31
+ item = [
32
+ {
33
+ **entry,
34
+ "data": {
35
+ k: v
36
+ for k, v in entry["data"].items()
37
+ if k not in value or value[k] != v
38
+ },
39
+ }
40
+ if isinstance(entry, dict) and isinstance(entry.get("data"), dict)
41
+ else entry
42
+ for entry in item
43
+ ]
44
+ owner = path in {(), ("extension",), ("extensions", "[]", "data")}
45
+ route = len(path) >= 2 and path[-2:] == ("routes", "[]")
46
+ if (
47
+ (
48
+ (owner and name in {"serializer_details", "view_details", "status_codes"})
49
+ or (route and name in {"parity_notes", "options"})
50
+ or (path == ("fingerprint",) and name == "evidence")
51
+ )
52
+ and isinstance(item, (dict, list))
53
+ and not _has_diagnostics(item)
54
+ ):
55
+ result[name] = {"count": len(item), "details": "artifacts"}
56
+ continue
57
+ if name == "extension" and isinstance(item, dict):
58
+ # Core lifecycle responses repeat extension fields; retain differing hashes.
59
+ item = {k: v for k, v in item.items() if k not in value or value[k] != v}
60
+ if not item:
61
+ continue
62
+ if (
63
+ name == "source"
64
+ and {"classification", "method"} <= value.keys()
65
+ and isinstance(item, str)
66
+ and artifacts
67
+ ):
68
+ result["omitted_source_characters"] = len(item)
69
+ else:
70
+ result[name] = _summary(
71
+ item,
72
+ path=(*path, name),
73
+ artifacts=artifacts,
74
+ inventory=inventory and name not in _DIAGNOSTICS,
75
+ )
76
+ return result
77
+ if isinstance(value, list):
78
+ return [
79
+ _summary(item, path=(*path, "[]"), artifacts=artifacts, inventory=inventory)
80
+ for item in value
81
+ ]
82
+ return value
83
+
84
+
85
+ def render_compact(payload: dict[str, Any]) -> str:
86
+ """One header, then key=JSON lines. Never truncate failures, warnings or hashes."""
87
+ lines = [" ".join(str(payload[k]) for k in ("command", "outcome", "migration_state"))]
88
+ lines[0] = "sanka-compact/v1 " + lines[0]
89
+ data = _summary(
90
+ payload["data"],
91
+ artifacts=bool(payload.get("artifacts")),
92
+ inventory=payload["command"] in {"scan", "plan"} and payload["outcome"] == "success",
93
+ )
94
+ for key, value in data.items():
95
+ # Escape even extension-defined keys so a newline cannot forge another record.
96
+ label = key if key.isidentifier() else json.dumps(key, ensure_ascii=False)
97
+ lines.append(label + "=" + json.dumps(value, ensure_ascii=False, separators=(",", ":")))
98
+ for key in ("artifacts", "limitations", "next_actions"):
99
+ if payload.get(key):
100
+ lines.append(
101
+ key + "=" + json.dumps(payload[key], ensure_ascii=False, separators=(",", ":"))
102
+ )
103
+ return "\n".join(lines)
@@ -207,6 +207,15 @@ def canonical_route_manifest(raw: Any) -> MappingRouteManifest:
207
207
  code="SANKA_MIGRATE_ROUTE_MANIFEST_INVALID",
208
208
  )
209
209
  seen.add(route_key)
210
+ identity_fields = item.get("identityFields", [])
211
+ if not isinstance(identity_fields, list) or any(
212
+ not isinstance(value, str) or not value.strip() or value != value.strip()
213
+ for value in identity_fields
214
+ ):
215
+ raise ExecutionFault(
216
+ "The saved Sanka route manifest contains invalid identity fields.",
217
+ code="SANKA_MIGRATE_ROUTE_MANIFEST_INVALID",
218
+ )
210
219
  normalized.append(
211
220
  {
212
221
  "routeKey": route_key,
@@ -215,6 +224,7 @@ def canonical_route_manifest(raw: Any) -> MappingRouteManifest:
215
224
  "sourceFilter": (
216
225
  _source_filter_payload(source_filter) if source_filter is not None else None
217
226
  ),
227
+ **({"identityFields": sorted(set(identity_fields))} if identity_fields else {}),
218
228
  }
219
229
  )
220
230
  return sorted(normalized, key=lambda row: str(row["routeKey"]))
@@ -1,4 +1,4 @@
1
1
  # SPDX-License-Identifier: Apache-2.0
2
2
  __all__ = ["__version__"]
3
3
 
4
- __version__ = "0.2.5"
4
+ __version__ = "0.2.7"
@@ -617,7 +617,7 @@ def test_research_client_uses_public_branded_base_and_unwraps_data() -> None:
617
617
  "after": ["2027-01"],
618
618
  "locale": ["ja"],
619
619
  }
620
- assert request.get_header("User-agent") == "sanka-cli/0.2.5"
620
+ assert request.get_header("User-agent") == "sanka-cli/0.2.7"
621
621
  assert timeout == 10.0
622
622
 
623
623
 
@@ -445,3 +445,78 @@ def test_compact_plan_keeps_review_hash_and_summarizes_generated_code(
445
445
  assert "target_app.py" in output and "Scope is limited" in output
446
446
  assert "omitted" in output and "/tmp/plan.json" in output
447
447
  assert len(output) < 1000
448
+
449
+
450
+ @pytest.mark.parametrize("command", ["scan", "plan"])
451
+ def test_compact_inventory_keeps_decisions_and_artifacts_without_metadata_repetition(
452
+ command: str,
453
+ ) -> None:
454
+ from copy import deepcopy
455
+
456
+ from sanka.cli._compact import render_compact
457
+
458
+ route = {
459
+ "method": "POST",
460
+ "path": "/items/",
461
+ "native": False,
462
+ "adaptation_reasons": [{"code": "CUSTOM_WRITE", "message": "Preserve validation"}],
463
+ "parity_notes": [{"code": "EXACT_MESSAGE", "message": "details" * 1000}],
464
+ "options": {"anonymous": {"actions": "metadata" * 1000}},
465
+ "warnings": ["Requires authentication"],
466
+ }
467
+ data = {
468
+ "plan_hash": "sha256:core",
469
+ "routes": [route],
470
+ "serializer_details": [{"fields": "fields" * 1000}],
471
+ "view_details": [{"source": "source" * 1000}],
472
+ "status_codes": {"HTTP_200_OK": 200},
473
+ "fingerprint": {"sha256": "sha256:source", "evidence": ["evidence" * 1000]},
474
+ "warnings": [{"routes": [route]}],
475
+ "extensions": [
476
+ {
477
+ "extension": {"id": "example", "manifest_digest": "sha256:manifest"},
478
+ "data": {"routes": [route], "plan_hash": "sha256:extension"},
479
+ }
480
+ ],
481
+ }
482
+ payload = {
483
+ "command": command,
484
+ "outcome": "success",
485
+ "migration_state": "planned",
486
+ "data": data,
487
+ "artifacts": [".sanka/full.json"],
488
+ }
489
+ before = deepcopy(payload)
490
+ output = render_compact(payload)
491
+ fields = {k: json.loads(v) for k, v in (line.split("=", 1) for line in output.splitlines()[1:])}
492
+ assert fields["routes"][0]["adaptation_reasons"] == route["adaptation_reasons"]
493
+ assert fields["routes"][0]["native"] is False
494
+ assert fields["routes"][0]["parity_notes"] == {"count": 1, "details": "artifacts"}
495
+ assert fields["warnings"] == data["warnings"]
496
+ assert fields["extensions"][0]["data"] == {"plan_hash": "sha256:extension"}
497
+ assert fields["extensions"][0]["extension"]["manifest_digest"] == "sha256:manifest"
498
+ assert fields["fingerprint"]["sha256"] == "sha256:source"
499
+ assert fields["plan_hash"] == "sha256:core"
500
+ assert fields["artifacts"] == payload["artifacts"]
501
+ assert payload == before
502
+ # Without a saved artifact, or on failure, metadata must remain inline.
503
+ payload["artifacts"] = []
504
+ assert '"actions":"metadata' in render_compact(payload)
505
+ payload["artifacts"] = [".sanka/full.json"]
506
+ payload["outcome"] = "error"
507
+ assert '"actions":"metadata' in render_compact(payload)
508
+
509
+
510
+ def test_compact_keeps_diagnostics_nested_inside_descriptive_metadata() -> None:
511
+ from sanka.cli._compact import render_compact
512
+
513
+ data = {"serializer_details": [{"nested": {"warnings": ["Unsupported validator"]}}]}
514
+ payload = {
515
+ "command": "scan",
516
+ "outcome": "success",
517
+ "migration_state": "scanned",
518
+ "data": data,
519
+ "artifacts": [".sanka/scan.json"],
520
+ }
521
+ text = render_compact(payload)
522
+ assert json.loads(text.splitlines()[1].split("=", 1)[1]) == data["serializer_details"]
@@ -604,7 +604,7 @@ def test_route_progress_keys_are_validated_by_the_remap() -> None:
604
604
 
605
605
  def test_canonical_route_manifest_sorts_rows_and_drops_extra_keys() -> None:
606
606
  rows = list(reversed(_filtered_manifest()))
607
- rows[0] = {**rows[0], "identityFields": ["email"]} # v0 manifest extra key
607
+ rows[0] = {**rows[0], "unusedMetadata": "ignored"}
608
608
  normalized = canonical_route_manifest(rows)
609
609
  assert [row["routeKey"] for row in normalized] == [FILTERED_ROUTE, "contacts|contacts"]
610
610
  assert all(
@@ -713,6 +713,60 @@ def test_execution_route_manifest_reads_the_saved_manifest() -> None:
713
713
  assert excinfo.value.code == "SANKA_MIGRATE_ROUTE_MANIFEST_MISSING"
714
714
 
715
715
 
716
+ def test_identity_manifest_survives_mapping_validation_and_journal_round_trip() -> None:
717
+ from sanka.runtime.mapping.record_mapping import mapping_route_manifest
718
+
719
+ field = MigrationMappingField(
720
+ source_field="accounts.Domain",
721
+ target_object="companies",
722
+ target_field="domain",
723
+ identity=True,
724
+ )
725
+ groups: list[MappingGroup] = [("accounts", "companies", None, [field])]
726
+ saved = mapping_route_manifest(groups)
727
+ assert saved[0]["identityFields"] == ["domain"]
728
+ validated = require_matching_route_manifest(groups, saved)
729
+ assert validated == saved
730
+ report = _queued_report()
731
+ report["execution"]["routeManifest"] = validated
732
+ restored = _round_trip(report)
733
+ assert restored["execution"]["routeManifest"] == saved
734
+
735
+
736
+ @pytest.mark.parametrize("identities", [["email"], [], None])
737
+ def test_changed_or_removed_identities_reject_a_previously_reviewed_manifest(
738
+ identities: list[str] | None,
739
+ ) -> None:
740
+ field = MigrationMappingField(
741
+ source_field="accounts.Domain",
742
+ target_object="companies",
743
+ target_field="domain",
744
+ identity=True,
745
+ )
746
+ groups: list[MappingGroup] = [("accounts", "companies", None, [field])]
747
+ saved = _manifest()
748
+ if identities is not None:
749
+ saved[0]["identityFields"] = identities
750
+ with pytest.raises(ExecutionFault) as excinfo:
751
+ require_matching_route_manifest(groups, saved)
752
+ assert excinfo.value.code == "SANKA_MIGRATE_ROUTE_MANIFEST_CHANGED"
753
+
754
+
755
+ @pytest.mark.parametrize("identities", [None, "email", [1], [""], [" email"], {}])
756
+ def test_invalid_identity_fields_fail_closed(identities: Any) -> None:
757
+ saved = _manifest()
758
+ saved[0]["identityFields"] = identities
759
+ with pytest.raises(ExecutionFault) as excinfo:
760
+ canonical_route_manifest(saved)
761
+ assert excinfo.value.code == "SANKA_MIGRATE_ROUTE_MANIFEST_INVALID"
762
+
763
+
764
+ def test_identity_order_and_duplicates_are_canonical() -> None:
765
+ saved = _manifest()
766
+ saved[0]["identityFields"] = ["external_id", "email", "email"]
767
+ assert canonical_route_manifest(saved)[0]["identityFields"] == ["email", "external_id"]
768
+
769
+
716
770
  # -- route selection -----------------------------------------------------------
717
771
 
718
772
 
@@ -21,7 +21,7 @@ def test_root_version_uses_unified_public_version(runner: CliRunner) -> None:
21
21
  result = runner.invoke(cli, ["--version"])
22
22
 
23
23
  assert result.exit_code == 0
24
- assert result.output == "sanka, version 0.2.5\n"
24
+ assert result.output == "sanka, version 0.2.7\n"
25
25
 
26
26
 
27
27
  def test_mcp_client_uses_the_cli_version_in_its_user_agent() -> None:
@@ -29,7 +29,7 @@ def test_mcp_client_uses_the_cli_version_in_its_user_agent() -> None:
29
29
 
30
30
  client = SankaMigrateApiClient()
31
31
 
32
- assert client._client.headers["User-Agent"] == "sanka-cli/0.2.5"
32
+ assert client._client.headers["User-Agent"] == "sanka-cli/0.2.7"
33
33
 
34
34
 
35
35
  def test_mcp_without_extra_has_install_hint(
@@ -35,7 +35,7 @@ def test_public_facade_version_matches_unified_distribution() -> None:
35
35
  == sanka_cli.__version__
36
36
  == sanka_cli.mcp.__version__
37
37
  == distribution_version("sanka-cli")
38
- == "0.2.5"
38
+ == "0.2.7"
39
39
  )
40
40
 
41
41
 
@@ -1,50 +0,0 @@
1
- # SPDX-License-Identifier: AGPL-3.0-only
2
- """Model-facing presentation of the existing result, with JSON-escaped values."""
3
-
4
- from __future__ import annotations
5
-
6
- import json
7
- from typing import Any
8
-
9
-
10
- def _summary(value: Any, *, path: tuple[str, ...] = (), artifacts: bool = False) -> Any:
11
- if isinstance(value, dict):
12
- if path in {("files",), ("extension", "files")} and artifacts:
13
- return {"names": sorted(value), "omitted_file_contents": len(value)}
14
- result = {}
15
- for name, item in value.items():
16
- if name == "extension" and isinstance(item, dict):
17
- # Core lifecycle responses repeat extension fields; retain differing hashes.
18
- item = {k: v for k, v in item.items() if k not in value or value[k] != v}
19
- if not item:
20
- continue
21
- if (
22
- name == "source"
23
- and {"classification", "method"} <= value.keys()
24
- and isinstance(item, str)
25
- and artifacts
26
- ):
27
- result["omitted_source_characters"] = len(item)
28
- else:
29
- result[name] = _summary(item, path=(*path, name), artifacts=artifacts)
30
- return result
31
- if isinstance(value, list):
32
- return [_summary(item, path=(*path, "[]"), artifacts=artifacts) for item in value]
33
- return value
34
-
35
-
36
- def render_compact(payload: dict[str, Any]) -> str:
37
- """One header, then key=JSON lines. Never truncate failures, warnings or hashes."""
38
- lines = [" ".join(str(payload[k]) for k in ("command", "outcome", "migration_state"))]
39
- lines[0] = "sanka-compact/v1 " + lines[0]
40
- data = _summary(payload["data"], artifacts=bool(payload.get("artifacts")))
41
- for key, value in data.items():
42
- # Escape even extension-defined keys so a newline cannot forge another record.
43
- label = key if key.isidentifier() else json.dumps(key, ensure_ascii=False)
44
- lines.append(label + "=" + json.dumps(value, ensure_ascii=False, separators=(",", ":")))
45
- for key in ("artifacts", "limitations", "next_actions"):
46
- if payload.get(key):
47
- lines.append(
48
- key + "=" + json.dumps(payload[key], ensure_ascii=False, separators=(",", ":"))
49
- )
50
- return "\n".join(lines)
File without changes
File without changes
File without changes
File without changes