Repository navigation
feat(quality): require the prose a Korean customer reads to be Korean #61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
seonghobae
wants to merge
1
commit into
main
Choose a base branch
from
claude/require-korean-report-prose
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| """Require the prose a Korean customer reads to actually be Korean. | ||
|
|
||
| Every other customer-visible property is checked before a report is published: | ||
| the required sections exist, each has an opportunity, a caution and an action, | ||
| no ungrounded 간지 appears, forbidden and vague copy is rejected, and the | ||
| disclaimer carries its required terms. Nothing checked the language. | ||
|
|
||
| That is not theoretical. The schema-repair turn in `nim.py` appends the pydantic | ||
| error text and the full JSON Schema, both English, to the conversation and then | ||
| asks for the complete answer again, which is a known way to pull a model's | ||
| output language across. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import pytest | ||
| from test_quality import FINGERPRINT, valid_report | ||
|
|
||
| from four_pillars.quality import validate_report | ||
|
|
||
| CODE = "foreign_language" | ||
|
|
||
|
|
||
| def _english_body(report): | ||
| """Replace the reader-visible prose with English, leaving identifiers alone.""" | ||
| for key, section in report.sections.items(): | ||
| section.title = key.replace("_", " ").title() | ||
| section.summary = "This section explains the calculation as a judgement aid." | ||
| section.opportunities = ["Confirming conditions makes a stable outcome possible."] | ||
| section.cautions = ["Do not treat future events as settled."] | ||
| section.actions = ["Record fact, impact, alternative, request."] | ||
| report.executive_summary = "A self-review document from traditional symbolism." | ||
| for skill in report.practical_skills: | ||
| skill.name = "Weekly review" | ||
| skill.purpose = "Detect overload early." | ||
| skill.steps = ["Write next week's three key events."] | ||
| skill.when_to_use = "When commitments rise together." | ||
| return report | ||
|
|
||
|
|
||
| def test_an_english_report_is_rejected() -> None: | ||
| """The whole body in English must not reach a Korean customer unchallenged.""" | ||
| codes = [issue.code for issue in validate_report(_english_body(valid_report()), FINGERPRINT)] | ||
|
|
||
| assert CODE in codes | ||
|
|
||
|
|
||
| def test_the_korean_fixture_still_passes() -> None: | ||
| """A report written in Korean gains nothing from this check.""" | ||
| assert validate_report(valid_report(), FINGERPRINT) == [] | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "field", | ||
| ["title", "summary", "opportunities", "cautions", "actions"], | ||
| ) | ||
| def test_one_english_field_in_one_section_is_enough_to_fail(field: str) -> None: | ||
| """A per-report ratio would miss this; the check is per reader-visible string.""" | ||
| report = valid_report() | ||
| english = "This single field drifted out of Korean." | ||
| section = report.sections["work"] | ||
| setattr(section, field, english if field in {"title", "summary"} else [english]) | ||
|
|
||
| assert CODE in [issue.code for issue in validate_report(report, FINGERPRINT)] | ||
|
|
||
|
|
||
| def test_a_latin_script_customer_name_is_not_a_violation() -> None: | ||
| """The subject's own name is theirs, not prose this product wrote.""" | ||
| report = valid_report() | ||
| report.subject_name = "Alex Marchetti" | ||
| report.title = f"{report.subject_name} 사주 보고서" | ||
|
|
||
| assert CODE not in [issue.code for issue in validate_report(report, FINGERPRINT)] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
정규화 후 한글을 검사하세요.
ReportDocument와ReportSection의 문자열 필드는 NFD 문자를 보존합니다. 따라서 독자용 필드에한글이 전달되면HANGUL과 일치하지 않아foreign_language오류가 발생합니다. 한국어 보고서 계약은 유효한 한국어 문장을 허용해야 하므로, 검사 전에 NFC로 정규화하세요.수정 예시
🤖 Prompt for AI Agents