Skip to content

Commit 158b0f3

Browse files
committed
fix(ci): tighten issue-quality word count and fenced placeholders
Count Cyrillic/Greek/Arabic as real word tokens, reject fenced N/A-only examples, and cover the true 6-7 word concrete-detail boundary.
1 parent 70bb34b commit 158b0f3

2 files changed

Lines changed: 159 additions & 9 deletions

File tree

‎.github/scripts/issue-quality.cjs‎

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,32 @@
1313
const PLACEHOLDER_ONLY_RE =
1414
/^[\s_*~`]*(?:no\s+response|n\/?a|not\s+applicable|not\s+available|none|todo|tbd)[\s_*~`]*[.!?]*$/i;
1515

16+
/**
17+
* If `text` is exactly one enclosing fenced code block (``` or ~~~), return the
18+
* inner body; otherwise null. Real multi-statement fences are left alone by
19+
* the placeholder matcher after unwrap.
20+
*/
21+
function unwrapSingleEnclosingFence(text) {
22+
const trimmed = text.trim();
23+
const match = trimmed.match(/^(```|~~~)[^\n]*\r?\n([\s\S]*?)\r?\n\1[ \t]*$/);
24+
if (!match) return null;
25+
return match[2];
26+
}
27+
1628
function isPlaceholderOnlyValue(raw) {
1729
if (typeof raw !== "string") return false;
18-
const withoutComments = raw.replace(/<!--[\s\S]*?-->/g, "").trim();
19-
if (!withoutComments) return false;
20-
return PLACEHOLDER_ONLY_RE.test(withoutComments);
30+
let value = raw.replace(/<!--[\s\S]*?-->/g, "").trim();
31+
if (!value) return false;
32+
33+
// A lone fenced block whose entire body is a placeholder is still placeholder
34+
// text (e.g. ```text\nN/A\n```), not a real example.
35+
const unwrapped = unwrapSingleEnclosingFence(value);
36+
if (unwrapped !== null) {
37+
value = unwrapped.trim();
38+
if (!value) return false;
39+
}
40+
41+
return PLACEHOLDER_ONLY_RE.test(value);
2142
}
2243

2344
/**
@@ -26,6 +47,9 @@ function isPlaceholderOnlyValue(raw) {
2647
function clean(raw) {
2748
if (typeof raw !== "string") return "";
2849
let s = raw.replace(/<!--[\s\S]*?-->/g, "");
50+
// Whole-value placeholders first (including a single enclosing fence), so
51+
// line-by-line stripping cannot leave bare fence markers behind.
52+
if (isPlaceholderOnlyValue(s)) return "";
2953
// Treat placeholder-only lines (GitHub "No response", N/A, etc.) as empty.
3054
s = s
3155
.split("\n")
@@ -354,13 +378,20 @@ function isPlaceholder(text) {
354378
function countWords(text) {
355379
const c = clean(text);
356380
if (!c) return 0;
357-
const spaced = (c.match(/\b[\p{L}\p{N}']+\b/gu) || []).length;
381+
382+
// Use Unicode letter/number tokens so Cyrillic/Greek/Arabic words count as
383+
// one token each. `\b` is ASCII-only and would miss those scripts.
384+
const tokens = c.match(/[\p{L}\p{N}']+/gu) || [];
358385
const letters = (c.match(/\p{L}/gu) || []).length;
359-
if (spaced === 0) return letters;
360-
if (letters >= 8 && /[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u.test(c) && spaced < letters) {
386+
const containsCjk =
387+
/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u.test(c);
388+
389+
// CJK often has no whitespace-separated words; letter count is the detail proxy.
390+
if (containsCjk && letters >= 8) {
361391
return letters;
362392
}
363-
return spaced;
393+
394+
return tokens.length;
364395
}
365396

366397
function hasConcreteDetail(text) {
@@ -696,6 +727,8 @@ module.exports = {
696727
isPlaceholderOnlyValue,
697728
isPlaceholder,
698729
isRawPlaceholder,
730+
countWords,
731+
hasConcreteDetail,
699732
labelForKind,
700733
KIND_TO_LABEL,
701734
hasSubstantialStructuredContent,

‎.github/scripts/issue-quality.test.cjs‎

Lines changed: 119 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ const {
1515
isPlaceholderOnlyValue,
1616
isPlaceholder,
1717
isRawPlaceholder,
18+
countWords,
19+
hasConcreteDetail,
1820
rejectsWorkflowDispatchPullRequest,
1921
rejectsWorkflowDispatchNonDefaultBranch,
2022
} = require("./issue-quality.cjs");
@@ -34,6 +36,19 @@ function featureBodyWithGoal(goal) {
3436
].join("\n");
3537
}
3638

39+
function featureBodyWithExample(example) {
40+
return [
41+
"### What are you trying to accomplish?",
42+
"Route voice requests to a configured fallback provider when the primary quota is exhausted.",
43+
"### What prevents this today?",
44+
"Voice mode is hard-wired to the primary Codex quota and cannot switch providers.",
45+
"### What should OpenCodex do?",
46+
"Expose a setting to choose the fallback voice model and provider.",
47+
"### Example usage or interface",
48+
example,
49+
].join("\n");
50+
}
51+
3752
// ---------------------------------------------------------------------------
3853
// Detection
3954
// ---------------------------------------------------------------------------
@@ -303,6 +318,29 @@ describe("validateIssue - feature", () => {
303318
}
304319
});
305320

321+
it("rejects a single long non-CJK word as overly terse", () => {
322+
const terseGoals = [
323+
"провайдер",
324+
"маршрут",
325+
"πάροχος",
326+
"واجهة",
327+
];
328+
for (const goal of terseGoals) {
329+
assert.equal(countWords(goal), 1, `Expected "${goal}" to count as one word`);
330+
const result = validateIssue({
331+
title: "Improve feature request quality",
332+
body: featureBodyWithGoal(goal),
333+
labels: ["enhancement"],
334+
});
335+
assert.equal(result.kind, "feature");
336+
assert.equal(result.valid, false, `Expected terse goal "${goal}" to be invalid`);
337+
assert.ok(
338+
result.reasons.some((r) => r.includes("too vague")),
339+
`Expected too vague reason for "${goal}", got: ${result.reasons.join(", ")}`,
340+
);
341+
}
342+
});
343+
306344
it("accepts sufficiently detailed goal sections", () => {
307345
const detailedGoal =
308346
"Expose a dashboard setting to choose the fallback voice model and provider.";
@@ -313,8 +351,16 @@ describe("validateIssue - feature", () => {
313351
});
314352
assert.equal(detailedResult.kind, "feature");
315353
assert.equal(detailedResult.valid, true);
354+
assert.ok(countWords(detailedGoal) >= 8);
355+
});
356+
357+
it("accepts a 6-7 word goal when it includes concrete technical detail", () => {
358+
const concreteGoal = "Route requests through the configured API provider.";
359+
assert.equal(countWords(concreteGoal), 7);
360+
assert.ok(countWords(concreteGoal) < 8);
361+
assert.ok(countWords(concreteGoal) >= 6);
362+
assert.equal(hasConcreteDetail(concreteGoal), true);
316363

317-
const concreteGoal = "Route voice requests through the configured fallback API provider.";
318364
const concreteResult = validateIssue({
319365
title: "Voice fallback routing",
320366
body: featureBodyWithGoal(concreteGoal),
@@ -323,8 +369,73 @@ describe("validateIssue - feature", () => {
323369
assert.equal(concreteResult.kind, "feature");
324370
assert.equal(concreteResult.valid, true);
325371
});
326-
});
327372

373+
it("rejects a 6-7 word goal that lacks concrete technical detail", () => {
374+
// Avoid keywords that count as concrete detail (api/provider/workflow/…).
375+
const vagueGoal = "Make this process easier for all users.";
376+
assert.equal(countWords(vagueGoal), 7);
377+
assert.equal(hasConcreteDetail(vagueGoal), false);
378+
379+
const vagueResult = validateIssue({
380+
title: "Voice fallback routing",
381+
body: featureBodyWithGoal(vagueGoal),
382+
labels: ["enhancement"],
383+
});
384+
assert.equal(vagueResult.kind, "feature");
385+
assert.equal(vagueResult.valid, false);
386+
assert.ok(vagueResult.reasons.some((r) => r.includes("too vague")));
387+
});
388+
389+
it("rejects fenced placeholder-only examples", () => {
390+
const fencedPlaceholders = [
391+
"```\nN/A\n```",
392+
"```text\nN/A\n```",
393+
"```json\nNot applicable.\n```",
394+
"~~~text\nN/A\n~~~",
395+
];
396+
for (const example of fencedPlaceholders) {
397+
assert.equal(
398+
isPlaceholderOnlyValue(example),
399+
true,
400+
`Expected fenced placeholder to match: ${JSON.stringify(example)}`,
401+
);
402+
const result = validateIssue({
403+
title: "Voice fallback routing",
404+
body: featureBodyWithExample(example),
405+
labels: ["enhancement"],
406+
});
407+
assert.equal(result.valid, false, `Expected fenced placeholder to be invalid: ${JSON.stringify(example)}`);
408+
assert.ok(
409+
result.reasons.some((r) => r.includes("placeholder")),
410+
`Expected placeholder reason for ${JSON.stringify(example)}, got: ${result.reasons.join("; ")}`,
411+
);
412+
}
413+
});
414+
415+
it("accepts real fenced examples that merely mention N/A", () => {
416+
const realExamples = [
417+
"```text\nThe API returns N/A when no provider is configured.\n```",
418+
'```json\n{"provider":"N/A","fallback":"anthropic"}\n```',
419+
];
420+
for (const example of realExamples) {
421+
assert.equal(
422+
isPlaceholderOnlyValue(example),
423+
false,
424+
`Expected real example not to be placeholder-only: ${JSON.stringify(example)}`,
425+
);
426+
const result = validateIssue({
427+
title: "Voice fallback routing",
428+
body: featureBodyWithExample(example),
429+
labels: ["enhancement"],
430+
});
431+
assert.equal(
432+
result.valid,
433+
true,
434+
`Expected real fenced example to remain valid, got: ${result.reasons.join("; ")}`,
435+
);
436+
}
437+
});
438+
});
328439
// ---------------------------------------------------------------------------
329440
// Validation: bug
330441
// ---------------------------------------------------------------------------
@@ -608,6 +719,10 @@ describe("normalisation", () => {
608719
"Not applicable",
609720
"Not applicable.",
610721
"Not available!",
722+
"```\nN/A\n```",
723+
"```text\nN/A\n```",
724+
"```json\nNot applicable.\n```",
725+
"~~~text\nN/A\n~~~",
611726
];
612727
for (const value of placeholders) {
613728
assert.equal(isPlaceholderOnlyValue(value), true, value);
@@ -616,6 +731,8 @@ describe("normalisation", () => {
616731
assert.equal(clean(value), "", value);
617732
}
618733
assert.equal(isPlaceholderOnlyValue("Route voice traffic to provider N/A fallback"), false);
734+
assert.equal(isPlaceholderOnlyValue("```text\nThe API returns N/A when no provider is configured.\n```"), false);
735+
assert.equal(isPlaceholderOnlyValue('```json\n{"provider":"N/A","fallback":"anthropic"}\n```'), false);
619736
assert.equal(isPlaceholder("use CLI"), false);
620737
assert.equal(isRawPlaceholder(""), false);
621738
assert.equal(isRawPlaceholder(null), false);

0 commit comments

Comments
 (0)