Skip to content

A self-organizing Obsidian vault that gives AI coding agents persistent memory.

feat: warn when a memory claims general reach without saying why (#176)

Brenno Ferrari1eeabcb246cc
diff --git a/.claude/scripts/lib/mcp-tools.ts b/.claude/scripts/lib/mcp-tools.ts
index 16b176b..c92b148 100644
--- a/.claude/scripts/lib/mcp-tools.ts
+++ b/.claude/scripts/lib/mcp-tools.ts
@@ -191,7 +191,12 @@ export const TOOLS: readonly ToolDef[] = [
type: "string",
enum: ["general", "platform", "project"],
description:
- "How far this reaches. 'project' = only projects you name. 'platform' = anything on the same platform. 'general' = everywhere, and it will be narrowed if you name projects.",
+ "How far this reaches. 'project' = only projects you name. 'platform' = anything on the same platform. 'general' = everywhere, and it will be narrowed if you name projects. Reach for 'platform' before 'general': a dependency's quirk, a language's rule or a toolchain's behaviour is 'platform', however hard-won. 'general' means it would help someone whose stack shares nothing with yours.",
+ },
+ generality: {
+ type: "string",
+ description:
+ "Why this reaches everywhere. Required in spirit whenever scope is 'general', the same way verification is for 'verified'.",
},
projects: {
type: "array",
diff --git a/.claude/scripts/lib/memory-write.ts b/.claude/scripts/lib/memory-write.ts
index 56c35d2..2067261 100644
--- a/.claude/scripts/lib/memory-write.ts
+++ b/.claude/scripts/lib/memory-write.ts
@@ -59,6 +59,7 @@ export interface MemoryInput {
readonly confidence?: unknown;
readonly verification?: unknown;
readonly scope?: unknown;
+ readonly generality?: unknown;
readonly projects?: unknown;
readonly platforms?: unknown;
}
@@ -70,6 +71,7 @@ export interface MemoryValue {
readonly claimed_confidence: Confidence | null;
readonly flags: string[];
readonly verification: string | null;
+ readonly generality: string | null;
readonly scope: Scope;
readonly projects: string[];
readonly platforms: string[];
@@ -467,6 +469,23 @@ export function validateMemory(
};
}
+ // OVER-CLAIMED REACH IS ANSWERED HERE, AND ONLY HERE.
+ //
+ // Sibling of the `verified`-without-`verification` warning above, and the same
+ // severity on purpose. Narrowing `general` by inspecting content was tried and
+ // reverted (see `narrowScope`): declared reach is the caller's to declare, and
+ // over-claiming is answered by warnings and by `origin` as evidence, never by
+ // rewriting what the caller said. This asks for the reasoning instead.
+ //
+ // Keyed on the NARROWED scope, not the claimed one. A caller who says
+ // `general` and names projects has already been downgraded to `project` by
+ // their own admission, and warning them about generality would be noise.
+ if (narrowed.scope === "general" && !input?.generality) {
+ warnings.push(
+ 'scope is "general" but no generality was given. Say why it reaches everywhere: a dependency, language or toolchain lesson is "platform", however hard-won.',
+ );
+ }
+
const capped = flags.length && confidence === "verified";
return {
ok: true,
@@ -482,6 +501,7 @@ export function validateMemory(
claimed_confidence: capped ? "verified" : null,
flags: flags.map((f) => f.marker),
verification: input?.verification ? String(input.verification).trim() : null,
+ generality: input?.generality ? String(input.generality).trim() : null,
scope: narrowed.scope,
projects: narrowed.projects,
platforms: platformsGiven,
@@ -545,6 +565,9 @@ export function renderMemory(value: MemoryValue, links: readonly string[] = []):
const parts = [fm.join("\n"), `# ${value.title}`, "", value.body, ""];
if (value.verification) parts.push("## How this is known", "", value.verification, "");
+ // Rendered rather than kept in frontmatter: a reach claim is an argument, and a
+ // later reader has to be able to judge it the same way they judge the evidence.
+ if (value.generality) parts.push("## Why this reaches everywhere", "", value.generality, "");
// A note without links is a bug — the vault's own doctrine. Links are the only
// way a memory reaches the project it is about, since it does not live inside
// that project's folder.
diff --git a/.claude/scripts/tests/memory-write.test.ts b/.claude/scripts/tests/memory-write.test.ts
index 3376e10..f7769f1 100644
--- a/.claude/scripts/tests/memory-write.test.ts
+++ b/.claude/scripts/tests/memory-write.test.ts
@@ -281,6 +281,29 @@ describe("epistemic contract", () => {
assert.ok(r.warnings.some((w) => /verified/i.test(w)));
});
+ test("general without generality warns but does not block", () => {
+ const r = validateMemory({ ...OK, scope: "general" }, ctx);
+ assert.equal(r.ok, true);
+ assert.ok(r.warnings.some((w) => /generality/i.test(w)));
+ });
+
+ test("a supplied generality silences the warning and is carried onto the value", () => {
+ const r = validateMemory({ ...OK, scope: "general", generality: "true of any language with a module system" }, ctx);
+ assert.equal(r.ok, true);
+ assert.ok(!r.warnings.some((w) => /generality/i.test(w)));
+ assert.match(String(r.value?.generality), /module system/);
+ });
+
+ // The warning keys on the NARROWED scope. A caller who claims `general` and
+ // names projects has been downgraded to `project` by their own admission, so
+ // asking them to justify a reach they did not end up claiming is noise.
+ test("general downgraded to project by named projects does not warn about generality", () => {
+ const r = validateMemory({ ...OK, scope: "general", projects: ["alpha"] }, ctx);
+ assert.equal(r.ok, true);
+ assert.equal(r.value?.scope, "project");
+ assert.ok(!r.warnings.some((w) => /generality/i.test(w)));
+ });
+
test("an oversized body warns about atomicity rather than failing", () => {
const r = validateMemory({ ...OK, body: "x. ".repeat(5000) }, ctx);
assert.equal(r.ok, true);
diff --git a/README.md b/README.md
index 461cade..2df3b9f 100644
--- a/README.md
+++ b/README.md
@@ -313,7 +313,11 @@ it would help someone working on a **different** project.
that cost time, a rule that generalises. Set `confidence`
(`verified` / `inferred` / `unverified`) honestly and supply `verification`
when you claim `verified`. For something specific to this project use
- `scope: "project"` with `projects: ["<this-repo>"]`.
+ `scope: "project"` with `projects: ["<this-repo>"]`. Reach for
+ `scope: "platform"` before `"general"`: a dependency's quirk or a language's
+ rule is platform-level however hard-won, and `general` claims it would help
+ someone whose stack shares nothing with yours. When you do claim `general`,
+ supply `generality` saying why, the same way `verification` backs `verified`.
- **`record_work`** files what happened *here*: changes, decisions and the
alternatives rejected, what was learned, what is still open, how it was
verified.