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
11 changes: 11 additions & 0 deletions docs/architecture/rolling-upgrades.md
Original file line number Diff line number Diff line change
Expand Up @@ -1357,6 +1357,17 @@ See the [participant lifecycle baseline](cells.md#participant-lifecycle-baseline
`frontend/src/flows/KnowledgeSourceDialog.test.tsx` checks N's side, and the
mixed-version gate does not check this rule.

87. **Captured-memory provenance** (migration `125_captured_conflict_provenance.sql`): a
captured service-account token is issued only when every live replica advertises the
resolver capability and its namespace uses `manual_review` as the general conflict
policy. Captured writes check the live capability again, so a mixed rollout pauses them.
While captured rows remain live, N refuses a namespace policy change away from
`manual_review`. N-1 does not read `capture_origin` or the captured policy, but it does
honor `manual_review`; this keeps its resolver and inline `newest_wins` path from
retiring those rows after a rollback. Captured resolver updates remain available on N
through the separate captured policy. `tests/unit/test_provenance.py` covers the live
resolver gate, and the captured conflict tests cover the policy fence.

86. **Regression suites** (`loom.knowledge_suites`, migration
`130_knowledge_suites.sql`): N-1 serves none of the `knowledge.suites.*` ops, and a
namespace erasure it runs has no step for the table. So `knowledge.suites.publish`
Expand Down
35 changes: 35 additions & 0 deletions docs/features/memory/captured-conflict-simulation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Captured conflict simulation

The seven-day model compares the resolver's default policy with an owner opt-in for settling
high-confidence updates between authenticated captured rows. It uses the production decision
helpers and fixed verdicts; it does not call an LLM or ClickHouse.

Run it from the repository root:

```bash
uv run --locked python scripts/ops/simulate_captured_conflicts.py
```

## Results

| Scenario | Captured rows | Human-reviewable pairs, default | Human-reviewable pairs, opt-in | All automatic settlements, default | All automatic settlements, opt-in | Captured-policy settlements, opt-in |
| --- | ---: | ---: | ---: | ---: | ---: | ---: |
| Light | 700 | 372 | 141 | 176 | 407 | 231 |
| Steady | 1,750 | 975 | 328 | 413 | 1,060 | 647 |
| Surge | 3,500 | 1,965 | 645 | 829 | 2,149 | 1,320 |

In all six runs, backlog growth, false automatic settlements, and settled genuine
contradictions were zero. Each scenario used a review capacity of 2,000 pairs per sitting.
The model produced no failed resolver jobs and left no resolver work pending.

## Model inputs and limits

- Seven days of seeded synthetic cases use fixed resolver verdicts and confidence scores.
- Resolver batches contain 40 rows, concurrency is 8, bursts last at most 300 seconds, and a
row gets at most three attempts.
- A daily resolver call cap stands in for the namespace cost-share limit; it is not a provider
price estimate.
- Review capacity is an input, not a measured operator rate. The generated workload contains
no Undo events.
- Synthetic case mixes and fixed verdicts do not represent production distributions. The model
excludes database races, provider latency distributions, and real restore writes.
22 changes: 22 additions & 0 deletions docs/features/memory/conflicts-and-refusal.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,21 @@ one call to `LOOM_CONFLICT_RESOLVER_MODEL` (`gpt-6.1-sol`). Per pair:

The judge sees when each note's statement holds and which session it comes from.

Captured writes carry a server-stamped `capture_origin` from a verified service-account token;
request fields cannot set it. The supported origins are `claude-code` and `codex`. The
namespace's `captured_conflict_policy` defaults to `manual_review`, and its
`captured_conflict_confidence` defaults to 0.98. With `manual_review`, a captured update stays

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.

P1 — The documented manual-review guarantee has an inline exception. Under newest_wins, check_on_commit can classify a templated update as refines, and the commit retires the peer before the resolver sees it. Cover the inline path with the captured policy and test a captured update against a templated peer.

flagged even when the general namespace policy would retire it. Setting the captured policy to
`resolver_update` lets the resolver retire a same-entity, same-attribute update only when both
rows have trusted capture origins, the same agent and user, and the verdict meets the configured
confidence. An anonymous user's cross-session update still waits for review. Rows without a
trusted origin cannot use this policy. The [captured-conflict simulation](./captured-conflict-simulation.md)
reports a deterministic workload model and its limits.

Issuing a captured credential requires the namespace's `default_conflict_policy` to be
`manual_review`, and that policy stays in place while captured rows are live. This keeps a
rollback build, which does not read `capture_origin`, from automatically retiring those rows.

It also re-checks pairs flagged before it judged them, so a false flag is cleared once (a
definition's flags excepted: it is never judged, only its dead flags released).
A pinned row is never touched, a row that changed since it was judged is left to its
Expand All @@ -205,6 +220,13 @@ applies `conflicts.resolve`. Three more tabs appear when they have content: **Le
([learnings](./procedures-and-learnings.md#learnings-review-queue)), **Auto-resolved**
(below) and **Exceptions** (the allowlist). See [the dashboard](../dashboard.md).

The queue summary and `mentor.brief` report **conflicted rows**, grouped by whether a resolver
judgement is owed, the resolver judged but left the conflict open, or only cosine similarity
flagged the row. A row count is not a count of distinct pairs: a conflict can be linked in both
directions or belong to a larger cluster. The summary separates authenticated plugin captures,
caller-written rows, and rows with unknown provenance. The plugin's SessionStart notice uses the
scoped `conflicts.list` count and links to that namespace's queue.

### Automatic retirements

When Loom retires memories on its own, each path that retired rows records them as
Expand Down
3 changes: 2 additions & 1 deletion docs/reference/operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ python scripts/codegen/docs_reference.py --check # exit 1 when a region is stal
<!-- Generated by `python scripts/codegen/docs_reference.py`; edit the source, not this region. -->
<!-- prettier-ignore-start -->

426 operations in 46 groups. Every op is served at `POST /v1/<op>` and, unless its line says otherwise, as the MCP tool `loom_<op>` (dots become underscores).
427 operations in 46 groups. Every op is served at `POST /v1/<op>` and, unless its line says otherwise, as the MCP tool `loom_<op>` (dots become underscores).

Columns: **Role** is the minimum role (`viewer` < `writer` < `admin` < `org_admin` < `platform_admin`); **Kind** is `read` (idempotent, viewer, unaudited, writes nothing — MCP `readOnlyHint`), `idempotent` (safe to retry) or `write`; **Listed under `all`** says whether an MCP connection on the `all` toolset lists the op in `tools/list` (`code.*` ops only with `LOOM_MCP_CODE_TOOLS=true`); an op marked `no` is still callable by name or through `loom_op`; an op marked `hidden` is not served over MCP, except where its line on its group's page names the one place that serves it; **Audit** marks ops that leave an `audit_log` row.

Expand Down Expand Up @@ -263,6 +263,7 @@ Fields for every `conflicts` op: [operations/conflicts.md](operations/conflicts.
| --- | --- | --- | --- | --- | --- |
| [`conflicts.allowlist_list`](operations/conflicts.md#conflictsallowlist_list) | List (memory_key, memory_key) pairs marked as known-non-conflicting so the conflicts worker stops flagging them. | viewer | read | hidden | |
| [`conflicts.allowlist_remove`](operations/conflicts.md#conflictsallowlist_remove) | Revoke an allow decision; the pair will re-flag on future writes. | admin | idempotent | hidden | yes |
| [`conflicts.bulk_accept`](operations/conflicts.md#conflictsbulk_accept) | Accept current hash-only resolver update suggestions independently. | admin | idempotent | hidden | yes |
| [`conflicts.list`](operations/conflicts.md#conflictslist) | List unresolved conflicts where two memories contradict each other. | viewer | read | hidden | |
| [`conflicts.propose_revision`](operations/conflicts.md#conflictspropose_revision) | Return non-destructive revise/contract/allow suggestions. | viewer | read | hidden | |
| [`conflicts.resolve`](operations/conflicts.md#conflictsresolve) | Pick the winner of a conflict (keep A, keep B, keep both, merge). | admin | idempotent | hidden | yes |
Expand Down
21 changes: 21 additions & 0 deletions docs/reference/operations/conflicts.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,26 @@ Revoke an allow decision; the pair will re-flag on future writes.
| --- | --- | --- |
| `removed` | `bool` | False when no live allowed pair matched. |

## `conflicts.bulk_accept`

Accept current hash-only resolver update suggestions independently.

`POST /v1/conflicts.bulk_accept` · MCP `loom_conflicts_bulk_accept` · role `admin` · idempotent · audited · not listed under the MCP `all` toolset

| Input field | Type | Default | Meaning |
| --- | --- | --- | --- |
| `org` | `str` | required | The tenant (first element of the identity tuple). |
| `namespace` | `str` | required | The namespace the op reads or writes. |
| `items` | `list[ConflictsResolverAcceptItem]` | required | Bounded so a request cannot monopolize the resolver or audit store. |

| Output field | Type | Meaning |
| --- | --- | --- |
| `results` | `list[_ConflictBulkResult]` | |
| `requested` | `int` | |
| `resolved` | `int` | |
| `stale` | `int` | |
| `failed` | `int` | |

## `conflicts.list`

List unresolved conflicts where two memories contradict each other.
Expand All @@ -66,6 +86,7 @@ List unresolved conflicts where two memories contradict each other.
| `next_before_version` | `int \| None` | Pass as `before_version` for the next page; null on the last page. |
| `total` | `int \| None` | The live conflicted count for the namespace; set on a count_only call. |
| `proposals` | `int \| None` | The pending proposals in the same scope, from the same read; set on a count_only call. |
| `backlog` | `ConflictBacklog \| None` | Row-based backlog split, present on `count_only`; reciprocal links are not pairs. |
| `keys` | `list[str] \| None` | The conflicted memory keys of the namespace; set on a keys_only call. |

## `conflicts.propose_revision`
Expand Down
1 change: 1 addition & 0 deletions docs/reference/operations/mentor.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ One agent's usage profile and the store's hints.
| `sessions` | `int` | Distinct client-named sessions of this agent in the window (`-` and `*` not counted). |
| `usage` | `dict[str, int]` | Calls per operation by this agent in the window, leaving out a `memory.get` of a repository's test cost row (key `repo:<id>/test-cost/pytest`), which a coding-agent plugin's prompt hook sends under the agent. |
| `planes` | `list[MentorPlane]` | Every plane the mentor knows, with this agent's calls to it (the sum of its ops' `usage` counts) and whether it is available. |
| `conflict_backlog` | `dict[str, dict[str, int]]` | Conflicted memory rows in this namespace, grouped by resolver state and trustworthy provenance. |
| `hints` | `list[MentorHint]` | The rules that fired for this agent, each with the counts that fired it; empty when none. |
| `adoption` | `list[MentorAdoption]` | Per hint code, sessions it was shown in and followed in, most shown first; empty when no hint reached the agent or the read failed. |
| `usage_evidence` | `list[UsageRung]` | The agent's use of Loom in the window, one rung each, weakest claim first: from a call made to a graded run. |
Expand Down
6 changes: 5 additions & 1 deletion docs/reference/operations/namespace.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ Fetch one namespace's metadata + settings (owner, visibility, feature flags, ret
| `rerank_endpoint` | `str \| None` | The reranker `memory.search` uses (a builtin or a configured endpoint's name); empty when none. |
| `classify_endpoint` | `str \| None` | URL `memory.set(classify=true)` calls to classify a write; empty when none. |
| `default_conflict_policy` | `str \| None` | How close writes are settled: `auto_reinforce` (the default when unset), `manual_review`, `newest_wins` or `append_only`. |
| `proposal_policy` | `ProposalPolicy \| None` | The owner's rule for proposals (`memory.set proposed=true`): under mode `auto`, `run.grade` rejects one once its failed graded runs reach `reject_after_fails` (0 = never), and no policy accepts one; the manual default when unset. |
| `captured_conflict_policy` | `str` | |
| `captured_conflict_confidence` | `float` | |
| `proposal_policy` | `ProposalPolicy \| None` | How proposals (`memory.set proposed=true`) are decided; the manual default when unset. |
| `code_change_policy` | `Literal['retire_removed', 'flag', 'revise'] \| None` | How reads treat the namespace's code-linked memories when their code changes: `retire_removed` (the default), `flag` or `revise`. |
| `curator_mode` | `str \| None` | Whether the curator's scheduled pass reads the namespace: `off` for a row that never set a mode, else the stored word (`findings`, `assist`, or a mode a newer build stored, served as it is). |
| `tag_registry` | `list[dict[str, Any]] \| None` | Per-tag configuration rows (retention, dedup threshold, hot quota, conflict policy); empty when none are registered. |
Expand Down Expand Up @@ -382,6 +384,8 @@ Create a shared memory workspace within an org; caller becomes admin.
| `classify_prompt_template` | `str \| None` | `None` | Text forwarded as `prompt_template` in every call to `classify_endpoint`. |
| `tag_registry` | `list[NamespaceTypeConfig]` | *(computed)* | Per-tag TTL + dedup_threshold registry, matched on tags at memory.set time. |
| `default_conflict_policy` | `Literal['auto_reinforce', 'manual_review', 'newest_wins', 'append_only'] \| None` | `None` | fresh: auto_reinforce |
| `captured_conflict_policy` | `Literal['manual_review', 'resolver_update'] \| None` | `None` | Captured integration conflicts stay human-reviewable unless the owner opts in. |
| `captured_conflict_confidence` | `float \| None` | `None` | Minimum resolver confidence for an opted-in captured-to-captured update. |
| `proposal_policy` | `ProposalPolicy \| None` | `None` | The owner's rule for proposals (facts written with memory.set proposed=true): under mode `auto`, `run.grade` rejects one once its failed graded runs reach `reject_after_fails` (0 = never), and no policy accepts one. |
| `code_change_policy` | `Literal['retire_removed', 'flag', 'revise'] \| None` | `None` | How reads treat this namespace's code-linked memories when their code changes: `retire_removed` (the default: search leaves out a memory whose code is all gone, and serves it again when the code returns), `flag` (only the links are marked)… |
| `curator_mode` | `Literal['off', 'findings', 'assist'] \| None` | `None` | `off`, `findings` or `assist`, which calls a model: In this mode the curator sends content of this namespace to the deployment's model provider: the namespace's guide and the text of each pending proposal of its shared scope that is not… |
Expand Down
4 changes: 2 additions & 2 deletions docs/reference/status.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ serves is in the [MCP reference](./mcp.md#toolsets).
<!-- Generated by `python scripts/codegen/docs_reference.py`; edit the source, not this region. -->
<!-- prettier-ignore-start -->

426 operations, 312 of them experimental.
427 operations, 313 of them experimental.

| Group | Stable | Experimental |
| --- | --- | --- |
Expand All @@ -37,7 +37,7 @@ serves is in the [MCP reference](./mcp.md#toolsets).
| `calibration` | 0 | [`calibration.get`](operations/calibration.md#calibrationget) |
| `code` | 28 | [`code.backport_gap`](operations/code.md#codebackport_gap), [`code.backport_gaps`](operations/code.md#codebackport_gaps), [`code.bisect_candidates`](operations/code.md#codebisect_candidates), [`code.blame_range`](operations/code.md#codeblame_range), [`code.callees`](operations/code.md#codecallees), [`code.conventions`](operations/code.md#codeconventions), [`code.coverage_claim`](operations/code.md#codecoverage_claim), [`code.edit_context`](operations/code.md#codeedit_context), [`code.examples`](operations/code.md#codeexamples), [`code.files`](operations/code.md#codefiles), [`code.first_build`](operations/code.md#codefirst_build), [`code.map`](operations/code.md#codemap), [`code.outline`](operations/code.md#codeoutline), [`code.path_guards`](operations/code.md#codepath_guards), [`code.pr_check`](operations/code.md#codepr_check), [`code.read`](operations/code.md#coderead), [`code.reindex`](operations/code.md#codereindex), [`code.repo.set_access`](operations/code.md#codereposet_access), [`code.repo.set_source`](operations/code.md#codereposet_source), [`code.review_brief`](operations/code.md#codereview_brief), [`code.setting_facts`](operations/code.md#codesetting_facts), [`code.symbol_history`](operations/code.md#codesymbol_history), [`code.test_gate`](operations/code.md#codetest_gate), [`code.test_home`](operations/code.md#codetest_home), [`code.tests_for`](operations/code.md#codetests_for), [`code.verify_citations`](operations/code.md#codeverify_citations) |
| `collection` | 0 | [`collection.budget_set`](operations/collection.md#collectionbudget_set), [`collection.create`](operations/collection.md#collectioncreate), [`collection.delete`](operations/collection.md#collectiondelete), [`collection.list`](operations/collection.md#collectionlist), [`collection.move`](operations/collection.md#collectionmove) |
| `conflicts` | 2 | [`conflicts.allowlist_list`](operations/conflicts.md#conflictsallowlist_list), [`conflicts.allowlist_remove`](operations/conflicts.md#conflictsallowlist_remove), [`conflicts.propose_revision`](operations/conflicts.md#conflictspropose_revision) |
| `conflicts` | 2 | [`conflicts.allowlist_list`](operations/conflicts.md#conflictsallowlist_list), [`conflicts.allowlist_remove`](operations/conflicts.md#conflictsallowlist_remove), [`conflicts.bulk_accept`](operations/conflicts.md#conflictsbulk_accept), [`conflicts.propose_revision`](operations/conflicts.md#conflictspropose_revision) |
| `connection` | 0 | [`connection.disconnect`](operations/connection.md#connectiondisconnect), [`connection.list`](operations/connection.md#connectionlist) |
| `consolidations` | 0 | [`consolidations.list`](operations/consolidations.md#consolidationslist) |
| `context` | 1 | [`context.fetch`](operations/context.md#contextfetch), [`context.offload`](operations/context.md#contextoffload) |
Expand Down
15 changes: 15 additions & 0 deletions frontend/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,7 @@ export interface ConflictRow {
content_sha256: string;
// A high row comes without its value; the inspector reads it by key.
sensitivity?: string;
capture_origin?: "claude-code" | "codex" | "";
}

/** The namespace's Review queue counts from one read: `total` conflicted and `proposals`
Expand All @@ -729,6 +730,19 @@ export function countReview(
export interface ReviewCounts {
total?: number | null;
proposals?: number | null;
backlog?: ConflictBacklog | null;
}

export interface ConflictSourceCounts {
plugin_captured: number;
caller_written: number;
unknown: number;
}

export interface ConflictBacklog {
pending_judgement: ConflictSourceCounts;
resolver_judged: ConflictSourceCounts;
cosine_only: ConflictSourceCounts;
}

// ===== cost.budget_status =====
Expand Down Expand Up @@ -981,6 +995,7 @@ export interface TokenCreated {
created_at: string;
expires_at: string | null;
mcp_url: string;
capture_origin?: "claude-code" | "codex" | null;
}

export interface BrowseEntry {
Expand Down
Loading