generated from coulomb/repo-seed
Some checks failed
ci / validate-registry (push) Has been cancelled
Add stats, establish (scaffold, publish-check, discover), and update CLI commands with optional llm-connect bridge, validate --root for sibling repos, pytest coverage, and documentation for sibling registry onboarding.
87 lines
2.9 KiB
Python
87 lines
2.9 KiB
Python
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
import yaml
|
|
|
|
from reuse_surface.establish import scaffold_registry
|
|
from reuse_surface.registry import load_index_at, registry_paths
|
|
from reuse_surface.registry_update import (
|
|
apply_deterministic_suggestions,
|
|
collect_deterministic_suggestions,
|
|
)
|
|
|
|
|
|
def _write_minimal_entry(tmp_path: Path, cap_id: str, vector: str) -> str:
|
|
rel = "registry/capabilities/capability-demo-sample.md"
|
|
d, a, c, r = [part.strip() for part in vector.split("/")]
|
|
front_matter = {
|
|
"id": cap_id,
|
|
"name": "Sample",
|
|
"summary": "Sample",
|
|
"owner": "demo",
|
|
"status": "draft",
|
|
"domain": "helix_forge",
|
|
"tags": ["demo"],
|
|
"maturity": {
|
|
"discovery": {"current": d, "target": "D5", "confidence": "low"},
|
|
"availability": {"current": a, "target": "A3", "confidence": "low"},
|
|
},
|
|
"external_evidence": {
|
|
"completeness": {"level": c, "confidence": "low"},
|
|
"reliability": {"level": r, "confidence": "low"},
|
|
},
|
|
"discovery": {"intent": "demo", "includes": [], "excludes": []},
|
|
"availability": {
|
|
"current_level": a,
|
|
"target_level": "A3",
|
|
"current_artifacts": [],
|
|
"consumption_modes": ["informational"],
|
|
},
|
|
"relations": {"depends_on": [], "supports": [], "related_to": []},
|
|
"evidence": {"documentation": [], "tests": []},
|
|
"consumer_guidance": {
|
|
"recommended_for": [],
|
|
"not_recommended_for": [],
|
|
"known_limitations": [],
|
|
},
|
|
}
|
|
path = tmp_path / rel
|
|
path.parent.mkdir(parents=True, exist_ok=True)
|
|
path.write_text(
|
|
"---\n"
|
|
+ yaml.safe_dump(front_matter, sort_keys=False)
|
|
+ "---\n",
|
|
encoding="utf-8",
|
|
)
|
|
return rel
|
|
|
|
|
|
def test_vector_drift_suggestion(tmp_path: Path):
|
|
scaffold_registry(tmp_path)
|
|
cap_id = "capability.demo.sample"
|
|
rel = _write_minimal_entry(tmp_path, cap_id, "D3 / A0 / C0 / R0")
|
|
index_path = registry_paths(tmp_path)["index"]
|
|
index = load_index_at(index_path)
|
|
index["capabilities"] = [
|
|
{
|
|
"id": cap_id,
|
|
"name": "Sample",
|
|
"summary": "Sample",
|
|
"vector": "D2 / A0 / C0 / R0",
|
|
"domain": "helix_forge",
|
|
"status": "draft",
|
|
"owner": "demo",
|
|
"path": rel,
|
|
"tags": ["demo"],
|
|
"consumption_modes": ["informational"],
|
|
}
|
|
]
|
|
index_path.write_text(yaml.safe_dump(index, sort_keys=False), encoding="utf-8")
|
|
|
|
suggestions = collect_deterministic_suggestions(tmp_path, capability_id=cap_id)
|
|
assert any(item["kind"] == "vector_drift" for item in suggestions)
|
|
changed = apply_deterministic_suggestions(tmp_path, suggestions)
|
|
assert changed
|
|
updated = load_index_at(index_path)
|
|
assert updated["capabilities"][0]["vector"] == "D3 / A0 / C0 / R0" |