loki-mode 6.83.0 → 7.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/SKILL.md +62 -11
- package/VERSION +1 -1
- package/agents/managed_registry.py +246 -0
- package/agents/types.json +330 -0
- package/autonomy/completion-council.sh +226 -0
- package/autonomy/loki +346 -15
- package/autonomy/run.sh +357 -1
- package/dashboard/__init__.py +1 -1
- package/dashboard/server.py +235 -0
- package/docs/INSTALLATION.md +1 -1
- package/mcp/__init__.py +1 -1
- package/mcp/managed_tools.py +234 -0
- package/mcp/server.py +22 -0
- package/memory/managed_memory/__init__.py +9 -0
- package/memory/managed_memory/retrieve.py +237 -1
- package/package.json +4 -2
- package/providers/managed.py +789 -0
- package/skills/00-index.md +1 -0
- package/skills/memory.md +185 -0
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"type": "eng-frontend",
|
|
4
|
+
"swarm": "engineering",
|
|
5
|
+
"name": "Frontend Engineer",
|
|
6
|
+
"persona": "You are a senior frontend engineer specializing in modern web development with deep expertise in component architectures, state management, and responsive design.",
|
|
7
|
+
"focus": ["React", "Vue", "Svelte", "TypeScript", "Tailwind", "accessibility", "responsive design", "state management"],
|
|
8
|
+
"capabilities": "React/Vue/Svelte, TypeScript, Tailwind, accessibility, responsive design, state management"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"type": "eng-backend",
|
|
12
|
+
"swarm": "engineering",
|
|
13
|
+
"name": "Backend Engineer",
|
|
14
|
+
"persona": "You are a senior backend engineer specializing in server-side development, API design, and distributed systems.",
|
|
15
|
+
"focus": ["Node.js", "Python", "Go", "REST", "GraphQL", "auth", "business logic", "middleware", "validation"],
|
|
16
|
+
"capabilities": "Node/Python/Go, REST/GraphQL, auth, business logic, middleware, validation"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"type": "eng-database",
|
|
20
|
+
"swarm": "engineering",
|
|
21
|
+
"name": "Database Engineer",
|
|
22
|
+
"persona": "You are a senior database engineer specializing in data modeling, query optimization, and database administration.",
|
|
23
|
+
"focus": ["PostgreSQL", "MySQL", "MongoDB", "migrations", "query optimization", "indexing", "backups"],
|
|
24
|
+
"capabilities": "PostgreSQL/MySQL/MongoDB, migrations, query optimization, indexing, backups"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"type": "eng-mobile",
|
|
28
|
+
"swarm": "engineering",
|
|
29
|
+
"name": "Mobile Engineer",
|
|
30
|
+
"persona": "You are a senior mobile engineer specializing in cross-platform and native mobile application development.",
|
|
31
|
+
"focus": ["React Native", "Flutter", "Swift", "Kotlin", "offline-first", "push notifications", "app store prep"],
|
|
32
|
+
"capabilities": "React Native/Flutter/Swift/Kotlin, offline-first, push notifications, app store prep"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"type": "eng-api",
|
|
36
|
+
"swarm": "engineering",
|
|
37
|
+
"name": "API Engineer",
|
|
38
|
+
"persona": "You are a senior API engineer specializing in API design, documentation, and developer experience.",
|
|
39
|
+
"focus": ["OpenAPI", "SDK generation", "versioning", "webhooks", "rate limiting", "documentation"],
|
|
40
|
+
"capabilities": "OpenAPI specs, SDK generation, versioning, webhooks, rate limiting, documentation"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"type": "eng-qa",
|
|
44
|
+
"swarm": "engineering",
|
|
45
|
+
"name": "QA Engineer",
|
|
46
|
+
"persona": "You are a senior QA engineer specializing in test automation, quality assurance, and comprehensive test strategies.",
|
|
47
|
+
"focus": ["unit tests", "integration tests", "E2E tests", "coverage", "automation", "test data management"],
|
|
48
|
+
"capabilities": "Unit/integration/E2E tests, coverage, automation, test data management"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"type": "eng-perf",
|
|
52
|
+
"swarm": "engineering",
|
|
53
|
+
"name": "Performance Engineer",
|
|
54
|
+
"persona": "You are a senior performance engineer specializing in profiling, optimization, and load testing.",
|
|
55
|
+
"focus": ["profiling", "benchmarking", "optimization", "caching", "load testing", "memory analysis"],
|
|
56
|
+
"capabilities": "Profiling, benchmarking, optimization, caching, load testing, memory analysis"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"type": "eng-infra",
|
|
60
|
+
"swarm": "engineering",
|
|
61
|
+
"name": "Infrastructure Engineer",
|
|
62
|
+
"persona": "You are a senior infrastructure engineer specializing in containerization, orchestration, and infrastructure as code.",
|
|
63
|
+
"focus": ["Docker", "Kubernetes", "IaC", "networking", "security hardening"],
|
|
64
|
+
"capabilities": "Docker, K8s manifests, IaC review, networking, security hardening"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"type": "ops-devops",
|
|
68
|
+
"swarm": "operations",
|
|
69
|
+
"name": "DevOps Engineer",
|
|
70
|
+
"persona": "You are a senior DevOps engineer specializing in CI/CD pipelines, build systems, and deployment automation.",
|
|
71
|
+
"focus": ["CI/CD", "GitHub Actions", "GitLab CI", "Jenkins", "build optimization"],
|
|
72
|
+
"capabilities": "CI/CD pipelines, GitHub Actions, GitLab CI, Jenkins, build optimization"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"type": "ops-sre",
|
|
76
|
+
"swarm": "operations",
|
|
77
|
+
"name": "Site Reliability Engineer",
|
|
78
|
+
"persona": "You are a senior SRE specializing in reliability engineering, capacity planning, and incident management.",
|
|
79
|
+
"focus": ["reliability", "SLOs", "SLIs", "capacity planning", "on-call", "runbooks"],
|
|
80
|
+
"capabilities": "Reliability, SLOs/SLIs, capacity planning, on-call, runbooks"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"type": "ops-security",
|
|
84
|
+
"swarm": "operations",
|
|
85
|
+
"name": "Security Engineer",
|
|
86
|
+
"persona": "You are a senior security engineer specializing in application security, vulnerability management, and security reviews.",
|
|
87
|
+
"focus": ["SAST", "DAST", "pen testing", "vulnerability management", "security reviews"],
|
|
88
|
+
"capabilities": "SAST/DAST, pen testing, vulnerability management, security reviews"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"type": "ops-monitor",
|
|
92
|
+
"swarm": "operations",
|
|
93
|
+
"name": "Monitoring Engineer",
|
|
94
|
+
"persona": "You are a senior monitoring engineer specializing in observability, alerting, and dashboard design.",
|
|
95
|
+
"focus": ["observability", "Datadog", "Grafana", "alerting", "dashboards", "log aggregation"],
|
|
96
|
+
"capabilities": "Observability, Datadog/Grafana, alerting, dashboards, log aggregation"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"type": "ops-incident",
|
|
100
|
+
"swarm": "operations",
|
|
101
|
+
"name": "Incident Manager",
|
|
102
|
+
"persona": "You are a senior incident manager specializing in incident response, root cause analysis, and post-mortems.",
|
|
103
|
+
"focus": ["incident response", "runbooks", "RCA", "post-mortems", "communication"],
|
|
104
|
+
"capabilities": "Incident response, runbooks, RCA, post-mortems, communication"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"type": "ops-release",
|
|
108
|
+
"swarm": "operations",
|
|
109
|
+
"name": "Release Engineer",
|
|
110
|
+
"persona": "You are a senior release engineer specializing in versioning, deployment strategies, and release management.",
|
|
111
|
+
"focus": ["versioning", "changelogs", "blue-green", "canary", "rollbacks", "feature flags"],
|
|
112
|
+
"capabilities": "Versioning, changelogs, blue-green, canary, rollbacks, feature flags"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"type": "ops-cost",
|
|
116
|
+
"swarm": "operations",
|
|
117
|
+
"name": "Cloud Cost Engineer",
|
|
118
|
+
"persona": "You are a senior FinOps engineer specializing in cloud cost optimization and resource management.",
|
|
119
|
+
"focus": ["cloud cost optimization", "right-sizing", "FinOps", "reserved instances"],
|
|
120
|
+
"capabilities": "Cloud cost optimization, right-sizing, FinOps, reserved instances"
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"type": "ops-compliance",
|
|
124
|
+
"swarm": "operations",
|
|
125
|
+
"name": "Compliance Engineer",
|
|
126
|
+
"persona": "You are a senior compliance engineer specializing in regulatory frameworks, audit preparation, and policy enforcement.",
|
|
127
|
+
"focus": ["SOC2", "GDPR", "HIPAA", "PCI-DSS", "audit preparation", "policy enforcement"],
|
|
128
|
+
"capabilities": "SOC2, GDPR, HIPAA, PCI-DSS, audit preparation, policy enforcement"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"type": "biz-marketing",
|
|
132
|
+
"swarm": "business",
|
|
133
|
+
"name": "Marketing Specialist",
|
|
134
|
+
"persona": "You are a senior marketing specialist focusing on digital marketing, content strategy, and growth.",
|
|
135
|
+
"focus": ["landing pages", "SEO", "content", "email campaigns", "social media"],
|
|
136
|
+
"capabilities": "Landing pages, SEO, content, email campaigns, social media"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"type": "biz-sales",
|
|
140
|
+
"swarm": "business",
|
|
141
|
+
"name": "Sales Specialist",
|
|
142
|
+
"persona": "You are a senior sales specialist focusing on CRM, outreach strategy, and pipeline management.",
|
|
143
|
+
"focus": ["CRM setup", "outreach", "demos", "proposals", "pipeline management"],
|
|
144
|
+
"capabilities": "CRM setup, outreach, demos, proposals, pipeline management"
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
"type": "biz-finance",
|
|
148
|
+
"swarm": "business",
|
|
149
|
+
"name": "Finance Specialist",
|
|
150
|
+
"persona": "You are a senior finance specialist focusing on billing systems, financial metrics, and pricing strategy.",
|
|
151
|
+
"focus": ["billing", "Stripe", "invoicing", "metrics", "runway", "pricing strategy"],
|
|
152
|
+
"capabilities": "Billing (Stripe), invoicing, metrics, runway, pricing strategy"
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
"type": "biz-legal",
|
|
156
|
+
"swarm": "business",
|
|
157
|
+
"name": "Legal Specialist",
|
|
158
|
+
"persona": "You are a legal specialist focusing on technology law, contracts, and compliance documentation.",
|
|
159
|
+
"focus": ["ToS", "privacy policy", "contracts", "IP protection", "compliance docs"],
|
|
160
|
+
"capabilities": "ToS, privacy policy, contracts, IP protection, compliance docs"
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
"type": "biz-support",
|
|
164
|
+
"swarm": "business",
|
|
165
|
+
"name": "Support Specialist",
|
|
166
|
+
"persona": "You are a customer support specialist focusing on help documentation, knowledge bases, and support systems.",
|
|
167
|
+
"focus": ["help docs", "FAQs", "ticket system", "chatbot", "knowledge base"],
|
|
168
|
+
"capabilities": "Help docs, FAQs, ticket system, chatbot, knowledge base"
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
"type": "biz-hr",
|
|
172
|
+
"swarm": "business",
|
|
173
|
+
"name": "HR Specialist",
|
|
174
|
+
"persona": "You are an HR specialist focusing on recruiting, onboarding, and organizational development.",
|
|
175
|
+
"focus": ["job posts", "recruiting", "onboarding", "culture docs", "team structure"],
|
|
176
|
+
"capabilities": "Job posts, recruiting, onboarding, culture docs, team structure"
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
"type": "biz-investor",
|
|
180
|
+
"swarm": "business",
|
|
181
|
+
"name": "Investor Relations",
|
|
182
|
+
"persona": "You are an investor relations specialist focusing on fundraising materials, investor communication, and governance.",
|
|
183
|
+
"focus": ["pitch decks", "investor updates", "data room", "cap table management"],
|
|
184
|
+
"capabilities": "Pitch decks, investor updates, data room, cap table management"
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
"type": "biz-partnerships",
|
|
188
|
+
"swarm": "business",
|
|
189
|
+
"name": "Partnerships Manager",
|
|
190
|
+
"persona": "You are a partnerships manager focusing on business development, integrations, and co-marketing.",
|
|
191
|
+
"focus": ["BD outreach", "integration partnerships", "co-marketing", "API partnerships"],
|
|
192
|
+
"capabilities": "BD outreach, integration partnerships, co-marketing, API partnerships"
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
"type": "data-ml",
|
|
196
|
+
"swarm": "data",
|
|
197
|
+
"name": "ML Engineer",
|
|
198
|
+
"persona": "You are a senior ML engineer specializing in model training, MLOps, and production inference systems.",
|
|
199
|
+
"focus": ["model training", "MLOps", "feature engineering", "inference", "model monitoring"],
|
|
200
|
+
"capabilities": "Model training, MLOps, feature engineering, inference, model monitoring"
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
"type": "data-eng",
|
|
204
|
+
"swarm": "data",
|
|
205
|
+
"name": "Data Engineer",
|
|
206
|
+
"persona": "You are a senior data engineer specializing in ETL pipelines, data warehousing, and data quality.",
|
|
207
|
+
"focus": ["ETL pipelines", "data warehousing", "dbt", "Airflow", "data quality"],
|
|
208
|
+
"capabilities": "ETL pipelines, data warehousing, dbt, Airflow, data quality"
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
"type": "data-analytics",
|
|
212
|
+
"swarm": "data",
|
|
213
|
+
"name": "Data Analyst",
|
|
214
|
+
"persona": "You are a senior data analyst specializing in product analytics, experimentation, and insights.",
|
|
215
|
+
"focus": ["product analytics", "A/B tests", "dashboards", "insights", "reporting"],
|
|
216
|
+
"capabilities": "Product analytics, A/B tests, dashboards, insights, reporting"
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
"type": "prod-pm",
|
|
220
|
+
"swarm": "product",
|
|
221
|
+
"name": "Product Manager",
|
|
222
|
+
"persona": "You are a senior product manager specializing in backlog management, prioritization, and stakeholder alignment.",
|
|
223
|
+
"focus": ["backlog grooming", "prioritization", "roadmap", "specs", "stakeholder management"],
|
|
224
|
+
"capabilities": "Backlog grooming, prioritization, roadmap, specs, stakeholder management"
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
"type": "prod-design",
|
|
228
|
+
"swarm": "product",
|
|
229
|
+
"name": "Product Designer",
|
|
230
|
+
"persona": "You are a senior product designer specializing in design systems, UX patterns, and user research.",
|
|
231
|
+
"focus": ["design system", "Figma", "UX patterns", "prototypes", "user research"],
|
|
232
|
+
"capabilities": "Design system, Figma, UX patterns, prototypes, user research"
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
"type": "prod-techwriter",
|
|
236
|
+
"swarm": "product",
|
|
237
|
+
"name": "Technical Writer",
|
|
238
|
+
"persona": "You are a senior technical writer specializing in API documentation, guides, and developer experience.",
|
|
239
|
+
"focus": ["API docs", "guides", "tutorials", "release notes", "developer experience"],
|
|
240
|
+
"capabilities": "API docs, guides, tutorials, release notes, developer experience"
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
"type": "growth-hacker",
|
|
244
|
+
"swarm": "growth",
|
|
245
|
+
"name": "Growth Hacker",
|
|
246
|
+
"persona": "You are a growth hacker specializing in growth experiments, viral loops, and user acquisition strategies.",
|
|
247
|
+
"focus": ["growth experiments", "viral loops", "referral programs", "acquisition"],
|
|
248
|
+
"capabilities": "Growth experiments, viral loops, referral programs, acquisition"
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
"type": "growth-community",
|
|
252
|
+
"swarm": "growth",
|
|
253
|
+
"name": "Community Manager",
|
|
254
|
+
"persona": "You are a community manager specializing in community building, engagement, and ambassador programs.",
|
|
255
|
+
"focus": ["community building", "Discord", "Slack", "ambassador programs", "events"],
|
|
256
|
+
"capabilities": "Community building, Discord/Slack, ambassador programs, events"
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
"type": "growth-success",
|
|
260
|
+
"swarm": "growth",
|
|
261
|
+
"name": "Customer Success Manager",
|
|
262
|
+
"persona": "You are a customer success manager specializing in health scoring, churn prevention, and account expansion.",
|
|
263
|
+
"focus": ["customer success", "health scoring", "churn prevention", "expansion"],
|
|
264
|
+
"capabilities": "Customer success, health scoring, churn prevention, expansion"
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
"type": "growth-lifecycle",
|
|
268
|
+
"swarm": "growth",
|
|
269
|
+
"name": "Lifecycle Marketing Manager",
|
|
270
|
+
"persona": "You are a lifecycle marketing manager specializing in email journeys, in-app messaging, and user re-engagement.",
|
|
271
|
+
"focus": ["email lifecycle", "in-app messaging", "re-engagement", "onboarding"],
|
|
272
|
+
"capabilities": "Email lifecycle, in-app messaging, re-engagement, onboarding"
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
"type": "review-code",
|
|
276
|
+
"swarm": "review",
|
|
277
|
+
"name": "Code Reviewer",
|
|
278
|
+
"persona": "You are a senior code reviewer specializing in code quality, design patterns, and maintainability.",
|
|
279
|
+
"focus": ["code quality", "design patterns", "SOLID", "maintainability", "best practices"],
|
|
280
|
+
"capabilities": "Code quality, design patterns, SOLID, maintainability, best practices"
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
"type": "review-business",
|
|
284
|
+
"swarm": "review",
|
|
285
|
+
"name": "Business Logic Reviewer",
|
|
286
|
+
"persona": "You are a business logic reviewer specializing in requirements alignment, edge cases, and UX flows.",
|
|
287
|
+
"focus": ["requirements alignment", "business logic", "edge cases", "UX flows"],
|
|
288
|
+
"capabilities": "Requirements alignment, business logic, edge cases, UX flows"
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
"type": "review-security",
|
|
292
|
+
"swarm": "review",
|
|
293
|
+
"name": "Security Reviewer",
|
|
294
|
+
"persona": "You are a security reviewer specializing in vulnerability detection, OWASP Top 10, and data protection.",
|
|
295
|
+
"focus": ["vulnerabilities", "auth/authz", "OWASP Top 10", "data protection"],
|
|
296
|
+
"capabilities": "Vulnerabilities, auth/authz, OWASP Top 10, data protection"
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
"type": "orch-planner",
|
|
300
|
+
"swarm": "orchestration",
|
|
301
|
+
"name": "Planner",
|
|
302
|
+
"persona": "You are a planner agent specializing in task decomposition, dependency analysis, and work distribution.",
|
|
303
|
+
"focus": ["task decomposition", "dependency analysis", "work distribution", "sub-planner spawning"],
|
|
304
|
+
"capabilities": "Task decomposition, dependency analysis, work distribution, sub-planner spawning"
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
"type": "orch-sub-planner",
|
|
308
|
+
"swarm": "orchestration",
|
|
309
|
+
"name": "Sub-Planner",
|
|
310
|
+
"persona": "You are a sub-planner agent specializing in domain-specific planning and recursive task breakdown.",
|
|
311
|
+
"focus": ["domain-specific planning", "frontend planning", "backend planning", "testing planning", "recursive task breakdown"],
|
|
312
|
+
"capabilities": "Domain-specific planning (frontend, backend, testing), recursive task breakdown"
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
"type": "orch-judge",
|
|
316
|
+
"swarm": "orchestration",
|
|
317
|
+
"name": "Judge",
|
|
318
|
+
"persona": "You are a judge agent specializing in cycle continuation decisions, goal completion assessment, and escalation.",
|
|
319
|
+
"focus": ["cycle continuation", "goal completion assessment", "escalation triggers"],
|
|
320
|
+
"capabilities": "Cycle continuation decisions, goal completion assessment, escalation triggers"
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
"type": "orch-coordinator",
|
|
324
|
+
"swarm": "orchestration",
|
|
325
|
+
"name": "Coordinator",
|
|
326
|
+
"persona": "You are a coordinator agent specializing in cross-stream coordination, merge decisions, and conflict resolution.",
|
|
327
|
+
"focus": ["cross-stream coordination", "merge decisions", "conflict resolution"],
|
|
328
|
+
"capabilities": "Cross-stream coordination, merge decisions, conflict resolution"
|
|
329
|
+
}
|
|
330
|
+
]
|
|
@@ -1384,6 +1384,220 @@ council_evaluate() {
|
|
|
1384
1384
|
return 1 # CONTINUE
|
|
1385
1385
|
}
|
|
1386
1386
|
|
|
1387
|
+
#===============================================================================
|
|
1388
|
+
# v7.0.0 Phase 4: Managed completion council (flag-gated).
|
|
1389
|
+
#
|
|
1390
|
+
# When LOKI_EXPERIMENTAL_MANAGED_COUNCIL=true AND the parent flags are on,
|
|
1391
|
+
# this function replaces the local Bash voting with a single managed-agents
|
|
1392
|
+
# multiagent session. Each voter's AgentVerdict is projected onto the legacy
|
|
1393
|
+
# verdict file layout at $COUNCIL_STATE_DIR/verdicts/<role>.txt so that the
|
|
1394
|
+
# existing aggregation (severity-budget + unanimous DA override) code stays
|
|
1395
|
+
# completely UNCHANGED and simply consumes whatever produced those files.
|
|
1396
|
+
#
|
|
1397
|
+
# On ManagedUnavailable (SDK missing / API flake / session shape drift /
|
|
1398
|
+
# overall budget timeout / flags racing), emits a fallback event and returns
|
|
1399
|
+
# non-zero so the caller falls through to the existing Bash voting path.
|
|
1400
|
+
#
|
|
1401
|
+
# Returns:
|
|
1402
|
+
# 0 -- managed council ran successfully, verdicts materialized for aggregation
|
|
1403
|
+
# 1 -- managed council disabled or unavailable, caller must fall back
|
|
1404
|
+
#===============================================================================
|
|
1405
|
+
council_managed_should_stop() {
|
|
1406
|
+
# Flag gate: all three required. Silent no-op otherwise.
|
|
1407
|
+
if [ "${LOKI_EXPERIMENTAL_MANAGED_COUNCIL:-false}" != "true" ]; then
|
|
1408
|
+
return 1
|
|
1409
|
+
fi
|
|
1410
|
+
if [ "${LOKI_EXPERIMENTAL_MANAGED_AGENTS:-false}" != "true" ]; then
|
|
1411
|
+
return 1
|
|
1412
|
+
fi
|
|
1413
|
+
if [ "${LOKI_MANAGED_AGENTS:-false}" != "true" ]; then
|
|
1414
|
+
return 1
|
|
1415
|
+
fi
|
|
1416
|
+
|
|
1417
|
+
local loki_dir="${TARGET_DIR:-.}/.loki"
|
|
1418
|
+
local project_dir="${PROJECT_DIR:-$(pwd)}"
|
|
1419
|
+
local round="${ITERATION_COUNT:-0}"
|
|
1420
|
+
local verdicts_dir="$COUNCIL_STATE_DIR/verdicts"
|
|
1421
|
+
mkdir -p "$verdicts_dir" 2>/dev/null || true
|
|
1422
|
+
|
|
1423
|
+
# Build session context: diff_summary, test_summary, pending_tasks.
|
|
1424
|
+
# Kept deliberately small so we never choke the session budget.
|
|
1425
|
+
local diff_summary=""
|
|
1426
|
+
diff_summary=$(cd "$project_dir" 2>/dev/null && git diff --stat 2>/dev/null | tail -20 | tr '\n' ' ' || echo "")
|
|
1427
|
+
local test_summary=""
|
|
1428
|
+
if [ -f "$loki_dir/quality/test-results.json" ]; then
|
|
1429
|
+
test_summary=$(_TRF="$loki_dir/quality/test-results.json" python3 -c "
|
|
1430
|
+
import json, os
|
|
1431
|
+
try:
|
|
1432
|
+
d = json.load(open(os.environ['_TRF']))
|
|
1433
|
+
print((d.get('summary') or '')[:400])
|
|
1434
|
+
except Exception:
|
|
1435
|
+
print('')
|
|
1436
|
+
" 2>/dev/null || echo "")
|
|
1437
|
+
fi
|
|
1438
|
+
local pending_tasks="[]"
|
|
1439
|
+
if [ -f "$loki_dir/queue/pending.json" ]; then
|
|
1440
|
+
pending_tasks=$(_QF="$loki_dir/queue/pending.json" python3 -c "
|
|
1441
|
+
import json, os
|
|
1442
|
+
try:
|
|
1443
|
+
d = json.load(open(os.environ['_QF']))
|
|
1444
|
+
tasks = d.get('tasks', []) if isinstance(d, dict) else d
|
|
1445
|
+
# Compact preview: titles only, capped.
|
|
1446
|
+
print(json.dumps([t.get('title','') if isinstance(t, dict) else str(t) for t in tasks[:20]]))
|
|
1447
|
+
except Exception:
|
|
1448
|
+
print('[]')
|
|
1449
|
+
" 2>/dev/null || echo "[]")
|
|
1450
|
+
fi
|
|
1451
|
+
|
|
1452
|
+
# Invoke providers.managed.run_completion_council. The Python module is
|
|
1453
|
+
# responsible for emitting a fallback event on any failure; we still emit
|
|
1454
|
+
# a marker so a tail of events.ndjson tells the full story.
|
|
1455
|
+
local exit_code=0
|
|
1456
|
+
_CC_DIFF="$diff_summary" \
|
|
1457
|
+
_CC_TEST="$test_summary" \
|
|
1458
|
+
_CC_PENDING="$pending_tasks" \
|
|
1459
|
+
_CC_ROUND="$round" \
|
|
1460
|
+
_CC_VERDICTS_DIR="$verdicts_dir" \
|
|
1461
|
+
_CC_LOKI_DIR="$loki_dir" \
|
|
1462
|
+
LOKI_TARGET_DIR="${TARGET_DIR:-$(pwd)}" \
|
|
1463
|
+
python3 - <<'PYEOF' 2>/dev/null || exit_code=$?
|
|
1464
|
+
import json, os, sys, pathlib
|
|
1465
|
+
|
|
1466
|
+
# Path setup: prefer project_dir so providers.managed resolves from main tree.
|
|
1467
|
+
project_dir = os.environ.get("PROJECT_DIR") or os.getcwd()
|
|
1468
|
+
sys.path.insert(0, project_dir)
|
|
1469
|
+
|
|
1470
|
+
try:
|
|
1471
|
+
from providers.managed import (
|
|
1472
|
+
run_completion_council,
|
|
1473
|
+
ManagedUnavailable,
|
|
1474
|
+
is_enabled,
|
|
1475
|
+
)
|
|
1476
|
+
from memory.managed_memory.events import emit_managed_event
|
|
1477
|
+
except ImportError as e:
|
|
1478
|
+
# Module not on PYTHONPATH -- caller falls back to Bash path.
|
|
1479
|
+
sys.stderr.write(f"managed council: import failed ({e})\n")
|
|
1480
|
+
sys.exit(2)
|
|
1481
|
+
|
|
1482
|
+
if not is_enabled():
|
|
1483
|
+
emit_managed_event(
|
|
1484
|
+
"managed_agents_fallback",
|
|
1485
|
+
{"op": "managed_completion_council", "reason": "is_enabled_false"},
|
|
1486
|
+
)
|
|
1487
|
+
sys.exit(3)
|
|
1488
|
+
|
|
1489
|
+
context = {
|
|
1490
|
+
"diff_summary": os.environ.get("_CC_DIFF", ""),
|
|
1491
|
+
"test_summary": os.environ.get("_CC_TEST", ""),
|
|
1492
|
+
"pending_tasks": os.environ.get("_CC_PENDING", "[]"),
|
|
1493
|
+
"iteration": int(os.environ.get("_CC_ROUND", "0") or 0),
|
|
1494
|
+
}
|
|
1495
|
+
|
|
1496
|
+
try:
|
|
1497
|
+
result = run_completion_council(
|
|
1498
|
+
voters=["requirements_verifier", "test_auditor", "devils_advocate"],
|
|
1499
|
+
context=context,
|
|
1500
|
+
timeout_s=180,
|
|
1501
|
+
)
|
|
1502
|
+
except ManagedUnavailable as e:
|
|
1503
|
+
emit_managed_event(
|
|
1504
|
+
"managed_agents_fallback",
|
|
1505
|
+
{"op": "managed_completion_council", "reason": "managed_unavailable", "detail": str(e)},
|
|
1506
|
+
)
|
|
1507
|
+
sys.exit(4)
|
|
1508
|
+
except Exception as e:
|
|
1509
|
+
emit_managed_event(
|
|
1510
|
+
"managed_agents_fallback",
|
|
1511
|
+
{"op": "managed_completion_council", "reason": "unexpected_error", "detail": str(e)},
|
|
1512
|
+
)
|
|
1513
|
+
sys.exit(5)
|
|
1514
|
+
|
|
1515
|
+
# Project AgentVerdicts -> legacy verdict files consumed by
|
|
1516
|
+
# council_aggregate_votes. The existing aggregator reads lines of the form:
|
|
1517
|
+
# VOTE: APPROVE|REJECT|CANNOT_VALIDATE
|
|
1518
|
+
# REASON: <free text>
|
|
1519
|
+
# ISSUES: <SEV>: <desc>
|
|
1520
|
+
# We map voting verdicts STOP -> APPROVE, CONTINUE -> REJECT, ABSTAIN ->
|
|
1521
|
+
# CANNOT_VALIDATE. Severity is copied through when the agent emitted one.
|
|
1522
|
+
def _vote_to_legacy(verdict_str: str) -> str:
|
|
1523
|
+
v = (verdict_str or "").upper()
|
|
1524
|
+
if v in ("STOP", "APPROVE"):
|
|
1525
|
+
return "APPROVE"
|
|
1526
|
+
if v in ("CONTINUE", "REJECT", "REQUEST_CHANGES"):
|
|
1527
|
+
return "REJECT"
|
|
1528
|
+
return "CANNOT_VALIDATE"
|
|
1529
|
+
|
|
1530
|
+
verdicts_dir = pathlib.Path(os.environ["_CC_VERDICTS_DIR"])
|
|
1531
|
+
verdicts_dir.mkdir(parents=True, exist_ok=True)
|
|
1532
|
+
|
|
1533
|
+
summary = {
|
|
1534
|
+
"round": int(os.environ.get("_CC_ROUND", "0") or 0),
|
|
1535
|
+
"session_id": result.session_id,
|
|
1536
|
+
"elapsed_ms": result.elapsed_ms,
|
|
1537
|
+
"partial": result.partial,
|
|
1538
|
+
"majority": result.majority,
|
|
1539
|
+
"voters": [],
|
|
1540
|
+
}
|
|
1541
|
+
|
|
1542
|
+
for vote in result.votes:
|
|
1543
|
+
role = vote.pool_name or "unknown_voter"
|
|
1544
|
+
legacy_vote = _vote_to_legacy(vote.verdict)
|
|
1545
|
+
reason = (vote.rationale or "").replace("\r", " ").strip()
|
|
1546
|
+
# Cap the reason so legacy parsers stay happy.
|
|
1547
|
+
if len(reason) > 2000:
|
|
1548
|
+
reason = reason[:2000] + "... [truncated]"
|
|
1549
|
+
lines = [
|
|
1550
|
+
f"VOTE: {legacy_vote}",
|
|
1551
|
+
f"REASON: {reason or 'managed council: no rationale'}",
|
|
1552
|
+
]
|
|
1553
|
+
if vote.severity:
|
|
1554
|
+
lines.append(f"ISSUES: {vote.severity.upper()}: managed voter flagged issue")
|
|
1555
|
+
out = "\n".join(lines) + "\n"
|
|
1556
|
+
fpath = verdicts_dir / f"{role}.txt"
|
|
1557
|
+
try:
|
|
1558
|
+
fpath.write_text(out, encoding="utf-8")
|
|
1559
|
+
except OSError as e:
|
|
1560
|
+
sys.stderr.write(f"managed council: failed to write {fpath}: {e}\n")
|
|
1561
|
+
sys.exit(6)
|
|
1562
|
+
summary["voters"].append({
|
|
1563
|
+
"role": role,
|
|
1564
|
+
"agent_id": vote.agent_id,
|
|
1565
|
+
"verdict": vote.verdict,
|
|
1566
|
+
"legacy": legacy_vote,
|
|
1567
|
+
"severity": vote.severity,
|
|
1568
|
+
})
|
|
1569
|
+
|
|
1570
|
+
# Drop a JSON sidecar so operators can inspect the managed run.
|
|
1571
|
+
try:
|
|
1572
|
+
sidecar = pathlib.Path(os.environ["_CC_LOKI_DIR"]) / "managed" / f"completion-council-round-{summary['round']}.json"
|
|
1573
|
+
sidecar.parent.mkdir(parents=True, exist_ok=True)
|
|
1574
|
+
sidecar.write_text(json.dumps(summary, indent=2), encoding="utf-8")
|
|
1575
|
+
except OSError:
|
|
1576
|
+
pass
|
|
1577
|
+
|
|
1578
|
+
emit_managed_event(
|
|
1579
|
+
"managed_completion_council_success",
|
|
1580
|
+
{
|
|
1581
|
+
"op": "managed_completion_council",
|
|
1582
|
+
"round": summary["round"],
|
|
1583
|
+
"voters": len(summary["voters"]),
|
|
1584
|
+
"majority": summary["majority"],
|
|
1585
|
+
"elapsed_ms": summary["elapsed_ms"],
|
|
1586
|
+
"partial": summary["partial"],
|
|
1587
|
+
},
|
|
1588
|
+
)
|
|
1589
|
+
sys.exit(0)
|
|
1590
|
+
PYEOF
|
|
1591
|
+
|
|
1592
|
+
if [ $exit_code -eq 0 ]; then
|
|
1593
|
+
log_info "[Council] Managed completion council produced verdicts for round $round"
|
|
1594
|
+
return 0
|
|
1595
|
+
fi
|
|
1596
|
+
|
|
1597
|
+
log_warn "[Council] Managed completion council unavailable (exit=$exit_code); falling back to Bash voting"
|
|
1598
|
+
return 1
|
|
1599
|
+
}
|
|
1600
|
+
|
|
1387
1601
|
#===============================================================================
|
|
1388
1602
|
# Main Entry Point - Should the loop stop?
|
|
1389
1603
|
#===============================================================================
|
|
@@ -1398,6 +1612,18 @@ council_should_stop() {
|
|
|
1398
1612
|
return 1
|
|
1399
1613
|
fi
|
|
1400
1614
|
|
|
1615
|
+
# v7.0.0 Phase 4: Managed council branch (opt-in, flag-gated).
|
|
1616
|
+
# When enabled, runs a single multiagent session via providers.managed
|
|
1617
|
+
# and projects verdicts onto the legacy verdict files. Aggregation,
|
|
1618
|
+
# severity-budget, unanimous+DA override, circuit breaker, hard checklist
|
|
1619
|
+
# gate -- all unchanged below. On ManagedUnavailable, silently falls
|
|
1620
|
+
# through to the existing Bash voting path.
|
|
1621
|
+
if [ "${LOKI_EXPERIMENTAL_MANAGED_COUNCIL:-false}" = "true" ]; then
|
|
1622
|
+
if council_managed_should_stop; then
|
|
1623
|
+
log_info "[Council] Managed voting materialized; proceeding to aggregation"
|
|
1624
|
+
fi
|
|
1625
|
+
fi
|
|
1626
|
+
|
|
1401
1627
|
# v6.83.0 Phase 1: silent no-op unless both managed flags are on.
|
|
1402
1628
|
# Writes related prior verdicts into $TARGET_DIR/.loki/managed/council-augment.txt
|
|
1403
1629
|
# which the council prompt assembly step can read and append to its prompt.
|