@@ -84,6 +84,8 @@ describe('agent workspace runtime behavior', () => {
8484 ? '/api/knowledge/session/plan'
8585 : operationId === 'query_knowledge'
8686 ? '/api/knowledge/query'
87+ : operationId === 'evaluate_ingest_guardrails'
88+ ? '/api/knowledge/ingest/guardrails/evaluate'
8789 : operationId === 'query_session_history'
8890 ? '/api/knowledge/session/history'
8991 : operationId === 'query_mastery_misconceptions'
@@ -125,6 +127,15 @@ describe('agent workspace runtime behavior', () => {
125127 } ,
126128 } ;
127129 }
130+ if ( operationId === 'evaluate_ingest_guardrails' ) {
131+ return {
132+ operationId,
133+ endpoint,
134+ method : 'POST' ,
135+ resultPresentation : capability . execution . resultPresentation ,
136+ body : { } ,
137+ } ;
138+ }
128139 if ( operationId === 'query_mastery_misconceptions' ) {
129140 return {
130141 operationId,
@@ -473,6 +484,85 @@ describe('agent workspace runtime behavior', () => {
473484 expect ( messages . textContent || '' ) . toContain ( 'Query trace loaded' ) ;
474485 } ) ;
475486
487+ test ( 'executes ingest guardrail capability and renders gate summary' , async ( ) => {
488+ const fetchMock = jest
489+ . fn ( )
490+ . mockResolvedValueOnce ( {
491+ ok : true ,
492+ status : 200 ,
493+ json : async ( ) => ( {
494+ success : true ,
495+ result : {
496+ userId : 'agent_user_default' ,
497+ message : 'Found 1 local knowledge point(s).' ,
498+ knowledgePoints : [
499+ {
500+ atomId : 'atom-guardrail-1' ,
501+ title : 'Guardrail Candidate' ,
502+ snippet : 'Inspect ingest governance budget.' ,
503+ score : 0.71 ,
504+ capabilities : [
505+ {
506+ actionId : 'inspect_ingest_guardrails' ,
507+ label : 'Ingest Guardrails' ,
508+ request : {
509+ userId : 'agent_user_default' ,
510+ atomId : 'atom-guardrail-1' ,
511+ } ,
512+ execution : {
513+ kind : 'knowledge_operation' ,
514+ operationId : 'evaluate_ingest_guardrails' ,
515+ resultPresentation : 'ingest_guardrail_card' ,
516+ } ,
517+ } ,
518+ ] ,
519+ } ,
520+ ] ,
521+ } ,
522+ } ) ,
523+ } )
524+ . mockResolvedValueOnce ( {
525+ ok : true ,
526+ status : 200 ,
527+ json : async ( ) => ( {
528+ success : true ,
529+ result : {
530+ overallPassed : false ,
531+ gates : [
532+ { gateId : 'changed_documents' , passed : true } ,
533+ { gateId : 'ingest_p95' , passed : false } ,
534+ ] ,
535+ } ,
536+ } ) ,
537+ } ) ;
538+ ( global as unknown as Record < string , unknown > ) . fetch = fetchMock ;
539+
540+ const runtime = runtimeModule . createAgentWorkspaceRuntime ( { defaultUserId : 'agent_user_default' } ) ;
541+ runtime . init ( ) ;
542+
543+ const input = document . getElementById ( 'agent-workspace-input' ) as HTMLTextAreaElement ;
544+ const form = document . getElementById ( 'agent-workspace-form' ) as HTMLFormElement ;
545+ input . value = 'inspect ingest guardrails' ;
546+ form . dispatchEvent ( new dom ! . window . Event ( 'submit' , { bubbles : true , cancelable : true } ) ) ;
547+ await flushAsync ( ) ;
548+
549+ const actionButton = document . querySelector ( '.agent-workspace-action-button' ) as HTMLButtonElement ;
550+ expect ( actionButton ) . not . toBeNull ( ) ;
551+ actionButton . click ( ) ;
552+ await flushAsync ( ) ;
553+
554+ expect ( fetchMock ) . toHaveBeenNthCalledWith (
555+ 2 ,
556+ '/api/knowledge/ingest/guardrails/evaluate' ,
557+ expect . objectContaining ( { method : 'POST' } )
558+ ) ;
559+ const payload = JSON . parse ( String ( fetchMock . mock . calls [ 1 ] ?. [ 1 ] ?. body || '{}' ) ) as Record < string , unknown > ;
560+ expect ( payload ) . toEqual ( { } ) ;
561+
562+ const messages = document . getElementById ( 'agent-workspace-messages' ) as HTMLElement ;
563+ expect ( messages . textContent || '' ) . toContain ( 'Ingest guardrails evaluated' ) ;
564+ } ) ;
565+
476566 test ( 'executes mastery misconceptions capability and renders summary message' , async ( ) => {
477567 const fetchMock = jest
478568 . fn ( )
0 commit comments