feat: block Korean prose contract violations

This commit is contained in:
DongHyeonka
2026-07-29 18:30:10 +09:00
parent 4b7f1a90d2
commit d333e265b9
2 changed files with 72 additions and 0 deletions
+37
View File
@@ -15,6 +15,7 @@ from claridoc.models import (
)
from claridoc.style_contracts import (
KOREAN_EXPERIENCE_CONTRACT_ID,
first_person_metrics,
korean_experience_contract_applies,
plain_form_ending_locations,
)
@@ -213,6 +214,17 @@ def lint_document(text: str, brief: Brief, outline: Outline, sources: SourcePack
if style_contract_applies
else []
)
experience_metrics = (
first_person_metrics(text)
if style_contract_applies
else {
"first_person_marker_count": 0,
"opening_has_first_person": False,
"experience_section_count": 0,
"marked_experience_section_count": 0,
"experience_section_coverage": 0.0,
}
)
if plain_form_locations:
add(
"STYLE002",
@@ -227,6 +239,30 @@ def lint_document(text: str, brief: Brief, outline: Outline, sources: SourcePack
"current behavior. Preserve quoted material and code unchanged."
),
)
if (
style_contract_applies
and experience_metrics["experience_section_count"]
and (
not experience_metrics["opening_has_first_person"]
or experience_metrics["experience_section_coverage"] < 0.5
)
):
reasons: list[str] = []
if not experience_metrics["opening_has_first_person"]:
reasons.append("the opening has no 저는/제가 experience marker")
if experience_metrics["experience_section_coverage"] < 0.5:
reasons.append(
"fewer than half of substantive H2 sections establish first-person experience"
)
add(
"STYLE003",
Severity.BLOCKER,
"The Korean experience-prose contract is incomplete: " + "; ".join(reasons) + ".",
suggestion=(
"Use 저는 or 제가 where the opening and major transitions describe "
"a supported observation, action, or decision. Do not add invented experience."
),
)
long_paragraph_count = 0
crowded_paragraph_count = 0
long_sentence_count = 0
@@ -430,6 +466,7 @@ def lint_document(text: str, brief: Brief, outline: Outline, sources: SourcePack
else "none"
),
"plain_form_ending_count": len(plain_form_locations),
**experience_metrics,
"has_verification": has_verification,
"has_tradeoffs": has_tradeoffs,
"severity_counts": dict(severity_counts),