@@ -12,6 +12,7 @@ import { coreEvents } from '../utils/events.js';
1212import * as tomlLoader from './agentLoader.js' ;
1313import { type Config } from '../config/config.js' ;
1414import { AcknowledgedAgentsService } from './acknowledgedAgents.js' ;
15+ import { PolicyDecision } from '../policy/types.js' ;
1516import * as fs from 'node:fs/promises' ;
1617import * as path from 'node:path' ;
1718import * as os from 'node:os' ;
@@ -103,13 +104,22 @@ describe('AgentRegistry Acknowledgement', () => {
103104 await fs . rm ( tempDir , { recursive : true , force : true } ) ;
104105 } ) ;
105106
106- it ( 'should not register unacknowledged project agents and emit event' , async ( ) => {
107+ it ( 'should register unacknowledged project agents and emit event' , async ( ) => {
107108 const emitSpy = vi . spyOn ( coreEvents , 'emitAgentsDiscovered' ) ;
108109
109110 await registry . initialize ( ) ;
110111
111- expect ( registry . getDefinition ( 'ProjectAgent' ) ) . toBeUndefined ( ) ;
112+ // Now unacknowledged agents ARE registered (but with ASK_USER policy)
113+ expect ( registry . getDefinition ( 'ProjectAgent' ) ) . toBeDefined ( ) ;
112114 expect ( emitSpy ) . toHaveBeenCalledWith ( [ MOCK_AGENT_WITH_HASH ] ) ;
115+
116+ // Verify policy
117+ const policyEngine = config . getPolicyEngine ( ) ;
118+ expect (
119+ await policyEngine ?. check ( { name : 'ProjectAgent' , args : { } } , undefined ) ,
120+ ) . toMatchObject ( {
121+ decision : PolicyDecision . ASK_USER ,
122+ } ) ;
113123 } ) ;
114124
115125 it ( 'should register acknowledged project agents' , async ( ) => {
@@ -134,6 +144,14 @@ describe('AgentRegistry Acknowledgement', () => {
134144
135145 expect ( registry . getDefinition ( 'ProjectAgent' ) ) . toBeDefined ( ) ;
136146 expect ( emitSpy ) . not . toHaveBeenCalled ( ) ;
147+
148+ // Verify policy is ALLOW for acknowledged agent
149+ const policyEngine = config . getPolicyEngine ( ) ;
150+ expect (
151+ await policyEngine ?. check ( { name : 'ProjectAgent' , args : { } } , undefined ) ,
152+ ) . toMatchObject ( {
153+ decision : PolicyDecision . ALLOW ,
154+ } ) ;
137155 } ) ;
138156
139157 it ( 'should register agents without hash (legacy/safe?)' , async ( ) => {
0 commit comments