sync-pilot / sync_pilot /taxonomy /source_policy.py
Emre Sarigöl
Deploy sync_pilot dashboard - 2026-06-10 16:43
a01358a
Raw
History Blame Contribute Delete
3.12 kB
"""Per-dimension evidence trust policy for taxonomy consumers."""
from __future__ import annotations
import hashlib
import json
from typing import Any
SOURCE_TRUST_POLICY: list[dict[str, Any]] = [
{
"dimension": "genre_family",
"trusted": ["groundtruth high/medium", "CLAP high score with MAEST/metadata support"],
"candidate_only": ["CLAP alone", "MAEST Discogs neighbor"],
"rule": "Use CLAP for Turkish-native genre only when corroborated; use MAEST as a Western crosswalk.",
},
{
"dimension": "genre_subtype",
"trusted": ["groundtruth high/medium", "deterministic title cue"],
"candidate_only": ["CLAP subtype prompts", "MAEST hints"],
"rule": "Do not present subtype as definitive from zero-shot audio alone.",
},
{
"dimension": "instrumentation",
"trusted": ["groundtruth credits", "stem-window high confidence"],
"candidate_only": ["CLAP instrument tags", "stem-window medium/low confidence"],
"rule": "Mention specific instruments only when GT/stem evidence supports them.",
},
{
"dimension": "vocal_configuration",
"trusted": ["groundtruth/review labels", "clear stem vocal presence"],
"candidate_only": ["CLAP vocal tags"],
"rule": "Use CLAP vocal configuration as a starting hypothesis for review, not as gold.",
},
{
"dimension": "vocal_technique",
"trusted": ["groundtruth/review labels"],
"candidate_only": ["CLAP technique prompts"],
"rule": "Do not assert hançere, gazel, or taverna technique unless reviewed or source-supported.",
},
{
"dimension": "mood",
"trusted": ["lyrics/themes", "review labels"],
"candidate_only": ["CLAP mood tags"],
"rule": "Let lyrics dominate mood when available; CLAP mood is weak cultural evidence.",
},
{
"dimension": "arrangement_aesthetic",
"trusted": ["groundtruth/review labels", "source-supported recording identity"],
"candidate_only": ["CLAP genre/instrument mixture"],
"rule": "Never infer production arrangement solely from CLAP.",
},
{
"dimension": "recording_context",
"trusted": ["groundtruth/review labels", "audible/source evidence"],
"candidate_only": ["CLAP/stem context hints"],
"rule": "Live, broadcast, lo-fi, and studio context need explicit evidence.",
},
]
def source_policy_hash() -> str:
payload = json.dumps(SOURCE_TRUST_POLICY, sort_keys=True, ensure_ascii=False)
return hashlib.sha256(payload.encode("utf-8")).hexdigest()[:12]
def format_source_policy_for_prompt() -> str:
rows: list[str] = []
for item in SOURCE_TRUST_POLICY:
rows.append(
"- {dimension}: trusted={trusted}; candidate_only={candidate_only}; rule={rule}".format(
dimension=item["dimension"],
trusted=", ".join(item["trusted"]),
candidate_only=", ".join(item["candidate_only"]),
rule=item["rule"],
)
)
return "\n".join(rows)