kryptheon 0.1.74 → 0.1.75

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/bin/kryptheon.js CHANGED
@@ -3221,26 +3221,43 @@ async function everythingFromDashboard(steps, opened, say, control, info) {
3221
3221
  });
3222
3222
  const step = { onStop: (fn) => (stopStep = fn) };
3223
3223
  const done = [];
3224
+ const dash = require(path.join(PACKAGE_DIR, 'kryptheon-dashboard.js'));
3225
+ const progress = typeof control.progress === 'function' ? control.progress : () => {};
3226
+ const estimate = (s) => (Number.isFinite(s.estimateMs) ? s.estimateMs : 60000);
3227
+ let quickSaid = false;
3224
3228
  for (let i = 0; i < steps.length; i++) {
3225
3229
  const s = steps[i];
3226
3230
  if (stopped) {
3227
3231
  done.push({ id: s.id, label: s.label, ok: false, said: 'not run: stopped' });
3228
3232
  continue;
3229
3233
  }
3234
+ // The first deep step: what ran so far is on Findings already, and the page and the guide say so.
3235
+ const quickDone = Boolean(s.deep) && i > 0;
3236
+ const leftMs = steps.slice(i).reduce((n, x) => n + estimate(x), 0);
3237
+ if (quickDone && !quickSaid) {
3238
+ quickSaid = true;
3239
+ say('');
3240
+ say('The first findings are ready - open Findings and start on the serious ones. The deeper checks keep running: about ' + dash.howLong(leftMs) + ' more.');
3241
+ }
3242
+ progress({ step: i + 1, of: steps.length, id: s.id, label: s.label, deep: Boolean(s.deep), quickDone: quickSaid, leftMs: leftMs, stepStartedAt: new Date().toISOString() });
3230
3243
  say('');
3231
3244
  say('Step ' + (i + 1) + ' of ' + steps.length + ': ' + s.label + ' - ' + s.title);
3232
3245
  stopStep = null;
3246
+ const t0 = Date.now();
3233
3247
  let r;
3234
3248
  try {
3235
3249
  if (s.id === 'api') r = await apiFromDashboard(s.origin, say, step, s.readOnly === true);
3236
- else if (PROBE_CHECKS[s.id]) r = await probeFromDashboard(s.id, say, step, info.confirmed);
3250
+ else if (PROBE_CHECKS[s.id]) r = await probeFromDashboard(s.id, say, step, info.confirmed, s.deep ? dash.DEEP_STEP_LIMIT_MS : 0);
3237
3251
  else r = await runFromDashboard(s.id, opened, say);
3238
3252
  } catch (err) {
3239
3253
  r = { ok: false, why: err && err.message ? err.message : String(err) };
3240
3254
  }
3255
+ const took = Date.now() - t0;
3241
3256
  const ok = Boolean(r && r.ok);
3242
- done.push({ id: s.id, label: s.label, ok: ok, said: ok ? r.summary : 'did not finish: ' + ((r && r.why) || 'it gave no answer') });
3243
- say((ok ? 'Done: ' : 'Did not finish: ') + (ok ? r.summary : (r && r.why) || 'it gave no answer'));
3257
+ // measured only when the step ran its whole course: a stopped or cut step would make the next estimate short
3258
+ if (ok && !stopped && !(r && r.timeUp)) dash.rememberStepTime(USER_DIR, process.env, s.id, took);
3259
+ done.push({ id: s.id, label: s.label, ok: ok, tookMs: took, said: (ok ? r.summary : 'did not finish: ' + ((r && r.why) || 'it gave no answer')) + ' (' + dash.howLong(took) + ')' });
3260
+ say((ok ? 'Done in ' + dash.howLong(took) + ': ' : 'Did not finish (' + dash.howLong(took) + '): ') + (ok ? r.summary : (r && r.why) || 'it gave no answer'));
3244
3261
  }
3245
3262
  say('');
3246
3263
  say('What ran:');
@@ -3311,7 +3328,7 @@ function runFromDashboard(id, opened, say) {
3311
3328
  * the tick, for an address that is not this computer) - so it runs here, in
3312
3329
  * this process, where its Stop can reach the browser run.
3313
3330
  */
3314
- async function probeFromDashboard(id, say, control, confirmed) {
3331
+ async function probeFromDashboard(id, say, control, confirmed, limitMs) {
3315
3332
  if (!PROBE_CHECKS[id]) return { ok: false, why: '"' + id + '" cannot be run from the dashboard' };
3316
3333
  const runner = probeModule(id);
3317
3334
  const { flows } = probeFlows();
@@ -3324,19 +3341,36 @@ async function probeFromDashboard(id, say, control, confirmed) {
3324
3341
  }
3325
3342
  if (!flows.length) return { ok: false, why: 'there is no recording that can be replayed - record one of your flows' };
3326
3343
  if (!ensureBrowser()) return { ok: false, why: 'the browser could not be downloaded' };
3344
+ // Inside Check my app a deep step has a time limit: then it stops like Stop does - what it found is kept, and
3345
+ // what it did not reach is said as not tried.
3346
+ let timeUp = false;
3347
+ let timer = null;
3327
3348
  const report = await runner.run(USER_DIR, flows, {
3328
3349
  say: say,
3329
- onControl: (c) => control.onStop(() => c.stop()),
3350
+ onControl: (c) => {
3351
+ control.onStop(() => c.stop());
3352
+ if (limitMs > 0 && !timer) {
3353
+ timer = setTimeout(() => {
3354
+ timeUp = true;
3355
+ say('Time limit of ' + Math.round(limitMs / 60000) + ' minutes reached: stopping here and keeping what was found.');
3356
+ c.stop();
3357
+ }, limitMs);
3358
+ if (timer.unref) timer.unref();
3359
+ }
3360
+ },
3330
3361
  confirmed: confirmed || [],
3331
3362
  });
3363
+ if (timer) clearTimeout(timer);
3332
3364
  runner.save(USER_DIR, report);
3333
3365
  for (const line of runner.summaryLines(report)) say(line);
3334
3366
  const problems = report.findings.filter((f) => f.status === 'confirmed').length;
3335
3367
  const tested = report.flows.some((f) => f.state === 'tested');
3336
- if (!tested) return { ok: false, why: 'nothing was tested - see what it printed' };
3368
+ if (!tested) return { ok: false, why: 'nothing was tested - see what it printed', timeUp: timeUp };
3337
3369
  return {
3338
3370
  ok: true,
3339
- summary: (report.stopped ? 'stopped after ' + report.runsDone + ' of ' + report.runsPlanned + ' runs - ' : '') +
3371
+ timeUp: timeUp,
3372
+ summary: (timeUp ? 'time limit reached after ' + report.runsDone + ' of ' + report.runsPlanned + ' runs, the rest not tried - '
3373
+ : report.stopped ? 'stopped after ' + report.runsDone + ' of ' + report.runsPlanned + ' runs - ' : '') +
3340
3374
  (problems ? problems + (problems === 1 ? ' problem found' : ' problems found') + ' - see Findings' : 'no problem found in what was tried') +
3341
3375
  (report.testData.length ? '. ' + report.testData.length + ' test writes were left in your app' : ''),
3342
3376
  };
@@ -124,7 +124,7 @@
124
124
  }
125
125
  // The guide (kryptheon-tour.js) follows the page: what the server last said, and whether something runs.
126
126
  function tell() {
127
- try { window.dispatchEvent(new CustomEvent('kryptheon:state', { detail: { state: state, busy: busy } })); } catch (e) { /* no guide then */ }
127
+ try { window.dispatchEvent(new CustomEvent('kryptheon:state', { detail: { state: state, busy: busy, quickDone: !!(busy && job && job.progress && job.progress.quickDone) } })); } catch (e) { /* no guide then */ }
128
128
  }
129
129
  // The clipboard, and when a browser refuses it, the older way: the text
130
130
  // put in a box off the screen, selected and copied.
@@ -267,6 +267,24 @@
267
267
  head.appendChild(close);
268
268
  }
269
269
  box.appendChild(head);
270
+ // Check my app: where it is, how long is left (measured on this computer once it has run), and - once the quick
271
+ // part is done - that its findings can be read while the deeper checks keep going.
272
+ var p = job.running && job.progress;
273
+ if (p) {
274
+ var left = Math.max(0, (p.leftMs || 0) - (Date.now() - new Date(p.stepStartedAt).getTime()));
275
+ box.appendChild(el('div', 'job-progress', 'Step ' + p.step + ' of ' + p.of + ': ' + p.label + ' · about ' + minutesWords(left) + ' left'));
276
+ if (p.quickDone) {
277
+ var ready = el('div', 'job-ready');
278
+ ready.appendChild(el('span', null, 'The first findings are ready. Read them and start on the serious ones - the deeper checks keep running.'));
279
+ if (currentView() !== 'findings') {
280
+ var see = el('button', 'go', 'See findings →');
281
+ see.type = 'button';
282
+ see.addEventListener('click', function () { go('findings'); });
283
+ ready.appendChild(see);
284
+ }
285
+ box.appendChild(ready);
286
+ }
287
+ }
270
288
  var open = linesOpen === null ? job.running || !ok : linesOpen;
271
289
  var lines = null;
272
290
  if (open) {
@@ -303,13 +321,23 @@
303
321
  root.style.setProperty('--job-room', (box.offsetHeight + 12) + 'px');
304
322
  }
305
323
 
324
+ /** "under a minute", "1 minute", "12 minutes". */
325
+ function minutesWords(ms) {
326
+ var m = Math.round(ms / 60000);
327
+ return m < 1 ? 'under a minute' : m === 1 ? '1 minute' : m + ' minutes';
328
+ }
329
+
306
330
  function getJob() {
307
331
  return fetch('/api/job', { cache: 'no-store' }).then(function (res) { return res.json(); }).then(function (d) { return d.job; });
308
332
  }
309
333
 
310
334
  /** Starts a job and follows it to its end. Resolves with the finished job. */
311
335
  function runJob(path, body) {
312
- if (busy) { toast('Something is already running - wait for it to finish.'); return Promise.reject(new Error('busy')); }
336
+ if (busy) {
337
+ var pr = job && job.running && job.progress;
338
+ toast(pr && pr.quickDone ? 'Check my app is still running its deeper checks - try this again when they end.' : 'Something is already running - wait for it to finish.');
339
+ return Promise.reject(new Error('busy'));
340
+ }
313
341
  setBusy(true);
314
342
  return post(path, body).then(function (started) {
315
343
  job = started.job;
@@ -331,7 +359,13 @@
331
359
  getJob().then(function (now) {
332
360
  // Drawn again only when something in it changed, so a button in it
333
361
  // stays the same button between presses.
334
- if (now && JSON.stringify(now) !== JSON.stringify(job)) { job = now; renderJob(); }
362
+ if (now && JSON.stringify(now) !== JSON.stringify(job)) {
363
+ var wasQuick = !!(job && job.progress && job.progress.quickDone);
364
+ job = now;
365
+ renderJob();
366
+ // the quick part just finished: its findings are on the server now - load them, and tell the guide
367
+ if (!wasQuick && job.progress && job.progress.quickDone) { load(); tell(); }
368
+ }
335
369
  if (now && now.running) setTimeout(tick, 700);
336
370
  else resolve(now);
337
371
  }, function () { setTimeout(tick, 1500); });
@@ -850,6 +884,10 @@
850
884
  return box;
851
885
  }
852
886
 
887
+ // What the findings list shows in the open: the rest are in "More to check", which stays as the person left it.
888
+ var SERIOUS = { CRITICAL: true, 'HIGH CRITICAL': true, HIGH: true };
889
+ function isSerious(f) { return !!SERIOUS[f.severity]; }
890
+ var moreOpen = false;
853
891
  function renderFindings() {
854
892
  var body = byId('findingList');
855
893
  clear(body);
@@ -858,7 +896,8 @@
858
896
  if (statusFilter === 'verify' && f.status === 'confirmed') return false;
859
897
  return true;
860
898
  });
861
- byId('findingBadge').textContent = shown.length + (shown.length !== state.findings.length ? ' of ' + state.findings.length : '');
899
+ var serious = shown.filter(isSerious).length;
900
+ byId('findingBadge').textContent = (serious ? serious + ' serious · ' : '') + shown.length + (shown.length !== state.findings.length ? ' of ' + state.findings.length : '');
862
901
  // A finding the last re-check closed is no longer in the list, so its
863
902
  // answer is said here instead - with what the fix newly broke, if anything.
864
903
  var open = state.findings.some(function (f) { return lastRecheck && f.id === lastRecheck.id; });
@@ -907,6 +946,16 @@
907
946
  return;
908
947
  }
909
948
  var newlyBroken = (lastRecheck ? lastRecheck.newProblems : []).map(function (p) { return p.id; });
949
+ // Serious first, in the open; the rest in a box that opens, counted - never left out. Only when there is
950
+ // something serious: a list of nothing but smaller things is shown as it is.
951
+ var seriousCount = shown.filter(isSerious).length;
952
+ var more = null;
953
+ if (seriousCount && seriousCount < shown.length) {
954
+ more = el('details', 'f-more');
955
+ more.open = moreOpen;
956
+ more.addEventListener('toggle', function () { moreOpen = more.open; });
957
+ more.appendChild(el('summary', null, 'More to check (' + (shown.length - seriousCount) + ') - medium and low: worth fixing, after the serious ones above'));
958
+ }
910
959
  shown.forEach(function (f) {
911
960
  var card = el('div', 'finding ' + (f.status === 'confirmed' ? 'bad' : 'warn'));
912
961
  var head = el('button', 'finding-head');
@@ -961,8 +1010,9 @@
961
1010
  card.appendChild(quick);
962
1011
  }
963
1012
  if (openRow === f.id) card.appendChild(detailBox(f));
964
- body.appendChild(card);
1013
+ (more && !isSerious(f) ? more : body).appendChild(card);
965
1014
  });
1015
+ if (more) body.appendChild(more);
966
1016
  }
967
1017
 
968
1018
  /* -------------------------------- other views -------------------------------- */
@@ -1256,7 +1306,7 @@
1256
1306
  if (!entries.length) { toast('Type the password first.'); return; }
1257
1307
  post('/api/setup/accounts', { entries: entries }).then(function () {
1258
1308
  pwTyped = {};
1259
- toast('Saved. Running your recordings now - 2-3 minutes.');
1309
+ toast('Saved. Running your recordings now.');
1260
1310
  load().then(function () { runChecks(['regression']); });
1261
1311
  }, function (err) { toast(err.message); });
1262
1312
  });
@@ -216,6 +216,11 @@
216
216
 
217
217
  /* --- findings: one row each, a rule down the side ------------------------ */
218
218
  .finding { border-bottom: 1px solid var(--line); }
219
+ /* The medium and low findings, after the serious ones: counted in the summary, opened with one press. */
220
+ .f-more { border-bottom: 1px solid var(--line); }
221
+ .f-more > summary { cursor: pointer; padding: 16px 20px; font-weight: 600; font-size: 14px; color: var(--on-light); background: rgba(18, 22, 29, 0.03); }
222
+ .f-more > summary:hover { color: var(--orange-deep); }
223
+ .f-more[open] > summary { border-bottom: 1px solid var(--line); }
219
224
  .finding.bad { box-shadow: inset 3px 0 0 var(--orange); }
220
225
  .finding.warn { box-shadow: inset 3px 0 0 rgba(18, 22, 29, 0.35); }
221
226
  .finding-head { display: flex; align-items: center; gap: 14px; width: 100%; padding: 18px 8px 18px 20px; text-align: left; transition: background 0.3s var(--ease); }
@@ -299,6 +304,10 @@
299
304
  .job-close { margin-left: auto; padding: 4px 10px; font: 10px var(--mono); letter-spacing: 0.12em; text-transform: uppercase; border: 1px solid var(--line-dark); }
300
305
  .job-lines { min-height: 0; max-height: 220px; margin: 12px 0 0; overflow: auto; font: 12px/1.6 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; opacity: 0.85; }
301
306
  .job-result { margin-top: 12px; font-weight: 700; }
307
+ /* Check my app: which step and how long is left; then, while the deeper checks run, that findings can be read. */
308
+ .job-progress { margin-top: 10px; font: 12px var(--mono); letter-spacing: 0.04em; color: var(--on-dark); }
309
+ .job-ready { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-top: 10px; padding: 10px 12px; font-size: 13px; font-weight: 600; color: var(--ink); background: #ffd9bf; }
310
+ .job-ready button.go { padding: 6px 12px; font: 10px var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--on-dark); background: var(--ink); border: 0; }
302
311
  .job-acts { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
303
312
  .job-acts button { padding: 6px 12px; font: 10px var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--on-dark); border: 1px solid var(--line-dark); }
304
313
  .job-acts button.go { color: var(--ink); background: var(--on-dark); border-color: var(--on-dark); }
@@ -135,6 +135,57 @@ function clearedBy(root, id, env) {
135
135
  return null;
136
136
  }
137
137
 
138
+ /**
139
+ * The API check's bad-value findings ("took price -1 and saved it", "crashed (500) when name was 3000 characters
140
+ * long") of one route, as one finding: one per field buried the cross-organization and payment holes under fifty
141
+ * lines on a real run (2026-11-21, 119 findings). Every field keeps its line and its proof in the detail, and the
142
+ * one fix prompt names each. A route with one such finding keeps it as it was; nothing of another kind is ever
143
+ * folded in. The headline holds no count, so the finding keeps its id while fields are fixed one by one.
144
+ */
145
+ const BAD_VALUE_KINDS = new Set(['invalid-kept', 'invalid-crash']);
146
+ const SEVERITY_RANK = { 'HIGH CRITICAL': 0, CRITICAL: 0, HIGH: 1, MEDIUM: 2, LOW: 3 };
147
+ function groupBadValues(list) {
148
+ const byRoute = new Map();
149
+ for (const f of list) {
150
+ if (!BAD_VALUE_KINDS.has(f.kind)) continue;
151
+ if (!byRoute.has(f.where)) byRoute.set(f.where, []);
152
+ byRoute.get(f.where).push(f);
153
+ }
154
+ const out = [];
155
+ const placed = new Set();
156
+ for (const f of list) {
157
+ const same = BAD_VALUE_KINDS.has(f.kind) ? byRoute.get(f.where) : null;
158
+ if (!same || same.length < 2) { out.push(f); continue; }
159
+ if (placed.has(f.where)) continue;
160
+ placed.add(f.where);
161
+ const severity = same.map((x) => x.severity).sort((a, b) => (SEVERITY_RANK[a] ?? 9) - (SEVERITY_RANK[b] ?? 9))[0];
162
+ const confirmed = same.some((x) => x.status === 'confirmed');
163
+ const fields = Array.from(new Set(same.map((x) => x.field || '?')));
164
+ out.push({
165
+ check: 'api',
166
+ kind: 'invalid-group',
167
+ severity: severity,
168
+ status: confirmed ? 'confirmed' : 'verification required',
169
+ evidence: confirmed ? 'runtime confirmed' : 'seen once',
170
+ confidence: confirmed ? 'high' : 'medium',
171
+ where: f.where,
172
+ headline: f.where + ' takes bad values it should turn away - nothing in the code checks them',
173
+ detail: [same.length + ' tries in ' + fields.length + ' fields (' + fields.join(', ') + '):']
174
+ .concat(same.map((x) => '- ' + x.headline + '\n ' + String(x.detail || '').split('\n').join('\n '))).join('\n'),
175
+ fixPrompt: [
176
+ 'Kryptheon sent bad values to my running app, and ' + f.where + ' did not turn them away:', '',
177
+ same.map((x) => '- ' + x.headline).join('\n'), '',
178
+ 'First check each is real (the app may mean to accept some). For each field that should not take it - ' + fields.join(', ') +
179
+ ' - reject the value where the handler reads it: blank, negative, the wrong type or too long, on the server, with a 400 and a message, before anything is stored. Change nothing else.',
180
+ '', 'Afterwards I will run: npx kryptheon api',
181
+ ].join('\n'),
182
+ when: f.when,
183
+ parts: same.length,
184
+ });
185
+ }
186
+ return out;
187
+ }
188
+
138
189
  /** A time as the dashboard shows it: 13 Oct, 17:20. */
139
190
  function localTime(iso) {
140
191
  const d = new Date(iso);
@@ -345,7 +396,7 @@ function localOrigin(address) {
345
396
  * computer the recordings open. A step marked live opens an address that is
346
397
  * not this computer: it runs only with the person's tick.
347
398
  */
348
- function everythingPlan(checks, app, addresses) {
399
+ function everythingPlan(checks, app, addresses, times) {
349
400
  const by = Object.fromEntries(checks.map((c) => [c.id, c]));
350
401
  const steps = [];
351
402
  const skipped = [];
@@ -388,8 +439,59 @@ function everythingPlan(checks, app, addresses) {
388
439
  lines.push(steps.filter((s) => s.addsData).map((s) => s.label).join(', ') + ' add test data to your app' + (origin && steps.some((s) => s.id === 'api') ? ' (the API step signs in as the accounts whose passwords are in your .env)' : '') + '. Nothing is ever deleted - the test data stays.');
389
440
  lines.push('Where: ' + (where.length ? where.join(', ') : 'your app on this computer') + '. Run it on your own test copy, never on the live app real people use.');
390
441
  }
391
- lines.push('It takes a few minutes. Stop ends it part way; what finished is kept.');
392
- return { steps: steps, skipped: skipped, addsData: addsData, live: live, origin: origin, lines: lines };
442
+ // How long, said as it is: measured on this computer once a run has finished, a guess before that. "A few
443
+ // minutes" was said for years; a real run on a 70-route app took 25 (2026-11-21), and a person who waits
444
+ // twice as long as told closes the window.
445
+ const measured = times || {};
446
+ for (const s of steps) {
447
+ s.deep = DEEP_STEPS.has(s.id);
448
+ s.estimateMs = measured[s.id] || STEP_GUESS_MS[s.id] || 60000;
449
+ }
450
+ const estimateMs = steps.reduce((n, s) => n + s.estimateMs, 0);
451
+ const quick = steps.filter((s) => !s.deep);
452
+ const quickMs = quick.reduce((n, s) => n + s.estimateMs, 0);
453
+ const guessed = steps.some((s) => !measured[s.id]);
454
+ lines.push('About ' + howLong(estimateMs) + (guessed ? ' (a guess - after one run it is measured on this computer)' : '') + '. ' +
455
+ (quick.length && quick.length < steps.length
456
+ ? 'The first findings (' + quick.map((s) => s.label).join(', ') + ') are ready to read after about ' + howLong(quickMs) + '; the deeper checks keep running after them. '
457
+ : '') +
458
+ 'Stop ends it part way; what finished is kept.');
459
+ return { steps: steps, skipped: skipped, addsData: addsData, live: live, origin: origin, lines: lines, estimateMs: estimateMs, quickMs: quickMs };
460
+ }
461
+
462
+ // The steps that replay recordings many times: they run after the others, and each has a time limit.
463
+ const DEEP_STEPS = new Set(['edge', 'reliability', 'roles']);
464
+ // Before anything is measured on this computer. From a real run on a 70-route app (2026-11-21).
465
+ // That run, 22 minutes in all: the first four 7.5, edge 6.5, reliability 4.5, roles 4.
466
+ const STEP_GUESS_MS = { frontend: 20000, backend: 20000, regression: 90000, api: 6 * 60000, edge: 6.5 * 60000, reliability: 4.5 * 60000, roles: 4 * 60000 };
467
+ // A deep step stops here, keeps what it found, and says what was not tried.
468
+ const DEEP_STEP_LIMIT_MS = 8 * 60000;
469
+ const STEP_TIMES_FILE = 'step-times.json';
470
+
471
+ /** "45 s", "4 min", "1 h 10 min". */
472
+ function howLong(ms) {
473
+ const s = Math.max(1, Math.round(ms / 1000));
474
+ if (s < 60) return s + ' s';
475
+ const m = Math.round(s / 60);
476
+ if (m < 60) return m + ' min';
477
+ return Math.floor(m / 60) + ' h' + (m % 60 ? ' ' + (m % 60) + ' min' : '');
478
+ }
479
+
480
+ /** How long each step took the last time it finished on this computer: { id: ms }. */
481
+ function readStepTimes(paths) {
482
+ const raw = readJson(path.join(paths.dir, STEP_TIMES_FILE)) || {};
483
+ const out = {};
484
+ for (const k of Object.keys(raw)) if (EVERYTHING_ORDER.includes(k) && Number.isFinite(raw[k]) && raw[k] > 0) out[k] = raw[k];
485
+ return out;
486
+ }
487
+
488
+ /** Kept for the next estimate - only for a step that ran to its end (not stopped, not cut by its limit). */
489
+ function rememberStepTime(root, env, id, ms) {
490
+ if (!EVERYTHING_ORDER.includes(id) || !(ms > 0)) return;
491
+ const paths = store.pathsFor(root, env);
492
+ const times = readStepTimes(paths);
493
+ times[id] = Math.round(ms);
494
+ try { fs.writeFileSync(path.join(paths.dir, STEP_TIMES_FILE), JSON.stringify(times) + '\n', 'utf8'); } catch (err) { /* the guess is used again */ }
393
495
  }
394
496
 
395
497
  // Loaded when it is first needed, so a page that never shows payments never
@@ -793,10 +895,13 @@ function buildState(root, env) {
793
895
  // a re-check that said FIXED after this run: that finding is closed until a later run finds it again
794
896
  const apiFixed = new Set(readHistory(paths.fixes, 500).filter((a) => a && a.check === 'api' && a.verdict === 'fixed' && a.at > (apiLast.checkedAt || ''))
795
897
  .map((a) => a.where + '|' + a.headline));
898
+ const apiFindings = [];
796
899
  for (const f of apiLast.findings || []) {
797
900
  if (apiFixed.has(f.where + '|' + f.headline)) continue;
798
- findings.push({
901
+ apiFindings.push({
799
902
  check: 'api',
903
+ kind: f.kind,
904
+ field: f.field,
800
905
  severity: f.severity,
801
906
  status: f.status,
802
907
  evidence: f.status === 'confirmed' ? 'runtime confirmed' : 'seen once',
@@ -808,6 +913,7 @@ function buildState(root, env) {
808
913
  when: apiLast.checkedAt,
809
914
  });
810
915
  }
916
+ for (const f of groupBadValues(apiFindings)) findings.push(f);
811
917
  }
812
918
 
813
919
  // Input and edge cases, and reliability: the last press of each one's
@@ -1089,7 +1195,7 @@ function buildState(root, env) {
1089
1195
  },
1090
1196
  next: nextAction(findings, steps),
1091
1197
  // What "Check my app" runs with one press, and what it leaves out.
1092
- everything: everythingPlan(checks, { address: readAppAddress(paths), webOnly: webOnly }, recordings ? probeAsk(root, '', env).addresses : []),
1198
+ everything: everythingPlan(checks, { address: readAppAddress(paths), webOnly: webOnly }, recordings ? probeAsk(root, '', env).addresses : [], readStepTimes(paths)),
1093
1199
  baselines: Object.keys(baselines).length,
1094
1200
  changes: recentChanges(root),
1095
1201
  // Part 3 is where a version gets verified. Until then this says so,
@@ -1291,6 +1397,8 @@ function createJobs() {
1291
1397
  id: job.id, kind: job.kind, title: job.title, command: job.command,
1292
1398
  startedAt: job.startedAt, endedAt: job.endedAt, running: job.running,
1293
1399
  lines: job.lines.slice(), result: job.result,
1400
+ // Check my app: which step, how long is left, and whether the first findings are ready to read.
1401
+ progress: job.progress || null,
1294
1402
  // A run that can be ended part way says so, and the page shows Stop.
1295
1403
  stoppable: Boolean(job.running && job.stopper), stopping: Boolean(job.stopping),
1296
1404
  };
@@ -1326,7 +1434,7 @@ function createJobs() {
1326
1434
  secrets = null;
1327
1435
  };
1328
1436
  Promise.resolve()
1329
- .then(() => work(say, { onStop: (fn) => (job.stopper = fn) }))
1437
+ .then(() => work(say, { onStop: (fn) => (job.stopper = fn), progress: (p) => { if (job.running) job.progress = p; } }))
1330
1438
  .then(finish, (err) => finish({ ok: false, why: err && err.message ? err.message : String(err) }));
1331
1439
  return view(job);
1332
1440
  },
@@ -1698,6 +1806,10 @@ module.exports = {
1698
1806
  tenantRoutesLines: tenantRoutesLines,
1699
1807
  CHECKS: CHECKS,
1700
1808
  everythingPlan: everythingPlan,
1809
+ howLong: howLong,
1810
+ readStepTimes: readStepTimes,
1811
+ rememberStepTime: rememberStepTime,
1812
+ DEEP_STEP_LIMIT_MS: DEEP_STEP_LIMIT_MS,
1701
1813
  localOrigin: localOrigin,
1702
1814
  buildState: buildState,
1703
1815
  clearedBy: clearedBy,
package/kryptheon-tour.js CHANGED
@@ -14,6 +14,7 @@
14
14
  var KEY = 'kryptheon.guide.v1';
15
15
  var state = null;
16
16
  var busy = false;
17
+ var quickDone = false; // Check my app is still running, and its first findings are ready to read
17
18
  var on = false;
18
19
  var at = null;
19
20
  var seen = {};
@@ -135,6 +136,13 @@
135
136
  function recordings() { var s = recordStep(); return s ? (s.count || (s.state === 'done' ? 1 : 0)) : 0; }
136
137
  function hasAddress() { return !!(state && state.app && state.app.address); }
137
138
  function findings() { return (state && state.findings) || []; }
139
+ // "4 minutes": when Check my app's first findings come, from the plan's estimate (measured once it has run)
140
+ function firstFindingsIn() {
141
+ var ms = state && state.everything && state.everything.quickMs;
142
+ if (!ms) return '';
143
+ var m = Math.max(1, Math.round(ms / 60000));
144
+ return m === 1 ? '1 minute' : m + ' minutes';
145
+ }
138
146
  function needsPassword() { return !!(state && state.passwordsNeeded && state.passwordsNeeded.length); }
139
147
  function needsConnect() {
140
148
  var f = findings()[0];
@@ -243,7 +251,7 @@
243
251
  show: function (c) {
244
252
  if (busy) {
245
253
  title(c, 'Running ', 'your recordings', '');
246
- c.appendChild(el('p', 'kt-red', 'Please wait - this takes 2 or 3 minutes. Keep this page and the black window open.'));
254
+ c.appendChild(el('p', 'kt-red', 'Please wait - your recordings are replaying. Keep this page and the black window open.'));
247
255
  waiting(c, 'Running');
248
256
  return;
249
257
  }
@@ -268,7 +276,8 @@
268
276
  return;
269
277
  }
270
278
  title(c, n === 1 ? 'Your ' : 'Your ', n + (n === 1 ? ' finding' : ' findings'), '');
271
- c.appendChild(el('p', null, 'Each one is something a check saw happen in your app, with its proof. The most serious is at the top. Open one to read what went wrong.'));
279
+ c.appendChild(el('p', null, 'Each one is something a check saw happen in your app, with its proof. The serious ones are at the top; the rest are in More to check below them. Open one to read what went wrong.'));
280
+ if (busy) c.appendChild(el('p', null, 'The deeper checks are still running - more findings may appear here while you read.'));
272
281
  row(c, [go('Next', function () { move('fix'); })]);
273
282
  },
274
283
  },
@@ -355,8 +364,8 @@
355
364
  show: function (c) {
356
365
  if (busy) {
357
366
  title(c, 'Checking ', 'your app', '');
358
- c.appendChild(el('p', 'kt-red', 'Please wait - this takes 2 or 3 minutes. Keep this page and the black window open.'));
359
- c.appendChild(el('p', null, 'Every check is running, one after another. You can watch each line here.'));
367
+ c.appendChild(el('p', 'kt-red', 'Please wait' + (firstFindingsIn() ? ' - the first findings come in about ' + firstFindingsIn() : '') + '. Keep this page and the black window open.'));
368
+ c.appendChild(el('p', null, 'Every check is running, one after another. You can watch each line here - and how long is left. The guide moves on as soon as the first findings are ready; the deeper checks keep running after.'));
360
369
  waiting(c, 'Running');
361
370
  return;
362
371
  }
@@ -370,7 +379,9 @@
370
379
  c.appendChild(el('p', null, text));
371
380
  waiting(c, 'Waiting for you to press it');
372
381
  },
373
- done: function () { return seen.ran && !busy; },
382
+ // done when the run ends - or, for Check my app, once its first findings are ready: nobody should sit through
383
+ // the deeper checks before they can read anything
384
+ done: function () { return seen.ran && (!busy || quickDone); },
374
385
  next: next,
375
386
  };
376
387
  }
@@ -637,7 +648,7 @@
637
648
  function signature() {
638
649
  return [at, busy, Date.now() - stepSince > STUCK_MS, seen.connectWhy || '', visible(byId('everyBox')), hasAddress(), recordings(), findings().length, seen.pressed, needsConnect(), connected(),
639
650
  !!((q('#accountBox input') || {}).value),
640
- state && state.autostart && state.autostart.on, state && state.daily && state.daily.on, needsPassword()].join('|');
651
+ state && state.autostart && state.autostart.on, state && state.daily && state.daily.on, needsPassword(), quickDone].join('|');
641
652
  }
642
653
 
643
654
  function move(id, back) {
@@ -696,6 +707,7 @@
696
707
  window.addEventListener('kryptheon:state', function (e) {
697
708
  state = (e.detail && e.detail.state) || state;
698
709
  busy = !!(e.detail && e.detail.busy);
710
+ quickDone = !!(e.detail && e.detail.quickDone);
699
711
  if (!state) return;
700
712
  if (!guideBtn && byId('runAll')) {
701
713
  guideBtn = el('button', 'btn kt-guide-btn', 'Guide me');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kryptheon",
3
- "version": "0.1.74",
3
+ "version": "0.1.75",
4
4
  "description": "Record what you do in your app and get plain-language reports when it breaks.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "commonjs",
@@ -75,7 +75,7 @@
75
75
  "pg": "^8.23.0"
76
76
  },
77
77
  "scripts": {
78
- "check": "node kryptheon-store.check.js && node kryptheon-code.check.js && node kryptheon-constdata.check.js && node kryptheon-listitems.check.js && node kryptheon-accept.check.js && node kryptheon-keys.check.js && node kryptheon-dashboard.check.js && node kryptheon-tour.check.js && node kryptheon-upgrade.check.js && node kryptheon-edge.check.js && node kryptheon-reliability.check.js && node kryptheon-fresh.check.js && node kryptheon-payments-dash.check.js && node kryptheon-embedded.check.js && node kryptheon-autostart.check.js && node kryptheon-changes.check.js && node kryptheon-look.check.js && node kryptheon-verify.check.js && node kryptheon-recheck.check.js && node kryptheon-reporter.check.js && node kryptheon-signature.check.js && node kryptheon-signature.stream.check.js && node kryptheon-signature.baseline.check.js && node kryptheon-signature.settle.check.js && node kryptheon-signature.number.check.js && node kryptheon-signature.rows.check.js && node kryptheon-env.check.js && node kryptheon-watchdog.check.js && node kryptheon-phone.check.js && node kryptheon-homedash.check.js && node kryptheon-record.check.js && node kryptheon-selectors.check.js && node kryptheon-recordings.check.js && node kryptheon-testfiles.check.js && node kryptheon-cleanup.check.js && node kryptheon-orphan.check.js && node kryptheon-project.check.js && node kryptheon-setup.check.js && node kryptheon-browser.check.js && node kryptheon-heal.check.js && node kryptheon-load.check.js && node kryptheon-authz.check.js && node kryptheon-roles.check.js && node kryptheon-map.check.js && node kryptheon-api.check.js && node kryptheon-webhook.check.js && node kryptheon-csv.check.js && node kryptheon-witness.check.js && node kryptheon-round34.check.js && node kryptheon-token.check.js && node kryptheon-questions.check.js && node kryptheon-pwbox.check.js && node kryptheon-daily.check.js && node kryptheon-live.check.js && node kryptheon-aim.check.js && node kryptheon-peruser.check.js && node kryptheon-aiapp.check.js && node kryptheon-package.check.js && node kryptheon-newer.check.js",
78
+ "check": "node kryptheon-store.check.js && node kryptheon-code.check.js && node kryptheon-constdata.check.js && node kryptheon-listitems.check.js && node kryptheon-accept.check.js && node kryptheon-keys.check.js && node kryptheon-dashboard.check.js && node kryptheon-tour.check.js && node kryptheon-upgrade.check.js && node kryptheon-edge.check.js && node kryptheon-reliability.check.js && node kryptheon-fresh.check.js && node kryptheon-payments-dash.check.js && node kryptheon-embedded.check.js && node kryptheon-autostart.check.js && node kryptheon-changes.check.js && node kryptheon-look.check.js && node kryptheon-verify.check.js && node kryptheon-recheck.check.js && node kryptheon-reporter.check.js && node kryptheon-signature.check.js && node kryptheon-signature.stream.check.js && node kryptheon-signature.baseline.check.js && node kryptheon-signature.settle.check.js && node kryptheon-signature.number.check.js && node kryptheon-signature.rows.check.js && node kryptheon-env.check.js && node kryptheon-watchdog.check.js && node kryptheon-phone.check.js && node kryptheon-homedash.check.js && node kryptheon-record.check.js && node kryptheon-selectors.check.js && node kryptheon-recordings.check.js && node kryptheon-testfiles.check.js && node kryptheon-cleanup.check.js && node kryptheon-orphan.check.js && node kryptheon-project.check.js && node kryptheon-setup.check.js && node kryptheon-browser.check.js && node kryptheon-heal.check.js && node kryptheon-load.check.js && node kryptheon-authz.check.js && node kryptheon-roles.check.js && node kryptheon-map.check.js && node kryptheon-api.check.js && node kryptheon-webhook.check.js && node kryptheon-csv.check.js && node kryptheon-witness.check.js && node kryptheon-round34.check.js && node kryptheon-token.check.js && node kryptheon-questions.check.js && node kryptheon-pwbox.check.js && node kryptheon-quiet.check.js && node kryptheon-speed.check.js && node kryptheon-daily.check.js && node kryptheon-live.check.js && node kryptheon-aim.check.js && node kryptheon-peruser.check.js && node kryptheon-aiapp.check.js && node kryptheon-package.check.js && node kryptheon-newer.check.js",
79
79
  "check:store": "node kryptheon-store.check.js",
80
80
  "check:code": "node kryptheon-code.check.js",
81
81
  "check:constdata": "node kryptheon-constdata.check.js",