-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME.html
More file actions
464 lines (464 loc) · 20.5 KB
/
Copy pathREADME.html
File metadata and controls
464 lines (464 loc) · 20.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>README</title>
<style>
/* Default styles provided by pandoc.
** See https://pandoc.org/MANUAL.html#variables-for-html for config info.
*/
html {
color: #1a1a1a;
background-color: #fdfdfd;
}
body {
margin: 0 auto;
max-width: 36em;
padding-left: 50px;
padding-right: 50px;
padding-top: 50px;
padding-bottom: 50px;
hyphens: auto;
overflow-wrap: break-word;
text-rendering: optimizeLegibility;
font-kerning: normal;
}
@media (max-width: 600px) {
body {
font-size: 0.9em;
padding: 12px;
}
h1 {
font-size: 1.8em;
}
}
@media print {
html {
background-color: white;
}
body {
background-color: transparent;
color: black;
font-size: 12pt;
}
p, h2, h3 {
orphans: 3;
widows: 3;
}
h2, h3, h4 {
page-break-after: avoid;
}
}
p {
margin: 1em 0;
}
a {
color: #1a1a1a;
}
a:visited {
color: #1a1a1a;
}
img {
max-width: 100%;
}
svg {
height: auto;
max-width: 100%;
}
h1, h2, h3, h4, h5, h6 {
margin-top: 1.4em;
}
h5, h6 {
font-size: 1em;
font-style: italic;
}
h6 {
font-weight: normal;
}
ol, ul {
padding-left: 1.7em;
margin-top: 1em;
}
li > ol, li > ul {
margin-top: 0;
}
blockquote {
margin: 1em 0 1em 1.7em;
padding-left: 1em;
border-left: 2px solid #e6e6e6;
color: #606060;
}
code {
white-space: pre-wrap;
font-family: Menlo, Monaco, Consolas, 'Lucida Console', monospace;
font-size: 85%;
margin: 0;
hyphens: manual;
}
pre {
margin: 1em 0;
overflow: auto;
}
pre code {
padding: 0;
overflow: visible;
overflow-wrap: normal;
}
.sourceCode {
background-color: transparent;
overflow: visible;
}
hr {
border: none;
border-top: 1px solid #1a1a1a;
height: 1px;
margin: 1em 0;
}
table {
margin: 1em 0;
border-collapse: collapse;
width: 100%;
overflow-x: auto;
display: block;
font-variant-numeric: lining-nums tabular-nums;
}
table caption {
margin-bottom: 0.75em;
}
tbody {
margin-top: 0.5em;
border-top: 1px solid #1a1a1a;
border-bottom: 1px solid #1a1a1a;
}
th {
border-top: 1px solid #1a1a1a;
padding: 0.25em 0.5em 0.25em 0.5em;
}
td {
padding: 0.125em 0.5em 0.25em 0.5em;
}
header {
margin-bottom: 4em;
text-align: center;
}
#TOC li {
list-style: none;
}
#TOC ul {
padding-left: 1.3em;
}
#TOC > ul {
padding-left: 0;
}
#TOC a:not(:hover) {
text-decoration: none;
}
span.smallcaps{font-variant: small-caps;}
div.columns{display: flex; gap: min(4vw, 1.5em);}
div.column{flex: auto; overflow-x: auto;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
/* The extra [class] is a hack that increases specificity enough to
override a similar rule in reveal.js */
ul.task-list[class]{list-style: none;}
ul.task-list li input[type="checkbox"] {
font-size: inherit;
width: 0.8em;
margin: 0 0.8em 0.2em -1.6em;
vertical-align: middle;
}
.display.math{display: block; text-align: center; margin: 0.5rem auto;}
/* CSS for syntax highlighting */
html { -webkit-text-size-adjust: 100%; }
pre > code.sourceCode { white-space: pre; position: relative; }
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
pre > code.sourceCode > span:empty { height: 1.2em; }
.sourceCode { overflow: visible; }
code.sourceCode > span { color: inherit; text-decoration: inherit; }
div.sourceCode { margin: 1em 0; }
pre.sourceCode { margin: 0; }
@media screen {
div.sourceCode { overflow: auto; }
}
@media print {
pre > code.sourceCode { white-space: pre-wrap; }
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
}
pre.numberSource code
{ counter-reset: source-line 0; }
pre.numberSource code > span
{ position: relative; left: -4em; counter-increment: source-line; }
pre.numberSource code > span > a:first-child::before
{ content: counter(source-line);
position: relative; left: -1em; text-align: right; vertical-align: baseline;
border: none; display: inline-block;
-webkit-touch-callout: none; -webkit-user-select: none;
-khtml-user-select: none; -moz-user-select: none;
-ms-user-select: none; user-select: none;
padding: 0 4px; width: 4em;
color: #aaaaaa;
}
pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; }
div.sourceCode
{ }
@media screen {
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
code span.al { color: #ff0000; font-weight: bold; } /* Alert */
code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
code span.at { color: #7d9029; } /* Attribute */
code span.bn { color: #40a070; } /* BaseN */
code span.bu { color: #008000; } /* BuiltIn */
code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
code span.ch { color: #4070a0; } /* Char */
code span.cn { color: #880000; } /* Constant */
code span.co { color: #60a0b0; font-style: italic; } /* Comment */
code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
code span.do { color: #ba2121; font-style: italic; } /* Documentation */
code span.dt { color: #902000; } /* DataType */
code span.dv { color: #40a070; } /* DecVal */
code span.er { color: #ff0000; font-weight: bold; } /* Error */
code span.ex { } /* Extension */
code span.fl { color: #40a070; } /* Float */
code span.fu { color: #06287e; } /* Function */
code span.im { color: #008000; font-weight: bold; } /* Import */
code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
code span.kw { color: #007020; font-weight: bold; } /* Keyword */
code span.op { color: #666666; } /* Operator */
code span.ot { color: #007020; } /* Other */
code span.pp { color: #bc7a00; } /* Preprocessor */
code span.sc { color: #4070a0; } /* SpecialChar */
code span.ss { color: #bb6688; } /* SpecialString */
code span.st { color: #4070a0; } /* String */
code span.va { color: #19177c; } /* Variable */
code span.vs { color: #4070a0; } /* VerbatimString */
code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
</style>
</head>
<body>
<header id="title-block-header">
<h1 class="title">README</h1>
</header>
<h1 id="llmorchestrator">LLMOrchestrator</h1>
<p>Standalone Go module for managing headless CLI agents (OpenCode,
Claude Code, Gemini, Junie, Qwen Code) with a hybrid pipe+file
communication protocol and a fully decoupled (CONST-051(B))
<code>i18n.Translator</code> abstraction for user-facing strings.</p>
<p><strong>Go module:</strong>
<code>digital.vasic.llmorchestrator</code> <strong>Round:</strong> 275
(deep-doc + Challenge enrichment; mirror of round-220 template applied
across the owned-submodule fleet).</p>
<h2 id="overview">Overview</h2>
<p>LLMOrchestrator provides a unified interface for spawning, managing,
and communicating with multiple LLM-powered CLI agents. It is
<strong>shared infrastructure</strong> consumed by multiple independent
projects — its specialised responsibility makes it reusable, and that
reusability is destroyed the moment any consumer's specifics leak in
(CONST-051(B)). Every consumer wires its own <code>Translator</code> for
user-facing text; the built-in <code>NoopTranslator</code> returns the
message id verbatim so missing translations surface visibly rather than
silently as empty strings (the anti-bluff contract documented in
<code>pkg/i18n/translator.go</code>).</p>
<h2 id="anti-bluff-guarantees-const-035--article-xi-119">Anti-bluff
guarantees (CONST-035 / Article XI §11.9)</h2>
<p>This module's tests and Challenges exist to <strong>prove</strong>
the codebase works for end users — not merely to compile. The round-275
deliverables enforce:</p>
<ul>
<li><strong>Real disk I/O.</strong>
<code>challenges/runner/main.go</code> invariant 4 round-trips a
<code>protocol.FileMessage</code> through <code>os.MkdirTemp</code> →
<code>FileTransport.WriteToInbox</code> →
<code>FileTransport.ReadFromInbox</code> → equality check, on real
filesystem.</li>
<li><strong>Real JSON encoding.</strong> Invariant 3 marshals and
unmarshals a real <code>protocol.PipeMessage</code> per locale and
asserts byte-level field preservation (<code>Content</code>,
<code>Type</code>, <code>RequestID</code>). A silent struct-tag drift
would fail the gate.</li>
<li><strong>Real parser execution.</strong> Invariant 1 feeds the
5-locale <code>prompt_json</code> fixtures through the real
<code>parser.DefaultParser</code> and asserts the produced
<code>agent.Action</code> slice contains an entry matching the fixture's
<code>expect_action_type</code> + <code>expect_action_target</code>. A
stub-parser returning an empty slice would FAIL the gate.</li>
<li><strong>Real defensive contract.</strong> Invariant 2 asserts
<code>parser.Parse("")</code> returns <code>ErrEmptyInput</code>. Under
<code>LLMORCH_MUTATE_RUNNER=1</code> the polarity flips → the Challenge
runner exits non-zero → the wrapper turns that into exit 99
(paired-mutation success per CONST-050(A) / §1.1). A runner that exited
0 under mutation would prove it is a bluff gate.</li>
<li><strong>Real i18n surface.</strong> Invariant 5 asserts
<code>NoopTranslator.T</code> / <code>NoopTranslator.TPlural</code> /
<code>Pkg()</code> all return the message id verbatim across five
locales (English, Serbian, Japanese, Spanish, German). A
hardcoded-English regression would surface a per-locale FAIL line, not a
green-but-broken UI.</li>
<li><strong>No mocks in Challenges.</strong> Per CONST-050(A),
Challenges exercise the real, fully implemented system. Mocks live only
in <code>*_test.go</code> unit-test sources.</li>
</ul>
<h2 id="features">Features</h2>
<ul>
<li><strong>5 CLI adapters</strong>: OpenCode, Claude Code, Gemini,
Junie, Qwen Code</li>
<li><strong>Thread-safe agent pool</strong> with
<code>Acquire(ctx, requirements)</code> and capability matching (vision
/ streaming / tool-use / token budget)</li>
<li><strong>Circuit breaker</strong>: per-agent health monitoring (3
consecutive failures → unhealthy)</li>
<li><strong>Hybrid communication</strong>: pipe (real-time JSON-lines
via <code>protocol.PipeTransport</code>) + file (inbox / outbox / shared
directories via <code>protocol.FileTransport</code>)</li>
<li><strong>Response parser</strong>: structured extraction of actions,
issues, and JSON from raw LLM output
(<code>parser.DefaultParser</code>)</li>
<li><strong>Security</strong>: path-traversal protection
(<code>ErrPathTraversal</code>), 1 MiB response length cap
(<code>MaxResponseLength</code>), command-injection prevention</li>
<li><strong>CONST-046 i18n abstraction</strong>:
<code>i18n.Translator</code> interface + <code>NoopTranslator</code>
default + <code>SetPkgTranslator</code> injection point for consuming
projects</li>
</ul>
<h2 id="quick-start">Quick Start</h2>
<div class="sourceCode" id="cb1"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Build the orchestrator binary</span></span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="ex">go</span> build ./cmd/orchestrator</span>
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a><span class="co"># Race-detector unit + integration suite</span></span>
<span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a><span class="ex">go</span> test <span class="at">-race</span> <span class="at">-count</span><span class="op">=</span>1 ./...</span>
<span id="cb1-6"><a href="#cb1-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-7"><a href="#cb1-7" aria-hidden="true" tabindex="-1"></a><span class="co"># Round-275 Challenge runner (5 locales, 29 invariants, real disk I/O)</span></span>
<span id="cb1-8"><a href="#cb1-8" aria-hidden="true" tabindex="-1"></a><span class="ex">go</span> run ./challenges/runner/</span>
<span id="cb1-9"><a href="#cb1-9" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-10"><a href="#cb1-10" aria-hidden="true" tabindex="-1"></a><span class="co"># Wrapper-gated Challenge (anti-bluff paired mutation)</span></span>
<span id="cb1-11"><a href="#cb1-11" aria-hidden="true" tabindex="-1"></a><span class="fu">bash</span> challenges/llmorchestrator_describe_challenge.sh normal <span class="co"># exits 0 on green</span></span>
<span id="cb1-12"><a href="#cb1-12" aria-hidden="true" tabindex="-1"></a><span class="fu">bash</span> challenges/llmorchestrator_describe_challenge.sh mutate <span class="co"># exits 99 on mutation-detected</span></span></code></pre></div>
<p>If you run the Challenge runner directly with
<code>go run ./challenges/runner/</code>, set
<code>LLMORCH_FIXTURES_DIR</code> to point at the
<code>challenges/fixtures/</code> directory from your invocation
cwd.</p>
<hr />
<h2 id="architecture">Architecture</h2>
<pre><code>LLMOrchestrator/
├── cmd/orchestrator/ # Standalone CLI entry point
├── pkg/
│ ├── agent/ # Agent, AgentPool, SimplePool, HealthMonitor,
│ │ # CircuitBreaker, MultiPool, per-CLI agents
│ ├── adapter/ # BaseAdapter + 5 CLI adapters
│ ├── protocol/ # PipeTransport (JSON-lines), FileTransport
│ │ # (inbox/outbox/shared), PipeMessage,
│ │ # FileMessage, validatePath
│ ├── parser/ # ResponseParser, JSON/action/issue extraction
│ ├── config/ # .env loading, agent path resolution
│ └── i18n/ # Translator interface + NoopTranslator default
├── challenges/
│ ├── runner/ # round-275 in-process Challenge runner (Go)
│ ├── fixtures/ # 5 locale fixtures (en, sr, ja, es, de)
│ ├── llmorchestrator_describe_challenge.sh # round-275 wrapper +
│ │ # paired mutation
│ └── scripts/ # chaos / ddos / scaling / stress / ui / ux
│ # supplementary Challenges
├── docs/
│ ├── ARCHITECTURE.md # design narrative
│ ├── architecture.md # lowercase alias (CONST-052 transition)
│ ├── HOST_POWER_MANAGEMENT.md # CONST-033 hard-ban anchor
│ └── test-coverage.md # round-275 symbol→test ledger
├── upstreams/ # Multi-remote sync scripts (CONST-056 transition target)
├── README.md USER_GUIDE.md ARCHITECTURE.md API_REFERENCE.md
├── CONSTITUTION.md CLAUDE.md AGENTS.md # governance (cascaded)
└── go.mod # digital.vasic.llmorchestrator (go 1.25)</code></pre>
<p>The <code>pkg/</code> layout is <strong>flat and shallow on
purpose</strong>: five packages, every API surface is documented at the
symbol level in <code>docs/test-coverage.md</code>, and the Challenge
runner exercises representative invariants from each.</p>
<h3 id="component-relationships">Component relationships</h3>
<pre><code> config.LoadFromEnv ──▶ agent.NewPool ──▶ adapter.NewXXXAgent
│ │
│ ▼
│ BaseAdapter (process mgmt)
│ │
▼ ▼
parser.NewParser ◀── Agent.Send (stdout)
│ │
▼ ▼
ParsedResponse protocol.PipeMessage
▲ │
│ ▼
└───────── protocol.FileTransport (inbox/outbox/shared)</code></pre>
<hr />
<h2 id="configuration">Configuration</h2>
<p>Copy <code>.env.example</code> to <code>.env</code> (mode 0600,
gitignored per CONST-053 + CONST-042) and configure agent paths and API
keys. See <code>USER_GUIDE.md</code> for the per-adapter parameter
catalog.</p>
<h2 id="testing">Testing</h2>
<div class="sourceCode" id="cb4"><pre
class="sourceCode bash"><code class="sourceCode bash"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> test <span class="co"># unit + integration with race detector</span></span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> fuzz <span class="co"># parser fuzz suite</span></span>
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> cover <span class="co"># coverage report</span></span>
<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a><span class="fu">make</span> check <span class="co"># vet + tests</span></span>
<span id="cb4-5"><a href="#cb4-5" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb4-6"><a href="#cb4-6" aria-hidden="true" tabindex="-1"></a><span class="co"># Round-275 Challenge (anti-bluff gate)</span></span>
<span id="cb4-7"><a href="#cb4-7" aria-hidden="true" tabindex="-1"></a><span class="fu">bash</span> challenges/llmorchestrator_describe_challenge.sh normal</span>
<span id="cb4-8"><a href="#cb4-8" aria-hidden="true" tabindex="-1"></a><span class="fu">bash</span> challenges/llmorchestrator_describe_challenge.sh mutate</span>
<span id="cb4-9"><a href="#cb4-9" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb4-10"><a href="#cb4-10" aria-hidden="true" tabindex="-1"></a><span class="co"># Anti-bluff smoke check (must always pass)</span></span>
<span id="cb4-11"><a href="#cb4-11" aria-hidden="true" tabindex="-1"></a><span class="fu">grep</span> <span class="at">-rn</span> <span class="st">"simulated\|for now\|TODO implement\|placeholder"</span> <span class="dt">\</span></span>
<span id="cb4-12"><a href="#cb4-12" aria-hidden="true" tabindex="-1"></a> pkg cmd <span class="kw">&&</span> <span class="bu">echo</span> <span class="st">"BLUFF FOUND"</span> <span class="kw">||</span> <span class="bu">echo</span> <span class="st">"clean"</span></span></code></pre></div>
<p>Per CONST-050(B), this module ships unit, integration, security
(<code>parser_security_test.go</code>), fuzz
(<code>parser_fuzz_test.go</code>), chaos / DDoS / scaling / stress / UI
/ UX challenges, and the round-275 deep-doc Challenge. The symbol→test
ledger at <code>docs/test-coverage.md</code> enumerates every exported
symbol's coverage row.</p>
<h2 id="round-275-deliverable-summary">Round-275 deliverable
summary</h2>
<table>
<thead>
<tr>
<th>Artefact</th>
<th>Status</th>
<th>Evidence</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>README.md</code> deep-doc with anti-bluff guarantees</td>
<td>LANDED</td>
<td>this file</td>
</tr>
<tr>
<td><code>docs/test-coverage.md</code> symbol→test ledger</td>
<td>LANDED</td>
<td>symbol-to-test ledger with 6-invariant floor</td>
</tr>
<tr>
<td><code>challenges/runner/main.go</code> real-system exerciser</td>
<td>LANDED</td>
<td>29 PASS lines across 5 locales</td>
</tr>
<tr>
<td><code>challenges/llmorchestrator_describe_challenge.sh</code></td>
<td>LANDED</td>
<td>normal=exit 0; mutate=exit 99</td>
</tr>
<tr>
<td><code>challenges/fixtures/{en,sr,ja,es,de}.yaml</code></td>
<td>LANDED</td>
<td>5-locale bilingual fixture set</td>
</tr>
<tr>
<td><code>.gitignore</code> CONST-053 enrichment</td>
<td>LANDED</td>
<td>covers go-test, coverage, IDE, OS, secrets, build</td>
</tr>
</tbody>
</table>
<h2 id="license">License</h2>
<p>Apache License 2.0 — see <a href="LICENSE">LICENSE</a>.</p>
</body>
</html>