Commit dedada3
committed
Multi-tenant hardening + e2e robustness fixes
End-to-end test verified: project goes from create → conda env clone →
Deep Research (Gemini) → title → citations → Dev Phase 4-step loop →
real claude code experimenter → LaTeX compile → 2-page PDF, all using
the project owner's own keys with no global fallback.
## Multi-tenant: remove ALL global config fallbacks
ARK is a product now: every user must supply their own keys. No more
silently using the lab admin's key when a user hasn't configured one.
* `deep_research.py`: strip `get_gemini_api_key()` to env-var only;
delete `_global_config()` and `save_gemini_api_key()`.
* `telegram.py`: drop `_load_global()`, `save()`,
`_global_config_path()`. `TelegramConfig` only reads per-project
config + `ARK_TELEGRAM_*` env vars.
* `orchestrator.py:_get_bot_model`, `agents.py:_get_ark_model`,
`cli.py:_get_configured_model`: never read `~/.ark/config.yaml`;
use per-project config or hardcoded default. Drop the now-unused
`get_config_dir` import in orchestrator.py and agents.py.
* `cli.py:_run_deep_research_for_project`: prompt user to export
`GEMINI_API_KEY` instead of saving to global config.
* `cli.py:cmd_setup_bot`: global telegram setup is gone — point users
at `ark setup-bot <project>` or `ARK_TELEGRAM_*` env vars.
* `webapp/jobs.py` + `slurm_template.sh` + `webapp/utils/verify.py`:
drop the `ARK_NO_GLOBAL_CONFIG=1` workaround flag — no longer
needed because the fallback is fully removed.
## Robustness fixes hit during real e2e
* `webapp/jobs.py:poll_local_job`: zombie reap. Use
`os.waitpid(pid, WNOHANG)` instead of `os.kill(pid, 0)` so finished
wrapper subprocesses get reaped instead of staying as zombies that
the poller mistakes for "still running".
* `agents.py:run_agent`: empty-run detection no longer uses length or
elapsed time as a quality signal. Length/duration are not correlated
with correctness — a good title is 60 chars, a good yes/no is 3
chars. Only flag empty when `returncode != 0` or output is literally
empty. Initialise `stdout`/`stderr` BEFORE the try block so the
TimeoutExpired path doesn't `NameError` on `stderr`. Re-capture
stdout/stderr inside the timeout handler with a short timeout.
* `pipeline.py:_parse_title_from_agent_output`: new helper that
strips `Title:` / `Generated title:` label lines so a model that
prefixes its answer with a label doesn't end up with the label
saved as the actual paper title.
* `pipeline.py:_plan_experiments`: page-aware experiment budget. A
1-page workshop poster doesn't need 8 experiments; tell the planner
to plan exactly N experiments based on `venue_pages` so the
experimenter agent can actually finish in its time budget.
* `pipeline.py:_run_experiments` + `execution.py`: bump experimenter
agent timeout from 1800s to 3600s — parameter sweeps need it, and
the orchestrator already handles per-experiment results streaming.
## webapp dashboard log SSE no longer double-renders
`webapp/routes.py:api_stream_log`: track which file is being tailed
and how many lines have been sent FROM THAT FILE. On the very first
iteration, skip past the existing content (the client just fetched
it via `/log?lines=300`); on a real log-file rotation
(env_provision.log → local_*.out), reset and send the new file from
the start. Previously the SSE always restarted from line 0 every
time the connection opened, replaying everything the initial
`loadLog()` had already rendered.1 parent 8719bfd commit dedada3
File tree
11 files changed
+203
-265
lines changed- ark
- webapp
- utils
11 files changed
+203
-265
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
68 | 67 | | |
69 | 68 | | |
70 | 69 | | |
| |||
190 | 189 | | |
191 | 190 | | |
192 | 191 | | |
193 | | - | |
194 | | - | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
203 | 199 | | |
204 | 200 | | |
205 | 201 | | |
| |||
522 | 518 | | |
523 | 519 | | |
524 | 520 | | |
| 521 | + | |
| 522 | + | |
525 | 523 | | |
526 | 524 | | |
527 | 525 | | |
| |||
582 | 580 | | |
583 | 581 | | |
584 | 582 | | |
585 | | - | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
586 | 591 | | |
587 | 592 | | |
588 | 593 | | |
| |||
599 | 604 | | |
600 | 605 | | |
601 | 606 | | |
602 | | - | |
603 | | - | |
604 | | - | |
605 | | - | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
606 | 621 | | |
607 | 622 | | |
608 | 623 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
55 | 53 | | |
56 | 54 | | |
57 | 55 | | |
| |||
1503 | 1501 | | |
1504 | 1502 | | |
1505 | 1503 | | |
1506 | | - | |
1507 | | - | |
1508 | | - | |
| 1504 | + | |
| 1505 | + | |
1509 | 1506 | | |
1510 | 1507 | | |
1511 | 1508 | | |
| |||
1705 | 1702 | | |
1706 | 1703 | | |
1707 | 1704 | | |
1708 | | - | |
1709 | | - | |
1710 | | - | |
1711 | | - | |
1712 | | - | |
1713 | | - | |
| 1705 | + | |
| 1706 | + | |
1714 | 1707 | | |
1715 | 1708 | | |
1716 | 1709 | | |
1717 | 1710 | | |
1718 | 1711 | | |
1719 | 1712 | | |
1720 | | - | |
1721 | | - | |
1722 | | - | |
1723 | | - | |
1724 | | - | |
1725 | | - | |
1726 | | - | |
1727 | | - | |
1728 | | - | |
1729 | | - | |
| 1713 | + | |
| 1714 | + | |
| 1715 | + | |
| 1716 | + | |
1730 | 1717 | | |
1731 | 1718 | | |
1732 | 1719 | | |
| |||
2816 | 2803 | | |
2817 | 2804 | | |
2818 | 2805 | | |
2819 | | - | |
2820 | | - | |
2821 | | - | |
2822 | | - | |
2823 | | - | |
2824 | | - | |
2825 | | - | |
2826 | | - | |
2827 | | - | |
2828 | | - | |
2829 | | - | |
2830 | | - | |
2831 | | - | |
2832 | | - | |
2833 | | - | |
2834 | | - | |
2835 | | - | |
2836 | | - | |
2837 | | - | |
2838 | | - | |
2839 | | - | |
2840 | | - | |
2841 | | - | |
2842 | | - | |
2843 | | - | |
2844 | | - | |
| 2806 | + | |
| 2807 | + | |
2845 | 2808 | | |
2846 | | - | |
2847 | | - | |
2848 | | - | |
2849 | | - | |
2850 | | - | |
2851 | | - | |
2852 | | - | |
2853 | | - | |
2854 | | - | |
2855 | | - | |
2856 | | - | |
2857 | | - | |
2858 | | - | |
2859 | | - | |
2860 | | - | |
2861 | | - | |
2862 | | - | |
2863 | | - | |
2864 | | - | |
2865 | | - | |
2866 | | - | |
2867 | | - | |
2868 | | - | |
2869 | | - | |
2870 | | - | |
2871 | | - | |
2872 | | - | |
2873 | | - | |
2874 | | - | |
2875 | | - | |
2876 | | - | |
2877 | | - | |
2878 | | - | |
2879 | | - | |
2880 | | - | |
2881 | | - | |
2882 | | - | |
2883 | | - | |
2884 | | - | |
2885 | | - | |
2886 | | - | |
2887 | | - | |
2888 | | - | |
2889 | | - | |
2890 | | - | |
2891 | | - | |
2892 | | - | |
2893 | | - | |
2894 | | - | |
2895 | | - | |
| 2809 | + | |
2896 | 2810 | | |
2897 | | - | |
| 2811 | + | |
| 2812 | + | |
| 2813 | + | |
| 2814 | + | |
| 2815 | + | |
2898 | 2816 | | |
2899 | 2817 | | |
2900 | 2818 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | 12 | | |
14 | 13 | | |
15 | 14 | | |
16 | 15 | | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | 16 | | |
25 | 17 | | |
26 | | - | |
| 18 | + | |
27 | 19 | | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
33 | 25 | | |
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 | | - | |
| 26 | + | |
78 | 27 | | |
79 | 28 | | |
80 | 29 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
552 | 552 | | |
553 | 553 | | |
554 | 554 | | |
555 | | - | |
| 555 | + | |
556 | 556 | | |
557 | 557 | | |
558 | 558 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
36 | 35 | | |
37 | 36 | | |
38 | 37 | | |
| |||
362 | 361 | | |
363 | 362 | | |
364 | 363 | | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | | - | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
375 | 371 | | |
376 | 372 | | |
377 | 373 | | |
| |||
0 commit comments