chatpbc1 commited on
Commit
cceef8f
·
verified ·
1 Parent(s): 526ccf5

security: admin console is served token-gated from the server, not from the public repo

Browse files
Files changed (1) hide show
  1. admin.html +0 -296
admin.html DELETED
@@ -1,296 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="utf-8"/>
5
- <meta name="viewport" content="width=device-width, initial-scale=1"/>
6
- <title>Pally Admin — Model Console</title>
7
- <style>
8
- :root{--bg:#0b0d10;--panel:#12161c;--panel2:#171c24;--border:#232a35;--text:#dbe2ea;--dim:#8b98a8;--accent:#4da3ff;--ok:#3ddc84;--warn:#ffb020;--err:#ff5d5d;--mono:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}
9
- *{box-sizing:border-box;margin:0;padding:0}
10
- body{background:var(--bg);color:var(--text);font:14px/1.5 -apple-system,Segoe UI,Roboto,sans-serif}
11
- header{display:flex;align-items:center;gap:16px;padding:14px 22px;border-bottom:1px solid var(--border);background:var(--panel);position:sticky;top:0;z-index:5}
12
- header h1{font-size:16px;font-weight:650}
13
- header .model{color:var(--dim);font-family:var(--mono);font-size:12px}
14
- header .right{margin-left:auto;display:flex;gap:10px;align-items:center}
15
- .dot{width:8px;height:8px;border-radius:50%;background:var(--err);display:inline-block}
16
- .dot.up{background:var(--ok)}
17
- nav{display:flex;gap:4px;padding:10px 22px;border-bottom:1px solid var(--border);background:var(--bg)}
18
- nav button{background:none;border:1px solid transparent;color:var(--dim);padding:6px 14px;border-radius:8px;cursor:pointer;font-size:13px}
19
- nav button.active{background:var(--panel2);color:var(--text);border-color:var(--border)}
20
- main{padding:22px;max-width:1280px;margin:0 auto}
21
- .cards{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:12px;margin-bottom:20px}
22
- .card{background:var(--panel);border:1px solid var(--border);border-radius:12px;padding:14px 16px}
23
- .card .k{color:var(--dim);font-size:12px}
24
- .card .v{font-size:22px;font-weight:700;margin-top:2px;font-family:var(--mono)}
25
- .card .s{color:var(--dim);font-size:11px;margin-top:2px}
26
- .panel{background:var(--panel);border:1px solid var(--border);border-radius:12px;padding:16px;margin-bottom:18px}
27
- .panel h2{font-size:14px;margin-bottom:10px;color:var(--text)}
28
- table{width:100%;border-collapse:collapse;font-size:12.5px}
29
- th{color:var(--dim);text-align:left;font-weight:500;padding:6px 8px;border-bottom:1px solid var(--border)}
30
- td{padding:7px 8px;border-bottom:1px solid #1a2029;font-family:var(--mono);font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:340px}
31
- tr:hover td{background:#141a22}
32
- .badge{display:inline-block;padding:1px 8px;border-radius:20px;font-size:11px;border:1px solid var(--border)}
33
- .badge.s2{color:var(--accent);border-color:#274a70}.badge.s1{color:var(--dim)}
34
- .badge.ok{color:var(--ok);border-color:#1d4a33}.badge.err{color:var(--err);border-color:#5a2323}
35
- .badge.imp{color:var(--warn);border-color:#5a4518}
36
- canvas{width:100%;height:120px;background:var(--panel2);border-radius:8px;border:1px solid var(--border)}
37
- .grid2{display:grid;grid-template-columns:1fr 1fr;gap:18px}
38
- @media(max-width:900px){.grid2{grid-template-columns:1fr}}
39
- .editlog{font-family:var(--mono);font-size:11.5px;color:var(--dim);max-height:260px;overflow:auto}
40
- .editlog div{padding:4px 0;border-bottom:1px solid #1a2029}
41
- input.tokenin{background:var(--panel2);border:1px solid var(--border);color:var(--text);padding:6px 10px;border-radius:8px;font-family:var(--mono);font-size:12px;width:220px}
42
- button.act{background:var(--accent);border:0;color:#041018;font-weight:600;padding:6px 14px;border-radius:8px;cursor:pointer}
43
- .muted{color:var(--dim)}
44
- .hidden{display:none}
45
- </style>
46
- </head>
47
- <body>
48
- <header>
49
- <h1>Pally Admin</h1>
50
- <span class="model" id="modelinfo">loading…</span>
51
- <div class="right">
52
- <span class="dot" id="livedot"></span><span class="muted" id="live">—</span>
53
- <input class="tokenin" id="token" type="password" placeholder="admin token"/>
54
- <button class="act" onclick="saveToken()">Connect</button>
55
- </div>
56
- </header>
57
- <nav>
58
- <button class="active" data-t="overview" onclick="tab('overview',this)">Overview</button>
59
- <button data-t="requests" onclick="tab('requests',this)">Requests</button>
60
- <button data-t="users" onclick="tab('users',this)">Users</button>
61
- <button data-t="performance" onclick="tab('performance',this)">Performance</button>
62
- <button data-t="selfedit" onclick="tab('selfedit',this)">Self-Edit History</button>
63
- <button data-t="research" onclick="tab('research',this)">Research</button>
64
- </nav>
65
- <main>
66
- <div class="cards" id="cards"></div>
67
-
68
- <div id="t-overview">
69
- <div class="panel">
70
- <h2>Requests / minute (last refresh window)</h2>
71
- <canvas id="spark" width="1200" height="120"></canvas>
72
- </div>
73
- <div class="grid2">
74
- <div class="panel"><h2>Live requests</h2>
75
- <table><thead><tr><th>time</th><th>user</th><th>sys</th><th>ms</th><th>calc</th><th>status</th><th>preview</th></tr></thead>
76
- <tbody id="tb-recent"></tbody></table>
77
- </div>
78
- <div class="panel"><h2>Model &amp; endpoint</h2>
79
- <div id="endpointinfo" class="muted" style="font-family:var(--mono);font-size:12px"></div>
80
- </div>
81
- </div>
82
- </div>
83
-
84
- <div id="t-requests" class="hidden">
85
- <div class="panel">
86
- <h2>Request log (last 100)</h2>
87
- <table><thead><tr><th>time</th><th>user</th><th>route</th><th>system</th><th>iters</th><th>ms</th><th>calc ok</th><th>calc fail</th><th>edits</th><th>status</th><th>preview</th></tr></thead>
88
- <tbody id="tb-requests"></tbody></table>
89
- </div>
90
- </div>
91
-
92
- <div id="t-users" class="hidden">
93
- <div class="panel">
94
- <h2>Users (anonymized)</h2>
95
- <table><thead><tr><th>id</th><th>requests</th><th>calc ok</th><th>avg ms</th><th>first seen</th><th>last seen</th><th>last message</th></tr></thead>
96
- <tbody id="tb-users"></tbody></table>
97
- </div>
98
- </div>
99
-
100
- <div id="t-performance" class="hidden">
101
- <div class="cards" id="perfcards"></div>
102
- <div class="panel"><h2>Latency distribution</h2>
103
- <canvas id="hist" width="1200" height="160"></canvas>
104
- </div>
105
- </div>
106
-
107
- <div id="t-selfedit" class="hidden">
108
- <div class="panel">
109
- <h2>CORTX-1 self-edit history (model rewrote its own rules)</h2>
110
- <div class="editlog" id="editlog"></div>
111
- </div>
112
- </div>
113
-
114
- <div id="t-research" class="hidden">
115
- <div class="grid2">
116
- <div class="panel"><h2>Honest benchmark</h2>
117
- <table><thead><tr><th>system</th><th>score /100</th><th>[calc:] fired</th></tr></thead>
118
- <tbody><tr><td>Pally v6 + CORTX-1</td><td>43</td><td>0 / 10</td></tr>
119
- <tr><td><b>Pally v7 + CORTX-1 (current)</b></td><td><b>49</b></td><td><b>2 / 10</b></td></tr>
120
- <tr><td>GPT-OSS 20B (no scaffold)</td><td>82</td><td>n/a</td></tr></tbody></table>
121
- <p class="muted" style="margin-top:10px;font-size:12px">10 consulting cases, same rubric, LLM judge. Canary battery: 12/17. Historical: Claude 90, DeepSeek-R1 67 (not re-run). A 1.7B model does not beat a 20B model on raw judgment — Pally's value is verifiable math + privacy, not raw IQ.</p>
122
- </div>
123
- <div class="panel"><h2>Documentation</h2>
124
- <p style="font-size:13px;line-height:1.9">
125
- 📄 <a href="https://huggingface.co/chatpbc1/Pally/blob/main/RESEARCH_CORTX1.md" style="color:#4da3ff" target="_blank">CORTX-1 architecture research paper</a><br>
126
- 📝 <a href="https://huggingface.co/chatpbc1/Pally/blob/main/README.md" style="color:#4da3ff" target="_blank">Model card &amp; honest strengths/weaknesses</a><br>
127
- 📊 <a href="https://huggingface.co/chatpbc1/Pally/blob/main/bench_scores_v7.json" style="color:#4da3ff" target="_blank">Raw benchmark scores</a><br>
128
- 🔌 <a href="https://huggingface.co/chatpbc1/pally-endpoint" style="color:#4da3ff" target="_blank">API docs &amp; endpoint</a><br>
129
- 💬 <a href="https://huggingface.co/spaces/chatpbc1/pally-console" style="color:#4da3ff" target="_blank">Chat console (user UI)</a>
130
- </p>
131
- </div>
132
- </div>
133
- <div class="panel"><h2>Research summary (CORTX-1)</h2>
134
- <div class="muted" style="font-size:12.5px;line-height:1.7" id="researchabstract">
135
- <b>Abstract.</b> CORTX-1 is a serving scaffold that wraps a 1.7B model with (1) a dual-stream System-1/System-2 deliberation router, (2) an executable <code>[calc:]</code> tool that AST-evaluates arithmetic and substitutes true results, (3) a generate→verify→revise loop, and (4) a <b>self-editing configuration</b> letting the model rewrite its own versioned, auditable operating rules at inference time. Evaluation: 12/17 canary battery, 49/100 consulting benchmark vs GPT-OSS 82/100. <b>Honest conclusion:</b> verifiability and auditability improve measurably (v6→v7: +6 points, calculator 0→2 firings); raw reasoning capability does not match a 20B model. Full paper: <a href="https://huggingface.co/chatpbc1/Pally/blob/main/RESEARCH_CORTX1.md" style="color:#4da3ff" target="_blank">RESEARCH_CORTX1.md</a>
136
- </div>
137
- </div>
138
- </div>
139
- </main>
140
-
141
- <script>
142
- let BASE = null, STATS = null, prevReqCount = 0, sparkData = [];
143
- const DISCOVER = 'https://huggingface.co/chatpbc1/pally-endpoint/raw/main/endpoint.json';
144
- let DISCOVERED = null;
145
-
146
- async function discover(){
147
- if(DISCOVERED) return DISCOVERED;
148
- try{
149
- const r = await fetch(DISCOVER, {cache:'no-store'});
150
- const j = await r.json();
151
- if(j && j.url) DISCOVERED = String(j.url).replace(/\/+$/,'');
152
- }catch(e){}
153
- return DISCOVERED;
154
- }
155
-
156
- function saveToken(){
157
- const t = document.getElementById('token').value.trim();
158
- if(t) localStorage.setItem('pally_admin_token', t);
159
- load();
160
- }
161
- function tab(name, btn){
162
- document.querySelectorAll('nav button').forEach(b=>b.classList.remove('active'));
163
- if(btn) btn.classList.add('active');
164
- ['overview','requests','users','performance','selfedit','research'].forEach(x=>{
165
- document.getElementById('t-'+x).classList.toggle('hidden', x!==name);
166
- });
167
- }
168
- function fmtMs(v){ return v==null?'—':(v>=1000?(v/1000).toFixed(1)+'s':Math.round(v)+'ms'); }
169
- function esc(s){ return String(s==null?'':s).replace(/[<>&]/g, c=>({'<':'&lt;','>':'&gt;','&':'&amp;'}[c])); }
170
-
171
- function card(k,v,s){
172
- return '<div class="card"><div class="k">'+k+'</div><div class="v">'+v+'</div>'+(s?'<div class="s">'+s+'</div>':'')+'</div>';
173
- }
174
-
175
- function drawSpark(){
176
- const c = document.getElementById('spark'), ctx = c.getContext('2d');
177
- ctx.clearRect(0,0,c.width,c.height);
178
- if(!sparkData.length) return;
179
- const max = Math.max(...sparkData, 1), w = c.width/sparkData.length;
180
- ctx.fillStyle = '#4da3ff';
181
- sparkData.forEach((v,i)=>{
182
- const h = Math.max(2, (v/max)*(c.height-16));
183
- ctx.globalAlpha = 0.85;
184
- ctx.fillRect(i*w+2, c.height-h-8, Math.max(3,w-4), h);
185
- });
186
- ctx.globalAlpha=1;
187
- ctx.fillStyle='#8b98a8'; ctx.font='12px monospace';
188
- ctx.fillText('req/window max='+max, 10, 14);
189
- }
190
-
191
- function drawHist(perf){
192
- const c = document.getElementById('hist'), ctx = c.getContext('2d');
193
- ctx.clearRect(0,0,c.width,c.height);
194
- const p50=perf.p50_ms||0, p95=perf.p95_ms||0, mx=perf.max_ms||0, avg=perf.avg_ms||0;
195
- const scale = Math.max(mx, 100);
196
- const bars = [{l:'p50',v:p50,c:'#3ddc84'},{l:'avg',v:avg,c:'#4da3ff'},{l:'p95',v:p95,c:'#ffb020'},{l:'max',v:mx,c:'#ff5d5d'}];
197
- bars.forEach((b,i)=>{
198
- const y = 18+i*34, w = Math.min(c.width-160, (b.v/scale)*(c.width-200));
199
- ctx.fillStyle = b.c; ctx.fillRect(120, y, Math.max(4,w), 22);
200
- ctx.fillStyle = '#dbe2ea'; ctx.font='13px monospace';
201
- ctx.fillText(b.l, 30, y+16);
202
- ctx.fillText(Math.round(b.v)+' ms', 130+Math.max(4,w)+10, y+16);
203
- });
204
- }
205
-
206
- function render(s){
207
- STATS = s;
208
- document.getElementById('modelinfo').textContent = s.model + ' · round ' + s.round + ' · cfg v' + s.config_version;
209
- const c = s.counters, p = s.perf;
210
- const up = Math.floor(s.uptime_sec/60);
211
- document.getElementById('cards').innerHTML =
212
- card('Requests', c.requests, 'since boot') +
213
- card('Errors', c.errors, (100*c.errors/Math.max(1,c.requests)).toFixed(1)+'% rate') +
214
- card('Calc executions', c.calc_ok, s.calc_fire_rate+' per request avg') +
215
- card('Calc failures', c.calc_fail) +
216
- card('p50 latency', fmtMs(p.p50_ms), p.samples+' samples') +
217
- card('p95 latency', fmtMs(p.p95_ms)) +
218
- card('Users', s.users.length, 'tracked') +
219
- card('Uptime', up+'m', Math.floor(s.uptime_sec/3600)+'h '+(up%60)+'m');
220
- document.getElementById('perfcards').innerHTML =
221
- card('p50', fmtMs(p.p50_ms)) + card('p95', fmtMs(p.p95_ms)) +
222
- card('avg', fmtMs(p.avg_ms)) + card('max', fmtMs(p.max_ms)) +
223
- card('samples', p.samples) +
224
- card('S1 / S2 / Improve', c.s1+' / '+c.s2+' / '+c.improve) +
225
- card('Self-edits', c.self_edits, 'model rewrote its rules') +
226
- card('Calc fire rate', s.calc_fire_rate, 'calcs per request');
227
-
228
- document.getElementById('tb-recent').innerHTML = s.requests.slice(0,15).map(r=>
229
- '<tr><td>'+esc(r.ts.slice(11,19))+'</td><td>'+esc(r.user)+'</td>'+
230
- '<td><span class="badge '+(r.system||'').slice(0,3)+'">'+esc(r.system)+'</span></td>'+
231
- '<td>'+esc(r.ms)+'</td><td>'+r.calc_ok+'/'+r.calc_fail+'</td>'+
232
- '<td><span class="badge '+(r.status==='ok'?'ok':'err')+'">'+esc(r.status)+'</span></td>'+
233
- '<td title="'+esc(r.preview)+'">'+esc(r.preview)+'</td></tr>').join('');
234
-
235
- document.getElementById('tb-requests').innerHTML = s.requests.map(r=>
236
- '<tr><td>'+esc(r.ts.slice(11,19))+'</td><td>'+esc(r.user)+'</td><td>'+esc(r.route)+'</td>'+
237
- '<td><span class="badge '+(r.system||'').slice(0,3)+'">'+esc(r.system)+'</span></td>'+
238
- '<td>'+esc(r.iters)+'</td><td>'+esc(r.ms)+'</td><td>'+r.calc_ok+'</td><td>'+r.calc_fail+'</td>'+
239
- '<td>'+(r.edits?('<span class="badge imp">'+r.edits+'</span>'):'0')+'</td>'+
240
- '<td><span class="badge '+(r.status==='ok'?'ok':'err')+'">'+esc(r.status)+'</span></td>'+
241
- '<td title="'+esc(r.preview)+'">'+esc(r.preview)+'</td></tr>').join('');
242
-
243
- document.getElementById('tb-users').innerHTML = s.users.map(u=>
244
- '<tr><td>'+esc(u.id)+'</td><td>'+u.requests+'</td><td>'+u.calc_ok+'</td><td>'+fmtMs(u.avg_ms)+'</td>'+
245
- '<td>'+esc((u.first_seen||'').slice(0,19))+'</td><td>'+esc((u.last_seen||'').slice(0,19))+'</td>'+
246
- '<td title="'+esc(u.last_preview)+'">'+esc(u.last_preview)+'</td></tr>').join('');
247
-
248
- document.getElementById('editlog').innerHTML = (s.config_edit_log||[]).slice().reverse().map(e=>
249
- '<div><b>v'+esc(e.ts||'')+'</b> → ['+esc(e.section)+'] ('+e.chars+' chars)<br/>'+esc(e.preview||'')+'…</div>').join('')
250
- || '<div class="muted">no self-edits recorded yet</div>';
251
-
252
- fetch(BASE.replace(/\/$/,'')+'/endpoint.json').then(r=>r.json()).then(e=>{
253
- document.getElementById('endpointinfo').innerHTML =
254
- 'url: '+esc(e.url)+'<br/>model: '+esc(e.model)+'<br/>round: '+esc(e.round)+
255
- '<br/>started: '+esc(e.started_utc)+'<br/>tools: '+esc((e.tools||[]).join(', '));
256
- }).catch(()=>{document.getElementById('endpointinfo').textContent='endpoint.json unavailable';});
257
-
258
- drawHist(p);
259
- }
260
-
261
- async function load(){
262
- const t = localStorage.getItem('pally_admin_token') || document.getElementById('token').value.trim();
263
- if(!t){ document.getElementById('live').textContent='enter admin token'; return; }
264
- const discovered = await discover();
265
- const cands = ['', discovered,
266
- (window.PALLY_ENDPOINT||'').replace(/\/$/,''),
267
- 'https://coffee-info-mate-pointer.trycloudflare.com'
268
- ].filter((v,i,a)=>v!=null && a.indexOf(v)===i);
269
- for(const base of cands){
270
- try{
271
- const r = await fetch(base+'/admin/stats?token='+encodeURIComponent(t));
272
- if(r.status===403){ document.getElementById('live').textContent='bad token'; return; }
273
- if(!r.ok) continue;
274
- const s = await r.json();
275
- BASE = base;
276
- document.getElementById('livedot').classList.add('up');
277
- document.getElementById('live').textContent = 'live · '+base.replace('https://','');
278
- if(s.counters.requests !== prevReqCount){
279
- sparkData.push(s.counters.requests - prevReqCount);
280
- if(sparkData.length>40) sparkData.shift();
281
- prevReqCount = s.counters.requests;
282
- drawSpark();
283
- }
284
- render(s);
285
- return;
286
- }catch(e){ /* try next base */ }
287
- }
288
- document.getElementById('livedot').classList.remove('up');
289
- document.getElementById('live').textContent='endpoint unreachable';
290
- }
291
- const saved = localStorage.getItem('pally_admin_token');
292
- if(saved) document.getElementById('token').value = saved;
293
- load(); setInterval(load, 5000);
294
- </script>
295
- </body>
296
- </html>