@staix/agent-mem 0.31.0 → 0.32.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.
@@ -3,7 +3,7 @@ import { types } from "node:util";
3
3
  import { fileURLToPath } from "node:url";
4
4
  import { canonicalPath, realPath } from "./memory/platform.ts";
5
5
  import { canonicalJSON } from "./memory/generation.ts";
6
- import { readSetupWriterRoots } from "./setup.ts";
6
+ import { readSetupWriterRoots, SETUP_TARGETS, setupReceiptRemedy, SetupWriterRootsError, type SetupTarget } from "./setup.ts";
7
7
  import { measureSyncPlacementWriters, extractSyncPlacementWriterFailure, type SyncPlacementWriterFailureDetail, type SyncPlacementWriterMeasurement } from "./memory/sync-placement-writers.ts";
8
8
  import { readEffectiveSyncPlacementWriters } from "./memory/sync-placement-effective-writers.ts";
9
9
  import { PlacementHomeFloorError, requirePlacementHomeFloor } from "./memory/sync-placement-prerequisites.ts";
@@ -18,19 +18,49 @@ const failureDetails:Record<SyncPlacementWriterFailureDetail,string>={
18
18
  "invalid-version":"package version is not a supported plain release", "invalid-inventory":"root inventory is invalid or duplicated", "unsafe-runtime":"runtime files have unsafe types or symlinks",
19
19
  "missing-runtime":"required bin/amem.js or src/index.ts is missing",bound:"inventory exceeds a supported bound",changed:"install changed during measurement",
20
20
  };
21
- function writerContextMessage(category:PlacementWriterRootCategory,causeClass:"missing"|"changed"|"unavailable",phase:PlacementWriterContextPhase,detail?:SyncPlacementWriterFailureDetail,renewalState?:"pending"|"staging"|"checkpoint-pending"):string {
21
+ function writerContextMessage(category:PlacementWriterRootCategory,causeClass:"missing"|"changed"|"unavailable",phase:PlacementWriterContextPhase,detail?:SyncPlacementWriterFailureDetail,renewalState?:"pending"|"staging"|"checkpoint-pending",setupTarget?:SetupTarget):string {
22
22
  if(category==="writer renewal")return new SharedWriterRevisionError(renewalState==="staging"?"staging":renewalState==="checkpoint-pending"?"checkpoint-pending":"pending").message;
23
23
  if(category==="active locator") return `Sync placement initial root locator is ${causeClass} (active locator category); have the person inspect sync-placement-writer-roots.json and the matching activation metadata with a compatible recovery release, then run amem migrate --sync-placement --dry-run.`;
24
24
  if(category==="home floor") return `Sync placement reader-floor proof is ${causeClass} (home floor category); have the person inspect formats.json and use a reader compatible with its recorded floor, then run amem migrate --sync-placement --dry-run.`;
25
25
  const cause=detail?`; ${failureDetails[detail]}`:"";
26
- if(phase==="initial")return `Sync placement initial writer proof is ${causeClass} (${category} category${cause}); ${category==="setup receipt"?"upgrade or repair the managed amem install and its host exact pin, then rerun amem setup <target> --apply":"upgrade or repair the amem install and its host exact pin"}. Declare the complete writer roots and rerun amem migrate --sync-placement --dry-run.`;
26
+ // #520: a receipt whose recorded install root is gone names its target and remedy, never the recorded path.
27
+ const receipt=category==="setup receipt"&&setupTarget?setupReceiptRemedy(setupTarget):undefined;
28
+ if(phase==="initial")return `Sync placement initial writer proof is ${causeClass} (${category} category${cause}); ${receipt??(category==="setup receipt"?"upgrade or repair the managed amem install and its host exact pin, then rerun amem setup <target> --apply":"upgrade or repair the amem install and its host exact pin")}. Declare the complete writer roots and rerun amem migrate --sync-placement --dry-run.`;
29
+ if(receipt)return `Sync placement writer proof is ${causeClass} (${category} category${cause}); ${receipt}; then rerun the sync.`;
27
30
  return `Sync placement writer proof is ${causeClass} (${category} category${cause}); restore the inventoried install, or have the person run amem migrate --sync-placement --dry-run and --apply with the complete --writer-root inventory after installing the required 0.22.0 home floor.`;
28
31
  }
29
32
  export class PlacementWriterContextError extends Error {
30
- constructor(readonly category: PlacementWriterRootCategory, readonly causeClass: "missing" | "changed" | "unavailable",readonly phase:PlacementWriterContextPhase="active",readonly detail?:SyncPlacementWriterFailureDetail,readonly renewalState?:"pending"|"staging"|"checkpoint-pending") {
31
- super(writerContextMessage(category,causeClass,phase,detail,renewalState)); this.name = "PlacementWriterContextError";
33
+ constructor(readonly category: PlacementWriterRootCategory, readonly causeClass: "missing" | "changed" | "unavailable",readonly phase:PlacementWriterContextPhase="active",readonly detail?:SyncPlacementWriterFailureDetail,readonly renewalState?:"pending"|"staging"|"checkpoint-pending",readonly setupTarget?:SetupTarget) {
34
+ super(writerContextMessage(category,causeClass,phase,detail,renewalState,setupTarget)); this.name = "PlacementWriterContextError";
32
35
  }
33
36
  }
37
+ /**
38
+ * #520: a later sync failure carries its placement refusal as fixed own data, never only as the message text a marked
39
+ * session masks, so the target and remedy survive the wrapper that adds the underlying transport error.
40
+ */
41
+ export function placementSyncFailure(refusal: PlacementWriterContextError, failure: unknown): Error {
42
+ const error = new Error(`${refusal.message} ${(failure as Error).message}`);
43
+ Object.defineProperty(error, "placementRefusal", { value: refusal }); return error;
44
+ }
45
+ /**
46
+ * #520: the fixed-data text a marked session gets when a placement refusal comes from an applied setup receipt whose
47
+ * recorded amem install no longer exists. Fields are read as own properties and validated against closed sets, so a
48
+ * caught message, a recorded path or a forged target never reaches the text; every other failure returns undefined and
49
+ * keeps the generic masked refusal.
50
+ */
51
+ export function markedSetupReceiptRefusal(error: unknown): string | undefined {
52
+ const target = setupReceiptTarget(error);
53
+ return target === undefined ? undefined : `Placement sync refused [cause: setup_receipt_missing_install]: ${setupReceiptRemedy(target)}; then rerun the sync.`;
54
+ }
55
+ function setupReceiptTarget(error: unknown): SetupTarget | undefined {
56
+ if (!error || typeof error !== "object" || types.isProxy(error)) return undefined;
57
+ const carried = Object.getOwnPropertyDescriptor(error, "placementRefusal")?.value;
58
+ const refusal: unknown = carried && typeof carried === "object" && !types.isProxy(carried) ? carried : error;
59
+ if (refusal === null || typeof refusal !== "object") return undefined;
60
+ const fields = Object.getOwnPropertyDescriptors(refusal), target: unknown = fields.setupTarget?.value;
61
+ return fields.category?.value === "setup receipt" && fields.causeClass?.value === "unavailable" && typeof target === "string"
62
+ && (SETUP_TARGETS as readonly string[]).includes(target) ? target as SetupTarget : undefined;
63
+ }
34
64
  function safeRefusal(error: unknown, category: PlacementWriterRootCategory,phase:PlacementWriterContextPhase="active"): PlacementWriterContextError {
35
65
  if (error && typeof error === "object" && !types.isProxy(error) && (error instanceof PlacementHomeFloorError || error instanceof FormatFloorError)) return new PlacementWriterContextError("home floor","unavailable",phase);
36
66
  if(error&&typeof error==="object"&&!types.isProxy(error)&&error instanceof SharedWriterRevisionError){const code=Object.getOwnPropertyDescriptor(error,"code")?.value;if(code==="pending"||code==="staging"||code==="checkpoint-pending")return new PlacementWriterContextError("writer renewal","unavailable",phase,undefined,code);}
@@ -40,17 +70,22 @@ function safeRefusal(error: unknown, category: PlacementWriterRootCategory,phase
40
70
  if (typeof category==="string" && ["running CLI","host package","setup receipt","declared writer","active locator","home floor","writer renewal"].includes(category)
41
71
  && typeof causeClass==="string" && ["missing","changed","unavailable"].includes(causeClass)) {
42
72
  const ownDetail=detail&&"value"in detail&&typeof detail.value==="string"&&Object.hasOwn(failureDetails,detail.value)?detail.value as SyncPlacementWriterFailureDetail:undefined;
43
- const state=fields.renewalState?.value;
44
- return new PlacementWriterContextError(category as PlacementWriterRootCategory,causeClass as PlacementWriterContextError["causeClass"],phase,ownDetail,state==="staging"||state==="pending"||state==="checkpoint-pending"?state:undefined);
73
+ const state=fields.renewalState?.value,target=fields.setupTarget?.value;
74
+ return new PlacementWriterContextError(category as PlacementWriterRootCategory,causeClass as PlacementWriterContextError["causeClass"],phase,ownDetail,state==="staging"||state==="pending"||state==="checkpoint-pending"?state:undefined,
75
+ typeof target==="string"&&(SETUP_TARGETS as readonly string[]).includes(target)?target as SetupTarget:undefined);
45
76
  }
46
77
  }
47
78
  return new PlacementWriterContextError(category,"unavailable",phase);
48
79
  }
49
- const fail = (category: PlacementWriterRootCategory, cause: PlacementWriterContextError["causeClass"],phase:PlacementWriterContextPhase="active",detail?:SyncPlacementWriterFailureDetail): never => { throw new PlacementWriterContextError(category,cause,phase,detail); };
80
+ const fail = (category: PlacementWriterRootCategory, cause: PlacementWriterContextError["causeClass"],phase:PlacementWriterContextPhase="active",detail?:SyncPlacementWriterFailureDetail,setupTarget?:SetupTarget): never => { throw new PlacementWriterContextError(category,cause,phase,detail,undefined,setupTarget); };
50
81
  function required(home: string, ownRoot: string,phase:PlacementWriterContextPhase="active") {
51
82
  let own: string, receipt: string[];
52
83
  try { own = realPath(ownRoot); } catch { return fail("running CLI","unavailable",phase,"unreadable"); }
53
- try { receipt = readSetupWriterRoots(home); } catch { return fail("setup receipt","unavailable",phase,"unreadable"); }
84
+ try { receipt = readSetupWriterRoots(home); }
85
+ catch (error) {
86
+ // #520: only a receipt naming a removed install carries its target; every other inventory refusal stays anonymous.
87
+ return fail("setup receipt","unavailable",phase,"unreadable",error instanceof SetupWriterRootsError?error.target:undefined);
88
+ }
54
89
  return { own, receipt, roots: [...new Set([own,...receipt])].sort() };
55
90
  }
56
91
  function rootCategory(root:string|undefined,needed:ReturnType<typeof required>):PlacementWriterRootCategory {
package/src/ui/panel.js CHANGED
@@ -11,12 +11,24 @@ export default (host) => {
11
11
  const line = (text, max = 120) => { const flat = String(text ?? "").replace(/\s+/g, " ").trim(); return flat.length > max ? `${flat.slice(0, max - 3)}...` : flat; };
12
12
  const act = (input) => host.action({ ...input, ...(project ? { project } : {}) });
13
13
 
14
+ // #525: how the picker marks a project whose memory panels cannot open, by the class the provider proved.
15
+ const GAP_LABEL = {
16
+ "local-key": "local-key, outside inventory",
17
+ "capture-only": "capture only, outside inventory",
18
+ "no-memory": "no memory yet, outside inventory",
19
+ "curated-unadmitted": "curated, not admitted",
20
+ "unverified": "state unverified",
21
+ };
22
+
23
+ // #525: a project whose memory panels cannot open carries the class the provider proved, in every list shape.
24
+ const gapLabel = (key, gaps) => (gaps?.[key] ? `${key} (${GAP_LABEL[gaps[key]] ?? gaps[key]})` : key);
25
+
14
26
  const picker = (s) => {
15
27
  const list = s.projects ?? [];
16
- if (s.error && !s.project && list.length === 1) return btn(`Choose project ${list[0]}`, () => go(panel, { project: list[0] }));
17
- if (list.length < 2) return list.length ? h("p", { class: "amem-sub", text: `Project ${list[0]}` }) : null;
28
+ if (s.error && !s.project && list.length === 1) return btn(`Choose project ${gapLabel(list[0], s.gaps)}`, () => go(panel, { project: list[0] }));
29
+ if (list.length < 2) return list.length ? h("p", { class: "amem-sub", text: `Project ${gapLabel(list[0], s.gaps)}` }) : null;
18
30
  const select = h("select", { name: "project", class: "amem-input", "aria-label": "Project", onchange: () => { project = select.value; go(panel); } },
19
- [...(!s.project ? [h("option", { value: "", text: "Choose an active project", disabled: true, selected: true })] : []), ...list.map((key) => { const o = h("option", { value: key, text: key }); if (key === s.project) o.selected = true; return o; })]);
31
+ [...(!s.project ? [h("option", { value: "", text: "Choose an active project", disabled: true, selected: true })] : []), ...list.map((key) => { const o = h("option", { value: key, text: gapLabel(key, s.gaps) }); if (key === s.project) o.selected = true; return o; })]);
20
32
  return h("label", { class: "amem-bar" }, h("span", { text: "Project" }), select);
21
33
  };
22
34
 
package/src/ui/plugin.ts CHANGED
@@ -21,7 +21,7 @@ import { pendingSummary } from "../memory/candidate-pending.ts";
21
21
  import { candidateOverlapsBatch } from "../memory/candidate-overlaps.ts";
22
22
  import { capacityReport } from "../memory/capacity.ts";
23
23
  import { readCaptureConfigFile, writeCaptureConfigFile } from "../memory/capture.ts";
24
- import { readCatalogFresh } from "../memory/catalog.ts";
24
+ import { catalogKeys, readCatalogFresh } from "../memory/catalog.ts";
25
25
  import { configuredPolicy, configuredPolicyOptions } from "../memory/config.ts";
26
26
  import { openCuratedForRead, requireShard } from "../memory/curated-read.ts";
27
27
  import { applyDecay, assertExactDecayForget, decayPreview, DECAY_DEFAULT_DAYS, readDecayCounters } from "../memory/decay-review.ts";
@@ -31,7 +31,7 @@ import { appendLifecycle, assertProjectActive, projectState } from "../memory/li
31
31
  import { hasFailLabel, noteAdd, parseFailTemplate } from "../memory/note-add.ts";
32
32
  import type { StandalonePolicy } from "../memory/policy.ts";
33
33
  import { applyPrune, planPrune, pruneText } from "../memory/prune.ts";
34
- import { aliasedKeys, readShardedSelection, resolveAlias } from "../memory/shard.ts";
34
+ import { aliasedKeys, PlacementRealmRefusal, placementRealmGap, placementRealmView, readShardedSelection, resolveAlias, type PlacementRealmGap, type PlacementRealmView } from "../memory/shard.ts";
35
35
  import { machineId, MemoryStore, openShardStore, type StoreOptions, type View } from "../memory/store.ts";
36
36
 
37
37
  // The contract types this module uses, copied from agent-console src/contract.ts (api 1, additive only): src/ takes no
@@ -129,31 +129,57 @@ export const plugin = {
129
129
  return [...new Set(views.filter(view => !view.supersededBy).map(view => view.project))];
130
130
  } finally { store.close(); }
131
131
  }
132
+ let inventoryIncomplete = false;
132
133
  function projects(): string[] {
133
- catalogExpiry = Infinity;
134
+ catalogExpiry = Infinity; inventoryIncomplete = false;
134
135
  if (!existsSync(base)) return [];
135
136
  const keys = new Set<string>(), waiting = new Set<string>();
136
- try { for (const p of readCatalogFresh(base)) keys.add(p.key); } catch (e) { ctx.log(`amem: project catalog unavailable: ${errorText(e)}`); }
137
- try { for (const key of sharedStoreProjects()) keys.add(resolveAlias(base, key)); } catch (e) { ctx.log(`amem: shared store projects unavailable: ${errorText(e)}`); }
137
+ try { for (const key of catalogKeys(base)) keys.add(key); } catch (e) { inventoryIncomplete = true; ctx.log(`amem: project catalog unavailable: ${errorText(e)}`); }
138
+ try { for (const key of sharedStoreProjects()) keys.add(resolveAlias(base, key)); } catch (e) { inventoryIncomplete = true; ctx.log(`amem: shared store projects unavailable: ${errorText(e)}`); }
138
139
  if (hasCandidates()) for (const key of withCandidates(undefined, store => store.projects())) { const canonical = resolveAlias(base, key); keys.add(canonical); waiting.add(canonical); }
139
140
  return [...keys].filter(key => projectState(base, key) === "active").sort((a, b) => Number(waiting.has(b)) - Number(waiting.has(a)) || a.localeCompare(b));
140
141
  }
141
- function projectList(): { list: string[]; cacheable: boolean } {
142
+ // #525: a project realm outside the activated inventory cannot open its memory panels, and the class says why. It rides
143
+ // the same revision-cached listing; reuse re-proves the inventory, and a failed proof claims `unverified`, never a class.
144
+ // An unproved view is never cached and a payload carrying one is never cached either, so a transient binding or inventory
145
+ // failure is retried on the next call even when the revision has not moved.
146
+ let realmView: { revision: string; view: PlacementRealmView; gaps: Record<string, PlacementRealmGap> } | undefined;
147
+ function projectGaps(revision: string | undefined, list: string[]): { gaps: Record<string, PlacementRealmGap>; proved: boolean } {
148
+ if (revision !== undefined && realmView?.revision === revision) {
149
+ try { if (realmView.view.kind === "inventory") realmView.view.assertCurrent(); return { gaps: realmView.gaps, proved: true }; }
150
+ catch { realmView = undefined; }
151
+ }
152
+ let view: PlacementRealmView | undefined;
153
+ try { view = placementRealmView(base); } catch { view = undefined; }
154
+ const gaps: Record<string, PlacementRealmGap> = {};
155
+ for (const key of list) { const gap = placementRealmGap(base, key, view); if (gap) gaps[key] = gap; }
156
+ if (view === undefined) { realmView = undefined; return { gaps, proved: false }; }
157
+ if (revision !== undefined) realmView = { revision, view, gaps };
158
+ return { gaps, proved: true };
159
+ }
160
+ function projectList(): { list: string[]; gaps: Record<string, PlacementRealmGap>; cacheable: boolean } {
142
161
  let revision: string;
143
162
  try { revision = snapshotRevision(base); }
144
- catch { catalog = undefined; return { list: projects(), cacheable: false }; }
163
+ catch { catalog = undefined; const list = projects(), marks = projectGaps(undefined, list); return { list, gaps: marks.gaps, cacheable: false }; }
145
164
  const now = Date.now();
146
- if (catalog?.revision === revision && now >= catalog.sampledAt && now < catalog.until) return { list: [...catalog.list], cacheable: true };
165
+ if (catalog?.revision === revision && now >= catalog.sampledAt && now < catalog.until) {
166
+ const marks = projectGaps(revision, catalog.list);
167
+ return { list: [...catalog.list], gaps: marks.gaps, cacheable: marks.proved };
168
+ }
147
169
  const list = projects();
170
+ // #359: an inventory a read failure cut short serves this snapshot only; the next one reads again, write or not.
171
+ if (inventoryIncomplete) { catalog = undefined; return { list, gaps: projectGaps(undefined, list).gaps, cacheable: false }; }
148
172
  // A missing witness affects reuse only; ordinary fresh reads remain available.
149
173
  try {
150
174
  if (snapshotRevision(base) === revision) {
175
+ const marks = projectGaps(revision, list);
151
176
  catalog = { revision, list: [...list], sampledAt: now, until: catalogExpiry };
152
- return { list, cacheable: true };
177
+ return { list, gaps: marks.gaps, cacheable: marks.proved };
153
178
  }
154
179
  } catch { /* Uncacheable; do not turn an inventory race into a panel failure. */ }
155
180
  catalog = undefined;
156
- return { list, cacheable: false };
181
+ const marks = projectGaps(undefined, list);
182
+ return { list, gaps: marks.gaps, cacheable: false };
157
183
  }
158
184
  // The shell's tabs navigate without params, so the project chosen on one panel is kept for the others and the palette.
159
185
  // ponytail: one choice per provider; fine for H0's single person, per session once a console serves several.
@@ -441,7 +467,9 @@ export const plugin = {
441
467
  for (const item of value.items) if (item.group === "candidate" && item.link.params?.project) projectOf.set(item.id, item.link.params.project);
442
468
  return { ...value };
443
469
  }
444
- let list: string[] = [], project: string | undefined;
470
+ let list: string[] = [], project: string | undefined, gaps: Record<string, PlacementRealmGap> = {};
471
+ // #525: every payload that lists projects carries the class of the ones whose memory panels cannot open.
472
+ const framed = (extra: Args): Args => ({ projects: list, ...(Object.keys(gaps).length ? { gaps } : {}), ...extra });
445
473
  try {
446
474
  if (input.panel === "timeline" || input.panel === "work") {
447
475
  const requested = str(args.project), selected = requested ? resolveAlias(base, requested) : chosen;
@@ -451,16 +479,19 @@ export const plugin = {
451
479
  // This is ordinary setup, never a published revision or a retained lease.
452
480
  const initial = pick(args, projects());
453
481
  if (initial) {
454
- const prepared = createMemoryMcp({ cwd: base, base, project: initial }); prepared.close();
482
+ // #525: a realm outside the activated inventory cannot warm its curated store. The panel read below reports
483
+ // that realm's class, so a failed warm must not pre-empt the selection the payload frames.
484
+ try { createMemoryMcp({ cwd: base, base, project: initial }).close(); } catch { /* reported by the panel read */ }
455
485
  if (preparedReads.size >= 16) preparedReads.delete(preparedReads.values().next().value!);
456
486
  preparedReads.add(bindingOf(initial)); catalog = undefined;
457
487
  }
458
488
  }
459
489
  }
460
- const selection = cachedPanels.has(input.panel) ? projectList() : { list: projects(), cacheable: false };
490
+ // #359: every panel reuses the project list (and its #525 class marks) behind the snapshotRevision witness; only result caching stays limited to cachedPanels.
491
+ const listed = projectList(), selection = cachedPanels.has(input.panel) ? listed : { ...listed, cacheable: false };
461
492
  if (input.panel === "recap" && !selection.cacheable) noteMiss("uncacheable selection");
462
- list = selection.list; project = pick(args, list);
463
- if (str(args.project) && !project) return { projects: list, project: null, error: "The requested memory project is unavailable; choose an active project from the project selector." };
493
+ list = selection.list; gaps = selection.gaps; project = pick(args, list);
494
+ if (str(args.project) && !project) return framed({ project: null, error: "The requested memory project is unavailable; choose an active project from the project selector." });
464
495
  if (input.panel === "search") {
465
496
  const q = str(args.q);
466
497
  if (!q || !project) return { hits: [], total: 0 };
@@ -470,8 +501,8 @@ export const plugin = {
470
501
  return { hits, total: hits.length };
471
502
  }
472
503
  const load = async (onExpiry?: (at: number) => void, onValidate?: (validate: () => void, retries: number, bytes: number) => void): Promise<Args> => input.panel === "capacity"
473
- ? { projects: list, project: project ?? null, ...(await capacity() ?? { report: null }) }
474
- : !project ? { projects: list, project: null } : { projects: list, project, ...(await panel(input.panel, args, project, onExpiry, onValidate)) };
504
+ ? framed({ project: project ?? null, ...(await capacity() ?? { report: null }) })
505
+ : !project ? framed({ project: null }) : framed({ project, ...(await panel(input.panel, args, project, onExpiry, onValidate)) });
475
506
  // Capacity samples resources/time; Timeline probes arbitrary referenced files.
476
507
  // Neither has a cheap complete revision, so both stay uncached.
477
508
  if (!cachedPanels.has(input.panel)) return await load();
@@ -480,7 +511,8 @@ export const plugin = {
480
511
  let sourceRetried = false;
481
512
  const projection = async () => {
482
513
  if (projectionVersion !== actionVersion) {
483
- list = projects(); project = pick(args, list); catalog = undefined;
514
+ const keys = projects(), marks = projectGaps(undefined, keys);
515
+ list = keys; gaps = marks.gaps; project = pick(args, list); catalog = undefined;
484
516
  projectionVersion = actionVersion;
485
517
  }
486
518
  let until = Math.min(catalogExpiry,
@@ -497,10 +529,11 @@ export const plugin = {
497
529
  } catch (e) {
498
530
  if (input.panel === "recap" && e instanceof RecapSourceChangedError) {
499
531
  noteMiss("failed copy");
500
- return { projects: list, project: project ?? null, error: e.message };
532
+ return framed({ project: project ?? null, error: e.message });
501
533
  }
502
534
  ctx.log(`amem: ${input.panel} for ${project ?? "project"} failed: ${errorText(e)}`);
503
- return { projects: list, project: project ?? null, error: "Memory is unavailable for this project right now; details are in the terminal." };
535
+ // #525: a realm outside the activated inventory names its class and remedy; everything else keeps the generic sentence.
536
+ return framed({ project: project ?? null, error: e instanceof PlacementRealmRefusal ? e.message : "Memory is unavailable for this project right now; details are in the terminal." });
504
537
  } finally {
505
538
  if (retryCache && input.panel === "recap" && diagnostic.reason) try { ctx.log(`amem: recap cache miss: ${diagnostic.reason}`); } catch { /* diagnostics never fail a snapshot */ }
506
539
  }