@@ -129,6 +129,42 @@ function parseRFCNumber(filename: string): string {
129129 return match ?. [ 1 ] ?? "0000" ;
130130}
131131
132+ interface ValidationError {
133+ filename : string ;
134+ message : string ;
135+ }
136+
137+ async function validateProposals ( ) : Promise < ValidationError [ ] > {
138+ const errors : ValidationError [ ] = [ ] ;
139+ const glob = new Bun . Glob ( "*" ) ;
140+ const seenNumbers = new Map < string , string > ( ) ;
141+
142+ for await ( const filename of glob . scan ( "./proposals" ) ) {
143+ // Check filename format: NNNN-slug.md
144+ if ( ! filename . match ( / ^ \d { 4 } - [ a - z A - Z 0 - 9 _ - ] + \. m d $ / ) ) {
145+ errors . push ( {
146+ filename,
147+ message : `Invalid filename format. Expected: NNNN-name.md (e.g., 0007-my-proposal.md)` ,
148+ } ) ;
149+ continue ;
150+ }
151+
152+ // Check for duplicate RFC numbers
153+ const number = filename . slice ( 0 , 4 ) ;
154+ const existing = seenNumbers . get ( number ) ;
155+ if ( existing ) {
156+ errors . push ( {
157+ filename,
158+ message : `Duplicate RFC number ${ number } (also used by ${ existing } )` ,
159+ } ) ;
160+ } else {
161+ seenNumbers . set ( number , filename ) ;
162+ }
163+ }
164+
165+ return errors ;
166+ }
167+
132168function parseTitle ( markdown : string , filename : string ) : string {
133169 // Try to extract title from first # heading
134170 const match = markdown . match ( / ^ # \s + ( .+ ) $ / m) ;
@@ -143,6 +179,17 @@ function parseTitle(markdown: string, filename: string): string {
143179async function build ( liveReload : boolean = false ) : Promise < number > {
144180 console . log ( "Building Vortex RFC site...\n" ) ;
145181
182+ // Validate proposals first
183+ const validationErrors = await validateProposals ( ) ;
184+ if ( validationErrors . length > 0 ) {
185+ console . error ( "Validation errors found:\n" ) ;
186+ for ( const error of validationErrors ) {
187+ console . error ( ` ${ error . filename } : ${ error . message } ` ) ;
188+ }
189+ console . error ( "" ) ;
190+ process . exit ( 1 ) ;
191+ }
192+
146193 const glob = new Bun . Glob ( "*.md" ) ;
147194 const rfcs : RFC [ ] = [ ] ;
148195
0 commit comments