Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions frontend/src/api/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,7 @@ export interface MentorHint {
ops: string[];
// The counts the rule fired on — checkable, never a value.
evidence: Record<string, unknown>;
// The plane of the first of the hint's ops that has one (a `planes` name); null or absent
// (a server a release behind) when none does.
// The plane this hint points to (a `planes` name), if it has one.
plane?: string | null;
}

Expand Down
24 changes: 24 additions & 0 deletions frontend/src/views/assistant/cards/MentorCard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,30 @@ describe("Assistant: the mentor card", () => {
expect(navigate).toHaveBeenLastCalledWith("runs", {});
});

it("keeps the Review queue link for a conflicts hint with no MCP ops", async () => {
const navigate = vi.fn();
useStore.setState({ navigate });
vi.mocked(mentorBrief).mockResolvedValueOnce({
...BRIEF,
hints: [
{
code: "conflicts_pending",
severity: "info",
text: "Review the unresolved conflicts in the dashboard.",
ops: [],
evidence: { conflicted_rows: 2 },
plane: "conflicts",
},
],
});
render(<InsightsHarness />);
await userEvent.click(await screen.findByRole("button", { name: STARTER }));
const hint = await screen.findByTestId("mentor-hint");
expect(within(hint).getByRole("button", { name: "Open in Review queue" })).toBeInTheDocument();
await userEvent.click(within(hint).getByRole("button", { name: "Open in Review queue" }));
expect(navigate).toHaveBeenCalledWith("admin:review_queue", {});
});

it("a hint from a server that names no plane, or one with no page, has no link", async () => {
vi.mocked(mentorBrief).mockResolvedValueOnce({
...BRIEF,
Expand Down
2 changes: 1 addition & 1 deletion integrations/claude-code-plugin/.claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "loom",
"displayName": "ClickHouse Loom",
"version": "1.2.176",
"version": "1.2.177",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 — Main already ships plugin version 1.2.177. The simulated merge changes the shipped skill text and leaves both manifest versions at 1.2.177, so a client already on that version cannot pick up the new guidance as an update. Give both manifests the next unused plugin version.

"description": "Shared long-term memory and code intelligence for Claude Code, self-hosted on ClickHouse. MCP tools to save and recall decisions, preferences and corrections across sessions and teammates; lifecycle hooks that capture each session with no model call; a code index that answers where-is, who-calls and blast-radius questions with line-accurate units instead of whole-file reads.",
"author": {
"name": "ClickHouse"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ hint to the user unless it changes what you are about to do.
| know before deciding what the store already holds | `context.pack` once at session start (working memory, profile, relevant memories, procedures); `memory.search` / `loom_search` before a decision; `memory.brief` to orient on one question | writing without reading |
| a `memory.get` says `found: false` | `memory.search` (by meaning), `memory.list prefix=` (the siblings); a moved key answers with `canonical_key` — pass `follow=true` | inventing the key again |
| a write came back with `duplicate_of` or `conflict` | read the named row (`memory.get`, `memory.related`), revise THAT key, or `memory.link supersedes` if yours replaces it; a `conflict` → tell the user both values (`loom-memory`) | writing a third copy |
| the namespace holds facts that disagree | `conflicts.list` (over HTTP/SDK; the dashboard's Review queue) → `conflicts.resolve`; search penalises conflicted rows until then | leaving them |
| the namespace holds facts that disagree | ask the user to review the pairs in the dashboard's Review queue; both versions may appear in search results | leaving them unresolved |
| follow what is connected to an entity | `facts.traverse` from a seed entity, `facts.path` between two names (via loom_op), `memory.related` for a row's neighbours | a chain of searches |
| do a piece of work whose outcome should grade the memories it used | `run.begin` before, its `run_id` on writes (`memory.set`, `observe.record`; reads carry the session's run), `run.complete(memories_used=[…], outcome=…)` after — callable via `loom_op` | nothing; the store cannot tell which memories helped |
| make a decision that a future session should be able to check | `decision.record` (scenario, options, choice), later `decision.outcome`; `decision.precedents` before a similar decision — callable via `loom_op` | a memory row that says "we decided X" |
Expand Down Expand Up @@ -66,7 +66,7 @@ the owner to select or register a connected source.
| `documents_as_memories` | rows over ~2 KB or JSON past the embed clip stored as memories | `knowledge.upsert` + pointer row; `loom-optimize` moves the existing ones |
| `checkpoints_as_memory` | run dumps stored as memory rows | `context.offload`; one short episodic row per run |
| `duplicates_written` | a tenth or more of writes landed as duplicates | `memory.related` / `memory.get` before the write; revise the same key |
| `conflicts_pending` | conflicted facts nobody has looked at | `conflicts.list` → `conflicts.resolve` (or the owner's Review queue) |
| `conflicts_pending` | unresolved conflicts; both versions may appear in search results | ask the user to review the pairs in the dashboard's Review queue |
| `records_for_identities` | many writes keyed by a number under one prefix | `memory_schema.register` + `memory.record.write` |
| `coordination_loop` | one key written or read dozens of times in a session | `working_memory.set` / `get` |
| `facts_graph_unused` | rows carry entities; the graph was never walked | `facts.traverse`, `memory.related`, `facts.path` |
Expand Down
2 changes: 1 addition & 1 deletion integrations/codex-plugin/.codex-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "loom",
"version": "1.2.176",
"version": "1.2.177",
"description": "Shared long-term memory and code intelligence for Codex, self-hosted on ClickHouse. MCP tools to save and recall decisions, preferences and corrections across sessions and teammates; lifecycle hooks that capture each session with no model call; a code index that answers where-is, who-calls and blast-radius questions with line-accurate units instead of whole-file reads.",
"author": {
"name": "ClickHouse"
Expand Down
4 changes: 2 additions & 2 deletions integrations/codex-plugin/skills/loom-mentor/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ hint to the user unless it changes what you are about to do.
| know before deciding what the store already holds | `context.pack` once at session start (working memory, profile, relevant memories, procedures); `memory.search` / `loom_search` before a decision; `memory.brief` to orient on one question | writing without reading |
| a `memory.get` says `found: false` | `memory.search` (by meaning), `memory.list prefix=` (the siblings); a moved key answers with `canonical_key` — pass `follow=true` | inventing the key again |
| a write came back with `duplicate_of` or `conflict` | read the named row (`memory.get`, `memory.related`), revise THAT key, or `memory.link supersedes` if yours replaces it; a `conflict` → tell the user both values (`loom-memory`) | writing a third copy |
| the namespace holds facts that disagree | `conflicts.list` (over HTTP/SDK; the dashboard's Review queue) → `conflicts.resolve`; search penalises conflicted rows until then | leaving them |
| the namespace holds facts that disagree | ask the user to review the pairs in the dashboard's Review queue; both versions may appear in search results | leaving them unresolved |
| follow what is connected to an entity | `facts.traverse` from a seed entity, `facts.path` between two names (via loom_op), `memory.related` for a row's neighbours | a chain of searches |
| do a piece of work whose outcome should grade the memories it used | `run.begin` before, its `run_id` on writes (`memory.set`, `observe.record`; reads carry the session's run), `run.complete(memories_used=[…], outcome=…)` after — callable via `loom_op` | nothing; the store cannot tell which memories helped |
| make a decision that a future session should be able to check | `decision.record` (scenario, options, choice), later `decision.outcome`; `decision.precedents` before a similar decision — callable via `loom_op` | a memory row that says "we decided X" |
Expand Down Expand Up @@ -66,7 +66,7 @@ the owner to select or register a connected source.
| `documents_as_memories` | rows over ~2 KB or JSON past the embed clip stored as memories | `knowledge.upsert` + pointer row; `loom-optimize` moves the existing ones |
| `checkpoints_as_memory` | run dumps stored as memory rows | `context.offload`; one short episodic row per run |
| `duplicates_written` | a tenth or more of writes landed as duplicates | `memory.related` / `memory.get` before the write; revise the same key |
| `conflicts_pending` | conflicted facts nobody has looked at | `conflicts.list` → `conflicts.resolve` (or the owner's Review queue) |
| `conflicts_pending` | unresolved conflicts; both versions may appear in search results | ask the user to review the pairs in the dashboard's Review queue |
| `records_for_identities` | many writes keyed by a number under one prefix | `memory_schema.register` + `memory.record.write` |
| `coordination_loop` | one key written or read dozens of times in a session | `working_memory.set` / `get` |
| `facts_graph_unused` | rows carry entities; the graph was never walked | `facts.traverse`, `memory.related`, `facts.path` |
Expand Down
3 changes: 1 addition & 2 deletions server/insights/api/models_mentor.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ class MentorHint(BaseModel):
ops: list[str] = Field(default_factory=list)
# The counts the rule fired on — checkable, never a value.
evidence: dict[str, Any] = Field(default_factory=dict)
# The plane of the first of the hint's ops that has one (a `planes` name), null when none
# does.
# The plane this hint points to (a `planes` name), if it has one.
plane: str | None = None


Expand Down
2 changes: 1 addition & 1 deletion server/insights/app/mentor_brief.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ async def handle_mentor_brief(inp: MentorBriefInput) -> MentorBriefOutput:
text=svc.named_for_caller(h.text),
ops=list(h.ops),
evidence=dict(h.evidence),
plane=mentor_rules.hint_plane(h.ops),
plane=h.plane or mentor_rules.hint_plane(h.ops),
)
for h in profile.hints
]
Expand Down
20 changes: 15 additions & 5 deletions server/insights/app/mentor_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ class Hint:
text: str
ops: tuple[str, ...]
evidence: dict[str, Any] = field(default_factory=dict)
plane: str | None = None


@dataclass(frozen=True)
Expand Down Expand Up @@ -390,7 +391,14 @@ def fact(self, key: str) -> int:
return int(self.facts.get(key, 0) or 0)

def add(
self, code: str, severity: str, text: str, ops: tuple[str, ...], **evidence: Any
self,
code: str,
severity: str,
text: str,
ops: tuple[str, ...],
*,
plane: str | None = None,
**evidence: Any,
) -> None:
note = _unlisted(ops)
# The body is clipped, never the note: it says how to reach the op.
Expand All @@ -402,6 +410,7 @@ def add(
text=body + note,
ops=ops,
evidence=evidence,
plane=plane,
)
)

Expand Down Expand Up @@ -665,10 +674,11 @@ def _rules_shapes(c: _Ctx) -> None:
c.add(
"conflicts_pending",
"info",
f"{conflicted} facts in this namespace disagree with another and nobody has looked: "
f"conflicts.list shows the pairs, conflicts.resolve settles one; "
"search penalises them until then.",
("conflicts.list", "conflicts.resolve"),
f"{conflicted} facts in this namespace have unresolved conflicts: "
"both versions may appear in search results; review the pairs in the "
"dashboard's Review queue.",
(),
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved
plane="conflicts",
conflicted_rows=conflicted,
)

Expand Down
26 changes: 6 additions & 20 deletions server/memory/app/retrieval/fact_rank.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ class _FactRankTerms:
tag_boost_expr: str
category_boost_expr: str
demote_expr: str
conflicted_demote_expr: str
sensitivity_demote_expr: str
reinforcement_boost_expr: str
lexical_score_expr: str
Expand Down Expand Up @@ -185,22 +184,12 @@ def _fact_boost_terms(q: SearchQuery, params: dict[str, Any]) -> _FactRankTerms:
# Hard-demote: rows whose tags intersect demote_tags sink below everything
# (large negative term) but are NOT dropped — for known-noise markers.
demote_expr = "0.0"
# Conflicted-status demotion: a status='conflicted' row still surfaces
# but sinks below clean matches by `conflicted_penalty` (0.0 = none; not
# the -1000 hard sink). Conflicted means "has a close peer", not wrong.
conflicted_demote_expr = "0.0"
if q.conflicted_penalty and q.conflicted_penalty > 0:
conflicted_demote_expr = (
"if(e.status = 'conflicted', -1.0 * {conflicted_penalty:Float32}, 0.0)"
)
params["conflicted_penalty"] = float(q.conflicted_penalty)
if q.demote_tags:
demote_expr = "if(hasAny(e.tags, {demote_tags:Array(String)}), -1000.0, 0.0)"
params["demote_tags"] = list(q.demote_tags)
# Sensitivity demotion: a labelled contact detail sinks a
# little below unlabelled matches unless the question asked for it (the
# handler zeroes the penalty on contact intent). Same correctness tail as
# the conflicted demotion; survives bare ranking.
# handler zeroes the penalty on contact intent); survives bare ranking.
sensitivity_demote_expr = "0.0"
if q.sensitivity_penalty > 0:
sensitivity_demote_expr = (
Expand Down Expand Up @@ -251,7 +240,6 @@ def _fact_boost_terms(q: SearchQuery, params: dict[str, Any]) -> _FactRankTerms:
tag_boost_expr=tag_boost_expr,
category_boost_expr=category_boost_expr,
demote_expr=demote_expr,
conflicted_demote_expr=conflicted_demote_expr,
sensitivity_demote_expr=sensitivity_demote_expr,
reinforcement_boost_expr=reinforcement_boost_expr,
lexical_score_expr=lexical_score_expr,
Expand Down Expand Up @@ -515,8 +503,7 @@ def _fact_mode_rank_score(
# Pure cosine — ZERO discretionary/relevance-inflating boosts (no
# entity/recency/chronological/temporal-anchor, no preference, and the
# prior group + reinforcement are skipped below). Only the hard
# demote_tags sink and the conflicted-status demotion (both appended in
# the correctness block below) survive.
# demote_tags sink and sensitivity demotion survive the correctness block.
rank_score_expr = "(1.0 - distance)"
t.rank_score_expr = rank_score_expr

Expand All @@ -536,15 +523,14 @@ def _fact_rank_tail(q: SearchQuery, params: dict[str, Any], t: _FactRankTerms) -
# reinforcement is already individually capped (reinf_cap) so it stays
# outside the group; demote is a deliberate hard sink, never a boost.
if t.no_priors or q.search_mode == "graph":
# Correctness-only tail: the hard demote_tags sink and the
# conflicted-status demotion. NO prior group (confidence + soft
# tag/category + preference), NO reinforcement boost — those are the
# Correctness-only tail: the hard demote_tags sink. NO prior group
# (confidence + soft tag/category + preference), NO reinforcement boost — those are the
# discretionary priors bare mode (and personalization="none") exist
# to drop. confidence_weight is left unset because nothing references
# it here.
t.rank_score_expr = (
f"({t.rank_score_expr}) "
f"+ ({t.demote_expr}) + ({t.conflicted_demote_expr}) + ({t.sensitivity_demote_expr}) "
f"+ ({t.demote_expr}) + ({t.sensitivity_demote_expr}) "
f"+ ({t.trust_boost_expr})"
)
elif q.search_mode != "related":
Expand All @@ -564,7 +550,7 @@ def _fact_rank_tail(q: SearchQuery, params: dict[str, Any], t: _FactRankTerms) -
t.prior_group_select = prior_group
t.rank_score_expr = (
f"({t.rank_score_expr}) + ({prior_group}) "
f"+ ({t.demote_expr}) + ({t.conflicted_demote_expr}) + ({t.sensitivity_demote_expr}) "
f"+ ({t.demote_expr}) + ({t.sensitivity_demote_expr}) "
f"+ ({t.reinforcement_boost_expr}) + ({t.trust_boost_expr})"
)
params["confidence_weight"] = float(q.confidence_weight)
3 changes: 0 additions & 3 deletions server/memory/domain/search_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@ class SearchQuery:
# so it acts as a tiebreak, not a re-rank. 0.0 = uncapped. See
# the rank_score assembly in memory_search for the rationale.
prior_cap: float = 0.0
# Additive penalty applied to status='conflicted' rows so unresolved
# contradictions sink below clean matches without being dropped. 0.0=off.
conflicted_penalty: float = 0.0
demote_tags: list[str] = field(default_factory=list)
# Additive penalty on rows tagged `sensitivity:medium` / `sensitivity:high`
# so a labelled contact detail does not ride into a window on a question
Expand Down
1 change: 0 additions & 1 deletion tests/analyzer/cases/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ async def _rank_terms(ch: RecordingCH, c: dict[str, Any]) -> None:
category="work" if c["category"] else "",
category_soft=c["category"] == "soft",
demote_tags=["stale"] if c["demote_tags"] else [],
conflicted_penalty=0.2 if c["penalties"] else 0.0,
sensitivity_penalty=0.3 if c["penalties"] else 0.0,
prior_cap=0.5 if c["penalties"] else 0.0,
reinforcement_weight=0.2 if c["reinforcement"] else 0.0,
Expand Down
Loading
Loading