File size: 35,826 Bytes
d17c121
 
 
ec976e3
d17c121
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
992dce2
 
 
 
 
 
 
 
 
d17c121
 
95f946d
 
 
d17c121
58d350c
 
 
510b5fb
 
 
 
 
 
89bf094
 
 
 
 
510b5fb
 
 
4909932
 
d17c121
 
 
ef34f33
 
 
 
d17c121
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6b69c89
 
 
 
d17c121
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b28f835
 
d17c121
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58d350c
d17c121
f45a137
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
426688a
 
 
 
 
 
 
 
 
58d350c
 
 
f45a137
 
d17c121
 
 
 
 
 
 
 
 
 
 
 
 
b2500f2
 
 
 
 
 
 
d17c121
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
518343a
 
d17c121
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
518343a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95f946d
633838b
 
e1cc43a
 
 
 
 
 
 
 
 
31aae73
 
 
 
 
 
 
 
d370791
 
 
 
 
 
 
 
 
e7d2c95
 
 
 
 
 
 
 
 
 
 
0b2bdfb
 
 
 
 
 
 
6fc4ba5
 
 
 
 
 
 
 
 
31aae73
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58d350c
 
 
 
 
 
 
 
 
 
 
 
 
31aae73
 
 
 
2b286d2
 
 
 
 
 
 
 
 
 
 
b3eaab3
 
 
 
 
 
 
 
 
 
 
b28a375
 
 
 
 
 
 
 
 
 
 
 
 
8e82c7c
 
 
 
 
 
 
 
 
 
15a31bf
8e82c7c
fc2ed36
 
 
 
 
 
 
 
 
 
 
36ab189
 
 
 
 
 
 
 
 
 
 
528f7c0
 
 
 
 
 
 
 
 
 
 
 
ac45d55
 
 
 
 
 
 
 
 
 
9f95429
0b43b59
 
58d350c
0b43b59
6808046
 
 
 
 
8319d38
 
 
 
 
 
ac45d55
d17c121
 
 
518343a
 
 
 
31aae73
 
 
 
 
 
 
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
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
# syntax=docker/dockerfile:1
# SPDX-License-Identifier: Apache-2.0
# © 2026 Lutar, Stephen P. — SZL Holdings · ORCID 0009-0001-0110-4173 · Doctrine v11
#
# a11oy HF Docker Space — RESET build (Brand Orchestration Layer at /).
#
# RESET 2026-05-31 (Yachay CTO): a11oy is NOT a /console/ admin panel.
# Per Replit .replit-artifact/artifact.toml: BASE_PATH="/", serve="static" from dist/public,
# rewrite /* -> /index.html (SPA history fallback). The React SPA IS the Brand
# Orchestration Layer; its HomePage (Vessels-DNA / investor-facing landing) renders at /.
#
# Serves:
#   /            — SPA front door (Brand Orchestration Layer landing)
#   /assets/*    — SPA JS/CSS chunks (vite base="/")
#   /boardroom, /investor-demo, /sovereign, /fabric, /nexus, /command, ... — SPA routes (history fallback)
#   /api/a11oy/* — a11oy serve endpoints (health, gates, reason, policy/evaluate, proxy)
#
# HF Space requirement: listen on PORT 7860.

FROM python:3.12-slim

WORKDIR /app

# Install Node 22 (for a11oy serve TypeScript runner)
RUN apt-get update && apt-get install -y --no-install-recommends \
    curl ca-certificates gnupg git && \
    curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \
    apt-get install -y --no-install-recommends nodejs && \
    apt-get clean && rm -rf /var/lib/apt/lists/*

# Install Python dependencies
# ADDITIVE (Yachay): huggingface_hub + openai power the a11oy.code orchestrator's
# unified open-LLM router (HF Router inference). python-multipart is required by
# FastAPI UploadFile for the Whisper /voice/stt endpoint. None of these change the
# existing SPA / gates runtime; the orchestrator import is try/except-guarded in serve.py.
RUN pip install --no-cache-dir \
    "fastapi>=0.111.0,<1.0.0" \
    "uvicorn[standard]>=0.29.0,<1.0.0" \
    "httpx>=0.27.0,<1.0.0" \
    "starlette>=0.37.0" \
    "huggingface_hub>=0.25.0" \
    "openai>=1.40.0" \
    "python-multipart>=0.0.9" \
    "cryptography>=42.0.0" \
    "lmdb>=1.4.0"
# BE hardening: slowapi rate limiter (60/min/IP). pydantic+fastapi already present.
RUN pip install --no-cache-dir "slowapi>=0.1.9"

# sqlite-vss removed from build: no pre-built wheel for python:3.12-slim;
# szl_khipu_lmdb.py and szl_unay.py already have honest try/except fallback
# to cosine similarity if the sqlite-vss .so cannot load. (P0 CI fix, Dev1 Rumi)

# a11oy source for the serve runtime (receipt-substrate + policy gates only).
# FIX (2026-06-03, HF Verification Squad): the previous `git clone` of the PRIVATE
# github.com/szl-holdings/a11oy repo failed in the HF build sandbox (no GitHub creds)
# with exit code 128, leaving the Space stuck in BUILD_ERROR. The required source is
# already vendored in THIS Space repo under packages/, so we COPY it locally to the
# exact path serve.py expects (/app/a11oy-src/packages/...). No network, no auth.
# Doctrine v11 LOCKED 749/14/163. ADDITIVE-equivalent: same files, same runtime path.
COPY packages/receipt-substrate/src /app/a11oy-src/packages/receipt-substrate/src
COPY packages/policy/src/gates /app/a11oy-src/packages/policy/src/gates

# Copy the pre-built SPA (Brand Orchestration Layer) to the static root.
# index.html + assets/* are served directly at / and /assets/*; unknown GET -> index.html.
COPY console/ ./static/

# Build cache-bust 2026-06-08T23:30Z (Wave23 instillation): knowledge.json was
# NEVER explicitly COPYed into the image, so /knowledge.json (SPA Formulas tab +
# /api/a11oy/v1/research/corpus) served a STALE in-layer copy. Pin it freshly into
# BOTH the static root (catch-all serves /app/static/knowledge.json) and /app root
# (research-corpus endpoint reads /app/knowledge.json). Wave23 = conditional Khipu
# BFT safety (Conjecture 2 conditional); locked-5 + Lambda Conjecture 1 UNCHANGED.
COPY knowledge.json ./static/knowledge.json
COPY knowledge.json ./knowledge.json

# Copy serve orchestrator and gates manifest
COPY szl_parity_gaps.py ./szl_parity_gaps.py
# ADDITIVE (live-ops): orchestration + AI-observability module — per-file COPY Dockerfile
# omitted it, so import a11oy_warhacker_obs failed and /warhacker + /observability 404'd.
COPY a11oy_warhacker_obs.py ./a11oy_warhacker_obs.py
COPY serve.py ./serve.py
# DEV-WIRE-A (2026-06-09): additive pure-stdlib tab-upgrade metrics module imported
# by serve.py (try/except-guarded). NO numpy/scipy/networkx. Per-file COPY.
COPY a11oy_wireA_metrics.py ./a11oy_wireA_metrics.py
# ADDITIVE (cathedral front-door hero): sovereign 3D landing matching the org card.
# Served at / by serve.py (console one click in at /console). Placed AFTER
# `COPY console/ ./static/` (line 65) so vendor3d + hero js are not clobbered.
# ES-module Three.js r160 (MIT) vendored locally — NO CDN. Doctrine v11 LOCKED.
COPY cathedral.html ./cathedral.html
COPY static/a11oy_cathedral.js ./static/a11oy_cathedral.js
# Operator organ (Dev3) — ingested 3D infra-viz, vendored-three (0 CDN)
COPY static/a11oy_operator_organ.js ./static/a11oy_operator_organ.js
COPY a11oy_operator_organ.py ./a11oy_operator_organ.py
COPY a11oy_hf_assets.py ./a11oy_hf_assets.py
# (pages/operator_organ.html is copied below via `COPY pages/ ./pages/`)
COPY static/vendor3d/three.module.min.js ./static/vendor3d/three.module.min.js
COPY static/vendor3d/OrbitControls.js ./static/vendor3d/OrbitControls.js
COPY static/vendor3d/THREE_LICENSE.txt ./static/vendor3d/THREE_LICENSE.txt
# ADDITIVE: batch-2 sovereign security data module (imported by serve.py; try/except-guarded).
COPY szl_b2_secdata.py ./szl_b2_secdata.py
COPY gates_manifest.json ./gates_manifest.json
# ADDITIVE: a11oy.code conversational orchestrator module (imported by serve.py).
COPY a11oy_code_orchestrator.py ./a11oy_code_orchestrator.py
# ADDITIVE: a11oy Code IDE page (served by orchestrator GET /api/a11oy/code/ide as a
# sibling of a11oy_code_orchestrator.py). Self-contained (vendored CodeMirror, 0 runtime
# CDN). Explicit per-file COPY (this Dockerfile does not use `COPY . .`).
COPY a11oy_code_ide.html ./a11oy_code_ide.html
# ADDITIVE (WAYRA organ): explicit per-file COPY (this Dockerfile does not use COPY . .).
# serve.py mounts wayra_serve.router -> /wayra, /wayra-digest, /api/a11oy/v1/wayra/*.
COPY wayra_serve.py ./wayra_serve.py
COPY wayra_snapshot.json ./wayra_snapshot.json
COPY wayra_digests_7d.json ./wayra_digests_7d.json
# ADDITIVE (KHIPU-OS agentic DAG organ, 2026-06-01, Yachay): explicit per-file COPY
# (this Dockerfile does not use COPY . .). serve.py imports szl_khipu_os_routes and
# mounts GET/POST /api/a11oy/v1/khipu-os/{stats,verify,checkpoint,archive}. Self-driving
# Merkle DAG + Reed-Solomon erasure (reedsolo optional; honest, NOT holographic/quantum).
COPY szl_khipu_os_routes.py ./szl_khipu_os_routes.py
# ADDITIVE (PURIQ Agentic Formulas, 2026-06-01, Yachay): explicit per-file COPY
# (this Dockerfile does not use COPY . .). serve.py imports szl_puriq_formulas and
# calls .register(app) -> GET /formulas + /api/a11oy/v1/puriq/formulas*. Doctrine v11 LOCKED.
COPY szl_puriq_formulas.py ./szl_puriq_formulas.py

# ADDITIVE (Yachay / AYNI-OS, 2026-06-01): reciprocity organism + event-sourced replay
# + Tinkuy (Kuramoto) flow. Explicit per-file COPY (this Dockerfile does not use COPY . .).
# serve.py imports ayni_os_serve.router -> /v1/ayni, /v1/replay, /v1/tinkuy and serves the
# /ayni tab from /app/pages/ayni.html. HONEST: replay=event-sourcing (NOT time-travel);
# Ayni=game-theory primitive (Axelrod-Hamilton 1981, NOT mystical); Tinkuy=Kuramoto 1975.
# LOCKED preserved: 749/14/163, 13-axis yuyay_v3, replay bacf5443…631fc5. Pure additive.
COPY ayni_os_serve.py ./ayni_os_serve.py
COPY ayni_os/ ./ayni_os/
# ayni_os_serve event-sources its ledger from the real signed-receipt corpus; it
# must be in the image or the loader honestly falls back to synthetic. Per-file
# Dockerfile (no `COPY . .`), so copy the corpus explicitly.
COPY infra/receipts-samples/ ./infra/receipts-samples/
COPY pages/ ./pages/

# ADDITIVE (Live 3D Wires / PURIQ Doctrine v12, Yachay): explicit per-file COPY.
# This Dockerfile uses per-file COPY (no `COPY . .`), so the live-wires module +
# its static assets must be copied explicitly or `import szl_live_wires` 404s and
# /live-wires falls through to the SPA shell. serve.py registers these FIRST.
COPY szl_live_wires.py ./szl_live_wires.py
COPY live_wires.html ./live_wires.html
COPY live_wires_3d.js ./live_wires_3d.js

# ADDITIVE (Provenance Hardening / Wire D + DSSE Cosign REAL signing, 2026-06-01, Yachay):
# explicit per-file COPY (this Dockerfile does not use `COPY . .`). serve.py imports
# szl_provenance (which imports szl_dsse) and calls register_provenance(app, "a11oy") ->
# GET /api/a11oy/wires/D, POST /khipu/sign, POST /khipu/verify, GET /khipu/ledger,
# GET /api/a11oy/provenance. Without these COPYs the import fails and the routes fall
# through to the Node :8081 proxy (503). cryptography (added above) backs the real
# ECDSA-P256-SHA256 cosign signatures. Real signatures only when SZL_COSIGN_PRIVATE_PEM
# runtime secret is present (else honestly UNSIGNED). SLSA L1 honest (signing live); L2 roadmap via Wire D; L3 NOT claimed.
COPY szl_dsse.py ./szl_dsse.py
COPY szl_provenance.py ./szl_provenance.py

ENV PORT=7860
# BE hardening (Greene) — per-file COPY (this Dockerfile uses per-file COPY).
COPY szl_be_hardening.py ./szl_be_hardening.py

EXPOSE 7860

# ADDITIVE (UNAY + Khipu-LMDB v2, 2026-06-01, Yachay / Perplexity Computer Agent):
# explicit per-file COPY (this Dockerfile does not use `COPY . .`). serve.py imports
# szl_unay_routes and calls .register(app, ns="a11oy") -> /api/a11oy/v2/unay/* +
# /api/a11oy/v2/khipu/lmdb/*. Real durable lmdb + real sqlite-vss (honest cosine-
# fallback if the .so cannot load in the slim image). a11oy carries Khipu-LMDB PRIMARY.
COPY szl_unay.py ./szl_unay.py
COPY szl_khipu_lmdb.py ./szl_khipu_lmdb.py
COPY szl_khipu_replicate.py ./szl_khipu_replicate.py
COPY szl_unay_routes.py ./szl_unay_routes.py
# ADDITIVE (Warhacker aliases, Yachay 2026-06-01): top-level /healthz + /khipu/* + /wires/D.
# Per-file COPY (no `COPY . .`) — without this `import szl_warhacker_aliases` fails.
COPY szl_warhacker_aliases.py ./szl_warhacker_aliases.py
# ADDITIVE (Hickok dual-stream ingest, 2026-06-01, Yachay / Perplexity Computer Agent):
# explicit per-file COPY (this Dockerfile does not use `COPY . .`). serve.py imports
# a11oy_v4_hickok and calls .register(app, ns="a11oy") -> POST /api/a11oy/v4/{dorsal,
# ventral,spt,when,what} + GET /api/a11oy/v4/stream (SSE) + GET /brain, plus the
# dual-stream router middleware on /agent/ask + /predict. Without this COPY the import
# fails and the routes fall through to the Node :8081 proxy (503). Every receipt carries
# neuro_citations[]. Anchors A36/A37/A38 (ts-only, honest `sorry` proofs). The three Lean
# anchor files (DualStreamRouting/InternalFeedback/HierarchicalLinearization.lean) arrive
# via the sparse-checkout of packages/policy/src/gates above (no explicit COPY needed).
# Grounded in Hickok & Poeppel 2007 (DOI 10.1038/nrn2113). Doctrine v11 LOCKED 749/14/163.
COPY a11oy_v4_hickok.py ./a11oy_v4_hickok.py

# ADDITIVE (Anatomy 3D + live formula wiring, 2026-06-02, Yachay / Perplexity
# Computer Agent): explicit per-file COPY (this Dockerfile does not use `COPY . .`).
# serve.py imports a11oy_v4_formulas (38-formula manifest + 15 live evaluators) and
# szl_anatomy_3d (7 sovereign Three.js r128 anatomy surfaces + 6 live JSON endpoints).
# szl_anatomy_3d self-serves Three.js at /anatomy-three.min.js from static-vendor/.
# Receipts sign via szl_dsse (already COPYed) using szl_khipu + szl_formulas. Without
# these COPYs the imports fail and the pages/endpoints fall through to the SPA shell.
# Doctrine v11 LOCKED 749/14/163. Lambda = Conjecture 1 (NOT a theorem). NO external CDN.
COPY szl_khipu.py ./szl_khipu.py
COPY szl_formulas.py ./szl_formulas.py
COPY a11oy_v4_formulas.py ./a11oy_v4_formulas.py
COPY web/formulas.html ./web/formulas.html
COPY static-vendor/three.min.js ./static-vendor/three.min.js
COPY szl_anatomy_3d.py ./szl_anatomy_3d.py
COPY szl_anatomy_routes.py ./szl_anatomy_routes.py

# ADDITIVE (Graph/Viz lane + Perplexity Computer Agent, 2026-06-06): AIR-GAP
# VENDORING. The operator console (pages/console.html) loads the 7 viz libs +
# KaTeX from /vendor/* instead of cdn.jsdelivr.net so the Space renders every
# graph with ZERO network egress (Warhacker #2 "Tychee" air-gap deploy stacks).
# Per-file COPY (this Dockerfile does NOT use `COPY . .`). The .js/.css ship as
# text under static-vendor/; the binary globe texture + KaTeX woff2 fonts ship
# as base64 TEXT in _vendor_blobs.py (decoded by the /vendor/* routes in serve.py)
# so NO LFS/Xet blob is committed. Doctrine v11 LOCKED. NO external CDN.
COPY static-vendor/chart.umd.min.js ./static-vendor/chart.umd.min.js
COPY static-vendor/3d-force-graph.min.js ./static-vendor/3d-force-graph.min.js
COPY static-vendor/echarts.min.js ./static-vendor/echarts.min.js
COPY static-vendor/echarts-gl.min.js ./static-vendor/echarts-gl.min.js
COPY static-vendor/globe.gl.min.js ./static-vendor/globe.gl.min.js
COPY static-vendor/cytoscape.min.js ./static-vendor/cytoscape.min.js
COPY static-vendor/d3.min.js ./static-vendor/d3.min.js
COPY static-vendor/katex.min.js ./static-vendor/katex.min.js
COPY static-vendor/katex.min.css ./static-vendor/katex.min.css
# Batch-1 uniqueness rebuild (2026-06-06): additional vendored graph-viz libs
# (MIT/ISC/BSD; NOTICE updated). Per-file COPY (this Dockerfile uses no COPY . .).
COPY static-vendor/dagre.min.js ./static-vendor/dagre.min.js
COPY static-vendor/cytoscape-dagre.js ./static-vendor/cytoscape-dagre.js
COPY static-vendor/d3-sankey.min.js ./static-vendor/d3-sankey.min.js
COPY static-vendor/ngraph.graph.min.js ./static-vendor/ngraph.graph.min.js
COPY static-vendor/ngraph.path.min.js ./static-vendor/ngraph.path.min.js
COPY static-vendor/ngraph.forcelayout.min.js ./static-vendor/ngraph.forcelayout.min.js
COPY static-vendor/panzoom.min.js ./static-vendor/panzoom.min.js
# DEV-WIRE-A (2026-06-09): anvaka graph-stack completion (0-CDN, in-image). BSD-3, anvaka.
COPY static-vendor/vivagraph.min.js ./static-vendor/vivagraph.min.js
COPY static-vendor/ngraph.events.umd.js ./static-vendor/ngraph.events.umd.js
COPY _vendor_blobs.py ./_vendor_blobs.py

# ADDITIVE (V4 Fleet Panel + /api/health fix, 2026-06-02, Dev2 Inti):
# explicit per-file COPY (this Dockerfile does not use COPY . .).
# Signed-off-by: Yachay <yachay@szlholdings.ai>
# Co-Authored-By: Perplexity Computer Agent <agent@perplexity.ai>
# szl_v4_fleet.py: /api/health + /api/a11oy/v4/fleet[/doctrine] + /fleet + /thesis
# v4_fleet_panel.html: canonical fleet panel served at /fleet
# operator_shell_v4.py: Unified Operator Shell v4 endpoints (fix import failure)
# web/operator.html: operator shell desktop cockpit HTML
COPY szl_v4_fleet.py ./szl_v4_fleet.py
COPY web/v4_fleet_panel.html ./web/v4_fleet_panel.html
COPY operator_shell_v4.py ./operator_shell_v4.py
COPY web/operator.html ./web/operator.html

# ADDITIVE (Frontier wave, 2026-06-08): two founder tabs served from /app/web/
# via serve.py _ptg_serve. Sovereign pages, vendored 3D (globe.gl + three from
# static-vendor; earth-night texture from _vendor_blobs.py /vendor route), 0 CDN.
# Per-file COPY (this Dockerfile uses no COPY . .).
COPY web/fleet-c2.html ./web/fleet-c2.html
COPY web/living-anatomy.html ./web/living-anatomy.html

# ADDITIVE (Cross-Harness Receipt Bridge — Hermes + OpenClaw; 2026-06-01, Yachay /
# Perplexity Computer Agent; closeout PR superseding #198 runtime files). serve.py
# already imports szl_bridge + a11oy_v4_agent and calls .register(app) BEFORE the
# /api/a11oy/{path} Node proxy + SPA catch-all, but the bridge runtime modules were
# never COPY'd, so `import szl_bridge` failed at boot and POST /api/a11oy/v4/bridge/
# {hermes,openclaw} + GET /api/a11oy/v4/bridge/receipt/{id} + GET /bridge fell through
# to the SPA (404). Explicit per-file COPY (this Dockerfile never uses `COPY . .`).
# szl_bridge imports szl_bridge_schemas (JSON Schema 2020-12 tool registry) and reuses
# the already-COPY'd szl_dsse + szl_receipt_substrate signing/ledger modules. Doctrine
# v11 LOCKED 749/14/163 UNCHANGED.
COPY szl_bridge.py ./szl_bridge.py
COPY szl_bridge_schemas.py ./szl_bridge_schemas.py
COPY agent.html ./agent.html
# a11oy-bridge CLI (sign --from hermes/openclaw, verify --receipt-id). Standalone
# operator tool; not imported at boot but shipped so it is runnable in-container.
COPY a11oy_bridge_cli.py ./a11oy_bridge_cli.py


# ADDITIVE (SZL Ken Agent Pattern v1, CTO Yachay Convergence Cycle 1, 2026-06-03):
# Explicit per-file COPY of szl_ken.py (this Dockerfile never uses `COPY . .`).
# serve.py tries `import szl_ken` at startup; without this COPY the import fails
# silently and /v1/agent/loop + /v1/mcp/tools return 404 instead of 200.
# ADDITIVE ONLY — zero existing routes touched. Doctrine v11 LOCKED 749/14/163.
# Signed-off-by: Yachay <yachay@szlholdings.ai>
# Co-Authored-By: Perplexity Computer Agent <agent@perplexity.ai>
COPY szl_ken.py ./szl_ken.py


# ADDITIVE (Formulas → Ecosystem instillation, Opus 4.8, 2026-06-03):
# Per-file COPY of the a11oy.formulas package (this Dockerfile never uses `COPY . .`).
# serve.py imports a11oy_formula_endpoints, which imports a11oy.formulas.* — without
# these COPYs the import fails and /api/a11oy/v1/formula/* fall through to the SPA shell.
# Real implementations of PAC-Bayes, BLS12-381 aggregate, Welford, Byzantine quorum,
# Holevo, Bloom, Kalman, HNSW (amaru-delegate), Reidemeister. Each cites thesis_v22.pdf
# + a real Lean theorem/obligation. Λ = Conjecture 1 (NEVER a theorem). SLSA L1 honest.
# L2 build-provenance attestation = roadmap (Wire D) — not yet claimed. L3 not claimed.
# Signed-off-by: Yachay <yachay@szlholdings.ai>
# Co-Authored-By: Perplexity Computer Agent <agent@perplexity.ai>
COPY src/a11oy/__init__.py ./src/a11oy/__init__.py
COPY src/a11oy/formulas/__init__.py ./src/a11oy/formulas/__init__.py
COPY src/a11oy/formulas/pac_bayes.py ./src/a11oy/formulas/pac_bayes.py
COPY src/a11oy/formulas/bls_aggregate.py ./src/a11oy/formulas/bls_aggregate.py
COPY src/a11oy/formulas/welford.py ./src/a11oy/formulas/welford.py
COPY src/a11oy/formulas/byzantine_quorum.py ./src/a11oy/formulas/byzantine_quorum.py
COPY src/a11oy/formulas/holevo_bound.py ./src/a11oy/formulas/holevo_bound.py
COPY src/a11oy/formulas/bloom_filter.py ./src/a11oy/formulas/bloom_filter.py
COPY src/a11oy/formulas/kalman.py ./src/a11oy/formulas/kalman.py
COPY src/a11oy/formulas/hnsw_retrieval.py ./src/a11oy/formulas/hnsw_retrieval.py
COPY src/a11oy/formulas/reidemeister.py ./src/a11oy/formulas/reidemeister.py
COPY a11oy_formula_endpoints.py ./a11oy_formula_endpoints.py
# ADDITIVE (Formulas SECTION page — closeout): serve.py imports a11oy_formulas_page
# and calls .register(app) BEFORE the SPA catch-all, mounting GET /formulas/wired
# (premium Inca-palette list of every live formula + thesis citation + Lean permalink
# + "Try it") and GET /api/a11oy/v1/formulas/page-manifest. Per-file COPY (never
# `COPY . .`); without it the import fails and the route falls through to the SPA.
COPY a11oy_formulas_page.py ./a11oy_formulas_page.py

# ADDITIVE (Missing modules fix, 2026-06-04, Perplexity Computer Agent):
# The following .py files exist in the repo and are imported via try/except
# in serve.py, but were never COPY'd into the Docker image. Without them the
# imports fail silently and the associated routes/tabs are unavailable.
# Per-file COPY (this Dockerfile never uses `COPY . .`).
# Signed-off-by: Stephen P. Lutar Jr. <stephenlutar2@gmail.com>
COPY a11oy_frontier_patch.py ./a11oy_frontier_patch.py
COPY a11oy_v4_agent.py ./a11oy_v4_agent.py
COPY szl_brain.py ./szl_brain.py
COPY szl_wire.py ./szl_wire.py
COPY szl_hub.py ./szl_hub.py
COPY szl_rosie_companion.py ./szl_rosie_companion.py

# ADDITIVE (Parity Gaps + Receipt Substrate fix, 2026-06-05, Orchestrator Squad):
# szl_parity_gaps.py was MISSING from the Dockerfile despite being imported by
# serve.py at line ~1722 and being the source of the 5 parity endpoints
# (compliance/export, lineage, policy/validate, receipts/replay, lambda/score).
# Without this COPY those endpoints 404'd.
# szl_receipt_substrate.py was likewise missing — the Dockerfile comment at line ~182
# said "already-COPY'd" but no COPY line existed; szl_bridge.py and szl_parity_gaps.py
# both import it via try/except, causing silent degradation.
# szl_alloy_embed_fabric.py + szl_ayni_quorum.py: exist in repo, imported in serve.py,
# but were never COPY'd — adding them makes their endpoints live.
# Per-file COPY (this Dockerfile never uses `COPY . .`).
# NOTE: szl_parity_gaps.py is already COPY'd at line 68 (above serve.py).
# Signed-off-by: Stephen P. Lutar Jr. <stephenlutar2@gmail.com>
# Co-Authored-By: Perplexity Computer Agent <agent@perplexity.ai>
COPY szl_receipt_substrate.py ./szl_receipt_substrate.py
COPY szl_alloy_embed_fabric.py ./szl_alloy_embed_fabric.py
COPY szl_ayni_quorum.py ./szl_ayni_quorum.py

# Governed agent loop module (RAG->tool-call->policy/trust->signed-receipt + canonical /mcp/).
COPY szl_agentic_loop.py ./szl_agentic_loop.py

# Formula-wiring module (ADDITIVE 2026-06-06): registers the kernel-verified theorem
# mechanisms as live executable checks + the /api/<ns>/v1/formulas/* endpoints
# (selftest, proof-summary). BYTE-IDENTICAL across a11oy + killinchu (single source of
# truth). Per-file COPY (this Dockerfile never uses `COPY . .`) -- without this
# `import szl_formula_wiring` fails at boot and the formula endpoints 404. Imports
# stdlib only; no weights, no keys.
# Signed-off-by: Stephen P. Lutar Jr. <stephenlutar2@gmail.com>
COPY szl_formula_wiring.py ./szl_formula_wiring.py

# a11oy Code engine (governed chat/code/research; C20/W7-5 router; W5-3/W7-4 conformal;
# C10-C12 consensus; REAL restricted-subprocess sandbox). Per-file COPY (this Dockerfile
# never uses `COPY . .`) -- without this `import a11oy_code_engine` fails at boot and the
# /api/a11oy/v1/code/* routes fall through to the SPA. Imports only stdlib + the already-
# present szl_agentic_loop primitives; OPEN-WEIGHT roster only, NO closed weights, NO keys.
# Signed-off-by: Stephen P. Lutar Jr. <stephenlutar2@gmail.com>
COPY a11oy_code_engine.py ./a11oy_code_engine.py

# a11oy.code 7-tier organ->model router (TIERS + route() + tiers_payload()).
# Per-file COPY (this Dockerfile never uses `COPY . .`) -- without this
# `import a11oy_code` fails at boot and the /api/a11oy/v1/code/{tiers,health,
# index,roster,route,auto,complete} router surface (registered in serve.py before
# the catch-all) silently no-ops, so the /code UI's GET /tiers + POST /route|/auto
# calls 404 and the chat cannot answer. Imports only stdlib (math/time/hashlib).
# Signed-off-by: Stephen P. Lutar Jr. <stephenlutar2@gmail.com>
COPY a11oy_code.py ./a11oy_code.py

# a11oy Seismic forecaster (Doctrine v13): honest Reasenberg-Jones (1994) +
# Modified-Omori (Utsu 1961) aftershock-rate model over the LIVE public USGS
# feeds. Per-file COPY (this Dockerfile never uses `COPY . .`) -- without this,
# `import a11oy_seismic` fails at boot and the /api/a11oy/v1/seismic/{quakes,
# forecast,health} routes (registered in serve.py before the catch-all) silently
# no-op and fall through to the proxy (404). Stdlib only (math/urllib/json);
# clean-room MIT, public-domain science, NO third-party code, 0 runtime CDN.
# Statistical forecast -- NOT certainty, NOT a locked-proven claim.
# Signed-off-by: Stephen P. Lutar Jr. <stephenlutar2@gmail.com>
COPY a11oy_seismic.py ./a11oy_seismic.py

# Warhacker mission tabs backend (5 investor-facing surfaces; reuses
# szl_agentic_loop primitives + the in-image signer). Per-file COPY
# (this Dockerfile never uses `COPY . .`) — without this
# `import szl_warhacker_real` fails at boot.
# Signed-off-by: Stephen P. Lutar Jr. <stephenlutar2@gmail.com>
COPY szl_warhacker_real.py ./szl_warhacker_real.py

# Warhacker EXHAUSTIVE demos backend (5 full step-by-step demos: step timeline,
# catch tree, single-byte tamper test, formula-proof panel). Pure-Python, no
# external deps; reuses the in-image signer + loop verifier. Per-file COPY
# (this Dockerfile never uses `COPY . .`) — without this
# `import szl_warhacker_demos` fails at boot.
# Signed-off-by: Stephen P. Lutar Jr. <stephenlutar2@gmail.com>
COPY szl_warhacker_demos.py ./szl_warhacker_demos.py
COPY NOTICE_warhacker_demos.txt ./NOTICE_warhacker_demos.txt

# ---------------------------------------------------------------------------
# OPEN-WEIGHT ALLOY MODEL LAYER (model-integration squad, 2026-06-06, ADDITIVE)
# Forges the strongest OPEN-WEIGHT coding models into a11oy's brains, BOUND by
# proven formulas (C20/W7-5 router, W5-3/W7-4 conformal, C10-C12 consensus),
# UNIFIED into the existing LLM registry (one roster, not two).
#   * szl_alloy_models.py : roster + router + conformal + consensus + governed
#     suggest + local GGUF backend (honest tower-side label when no GGUF mounted).
#   * szl_llm_registry.py : the EXISTING registry module (was imported in serve.py
#     but NEVER COPY'd -> import failed silently / /llm/registry 404). This COPY
#     makes the unified roster genuinely LIVE.
#   * szl_elite_console.py: existing console module imported by serve.py.
# Per-file COPY (this Dockerfile never uses `COPY . .`). OPEN-WEIGHT only, NO
# closed weights, NO keys. Weights NOT redistributed (loaded by hf_repo at
# runtime / tower-side).
# Signed-off-by: Stephen P. Lutar Jr. <stephenlutar2@gmail.com>
# Co-Authored-By: Perplexity Computer Agent <agent@perplexity.ai>
COPY szl_llm_registry.py ./szl_llm_registry.py
COPY szl_elite_console.py ./szl_elite_console.py
COPY szl_alloy_models.py ./szl_alloy_models.py

# OPTIONAL live CPU demo tier: try to install llama.cpp + fetch ONE tiny
# Apache-2.0 GGUF (Qwen2.5-Coder-0.5B-Instruct Q4_K_M) so the demo tier can
# serve REAL output on cpu-basic. Both steps are NON-FATAL (`|| echo ...`): if
# the wheel build or download fails on this hardware, the alloy layer falls back
# to the HONEST tower-side label and NEVER fakes output. We never redistribute
# the weight in our repo — it is fetched from the original HF repo at build time.
# OPTIONAL live CPU demo tier wheel — PINNED PREBUILT (no source compile).
# Previously `pip install "llama-cpp-python>=0.2.79"` built the wheel FROM SOURCE,
# which fails to compile on CPU-only CI/hardware and was silently swallowed by the
# trailing `|| echo`, so the alloy demo tier always degraded to the tower-side label.
# python:3.12-slim is cp312 and the CI runner + box are linux_x86_64, and version
# 0.3.19 publishes a matching cp312 linux_x86_64 prebuilt wheel on llama-cpp-python's
# official CPU wheel index, so this resolves deterministically with NO from-source
# build. The `|| echo` stays ONLY as a final safety net for a platform without a
# matching prebuilt wheel (honest tower-side fallback, never fabricated output).
RUN pip install --no-cache-dir \
      --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cpu \
      "llama-cpp-python==0.3.19" \
    || echo "[a11oy] llama-cpp-python prebuilt wheel unavailable on this platform -> alloy demo tier falls back to honest tower-side label"
RUN mkdir -p /app/models && python -c "from huggingface_hub import hf_hub_download; hf_hub_download(repo_id='Qwen/Qwen2.5-Coder-0.5B-Instruct-GGUF', filename='qwen2.5-coder-0.5b-instruct-q4_k_m.gguf', local_dir='/app/models')" \
    || echo "[a11oy] GGUF fetch skipped/failed -> alloy demo tier falls back to honest tower-side label"
ENV A11OY_ALLOY_GGUF=/app/models/qwen2.5-coder-0.5b-instruct-q4_k_m.gguf

# ADDITIVE (Live-Data Layer, 2026-06-06, Warhacker): SHARED live-feed proxy module
# a11oy_live_feeds.py exposes GET /api/a11oy/v1/live/<feed> (server-side fetch+cache,
# CORS-safe same-origin, honest live/cached/self labels, NEVER fabricated). The
# bundled live_snapshots/ are the in-image fallback served labelled 'cached' when an
# upstream feed is unreachable. Per-file COPY (this Dockerfile never uses `COPY . .`)
# -- without these the import fails and the /v1/live/* routes fall through to the SPA.
# Signed-off-by: Stephen P. Lutar Jr. <stephenlutar2@gmail.com>
# Co-Authored-By: Perplexity Computer Agent <agent@perplexity.ai>
COPY a11oy_live_feeds.py ./a11oy_live_feeds.py
COPY live_snapshots/ ./live_snapshots/

# ADDITIVE (Investor-WOW Layer, 2026-06-08, Dev1): a11oy_dev1_endpoints.py exposes
# the four founder-approved WOW surfaces: POST /v1/wow/govern (Drop-on-Anything
# governed turn + ungoverned-vs-governed catch), GET /v1/wow/ledger (unified
# cross-vertical tamper-evident receipt chain), /v1/wow/roi (cost-of-failure model,
# labeled assumptions), /v1/wow/router-latency (live router topology). Self-contained,
# DSSE-signed receipts, honest labels, 0 fabricated data, 0 CDN. Per-file COPY (this
# Dockerfile never uses `COPY . .`) -- without it the import fails and the /v1/wow/*
# routes fall through to the SPA. serve.py imports it try/except-guarded.
# Co-Authored-By: Perplexity Computer Agent <agent@perplexity.ai>
COPY a11oy_dev1_endpoints.py ./a11oy_dev1_endpoints.py

# ADDITIVE (Vertical Packs Layer, 2026-06-08, Dev2): a11oy_vertical_feeds.py exposes
# the 5 vertical packs (Defense/Gov, Finance, Legal, Enterprise/Cyber, Real Estate)
# under /api/a11oy/v1/vert/* -- real live server-side feeds (CISA KEV, NVD, Federal
# Register, CourtListener, Yahoo, Coinbase, Frankfurter FX, GitHub events, NYC HPD/DOB,
# Treasury), each running the governed loop (szl_governance_gateway) + emitting
# DSSE-signed receipts (szl_dsse + szl_khipu, all already COPY'd above). Honest
# labels, 0 fabricated data, 0 CDN. Per-file COPY (this Dockerfile never uses
# `COPY . .`) -- without it the import fails and the /v1/vert/* routes fall through
# to the SPA. serve.py imports it try/except-guarded; register() self-reorders its
# routes to the front of the router so they beat the proxy + SPA catch-all.
# Co-Authored-By: Perplexity Computer Agent <agent@perplexity.ai>
COPY a11oy_vertical_feeds.py ./a11oy_vertical_feeds.py

# ADDITIVE (Deep Feeds Layer, 2026-06-08, Dev-A): a11oy_deva_feeds.py exposes the 10
# deep tabs (RealEstate 5: Market Pulse, Distress Radar, Ownership Graph, Deal Intel,
# Broker Edge; Finance 5: Quant Desk, Crypto Live, Markets Macro, Prediction Markets,
# Risk & Fraud Obs.) under /api/a11oy/v1/deva/* -- granular live server-side feeds
# (Yahoo v8, Coinbase, CoinGecko, Frankfurter FX, Treasury, NYC HPD wvxf-dwi5 + DOB,
# Polymarket gamma, SEC EDGAR, NVD), reusing a11oy_vertical_feeds governed_turn/_ledger
# + szl_khipu/szl_dsse for signed receipts. Honest labels, 0 fabricated data, 0 CDN.
# Per-file COPY (this Dockerfile never uses `COPY . .`); register() front-moves its
# routes so they beat the proxy + SPA catch-all.
COPY a11oy_deva_feeds.py ./a11oy_deva_feeds.py
COPY a11oy_devb_endpoints.py ./a11oy_devb_endpoints.py

# ADDITIVE (Provenance & Trust Anchor, 2026-06-08): a11oy_amaru_feeds.py exposes the
# 5 trust tabs (Public-Ledger Anchor LIVE, Post-Quantum Signing PQC, Receipt
# Provenance Graph 3D, Tamper/Audit Verifier, Anchor Health) under
# /api/a11oy/v1/provenance/* -- live CT signed tree heads (Google Argon/Xenon,
# Cloudflare Nimbus) + Bitcoin tip (mempool.space/blockstream), reusing
# a11oy_vertical_feeds governed_turn + szl_khipu/szl_dsse for signed receipts.
# Honest PQC labels (classical ECDSA-P256 live; ML-DSA/ML-KEM/SLH-DSA roadmap),
# 0 fabricated data, 0 CDN. Per-file COPY; register() front-moves its routes so
# they beat the proxy + SPA catch-all.
COPY a11oy_amaru_feeds.py ./a11oy_amaru_feeds.py

# ADDITIVE (MINED UPGRADES, 2026-06, Yachay): four self-contained operator surfaces,
# each adopting a PERMISSIVELY-licensed PATTERN (NOTICE updated) and evolving it into
# an a11oy-native mechanism. Stdlib-only (no torch/numpy/CDN). Per-file COPY (this
# Dockerfile never uses `COPY . .`) -- without these the imports fail and the
# /governance-gateway, /abacus-verify, /decision-uncertainty, /gor-audit routes
# fall through to the SPA shell. serve.py imports them try/except-guarded.
COPY szl_governance_gateway.py ./szl_governance_gateway.py
COPY szl_abacus_verify.py ./szl_abacus_verify.py
COPY szl_decision_uncertainty.py ./szl_decision_uncertainty.py
COPY szl_gor_audit.py ./szl_gor_audit.py

# ADDITIVE (RE-SWEEP WAVE 2, 2026-06, Yachay): four MORE operator surfaces from the
# P0 re-sweep backlog, each adopting a PERMISSIVE pattern (MIT/Apache; NOTICE updated)
# and evolving it into an a11oy-native mechanism. Stdlib-only (no torch/numpy/CDN);
# graph tabs render with the already-vendored cytoscape. Per-file COPY (this Dockerfile
# never uses `COPY . .`) -- without these the imports fail and /sovereign-search,
# /consensus-clusters, /mission-ledger, /budget-router fall through to the SPA shell.
# serve.py imports them try/except-guarded.
COPY szl_sovereign_search.py ./szl_sovereign_search.py
COPY szl_consensus_clusters.py ./szl_consensus_clusters.py
COPY szl_mission_ledger.py ./szl_mission_ledger.py
COPY szl_budget_router.py ./szl_budget_router.py

# ADDITIVE (WAVE9/10 INSTILLATION, 2026-06): the "Proven Formulas (experimental)"
# surface wiring a11oy-targeted lutar-lean Wave9+Wave10 theorems as honest cards with
# verbatim #print axioms + real in-image checks (Gershgorin matrix-health, Ville
# anytime-alarm, replay-determinism+tamper-localize, quorum-intersection, DSSE
# injectivity). Stdlib-only (no torch/numpy/CDN). Per-file COPY (this Dockerfile never
# uses `COPY . .`) -- without this the import fails and /proven-formulas +
# /api/a11oy/v1/proven/* fall through to the SPA shell, and the governance-gateway
# matrix-health pre-flight reports the module missing. serve.py + szl_governance_gateway
# import it try/except-guarded. LOCKED-proven stays EXACTLY 5; Lambda=Conjecture 1.
COPY szl_wave910_proofs.py ./szl_wave910_proofs.py
COPY szl_evidence_research.py ./szl_evidence_research.py
# Operational Readiness backend (deployed-vs-repo reality, live/cached/unreachable).
# serve.py imports this try/except-guarded; without this per-file COPY the import
# fails and /api/a11oy/v1/readiness 404s (falls through to the SPA shell).
COPY szl_readiness.py ./szl_readiness.py
# Contracting Readiness backend (SAM/CAGE + SBIR/STTR eligibility, web-sourced,
# honest verified/confirmed/needs_founder_input/needs_founder_action labels, source
# liveness probes, 0 fabricated org values). serve.py imports this try/except-guarded;
# without this per-file COPY the import fails and /api/a11oy/v1/contracting 404s.
COPY szl_contracting.py ./szl_contracting.py
# ADDITIVE (Open-Problem Bounty Board, bounties-tab-patch): stdlib-only bounty module
# + the canonical bounty YAMLs (single source of truth, copied byte-identical from
# szl-holdings/lutar-lean). Per-file/dir COPY (this Dockerfile never uses `COPY . .`)
# -- without these the import fails and /api/a11oy/v1/bounties 404s.
COPY szl_bounties.py ./szl_bounties.py
COPY bounties/ ./bounties/

CMD ["python", "serve.py"]


# Build cache-bust 2026-06-05T00:00Z (Orchestrator Squad):
# szl_parity_gaps.py already COPY'd at line 68 (commit 543ca95).
# Added COPY szl_receipt_substrate.py + szl_alloy_embed_fabric.py + szl_ayni_quorum.py.
# All 5 parity endpoints now deployable. All 63 COPY sources verified present in repo.

# Build cache-bust 2026-06-06T09:00Z (model-integration squad, Opus 4.8):
# Added OPEN-WEIGHT ALLOY MODEL LAYER: COPY szl_alloy_models.py + szl_llm_registry.py
# (was 404/never-copied) + szl_elite_console.py; optional non-fatal llama-cpp-python +
# tiny Apache-2.0 GGUF fetch for the live CPU demo tier (honest tower-side fallback).
# UNIFIED into the existing LLM registry (one roster). DeepSeek-Coder-V2 = CODE_PRIMARY.
# C20/W7-5 router, W5-3/W7-4 conformal, C10-C12 consensus; every call -> signed receipt.