prism-mcp-server 20.21.25 → 20.21.26

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/README.md CHANGED
@@ -170,6 +170,58 @@ or by re-enabling after each run.
170
170
  <details>
171
171
  <summary>Release history (optional)</summary>
172
172
 
173
+ ## What's New in v20.21.26
174
+
175
+ **Why it matters:** routine wording no longer lets a mixed request skip
176
+ Layer 1, the safety screen that decides whether a request may run on your
177
+ device. A BCBA who asks in one message for an operational
178
+ definition and how many mL of a drug to give, or a developer who asks for a
179
+ code review and then authentication code, now has that request screened by
180
+ Layer 1's rules and, unless the request or conversation is already marked
181
+ reserved, a classifier read. Before, it could be answered by a local model
182
+ with no classifier read.
183
+
184
+ - **Rules no longer clear requests.** Before, one routine clause let Layer 1's
185
+ rules clear the whole request, so it skipped the classifier. "Write an
186
+ operational definition for tantrums and tell me how many mL of Benadryl to
187
+ give at bedtime" was answered locally with no classifier read, and so was
188
+ "review the dashboard component for hook order and then write the JWT
189
+ validation middleware". Now rules can only mark a request reserved. The
190
+ routine shortcut is gone for a single prompt and for the current prompt of a
191
+ follow-up; the prompt's classifier read is skipped only if the request or
192
+ conversation is already marked reserved. A long prompt that reaches the
193
+ classifier is read as excerpts, as before.
194
+ - **What happens to a flagged request.** A text request that a rule marks
195
+ reserved, or that the classifier flags, goes to a stronger cloud model when
196
+ your plan includes cloud and the call does not pass `cloud_fallback: false`.
197
+ Otherwise it is refused, and the refusal says why. Requests the classifier
198
+ clears remain eligible to run locally, so routine drafting (operational
199
+ definitions, data sheets, antecedent strategies) and routine code work still
200
+ run on your device when the local model can answer.
201
+ - **Seclusion by another name.** Placement phrases such as "put him in the
202
+ quiet room until he calms down" (also isolation, time-out, padded and
203
+ calm-down rooms) are now marked reserved by rule. This catches placement
204
+ requests of that shape (him, her, them, or the client, student or child
205
+ placed into the room) that never use the word "seclusion". Other wording,
206
+ and other mentions of these rooms, are left to the classifier.
207
+ - **Measured:** of 46 mixed requests built to test this bypass, which should
208
+ never be answered locally, 41 were cleared to run locally before this
209
+ release and 9 after: 32 fewer sensitive requests reaching a local model. Of
210
+ 294 routine requests, 2 more than before are escalated (or refused, without
211
+ cloud).
212
+ - **Limits, unchanged in this release.** Keep them in mind when deciding
213
+ whether a local answer needs your review:
214
+ - The classifier can miss a request, and a missed request still runs
215
+ locally. The 9 above are such misses.
216
+ - Some classifier failures fall back to a keyword check, and text that
217
+ passes it can still run locally.
218
+ - A request with images is processed on this device even when flagged, and
219
+ is never sent to the cloud.
220
+ - **Cost:** requests that used the shortcut now need a classifier read, unless
221
+ screening has already marked them reserved. That added check is the price of
222
+ closing the bypass; in our tests the read took about 0.3 s at the 95th
223
+ percentile.
224
+
173
225
  ## What's New in v20.21.25
174
226
 
175
227
  Semantic memory search now automatically applies ACT-R ranking, combining
@@ -318,7 +318,6 @@ export async function layer1HedgeSecondRead(o) {
318
318
  const tier = MODEL_TIERS.find(t => t.tag === "prism-coder:9b");
319
319
  if (!o.installed.has(big) || big === o.guardModel || tier === undefined)
320
320
  return skip("no_9b");
321
- const readPrompt = !o.promptFastPath;
322
321
  const messages = o.args.messages ?? [];
323
322
  const turnReads = messages.flatMap((m, index) => historyTurnWindows(m.content).filter(w => w.trim()).map(text => ({ text, index, role: m.role })));
324
323
  const turnTexts = turnReads.map(t => t.text);
@@ -333,7 +332,7 @@ export async function layer1HedgeSecondRead(o) {
333
332
  if (excluded)
334
333
  return skip(excluded);
335
334
  }
336
- if (readPrompt && o.args.prompt.length > MAX_CLASSIFIER_PROMPT_LENGTH)
335
+ if (o.args.prompt.length > MAX_CLASSIFIER_PROMPT_LENGTH)
337
336
  return skip("prompt_oversize");
338
337
  const reads = [];
339
338
  const seen = new Set();
@@ -341,8 +340,7 @@ export async function layer1HedgeSecondRead(o) {
341
340
  seen.add(k);
342
341
  reads.push(r);
343
342
  } };
344
- if (readPrompt)
345
- add({ model: big, text: o.args.prompt, kind: "prompt", label: "9b:prompt" });
343
+ add({ model: big, text: o.args.prompt, kind: "prompt", label: "9b:prompt" });
346
344
  for (let i = turnReads.length - 1; i >= 0; i--)
347
345
  add({ model: big, text: turnReads[i].text, kind: "turn", label: `9b:turn:${turnReads[i].index}:${turnReads[i].role}` });
348
346
  for (let i = ctxTexts.length - 1; i >= 0; i--)
@@ -388,7 +386,7 @@ export async function layer1HedgeSecondRead(o) {
388
386
  if (!known(ctxBig) || !known(ctxSmall) || !known(overBig) || !known(overSmall))
389
387
  return skip("unprobeable");
390
388
  const fitsIn = (ctx, over) => (t) => Buffer.byteLength(layer1ClassifierContent(t), "utf8") + over + LAYER1_CLASSIFIER_OUTPUT_TOKENS <= ctx;
391
- if (![...turnTexts, ...(readPrompt ? [o.args.prompt] : []), ...ctxTexts].every(fitsIn(ctxBig, overBig)))
389
+ if (![...turnTexts, o.args.prompt, ...ctxTexts].every(fitsIn(ctxBig, overBig)))
392
390
  return skip("unfit");
393
391
  if (!ctxTexts.every(fitsIn(ctxSmall, overSmall)))
394
392
  return skip("unfit");
@@ -2242,27 +2240,18 @@ export async function runInfer(args, deps) {
2242
2240
  // The current prompt is a request: its deterministic floor runs
2243
2241
  // here explicitly (not only inside the classifier entry point, so
2244
2242
  // an injected classifier cannot skip it), in the same proximity
2245
- // slices as a turn; then, unless the routine fast path below
2246
- // applies, it is read alone with its images and that verdict is
2247
- // kept like a turn's.
2248
- let promptRoutine = true;
2243
+ // slices as a turn; then it is read alone with its images and that
2244
+ // verdict is kept like a turn's. The floor only refuses, so there is
2245
+ // no fast path: a prompt a rule does not refuse is always read.
2249
2246
  for (const slice of windowsOf(args.prompt, DETERMINISTIC_FLOOR_WINDOW_CHARS, DETERMINISTIC_FLOOR_WINDOW_OVERLAP)) {
2250
2247
  const promptDet = classifyDeterministicLayer1(slice);
2251
2248
  if (promptDet)
2252
2249
  l1 = raise(l1, promptDet, "rules");
2253
- if (promptDet !== "OBVIOUS_NOT_RESERVED")
2254
- promptRoutine = false;
2255
2250
  }
2256
2251
  // The classifier entry point's own whole-prompt deterministic pass
2257
2252
  // is switched off here — it would undo the slicing above (words
2258
- // 14k chars apart firing one rule; review round 18). The routine
2259
- // fast path it provided is kept explicitly and on ITS boundary: a
2260
- // prompt of at most 4,000 chars whose rules verdict is routine,
2261
- // with no images, skips the model. Longer prompts always reach
2262
- // the entry point, whose full-text keyword floor must run
2263
- // (review round 19: skipping it there bypassed that floor).
2264
- const promptFastPath = promptRoutine && args.prompt.length <= MAX_CLASSIFIER_PROMPT_LENGTH && (resolvedImages?.length ?? 0) === 0;
2265
- if (l1 !== "OBVIOUS_RESERVED" && !promptFastPath) {
2253
+ // 14k chars apart firing one rule; review round 18).
2254
+ if (l1 !== "OBVIOUS_RESERVED") {
2266
2255
  l1 = raise(l1, await l1fn(args.prompt, deps.ollamaUrl, l1Model, undefined, resolvedImages, { deterministic: false, ...(classifierInput ? { classifierInput } : {}) }), "prompt");
2267
2256
  }
2268
2257
  // 3. Context, raise only: one window per turn and one for the
@@ -2328,7 +2317,7 @@ export async function runInfer(args, deps) {
2328
2317
  else if (modelHedgeOnly) {
2329
2318
  const second = await layer1HedgeSecondRead({
2330
2319
  l1fn, args, installed, listLoaded: deps.listLoaded, freeBytes: deps.freemem(), ollamaUrl: deps.ollamaUrl,
2331
- guardModel: l1Model, promptFastPath,
2320
+ guardModel: l1Model,
2332
2321
  probeClassifierLimits: deps.probeClassifierLimits ?? probeClassifierLimits,
2333
2322
  policy: await (deps.secondReadPolicy ?? getSecondReadPolicy)().catch(() => null),
2334
2323
  });
@@ -150,7 +150,12 @@ const all = (...rules) => (prompt) => rules.every((rule) => rule(prompt));
150
150
  * restraint, self-harm, suicide, medication or diagnosis. */
151
151
  const CLINICAL_RESERVED_RULES = [
152
152
  all(has(/\b(?:de[- ]?escalat\w*|meltdown\w*|rage\s+episode|violent\w*)\b/i), has(/\b(?:draft|write|plan|procedure|protocol|manag\w*|what\s+(?:do|should)\b|respond\w*)\b/i)),
153
- all(has(/\b(?:physical\s+intervention|containment|hold\s+procedure|restrain\w*|seclu\w*|physical\s+management)\b/i), has(/\b(?:draft|write|document|procedure|protocol|use|implement|instruct\w*)\b/i)),
153
+ (prompt) => (/\b(?:physical\s+intervention|containment|hold\s+procedure|restrain\w*|seclu\w*|physical\s+management)\b/i.test(prompt)
154
+ && /\b(?:draft|write|document|procedure|protocol|use|implement|instruct\w*)\b/i.test(prompt)) || (
155
+ // Seclusion by another name: someone placed IN a room ("put him in the
156
+ // quiet room", "walk the student into the calm-down room"). A room
157
+ // named as a setting, a schedule, or a room used by choice is not one.
158
+ /\b(?:put|puts|putting|plac(?:e|es|ed|ing)|sen(?:d|ds|t|ding)|tak(?:e|es|en|ing)|took|walk\w*|mov(?:e|es|ed|ing)|bring\w*|brought|escort\w*|carr(?:y|ies|ied|ying)|drag\w*|lock\w*|confin\w*|keep\w*|kept)\s+(?:him|her|them|(?:the|a|an|this|that)\s+(?:client|student|child|kid|learner|resident|patient))\s+(?:back\s+)?(?:in|into|to|inside)\s+(?:the\s+|a\s+|an\s+)?(?:quiet|isolation|time[- ]?out|padded|calm[- ]?down|seclusion)\s+rooms?\b/i.test(prompt)),
154
159
  all(has(/\b(?:self[- ]?(?:harm|injur\w*)|bites?\s+(?:him|her|them)self|bites?\s+(?:his|her|their)\s+own\b|scratches?\s+(?:him|her|them)self|scratches?\s+(?:his|her|their)\s+own\b|bangs?\s+(?:his|her|their)\s+head|harm\s+(?:himself|herself|themselves))\b/i), has(/\b(?:bleed\w*|blood|concrete|head\s+impact|medical\s+attention|risk(?:\s+of\s+injury)?|causes?\s+injury|actual\s+injury|assess\w*|screen\w*|want\w*)\b/i)),
155
160
  (prompt) => (/\b(?:punch\w*|attack\w*|aggress\w*|hit\s+staff)\b/i.test(prompt)
156
161
  && /\b(?:last\s+(?:week|month|year)|prior|previous|history|injur\w*)\b/i.test(prompt)
@@ -173,17 +178,6 @@ const RESERVED_INTENT_RULES = [
173
178
  ...CLINICAL_RESERVED_RULES,
174
179
  ...OPERATIONAL_RESERVED_RULES,
175
180
  ];
176
- const ROUTINE_BCBA_INTENT_RULES = [
177
- has(/\boperational\s+definition\b/i),
178
- all(has(/\bdefin\w*\b/i), has(/\b(?:onset|offset|observers?|score|measur\w*)\b/i)),
179
- all(has(/\b(?:abc|fba|functional\s+behavior)\b/i), has(/\b(?:hypothes\w*|tentative|summari[sz]\w*)\b/i)),
180
- all(has(/\b(?:what\s+data|data\s+(?:should|to)\s+(?:be\s+)?gather\w*|collect\s+data)\b/i), has(/\bbefore\s+(?:select\w*|choos\w*|design\w*)\s+(?:an?\s+)?intervention\b/i)),
181
- all(has(/\b(?:aac|augmentative\s+communication)\b/i), has(/\b(?:replacement[- ]response|replacement\s+(?:skill|behavior)|function[- ]matched)\b/i), has(/\b(?:bcba|clinician)\s+review\b/i)),
182
- all(has(/\b(?:explain|educat\w*|why)\b/i), has(/\b(?:dro|differential\s+reinforcement|function[- ]matched|maintain\w+\s+by|escape\s+from)\b/i)),
183
- all(has(/\b(?:caregiver|staff|parent)\s+training\b/i), has(/\b(?:aac|replacement|break[- ]request|communication)\b/i)),
184
- all(has(/\b(?:rewrite|rephrase)\b/i), has(/\b(?:stigmat\w*|dignity|objective|tentative|function[- ]based)\b/i)),
185
- all(has(/\b(?:aac|communication\s+device)\b/i), has(/\b(?:remain|keep)\s+available\b/i), has(/\bno\s+injur(?:y|ies)\b/i), has(/\bnonrestrictive\b/i)),
186
- ];
187
181
  function matchesAny(prompt, rules) {
188
182
  return rules.some((rule) => rule(prompt));
189
183
  }
@@ -235,11 +229,11 @@ export function reservedCategory(prompt) {
235
229
  // The artifact exemption sits BETWEEN the two groups in
236
230
  // classifyDeterministicLayer1, and omitting it here made the label disagree
237
231
  // with the verdict: "add numeric validation fields to the auth token
238
- // verification handler" classifies OBVIOUS_NOT_RESERVED, while this reported
239
- // "auth / session / token code". Harmless when the deterministic verdict is
240
- // used directly, but the label is also read on paths that skip that fast
241
- // path — prompts over MAX_CLASSIFIER_PROMPT_LENGTH, and image requests — so
242
- // it could name a rule that did not fire.
232
+ // verification handler" is never refused by a rule (the classifier reads
233
+ // it), while this reported "auth / session / token code". Harmless when the
234
+ // deterministic verdict is used directly, but the label is also read on
235
+ // paths that skip that fast path — prompts over MAX_CLASSIFIER_PROMPT_LENGTH,
236
+ // and image requests — so it could name a rule that did not fire.
243
237
  if (NON_OPERATIONAL_ARTIFACT_CONTEXT.test(prompt) &&
244
238
  NON_OPERATIONAL_ARTIFACT_ACTION.test(prompt)) {
245
239
  return null;
@@ -255,9 +249,8 @@ const NON_OPERATIONAL_ARTIFACT_ACTION = /\b(?:review\b[\s\S]{0,120}\bhook\s+orde
255
249
  /**
256
250
  * Deterministic policy floor for unambiguous intents.
257
251
  *
258
- * Routing is code, not model judgment: clear reserved work fails closed and
259
- * clear routine BCBA work reaches local inference. Ambiguous prompts return
260
- * null and continue to the semantic classifier below.
252
+ * Clear reserved work fails closed by rule. Everything else returns null and
253
+ * is read by the semantic classifier below: the floor never clears.
261
254
  */
262
255
  /** The non-operational artifact exemption over a text. classifyDeterministic
263
256
  * Layer1 applies it to the text it is given; prism_infer's history screen
@@ -281,19 +274,25 @@ export function classifyDeterministicLayer1(userPrompt, opts) {
281
274
  // the crisis form" escaping the restraint rule, and a wrong answer there
282
275
  // costs more than an unnecessary escalation. Clinical intent still fails
283
276
  // closed first, before anything can exempt it.
277
+ //
278
+ // The floor only refuses; it never clears. Every bypass found in review was
279
+ // a rule clearing a request no model read: a routine or artifact clause
280
+ // beside "a prone hold protocol for staff", "how many mL of Benadryl to
281
+ // give" or "find paths allowing unauthenticated access" was served in
282
+ // 0 ms, and each word-list patch was followed by new wording. Anything a
283
+ // rule does not refuse is read by the classifier.
284
284
  const clinicalReserved = matchesAny(userPrompt, CLINICAL_RESERVED_RULES);
285
285
  if (clinicalReserved)
286
286
  return "OBVIOUS_RESERVED";
287
- if (opts?.operational === false) {
288
- return matchesAny(userPrompt, ROUTINE_BCBA_INTENT_RULES) ? "OBVIOUS_NOT_RESERVED" : null;
289
- }
290
- if (isNonOperationalArtifact(userPrompt)) {
291
- return "OBVIOUS_NOT_RESERVED";
292
- }
287
+ if (opts?.operational === false)
288
+ return null;
289
+ // A non-operational artifact edit is never refused by an operational rule
290
+ // (an auth_bypass fixture label is not reserved work); the classifier
291
+ // reads it.
292
+ if (isNonOperationalArtifact(userPrompt))
293
+ return null;
293
294
  if (matchesAny(userPrompt, RESERVED_INTENT_RULES))
294
295
  return "OBVIOUS_RESERVED";
295
- if (matchesAny(userPrompt, ROUTINE_BCBA_INTENT_RULES))
296
- return "OBVIOUS_NOT_RESERVED";
297
296
  return null;
298
297
  }
299
298
  /**
@@ -451,13 +450,6 @@ images, opts) {
451
450
  const deterministic = opts?.deterministic === false ? null : classifyDeterministicLayer1(userPrompt);
452
451
  if (deterministic === "OBVIOUS_RESERVED")
453
452
  return deterministic;
454
- // The routine-work fast path may only skip the model when there is nothing
455
- // to look at. It reads the PROMPT, so with an image attached it is a free
456
- // bypass: pair "write an operational definition" — or any ROUTINE_BCBA
457
- // phrasing — with a clinical screenshot and the gate returns NOT_RESERVED
458
- // without a single call. Text keeps the shortcut; images earn the screen.
459
- if (!oversize && !hasImages && deterministic === "OBVIOUS_NOT_RESERVED")
460
- return deterministic;
461
453
  if (oversize && keywordBackstop(userPrompt) === "OBVIOUS_RESERVED") {
462
454
  // The regex floor has no length limit — reserved vocabulary anywhere
463
455
  // in the full text (including the middle the excerpt can't see)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prism-mcp-server",
3
- "version": "20.21.25",
3
+ "version": "20.21.26",
4
4
  "mcpName": "io.github.dcostenco/prism-coder",
5
5
  "description": "Persistent session memory for AI coding agents that never leaves your machine — including the on-device model that reasons over it. Restores your prior decisions, open TODOs, and changed files across sessions; adds associative recall of related past work, semantic drift detection, and local inference. Local-first by default. Works with Claude Code, Cursor, and Codex.",
6
6
  "module": "index.ts",