feat(05-01): add Atlas and Prometheus delegation prompt builders
- Build pure prompt constructors with confirmed finding context and agreement levels - Add BDD tests for fix/planning intent, question context, and single-finding edge cases
This commit is contained in:
parent
665499a40d
commit
29afaf527c
125
src/agents/athena/delegation-prompts.test.ts
Normal file
125
src/agents/athena/delegation-prompts.test.ts
Normal file
@ -0,0 +1,125 @@
|
||||
import { describe, expect, test } from "bun:test"
|
||||
import type { SynthesizedFinding } from "./synthesis-types"
|
||||
import { buildAtlasDelegationPrompt, buildPrometheusDelegationPrompt } from "./delegation-prompts"
|
||||
|
||||
function createConfirmedFindings(): SynthesizedFinding[] {
|
||||
return [
|
||||
{
|
||||
summary: "Guard missing council config in startup",
|
||||
details: "Athena path can proceed with undefined council members in some flows.",
|
||||
agreementLevel: "unanimous",
|
||||
reportedBy: ["OpenAI", "Claude", "Gemini"],
|
||||
assessment: {
|
||||
agrees: true,
|
||||
rationale: "Directly observed from startup and config fallback paths.",
|
||||
},
|
||||
isFalsePositiveRisk: false,
|
||||
},
|
||||
{
|
||||
summary: "Potential retry thrash in background runner",
|
||||
details: "Repeated failures can cascade retry windows under high load.",
|
||||
agreementLevel: "minority",
|
||||
reportedBy: ["Claude"],
|
||||
assessment: {
|
||||
agrees: true,
|
||||
rationale: "Worth addressing to lower operational risk.",
|
||||
},
|
||||
isFalsePositiveRisk: false,
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
describe("buildAtlasDelegationPrompt", () => {
|
||||
//#given confirmed findings and an original question
|
||||
//#when the Atlas delegation prompt is built
|
||||
//#then it includes both findings and the original question context
|
||||
test("includes confirmed findings summaries and original question", () => {
|
||||
const findings = createConfirmedFindings()
|
||||
const question = "Which issues should we fix first in Athena integration?"
|
||||
|
||||
const prompt = buildAtlasDelegationPrompt(findings, question)
|
||||
|
||||
expect(prompt).toContain("Original question")
|
||||
expect(prompt).toContain(question)
|
||||
expect(prompt).toContain("Guard missing council config in startup")
|
||||
expect(prompt).toContain("Potential retry thrash in background runner")
|
||||
})
|
||||
|
||||
//#given confirmed findings
|
||||
//#when Atlas prompt is generated
|
||||
//#then it explicitly asks Atlas to fix those specific issues
|
||||
test("instructs Atlas to implement direct fixes", () => {
|
||||
const prompt = buildAtlasDelegationPrompt(createConfirmedFindings(), "Fix Athena reliability issues")
|
||||
|
||||
expect(prompt).toContain("Fix these confirmed issues directly")
|
||||
expect(prompt).toContain("Implement code changes")
|
||||
expect(prompt).toContain("prioritize by agreement level")
|
||||
})
|
||||
|
||||
//#given a single confirmed finding
|
||||
//#when Atlas prompt is generated
|
||||
//#then prompt still renders correctly for edge case input
|
||||
test("handles a single finding edge case", () => {
|
||||
const [singleFinding] = createConfirmedFindings()
|
||||
|
||||
const prompt = buildAtlasDelegationPrompt([singleFinding], "Fix this one issue")
|
||||
|
||||
expect(prompt).toContain("1. Guard missing council config in startup")
|
||||
expect(prompt).toContain("Agreement level: unanimous")
|
||||
})
|
||||
})
|
||||
|
||||
describe("buildPrometheusDelegationPrompt", () => {
|
||||
//#given confirmed findings and an original question
|
||||
//#when the Prometheus delegation prompt is built
|
||||
//#then it includes both findings and the original question context
|
||||
test("includes confirmed findings summaries and original question", () => {
|
||||
const findings = createConfirmedFindings()
|
||||
const question = "How should we sequence Athena integration hardening work?"
|
||||
|
||||
const prompt = buildPrometheusDelegationPrompt(findings, question)
|
||||
|
||||
expect(prompt).toContain("Original question")
|
||||
expect(prompt).toContain(question)
|
||||
expect(prompt).toContain("Guard missing council config in startup")
|
||||
expect(prompt).toContain("Potential retry thrash in background runner")
|
||||
})
|
||||
|
||||
//#given confirmed findings
|
||||
//#when Prometheus prompt is generated
|
||||
//#then it explicitly asks for phased planning and prioritization
|
||||
test("instructs Prometheus to create an execution plan", () => {
|
||||
const prompt = buildPrometheusDelegationPrompt(createConfirmedFindings(), "Plan Athena stabilization")
|
||||
|
||||
expect(prompt).toContain("Create an execution plan")
|
||||
expect(prompt).toContain("phased implementation plan")
|
||||
expect(prompt).toContain("prioritize by agreement level and impact")
|
||||
})
|
||||
|
||||
//#given a single confirmed finding
|
||||
//#when Prometheus prompt is generated
|
||||
//#then prompt still renders correctly for edge case input
|
||||
test("handles a single finding edge case", () => {
|
||||
const [singleFinding] = createConfirmedFindings()
|
||||
|
||||
const prompt = buildPrometheusDelegationPrompt([singleFinding], "Plan this one issue")
|
||||
|
||||
expect(prompt).toContain("1. Guard missing council config in startup")
|
||||
expect(prompt).toContain("Agreement level: unanimous")
|
||||
})
|
||||
|
||||
//#given findings at multiple agreement levels
|
||||
//#when either delegation prompt is generated
|
||||
//#then each finding includes agreement level context
|
||||
test("includes agreement level context for each finding in both prompts", () => {
|
||||
const findings = createConfirmedFindings()
|
||||
|
||||
const atlasPrompt = buildAtlasDelegationPrompt(findings, "Atlas context")
|
||||
const prometheusPrompt = buildPrometheusDelegationPrompt(findings, "Prometheus context")
|
||||
|
||||
expect(atlasPrompt).toContain("Agreement level: unanimous")
|
||||
expect(atlasPrompt).toContain("Agreement level: minority")
|
||||
expect(prometheusPrompt).toContain("Agreement level: unanimous")
|
||||
expect(prometheusPrompt).toContain("Agreement level: minority")
|
||||
})
|
||||
})
|
||||
55
src/agents/athena/delegation-prompts.ts
Normal file
55
src/agents/athena/delegation-prompts.ts
Normal file
@ -0,0 +1,55 @@
|
||||
import type { SynthesizedFinding } from "./synthesis-types"
|
||||
|
||||
function formatFindingBlock(finding: SynthesizedFinding, index: number): string {
|
||||
const assessment = finding.assessment.agrees ? "Agrees" : "Disagrees"
|
||||
|
||||
return [
|
||||
`${index + 1}. ${finding.summary}`,
|
||||
` Details: ${finding.details}`,
|
||||
` Agreement level: ${finding.agreementLevel}`,
|
||||
` Athena assessment: ${assessment}`,
|
||||
` Rationale: ${finding.assessment.rationale}`,
|
||||
].join("\n")
|
||||
}
|
||||
|
||||
function formatConfirmedFindings(confirmedFindings: SynthesizedFinding[]): string {
|
||||
return confirmedFindings.map((finding, index) => formatFindingBlock(finding, index)).join("\n\n")
|
||||
}
|
||||
|
||||
export function buildAtlasDelegationPrompt(confirmedFindings: SynthesizedFinding[], question: string): string {
|
||||
return [
|
||||
"# Atlas Delegation Brief",
|
||||
"Original question:",
|
||||
question,
|
||||
"",
|
||||
"Task:",
|
||||
"Fix these confirmed issues directly.",
|
||||
"",
|
||||
"Confirmed findings:",
|
||||
formatConfirmedFindings(confirmedFindings),
|
||||
"",
|
||||
"Execution instructions:",
|
||||
"- Implement code changes to resolve each confirmed issue.",
|
||||
"- prioritize by agreement level, addressing unanimous findings first.",
|
||||
"- Validate fixes with relevant tests and type safety checks.",
|
||||
].join("\n")
|
||||
}
|
||||
|
||||
export function buildPrometheusDelegationPrompt(confirmedFindings: SynthesizedFinding[], question: string): string {
|
||||
return [
|
||||
"# Prometheus Delegation Brief",
|
||||
"Original question:",
|
||||
question,
|
||||
"",
|
||||
"Task:",
|
||||
"Create an execution plan for these confirmed issues.",
|
||||
"",
|
||||
"Confirmed findings:",
|
||||
formatConfirmedFindings(confirmedFindings),
|
||||
"",
|
||||
"Planning instructions:",
|
||||
"- Produce a phased implementation plan with clear task boundaries.",
|
||||
"- prioritize by agreement level and impact.",
|
||||
"- Include verification checkpoints for each phase.",
|
||||
].join("\n")
|
||||
}
|
||||
@ -7,4 +7,6 @@ export * from "./council-result-collector"
|
||||
export * from "./synthesis-types"
|
||||
export * from "./synthesis-prompt"
|
||||
export * from "./synthesis-formatter"
|
||||
export * from "./findings-presenter"
|
||||
export * from "./delegation-prompts"
|
||||
export * from "../../config/schema/athena"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user