teleo-infrastructure/tests/test_hermes_leoclean_skill_surfaces.py
2026-07-12 10:57:54 +02:00

142 lines
6.9 KiB
Python

from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
SKILL_ROOT = ROOT / "hermes-agent" / "leoclean-skills"
def test_gcp_kb_skill_uses_cloudsql_bridge_not_vps_docker() -> None:
text = (SKILL_ROOT / "gcp" / "teleo-kb-bridge" / "SKILL.md").read_text()
squashed = " ".join(text.split())
assert "Cloud SQL" in text
assert "answer from the Cloud SQL KB after a bounded read" in text
assert "Do not browse the public web just because the KB has evidence gaps" in text
assert "/home/teleo/.hermes/profiles/leoclean/bin/teleo-kb" in text
assert "search-proposals" in text
assert "decision-matrix-status" in text
assert "list-proposals --status all" in text
assert "Do not answer" in text or "do not infer matrix approval" in text
assert "Next Cory-style follow-up" in text
assert "Always include the final line label" in text
assert "Cory Direct-Claim Answer Contract" in text
assert "not just pointer mismatch" in text
assert "staging write to `kb_stage.kb_proposals`" in squashed
assert "demo tier" in text
assert "Approved is not the same as applied" in squashed
assert "applied_at: NULL" in text
assert "not applied" in text
assert "canonical KB change not safe to demo from chat" in squashed
assert "not provable from chat" in text
assert "equivalent GCP execution is not yet proven" in squashed
assert "false global statement that no apply tooling exists" in squashed
assert "DB readback:" in text
assert "full UUID plus observed `status` and `applied_at`" in squashed
assert "Short eight-character IDs" in text
assert "PROPOSAL_UUID_36_CHARS" in text
assert "OBSERVED_STATUS" in text
assert "OBSERVED_TIMESTAMP_OR_NONE" in text
assert "claims: `N`; sources: `N`; claim_edges: `N`; claim_evidence: `N`; kb_proposals: `N`" in text
assert "Never shorten a UUID" in text
assert "Do not paraphrase a count" in text
assert "`N/A` and `see public.*` are invalid" in squashed
assert "canonical identity requires DB rows plus" in squashed
assert "not canonical Postgres" in text
assert "not the source of truth" in text
assert "not a canonical commit" in text
assert "not collective truth" in text
assert "Row-level proof would require current readback" in text
assert "new or updated row IDs" in text
assert "I cannot claim canonical DB changed" in text
assert "explicit operator/admin authorization" in text
assert "docker exec" not in text
assert "teleo-pg" not in text
assert "on the VPS" not in text
def test_vps_kb_skill_keeps_vps_scope_explicit() -> None:
text = (SKILL_ROOT / "vps" / "teleo-kb-bridge" / "SKILL.md").read_text()
squashed = " ".join(text.split())
assert "VPS production leoclean" in text
assert "Cloud SQL" not in text
assert "/home/teleo/.hermes/profiles/leoclean/bin/teleo-kb" in text
assert "prefer the bridge over raw database access" in text
assert "Claim / Body / Concept Map Loop" in text
assert "Status: applied | pending | missing | partially applied" in text
assert "search-proposals" in text
assert "decision-matrix-status" in text
assert "list-proposals --status all" in text
assert "do not infer matrix approval" in text
assert "approved/staged or packet-ready but not canonical" in text
assert "Next Cory-style follow-up" in text
assert "Always include the final line label" in text
assert "Cory Direct-Claim Answer Contract" in text
assert "not just pointer mismatch" in text
assert "staging write to `kb_stage.kb_proposals`" in squashed
assert "demo tier" in text
assert "Approved is not the same as applied" in squashed
assert "applied_at: NULL" in text
assert "not applied" in text
assert "canonical KB change not safe to demo from chat" in squashed
assert "not provable from chat" in text
assert "production permission migration and apply worker remain disabled" in squashed
assert "false global statement that no apply tooling exists" in squashed
assert "DB readback:" in text
assert "full UUID plus observed `status` and `applied_at`" in squashed
assert "Short eight-character IDs" in text
assert "PROPOSAL_UUID_36_CHARS" in text
assert "OBSERVED_STATUS" in text
assert "OBSERVED_TIMESTAMP_OR_NONE" in text
assert "claims: `N`; sources: `N`; claim_edges: `N`; claim_evidence: `N`; kb_proposals: `N`" in text
assert "Never shorten a UUID" in text
assert "Do not paraphrase a count" in text
assert "`N/A` and `see public.*` are invalid" in squashed
assert "canonical identity requires DB rows plus" in squashed
assert "not canonical Postgres" in text
assert "not the source of truth" in text
assert "not a canonical commit" in text
assert "not collective truth" in text
assert "Row-level proof would require current readback" in text
assert "new or updated row IDs" in text
assert "I cannot claim canonical DB changed" in text
assert "explicit operator/admin authorization" in text
assert "Do not call an approved proposal \"implemented\"" in text
assert "repository contains a live-proven strict existing-ID `add_edge` path" in squashed
assert "Never end a normal Telegram answer by offering to run direct `INSERT`, `UPDATE`" in text
assert "Next admin-panel action" in text
assert "draft or refresh the admin review packet" in squashed
assert "/kb/claims/<claim_id>" in text
assert "wrap claim IDs, proposal IDs" in text
assert "claim page: https://leo.livingip.xyz/kb/claims/<claim_id>" in text
assert "search-proposals" in text
assert "decision-matrix-status" in text
def test_gcp_kb_skill_keeps_claim_links_and_backtick_rendering() -> None:
text = (SKILL_ROOT / "gcp" / "teleo-kb-bridge" / "SKILL.md").read_text()
assert "/kb/claims/<claim_id>" in text
assert "wrap claim IDs, proposal IDs" in text
assert "claim page: https://leo.livingip.xyz/kb/claims/<claim_id>" in text
def test_leoclean_kb_skills_anchor_external_doctrine_in_target_project_language() -> None:
for surface in ("vps", "gcp"):
text = (SKILL_ROOT / surface / "teleo-kb-bridge" / "SKILL.md").read_text()
assert "External Doctrine Contributions" in text
assert "Use the target project's native language first" in text
assert "no single voice can own understanding" in text
assert "purpose precedes" in text
assert "Prefer issue-before-PR" in text
assert "Consent is action-specific" in text
def test_vps_live_telegram_skill_uses_systemd_for_gateway_liveness() -> None:
text = (SKILL_ROOT / "vps" / "live-leo-telegram" / "SKILL.md").read_text()
assert "systemctl is-active leoclean-gateway.service" in text
assert "systemctl show leoclean-gateway.service" in text
assert "hermes -p leoclean gateway run" in text
assert "Do not use `hermes -p leoclean gateway status` as authoritative" in text
assert "If you are currently replying in Telegram" in text