You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2026/08/16 10:55:52 UTC

(shardingsphere) branch master updated: Refine documentation wording rules and policy canaries (#39487)

This is an automated email from the ASF dual-hosted git repository.

terrymanu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new ead5993a981 Refine documentation wording rules and policy canaries (#39487)
ead5993a981 is described below

commit ead5993a981309a124f067eb6d89c077c69e7b59
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Sun Aug 16 18:55:46 2026 +0800

    Refine documentation wording rules and policy canaries (#39487)
---
 .codex/harness/agents/cases.toml  | 88 +++++++++++++++++++++++++++++++++++++++
 .codex/harness/agents/run.py      | 18 ++++++++
 .codex/harness/agents/test_run.py | 50 ++++++++++++++++++++++
 AGENTS.md                         | 22 ++++++----
 4 files changed, 170 insertions(+), 8 deletions(-)

diff --git a/.codex/harness/agents/cases.toml b/.codex/harness/agents/cases.toml
index 1186d25d524..9eaef07bc7e 100644
--- a/.codex/harness/agents/cases.toml
+++ b/.codex/harness/agents/cases.toml
@@ -703,6 +703,94 @@ max_summary_chars = 110
 required_summary_prefix = "Parser adapters must not reference LegacyNode. Before invoking an adapter, verify that strict mode is enabled."
 critical = true
 
+[[cases]]
+id = "documentation_wording_replaces_abstract_fields"
+group = "reasoning"
+description = "Requires abstract field labels to become a concrete check, action, and failure result."
+phase = "documentation wording review and ordinary completion loop"
+ordinary_loop = true
+prompt = "This is a self-contained wording request; do not edit a local artifact. Rewrite the field-style text as one direct sentence and return only the revised rule: `Authority source: API schema. Constraint strength: mandatory. Compatibility goal: preserve compatibility. Check object: each changed key. Action: reject the change. Problem result: the key differs from the schema.`"
+decision = "proceed"
+required_actions = []
+allowed_actions = []
+forbidden_actions = ["edit_code", "edit_non_code", "mutate_git", "mutate_remote"]
+required_reasons = ["documentation_wording_required"]
+response_style = "concise"
+max_summary_chars = 160
+required_summary_terms = ["changed key", "API schema", "reject", "differs", "compatibility"]
+forbidden_summary_terms = ["Authority source", "Constraint strength", "Compatibility goal", "Check object", "Action:", "Problem result"]
+critical = true
+
+[[cases]]
+id = "documentation_wording_removes_redundant_structure"
+group = "reasoning"
+description = "Removes a repeated heading, a non-comparative table, field-style fragments, and a duplicate summary from a short document."
+phase = "documentation wording review and ordinary completion loop"
+ordinary_loop = true
+prompt = "This is a self-contained wording request; do not edit a local artifact. Rewrite this short document without redundant structure and return only the revision: `## Validation\n\n### Validation\n\n| Field | Value |\n| --- | --- |\n| Scope | YAML keys. |\n| Rule | Reject unknown keys. |\n| Check | Compare them with the schema. |\n\n**Summary:** Reject unknown YAML keys.`"
+decision = "proceed"
+required_actions = []
+allowed_actions = []
+forbidden_actions = ["edit_code", "edit_non_code", "mutate_git", "mutate_remote"]
+required_reasons = ["documentation_wording_required"]
+response_style = "concise"
+max_summary_chars = 100
+required_summary_terms = ["## YAML", "schema", "reject", "unknown"]
+forbidden_summary_terms = ["###", "|", "**Summary:**"]
+critical = true
+
+[[cases]]
+id = "documentation_wording_uses_established_term"
+group = "reasoning"
+description = "Replaces a coined umbrella term with the established project term."
+phase = "documentation wording review and ordinary completion loop"
+ordinary_loop = true
+prompt = "This is a self-contained wording request; do not edit a local artifact. In this repository, `validate configuration` is the established term for comparing configuration keys with the schema and rejecting unknown keys. Rewrite this sentence and return only the revised rule: `Perform configuration-schema congruence before loading.`"
+decision = "proceed"
+required_actions = []
+allowed_actions = []
+forbidden_actions = ["edit_code", "edit_non_code", "mutate_git", "mutate_remote"]
+required_reasons = ["documentation_wording_required"]
+response_style = "concise"
+max_summary_chars = 60
+required_summary_terms = ["validate", "configuration", "before loading"]
+forbidden_summary_terms = ["congruence"]
+critical = true
+
+[[cases]]
+id = "documentation_wording_keeps_sentence_on_one_line"
+group = "reasoning"
+description = "Keeps a complete sentence on one physical line."
+phase = "documentation wording review and ordinary completion loop"
+ordinary_loop = true
+prompt = "This is a self-contained wording request; do not edit a local artifact. Return one Markdown bullet, keep its complete sentence on one physical line, and return only the revision: `Reject unknown keys when\nloading configuration.`"
+decision = "proceed"
+required_actions = []
+allowed_actions = []
+forbidden_actions = ["edit_code", "edit_non_code", "mutate_git", "mutate_remote"]
+required_reasons = ["documentation_wording_required"]
+response_style = "concise"
+max_summary_chars = 49
+required_summary_prefix = "- Reject unknown keys when loading configuration."
+critical = true
+
+[[cases]]
+id = "documentation_wording_preserves_complete_policy"
+group = "reasoning"
+description = "Preserves scope, obligation strength, a verified exception, and its verification duty while simplifying policy text."
+phase = "documentation wording review and ordinary completion loop"
+ordinary_loop = true
+prompt = "This is a self-contained wording request; do not edit a local artifact. In this repository, `reference LegacyNode` is the established term for importing it, creating its instances, or using type checks against it. The migration-test fixture exception is verified and permits that reference only while reading archived v1 snapshots. Simplify this policy and return only the revised rule: `Every parser adapter must not import LegacyNode, create LegacyNode instances, or use type chec [...]
+decision = "proceed"
+required_actions = []
+allowed_actions = []
+forbidden_actions = ["edit_code", "edit_non_code", "mutate_git", "mutate_remote"]
+required_reasons = ["documentation_wording_required"]
+response_style = "concise"
+max_summary_chars = 280
+required_summary_terms = ["Parser adapters must not reference LegacyNode", "Migration-test fixtures may reference", "only while reading archived v1 snapshots", "Before release", "inspect every parser adapter and migration-test fixture", "no other LegacyNode reference remains"]
+critical = true
+
 [[cases]]
 id = "meaningless_getter_test"
 group = "coding / tests"
diff --git a/.codex/harness/agents/run.py b/.codex/harness/agents/run.py
index 3aa77c2d277..f88946726cd 100644
--- a/.codex/harness/agents/run.py
+++ b/.codex/harness/agents/run.py
@@ -207,6 +207,10 @@ def validate_cases(cases: list[dict[str, Any]]) -> None:
         if "required_summary_prefix" in each:
             if not isinstance(each["required_summary_prefix"], str) or not each["required_summary_prefix"]:
                 raise ValueError(f"Required summary prefix must be a non-empty string for case: {each['id']}")
+        for field in ("required_summary_terms", "forbidden_summary_terms"):
+            terms = each.get(field)
+            if field in each and (not isinstance(terms, list) or not terms or any(not isinstance(term, str) or not term for term in terms)):
+                raise ValueError(f"Summary terms must be a non-empty list of non-empty strings for case: {each['id']}")
 
 
 def load_cases(case_ids: list[str] | None) -> list[dict[str, Any]]:
@@ -295,6 +299,9 @@ def normalize_case_contracts(cases: list[dict[str, Any]]) -> list[dict[str, Any]
             contract["max_summary_chars"] = each["max_summary_chars"]
         if "required_summary_prefix" in each:
             contract["required_summary_prefix"] = each["required_summary_prefix"]
+        for field in ("required_summary_terms", "forbidden_summary_terms"):
+            if field in each:
+                contract[field] = sorted(each[field])
         contracts.append(contract)
     return sorted(contracts, key=lambda each: each["id"])
 
@@ -551,6 +558,17 @@ def grade(cases: list[dict[str, Any]], actual: dict[str, Any]) -> list[dict[str,
                 failures.append(
                     f"summary does not start with required prefix={expected['required_summary_prefix']!r}"
                 )
+            folded_summary = summary.casefold()
+            missing_summary_terms = [
+                each for each in expected.get("required_summary_terms", []) if each.casefold() not in folded_summary
+            ]
+            forbidden_summary_terms = [
+                each for each in expected.get("forbidden_summary_terms", []) if each.casefold() in folded_summary
+            ]
+            if missing_summary_terms:
+                failures.append(f"summary lacks required terms={missing_summary_terms}")
+            if forbidden_summary_terms:
+                failures.append(f"summary contains forbidden terms={forbidden_summary_terms}")
             if "max_summary_chars" in expected and len(summary) > expected["max_summary_chars"]:
                 failures.append(
                     f"summary characters={len(summary)} maximum={expected['max_summary_chars']}"
diff --git a/.codex/harness/agents/test_run.py b/.codex/harness/agents/test_run.py
index ba5310b0ad9..35457b19355 100644
--- a/.codex/harness/agents/test_run.py
+++ b/.codex/harness/agents/test_run.py
@@ -75,6 +75,21 @@ class RunTest(unittest.TestCase):
         with self.assertRaisesRegex(ValueError, "Unknown reasons"):
             run.validate_cases([self.case])
 
+    def test_summary_terms_must_be_list(self) -> None:
+        self.case["required_summary_terms"] = "term"
+        with self.assertRaisesRegex(ValueError, "Summary terms must be a non-empty list"):
+            run.validate_cases([self.case])
+
+    def test_summary_terms_must_not_be_empty(self) -> None:
+        self.case["required_summary_terms"] = []
+        with self.assertRaisesRegex(ValueError, "Summary terms must be a non-empty list"):
+            run.validate_cases([self.case])
+
+    def test_summary_terms_must_contain_non_empty_strings(self) -> None:
+        self.case["forbidden_summary_terms"] = [""]
+        with self.assertRaisesRegex(ValueError, "Summary terms must be a non-empty list"):
+            run.validate_cases([self.case])
+
     def test_required_action_must_be_allowed(self) -> None:
         self.case["required_actions"] = ["inspect_local"]
         with self.assertRaisesRegex(ValueError, "Required actions must be allowed"):
@@ -169,6 +184,41 @@ class RunTest(unittest.TestCase):
                 "output_tokens": 6,
             }, run.read_usage(events_path))
 
+    def test_normalize_case_contracts_sorts_summary_terms(self) -> None:
+        self.case["required_summary_terms"] = ["beta", "alpha"]
+        self.case["forbidden_summary_terms"] = ["delta", "gamma"]
+        actual = run.normalize_case_contracts([self.case])[0]
+        self.assertEqual(["alpha", "beta"], actual["required_summary_terms"])
+        self.assertEqual(["delta", "gamma"], actual["forbidden_summary_terms"])
+
+    def test_grade_checks_summary_terms_case_insensitively(self) -> None:
+        self.case["required_summary_terms"] = ["required term"]
+        self.case["forbidden_summary_terms"] = ["internal label"]
+        actual = {"results": [{
+            "case_id": self.case["id"],
+            "decision": "proceed",
+            "actions": [],
+            "reasons": [],
+            "summary": "The REQUIRED TERM replaces the Internal Label.",
+            "response_style": "concise",
+        }]}
+        failures = run.grade([self.case], actual)[0]["failures"]
+        self.assertNotIn("summary lacks required terms=['required term']", failures)
+        self.assertIn("summary contains forbidden terms=['internal label']", failures)
+
+    def test_grade_reports_missing_summary_terms(self) -> None:
+        self.case["required_summary_terms"] = ["required term"]
+        actual = {"results": [{
+            "case_id": self.case["id"],
+            "decision": "proceed",
+            "actions": [],
+            "reasons": [],
+            "summary": "The required content is absent.",
+            "response_style": "concise",
+        }]}
+        failures = run.grade([self.case], actual)[0]["failures"]
+        self.assertIn("summary lacks required terms=['required term']", failures)
+
 
 if __name__ == "__main__":
     unittest.main()
diff --git a/AGENTS.md b/AGENTS.md
index c5262a98a28..09afd8144f0 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -453,14 +453,20 @@ not expand scope or rewrite unrelated existing code.
 
 Apply this section whenever creating or revising documentation, Skills, prompts, comments, configuration descriptions, or other prose.
 
-- Identify the core rule, fact, or action first, then state it directly.
-- Do not enumerate multiple concrete actions or manifestations when one established term expresses the same requirement.
-- Merge adjacent statements that express the same rule or where one statement fully includes another.
-- Keep an exception only when a real allowed case has been verified and state its exact boundary. Do not add speculative or overly broad exceptions.
-- Keep examples only when they add an independent decision condition or materially help execution. Otherwise remove them or separate them from the rule.
-- Simplification must preserve the original scope, obligation strength, valid exceptions, and verification requirements.
-- Do not shorten mechanically or replace precise technical language with casual wording. The result must be understandable without requiring the reader to infer the underlying rule.
-- Before handoff, review every changed prose statement against these requirements.
+- Make each rule understandable to people and Codex on the first reading. State what to inspect, what action to take, what result identifies a problem, and how to verify it; labels such as `authority source`, `constraint strength`, `behavior value`, or `proper ownership` do not replace these instructions.
+- State the core rule, fact, or action first. Follow it with necessary applicability conditions, exceptions, and verification methods in that order.
+- Use established project technical terms. Do not coin uncommon umbrella terms; when an unavoidable technical term first appears, immediately explain what it means.
+- Express one main rule per sentence and do not compress multiple decisions into a difficult long sentence. When one established term fully expresses a requirement, use it instead of enumerating synonymous actions or manifestations.
+- Use professional, direct, specific, and concise language. Avoid bureaucratic or academic phrasing, excessive informality, and mechanical shortening that replaces precise technical language with casual wording.
+- State each requirement once and merge adjacent statements when one repeats or fully includes another. For Skills, keep the core workflow and reference routing in `SKILL.md`, specific decisions in its referenced files, and concrete rules in `references/rules/`; do not duplicate the same content across files.
+- Give every Skill and audit category a distinct, accurately named responsibility. Do not use vague names to hide overlapping responsibilities or duplicate work owned by another specialized Skill.
+- Use lists only for genuinely parallel rules, categories, or steps, and use tables only when readers need a column-by-column comparison. Express content that fits in one sentence as prose instead of a field-style list.
+- Make each heading name its specific subject and purpose without repeating its parent heading. A title such as `Validation` is insufficient when the section only covers YAML keys. In a short document, omit overview tables, key-point checklists, tables of contents, and repeated summaries that have no independent purpose.
+- Keep an exception only when a real allowed case has been verified. State why it is allowed and its exact boundary; do not add speculative or overly broad exceptions.
+- Keep an example only when it resolves ambiguity, adds an independent decision condition, or materially helps execution. Otherwise remove it or separate it from the rule.
+- Simplification must preserve the original scope, obligation strength, valid exceptions, and verification requirements. Do not shorten mechanically or make readers infer a rule that the original text stated explicitly.
+- Keep each new or changed complete sentence on one physical line, and break a line only after punctuation ends the complete sentence. Do not reflow untouched text merely to make formatting consistent. Never modify ASF license text or its internal formatting.
+- Before handoff, review every changed prose sentence and rewrite any sentence that does not let a reader directly identify what to inspect, what result is a problem, which exceptions apply, and how to verify it.
 
 ## Test Rules