create-pmos 0.438.0 → 0.439.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-pmos",
3
- "version": "0.438.0",
3
+ "version": "0.439.0",
4
4
  "description": "Scaffold the PMOS portable kit — run the PMOS product-management workflow (initiative → lane-fit spec → contract → build → three gates, with work-type lanes for features, research, maintenance, incidents, and content) entirely inside your own repo, with all state as git-versioned files. Includes `workflow-sweep`, which audits the state every board derives from and separates real defects from work you simply have not done. `create-pmos workspace` also installs + launches the local Terminal Workspace GUI. No database, no network, no telemetry.",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -32,6 +32,18 @@
32
32
  "audit"
33
33
  ],
34
34
  "pmosChanges": [
35
+ {
36
+ "v": "0.439.0",
37
+ "at": "2026-10-28T08:30:50.008Z",
38
+ "f": 2,
39
+ "prs": [
40
+ {
41
+ "n": 1083,
42
+ "t": "Meeting notes cover the whole meeting when the live transcript stops early",
43
+ "s": "Meeting notes cover the whole meeting when the live transcript stops early"
44
+ }
45
+ ]
46
+ },
35
47
  {
36
48
  "v": "0.438.0",
37
49
  "at": "2026-10-28T06:29:09.651Z",
@@ -259,18 +271,6 @@
259
271
  "s": "Ninth testing feedback batch"
260
272
  }
261
273
  ]
262
- },
263
- {
264
- "v": "0.419.0",
265
- "at": "2026-10-26T03:21:59.105Z",
266
- "f": 2,
267
- "prs": [
268
- {
269
- "n": 1055,
270
- "t": "Eighth testing feedback batch",
271
- "s": "Eighth testing feedback batch"
272
- }
273
- ]
274
274
  }
275
275
  ]
276
276
  }
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@83a39666
1
+ kernel-source: pmos@669943cd
2
2
  assembled: 2026-10-28
3
3
  mode: vendor
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Eval calibration log"
4
4
  description: "Append-only record of every PM override of an evaluator verdict."
5
- generated: {by: process:create-pmos, at: "2026-10-28T06:29:06Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-28T08:30:46Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Health budgets"
4
4
  description: "Closed registry of health-budget anchors (D59), edited only by the PM."
5
- generated: {by: process:create-pmos, at: "2026-10-28T06:29:06Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-28T08:30:46Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Discoveries and friction log"
4
4
  description: "Append-only record of what runs discovered and where the process rubbed."
5
- generated: {by: process:create-pmos, at: "2026-10-28T06:29:06Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-28T08:30:46Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -1,4 +1,16 @@
1
1
  [
2
+ {
3
+ "v": "0.439.0",
4
+ "at": "2026-10-28T08:30:50.008Z",
5
+ "f": 2,
6
+ "prs": [
7
+ {
8
+ "n": 1083,
9
+ "t": "Meeting notes cover the whole meeting when the live transcript stops early",
10
+ "s": "Meeting notes cover the whole meeting when the live transcript stops early"
11
+ }
12
+ ]
13
+ },
2
14
  {
3
15
  "v": "0.438.0",
4
16
  "at": "2026-10-28T06:29:09.651Z",
@@ -2,7 +2,7 @@
2
2
  type: Guide
3
3
  title: "Guide: notes"
4
4
  description: "How to take notes in a meeting: one note top to bottom, typed notes as timed lines, key points written each minute and labelled by Jev, delete a note; final notes written after Stop from the whole recording, with speakers and a quote for each item, decisions with their why and who, next steps with an open question, a discussion paragraph, and Wispr Flow's notes merged in and fetched by hand when the fetch fails; listen to your microphone and the meeting on this machine, see decisions, actions and questions caught as they are said, check them against the repository for conflicts, capture highlights during the meeting, create tasks from next steps, correct and tag lines, see what changed in your notes, replay the meeting, see screenshots of the shared screen beside the transcript, link a note to its meeting and its initiative, and get a summary."
5
- timestamp: 2026-10-26
5
+ timestamp: 2026-10-28
6
6
  ---
7
7
 
8
8
  # Guide: notes
@@ -37,6 +37,8 @@ The live transcript keeps each sentence once:
37
37
  - A line that only repeats the line before it is left out. A sentence said twice in a row in one line is kept once.
38
38
  - If the meeting language is English (the default), a line that comes back in another language, for example Hindi, Indonesian or Chinese, is transcribed again in English. The first text stays with the line.
39
39
  - If the workspace restarts during a meeting, the recording continues where it was. Nothing is written twice.
40
+ - When the live transcript falls behind, or the engine stops for a moment, the audio is still kept. When the engine answers again, the stretches it missed are transcribed from the kept audio and appear at their own time in the transcript.
41
+ - When Qwen3-ASR fails three lines in a row, the live transcript uses Whisper for five minutes (when Whisper is set up), then tries Qwen3-ASR again.
40
42
 
41
43
  ## Pause, resume and stop
42
44
 
@@ -123,7 +125,7 @@ After **Stop**, the final notes replace this live draft. See [Final notes after
123
125
 
124
126
  ## Final notes after Stop
125
127
 
126
- The notes taken live are a draft. After **Stop**, the workspace transcribes the whole recording again on this machine, with more time for each sentence, and then your agent session writes the final notes from that transcript and your typed lines.
128
+ The notes taken live are a draft. After **Stop**, from any page (the recording tab, the meeting in the Viewer or your phone), the workspace transcribes the whole recording again on this machine, with more time for each sentence, and then your agent session writes the final notes from that transcript and your typed lines.
127
129
 
128
130
  1. The workspace transcribes your microphone and the meeting apart. It uses **Qwen3-ASR** when it is set up, in any of the languages. Else it uses **Parakeet** when it is set up and the meeting is in English, else Whisper with beam search, speech detection and the names of this meeting. When one engine fails, the next one set up is used.
129
131
  2. It tells the speakers apart. Your microphone is you. The meeting's voices are **Speaker 1**, **Speaker 2** and so on. When no meeting audio was captured, the voices on your microphone are told apart instead.
@@ -146,6 +148,7 @@ When PMOS restarts (for example after you install a new version) while a note wa
146
148
 
147
149
  - A final pass that was queued or running is queued again. When it can no longer run, for example because the audio is gone, the note says why, and your agent session writes the notes from the live transcript.
148
150
  - A summary that was started and never written is started again.
151
+ - A meeting that ended in the last two weeks with no final pass gets one, from its kept audio, and your agent session writes its notes again from the whole meeting. At most 10 meetings, the most recent first.
149
152
  - A Wispr Flow fetch continues on its own schedule. When its 20 minutes have passed, it stops and says so. Press **Fetch Wispr Flow notes now** to try again.
150
153
 
151
154
  ## Wispr Flow notes
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * detect(runtimeDir, { env }) → { ready, bin, model, missing, setup, model_dir }
5
5
  * setupCommand(runtimeDir) → the shell commands the PM runs once: install whisper.cpp and download its model
6
- * createTranscriber({ runtimeDir, onText, run?, detect?, vocab?, prompt? }) → { push, flush, drop, pending, idle }
6
+ * createTranscriber({ runtimeDir, onText, onSkip?, run?, detect?, vocab?, prompt? }) → { push, fill, flush, drop, pending, idle }
7
7
  * wav(pcm, rate) · levels(pcm, rate) · cleanText(text, { voicedRatio }) · promptFor(vocab, previous)
8
8
  * getLanguage(runtimeDir) · setLanguage(runtimeDir, code) the spoken language Whisper writes in (LANGUAGES)
9
9
  * getModel(runtimeDir) · setModel(runtimeDir, id) the model: accurate (1.6 GB) or faster (about 550 MB) (MODELS)
@@ -60,6 +60,7 @@ const MIN_VOICED_MS = 300;
60
60
  const LEAD_MS = 300; // speech that starts a cut keeps this much of the quiet before it
61
61
  const MIN_RMS = 180; // in 16-bit units; below this a frame is quiet whatever the room
62
62
  const MAX_QUEUE = 24;
63
+ const FILL_ROOM = 2; // a skipped stretch is filled in only while fewer cuts than this wait
63
64
  const RUN_TIMEOUT_MS = 120000;
64
65
  const HOLD_MS = 12000; // a microphone line waits at most this long for the meeting's line of the same time
65
66
  const MEETING_LIVE_MS = 30000; // meeting audio this recent means the meeting is being captured
@@ -264,7 +265,7 @@ function runWhisper({ bin, model, file, lang = DEFAULT_LANGUAGE, accuracy = DEFA
264
265
  * @param {Function} [a.run] runWhisper, replaceable in the suites
265
266
  * @param {Function} [a.detect] detect, replaceable in the suites
266
267
  */
267
- function createTranscriber({ runtimeDir, onText, onError = () => {}, onCut = () => {}, run = runWhisper, detect: det = () => detect(runtimeDir), vocab = null, prompt = '',
268
+ function createTranscriber({ runtimeDir, onText, onError = () => {}, onCut = () => {}, onSkip = () => {}, run = runWhisper, detect: det = () => detect(runtimeDir), vocab = null, prompt = '',
268
269
  echo = true, holdMs = HOLD_MS, recent = null, lastLine = null }) {
269
270
  const bufs = new Map(); // `${id}|${source}` → { id, source, chunks, ms, voicedMs, quietMs, t, noise }
270
271
  const lastText = new Map(); // `${id}|${source}` → { text, t }: the last line heard there, for the repetition guard
@@ -373,27 +374,48 @@ function createTranscriber({ runtimeDir, onText, onError = () => {}, onCut = ()
373
374
  try { onCut({ id: b.id, source: b.source, until: Math.min(b.t + b.ms, ...waitFor) }); } catch { /* the caller's bookkeeping */ }
374
375
  };
375
376
  if (b.voicedMs < MIN_VOICED_MS || !b.chunks.length) { queue = queue.then(done).catch(() => {}); if (held.length) release(); return false; }
376
- if (waiting >= MAX_QUEUE) { onError({ id: b.id, source: b.source, error: 'transcription is falling behind, so a few seconds were skipped' }); return false; }
377
- const pcm = Buffer.concat(b.chunks);
378
377
  const job = { id: b.id, source: b.source, t: b.t, ms: b.ms, ...(b.ts ? { exact: true } : {}) };
379
- const voicedRatio = b.ms > 0 ? b.voicedMs / b.ms : 1;
378
+ if (waiting >= MAX_QUEUE) { skipped(job, 'transcription is falling behind, so a few seconds were skipped'); return false; }
379
+ enqueue(job, Buffer.concat(b.chunks), b.ms > 0 ? b.voicedMs / b.ms : 1, done);
380
+ return true;
381
+ }
382
+ /* CATCHING UP (notes-transcript-recovery). A cut that was skipped (falling behind) or failed (the engine stopped, timed out or
383
+ * was not ready) is not lost: the caller hears of it through onSkip({ id, source, t, ms, tries }) and, once the queue is short
384
+ * again, hands the same stretch back from the kept audio through fill(). So the live transcript fills its own gaps. */
385
+ function skipped(job, error) {
386
+ onError({ ...job, error });
387
+ try { onSkip({ id: job.id, source: job.source, t: job.t, ms: job.ms, tries: job.tries || 0 }); } catch { /* the caller's bookkeeping */ }
388
+ }
389
+ function enqueue(job, pcm, voicedRatio, done = () => {}) {
380
390
  const q = { id: job.id, source: job.source, t: job.t };
381
391
  inQueue.push(q);
382
392
  waiting++;
383
393
  queue = queue.then(async () => {
384
394
  const d = det();
385
- if (!d.ready) { onError({ ...job, error: 'local transcription is not set up' }); return; }
395
+ if (!d.ready) { skipped(job, 'local transcription is not set up'); return; }
386
396
  fs.mkdirSync(tmpDir, { recursive: true });
387
397
  const file = path.join(tmpDir, 'cut-' + crypto.randomBytes(6).toString('hex') + '.wav');
388
398
  try {
389
399
  fs.writeFileSync(file, wav(pcm), { mode: 0o600 });
390
400
  // `engine` is 'qwen' when the caller's detect chose Qwen3-ASR (lib/notes-qwen.js); `run` then sends the cut there
391
401
  const r = await transcribe(d, job, file, voicedRatio);
392
- if (!r.ok) { onError({ ...job, error: r.error }); return; }
393
- if (r.text) await deliver(job, r.text, r.extra);
394
- } catch (e) { onError({ ...job, error: String((e && e.message) || e) }); }
402
+ engineOk = !!r.ok;
403
+ if (!r.ok) { skipped(job, r.error); return; }
404
+ if (r.text) await deliver(job, r.text, job.fill ? { ...(r.extra || {}), fill: true } : r.extra);
405
+ } catch (e) { engineOk = false; skipped(job, String((e && e.message) || e)); }
395
406
  finally { try { fs.unlinkSync(file); } catch { /* already gone */ } }
396
407
  }).catch(() => {}).finally(() => { waiting--; done(); const i = inQueue.indexOf(q); if (i >= 0) inQueue.splice(i, 1); if (held.length) release(); });
408
+ }
409
+ /** A stretch skipped earlier, read back from the kept audio. Queued only once the engine has answered again (a stretch tried
410
+ * while it is still down would only fail again) and while the queue has room for the live cuts too. → true when it was queued. */
411
+ let engineOk = true;
412
+ function fill({ id, source, pcm, t, tries = 0 }) {
413
+ if (!pcm || pcm.length < 2 || waiting >= FILL_ROOM || !engineOk) return false;
414
+ const ms = (pcm.length / 2 / RATE) * 1000;
415
+ let voiced = 0; let noise = noiseOf.has(source) ? noiseOf.get(source) : null;
416
+ for (const v of levels(pcm)) { if (v > Math.max(MIN_RMS, (noise == null ? 0 : noise) * 3)) voiced += FRAME_MS; else noise = noise == null ? v : noise * 0.9 + v * 0.1; }
417
+ if (voiced < MIN_VOICED_MS) return true; // nothing was said there: nothing to fill
418
+ enqueue({ id, source, t, ms, exact: true, fill: true, tries: tries + 1 }, pcm, ms > 0 ? voiced / ms : 1);
397
419
  return true;
398
420
  }
399
421
 
@@ -460,9 +482,9 @@ function createTranscriber({ runtimeDir, onText, onError = () => {}, onCut = ()
460
482
  if (q === queue) return;
461
483
  }
462
484
  }
463
- return { push, flush, drop, has, pending: () => waiting + held.length, idle };
485
+ return { push, fill, flush, drop, has, pending: () => waiting + held.length, idle };
464
486
  }
465
487
 
466
488
  module.exports = { detect, setupCommand, getLanguage, setLanguage, LANGUAGES, DEFAULT_LANGUAGE, getModel, setModel, MODELS, DEFAULT_MODEL,
467
489
  getAccuracy, setAccuracy, ACCURACIES, DEFAULT_ACCURACY, createTranscriber, runWhisper, wav, levels, cleanText, promptFor, modelDir, RATE, MODEL_FILE, MODEL_URL,
468
- MIN_CUT_MS, MAX_CUT_MS, PAUSE_MS, LONG_PAUSE_MS, PROMPT_MAX, LOW_VOICED_RATIO, NO_SPEECH_THOLD };
490
+ MIN_CUT_MS, MAX_CUT_MS, MAX_QUEUE, FILL_ROOM, PAUSE_MS, LONG_PAUSE_MS, PROMPT_MAX, LOW_VOICED_RATIO, NO_SPEECH_THOLD };
@@ -587,7 +587,7 @@ function joinText(prev, next, names) {
587
587
  const tail = KEEP_CAP.test(next) || (names && names.has(word)) || PROPER_DAYS.test(word) ? next : next.charAt(0).toLowerCase() + next.slice(1);
588
588
  return askMark(head.replace(/[,\s]+$/, '') + ' ' + tail);
589
589
  }
590
- function appendTranscript(dir, { id, text, source = 'speech', t: at = null, ms = null, heard_as = null, now = Date.now() } = {}) {
590
+ function appendTranscript(dir, { id, text, source = 'speech', t: at = null, ms = null, heard_as = null, fill = false, now = Date.now() } = {}) {
591
591
  const note = load(dir, id);
592
592
  if (!note) return err(404, 'no such note');
593
593
  if (note.private) return err(409, 'this note is marked private, so nothing more is recorded in it');
@@ -602,12 +602,14 @@ function appendTranscript(dir, { id, text, source = 'speech', t: at = null, ms =
602
602
  const names = namesIn((note.transcript || []).map((x) => x.text).concat(sentences, [note.body || '']));
603
603
  const tr = note.transcript || (note.transcript = []);
604
604
  const tEnd = Number.isFinite(ms) && ms > 0 ? t + Math.round(ms) : null;
605
- const open = JOINS.has(src) && endsOpen(raw);
605
+ // a stretch filled in after the engine caught up (notes-transcript-recovery) belongs earlier than the last line: it is never
606
+ // joined to that line, and it is never left open for the next line to join
607
+ const open = !fill && JOINS.has(src) && endsOpen(raw);
606
608
  // the first text of a line that came back in another language and was run again in English (notes-recording-reliability, D8)
607
609
  const heardAs = heard_as && typeof heard_as.text === 'string' && heard_as.text ? { text: heard_as.text.slice(0, MAX_PHRASE), language: String(heard_as.language || '').slice(0, 40) } : null;
608
610
  const out = [];
609
611
  // the first sentence may finish the line before it, from the same source
610
- if (JOINS.has(src)) {
612
+ if (JOINS.has(src) && !fill) {
611
613
  let pi = -1;
612
614
  for (let k = tr.length - 1; k >= 0; k--) if (tr[k] && tr[k].source === src) { pi = k; break; }
613
615
  const prev = pi >= 0 ? tr[pi] : null;
@@ -627,7 +629,7 @@ function appendTranscript(dir, { id, text, source = 'speech', t: at = null, ms =
627
629
  const base = tr.length;
628
630
  const added = sentences.map((s, k) => { const isOpen = open && k === sentences.length - 1;
629
631
  return { at: iso(now), t, ...(tEnd != null ? { t_end: tEnd } : {}), text: s, source: src, cat: isOpen ? null : categoryOf(s, names), cat_by: 'local',
630
- ...(isOpen ? { open: true } : {}), ...(heardAs ? { heard_as: heardAs } : {}), index: base + k }; });
632
+ ...(isOpen ? { open: true } : {}), ...(heardAs ? { heard_as: heardAs } : {}), ...(fill ? { filled: true } : {}), index: base + k }; });
631
633
  note.transcript = tr.concat(added.map(({ index, ...x }) => x));
632
634
  note.updated_at = iso(now);
633
635
  store(dir, note);
@@ -396,16 +396,55 @@ function vocabFor(ctx, id) {
396
396
  /* ── local transcription: one transcriber for the process ─────────────────────────────────────── */
397
397
  /* THE LIVE ENGINE (Run 10). Qwen3-ASR when it is set up (lib/notes-qwen.js: more accurate, Chinese and Indonesian too, kept
398
398
  * loaded so each cut is quick), else whisper.cpp. ctx.notesQwenDetect and ctx.notesQwenRun replace them in the suites. */
399
+ /* RECOVERY (notes-transcript-recovery). When Qwen3-ASR fails QWEN_FAILS cuts in a row (it stopped, timed out, or the machine
400
+ * is short of memory), the live transcript goes on with whisper.cpp for QWEN_REST_MS when whisper.cpp is set up, and then tries
401
+ * Qwen3-ASR again. Without whisper.cpp, Qwen3-ASR is started again on the next cut, as before. */
402
+ const QWEN_FAILS = 3;
403
+ const QWEN_REST_MS = 5 * 60 * 1000;
404
+ let qwenFails = 0; let qwenRestUntil = 0;
399
405
  function qwenDetect(ctx) { return ctx.notesQwenDetect ? ctx.notesQwenDetect() : notesQwen.detect(ctx.runtimeDir); }
406
+ function whisperDetect(ctx) { return ctx.notesWhisperDetect ? ctx.notesWhisperDetect() : whisper.detect(ctx.runtimeDir); }
400
407
  function liveDetect(ctx) {
401
408
  const q = qwenDetect(ctx);
409
+ if (q.ready && Date.now() < qwenRestUntil) { const w = whisperDetect(ctx); if (w.ready) return { ...w, engine: 'whisper' }; }
402
410
  if (q.ready) return { ready: true, engine: 'qwen', model: q.live, bin: null };
403
- return { ...whisper.detect(ctx.runtimeDir), engine: 'whisper' };
411
+ return { ...whisperDetect(ctx), engine: 'whisper' };
404
412
  }
405
- function liveRun(ctx, args) {
406
- if (args.engine !== 'qwen') return whisper.runWhisper(args);
407
- if (ctx.notesQwenRun) return ctx.notesQwenRun(args);
408
- return notesQwen.runQwen(notesQwen.workerFor(ctx.runtimeDir), args);
413
+ async function liveRun(ctx, args) {
414
+ if (args.engine !== 'qwen') return ctx.notesWhisperRun ? ctx.notesWhisperRun(args) : whisper.runWhisper(args);
415
+ const r = await (ctx.notesQwenRun ? ctx.notesQwenRun(args) : notesQwen.runQwen(notesQwen.workerFor(ctx.runtimeDir), args));
416
+ if (r && r.ok) qwenFails = 0;
417
+ else if (++qwenFails >= QWEN_FAILS) { qwenFails = 0; qwenRestUntil = Date.now() + QWEN_REST_MS; }
418
+ return r;
419
+ }
420
+ /* GAPS (notes-transcript-recovery). A cut the transcriber skipped or could not transcribe is kept here as a stretch of the
421
+ * meeting clock; when the transcriber has caught up, the next audio chunk of the note hands the oldest stretch back from the
422
+ * kept audio (transcriber.fill), FILL_PIECE_MS at a time, at most FILL_TRIES times. The lines land in the transcript at their
423
+ * own time, marked filled. What still fails is covered by the final pass after Stop, which reads the whole kept audio. */
424
+ const FILL_PIECE_MS = 25000;
425
+ const FILL_TRIES = 3;
426
+ const MAX_GAPS = 200;
427
+ const gaps = new Map(); // note id → [{ source, t, ms, tries }], oldest first
428
+ function addGap(c) {
429
+ if (!c || !c.id || !(c.ms > 0) || (c.tries || 0) >= FILL_TRIES) return;
430
+ const xs = gaps.get(c.id) || [];
431
+ const last = xs.length ? xs[xs.length - 1] : null;
432
+ // a stretch straight after the last one of its source, at the same try, is the same gap
433
+ if (last && last.source === c.source && last.tries === (c.tries || 0) && Math.abs(last.t + last.ms - c.t) <= 1500) last.ms = c.t + c.ms - last.t;
434
+ else xs.push({ source: c.source, t: c.t, ms: c.ms, tries: c.tries || 0 });
435
+ if (xs.length > MAX_GAPS) xs.shift();
436
+ gaps.set(c.id, xs);
437
+ }
438
+ function fillGaps(ctx, id, tr) {
439
+ const xs = gaps.get(id);
440
+ if (!xs || !xs.length || !tr.fill) return;
441
+ const g = xs[0];
442
+ const ms = Math.min(g.ms, FILL_PIECE_MS);
443
+ const from = Math.round(g.t * whisper.RATE / 1000); const to = Math.round((g.t + ms) * whisper.RATE / 1000);
444
+ const back = notesAudio.readSource(ctx.runtimeDir, id, g.source, from, to);
445
+ if (back && back.pcm.length && !tr.fill({ id, source: g.source, pcm: back.pcm, t: (back.from / whisper.RATE) * 1000, tries: g.tries })) return;
446
+ if (g.ms - ms > 500) { g.t += ms; g.ms -= ms; } else xs.shift();
447
+ if (!xs.length) gaps.delete(id);
409
448
  }
410
449
  let transcriber = null; let transcriberDir = null;
411
450
  const audioErrors = new Map(); // note id → the last thing that went wrong, for the page
@@ -433,10 +472,11 @@ function transcriberFor(ctx) {
433
472
  return null;
434
473
  },
435
474
  onText: async (c) => {
436
- const r = notes.appendTranscript(ctx.runtimeDir, { id: c.id, text: c.text, source: c.source, t: c.t, ms: c.ms, heard_as: c.heard_as });
475
+ const r = notes.appendTranscript(ctx.runtimeDir, { id: c.id, text: c.text, source: c.source, t: c.t, ms: c.ms, heard_as: c.heard_as, fill: c.fill === true });
437
476
  if (r.ok) { audioErrors.delete(c.id); arm(ctx, c.id); }
438
477
  },
439
478
  onError: (c) => { audioErrors.set(c.id, { at: new Date().toISOString(), error: c.error }); },
479
+ onSkip: (c) => addGap(c),
440
480
  // how far the live transcription has cut each source, kept with the capture so a restart picks up what it had buffered
441
481
  onCut: (c) => { try { notesCapture.setCut(ctx.runtimeDir, c.id, { source: c.source, sample: Math.round(c.until * whisper.RATE / 1000) }); } catch { /* best effort */ } },
442
482
  });
@@ -501,11 +541,14 @@ function finalInfo(ctx) {
501
541
  const d = ctx.notesFinalDetect ? ctx.notesFinalDetect() : notesFinal.detect(ctx.runtimeDir);
502
542
  return { ready: !!d.ready && !finalOff(ctx), transcriber: d.transcriber || null, vad: !!d.vad, speakers: !!d.diarize, missing: d.missing || [], setup: d.setup || '' };
503
543
  }
504
- /** Queue the final pass of a note when it can run. → { queued, reason } */
505
- function queueFinal(ctx, id) {
544
+ /** Queue the final pass of a note when it can run. A pass already queued or running in this process is kept, unless `force`
545
+ * (the PM asks for it again). → { queued, reason } */
546
+ function queueFinal(ctx, id, { force = false } = {}) {
506
547
  const dir = ctx.runtimeDir;
507
548
  const cur = notes.read(dir, id);
508
549
  if (!cur.ok || cur.note.private) return { queued: false, reason: 'this note is marked private' };
550
+ const now = !force && finalRunner && finalRunner.state(id);
551
+ if (now && (now.state === 'queued' || now.state === 'running')) return { queued: true, reason: '' };
509
552
  if (finalOff(ctx)) return { queued: false, reason: 'the final pass is switched off on this machine' };
510
553
  const info = finalInfo(ctx);
511
554
  if (!info.ready) return { queued: false, reason: 'local transcription is not set up' };
@@ -516,6 +559,30 @@ function queueFinal(ctx, id) {
516
559
  return { queued: true, reason: '' };
517
560
  }
518
561
  function cancelFinal(ctx, id) { if (finalRunner) finalRunner.cancel(id); }
562
+ /* STOP WRITES THE NOTES (notes-transcript-recovery). The page used to ask for the final pass after Stop (summarize with
563
+ * prefer 'agent'), and a Stop that did not come from the page that listened (the recording tab after Pause, the Viewer, a phone)
564
+ * never asked, so the notes were written from the live transcript alone, and a live transcript with gaps gave notes with gaps.
565
+ * Stop now queues the final pass itself: the whole kept audio is transcribed again, and the agent writes the notes from that.
566
+ * Without an engine or audio, the agent writes them from the live transcript at once. A later summarize from the page finds
567
+ * the pass queued (queueFinal keeps it) or the agent already asked (agentAsked), and starts nothing twice. */
568
+ function agentAsked(note) {
569
+ const a = note && note.agent;
570
+ if (!a || !a.started || a.imported_at) return false;
571
+ const asked = Date.parse(a.requested_at) || 0; const ended = Date.parse(note.ended_at) || 0;
572
+ return asked >= ended - 1000;
573
+ }
574
+ function finishAfterStop(ctx, id, ws) {
575
+ const dir = ctx.runtimeDir;
576
+ const cur = notes.read(dir, id);
577
+ if (!cur.ok || cur.note.private) return;
578
+ const q = queueFinal(ctx, id);
579
+ if (q.queued) return;
580
+ const n = cur.note;
581
+ if (!(n.transcript || []).length && !String(n.body || '').trim()) return;
582
+ if (agentAsked(n)) return;
583
+ const w = ws && ws.ok && ws.w ? ws.w : (n.ws ? ctx.getWs(n.ws) : null);
584
+ startAgent(ctx, dir, id, w && (!n.ws || w.id === n.ws) ? w : null);
585
+ }
519
586
 
520
587
  const WISPR_DELAY_MS = 5 * 60 * 1000;
521
588
  const WISPR_RETRY_MS = 2 * 60 * 1000;
@@ -627,7 +694,11 @@ function mergeWispr(ctx, id) {
627
694
  * reason, and the agent writes the notes from the live transcript, as Stop does without an engine;
628
695
  * - a summary run that was started, wrote nothing and is no longer a session is started again;
629
696
  * - a Wispr Flow check that was waiting or asking carries on from its own clock, or ends as failed once its deadline
630
- * after Stop is past (the PM can press Fetch to try again). */
697
+ * after Stop is past (the PM can press Fetch to try again);
698
+ * - a meeting that ended in the last BACKFILL_MS with no final pass at all (its Stop never asked for one) gets it now, from
699
+ * its kept audio, at most BACKFILL_MAX of them; the agent then writes its notes again from the whole meeting. */
700
+ const BACKFILL_MS = 14 * 24 * 60 * 60 * 1000;
701
+ const BACKFILL_MAX = 10;
631
702
  let resumedFor = null;
632
703
  function resumeStuck(ctx) {
633
704
  const dir = ctx.runtimeDir;
@@ -643,6 +714,7 @@ function resumeStuck(ctx) {
643
714
  return live;
644
715
  };
645
716
  const wsFor = (n) => { const w = n.ws ? ctx.getWs(n.ws) : null; return w && w.id === n.ws ? w : null; };
717
+ let backfill = BACKFILL_MAX;
646
718
  for (const row of l.notes) {
647
719
  const cur = notes.read(dir, row.id);
648
720
  if (!cur.ok || cur.note.private || listening(cur.note)) continue;
@@ -657,6 +729,11 @@ function resumeStuck(ctx) {
657
729
  if (!a || (!a.imported_at && !a.started)) { startAgent(ctx, dir, n.id, wsFor(n)); done.push({ id: n.id, final: 'failed', agent: 'started' }); }
658
730
  else done.push({ id: n.id, final: 'failed' });
659
731
  }
732
+ } else if (!fst && backfill > 0 && n.ended_at && Date.now() - (Date.parse(n.ended_at) || 0) <= BACKFILL_MS && n.recorded_from
733
+ && !(n.final && (n.final.segments || []).length) && !(finalRunner && finalRunner.state(n.id))) {
734
+ // ended without a final pass (a Stop that did not ask for it, before notes-transcript-recovery): it runs now, from the kept audio
735
+ const q = queueFinal(ctx, n.id);
736
+ if (q.queued) { backfill--; done.push({ id: n.id, final: 'queued', backfill: true }); }
660
737
  } else if (n.agent && n.agent.started && !n.agent.imported_at && !(n.agent.out && fs.existsSync(n.agent.out)) && n.agent.session && !liveIds().has(n.agent.session)) {
661
738
  startAgent(ctx, dir, n.id, wsFor(n));
662
739
  done.push({ id: n.id, agent: 'started' });
@@ -845,7 +922,7 @@ async function handle(req, res, url, ctx) {
845
922
  if (p === '/api/notes/stop') {
846
923
  const r = notes.stop(dir, { id, resumeMs: resumeMsOf(ctx) });
847
924
  notesCapture.close(dir, id);
848
- if (r.ok) { clearExpiry(id); swept.add(id); disarm(id); runMinute(ctx, id, { final: true }); scheduleWispr(ctx, id); }
925
+ if (r.ok) { clearExpiry(id); swept.add(id); disarm(id); runMinute(ctx, id, { final: true }); scheduleWispr(ctx, id); gaps.delete(id); finishAfterStop(ctx, id, wsOf()); }
849
926
  return done(r);
850
927
  }
851
928
  if (p === '/api/notes/transcript') {
@@ -905,6 +982,8 @@ async function handle(req, res, url, ctx) {
905
982
  }
906
983
  const pushed = tr.push({ id, source, pcm, t, final: body.final === true, exact: !!cap });
907
984
  if (cap) notesCapture.mark(dir, id, { source, seq: body.seq, end: sample + pcm.length / 2 });
985
+ // the transcriber has caught up: a stretch it skipped earlier is read back from the kept audio and transcribed now
986
+ if (gaps.has(id) && tr.pending() < whisper.FILL_ROOM) fillGaps(ctx, id, tr);
908
987
  return done(pushed);
909
988
  }
910
989
  if (p === '/api/notes/label') return done(notes.setLabel(dir, { id, index: Number(body.index), cat: body.cat, drop: body.drop === true }));
@@ -915,7 +994,7 @@ async function handle(req, res, url, ctx) {
915
994
  if (p === '/api/notes/final') {
916
995
  // the PM asks for the final pass again, for example after setting up a better engine
917
996
  if (!notes.read(dir, id).ok) return done(notes.read(dir, id));
918
- const q = queueFinal(ctx, id);
997
+ const q = queueFinal(ctx, id, { force: true });
919
998
  return done(q.queued ? { ok: true, queued: true } : { ok: false, status: 409, error: q.reason });
920
999
  }
921
1000
  if (p === '/api/notes/bullet') return done(notes.editBullet(dir, { id, bid: body.bullet, cat: body.cat, drop: body.drop, text: body.text, owner: body.owner, due: body.due }));
@@ -1023,7 +1102,7 @@ async function handle(req, res, url, ctx) {
1023
1102
  if (p === '/api/notes/private') {
1024
1103
  vocabCache.delete(id);
1025
1104
  const r = notes.setPrivate(dir, { id, private: body.private });
1026
- if (r.ok && r.private) { clearExpiry(id); disarm(id); unwatchLate(id); cancelFinal(ctx, id); unwatchWispr(id); if (transcriber) transcriber.drop(id); notesAudio.remove(dir, id); notesCapture.remove(dir, id); notesScreen.remove(dir, id); }
1105
+ if (r.ok && r.private) { gaps.delete(id); clearExpiry(id); disarm(id); unwatchLate(id); cancelFinal(ctx, id); unwatchWispr(id); if (transcriber) transcriber.drop(id); notesAudio.remove(dir, id); notesCapture.remove(dir, id); notesScreen.remove(dir, id); }
1027
1106
  return done(r);
1028
1107
  }
1029
1108
  if (p === '/api/notes/summarize') {
@@ -1045,6 +1124,8 @@ async function handle(req, res, url, ctx) {
1045
1124
  // with kept audio and an engine, the final pass runs first and the agent writes the notes from it (Run 9)
1046
1125
  const q = cur.ok && !cur.note.private ? queueFinal(ctx, id) : { queued: false };
1047
1126
  if (q.queued) { r.final = { state: 'queued' }; r.agent = { started: false, waiting: 'final', reason: '' }; r.source = 'agent'; return done(r); }
1127
+ // Stop already asked the agent (finishAfterStop): the same run is answered, not a second one started
1128
+ if (cur.ok && agentAsked(cur.note)) { const a = cur.note.agent; r.agent = { started: true, session: a.session || null, withheld: a.withheld, out: a.out, reason: '' }; r.source = 'agent'; return done(r); }
1048
1129
  const ag = cur.ok && cur.note.private ? { ok: false, error: 'this note is marked private, so it is not handed to any agent or service' }
1049
1130
  : startAgent(ctx, dir, id, ws.ok ? ws.w : null);
1050
1131
  r.agent = ag.ok ? (({ ok, ...x }) => x)(ag) : { started: false, reason: ag.error || 'the agent could not be asked' };
@@ -1052,7 +1133,7 @@ async function handle(req, res, url, ctx) {
1052
1133
  }
1053
1134
  return done(r);
1054
1135
  }
1055
- if (p === '/api/notes/delete') { clearExpiry(id); swept.delete(id); disarm(id); unwatchLate(id); cancelFinal(ctx, id); unwatchWispr(id); if (transcriber) transcriber.drop(id); const r = notes.remove(dir, id); if (r.ok) { notesAudio.remove(dir, id); notesCapture.remove(dir, id); notesScreen.remove(dir, id); } return done(r); }
1136
+ if (p === '/api/notes/delete') { gaps.delete(id); clearExpiry(id); swept.delete(id); disarm(id); unwatchLate(id); cancelFinal(ctx, id); unwatchWispr(id); if (transcriber) transcriber.drop(id); const r = notes.remove(dir, id); if (r.ok) { notesAudio.remove(dir, id); notesCapture.remove(dir, id); notesScreen.remove(dir, id); } return done(r); }
1056
1137
  if (p === '/api/notes/highlight') {
1057
1138
  // the PM's highlight: the transcript of the window, then Jev's label and the repository check of its text
1058
1139
  const r = notes.addHighlight(dir, { id, from: body.from, to: body.to });
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.438.0",
3
+ "version": "0.439.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.438.0",
9
+ "version": "0.439.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@xterm/addon-fit": "^0.11.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.438.0",
3
+ "version": "0.439.0",
4
4
  "private": true,
5
5
  "description": "PMOS Terminal Workspace — local companion hosting real PTYs beside the library and gates (D62)",
6
6
  "license": "MIT",
@@ -133,7 +133,9 @@ export function transcriptModel(one, { max = 80 } = {}) {
133
133
  if (!n || n.private) return [];
134
134
  const names = n.speakers || {};
135
135
  const who = (src) => names[src] || { mic: 'You', meeting: 'Meeting', speech: 'You', typed: 'You (typed)' }[src] || 'You';
136
- const tr = (Array.isArray(n.transcript) ? n.transcript : []).filter((x) => x && !x.dropped && typeof x.text === 'string' && x.text.trim());
136
+ // in meeting-time order: a stretch filled in after the engine caught up is stored after the lines heard later
137
+ const tr = (Array.isArray(n.transcript) ? n.transcript : []).filter((x) => x && !x.dropped && typeof x.text === 'string' && x.text.trim())
138
+ .sort((a, b) => (Number.isFinite(a.t) ? a.t : 0) - (Number.isFinite(b.t) ? b.t : 0));
137
139
  const rows = tr.slice(-max).map((x) => ({ t: Number.isFinite(x.t) ? x.t : null, who: who(x.source), text: x.text.trim(), hl: false, dec: x.cat === 'decision', now: false }));
138
140
  for (const h of Array.isArray(n.highlights) ? n.highlights : []) {
139
141
  const ht = Number(h && (h.t != null ? h.t : h.from));
@@ -85,6 +85,7 @@ const norm = (t) => String(t || '').toLowerCase().replace(/\s+/g, ' ').trim();
85
85
  export const stepNorm = (s) => String(s == null ? '' : s).replace(/\s+/g, ' ').trim().slice(0, 400).toLowerCase().replace(/[^a-z0-9 ]+/g, ' ').replace(/\s+/g, ' ').trim();
86
86
 
87
87
  /** The transcript as lines with who said each, and the key that names a speaker: `source` for live lines, `key` for the final segments. */
88
+ const byTime = (xs) => xs.slice().sort((a, b) => (Number.isFinite(a.t) ? a.t : 0) - (Number.isFinite(b.t) ? b.t : 0));
88
89
  export function linesOf(n) {
89
90
  if (!n || n.private) return [];
90
91
  const sp = n.speakers || {}, DEF = { mic: 'You', meeting: 'Meeting', speech: 'You' };
@@ -92,7 +93,8 @@ export function linesOf(n) {
92
93
  const names = (n.final && n.final.speakers) || {};
93
94
  return n.final.segments.filter((g) => g && String(g.text || '').trim()).map((g) => ({ t: g.t, text: String(g.text), who: names[g.spk] || sp[g.spk] || DEF[g.spk] || String(g.spk || 'Speaker'), key: g.spk == null ? '' : String(g.spk), source: '' }));
94
95
  }
95
- return (n.transcript || []).filter((x) => x && x.text && !x.dropped).map((x) => ({ t: x.t, text: String(x.text), who: sp[x.source] || DEF[x.source] || 'You', key: '', source: x.source || 'mic' }));
96
+ // a stretch filled in after the engine caught up is stored after the lines heard later; the lines read in meeting-time order
97
+ return byTime((n.transcript || []).filter((x) => x && x.text && !x.dropped)).map((x) => ({ t: x.t, text: String(x.text), who: sp[x.source] || DEF[x.source] || 'You', key: '', source: x.source || 'mic' }));
96
98
  }
97
99
  /** The facts said in the meeting, as view-notes.js caught() reads them: a statement with a number, or one checked against a repository file. */
98
100
  export function factsOf(n) {
@@ -0,0 +1,9 @@
1
+ {
2
+ "_comment": "notes-transcript-recovery (Wawan, 2026-10-28): the live transcript fills the stretches it skipped, Qwen3-ASR failing hands over to whisper.cpp, Stop runs the final pass itself, and ended meetings with no final pass get one after a restart.",
3
+ "modules": [
4
+ "notes-transcript-recovery.test.js"
5
+ ],
6
+ "seconds": {
7
+ "notes-transcript-recovery.test.js": 3
8
+ }
9
+ }