@@ -181,7 +181,20 @@ describe("doctor invalid config process exit", () => {
181181 version : 1 ,
182182 agents : {
183183 jup : {
184- allowlist : [ { pattern : "/usr/bin/rg" , lastUsedAt : null , lastUsedCommand : null } ] ,
184+ allowlist : [
185+ {
186+ pattern : "/usr/bin/rg" ,
187+ source : "allow-always" ,
188+ lastUsedAt : null ,
189+ lastUsedCommand : null ,
190+ } ,
191+ {
192+ pattern : "=command:durable" ,
193+ source : "allow-always" ,
194+ lastUsedAt : null ,
195+ lastUsedCommand : null ,
196+ } ,
197+ ] ,
185198 } ,
186199 } ,
187200 } ) ,
@@ -209,6 +222,7 @@ describe("doctor invalid config process exit", () => {
209222 expect ( result . status , output ) . toBe ( 0 ) ;
210223 expect ( result . signal , output ) . toBeNull ( ) ;
211224 expect ( output ) . toContain ( "Imported legacy exec approvals into shared SQLite state." ) ;
225+ expect ( output ) . toContain ( "Exec approvals updated: removed 1 older generated approval" ) ;
212226 expect ( output ) . toContain ( "Doctor complete." ) ;
213227
214228 expect ( fs . existsSync ( approvalsPath ) ) . toBe ( false ) ;
@@ -219,7 +233,8 @@ describe("doctor invalid config process exit", () => {
219233 const row = database
220234 . prepare ( "SELECT raw_json FROM exec_approvals_config WHERE config_key = 'current'" )
221235 . get ( ) as { raw_json ?: string } | undefined ;
222- expect ( row ?. raw_json ) . toContain ( '"pattern": "/usr/bin/rg"' ) ;
236+ expect ( row ?. raw_json ) . not . toContain ( '"pattern": "/usr/bin/rg"' ) ;
237+ expect ( row ?. raw_json ) . toContain ( '"pattern": "=command:durable"' ) ;
223238 expect ( row ?. raw_json ) . not . toContain ( "lastUsedAt" ) ;
224239 expect ( row ?. raw_json ) . not . toContain ( "lastUsedCommand" ) ;
225240 } finally {
@@ -283,120 +298,6 @@ describe("doctor invalid config process exit", () => {
283298 } , 75_000 ) ;
284299} ) ;
285300
286- describe ( "doctor legacy exec approvals process repair" , ( ) => {
287- it ( "imports legacy approvals before renewing obsolete generated grants" , async ( ) => {
288- const root = fs . realpathSync ( tempDirs . make ( "openclaw-doctor-exec-approvals-order-" ) ) ;
289- const stateDir = path . join ( root , "state" ) ;
290- const configPath = path . join ( stateDir , "openclaw.json" ) ;
291- const sourcePath = path . join ( stateDir , "exec-approvals.json" ) ;
292- const databasePath = path . join ( stateDir , "state" , "openclaw.sqlite" ) ;
293- const env : NodeJS . ProcessEnv = {
294- ...process . env ,
295- HOME : root ,
296- USERPROFILE : root ,
297- OPENCLAW_CONFIG_PATH : configPath ,
298- OPENCLAW_DISABLE_BUNDLED_PLUGINS : "1" ,
299- OPENCLAW_NO_RESPAWN : "1" ,
300- OPENCLAW_SKIP_CHANNELS : "1" ,
301- OPENCLAW_STATE_DIR : stateDir ,
302- OPENCLAW_TEST_FAST : "1" ,
303- NO_COLOR : "1" ,
304- } ;
305- delete env . NODE_ENV ;
306- delete env . NODE_OPTIONS ;
307- delete env . OPENCLAW_GATEWAY_PASSWORD ;
308- delete env . OPENCLAW_GATEWAY_TOKEN ;
309- delete env . OPENCLAW_GATEWAY_URL ;
310- delete env . OPENCLAW_HOME ;
311- delete env . VITEST ;
312- delete env . VITEST_POOL_ID ;
313- delete env . VITEST_WORKER_ID ;
314-
315- fs . mkdirSync ( stateDir , { recursive : true } ) ;
316- fs . writeFileSync (
317- configPath ,
318- JSON . stringify ( { gateway : { mode : "local" , auth : { mode : "none" } } } ) ,
319- ) ;
320- fs . writeFileSync (
321- sourcePath ,
322- JSON . stringify ( {
323- version : 1 ,
324- agents : {
325- main : {
326- allowlist : [
327- { pattern : "/usr/bin/rg" , source : "allow-always" } ,
328- { pattern : "=command:durable" , source : "allow-always" } ,
329- ] ,
330- } ,
331- } ,
332- } ) ,
333- ) ;
334- const preflightUrl = new URL ( "./doctor-config-preflight.ts" , import . meta. url ) . href ;
335- await runIsolatedModuleScript (
336- env ,
337- `
338- const { runDoctorConfigPreflight } = await import(${ JSON . stringify ( preflightUrl ) } );
339- await runDoctorConfigPreflight({
340- migrateLegacyConfig: false,
341- invalidConfigNote: false,
342- observe: false,
343- requireStartupMigrationCheckpoint: true,
344- beforeStateMigrations: async () => true,
345- });
346- ` ,
347- ) ;
348- expect ( fs . existsSync ( sourcePath ) ) . toBe ( true ) ;
349-
350- const result = spawnSync (
351- process . execPath ,
352- [
353- "--import" ,
354- "tsx" ,
355- path . resolve ( "src/entry.ts" ) ,
356- "doctor" ,
357- "--fix" ,
358- "--non-interactive" ,
359- "--no-workspace-suggestions" ,
360- ] ,
361- {
362- cwd : path . resolve ( "." ) ,
363- encoding : "utf8" ,
364- env,
365- timeout : 60_000 ,
366- } ,
367- ) ;
368- const output = `${ result . stderr } \n${ result . stdout } ` ;
369-
370- expect ( result . error , output ) . toBeUndefined ( ) ;
371- expect ( result . status , output ) . toBe ( 0 ) ;
372- expect ( result . signal , output ) . toBeNull ( ) ;
373- expect ( output ) . toContain ( "Doctor complete." ) ;
374- expect ( fs . existsSync ( sourcePath ) ) . toBe ( false ) ;
375-
376- const database = new DatabaseSync ( databasePath , { readOnly : true } ) ;
377- try {
378- const row = database
379- . prepare ( "SELECT raw_json FROM exec_approvals_config WHERE config_key = 'current'" )
380- . get ( ) as { raw_json : string } | undefined ;
381- const approvals = JSON . parse ( row ?. raw_json ?? "null" ) as {
382- agents ?: { main ?: { allowlist ?: Array < { pattern ?: string } > } } ;
383- } | null ;
384- expect ( approvals ?. agents ?. main ?. allowlist ) . toEqual ( [
385- expect . objectContaining ( { pattern : "=command:durable" } ) ,
386- ] ) ;
387- expect (
388- database
389- . prepare (
390- "SELECT status, removed_source FROM migration_sources WHERE migration_kind = 'legacy-exec-approvals-json'" ,
391- )
392- . get ( ) ,
393- ) . toMatchObject ( { status : "completed" , removed_source : 1 } ) ;
394- } finally {
395- database . close ( ) ;
396- }
397- } , 75_000 ) ;
398- } ) ;
399-
400301// Synchronous CLI probes must not consume neighboring cases' timeout budgets.
401302describe ( "gateway startup-migration refusal" , ( ) => {
402303 it ( "repairs the stable upgrade config and additive state schema before readiness" , async ( ) => {
0 commit comments