Finish ITC-WP-0013 (AttributeValueType under ITC-DATA) and ITC-WP-0014 T02/T03/T05/T06/T07. Capability contract schemas, live-catalog review CLI, landscape/kernel-map pointers. Sit on this version.
208 lines
6.6 KiB
Python
208 lines
6.6 KiB
Python
from info_tech_canon.service import (
|
|
alignment_template,
|
|
artifact_graph,
|
|
generate_agent_briefs,
|
|
generate_indexes,
|
|
generate_tree,
|
|
inspect_canon,
|
|
list_models,
|
|
list_standards,
|
|
profile_graph,
|
|
profile_validate,
|
|
review_capability_record,
|
|
review_kit,
|
|
validate_canon,
|
|
)
|
|
from info_tech_canon.service import DEFAULT_INFOSPACE_ROOT
|
|
from pathlib import Path
|
|
import json
|
|
import shutil
|
|
|
|
|
|
def test_inspect_canon_counts_artifact_kinds() -> None:
|
|
payload = inspect_canon()
|
|
|
|
assert payload["ok"] is True
|
|
assert payload["infospace"]["slug"] == "canon"
|
|
assert payload["infospace"]["artifact_count"] == 68
|
|
assert payload["infospace"]["kinds"] == {
|
|
"access-descriptor-set": 1,
|
|
"alignment-review-kit": 1,
|
|
"assimilation": 1,
|
|
"alignment-review-schema": 1,
|
|
"alignment-review-workflow": 1,
|
|
"alignment-scorecard": 1,
|
|
"benefit-analysis": 1,
|
|
"benchmark-findings": 1,
|
|
"benchmark-workspace": 1,
|
|
"capability-catalog": 1,
|
|
"capture-criteria": 1,
|
|
"caring-mapping": 1,
|
|
"comparison-frame": 1,
|
|
"comparison-report": 1,
|
|
"concept-catalog": 3,
|
|
"conformance-pack": 1,
|
|
"consumer-workplan-brief": 3,
|
|
"consumer-workplan-template": 1,
|
|
"evaluation-pack": 1,
|
|
"evaluation-question-set": 1,
|
|
"example": 1,
|
|
"extension-candidate-set": 1,
|
|
"interface-card-expectation": 1,
|
|
"kernel": 2,
|
|
"mapping": 2,
|
|
"mapping-expectation": 1,
|
|
"model": 12,
|
|
"model-extension": 1,
|
|
"model-selection-guide": 1,
|
|
"native-concept-map": 1,
|
|
"pattern": 1,
|
|
"practice": 1,
|
|
"profile-alignment": 1,
|
|
"profile": 1,
|
|
"profile-artifact": 13,
|
|
"standard": 3,
|
|
"visualization-example-set": 1,
|
|
}
|
|
|
|
|
|
def test_model_and_standard_lists_are_filtered() -> None:
|
|
assert list_models()["count"] == 12
|
|
assert list_standards()["count"] == 3
|
|
|
|
|
|
def test_review_kit_exports_workflow_and_template() -> None:
|
|
payload = review_kit()
|
|
|
|
assert payload["ok"] is True
|
|
assert payload["review_kit"]["id"] == "review-kit/alignment"
|
|
assert payload["components"]["workflow"]["content"]["id"] == (
|
|
"review-kit/alignment/workflow"
|
|
)
|
|
assert "## Current Fit" in payload["template"]["content"]
|
|
|
|
|
|
def test_alignment_template_exports_content() -> None:
|
|
payload = alignment_template()
|
|
|
|
assert payload["ok"] is True
|
|
assert payload["path"] == "agent/templates/consumer-alignment-workplan.template.md"
|
|
assert "{{WORKPLAN_ID}}" in payload["content"]
|
|
|
|
|
|
def test_validate_canon_passes_scaffold() -> None:
|
|
payload = validate_canon()
|
|
|
|
assert payload["ok"] is True
|
|
assert payload["errors"] == []
|
|
assert "warnings" in payload
|
|
assert payload["details"]["artifact_count"] == 68
|
|
|
|
|
|
def test_graph_exports_relationship_summary() -> None:
|
|
payload = artifact_graph()
|
|
|
|
assert payload["ok"] is True
|
|
assert payload["graph"]["node_count"] == 68
|
|
assert payload["graph"]["edge_count"] > 15
|
|
|
|
|
|
def test_capability_review_joins_a_minimal_record(tmp_path) -> None:
|
|
record = {
|
|
"record_id": "test",
|
|
"requires": [
|
|
{
|
|
"capability": "data.backup",
|
|
"profile": "database",
|
|
"minimum_maturity": "D5",
|
|
}
|
|
],
|
|
"provisions": [
|
|
{
|
|
"provider": "test.backup",
|
|
"capability": "data.backup",
|
|
"profile": "database",
|
|
"maturity": "D4",
|
|
"uses_provisions": [
|
|
{
|
|
"capability": "data.object",
|
|
"provider": "test.object",
|
|
"relation": "depends_on",
|
|
}
|
|
],
|
|
"consumes": [
|
|
{
|
|
"class": "H",
|
|
"quantity": {"value": None, "unit": "hour"},
|
|
"basis": "unknown",
|
|
"gap": "not recorded (owner: test)",
|
|
}
|
|
],
|
|
}
|
|
],
|
|
}
|
|
path = tmp_path / "case.json"
|
|
path.write_text(json.dumps(record))
|
|
payload = review_capability_record(path)
|
|
assert payload["ok"] is True
|
|
assert payload["requirements"][0]["status"] == "below_requirement"
|
|
|
|
|
|
def test_small_saas_profile_validates() -> None:
|
|
payload = profile_validate("small-saas")
|
|
|
|
assert payload["ok"] is True
|
|
assert payload["errors"] == []
|
|
assert payload["details"]["kinds"]["tenant"] == 2
|
|
|
|
|
|
def test_small_saas_profile_graph_exports_slice() -> None:
|
|
payload = profile_graph("small-saas")
|
|
|
|
assert payload["ok"] is True
|
|
assert payload["profile"] == "small-saas"
|
|
assert "small-saas/service/billing-portal" in payload["graph"]["nodes"]
|
|
|
|
|
|
def test_generators_write_expected_assets(tmp_path) -> None:
|
|
root = tmp_path / "infospace"
|
|
shutil.copytree(DEFAULT_INFOSPACE_ROOT, root)
|
|
|
|
index_payload = generate_indexes(root)
|
|
tree_payload = generate_tree(root)
|
|
brief_payload = generate_agent_briefs(root)
|
|
|
|
assert index_payload["ok"] is True
|
|
assert tree_payload["ok"] is True
|
|
assert brief_payload["ok"] is True
|
|
assert (root / "indexes" / "concept-ownership.yaml").is_file()
|
|
assert (root / "views" / "by-standard.md").read_text(
|
|
encoding="utf-8"
|
|
).startswith("<!-- GENERATED")
|
|
assert (root / "agent" / "global-agent-brief.md").is_file()
|
|
assert (root / "agent" / "retrieval-index.md").is_file()
|
|
assert (root / "agent" / "retrieval-index.yaml").is_file()
|
|
assert (root / "agent" / "retrieval-index.json").is_file()
|
|
assert (root / "agent" / "briefs" / "model-access-control.md").is_file()
|
|
assert (
|
|
root / "agent" / "briefs" / "model-purpose-demand-extension.md"
|
|
).is_file()
|
|
assert (root / "agent" / "briefs" / "evaluation-user-engine.md").is_file()
|
|
assert (
|
|
root / "agent" / "briefs" / "conformance-railiance-fabric.md"
|
|
).is_file()
|
|
assert (
|
|
root / "agent" / "briefs" / "comparison-repo-scoping-report.md"
|
|
).is_file()
|
|
assert (
|
|
root / "agent" / "briefs" / "benchmark-caring-kubernetes-rbac.md"
|
|
).is_file()
|
|
assert (root / "agent" / "briefs" / "review-kit-alignment.md").is_file()
|
|
assert (
|
|
root / "agent" / "templates" / "consumer-alignment-workplan.template.md"
|
|
).is_file()
|
|
assert (root / "agent" / "briefs" / "pattern-intent-scope-purposes.md").is_file()
|
|
assert (
|
|
root / "agent" / "templates" / "canon-interface-card.template.yaml"
|
|
).is_file()
|
|
assert (root / "agent" / "consumer-briefs" / "user-engine.md").is_file()
|