fix(synastry): drop a section title repeated at the start of the body
The gate now rejects that opening and asks for a rewrite, and the saved text no longer keeps the duplicate. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -225,6 +225,15 @@ def _scan_prose(text: str, language: str, section: str, *, opening: bool) -> lis
|
||||
return failures
|
||||
|
||||
|
||||
def _opens_with_title(text: str, title: str) -> bool:
|
||||
heading = title.strip()
|
||||
body = text.lstrip()
|
||||
if not heading or not body.startswith(heading):
|
||||
return False
|
||||
rest = body[len(heading):]
|
||||
return rest == "" or rest[:1].isspace() or rest.startswith(heading)
|
||||
|
||||
|
||||
def validate_synastry_reader(
|
||||
delivery: dict[str, Any],
|
||||
section_inputs: dict[str, Any] | None = None,
|
||||
@@ -254,6 +263,9 @@ def validate_synastry_reader(
|
||||
failures.append(_fail(section_id, "missing_section", section_id))
|
||||
continue
|
||||
text = str(row.get("text") or "")
|
||||
title = str(row.get("title") or "")
|
||||
if _opens_with_title(text, title):
|
||||
failures.append(_fail(section_id, "repeated_heading", title))
|
||||
prose_characters += len(re.sub(r"\s+", "", text))
|
||||
prose_words += len(re.findall(r"\b[\w']+\b", text))
|
||||
minimum = ZH_SECTION_MINIMUM if language == "zh" else EN_SECTION_MINIMUM
|
||||
|
||||
Reference in New Issue
Block a user