Skip to content

Commit f0dcfa2

Browse files
Michaelclaude
andcommitted
feat: Enhance orchestration system with test infrastructure and documentation
Orchestration Enhancements: - backend/services/orchestrator.cjs: Multi-agent sequential workflow orchestration - State-passing between agents (governor → finance → seo → marketing → builder) - Cove Framework threshold logic (18+ score executes all agents, <18 stops early) - Lens validation integration for each agent output - Performance metrics tracking (duration, prompt/response length) - backend/scripts/test-orchestrator.cjs: Test harness for orchestration workflows Documentation: - workspace/docs/Obsidian-v2/plans/active/ORCHESTRATION-TEST-RESULTS.md - Test results for 5-agent workflow validation - Score-based execution thresholds working correctly - workspace/docs/Obsidian-v2/technical/orchestrator-pipeline-fix-2025-10-26.md - Technical details on LensOrchestrator.apply() parameter fix - workspace/docs/Obsidian-v2/tests/test-run-2025-10-26.md - Test execution log and validation results Reference Documentation: - workspace/docs/Obsidian-v2/docs/reference/services/orchestrator.md - Complete orchestrator API and workflow patterns - workspace/docs/Obsidian-v2/docs/reference/tools/*.md - claude-trace, claude-code-docs-map, test-lens-pipeline, soulfield-debugging-options Cleanup: - Remove 72 old test result files (Google Workspace, Drive webhook, production readiness) - Remove 26 test project directories from agent workspace - Remove 2 old marketing campaign files 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent b7eeb06 commit f0dcfa2

83 files changed

Lines changed: 3670 additions & 11662 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* Test multi-agent orchestration system
5+
*
6+
* Tests the sequential orchestration flow:
7+
* @governor → @finance → @seo → @marketing → @builder
8+
*/
9+
10+
const orchestrator = require('../services/orchestrator.cjs');
11+
12+
async function main() {
13+
console.log('='.repeat(60));
14+
console.log('MULTI-AGENT ORCHESTRATION TEST');
15+
console.log('='.repeat(60));
16+
17+
// Test case 1: High-scoring product (should execute all agents)
18+
const goodIdea = `
19+
Product: AI-powered Shopify plugin for automated SEO optimization
20+
Target: E-commerce stores doing $10K-100K/month
21+
Problem: Store owners spend 20+ hours/month on SEO tasks
22+
Solution: One-click SEO automation with AI content generation
23+
Pricing: $97/month subscription
24+
MVP: Chrome extension that analyzes Shopify stores and generates SEO recommendations
25+
`;
26+
27+
// Test case 2: Low-scoring product (should stop at governor)
28+
const badIdea = `
29+
Product: Social network for pet rocks
30+
Target: Pet rock collectors
31+
Problem: No dedicated community for pet rock enthusiasts
32+
Solution: Mobile app for sharing pet rock photos
33+
Pricing: Free with ads
34+
MVP: Basic photo sharing app
35+
`;
36+
37+
try {
38+
// Test 1: Should trigger full workflow
39+
console.log('\n📝 TEST 1: High-scoring product idea');
40+
console.log('Expected: All 5 agents execute\n');
41+
42+
const result1 = await orchestrator.orchestrateWorkflow(goodIdea, 'full');
43+
44+
console.log('\n✅ Test 1 Results:');
45+
console.log(`- Workflow completed: ${result1.steps.length} steps`);
46+
console.log(`- Agents executed: ${result1.steps.map(s => s.agent).join(' → ')}`);
47+
console.log(`- Cove score: ${result1.score || 'N/A'}/25`);
48+
console.log(`- Recommendation: ${result1.recommendation}`);
49+
console.log(`- Duration: ${result1.duration_ms}ms`);
50+
51+
// Test 2: Should stop at governor
52+
console.log('\n📝 TEST 2: Low-scoring product idea');
53+
console.log('Expected: Stop at governor (score < 12)\n');
54+
55+
const result2 = await orchestrator.orchestrateWorkflow(badIdea, 'full');
56+
57+
console.log('\n✅ Test 2 Results:');
58+
console.log(`- Workflow completed: ${result2.steps.length} steps`);
59+
console.log(`- Agents executed: ${result2.steps.map(s => s.agent).join(' → ')}`);
60+
console.log(`- Cove score: ${result2.score || 'N/A'}/25`);
61+
console.log(`- Recommendation: ${result2.recommendation}`);
62+
console.log(`- Duration: ${result2.duration_ms}ms`);
63+
64+
// Summary
65+
console.log('\n' + '='.repeat(60));
66+
console.log('TEST SUMMARY');
67+
console.log('='.repeat(60));
68+
69+
const test1Pass = result1.steps.length === 5;
70+
const test2Pass = result2.steps.length === 1 && result2.recommendation === 'KILL_OR_ITERATE';
71+
72+
console.log(`Test 1 (Full workflow): ${test1Pass ? '✅ PASSED' : '❌ FAILED'}`);
73+
console.log(`Test 2 (Governor stop): ${test2Pass ? '✅ PASSED' : '❌ FAILED'}`);
74+
console.log(`\nOverall: ${test1Pass && test2Pass ? '✅ ALL TESTS PASSED' : '❌ SOME TESTS FAILED'}`);
75+
76+
} catch (error) {
77+
console.error('\n❌ Test failed with error:', error.message);
78+
console.error(error.stack);
79+
process.exit(1);
80+
}
81+
}
82+
83+
// Run if called directly
84+
if (require.main === module) {
85+
main().catch(console.error);
86+
}
87+
88+
module.exports = { main };

backend/services/orchestrator.cjs

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,22 @@ async function orchestrateWorkflow(productIdea, workflowType = 'full') {
159159
const sequence = [];
160160
const startTime = Date.now();
161161

162+
// Initialize orchestration trace
163+
const trace = {
164+
workflowId: `wf_${Date.now()}`,
165+
productIdea: productIdea.slice(0, 200),
166+
workflowType,
167+
startTime: new Date().toISOString(),
168+
steps: []
169+
};
170+
162171
try {
163172
// Step 1: Governor - Cove Framework validation
164173
console.log("\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
165174
console.log("STEP 1: @governor - Cove Framework Validation");
166175
console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
167176

177+
const stepStartTime = Date.now();
168178
const governorResult = await delegateToAgent(
169179
"governor",
170180
"",
@@ -174,6 +184,16 @@ async function orchestrateWorkflow(productIdea, workflowType = 'full') {
174184
results.governor = governorResult;
175185
sequence.push({ step: 1, agent: "governor", success: governorResult.success });
176186

187+
// Add to trace
188+
trace.steps.push({
189+
agent: "governor",
190+
duration: Date.now() - stepStartTime,
191+
promptLength: productIdea.length,
192+
responseLength: governorResult.output?.length || 0,
193+
lensValidation: governorResult.lensValidation,
194+
success: governorResult.success
195+
});
196+
177197
if (!governorResult.success) {
178198
console.warn("[Orchestrator] ⚠️ @governor lens validation failed, continuing with warnings");
179199
}
@@ -202,6 +222,7 @@ async function orchestrateWorkflow(productIdea, workflowType = 'full') {
202222
console.log("STEP 2: @finance - Unit Economics Analysis");
203223
console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
204224

225+
const financeStepStart = Date.now();
205226
const financeResult = await delegateToAgent(
206227
"finance",
207228
context,
@@ -211,6 +232,15 @@ async function orchestrateWorkflow(productIdea, workflowType = 'full') {
211232
results.finance = financeResult;
212233
sequence.push({ step: 2, agent: "finance", success: financeResult.success });
213234

235+
trace.steps.push({
236+
agent: "finance",
237+
duration: Date.now() - financeStepStart,
238+
promptLength: context.length,
239+
responseLength: financeResult.output?.length || 0,
240+
lensValidation: financeResult.lensValidation,
241+
success: financeResult.success
242+
});
243+
214244
if (!financeResult.success) {
215245
console.warn("[Orchestrator] ⚠️ @finance lens validation failed, continuing with warnings");
216246
}
@@ -222,6 +252,7 @@ async function orchestrateWorkflow(productIdea, workflowType = 'full') {
222252
console.log("STEP 3: @seo - Keyword Research & Organic Strategy");
223253
console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
224254

255+
const seoStepStart = Date.now();
225256
const seoResult = await delegateToAgent(
226257
"seo",
227258
context,
@@ -231,6 +262,15 @@ async function orchestrateWorkflow(productIdea, workflowType = 'full') {
231262
results.seo = seoResult;
232263
sequence.push({ step: 3, agent: "seo", success: seoResult.success });
233264

265+
trace.steps.push({
266+
agent: "seo",
267+
duration: Date.now() - seoStepStart,
268+
promptLength: context.length,
269+
responseLength: seoResult.output?.length || 0,
270+
lensValidation: seoResult.lensValidation,
271+
success: seoResult.success
272+
});
273+
234274
if (!seoResult.success) {
235275
console.warn("[Orchestrator] ⚠️ @seo lens validation failed, continuing with warnings");
236276
}
@@ -242,6 +282,7 @@ async function orchestrateWorkflow(productIdea, workflowType = 'full') {
242282
console.log("STEP 4: @marketing - Campaign Strategy & Funnel");
243283
console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
244284

285+
const marketingStepStart = Date.now();
245286
const marketingResult = await delegateToAgent(
246287
"marketing",
247288
context,
@@ -251,6 +292,15 @@ async function orchestrateWorkflow(productIdea, workflowType = 'full') {
251292
results.marketing = marketingResult;
252293
sequence.push({ step: 4, agent: "marketing", success: marketingResult.success });
253294

295+
trace.steps.push({
296+
agent: "marketing",
297+
duration: Date.now() - marketingStepStart,
298+
promptLength: context.length,
299+
responseLength: marketingResult.output?.length || 0,
300+
lensValidation: marketingResult.lensValidation,
301+
success: marketingResult.success
302+
});
303+
254304
if (!marketingResult.success) {
255305
console.warn("[Orchestrator] ⚠️ @marketing lens validation failed, continuing with warnings");
256306
}
@@ -262,6 +312,7 @@ async function orchestrateWorkflow(productIdea, workflowType = 'full') {
262312
console.log("STEP 5: @builder - Implementation Plan");
263313
console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
264314

315+
const builderStepStart = Date.now();
265316
const builderResult = await delegateToAgent(
266317
"builder",
267318
context,
@@ -271,6 +322,15 @@ async function orchestrateWorkflow(productIdea, workflowType = 'full') {
271322
results.builder = builderResult;
272323
sequence.push({ step: 5, agent: "builder", success: builderResult.success });
273324

325+
trace.steps.push({
326+
agent: "builder",
327+
duration: Date.now() - builderStepStart,
328+
promptLength: context.length,
329+
responseLength: builderResult.output?.length || 0,
330+
lensValidation: builderResult.lensValidation,
331+
success: builderResult.success
332+
});
333+
274334
if (!builderResult.success) {
275335
console.warn("[Orchestrator] ⚠️ @builder lens validation failed, continuing with warnings");
276336
}
@@ -287,6 +347,19 @@ async function orchestrateWorkflow(productIdea, workflowType = 'full') {
287347
console.log(`Success rate: ${sequence.filter(s => s.success).length}/${sequence.length}`);
288348
console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n");
289349

350+
// Write orchestration trace to file
351+
const fs = require('fs');
352+
const path = require('path');
353+
const logsDir = path.join(__dirname, '../../workspace/data/logs');
354+
if (!fs.existsSync(logsDir)) {
355+
fs.mkdirSync(logsDir, { recursive: true });
356+
}
357+
const traceFile = path.join(logsDir, `orchestration-${trace.workflowId}.json`);
358+
trace.endTime = new Date().toISOString();
359+
trace.duration = duration;
360+
fs.writeFileSync(traceFile, JSON.stringify(trace, null, 2));
361+
console.log(`[Orchestrator] Trace written to ${traceFile}`);
362+
290363
return {
291364
workflow: workflowType,
292365
recommendation: 'SHIP',

backend/tests/results/drive-webhook-validation-2025-10-18T19-40-18.551Z.json

Lines changed: 0 additions & 36 deletions
This file was deleted.

backend/tests/results/drive-webhook-validation-2025-10-21T23-02-49.870Z.json

Lines changed: 0 additions & 36 deletions
This file was deleted.

backend/tests/results/drive-webhook-validation-2025-10-25T02-56-29.056Z.json

Lines changed: 0 additions & 36 deletions
This file was deleted.

backend/tests/results/drive-webhook-validation-2025-10-25T03-02-07.085Z.json

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)