fix: resolve e2e integration issues found during Hermes Agent testing#4
Merged
htafolla merged 1 commit intoMar 27, 2026
Merged
Conversation
- Fix orchestrator status handler crash: null-safe access on
completedTasks/failedTasks and guard against undefined
agentUtilization/recentSessions properties
- Fix security-scan hardcoding 'npm' instead of auto-detecting
package manager via detectPackageManager('auto')
- Fix integration test mock path mismatch: vi.mock path
'../mcps/agent-resolver.js' corrected to '../../mcps/agent-resolver.js'
to match the actual import in the resolveAgent test
- Add 'system' prompt to enforcer.yml agent config so
resolveAgent('enforcer') returns a defined system field
- Fix analyze_complexity NaN scoring: dependencies field can be
number or string[] depending on calling tool schema; added
safe type checking in calculateTaskComplexity,
createOptimizedPlan, sortByDependencies, and
calculateParallelPotential
- Update OrchestrationTask type to accept string[] | number for
dependencies to match both tool schemas
All 2311 tests pass (was 2310 pass / 1 fail). Zero new TS errors.
Pre-existing downlevelIteration errors on Map iteration unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Found and fixed 5 issues during full integration testing of PRs #2 and #3. All 2311 tests now pass (was 2310 pass / 1 fail).
Issues Fixed
1. HIGH — Orchestrator status handler crash (
status-handler.ts)get_orchestration_statuscrashed withCannot read properties of undefined (reading 'length')when looking up completed sessions.formatStatusResponseaccessedresult.completedTasks,result.failedTasks,orchStatus.agentUtilization, andorchStatus.recentSessionswithout null-safe guards.?? 0defaults for numeric fields and|| {}/|| []defaults for objects/arrays. Also addedstatusAny.status === 'completed'detection alongside thecompletedboolean.2. MODERATE — Security scan hardcodes
npm(security-scan.server.ts)handleSecurityScanalways passed"npm"toscanDependencies, ignoring yarn/pnpm projects.handleDependencyAuditcorrectly usesdetectPackageManager("auto")buthandleSecurityScandid not.const detectedPm = this.detectPackageManager("auto")before the dependency scan call.3. MODERATE — Failing integration test (
integration.test.ts+enforcer.yml)resolveAgent('enforcer')test failed becauseconfig.systemwas undefined.vi.mockpath was"../mcps/agent-resolver.js"but the test imports from"../../mcps/agent-resolver.js", so the mock never intercepted; (b)enforcer.ymlhas nosystemfield."../../mcps/agent-resolver.js"and added asystemprompt toenforcer.yml.4. MODERATE — analyze_complexity produces NaN scores (
execution-planner.ts)Tasks with
dependencies > 0got NaN complexity scores.analyze-complexitytool schema definesdependencies: numberbutOrchestrationTasktyped it asstring[]. WhencalculateTaskComplexitycalledtask.dependencies.lengthon a number, it returnedundefined, producing NaN.OrchestrationTask.dependenciestostring[] | number. AddedArray.isArrayguards in all 4 locations that access.lengthon dependencies (calculateTaskComplexity,createOptimizedPlan,sortByDependencies,calculateParallelPotential). Also added divide-by-zero guard incalculateParallelPotential.5. LOW — Type safety for dependencies field (
types.ts)OrchestrationTask.dependenciestype changed fromstring[]tostring[] | numberto match both theorchestrate-taskschema (string[] task IDs) and theanalyze-complexityschema (number count).Test Results
TypeScript
Zero new TS errors introduced. Pre-existing
downlevelIterationerrors onMap<string, ...>iteration remain unchanged — these are caused by the tsconfig target not includinges2015+for iterator support and affectagent-capabilities.tsandexecution-planner.tsMap iteration patterns. They do not affect runtime behavior (the code compiles and runs correctly under the actual build config).