Skip to content

feat(schema): enforce no-whitespace in tags via pattern ^\\S+$#197

Closed
mingcha-dev wants to merge 1 commit into
mainfrom
mingcha/schema-tags-no-whitespace
Closed

feat(schema): enforce no-whitespace in tags via pattern ^\\S+$#197
mingcha-dev wants to merge 1 commit into
mainfrom
mingcha/schema-tags-no-whitespace

Conversation

@mingcha-dev
Copy link
Copy Markdown
Collaborator

Summary

Adds hard schema-level enforcement that tags must not contain whitespace.

"items": {
-  "type": "string"
+  "type": "string",
+  "pattern": "^\\\\S+$"
}

Also updates description to state the rule + acronym-case convention.

Why

Tags containing spaces (e.g. "economic growth") break tokenizer/index semantics. Schema description has always said "mixed Chinese/English keywords" and examples always used hyphens (economic-growth), but there was no enforcement. This PR closes the gap.

Prereq

Merged PR #196 cleaned up 322 existing files (2967 space-tag violations → 0). Main is clean; this PR just locks the door behind us.

Validation

Ran make validate against current main — all files pass.

Three-way context

Ref: 2026-04-30 alignment (明鉴/墨子/明察). This is the 2nd of 2 back-to-back PRs.

  1. PR chore: normalize whitespace in tags across all sources (keep Chinese) #196 cleanup (merged) ✅
  2. This PR (enforcement)

Convention (documented in description)

Checklist

  • make validate passes on main
  • Schema still allows mixed CN/EN
  • No source file changes
  • Description free of banned terms

Adds hard schema-level enforcement that tags must not contain whitespace.
This prevents tags like 'economic growth' from being introduced — authors
must use 'economic-growth' instead.

Changes:
- tags.items gains 'pattern': '^\\S+$'
- Description updated with explicit rule + case preservation convention

Prereq satisfied by PR #196 (cleanup of 322 existing files to remove
whitespace before enforcing the pattern).

Tested: 'make validate' passes against current main (0 violations).

Ref: three-way review 2026-04-30 (明鉴/墨子/明察)
@mingcha-dev
Copy link
Copy Markdown
Collaborator Author

protect-schema CI 规则:schema 改动必须直接 commit to main by maintainer,不能走 PR。

关闭此 PR。合适做法:

  1. 在 main 分支直接 commit schema diff
  2. 或老板配 bypass rule 给 trusted role

schema 改动内容(pattern + description 更新)已 ready,可由有权限人直接 commit。

Copy link
Copy Markdown
Collaborator

@firstdata-dev firstdata-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved ✅

  • Schema change 最小:items 加 "pattern": "^\\S+$" + description 标注

Copy link
Copy Markdown
Collaborator

@firstdata-dev firstdata-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved ✅ schema 变更最小(items pattern + description)。本地 make validate 在 origin/main 全库通过。

@mingcha-dev mingcha-dev deleted the mingcha/schema-tags-no-whitespace branch April 30, 2026 03:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants