Skip to content

Commit e9accde

Browse files
DaMandal0rianclaude
andcommitted
fix: resolve TypeScript compilation errors in agent-optimized.ts
- Fixed import paths for performance module components - Updated PerformanceManagerConfig interface usage - Resolved PERFORMANCE_CONFIG undefined references - Fixed method naming (shutdown -> dispose) for performance manager - Updated agent-optimized.ts to use proper PerformanceManager APIs - All container-based CI tests now pass (lint, format, tsc) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 4f8719f commit e9accde

File tree

9 files changed

+346
-261
lines changed

9 files changed

+346
-261
lines changed

packages/indexer-agent/src/agent-optimized.ts

Lines changed: 207 additions & 152 deletions
Large diffs are not rendered by default.

packages/indexer-agent/src/performance-config.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export interface PerformanceConfig {
6161
cacheTTL: number
6262
cacheMaxSize: number
6363
cacheCleanupInterval: number
64-
64+
6565
// Hierarchical cache settings
6666
enableCacheHierarchy: boolean
6767
l1CacheTTL: number // DataLoader cache
@@ -72,7 +72,7 @@ export interface PerformanceConfig {
7272
circuitBreakerFailureThreshold: number
7373
circuitBreakerResetTimeout: number
7474
circuitBreakerHalfOpenMaxAttempts: number
75-
75+
7676
// Global circuit breaker settings
7777
enableGlobalCircuitBreaker: boolean
7878
perServiceCircuitBreakers: boolean
@@ -81,7 +81,7 @@ export interface PerformanceConfig {
8181
enablePriorityQueue: boolean
8282
priorityQueueSignalThreshold: string
8383
priorityQueueStakeThreshold: string
84-
84+
8585
// Intelligent batching settings
8686
enableIntelligentBatching: boolean
8787
batchPriorityWeighting: boolean
@@ -100,7 +100,7 @@ export interface PerformanceConfig {
100100
enableMetrics: boolean
101101
metricsInterval: number
102102
enableDetailedLogging: boolean
103-
103+
104104
// Performance manager settings
105105
enablePerformanceManager: boolean
106106
performanceManagerWarmupEnabled: boolean
@@ -118,7 +118,7 @@ export const DEFAULT_PERFORMANCE_CONFIG: PerformanceConfig = {
118118
cacheTTL: PERFORMANCE_DEFAULTS.CACHE_TTL,
119119
cacheMaxSize: PERFORMANCE_DEFAULTS.CACHE_MAX_SIZE,
120120
cacheCleanupInterval: PERFORMANCE_DEFAULTS.CACHE_CLEANUP_INTERVAL,
121-
121+
122122
// Hierarchical cache settings
123123
enableCacheHierarchy: true,
124124
l1CacheTTL: 5000, // 5 seconds for request-scoped cache
@@ -131,7 +131,7 @@ export const DEFAULT_PERFORMANCE_CONFIG: PerformanceConfig = {
131131
circuitBreakerResetTimeout:
132132
PERFORMANCE_DEFAULTS.CIRCUIT_BREAKER_RESET_TIMEOUT,
133133
circuitBreakerHalfOpenMaxAttempts: 3,
134-
134+
135135
// Global circuit breaker settings
136136
enableGlobalCircuitBreaker: true,
137137
perServiceCircuitBreakers: false,
@@ -142,7 +142,7 @@ export const DEFAULT_PERFORMANCE_CONFIG: PerformanceConfig = {
142142
PERFORMANCE_DEFAULTS.PRIORITY_QUEUE_SIGNAL_THRESHOLD,
143143
priorityQueueStakeThreshold:
144144
PERFORMANCE_DEFAULTS.PRIORITY_QUEUE_STAKE_THRESHOLD,
145-
145+
146146
// Intelligent batching settings
147147
enableIntelligentBatching: true,
148148
batchPriorityWeighting: true,
@@ -161,7 +161,7 @@ export const DEFAULT_PERFORMANCE_CONFIG: PerformanceConfig = {
161161
enableMetrics: true,
162162
metricsInterval: PERFORMANCE_DEFAULTS.METRICS_INTERVAL,
163163
enableDetailedLogging: false,
164-
164+
165165
// Performance manager settings
166166
enablePerformanceManager: true,
167167
performanceManagerWarmupEnabled: true,
@@ -197,7 +197,7 @@ function applyCacheSettings(config: PerformanceConfig): void {
197197
'CACHE_CLEANUP_INTERVAL',
198198
config.cacheCleanupInterval,
199199
)
200-
200+
201201
// Hierarchical cache settings
202202
config.enableCacheHierarchy = parseEnvBoolean(
203203
'ENABLE_CACHE_HIERARCHY',
@@ -227,7 +227,7 @@ function applyCircuitBreakerSettings(config: PerformanceConfig): void {
227227
'CIRCUIT_BREAKER_HALF_OPEN_MAX_ATTEMPTS',
228228
config.circuitBreakerHalfOpenMaxAttempts,
229229
)
230-
230+
231231
// Global circuit breaker settings
232232
config.enableGlobalCircuitBreaker = parseEnvBoolean(
233233
'ENABLE_GLOBAL_CIRCUIT_BREAKER',
@@ -255,7 +255,7 @@ function applyPriorityQueueSettings(config: PerformanceConfig): void {
255255
'PRIORITY_QUEUE_STAKE_THRESHOLD',
256256
config.priorityQueueStakeThreshold,
257257
)
258-
258+
259259
// Intelligent batching settings
260260
config.enableIntelligentBatching = parseEnvBoolean(
261261
'ENABLE_INTELLIGENT_BATCHING',

packages/indexer-common/src/performance/__tests__/integration.test.ts

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,29 @@ import {
1616
import { Allocation } from '../../allocations'
1717

1818
// Mock subgraph client for testing
19-
const createMockSubgraphClient = () => ({
20-
name: 'mock-client',
21-
logger: createMockLogger(),
22-
freshnessChecker: undefined,
23-
endpointClient: undefined,
24-
deployment: undefined,
25-
endpoint: 'http://mock-endpoint',
26-
checkedQuery: jest.fn(),
27-
query: jest.fn(),
28-
queryRaw: jest.fn(),
29-
} as unknown as SubgraphClient)
19+
const createMockSubgraphClient = () =>
20+
({
21+
name: 'mock-client',
22+
logger: createMockLogger(),
23+
freshnessChecker: undefined,
24+
endpointClient: undefined,
25+
deployment: undefined,
26+
endpoint: 'http://mock-endpoint',
27+
checkedQuery: jest.fn(),
28+
query: jest.fn(),
29+
queryRaw: jest.fn(),
30+
}) as unknown as SubgraphClient
3031

3132
// Mock logger
32-
const createMockLogger = (): Logger => ({
33-
child: jest.fn().mockReturnThis(),
34-
info: jest.fn(),
35-
warn: jest.fn(),
36-
error: jest.fn(),
37-
debug: jest.fn(),
38-
trace: jest.fn(),
39-
}) as unknown as Logger
33+
const createMockLogger = (): Logger =>
34+
({
35+
child: jest.fn().mockReturnThis(),
36+
info: jest.fn(),
37+
warn: jest.fn(),
38+
error: jest.fn(),
39+
debug: jest.fn(),
40+
trace: jest.fn(),
41+
}) as unknown as Logger
4042

4143
describe('Performance Module Integration', () => {
4244
let logger: Logger
@@ -259,10 +261,13 @@ describe('Performance Module Integration', () => {
259261
if (state === 'HALF_OPEN') {
260262
// Circuit is attempting recovery
261263
const successfulOp = jest.fn().mockResolvedValue('recovery-success')
262-
circuitBreaker.execute(successfulOp).then(() => {
263-
expect(circuitBreaker.getState()).toBe('CLOSED')
264-
done()
265-
}).catch(done)
264+
circuitBreaker
265+
.execute(successfulOp)
266+
.then(() => {
267+
expect(circuitBreaker.getState()).toBe('CLOSED')
268+
done()
269+
})
270+
.catch(done)
266271
}
267272
})
268273

@@ -273,7 +278,7 @@ describe('Performance Module Integration', () => {
273278
promises.push(
274279
circuitBreaker.execute(failingOp).catch(() => {
275280
// Expected failures
276-
}) as Promise<void>
281+
}) as Promise<void>,
277282
)
278283
}
279284
Promise.all(promises).then(() => {
@@ -456,9 +461,11 @@ describe('Performance Module Integration', () => {
456461

457462
// Trigger multiple failures
458463
const failurePromises = Array.from({ length: 10 }, () =>
459-
performanceManager.executeOptimized(networkFailureOp, {
460-
componentName: 'network-test',
461-
}).catch(() => {}),
464+
performanceManager
465+
.executeOptimized(networkFailureOp, {
466+
componentName: 'network-test',
467+
})
468+
.catch(() => {}),
462469
)
463470

464471
await Promise.all(failurePromises)
@@ -508,4 +515,4 @@ describe('Performance Module Integration', () => {
508515
expect(retrievedData).toEqual(testData)
509516
})
510517
})
511-
})
518+
})

packages/indexer-common/src/performance/__tests__/performance-manager.test.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -490,9 +490,14 @@ describe('PerformanceManager Error Handling', () => {
490490

491491
it('should handle initialization errors', async () => {
492492
// Mock an error during initialization
493-
jest.spyOn(manager as unknown as { startMetricsCollection: () => void }, 'startMetricsCollection').mockImplementation(() => {
494-
throw new Error('Metrics initialization failed')
495-
})
493+
jest
494+
.spyOn(
495+
manager as unknown as { startMetricsCollection: () => void },
496+
'startMetricsCollection',
497+
)
498+
.mockImplementation(() => {
499+
throw new Error('Metrics initialization failed')
500+
})
496501

497502
await expect(manager.initialize()).rejects.toThrow(PerformanceError)
498503
})
@@ -530,4 +535,4 @@ describe('PerformanceManager Error Handling', () => {
530535
expect(result).toBe('success')
531536
expect(attempts).toBe(3)
532537
})
533-
})
538+
})

packages/indexer-common/src/performance/errors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,4 +217,4 @@ export class ErrorHandler {
217217
stack: error.stack,
218218
}
219219
}
220-
}
220+
}

packages/indexer-common/src/performance/graphql-dataloader-enhanced.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ export interface EnhancedDataLoaderOptions {
2222
cache?: boolean
2323
maxBatchSize?: number
2424
batchScheduleFn?: (callback: () => void) => void
25-
25+
2626
// Hierarchical caching options
2727
enableL2Cache?: boolean
2828
l1CacheTTL?: number
2929
l2CacheTTL?: number
30-
30+
3131
// Circuit breaker integration
3232
enableCircuitBreaker?: boolean
3333
}
@@ -223,7 +223,7 @@ export class GraphQLDataLoaderEnhanced {
223223
for (const allocation of result.data.allocations || []) {
224224
const parsed = parseGraphQLAllocation(allocation, this.protocolNetwork)
225225
allocationsMap.set(allocation.id.toLowerCase(), parsed)
226-
226+
227227
// Cache in L2
228228
if (this.options.enableL2Cache && this.networkCache) {
229229
const cacheKey = `allocation:${allocation.id.toLowerCase()}`
@@ -300,7 +300,7 @@ export class GraphQLDataLoaderEnhanced {
300300
for (const deployment of result.data.subgraphDeployments || []) {
301301
const parsed = parseGraphQLSubgraphDeployment(deployment, this.protocolNetwork)
302302
deploymentsMap.set(deployment.id.toLowerCase(), parsed)
303-
303+
304304
// Cache in L2
305305
if (this.options.enableL2Cache && this.networkCache) {
306306
const cacheKey = `deployment:${deployment.id.toLowerCase()}`
@@ -339,7 +339,9 @@ export class GraphQLDataLoaderEnhanced {
339339
): Promise<Allocation[][]> {
340340
const operation = async () => {
341341
const startTime = Date.now()
342-
this.logger.trace('Enhanced batch loading multi-allocations', { count: keys.length })
342+
this.logger.trace('Enhanced batch loading multi-allocations', {
343+
count: keys.length,
344+
})
343345
this.metrics.batchLoads++
344346

345347
// Group by unique indexers to minimize queries
@@ -404,7 +406,7 @@ export class GraphQLDataLoaderEnhanced {
404406
}
405407
const parsed = parseGraphQLAllocation(allocation, this.protocolNetwork)
406408
allocationsMap.get(key)!.push(parsed)
407-
409+
408410
// Cache individual allocations in L2
409411
if (this.options.enableL2Cache && this.networkCache) {
410412
const cacheKey = `allocation:${allocation.id.toLowerCase()}`
@@ -530,12 +532,12 @@ export class GraphQLDataLoaderEnhanced {
530532
this.allocationLoader.clearAll()
531533
this.deploymentLoader.clearAll()
532534
this.multiAllocationLoader.clearAll()
533-
535+
534536
// Clear L2 cache patterns
535537
if (this.networkCache) {
536538
this.networkCache.invalidatePattern(/^(allocation|deployment|multi-allocation):/)
537539
}
538-
540+
539541
this.logger.debug('Cleared all DataLoader caches (L1 and L2)')
540542
}
541543

@@ -545,7 +547,7 @@ export class GraphQLDataLoaderEnhanced {
545547
clearAllocation(id: string): void {
546548
// Clear from L1
547549
this.allocationLoader.clear(id)
548-
550+
549551
// Clear from L2
550552
if (this.networkCache) {
551553
this.networkCache.invalidate(`allocation:${id.toLowerCase()}`)
@@ -558,7 +560,7 @@ export class GraphQLDataLoaderEnhanced {
558560
clearDeployment(id: string): void {
559561
// Clear from L1
560562
this.deploymentLoader.clear(id)
561-
563+
562564
// Clear from L2
563565
if (this.networkCache) {
564566
this.networkCache.invalidate(`deployment:${id.toLowerCase()}`)
@@ -571,7 +573,7 @@ export class GraphQLDataLoaderEnhanced {
571573
primeAllocation(id: string, allocation: Allocation): void {
572574
// Prime L1
573575
this.allocationLoader.prime(id, allocation)
574-
576+
575577
// Prime L2
576578
if (this.options.enableL2Cache && this.networkCache) {
577579
const cacheKey = `allocation:${id.toLowerCase()}`
@@ -585,7 +587,7 @@ export class GraphQLDataLoaderEnhanced {
585587
primeDeployment(id: string, deployment: SubgraphDeployment): void {
586588
// Prime L1
587589
this.deploymentLoader.prime(id, deployment)
588-
590+
589591
// Prime L2
590592
if (this.options.enableL2Cache && this.networkCache) {
591593
const cacheKey = `deployment:${id.toLowerCase()}`
@@ -639,4 +641,4 @@ export class GraphQLDataLoaderEnhanced {
639641
this.clearAll()
640642
this.logger.info('Enhanced DataLoader disposed')
641643
}
642-
}
644+
}

packages/indexer-common/src/performance/index.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ export type { QueueMetrics } from './allocation-priority-queue'
1515

1616
export { GraphQLDataLoader } from './graphql-dataloader'
1717
export { GraphQLDataLoaderEnhanced } from './graphql-dataloader-enhanced'
18-
export type {
19-
EnhancedDataLoaderOptions,
20-
} from './graphql-dataloader-enhanced'
18+
export type { EnhancedDataLoaderOptions } from './graphql-dataloader-enhanced'
2119

2220
export { ConcurrentReconciler } from './concurrent-reconciler'
2321
export type { ReconcilerOptions, ReconciliationMetrics } from './concurrent-reconciler'
@@ -40,4 +38,4 @@ export {
4038
ConfigurationError,
4139
ErrorHandler,
4240
} from './errors'
43-
export type { ErrorContext } from './errors'
41+
export type { ErrorContext } from './errors'

0 commit comments

Comments
 (0)