@@ -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