@ harness- engineering/ 情报
用于光谱浓缩,复杂建模,以及执行前模拟的情报管道. 增强混合管弦乐手的路由,并用相图后置分析和分层模拟.
建筑
┌─────────────────────┐
│ Work Item Input │
│ Roadmap · JIRA · │
│ GitHub · Linear · │
│ Manual text │
└──────────┬──────────┘
▼
┌─────────────────────┐
│ Adapters │
│ toRawWorkItem() │
│ jiraToRawWorkItem() │
│ githubToRawWorkItem │
│ linearToRawWorkItem │
│ manualToRawWorkItem │
└──────────┬──────────┘
▼
┌────────────────────────────────────────────────────────────────┐
│ IntelligencePipeline │
│ │
│ ┌──────────────────────────────────────────────────────────┐ │
│ │ SEL — Spec Enrichment Layer │ │
│ │ LLM analysis + graph-validated system discovery │ │
│ │ → EnrichedSpec (intent, affected systems, unknowns) │ │
│ └──────────────────────┬───────────────────────────────────┘ │
│ ▼ │
│ ┌──────────────────────────────────────────────────────────┐ │
│ │ CML — Complexity Modeling Layer │ │
│ │ Structural (graph blast radius) + Semantic (ambiguity) │ │
│ │ + Historical (past outcome failure rate) │ │
│ │ → ComplexityScore → ConcernSignal[] │ │
│ └──────────────────────┬───────────────────────────────────┘ │
│ ▼ │
│ ┌──────────────────────────────────────────────────────────┐ │
│ │ PESL — Pre-Execution Simulation Layer │ │
│ │ Graph-only checks (quick-fix) or full LLM simulation │ │
│ │ (guided-change) with abort on low confidence │ │
│ │ → SimulationResult (confidence, abort flag) │ │
│ └──────────────────────────────────────────────────────────┘ │
│ │
│ ┌──────────────────────────────────────────────────────────┐ │
│ │ Outcome Recording │ │
│ │ ExecutionOutcomeConnector → graph nodes + edges │ │
│ │ Feeds back into CML historical dimension │ │
│ └──────────────────────────────────────────────────────────┘ │
└────────────────────────────────────────────────────────────────┘
快速启动
import {
IntelligencePipeline,
AnthropicAnalysisProvider,
toRawWorkItem,
} from '@harness-engineering/intelligence';
import { GraphStore } from '@harness-engineering/graph';
// 1. Create the pipeline
const provider = new AnthropicAnalysisProvider({
apiKey: process.env.ANTHROPIC_API_KEY!,
});
const store = new GraphStore();
await store.load('.harness/graph');
const pipeline = new IntelligencePipeline(provider, store);
// 2. Preprocess an issue (SEL → CML → signals)
const result = await pipeline.preprocessIssue(issue, scopeTier, escalationConfig);
// result.spec — EnrichedSpec with intent, affected systems, unknowns
// result.score — ComplexityScore with overall 0-1, risk level, reasoning
// result.signals — ConcernSignal[] for routeIssue()
// 3. Simulate before dispatch (PESL)
if (result.spec && result.score) {
const simulation = await pipeline.simulate(result.spec, result.score, scopeTier);
// simulation.abort — true if confidence too low
// simulation.predictedFailures — what might go wrong
// simulation.testGaps — missing test coverage
}
// 4. Record execution outcomes (feedback loop)
await pipeline.recordOutcome({
issueId: 'CORE-42',
result: 'success',
retryCount: 0,
failureReasons: [],
durationMs: 45000,
affectedSystemNodeIds: ['node-abc'],
});
等级行为
管道根据管弦乐手的视野级调整其行为:
| 范围 | 自己 | CML 数据 | 萨尔瓦多 | 路线 |
|---|---|---|---|---|
autoExecute (快速修复,诊断) | 跳过 | 跳过 | 仅图 | 总是在本地发送 |
signalGated (修改指南) | 运行 | 运行 | 完全 LLM 模拟 | 无关切信号的发送 |
alwaysHuman (全面探索) | 运行 | 跳过 | 跳过 | 总是升级( 浓缩为上下文) |
层
SEL — 光谱浓缩层
将原始工作项目转换为结构化 EnrichedSpec 对象通过 LLM 分析和图表验证.
import { enrich, GraphValidator } from '@harness-engineering/intelligence';
const validator = new GraphValidator(store);
const spec = await enrich(rawWorkItem, provider, validator);
// spec.intent — what the task is trying to accomplish
// spec.affectedSystems — graph-validated system references
// spec.unknowns — explicitly identified knowledge gaps
// spec.ambiguities — areas needing clarification
CML — 复杂模拟层
三个方面的任务复杂性:
- 结构 - 图像爆炸半径通过
CascadeSimulator,正态为 0-1 - 语义 ——来自SEL浓缩的不明、模糊和风险信号
- 历史 ——同一受影响系统过去执行结果的平稳故障率
import { scoreCML, scoreToConcernSignals } from '@harness-engineering/intelligence';
const score = scoreCML(enrichedSpec, store);
// score.overall — 0-1 weighted composite
// score.riskLevel — 'low' | 'medium' | 'high' | 'critical'
// score.recommendedRoute — 'local' | 'human' | 'simulation-required'
const signals = scoreToConcernSignals(score);
// signals fed into existing routeIssue() for signalGated tiers
PESL — 执行前模拟层
在写入代码前模拟执行 。 按成本划分:
- 仅图 (快速固定/诊断) -
CascadeSimulator爆炸半径+测试漏洞检测. 快 (<2s),无 LLM 成本. - 完全模拟 (指向变化)——LLM辅助计划扩展,故障注入,测试投影. 与图表基线合并.
import { PeslSimulator } from '@harness-engineering/intelligence';
const simulator = new PeslSimulator(provider, store);
const result = await simulator.simulate(spec, score, scopeTier);
if (result.abort) {
// Confidence too low — escalate to human instead of dispatching
console.log('Predicted failures:', result.predictedFailures);
console.log('Test gaps:', result.testGaps);
}
适配器
将外部数据转换为纯映射函数 RawWorkItem数字 :
import {
toRawWorkItem, // Roadmap Issue → RawWorkItem
jiraToRawWorkItem, // JIRA issue → RawWorkItem
githubToRawWorkItem, // GitHub issue/PR → RawWorkItem
linearToRawWorkItem, // Linear issue → RawWorkItem
manualToRawWorkItem, // Free text → RawWorkItem
} from '@harness-engineering/intelligence';
每个适配器接受前置数据对象并生成一个 RawWorkItem。不包括 API 客户端 — 适配器是纯函数 .
有效性——代理性能回顾
属性分析 execution_outcome 在图中的节点可以对每个人的准确度进行分分,检测出盲点,并推荐哪个人物将新问题引导到.
import {
computePersonaEffectiveness,
detectBlindSpots,
recommendPersona,
} from '@harness-engineering/intelligence';
// Per-(persona, system) success rates with Laplace smoothing
const scores = computePersonaEffectiveness(store, { persona: 'backend-dev' });
// scores[0].successRate — smoothed success rate in [0, 1]
// scores[0].sampleSize — total observations
// Blind spots: (persona, system) pairs with high failure rates
const spots = detectBlindSpots(store, { minFailures: 2, minFailureRate: 0.5 });
// spots[0].failureRate — raw failure rate
// spots[0].failures — absolute failure count
// Recommend personas for an issue given its affected systems
const recs = recommendPersona(store, {
systemNodeIds: ['module-auth', 'module-db'],
candidatePersonas: ['backend-dev', 'fullstack'],
minSamples: 3,
});
// recs[0].persona — best candidate
// recs[0].score — mean smoothed success rate across requested systems
专门性——长期代理专家追踪
以时间衰变、任务类型分类、一致性评分、专门知识水平和持续配置存储来扩大效力。 最近的结果通过指数衰减而比起旧的结果更重地加权.
import {
computeSpecialization,
computeExpertiseLevel,
buildSpecializationProfile,
weightedRecommendPersona,
decayWeight,
temporalSuccessRate,
loadProfiles,
saveProfiles,
refreshProfiles,
} from '@harness-engineering/intelligence';
// Compute specialization entries for (persona, system, taskType) tuples
const entries = computeSpecialization(store, {
persona: 'backend-dev',
taskType: 'bug-fix',
temporal: { halfLifeDays: 30 },
});
// entries[0].score.composite — weighted combination of temporal, consistency, volume
// entries[0].expertiseLevel — 'novice' | 'competent' | 'proficient' | 'expert'
// Classify expertise from raw numbers
const level = computeExpertiseLevel(25, 0.8); // → 'proficient'
// Build a full profile for a persona (strengths, weaknesses, overall level)
const profile = buildSpecializationProfile(store, 'backend-dev', {
temporal: { halfLifeDays: 30 },
});
// profile.strengths — top 3 entries by composite score
// profile.weaknesses — entries with temporal success rate < 0.5
// profile.overallLevel — median expertise across all entries
// Weighted recommendation incorporating specialization multipliers
const weighted = weightedRecommendPersona(store, {
systemNodeIds: ['module-auth'],
taskType: 'bug-fix',
});
// weighted[0].weightedScore — baseScore * specializationMultiplier
// Temporal decay helpers
const weight = decayWeight(15, 30); // weight at 15 days with 30-day half-life
const rate = temporalSuccessRate([{ result: 'success', timestamp: '2026-04-01T00:00:00Z' }], {
halfLifeDays: 30,
});
// Persist profiles to .harness/specialization-profiles.json
const profiles = loadProfiles('/path/to/project');
saveProfiles('/path/to/project', profiles);
// Recompute and persist profiles for all personas with outcomes
const refreshed = refreshProfiles('/path/to/project', store);
结果记录
执行结果反馈到图表中, 用于未来的 CML 评分 :
import { ExecutionOutcomeConnector } from '@harness-engineering/intelligence';
const connector = new ExecutionOutcomeConnector(store);
await connector.ingest({
issueId: 'CORE-42',
result: 'failure',
retryCount: 2,
failureReasons: ['Migration script failed'],
durationMs: 120000,
affectedSystemNodeIds: ['module-auth'],
});
// Creates execution_outcome node with outcome_of edges to affected systems
// Future CML scoring queries these outcomes for historical failure rates
整形器整合
情报管道在两点上融入了管弦乐手的滴答循环:
-
预线 (单位:千美元)
asyncTick(b) ——preprocessIssue()运行 SEL + CML,生成反馈到routeIssue()用于alwaysHuman中,浓缩光谱附于EscalateEffect作为人类评论员的背景. -
后路线 (单位:千美元)
asyncTick(b) ——simulate()管理地方发行的PESL。 如果模拟建议中止( I)confidence < 0.3),将调度转换为EscalateEffect换句话说. -
执行后 (单位:千美元)
emitWorkerExit(b) ——recordOutcome()将执行结果输入到图中,将CML的历史维度反馈给未来的评分.
盘子
仪表板的 请注意 页面显示升级互动。 当情报管道启用时,升级包括内容更丰富:
- 丰富光谱摘要 ——意向,受影响系统,未知数
- 关注信号 导致升级的原因(高度复杂、爆炸半径大、模糊不清)
- PESL 流产原因 ——预测的故障和测试缺口(当模拟建议中止时)
这种背景有助于人类审查人员就升级的工作项目做出更快,更知情的决定.
配置
管道使用与管弦乐手的代理后端——Anthropic API,OpenAI API,或本地LLM(Ollama,LM Studio等)相同的LLM连接:
intelligence:
enabled: true
不需要单独的 API 密钥 。 管道的提供者来自现有的代理人配置:
| 代理后端 | 情报用途 |
|---|---|
anthropic 编号 : claude | Anthropic 信件 API( 相同的密钥) |
openai | OpenAI Chat API( 相同的密钥) |
localBackend: openai-compatible | 本地端点( 相同的 URL) |
覆盖每层模型 :
intelligence:
enabled: true
models:
sel: llama3.2 # fast model for enrichment
pesl: deepseek-r1 # reasoning model for simulation
对于思维模型(Quen3, Deepseek-R1),对结构化输出的禁用推理:
intelligence:
enabled: true
promptSuffix: '/no_think' # Qwen3 — disable thinking for structured output
jsonMode: false # Qwen3 hangs with Ollama's JSON grammar constraint
requestTimeoutMs: 90000 # fail fast instead of waiting 10 min
failureCacheTtlMs: 300000 # don't retry failed analyses for 5 min
何时 enabled: false (默认),管道完全跳过. 见 智能管道指南 用于完整配置参考.
依赖关系
@harness-engineering/types → shared type definitions
@harness-engineering/graph → GraphStore, CascadeSimulator, node/edge types
@anthropic-ai/sdk → LLM calls via AnalysisProvider
openai → OpenAI-compatible analysis provider
zod → response schema validation
情报包 无依赖 打开 @harness-engineering/orchestrator。依赖性流动的方式如下: orchestrator → intelligence → graph → types。 。 。 .
API 参考
管道
| 导出 | 说明 |
|---|---|
IntelligencePipeline | SEL、CML、PESL的主要管道类别 |
PreprocessResult | 返回类型 preprocessIssue() |
适配器
| 导出 | 说明 |
|---|---|
toRawWorkItem | 路线图 Issue → RawWorkItem |
jiraToRawWorkItem | JIRA问题 RawWorkItem |
githubToRawWorkItem | GitHub 问题/PR + RawWorkItem |
linearToRawWorkItem | 线性问题 RawWorkItem |
manualToRawWorkItem | 自由文本 − RawWorkItem |
类型
| 导出 | 说明 |
|---|---|
RawWorkItem | 一般工作项目投入 |
EnrichedSpec | SEL 输出意图, 受影响的系统, 未知 |
ComplexityScore | CML 输出总分, 风险水平, 推理 |
SimulationResult | PESL 输出有自信, 中止旗, 预测 |
ExecutionOutcome | 图摄入的结果数据 |
有效性
| 导出 | 说明 |
|---|---|
computePersonaEffectiveness | 人均(人,系统) 平地平地成功率 |
detectBlindSpots | 查找故障率高的对( persona, system) |
recommendPersona | 给某个问题提供个人建议 |
PersonaEffectivenessScore | 类型:对一对(人,系统)的平滑成功率 |
BlindSpot | 类型 :( persona, system) 有相容失败的配对 |
PersonaRecommendation | 类型:有分数和覆盖面的推荐人 |
专业
| 导出 | 说明 |
|---|---|
computeSpecialization | 计算( persona, system, taskType) tuple 的专业条目 |
computeExpertiseLevel | 从样本规模和成功率对专门知识级别进行分类 |
buildSpecializationProfile | 构建完整的人物简介a(实力、弱点、总体水平) |
weightedRecommendPersona | 专门化乘数建议 |
decayWeight | 特定年龄结果的指数衰减加权数 |
temporalSuccessRate | 按时间标记的结果计算的临时加权成功率 |
loadProfiles | 从磁盘装入持续的专业配置 |
saveProfiles | 将专业配置保存到 .harness/specialization-profiles.json |
refreshProfiles | 调整和坚持所有个人的简介,使其符合成果 |
SpecializationScore | 类型:综合分数(时间,一致性,体积,复合) |
SpecializationEntry | 类型: 单项( persona, system, taskType) 桶 |
SpecializationProfile | 类型:具有长处、弱点的完整人物简介,总体水平 |
WeightedRecommendation | 类型:有基准分数、专业乘数、加权分数的推荐 |
ExpertiseLevel | 类型 : 'novice' | 'competent' | 'proficient' | 'expert' |
TaskType | 类型:任务类型分类 |
TemporalConfig | 类型:时间衰变配置(半衰期,参考时间) |
ProfileStore | 类型:长期保存专业简介 |
分析
| 导出 | 说明 |
|---|---|
AnthropicAnalysisProvider | 反动支持 AnalysisProvider |
OpenAICompatibleAnalysisProvider | OpenAI/ 本地 LLM 支持 AnalysisProvider |
enrich | SEL 浓缩功能 |
GraphValidator | 基于图表的系统解析器 |
scoreCML | CML 评分函数 |
scoreToConcernSignals | 得分 + ConcernSignal[] 转换 |
PeslSimulator | 分层模拟外观 |
ExecutionOutcomeConnector | 结果图摄入量 |
computeHistoricalComplexity | CML 历史维度 |
许可证
麻省理工学院