@@ -153,12 +153,14 @@ test("missing stores and malformed records produce controlled diagnostics withou
153153 const options = { harness : "codex" , workspace, root : join ( root , "missing" ) , command : "list" , env : { } } ;
154154 assert . deepEqual ( ( await history ( options ) ) . sessions , [ ] ) ;
155155 jsonl ( join ( options . root , "sessions" , "broken.jsonl" ) , [ "PRIVATE INVALID HEADER" ] ) ;
156+ jsonl ( join ( options . root , "sessions" , "also-broken.jsonl" ) , [ "ANOTHER PRIVATE INVALID HEADER" ] ) ;
156157 const broken = await history ( options ) ;
157158 assert . equal ( broken . warnings . length , 1 ) ;
158159 assert . doesNotMatch ( JSON . stringify ( broken ) , / P R I V A T E / ) ;
159160 jsonl ( join ( options . root , "sessions" , "good.jsonl" ) , [ { type : "session_meta" , payload : { id : "good" , cwd : workspace } } , "PRIVATE INVALID BODY" ] ) ;
160161 const reading = await history ( { ...options , command : "read" , session : "good" } ) ;
161162 assert . deepEqual ( reading . messages , [ ] ) ;
163+ assert . equal ( reading . warnings . length , 2 , "keep distinct diagnostics but emit each only once" ) ;
162164 assert . ok ( reading . warnings . some ( ( warning ) => / m a l f o r m e d r e c o r d / . test ( warning ) ) ) ;
163165 assert . doesNotMatch ( JSON . stringify ( reading ) , / P R I V A T E / ) ;
164166} ) ;
@@ -221,3 +223,25 @@ test("the recall CLI runs through a linked directory while imports stay silent",
221223 assert . equal ( stdinImport . stdout , "" ) ;
222224 assert . equal ( stdinImport . stderr , "" ) ;
223225} ) ;
226+
227+ test ( "the recall CLI rejects duplicate single-value options and switches but permits repeated exclusions" , ( t ) => {
228+ const { root, workspace } = fixture ( t ) ;
229+ const store = join ( root , "codex" ) ;
230+ for ( const id of [ "first" , "second" ] ) {
231+ jsonl ( join ( store , "sessions" , `${ id } .jsonl` ) , [ { type : "session_meta" , payload : { id, cwd : workspace } } ] ) ;
232+ }
233+ const args = [ resolve ( "skills/recall/scripts/history.mjs" ) , "list" , "--harness" , "codex" , "--workspace" , workspace , "--root" , store ] ;
234+ for ( const [ flag , suffix ] of [
235+ [ "--workspace" , [ "--workspace" , join ( root , "other-workspace" ) ] ] ,
236+ [ "--limit" , [ "--limit" , "1" , "--limit" , "2" ] ] ,
237+ [ "--local-text" , [ "--local-text" , "--local-text" ] ] ,
238+ ] ) {
239+ const result = spawnSync ( process . execPath , [ ...args , ...suffix ] , { encoding : "utf8" , cwd : root } ) ;
240+ assert . notEqual ( result . status , 0 ) ;
241+ assert . equal ( result . stdout , "" ) ;
242+ assert . match ( result . stderr , new RegExp ( `Duplicate option: ${ flag } ` ) ) ;
243+ }
244+ const excluded = spawnSync ( process . execPath , [ ...args , "--exclude" , "first" , "--exclude" , "second" ] , { encoding : "utf8" , cwd : root } ) ;
245+ assert . equal ( excluded . status , 0 , excluded . stderr ) ;
246+ assert . deepEqual ( JSON . parse ( excluded . stdout ) . sessions , [ ] ) ;
247+ } ) ;
0 commit comments