11import { describe , expect , it } from "bun:test" ;
2- import { promptResidual } from "./model-family-policy.js" ;
2+ import { GROK_PROMPT_RESIDUAL } from "./model-family-policy.js" ;
33import {
44 buildGrokLeafAntiThrashNote ,
55 buildSubAgentSystemPrompt ,
66} from "./prompts.js" ;
7+ import { shouldApplyGrokAntiThrash } from "../subagent/provider-family.js" ;
78
89// The three Grok ceremony lines (CL-7768 Design, merged by CL-8296): no git,
910// no pre-plan, verify once.
@@ -19,28 +20,47 @@ function countOccurrences(haystack: string, needle: string): number {
1920
2021describe ( "grok ceremony merge (CL-8296)" , ( ) => {
2122 it ( "exposes a single grok residual with each ceremony line exactly once" , ( ) => {
22- const residual = promptResidual ( "grok" ) ;
23- expect ( residual ) . toContain ( "Finish bias (xAI / Grok worker):" ) ;
23+ expect ( GROK_PROMPT_RESIDUAL ) . toContain ( "Finish bias (xAI / Grok worker):" ) ;
2424 for ( const line of CEREMONY_LINES ) {
25- expect ( countOccurrences ( residual , line ) ) . toBe ( 1 ) ;
25+ expect ( countOccurrences ( GROK_PROMPT_RESIDUAL , line ) ) . toBe ( 1 ) ;
2626 }
2727 } ) ;
2828
2929 it ( "keeps the don't re-read line exactly once — no duplicate" , ( ) => {
30- const residual = promptResidual ( "grok" ) ;
31- expect ( countOccurrences ( residual , "re-open paths you already read" ) ) . toBe (
32- 1 ,
33- ) ;
30+ expect (
31+ countOccurrences ( GROK_PROMPT_RESIDUAL , "re-open paths you already read" ) ,
32+ ) . toBe ( 1 ) ;
3433 } ) ;
3534
36- it ( "is grok-only: every other family resolves to an empty residual" , ( ) => {
37- expect ( promptResidual ( "default" ) ) . toBe ( "" ) ;
38- expect ( promptResidual ( "kimi" ) ) . toBe ( "" ) ;
39- expect ( promptResidual ( "muse" ) ) . toBe ( "" ) ;
35+ it ( "is grok-only: the finish-bias gate fires for grok leaves alone" , ( ) => {
36+ expect (
37+ shouldApplyGrokAntiThrash ( {
38+ providerName : "xai/default" ,
39+ model : "grok-4.6" ,
40+ orchestrator : false ,
41+ } ) ,
42+ ) . toBe ( true ) ;
43+ for ( const input of [
44+ { providerName : "anthropic" , model : "claude-sonnet-4" } ,
45+ { providerName : "moonshot" , model : "kimi-k2" } ,
46+ { providerName : "opencode-go" , model : "muse-spark-1.3-contributor" } ,
47+ { providerName : "openai" , model : "gpt-4.1" } ,
48+ ] as const ) {
49+ expect ( shouldApplyGrokAntiThrash ( { ...input , orchestrator : false } ) ) . toBe (
50+ false ,
51+ ) ;
52+ }
53+ expect (
54+ shouldApplyGrokAntiThrash ( {
55+ providerName : "xai/default" ,
56+ model : "grok-4.6" ,
57+ orchestrator : true ,
58+ } ) ,
59+ ) . toBe ( false ) ;
4060 } ) ;
4161
4262 it ( "buildGrokLeafAntiThrashNote is the same single residual (one source of truth)" , ( ) => {
43- expect ( buildGrokLeafAntiThrashNote ( ) ) . toBe ( promptResidual ( "grok" ) ) ;
63+ expect ( buildGrokLeafAntiThrashNote ( ) ) . toBe ( GROK_PROMPT_RESIDUAL ) ;
4464 } ) ;
4565
4666 it ( "the assembled grok worker prompt carries the merged residual exactly once" , ( ) => {
0 commit comments