create-pmos 0.411.0 → 0.412.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.
Files changed (63) hide show
  1. package/package.json +13 -13
  2. package/payload/KIT-VERSION +1 -1
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/workspace/briefing-premium-adddoc-test.js +1 -1
  7. package/workspace/briefing-premium-insights-test.js +2 -2
  8. package/workspace/briefing-premium-test.js +3 -3
  9. package/workspace/changelog.json +12 -0
  10. package/workspace/guide/board.md +1 -1
  11. package/workspace/guide/breakdown.md +6 -13
  12. package/workspace/guide/index.md +1 -1
  13. package/workspace/guide/initiative-driver.md +1 -1
  14. package/workspace/guide/initiatives-screen.md +1 -1
  15. package/workspace/guide/pm-only-acts.md +23 -24
  16. package/workspace/guide/today.md +1 -1
  17. package/workspace/lib/briefing-premium-writes.js +5 -4
  18. package/workspace/lib/coredoc-cli.js +1 -1
  19. package/workspace/lib/driver-cli.js +2 -1
  20. package/workspace/lib/driver-decide.js +3 -2
  21. package/workspace/lib/driver.js +2 -1
  22. package/workspace/lib/grant-mint.js +3 -2
  23. package/workspace/lib/initiative-cli.js +9 -9
  24. package/workspace/lib/issues.js +5 -4
  25. package/workspace/lib/people-store.js +1 -1
  26. package/workspace/lib/people.js +3 -1
  27. package/workspace/lib/placements.js +13 -15
  28. package/workspace/lib/plan-items.js +17 -48
  29. package/workspace/lib/pm-guard.js +18 -5
  30. package/workspace/lib/pm-lines-needs.js +9 -5
  31. package/workspace/lib/report-cli.js +2 -2
  32. package/workspace/lib/routes-board-metric-targets.js +0 -1
  33. package/workspace/lib/routes-briefing-premium.js +3 -5
  34. package/workspace/lib/routes-core-docs.js +0 -1
  35. package/workspace/lib/routes-custom-docs.js +0 -1
  36. package/workspace/lib/routes-driver.js +0 -1
  37. package/workspace/lib/routes-home-desk.js +1 -1
  38. package/workspace/lib/routes-home-review.js +1 -1
  39. package/workspace/lib/routes-initiative-layout.js +1 -1
  40. package/workspace/lib/routes-insights-records.js +0 -1
  41. package/workspace/lib/routes-meeting-material.js +0 -1
  42. package/workspace/lib/routes-onboarding.js +3 -1
  43. package/workspace/lib/routes-orchestrator.js +0 -1
  44. package/workspace/lib/routes-premium-charts.js +0 -1
  45. package/workspace/lib/routes-premium-dashboards.js +0 -1
  46. package/workspace/lib/routes-programs.js +1 -1
  47. package/workspace/lib/routes-records.js +1 -1
  48. package/workspace/lib/routes-report-design.js +7 -3
  49. package/workspace/lib/routes-report-setups.js +0 -1
  50. package/workspace/lib/routes-report-structure.js +0 -1
  51. package/workspace/lib/routes-runs.js +2 -5
  52. package/workspace/lib/routes-scan.js +0 -1
  53. package/workspace/lib/routes-sources.js +1 -1
  54. package/workspace/lib/run-answers.js +14 -5
  55. package/workspace/lib/scan-cli.js +2 -1
  56. package/workspace/lib/scan.js +2 -1
  57. package/workspace/lib/vendor/scripts/onboarding/proposals.js +7 -3
  58. package/workspace/package-lock.json +2 -2
  59. package/workspace/package.json +1 -1
  60. package/workspace/premium-core-doc-issue-test.js +1 -1
  61. package/workspace/premium-viewer-share-test.js +5 -2
  62. package/workspace/replaced-tests.json +101 -0
  63. package/workspace/server.js +8 -9
@@ -18,9 +18,10 @@
18
18
  * --json) the day-one derivation (R26) reads; `rules` is lib/plan-rules.js readRules(root). A consumer that needs a
19
19
  * horizon reads it through horizonOf, never from the file.
20
20
  *
21
- * The actor is never chosen by the caller of a route: the route takes it from pm-guard.js (Move to Now, adopt — PM
22
- * only) or actor.js (every other press); the CLI from actor.fromCli or requirePmCli. Only a PM line moves an initiative
23
- * into Now; an agent's line is a proposal (`proposed: true`), whatever horizon it names.
21
+ * The actor is never chosen by the caller of a route: the route takes it from pm-guard.js (Move to Now, adopt) or
22
+ * actor.js (every other press); the CLI from actor.fromCli or requirePmCli. D98: an agent's line applies like the PM's
23
+ * (Now and adopt included) and keeps the agent's `by`, so the PM sees who moved what and can move it back. The writer
24
+ * no longer writes `proposed: true`; such a line from before D98 stays a proposal until it is adopted or dropped.
24
25
  *
25
26
  * THE `placed` LINE (the shared contract; 2C may add events, never change this one):
26
27
  * { v: 1, eid, ev: 'placed', initiative, horizon: 'now'|'next'|'later', after: <initiative id> | null,
@@ -32,10 +33,10 @@
32
33
  * { ev: 'created', initiative, from?: 'capture-YYYY-MM-DD-<n>' } the initiative writer's landing line: top of
33
34
  * Later, so a new record never reads Now through day one (R16, R23: what an agent creates lands in Later).
34
35
  * Any actor; only for an initiative with no line yet. `from` names the capture it came from (triage reads it).
35
- * { ev: 'adopted', proposal: <eid> } the PM keeps an agent's proposal: its placement applies as the PM's.
36
- * { ev: 'dropped', proposal: <eid> } the proposal is closed unapplied (the PM, or the agent that proposed it).
37
- * pmOnly(rec) → true for a line only the PM may write: a non-proposed `placed` into Now, and `adopted`. The checker
38
- * (scripts/check-pm-lines.js, 2B) asks this function and never reads the schema itself.
36
+ * { ev: 'adopted', proposal: <eid> } the PM or an agent keeps an open proposal: its placement applies.
37
+ * { ev: 'dropped', proposal: <eid> } the proposal is closed unapplied (the PM or any agent, D98).
38
+ * pmOnly(rec) → true for a line that was PM-only before D98: a non-proposed `placed` into Now, and `adopted`. The
39
+ * checker (scripts/check-pm-lines.js, 2B) asks this function and never reads the schema itself.
39
40
  *
40
41
  * DAY ONE (R26), with no migration. An initiative of a work lane with no line in the ledger is placed by its activity:
41
42
  * active within `stall_days` reads Now, unconfirmed (`confirmed: false`, `source: 'day-one'`, outside any cap); every
@@ -54,9 +55,8 @@
54
55
  * once, lines apply in (at, eid) order, and one eid with two contents keeps the first and flags the second. A later
55
56
  * PM `placed` line for an initiative closes that initiative's open proposals (they are superseded, not adopted).
56
57
  *
57
- * HONEST LIMIT. The fold tells an agent's line by its `by`. An agent `placed` line without `proposed` is a line the
58
- * writer never writes: the fold reads it as a proposal and flags it (`agent-not-proposed`); an `adopted` line by an
59
- * agent is ignored and flagged. A forged `pm:` line is caught only by scripts/check-pm-lines.js (2B), not here.
58
+ * HONEST LIMIT. The fold tells an agent's line by its `by`, and since D98 applies it either way; the `by` is the
59
+ * record of who acted. A forged `pm:` line is caught only by scripts/check-pm-lines.js (2B), not here.
60
60
  *
61
61
  * The ledger is one per repository: lib/plan-ledgers.js ledgerPath(root, 'placements'). Nothing is cached (D33).
62
62
  */
@@ -97,7 +97,9 @@ const ALPHABET = '0123456789abcdefghijklmnopqrstuvwxyz';
97
97
 
98
98
  const isStr = (v) => typeof v === 'string';
99
99
  const has = (o, k) => Object.prototype.hasOwnProperty.call(o, k);
100
- const isPmBy = (by) => isStr(by) && by.startsWith('pm:');
100
+ // D98: a line by the PM or an agent session takes effect (placed, adopted, dropped); the line keeps who wrote it.
101
+ // A line marked `proposed` (written before D98) is still a proposal until someone adopts or drops it.
102
+ const isPmBy = (by) => isStr(by) && (by.startsWith('pm:') || by.startsWith('agent:'));
101
103
  const dateOk = (v) => isStr(v) && DATE_RE.test(v) && !Number.isNaN(Date.parse(v + 'T00:00:00Z'))
102
104
  && new Date(v + 'T00:00:00Z').toISOString().slice(0, 10) === v;
103
105
 
@@ -355,7 +357,6 @@ function buildRecord(root, ev, i, actor, state) {
355
357
  if (!has(CALLER_KEYS, ev.ev)) return refuse(400, `ev must be one of ${EVENTS.join(', ')}`, i);
356
358
  const extra = Object.keys(ev).filter((k) => k !== 'ev' && !CALLER_KEYS[ev.ev].includes(k));
357
359
  if (extra.length) return refuse(400, `a ${ev.ev} line has no field ${extra.join(', ')}`, i);
358
- const agent = !actorLib.isPm(actor);
359
360
  const rec = { ev: ev.ev };
360
361
  if (ev.ev === 'placed' || ev.ev === 'created') {
361
362
  if (!isStr(ev.initiative) || !INIT_RE.test(ev.initiative)) return refuse(400, 'initiative must be an initiative id', i);
@@ -373,7 +374,6 @@ function buildRecord(root, ev, i, actor, state) {
373
374
  if (ev.check_by !== null && !dateOk(ev.check_by)) return refuse(400, 'check_by must be YYYY-MM-DD, or null to clear it', i);
374
375
  rec.check_by = ev.check_by;
375
376
  }
376
- if (agent) rec.proposed = true; // an agent's placement is a proposal, whatever it names (R23)
377
377
  } else if (ev.ev === 'created') {
378
378
  if (has(ev, 'from')) {
379
379
  if (!(isStr(ev.from) && CAPTURE_RE.test(ev.from))) return refuse(400, 'from must name a capture note, like capture-2026-10-04-1', i);
@@ -384,8 +384,6 @@ function buildRecord(root, ev, i, actor, state) {
384
384
  if (!isStr(ev.proposal) || !EID_RE.test(ev.proposal)) return refuse(400, 'proposal must be the eid of a proposal', i);
385
385
  const p = state.open.get(ev.proposal);
386
386
  if (!p) return refuse(404, `${ev.proposal} is not an open proposal`, i);
387
- if (ev.ev === 'adopted' && agent) return refuse(403, 'only the PM adopts a proposal', i);
388
- if (ev.ev === 'dropped' && agent && actor.by !== p.by) return refuse(403, 'an agent drops only its own proposal', i);
389
387
  rec.proposal = ev.proposal;
390
388
  }
391
389
  return { ok: true, rec };
@@ -16,11 +16,10 @@
16
16
  *
17
17
  * WHO IS WHO COMES FROM lib/actor.js (Run 2, slice 2A). The server route runs lib/pm-guard.js first (Origin, the
18
18
  * per-launch nonce, writer fields; act `keep` when the call carries a Keep) and passes the guard's actor on;
19
- * `pmos item` takes actor.fromCli. R23 (X35): an agent does not change the PM's items. A set or a flag by an agent on
20
- * an item whose owner is `you` is refused with 403, and so is a withdraw of an item it did not plan; the agent asks the
21
- * PM instead. A move of one of the PM's items is open only to the session the PM handed that item to (Hand to agent:
22
- * the session meta's `plan_item`, read through actor.sessionForToken), so it can take it through Doing to Done with
23
- * evidence (R23 "finishes"). Item-change proposals are not built (deferred, named in the run PR).
19
+ * `pmos item` takes actor.fromCli. D98 (amends R23): an agent finishes the work it was asked to do. Its items are live
20
+ * at once (never proposed, so there is nothing to Keep), and it may set, flag, move and withdraw any item, the PM's
21
+ * included. Every line keeps the agent's own `by`, so the PM sees who acted and can move or withdraw it back. Keep
22
+ * lines written before D98 name items that are already live; the fold skips them silently.
24
23
  *
25
24
  * HONEST LIMIT (rubric anti-optimism). A process that runs as the PM's own user can still read the nonce from the
26
25
  * page, or fake a terminal with no PMOS_SESSION, and be recorded as the PM. The fold flags a `kept` line whose `via`
@@ -36,7 +35,6 @@ const { createSinkGuard } = require('./sink.js');
36
35
  const planTree = require('./plan-tree.js');
37
36
  const consoleState = require('./console-state');
38
37
  const actorLib = require('./actor.js');
39
- const stateRoot = require('./state-root');
40
38
 
41
39
  const LEDGER = 'plan-items.jsonl';
42
40
  const EVENTS = ['planned', 'set', 'moved', 'flagged', 'withdrawn', 'kept'];
@@ -268,7 +266,7 @@ function freshItem(rec) {
268
266
  after: rec.after.slice(), start: rec.start, due: rec.due, milestone: rec.milestone, note: rec.note == null ? '' : rec.note,
269
267
  state: 'todo', blocked: null, evidence: null, noEvidence: false, doneAt: null,
270
268
  movedBy: null, movedVia: null, override: false, overrideShown: false,
271
- proposed: rec.by.startsWith('agent:'), kept: false,
269
+ proposed: false, kept: false, // D98: an agent's item is live at once; nothing waits for a Keep
272
270
  createdBy: rec.by, createdVia: rec.via, createdAt: rec.at,
273
271
  updatedBy: rec.by, updatedVia: rec.via, updatedAt: rec.at,
274
272
  history: [],
@@ -303,9 +301,10 @@ function applyLine(S, rec, n) {
303
301
  }
304
302
  if (rec.ev === 'kept') {
305
303
  if (rec.via !== 'ui') { flag(S, 'kept-not-ui', rec, n, `a Keep line was written with via "${rec.via}", not from the workspace page — it has no effect`); return; }
306
- if (!rec.by.startsWith('pm:')) { flag(S, 'kept-not-pm', rec, n, `a Keep line was written by ${rec.by}, not the PM — it has no effect`); return; }
307
304
  for (const id of rec.items) {
308
305
  const it = S.items.get(id);
306
+ // A Keep written before D98: the item is already live (agent items are no longer proposed), so it needs nothing.
307
+ if (it && !it.proposed && it.createdBy === rec.batch && it.initiative === rec.initiative) continue;
309
308
  if (!it || !it.proposed || it.createdBy !== rec.batch || it.initiative !== rec.initiative) {
310
309
  S.flags.push({ kind: 'kept-mismatch', line: n == null ? null : n, eid: rec.eid, item: id, initiative: rec.initiative,
311
310
  message: `${id} is not a proposed item of ${rec.batch} on ${rec.initiative} — this part of the Keep has no effect` });
@@ -482,8 +481,6 @@ function actorFromCli(opts = {}) {
482
481
 
483
482
  // ── the writer ────────────────────────────────────────────────────────────────────────────────────
484
483
  const refuse = (status, error, index) => ({ ok: false, status, error, index: index == null ? null : index });
485
- const PM_ITEM_HINT = 'this item is the PM\'s (owner you) — an agent does not change it; ask the PM';
486
- const PM_MOVE_HINT = 'this item is the PM\'s (owner you) and the PM did not hand it to this session — ask the PM to hand it to you';
487
484
 
488
485
  /** Does adding `from → each of after` make a loop in the predecessor graph of `items`? */
489
486
  function makesLoop(items, from, after) {
@@ -505,7 +502,7 @@ function makesLoop(items, from, after) {
505
502
  * The record's keys are emitted common-first, then the payload, in the order of the plan's §1.2.
506
503
  */
507
504
  function buildRecord(ctx, ev, index) {
508
- const { S, actor, allowKept, root, stagesCache, nextAt, handedTo } = ctx;
505
+ const { S, actor, allowKept, root, stagesCache, nextAt } = ctx;
509
506
  if (!ev || typeof ev !== 'object' || Array.isArray(ev)) return refuse(400, 'each line must be an object', index);
510
507
  for (const k of WRITER_FIELDS) if (k in ev) return refuse(400, `field ${k} is set by the writer`, index);
511
508
  if (!EVENTS.includes(ev.ev)) return refuse(400, `unknown event ${JSON.stringify(ev.ev)} — one of ${EVENTS.join(', ')}`, index);
@@ -529,8 +526,6 @@ function buildRecord(ctx, ev, index) {
529
526
  Object.assign(rec, { initiative, by: actor.by, via: actor.via, at: nextAt(floor) });
530
527
  return rec;
531
528
  };
532
- // R23 (X35): the PM's items (owner `you`) are the PM's to change. An agent asks; it does not set or flag them.
533
- const agentOnPmItem = (it) => actor.by.startsWith('agent:') && it.owner === 'you';
534
529
  const stagesOf = (initiative) => {
535
530
  if (!stagesCache.has(initiative)) stagesCache.set(initiative, planTree.stagesFor(root, initiative));
536
531
  return stagesCache.get(initiative);
@@ -603,7 +598,6 @@ function buildRecord(ctx, ev, index) {
603
598
  case 'set': {
604
599
  const ex = existing(); if (ex.ok === false) return ex;
605
600
  const { it, init } = ex;
606
- if (agentOnPmItem(it)) return refuse(403, PM_ITEM_HINT, index);
607
601
  const f = ev.fields;
608
602
  if (!f || typeof f !== 'object' || Array.isArray(f) || !Object.keys(f).length) return refuse(400, 'fields must name at least one of ' + SET_FIELDS.join(', '), index);
609
603
  const out = {};
@@ -629,7 +623,6 @@ function buildRecord(ctx, ev, index) {
629
623
  const ex = existing(); if (ex.ok === false) return ex;
630
624
  const { it, init } = ex;
631
625
  if (!STATES.includes(ev.to)) return refuse(400, `to must be one of ${STATES.join(', ')}`, index);
632
- if (agentOnPmItem(it) && !handedTo(it.id)) return refuse(403, PM_MOVE_HINT, index);
633
626
  /* done → done with evidence attaches it to an item that reads Done without evidence: the way to correct an agent
634
627
  * Done that forgot --evidence, from the CLI or the item sheet. Any other same-state move is refused. */
635
628
  const attach = ev.to === 'done' && it.state === 'done' && ev.evidence != null && (it.noEvidence || !it.evidence);
@@ -652,7 +645,6 @@ function buildRecord(ctx, ev, index) {
652
645
  case 'flagged': {
653
646
  const ex = existing(); if (ex.ok === false) return ex;
654
647
  const { it, init } = ex;
655
- if (agentOnPmItem(it)) return refuse(403, PM_ITEM_HINT, index);
656
648
  if (ev.blocked === true) {
657
649
  if (!oneLine(ev.reason, 200)) return refuse(400, 'a block reason is 1 to 200 characters on one line', index);
658
650
  const rec = common(init, it.id, it.updatedAt);
@@ -670,11 +662,7 @@ function buildRecord(ctx, ev, index) {
670
662
  }
671
663
  case 'withdrawn': {
672
664
  const ex = existing(); if (ex.ok === false) return ex;
673
- /* Withdraw is terminal (the fold has no un-withdraw), so an agent withdraws only what it planned itself (R23).
674
- * The PM's items, and another session's, are the PM's to withdraw. */
675
- if (actor.by.startsWith('agent:') && ex.it.createdBy !== actor.by) {
676
- return refuse(403, 'an agent withdraws only the items it planned — the PM withdraws the rest', index);
677
- }
665
+ // D98: any actor withdraws any item; the line names who did it.
678
666
  return { rec: common(ex.init, ex.it.id, ex.it.updatedAt) };
679
667
  }
680
668
  case 'kept': {
@@ -714,7 +702,7 @@ function parseEvidence(s) {
714
702
  return { kind: m[1], ref: m[2] };
715
703
  }
716
704
 
717
- function append(root, events, actor, { now, allowKept, handedTo = () => false }) {
705
+ function append(root, events, actor, { now, allowKept }) {
718
706
  if (!Array.isArray(events) || !events.length) return refuse(400, 'send at least one line', null);
719
707
  if (events.length > MAX_LINES) return refuse(413, `send at most ${MAX_LINES} lines at once`, null);
720
708
  let read;
@@ -744,7 +732,7 @@ function append(root, events, actor, { now, allowKept, handedTo = () => false })
744
732
  last = t;
745
733
  return new Date(t).toISOString();
746
734
  };
747
- const ctx = { S, actor, allowKept, root, stagesCache: new Map(), nextAt, handedTo };
735
+ const ctx = { S, actor, allowKept, root, stagesCache: new Map(), nextAt };
748
736
  const recs = [];
749
737
  for (let i = 0; i < events.length; i++) {
750
738
  let r;
@@ -772,37 +760,20 @@ function append(root, events, actor, { now, allowKept, handedTo = () => false })
772
760
 
773
761
  /**
774
762
  * The workspace page's route. The only path that accepts `kept`. The route passes the actor lib/pm-guard.js answered;
775
- * with none, actor.fromUi(). Either way it must be the PM via `ui`: anything else is refused, not rewritten.
763
+ * with none, actor.fromUi(). D98: an agent session's call through the route keeps its own `by`; the line says `ui`.
776
764
  */
777
765
  function appendFromUi(root, events, { now, actor } = {}) {
778
766
  const who = actor === undefined ? actorLib.fromUi() : actor;
779
- if (!actorLib.isPm(who) || who.via !== 'ui') return refuse(403, 'the page writes only as the PM, after the guard', null);
767
+ if (!actorLib.valid(who)) return refuse(403, 'the page writes only after the guard', null);
780
768
  return append(root, events, { by: who.by, via: 'ui' }, { now, allowKept: true });
781
769
  }
782
770
  /** `pmos item`. The actor comes from the terminal and PMOS_SESSION, never from an argument. Refuses `kept`. */
783
- function appendFromCli(root, events, { now, isTTY, env, sessDir } = {}) {
771
+ function appendFromCli(root, events, { now, isTTY, env } = {}) {
784
772
  const opts = {};
785
773
  if (isTTY !== undefined) opts.isTTY = isTTY;
786
774
  if (env !== undefined) opts.env = env;
787
775
  const who = actorFromCli(opts);
788
- return append(root, events, who, { now, allowKept: false, handedTo: handedToSession(who, env, sessDir) });
789
- }
790
- /**
791
- * itemId → true when the PM handed that item to the actor's session (R23). The session meta lives in the workspace's
792
- * runtime state (`<state root>/sessions`), resolved from the environment the way the server resolves it; a test passes
793
- * `sessDir`. The meta is read at most once per call.
794
- */
795
- function handedToSession(who, env, sessDir) {
796
- const token = actorLib.sessionOf(who);
797
- if (!token) return () => false;
798
- let s;
799
- return (itemId) => {
800
- if (s === undefined) {
801
- const dir = sessDir || path.join(stateRoot.defaultRoot({ env: env || process.env }), 'sessions');
802
- s = actorLib.sessionForToken(token, { sessDir: dir });
803
- }
804
- return !!s && s.plan_item === itemId;
805
- };
776
+ return append(root, events, who, { now, allowKept: false });
806
777
  }
807
778
 
808
779
  // ── needs-you rows (Keep cards, agent Done with no evidence, forged Keep lines) ─────────────────────
@@ -823,11 +794,9 @@ function needsFor(root, { now } = {}) {
823
794
  question: `"${it.title}" reads Done with no evidence`, doc: null, item: id });
824
795
  }
825
796
  for (const f of r.flags) {
826
- if (f.kind !== 'kept-not-ui' && f.kind !== 'kept-not-pm') continue;
797
+ if (f.kind !== 'kept-not-ui') continue;
827
798
  rows.push({ run_id: `plan-flag:${f.eid}`, initiative_id: f.initiative, kind: 'plan-flag', derived: true,
828
- question: f.kind === 'kept-not-ui'
829
- ? 'A Keep line in plan-items.jsonl was not written from the workspace page. It has no effect.'
830
- : 'A Keep line in plan-items.jsonl was not written by the PM. It has no effect.',
799
+ question: 'A Keep line in plan-items.jsonl was not written from the workspace page. It has no effect.',
831
800
  doc: null, flag: { kind: f.kind, eid: f.eid, line: f.line } });
832
801
  }
833
802
  return rows;
@@ -1,6 +1,11 @@
1
1
  'use strict';
2
- /* pm-guard.js — THE GUARDED WRITER'S FRONT DOOR: every act only the PM may take passes here first (pm-os-absorb, PRD
3
- * R25, D86 point 2).
2
+ /* pm-guard.js — THE GUARDED WRITER'S FRONT DOOR: every act that was PM-only passes here first (pm-os-absorb, PRD
3
+ * R25, D86 point 2, amended by D98).
4
+ *
5
+ * D98: an agent session finishes the work it was asked to do. It may take every act below without a typed
6
+ * confirmation, and the guard answers with the agent's own actor, so every line it writes says `by: agent:…` and the PM
7
+ * sees who acted and can return or undo it. What stays: the Origin and launch-nonce checks (another website cannot
8
+ * write), the writer fields, and the PM's own typed confirmation at a terminal.
4
9
  *
5
10
  * requirePmPress(req, body, { act }) → { ok: true, actor } | { ok: false, status, error }
6
11
  * requirePmCli({ act, expect, isTTY, env, ask }) → Promise of the same shape
@@ -33,8 +38,10 @@
33
38
  * another port, so another launch): 403. A socket request with no Host header is refused too, because there is
34
39
  * nothing to match. Only a caller with no socket and no Host (a unit test's plain object) skips the Host match;
35
40
  * - once server.js has called setLaunchNonce, a missing or wrong x-pmos-nonce header: 403.
36
- * The terminal side refuses an agent session (403, without asking), no interactive terminal (403), and a typed text
37
- * that does not match `expect` (403). With no `ask` function there is no way to confirm, so the act is refused (X12).
41
+ * The terminal side lets an agent session through at once with its own actor (D98). The PM at a terminal types `expect`;
42
+ * a typed text that does not match is 403, and with no `ask` function there is no way to confirm, so it is refused (X12).
43
+ * A request that carries an `x-pmos-session` token (an agent's hook or curl) and passes the Origin and nonce checks is
44
+ * answered with that agent's actor, never the PM's.
38
45
  *
39
46
  * RESIDUAL (named, not closed). A process that runs as the PM's own user can read the nonce from GET / and send it with
40
47
  * an Origin that matches. A process that fakes a terminal (`script`) and types the expected id is the PM to this file.
@@ -73,6 +80,7 @@ const ACT_PHRASE = Object.freeze({
73
80
  const WRITER_FIELDS = Object.freeze(['v', 'eid', 'by', 'via', 'at', 'override', 'pm', 'actor', 'nonce', 'grant']);
74
81
 
75
82
  const NONCE_HEADER = 'x-pmos-nonce';
83
+ const SESSION_HEADER = 'x-pmos-session';
76
84
  const NONCE_META = 'pmos-nonce';
77
85
  let NONCE = '';
78
86
  /** server.js calls this once at start (2A). The value never goes into a PTY environment or a log (D08). */
@@ -109,6 +117,10 @@ function pageChecks(req, who) {
109
117
  // A wrong value is almost always a page from an earlier start of the workspace; a missing one is not the page at all.
110
118
  if (NONCE && !h[NONCE_HEADER]) return refuse(403, `${who}; this request does not come from the workspace page`);
111
119
  if (NONCE && h[NONCE_HEADER] !== NONCE) return refuse(403, `${who}; the workspace restarted, so reload the page, then try again`);
120
+ // D98: an agent session's call is allowed and keeps the agent's name on the line it writes.
121
+ const tok = Array.isArray(h[SESSION_HEADER]) ? h[SESSION_HEADER][0] : h[SESSION_HEADER];
122
+ // A header that is not a well-formed token is still an agent's call: it is agent:unknown, never the PM.
123
+ if (typeof tok === 'string' && tok) return { ok: true, actor: { by: actor.SESSION_RE.test(tok) ? `agent:${tok}` : 'agent:unknown', via: 'ui' } };
112
124
  return { ok: true, actor: actor.fromUi() };
113
125
  }
114
126
 
@@ -149,7 +161,8 @@ async function requirePmCli({ act, expect, isTTY, env, ask } = {}) {
149
161
  if (!knownAct(act)) return refuse(500, `pm-guard: ${JSON.stringify(act)} is not a PM-only act`);
150
162
  if (typeof expect !== 'string' || !expect.trim()) return refuse(500, 'pm-guard: a PM-only verb needs the text the PM must type');
151
163
  const who = actor.fromCli({ isTTY, env });
152
- if (actor.isAgent(who) && who.by !== 'agent:unknown') return refuse(403, `an agent session cannot ${ACT_PHRASE[act]}; ask the PM to do it`);
164
+ // D98: an agent does what it was asked, with no typed confirmation; the line it writes names the agent.
165
+ if (actor.isAgent(who)) return { ok: true, actor: who };
153
166
  if (!actor.isPm(who)) return refuse(403, `only the PM can ${ACT_PHRASE[act]}, at an interactive terminal`);
154
167
  if (typeof ask !== 'function') return refuse(403, `to ${ACT_PHRASE[act]}, type a confirmation at the terminal`);
155
168
  let typed;
@@ -14,8 +14,9 @@
14
14
  * grant-mismatch a PM-only line that cites a grant that does not cover it: a lifecycle line needs a lifecycle-bulk
15
15
  * grant whose target names its state and its initiative, and every line's `at` falls inside the grant's
16
16
  * window (at to expires_at). A copied id of a merge grant, or of another batch, is flagged;
17
- * not-pm a PM-only line in a D86 ledger whose `by` is not the PM's;
18
- * agent-commit a PM-only line that arrived in an agent-authored commit (a Co-Authored-By trailer that names an agent,
17
+ * not-pm a line in a D86 ledger whose `by` names neither the PM nor an agent session (D98 lets an agent write
18
+ * these lines; its `by` is the record of who acted);
19
+ * agent-commit a line that claims the PM (not an agent's own `by`, D98) and arrived in an agent-authored commit (a Co-Authored-By trailer that names an agent,
19
20
  * a session trailer, or an agent's address). This catches a line written by a script and then committed
20
21
  * (bypass e) and a patch applied with `git apply` (bypass f).
21
22
  * agent-basis an agent's acceptance (D87) that the Review Gate does not back: no eval row for its run, a verdict that
@@ -256,10 +257,13 @@ function scan(root, { runsDir, rules, rulesFile, now = Date.now(), arrival = tru
256
257
  const why = grantMismatch(src.ledger, rec, grants.get(cites));
257
258
  if (why) say('grant-mismatch', `${what[src.ledger](rec)} cites a grant that does not cover it`, why);
258
259
  }
259
- if (D86.has(src.ledger) && typeof rec.by === 'string' && !rec.by.startsWith('pm:')) {
260
- say('not-pm', `${what[src.ledger](rec)} is written by an agent`, 'a PM-only line whose by is not the PM');
260
+ // D98: an agent session may write these lines; its `by` is the record of who acted, so it is not flagged.
261
+ if (D86.has(src.ledger) && typeof rec.by === 'string' && !/^(?:pm|agent):/.test(rec.by)) {
262
+ say('not-pm', `${what[src.ledger](rec)} names no PM or agent session`, 'a line whose by is neither the PM nor an agent session');
261
263
  }
262
- if (a && !a.boundary && a.agent && !isOlder) {
264
+ // An agent's own line (D98) arrives in an agent's commit by design; a line that claims the PM there is still flagged.
265
+ const ownAgentLine = typeof rec.by === 'string' && rec.by.startsWith('agent:');
266
+ if (a && !a.boundary && a.agent && !isOlder && !ownAgentLine) {
263
267
  say('agent-commit', `${what[src.ledger](rec)} arrived in an agent-authored commit`, `arrived in the agent-authored commit ${a.sha.slice(0, 8)}`);
264
268
  }
265
269
  if (isOlder && viaMissing && src.viaChecked) olderCount++;
@@ -191,8 +191,8 @@ function reportWorkspace(verb, { pos, flags, root, json, say, fail, isTTY, env,
191
191
  }
192
192
  const who = actorLib.fromCli({ ...(isTTY === undefined ? {} : { isTTY }), ...(env === undefined ? {} : { env }) });
193
193
  if (verb === 'finder') {
194
- // The PM's: an agent session cannot turn the finder or a source on or off.
195
- if (!actorLib.isPm(who)) return fail(`only the PM can change the report finder, at an interactive terminal${actorLib.isAgent(who) && who.by !== 'agent:unknown' ? '; an agent session cannot' : ''}`);
194
+ // D98: the PM or an agent session turns the finder or a source on or off; the line names who.
195
+ if (!actorLib.isPm(who) && !actorLib.isAgent(who)) return fail('only the PM or an agent session can change the report finder');
196
196
  const file = RS.ledgerFile(root);
197
197
  let r;
198
198
  if (pos[0] === 'source') {
@@ -19,7 +19,6 @@ async function handle(req, res, url, ctx) {
19
19
  const read = await ctx.readJson(req);
20
20
  if (!read.ok) return send(bad(400, 'the body is not JSON'));
21
21
  const body = read.body || {};
22
- if (req.headers && req.headers['x-pmos-session']) return send(bad(403, 'an agent session cannot set a target. Only a press on the page does'));
23
22
  const g = guard.requirePagePress(req, body);
24
23
  if (!g.ok) return send(bad(g.status, g.error));
25
24
  const id = typeof body.ws === 'string' ? body.ws : '';
@@ -56,7 +56,6 @@ const rootOf = (url, ctx) => {
56
56
  /** The PM's own calls (initiative briefing-premium-writes). Each appends one record and answers with the rebuilt model. */
57
57
  async function post(req, res, url, ctx) {
58
58
  const act = url.pathname.slice('/api/briefing-premium/'.length);
59
- if (req.headers && req.headers['x-pmos-session']) { ctx.json(res, { ok: false, error: 'an agent session cannot record the PM\'s decision' }, 403); return true; }
60
59
  const got = await ctx.readJson(req);
61
60
  if (!got.ok) { ctx.json(res, { ok: false, error: 'body must be JSON' }, 400); return true; }
62
61
  const b = got.body;
@@ -100,9 +99,10 @@ async function post(req, res, url, ctx) {
100
99
  return true;
101
100
  }
102
101
  let r;
102
+ const agentBy = actor.isAgent(g.actor) ? actor.pageName(g.actor.by) : undefined; // D98: an agent's decision names it
103
103
  try {
104
- if (act === 'decide') r = Wr.decide({ root, key: sk ? sk.base : b.key, choice: b.choice, why: b.why });
105
- else if (act === 'put-off') r = Wr.putOff({ runtimeDir, key: b.key, until: b.until });
104
+ if (act === 'decide') r = Wr.decide({ root, key: sk ? sk.base : b.key, choice: b.choice, why: b.why, by: agentBy });
105
+ else if (act === 'put-off') r = Wr.putOff({ runtimeDir, key: b.key, until: b.until, by: agentBy });
106
106
  else r = Wr.returnRun({ root, runtimeDir, run: b.run, reason: b.reason, correctionEvent, appendOutbox });
107
107
  } catch (e) { r = { ok: false, status: 500, error: 'the record could not be written: ' + String((e && e.message) || e).slice(0, 160) }; }
108
108
  if (!r.ok) { ctx.json(res, { ok: false, error: r.error }, r.status || 400); return true; }
@@ -140,7 +140,6 @@ async function chatFile(req, res, url, ctx) {
140
140
  return true;
141
141
  }
142
142
  if (req.method !== 'POST') { ctx.json(res, { ok: false, error: 'POST only' }, 405); return true; }
143
- if (req.headers && req.headers['x-pmos-session']) { ctx.json(res, { ok: false, error: 'an agent session cannot attach a file to the PM\'s message' }, 403); return true; }
144
143
  const g = guard.requirePagePress(req, {});
145
144
  if (!g.ok) { ctx.json(res, { ok: false, error: g.error }, g.status); return true; }
146
145
  if (url.pathname === '/api/chat-file/notes' || url.pathname === '/api/chat-file/notes/remove') { // premium-chat-notes: save or delete one note
@@ -204,7 +203,6 @@ module.exports = {
204
203
  if (url.pathname === '/api/briefing-premium/seen') {
205
204
  // popup context slice 3b: a popup the PM opened, with what it showed, so the leads session after a refresh writes its lead. Starts nothing.
206
205
  if (req.method !== 'POST') { ctx.json(res, { ok: false, error: 'POST only' }, 405); return true; }
207
- if (req.headers && req.headers['x-pmos-session']) { ctx.json(res, { ok: false, error: 'an agent session cannot record what the PM opened' }, 403); return true; }
208
206
  const got = await ctx.readJson(req);
209
207
  if (!got.ok || !got.body || typeof got.body !== 'object') { ctx.json(res, { ok: false, error: 'body must be JSON' }, 400); return true; }
210
208
  const g = guard.requirePagePress(req, got.body);
@@ -199,7 +199,6 @@ async function handle(req, res, url, ctx) {
199
199
  const read = await ctx.readJson(req);
200
200
  if (!read.ok) return send(bad(400, 'the body is not JSON'));
201
201
  const body = read.body || {};
202
- if (req.headers && req.headers['x-pmos-session']) return send(bad(403, 'an agent session cannot draft, issue or drop a core document. Only a press on the page does'));
203
202
  const g = sub === 'draft' ? guard.requirePagePress(req, body) : guard.requirePmPress(req, body, { act: 'issue' });
204
203
  if (!g.ok) return send(bad(g.status, g.error));
205
204
  const w = wsOf(ctx, text(body.ws));
@@ -44,7 +44,6 @@ async function handle(req, res, url, ctx) {
44
44
  const read = await ctx.readJson(req);
45
45
  if (!read.ok) return send(bad(400, 'the body is not JSON'));
46
46
  const body = read.body || {};
47
- if (req.headers && req.headers['x-pmos-session']) return send(bad(403, 'an agent session cannot add a document. Only a press on the page does'));
48
47
  const g = guard.requirePagePress(req, body);
49
48
  if (!g.ok) return send(bad(g.status, g.error));
50
49
  const w = wsOf(ctx, text(body.ws));
@@ -118,7 +118,6 @@ async function handle(req, res, url, ctx) {
118
118
  const read = await ctx.readJson(req);
119
119
  if (!read.ok) return send(bad(400, 'the body is not JSON'));
120
120
  const body = read.body;
121
- if (req.headers && req.headers['x-pmos-session']) return send(bad(403, 'an agent session cannot keep, send back, drop, pause or change the mode of the driver'));
122
121
  const g = guard.requirePagePress(req, body);
123
122
  if (!g.ok) return send(bad(g.status, g.error));
124
123
  const w = wsOf(ctx, text(body.ws));
@@ -15,7 +15,7 @@
15
15
  * · seen and queued are the PM's per-machine marks, so they are runtime state: <runtime>/home/seen.jsonl, <runtime>/home/queued.jsonl
16
16
  * · recipients, sent updates and stakeholders are product records, so they go in the workspace's state folder (stateDirFor):
17
17
  * <state>/product-updates.jsonl and <state>/stakeholders.jsonl. The last line for a key wins when read back.
18
- * Every POST is a page press (pm-guard requirePagePress): an agent session cannot write these. Nothing here sends mail, Slack or
18
+ * Every POST is a page press (pm-guard requirePagePress): an agent session writes these too, under its own name (D98). Nothing here sends mail, Slack or
19
19
  * anything else: Send on the weekly update opens a mail draft in the PM's own mail app, and this route only records that it was opened. */
20
20
  const path = require('path');
21
21
  const guard = require('./pm-guard.js');
@@ -12,7 +12,7 @@
12
12
  *
13
13
  * FILE MODE ONLY, append-only JSONL (D64/D66): <state>/weekly-review.jsonl in the workspace's state folder (stateDirFor). Nothing is
14
14
  * rewritten; the last line for a step or an initiative in a week wins when read back. Every POST is a page press (pm-guard
15
- * requirePagePress): an agent session cannot write the review. Nothing here sends anything to anyone. */
15
+ * requirePagePress): an agent session writes it too, under its own name (D98). Nothing here sends anything to anyone. */
16
16
  const path = require('path');
17
17
  const guard = require('./pm-guard.js');
18
18
  const pmItems = require('./pm-items.js');
@@ -9,7 +9,7 @@
9
9
  * → the same answer as GET, after the line is written
10
10
  *
11
11
  * FILE MODE ONLY, append-only JSONL (D64/D66): <state>/initiative-layout.jsonl in the workspace's state folder (stateDirFor).
12
- * Every POST is a page press (pm-guard requirePagePress): an agent session cannot write it. */
12
+ * Every POST is a page press (pm-guard requirePagePress): an agent session writes it too, under its own name (D98). */
13
13
  const path = require('path');
14
14
  const guard = require('./pm-guard.js');
15
15
  const pmItems = require('./pm-items.js');
@@ -57,7 +57,6 @@ async function handle(req, res, url, ctx) {
57
57
  const read = await ctx.readJson(req);
58
58
  if (!read.ok) return send(bad(400, 'the body is not JSON'));
59
59
  const body = read.body || {};
60
- if (req.headers && req.headers['x-pmos-session']) return send(bad(403, 'an agent session cannot change Insights. Only a press on the page does'));
61
60
  const g = guard.requirePagePress(req, body);
62
61
  if (!g.ok) return send(bad(g.status, g.error));
63
62
  const w = dashRoutes.wsOf(ctx, text(body.ws));
@@ -150,7 +150,6 @@ async function file(req, res, url, ctx) {
150
150
  return true;
151
151
  }
152
152
  if (req.method !== 'POST') return respond(ctx, res, fail(405, 'GET or POST only'));
153
- if (req.headers && req.headers['x-pmos-session']) return respond(ctx, res, fail(403, 'an agent session cannot add material to a meeting'));
154
153
  const g = guard.requirePagePress(req, {});
155
154
  if (!g.ok) return respond(ctx, res, fail(g.status, g.error));
156
155
  const raw = await readRaw(req, files.MAX_BYTES);
@@ -34,9 +34,11 @@ const today = () => new Date().toISOString().slice(0, 10);
34
34
  const bad = (status, error) => ({ status, body: { ok: false, error } });
35
35
  const len = (v) => (Array.isArray(v) ? v.length : Number(v) || 0);
36
36
 
37
- /** pm:<slug> from the press becomes human:<slug> for the onboarding ledger. Null for anything else. */
37
+ /** pm:<slug> from the press becomes human:<slug> for the onboarding ledger; an agent session keeps its agent:… (D98).
38
+ * Null for anything else. */
38
39
  function humanOf(actor) {
39
40
  const by = actor && typeof actor.by === 'string' ? actor.by : '';
41
+ if (/^agent:(?:unknown|sess-\d+\.[0-9a-f]{8})$/.test(by)) return { by, via: actor.via || 'ui' };
40
42
  return /^pm:[a-z0-9_-]{1,40}$/.test(by) ? { by: 'human:' + by.slice(3), via: actor.via || 'ui' } : null;
41
43
  }
42
44
 
@@ -33,7 +33,6 @@ async function handle(req, res, url, ctx) {
33
33
  if (req.method !== 'POST') return send(bad(405, 'POST only'));
34
34
  const read = await ctx.readJson(req);
35
35
  if (!read.ok) return send(bad(400, 'the body is not JSON'));
36
- if (req.headers && req.headers['x-pmos-session']) return send(bad(403, 'an agent session cannot stop or resume the orchestrator'));
37
36
  const g = guard.requirePagePress(req, read.body);
38
37
  if (!g.ok) return send(bad(g.status, g.error));
39
38
  const r = o.gate.setStopped(sub === 'stop', actorLib.pageName ? actorLib.pageName(g.actor) : 'pm');
@@ -22,7 +22,6 @@ async function handle(req, res, url, ctx) {
22
22
  const read = await ctx.readJson(req);
23
23
  if (!read.ok) return send(bad(400, 'the body is not JSON'));
24
24
  const body = read.body || {};
25
- if (req.headers && req.headers['x-pmos-session']) return send(bad(403, 'an agent session cannot change a chart. Only a press on the page does'));
26
25
  const g = guard.requirePagePress(req, body);
27
26
  if (!g.ok) return send(bad(g.status, g.error));
28
27
  const w = wsOf(ctx, typeof body.ws === 'string' ? body.ws : '');
@@ -42,7 +42,6 @@ async function handle(req, res, url, ctx) {
42
42
  const read = await ctx.readJson(req);
43
43
  if (!read.ok) return send(bad(400, 'the body is not JSON'));
44
44
  const body = read.body || {};
45
- if (req.headers && req.headers['x-pmos-session']) return send(bad(403, 'an agent session cannot change a dashboard. Only a press on the page does'));
46
45
  const g = guard.requirePagePress(req, body);
47
46
  if (!g.ok) return send(bad(g.status, g.error));
48
47
  const w = wsOf(ctx, text(body.ws));
@@ -13,7 +13,7 @@
13
13
  * POST /api/programs/archive { ws, program }
14
14
  *
15
15
  * FILE MODE ONLY (D64/D66): <state>/programs.jsonl of the workspace named by `ws`, append-only. Every POST is a page press (pm-guard
16
- * requirePagePress): an agent session cannot make, join or archive a program. Nothing here writes to Jira. */
16
+ * requirePagePress): an agent session may make, join or archive a program too (D98). Nothing here writes to Jira. */
17
17
  const path = require('path');
18
18
  const guard = require('./pm-guard.js');
19
19
  const pmItems = require('./pm-items.js');
@@ -7,7 +7,7 @@
7
7
  * POST /api/records/kr-metrics/reading { rid, at, value } → { ok } one actual reading of a KR metric
8
8
  *
9
9
  * STATE: planning/records/<kind>.jsonl, written only through scripts/records (which uses scripts/trust/ledger.js).
10
- * WHO WRITES: every POST passes pm-guard requirePagePress; an agent session cannot add or edit these records.
10
+ * WHO WRITES: every POST passes pm-guard requirePagePress; an agent session adds and edits them too, under its own name (D98).
11
11
  */
12
12
  const path = require('path');
13
13
  const guard = require('./pm-guard.js');
@@ -384,6 +384,11 @@ function rememberStudio(ctx, w, id) {
384
384
  return true;
385
385
  } catch { return false; }
386
386
  }
387
+ /** Who a note line names: 'pm', or an agent session's page name (D98; never its token). */
388
+ const logBy = (a) => {
389
+ const m = a && typeof a.by === 'string' ? /^(agent:(?:unknown|sess-\d+))/.exec(a.by) : null;
390
+ return m ? m[1] : 'pm';
391
+ };
387
392
  function editLog(ctx, row) {
388
393
  if (!ctx.runtimeDir) return false;
389
394
  try {
@@ -484,7 +489,6 @@ async function handle(req, res, url, ctx) {
484
489
  const read = await ctx.readJson(req);
485
490
  if (!read.ok) return send(bad(400, 'the body is not JSON'));
486
491
  const body = read.body || {};
487
- if (req.headers && req.headers['x-pmos-session']) return send(bad(403, 'an agent session cannot change a report design, its cycles or its notes. Only a press on the page does'));
488
492
  const g = guard.requirePagePress(req, body);
489
493
  if (!g.ok) return send(bad(g.status, g.error));
490
494
  const w = wsOf(ctx, text(body.ws));
@@ -500,7 +504,7 @@ async function handle(req, res, url, ctx) {
500
504
  } else {
501
505
  const r = D.pinOp(root, d.c.rel, body, { by: 'you' });
502
506
  if (!r.ok) return fail(r);
503
- editLog(ctx, { event: 'pin', path: d.c.rel, by: 'pm', op: r.op, id: r.pin.id, slide: r.pin.slide, text: r.pin.text, ...(r.pin.section ? { section: r.pin.section } : {}) });
507
+ editLog(ctx, { event: 'pin', path: d.c.rel, by: logBy(g.actor), op: r.op, id: r.pin.id, slide: r.pin.slide, text: r.pin.text, ...(r.pin.section ? { section: r.pin.section } : {}) });
504
508
  }
505
509
  return send({ status: 200, body: D.notesOf(root, d.c.rel) });
506
510
  }
@@ -534,7 +538,7 @@ async function handle(req, res, url, ctx) {
534
538
  const r = D.decideCycle(root, c.rel, { diff: diff.id, choice, newVersion });
535
539
  if (!r.ok) return fail(r);
536
540
  D.append(root, c.cadence, { ev: 'cycle-decision', path: c.rel, slot: c.slot, diff: diff.id, choice }, { actor: g.actor });
537
- editLog(ctx, { event: 'design', path: c.rel, by: 'pm', choice, diff: diff.id, what: diff.what });
541
+ editLog(ctx, { event: 'design', path: c.rel, by: logBy(g.actor), choice, diff: diff.id, what: diff.what });
538
542
  return send({ status: 200, body: { ...cycleAnswer(w, c), cycle: r.cycle } });
539
543
  }
540
544
 
@@ -309,7 +309,6 @@ async function handle(req, res, url, ctx) {
309
309
  const read = await ctx.readJson(req);
310
310
  if (!read.ok) return send(bad(400, 'the body is not JSON'));
311
311
  const body = read.body || {};
312
- if (req.headers && req.headers['x-pmos-session']) return send(bad(403, 'an agent session cannot set up, change or dismiss a report. Only a press on the page does'));
313
312
  const g = guard.requirePagePress(req, body);
314
313
  if (!g.ok) return send(bad(g.status, g.error));
315
314
  const w = wsOf(ctx, text(body.ws));
@@ -697,7 +697,6 @@ async function handle(req, res, url, ctx) {
697
697
  const read = await ctx.readJson(req);
698
698
  if (!read.ok) return send(bad(400, 'the body is not JSON'));
699
699
  const body = read.body || {};
700
- if (req.headers && req.headers['x-pmos-session']) return send(bad(403, 'an agent session cannot change a report structure, add a source, start a check or save a chart. Only a press on the page does'));
701
700
  const g = guard.requirePagePress(req, body);
702
701
  if (!g.ok) return send(bad(g.status, g.error));
703
702
  const w = wsOf(ctx, text(body.ws));