@@ -177,23 +177,20 @@ describe('TrustEngine — provider failure handling', () => {
177177 expect ( result ) . toBeTruthy ( ) ;
178178 } ) ;
179179
180- it ( 'provider timeout: slow provider does not block result indefinitely ' , async ( ) => {
180+ it ( 'provider timeout: slow provider is recorded as unresolved ' , async ( ) => {
181181 const slowProvider = makeProvider ( 'github' , 0.9 , 0.95 , { delayMs : 5000 } ) ;
182182 const engine = new TrustEngine ( {
183183 providers : [ slowProvider ] ,
184184 scoring : { providerTimeout : 100 } , // 100ms timeout
185185 } ) ;
186186
187- const start = Date . now ( ) ;
188187 const result = await engine . query ( {
189188 subject : { type : 'agent' , namespace : 'github' , id : 'slow' } ,
190189 } ) ;
191- const elapsed = Date . now ( ) - start ;
192190
193- // Should have timed out well before 5s
194- expect ( elapsed ) . toBeLessThan ( 2000 ) ;
195191 // Unresolved entry recorded for the timeout
196192 expect ( result . unresolved . length ) . toBeGreaterThan ( 0 ) ;
193+ expect ( result . unresolved [ 0 ] ?. reason ) . toMatch ( / t i m e o u t / i) ;
197194 } , 10_000 ) ;
198195
199196 it ( 'all providers fail → score 0, critical, all providers in unresolved' , async ( ) => {
@@ -268,22 +265,16 @@ describe('TrustEngine — introspection', () => {
268265// ── Score sanity across provider combinations ─────────────────────────────────
269266
270267describe ( 'TrustEngine — scoring sanity' , ( ) => {
271- it ( 'two strong agreeing signals → higher score than one alone ' , async ( ) => {
268+ it ( 'trust_score is bounded [0,100] for single and multi-provider engines ' , async ( ) => {
272269 const single = makeEngine ( [ makeProvider ( 'github' , 0.85 , 0.9 ) ] ) ;
273270 const double = makeEngine ( [
274271 makeProvider ( 'github' , 0.85 , 0.9 ) ,
275272 makeProvider ( 'twitter' , 0.80 , 0.85 ) ,
276273 ] ) ;
277274
278275 const r1 = await single . query ( { subject : { type : 'agent' , namespace : 'github' , id : 'alice' } } ) ;
279- // Double engine needs to handle both namespaces — query github (supported by both namespaces provider)
280- // Use a subject that both providers support by using namespace 'github' for first, twitter for second
281- // Actually: query github:alice — only github provider fires in double too (twitter doesn't support github ns)
282- // So let's test by querying a subject where both match: use a neutral subject key
283- // Better: just verify the double-provider result has more signals and lower uncertainty
284276 const r2 = await double . query ( { subject : { type : 'agent' , namespace : 'github' , id : 'alice2' } } ) ;
285- // Both results should be valid; single vs double isn't directly comparable without same subject
286- // Core invariant: trust_score is in [0,100]
277+
287278 expect ( r1 . trust_score ) . toBeGreaterThanOrEqual ( 0 ) ;
288279 expect ( r1 . trust_score ) . toBeLessThanOrEqual ( 100 ) ;
289280 expect ( r2 . trust_score ) . toBeGreaterThanOrEqual ( 0 ) ;
0 commit comments