Skip to content
Draft
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ Rules decide only what to keep and how to organize it. The output schema, tools

### Traceable and governed

- **Shared Topic Memory.** Publish exact revisions across Scopes and refresh shared copies with traceable source revisions.
- **Evidence behind every memory:** each memory traces back to its source evidence and exact revision, and can point to the precise location in the source.
- **Task outcomes:** Claude Code, Codex, and OpenCode get per-turn guidance to record evidence at actual task completion or explicit interruption.
- **Reviewed changes:** generated experiences and skills are recalled only after review; Dream revisions take effect after your approval; outdated memories can be retired while their history is kept.
Expand Down
1 change: 1 addition & 0 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@

### 可追溯与可管控

- **共享主题记忆。** 可跨 Scope 发布精确版本、刷新共享副本并追溯源版本。
- **有据可查:** 每条记忆都能追溯到来源证据和精确版本,并可定位到来源中的具体位置。
- **任务结果:** Claude Code、Codex 和 OpenCode 每轮都会收到指引,在任务实际完成或明确中断时记录证据。
- **改动经过审核:** 生成的经验和技能经审核后才会被召回;Dream 的修订由你批准后生效;过时的记忆可以停用,历史版本保留。
Expand Down
1 change: 1 addition & 0 deletions README_JP.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@

### 追跡と統制

- **共有 Topic Memory。** Scope 間で正確なリビジョンを公開し、公開元を追跡できる共有コピーを更新できます。
- **根拠のある記憶:** それぞれの記憶は、根拠となる Source と正確なリビジョンまでたどれ、Source 内の具体的な位置も示せます。
- **タスクの結果:** Claude Code、Codex、OpenCode には、タスクが完了するか明示的に中断された時点で根拠を記録するよう、各ターンで案内が提示されます。
- **レビューを経た変更:** 生成された経験とスキルはレビュー後にのみ想起され、Dream の改訂はあなたの承認後に反映されます。古くなった記憶は履歴を残したまま無効化できます。
Expand Down
21 changes: 21 additions & 0 deletions desktop/src-tauri/src/connections/compatibility.json
Original file line number Diff line number Diff line change
Expand Up @@ -2001,5 +2001,26 @@
"remember_memory",
"search_memory"
]
},
{
"id": "sqlite-topic-publication-1a98d826-linux-v1",
"serverCommit": "working-tree-sha256:1a98d82630a0c5948a8aac6c2d705bee175e3c079fbfe0e46096a2d2cba1f695",
"contractSha256": "ddf2bd3e3fd30bae24c950322ea81c708402409b61b7df02de0fd5dcb85f21b9",
"artifactSha256": "d79156896f36bec43b503febed50c5f5d0bd7534dd10574f3a04c0cac89e3b27",
"operations": [
"get_access_principal",
"get_artifact_revision",
"get_capabilities",
"get_connection_identity",
"get_default_scope",
"get_liveness",
"get_readiness",
"get_scope",
"get_server_info",
"get_stats",
"list_scopes",
"remember_memory",
"search_memory"
]
}
]
2 changes: 1 addition & 1 deletion desktop/src-tauri/src/transport/operations.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"contractSha256": "32a8aebe3ac5b5eb388e03e0b0e25fc95ea232b10b94caf16323bd369cd7bf69",
"contractSha256": "ddf2bd3e3fd30bae24c950322ea81c708402409b61b7df02de0fd5dcb85f21b9",
"operations": {
"get_liveness": {
"method": "GET",
Expand Down
33 changes: 33 additions & 0 deletions desktop/src-tauri/src/transport/wire.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,9 @@ pub struct ArtifactRevision {
pub artifacts: Vec<ArtifactReference>,
#[serde(rename = "content_digest")]
pub content_digest: String,
#[ts(optional)]
#[serde(rename = "published_from", skip_serializing_if = "Option::is_none")]
pub published_from: Option<TopicMemoryPublicationSource>,
/// When this revision was committed. Absent for revisions stored before this field existed.
#[ts(optional)]
#[ts(type = "string | null")]
Expand Down Expand Up @@ -518,6 +521,7 @@ impl ArtifactRevision {
sources,
artifacts,
content_digest,
published_from: None,
created_at: None,
created_by: None,
restored_from_revision: None,
Expand Down Expand Up @@ -2941,6 +2945,34 @@ impl TokenEstimatorProfile {
}
}

/// TopicMemoryPublicationSource : Exact source selected when this Topic Memory revision was published across Scopes.
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, TS)]
#[serde(deny_unknown_fields)]
pub struct TopicMemoryPublicationSource {
#[serde(rename = "scope_id")]
pub scope_id: String,
#[serde(rename = "artifact_id")]
pub artifact_id: String,
#[serde(rename = "revision")]
pub revision: i64,
}

impl TopicMemoryPublicationSource {
/// Exact source selected when this Topic Memory revision was published across Scopes.
#[allow(clippy::too_many_arguments)]
pub fn new(
scope_id: String,
artifact_id: String,
revision: i64,
) -> TopicMemoryPublicationSource {
TopicMemoryPublicationSource {
scope_id,
artifact_id,
revision,
}
}
}

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, TS)]
#[serde(deny_unknown_fields)]
pub struct UsageStatistics {
Expand Down Expand Up @@ -3079,6 +3111,7 @@ pub fn declarations(config: &ts_rs::Config) -> Vec<String> {
<TagMatch as ts_rs::TS>::decl(config),
<Timezone as ts_rs::TS>::decl(config),
<TokenEstimatorProfile as ts_rs::TS>::decl(config),
<TopicMemoryPublicationSource as ts_rs::TS>::decl(config),
<Type as ts_rs::TS>::decl(config),
<UsageStatistics as ts_rs::TS>::decl(config),
]
Expand Down
12 changes: 11 additions & 1 deletion desktop/ui/src/generated/api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ export interface paths {
put?: never;
/**
* Publish one exact Artifact revision into another Scope
* @description Memory publication is rejected until its complete family-owned state can be created atomically in the target Scope. Prompt publication is rejected because Prompt identities must be registered operation keys. Configure the target Scope through the Artifact Create and Replace APIs instead. Profile artifacts cannot be copied or published across Scopes, whether or not the target already has a Profile. Requests for these families return HTTP 422 with code artifact_publication_unsupported and details.family. Rejection creates no target Artifact or publication record; other supported families retain their existing behavior. Topic Memory publication requires scope.admin in both Scopes and atomically copies the exact revision with its retrieval indexes into a new target identity. Tags and direct Sources are not copied. Completed idempotent retries do not require embedding inference. Deliver a user-selected exact Artifact revision to an explicitly selected target Scope. Never infer latest, publish unrelated history, or treat a handoff preview as publication authority. The returned target artifact is independent; publication does not move Sources or authorize its execution.
* @description Memory publication is rejected until its complete family-owned state can be created atomically in the target Scope. Prompt publication is rejected because Prompt identities must be registered operation keys. Configure the target Scope through the Artifact Create and Replace APIs instead. Profile artifacts cannot be copied or published across Scopes, whether or not the target already has a Profile. Requests for these families return HTTP 422 with code artifact_publication_unsupported and details.family. Rejection creates no target Artifact or publication record; other supported families retain their existing behavior. Topic Memory publication requires scope.contribute in both Scopes. The first publication copies the exact revision and its retrieval indexes into a new target identity. Reuse the key with a newer revision of the same source Topic to refresh that identity when the content changes. Already published, older and identical-content revisions are skipped. Tags and direct Sources are not copied. Skipped requests do not require embedding inference. Deliver a user-selected exact Artifact revision to an explicitly selected target Scope. Never infer latest, publish unrelated history, or treat a handoff preview as publication authority. The returned target artifact is independent; publication does not move Sources or authorize its execution.
*/
post: operations["publish_artifact"];
delete?: never;
Expand Down Expand Up @@ -3139,6 +3139,7 @@ export interface components {
sources: components["schemas"]["SourceTypeReference"][];
artifacts: components["schemas"]["ArtifactReference"][];
content_digest: string;
published_from?: components["schemas"]["TopicMemoryPublicationSource"];
/**
* Format: date-time
* @description When this revision was committed. Absent for revisions stored before this field existed.
Expand Down Expand Up @@ -5885,6 +5886,13 @@ export interface components {
summary: string;
detail: string;
source_refs: components["schemas"]["SourceReference"][];
published_from?: components["schemas"]["TopicMemoryPublicationSource"];
};
/** @description Exact source selected when this Topic Memory revision was published across Scopes. */
TopicMemoryPublicationSource: {
scope_id: string;
artifact_id: string;
revision: number;
};
/** @description A built-in family's creation request, or the complete content of an Artifact in a loaded plugin's family. The family name selects the branch: built-in names select the built-in branch. */
CreateArtifactRequest: components["schemas"]["CreateBuiltinArtifactRequest"] | components["schemas"]["CreatePluginArtifactRequest"];
Expand Down Expand Up @@ -7390,6 +7398,8 @@ export interface operations {
/** @description Independent target Artifact and its exact source provenance. */
201: {
headers: {
/** @description Whether the request created, reused, or refreshed a publication. */
"X-Publication-Outcome"?: "created" | "skipped" | "replaced";
[name: string]: unknown;
};
content: {
Expand Down
3 changes: 2 additions & 1 deletion desktop/ui/src/generated/ipc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export type ArtifactFamilyAccessCapability = { family: string, enabled: boolean,
export type ArtifactInventoryStatistics = { total: number, by_family: Array<FamilyCount>, };
export type ArtifactReadFamily = string;
export type ArtifactReference = { family: string, artifact_id: string, revision: number, };
export type ArtifactRevision = { scope_id: string, family: string, artifact_id: string, revision: number, content: Record<string, unknown>, sources: Array<SourceTypeReference>, artifacts: Array<ArtifactReference>, content_digest: string,
export type ArtifactRevision = { scope_id: string, family: string, artifact_id: string, revision: number, content: Record<string, unknown>, sources: Array<SourceTypeReference>, artifacts: Array<ArtifactReference>, content_digest: string, published_from?: TopicMemoryPublicationSource,
/**
* When this revision was committed. Absent for revisions stored before this field existed.
*/
Expand Down Expand Up @@ -408,5 +408,6 @@ export type TagFilter = { tags: Array<string>, match?: TagMatch, };
export type TagMatch = "all" | "any";
export type Timezone = "UTC";
export type TokenEstimatorProfile = { estimator_id: string, version: string, };
export type TopicMemoryPublicationSource = { scope_id: string, artifact_id: string, revision: number, };
export type Type = "user" | "service";
export type UsageStatistics = { period: ResolvedUsagePeriod, totals: ModelUsageStatistics, by_purpose: Array<ModelUsagePurposeBreakdown>, daily: Array<ModelUsageDay>, };
2 changes: 1 addition & 1 deletion desktop/ui/src/generated/operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

// Generated from openapi/powercontext.yaml. Do not edit.
export const contractSha256 = "32a8aebe3ac5b5eb388e03e0b0e25fc95ea232b10b94caf16323bd369cd7bf69";
export const contractSha256 = "ddf2bd3e3fd30bae24c950322ea81c708402409b61b7df02de0fd5dcb85f21b9";
export const operations = {
"get_liveness": {
"method": "GET",
Expand Down
11 changes: 6 additions & 5 deletions docs/en/docs/develop/http-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,12 @@ retargets their valid grants to the corresponding Atomic Memory. Unknown Familie
and mismatched selectors or roles never create a Binding. `/v1/access/me` reports the current mode, Provider
capabilities, and each Artifact Family's enabled state.

Cross-Scope Artifact publication uses `POST /v1/artifact-publications`. The request selects an exact source Revision,
but authorization checks `artifact.share` on its logical `{family, artifact_id}` identity and `scope.admin` on the
target Scope. Consequently, one logical sharing grant covers earlier and later source Revisions while every
publication still records the exact copied Revision and its provenance. Host-local projection remains an
operational surface protected by the corresponding Scope and Artifact checks.
Cross-Scope Artifact publication uses `POST /v1/artifact-publications` and selects an exact source Revision.
Topic Memory requires `scope.contribute` in both Scopes and supports refreshing the target with the same key.
Other supported families require `artifact.share` on the logical `{family, artifact_id}` and `scope.admin` on the
target Scope. A logical sharing grant covers earlier and later source Revisions, and each publication records the
exact Revision copied. Host-local projection uses the corresponding Scope and Artifact checks.
See [Topic Memory](../workflows/topic-memory.md) for refresh outcomes and provenance.

Atomic Memory does not support cross-Scope publication. Prompt publication returns `422 / artifact_publication_unsupported` without creating a target Artifact. To configure
a Prompt in another Scope, use `POST /v1/scopes/{scope_id}/artifacts` with `family=prompt` and a registered `prompt_key`,
Expand Down
16 changes: 13 additions & 3 deletions docs/en/docs/workflows/topic-memory.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,19 @@ through that chain. Revisions already stored keep the lineage they were written
Manage tags as described in [Organize with tags](manage-artifact-tags.md); whole-Artifact Topic Memory tags are
read with `scope.read` and modified with `scope.admin`.

Publish one exact Revision into another Scope with `POST /v1/artifact-publications`, which requires `scope.admin` in
both the source and target Scopes. Publication creates an independent identity in the target Scope and carries its
retrieval indexes; tags and direct Sources are not copied.
Publish one exact Revision into an explicitly selected Scope with `POST /v1/artifact-publications`. You need
`scope.contribute` in both Scopes. The first publication creates an independent target Artifact and builds its
retrieval indexes. The target gets its own tags and has no direct Sources copied from the source.

Reuse the same `idempotency_key` in the target Scope to refresh the copy from a newer Revision of the same Topic.
A refresh with changed content appends a target Revision and updates its search indexes while keeping its Artifact ID.
The `X-Publication-Outcome` response header is `created` for a new copy, `replaced` for a refresh, or `skipped` for
an older, already published, or identical-content Revision. A skipped request returns the most recent publication.
A different source Topic using the same key returns HTTP 409.

The current and exact detail responses for a published Revision include `published_from` with the source
`scope_id`, `artifact_id`, and `revision` selected for that publication. This field is omitted for ordinary
topic Revisions. Seeing provenance does not grant access to the source Scope.

## Assemble into PreparedContext

Expand Down
14 changes: 9 additions & 5 deletions docs/en/rfcs/1614_topic_memory_generic_api_completion.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,29 +124,33 @@ Pagination is a boundary over a live collection, not a cross-request snapshot. T
| Existing reads, tag reads/queries, filtered lists | `scope.read` |
| Create | `scope.contribute` |
| Replace and replace tags | `scope.admin` |
| Cross-Scope publish | `scope.admin` in both source and target |
| Cross-Scope publish | `scope.contribute` in both source and target |

Topics are shared Scope knowledge, including automatically generated topics without a single owner. Do not introduce per-topic Artifact ownership or sharing. Skip the generic owner-establishment hooks for Topic Memory creation and publication; otherwise a successful data commit could be followed by an unsupported resource error.

Source administrator permission authorizes exporting the whole topic; read access alone does not. Target administrator permission authorizes introducing external knowledge. Topic-specific resolvers return Scope resources while retaining other families' rules.
Source contributor permission authorizes exporting the whole topic. Target contributor permission authorizes introducing external knowledge. Topic-specific resolvers return Scope resources while retaining other families' rules.

Embedded calls retain the trusted-host model; protected HTTP/MCP entrypoints enforce these requirements. Cover enabled/shadow/disabled modes and enabled-mode denial cases. Provenance never grants access to source Scope content.

## 8. Cross-Scope publication

### 8.1 Exact content and target state

Reuse PublishArtifactRequest with a complete source address, including revision. A published historical revision is eligible. Generate a new target ID and revision 1 with identical content; never merge matching titles or overwrite a target topic.
Reuse PublishArtifactRequest with a complete source address, including revision. A published historical revision is eligible. The first publication creates target revision 1 with identical content and a new artifact ID. A refresh from the same source Topic appends a target revision with the same artifact ID. Matching titles have no effect on target identity.

Validate the source's Topic Memory publication record. Prepare projections using the target deployment's retrieval shape rather than copying source index rows. Use target transaction time for published_at and list ordering.

Preserve existing publication_source/publication_digest and ArtifactPublication provenance, including repeated-publication chain semantics. Do not place source-local SourceRef/ArtifactRef values into target-local lineage. A pure published copy has no direct Sources and source_count is zero. Do not copy tags, permissions, or Worker cursor/pending state.
Preserve existing publication_source/publication_digest and ArtifactPublication provenance, including repeated-publication chain semantics. Detail responses for published Topic Memory expose the exact selected source as `published_from`. Keep source-local SourceRef/ArtifactRef values out of target-local lineage. A pure published copy has no direct Sources and source_count is zero. Do not copy tags, permissions, or Worker cursor/pending state.

### 8.2 Transaction and idempotency

Add a family-owned repository publication method that performs base copying, Topic Memory activation, and the generic publication record in one transaction. It may internally reuse copy_exact and activation, but callers must not commit the base copy first or invoke private repository methods directly.

Retain target_scope_id/idempotency_key uniqueness. The same full request returns the original target; a different request with the same key returns 409. Concurrent duplicates leave at most one complete target and no orphan Artifact. Look up successful requests before expensive preparation, then recheck in the transaction. Replaying success must not depend on Embedding availability.
Bind each key within the target Scope to one source Topic and one target Artifact. A newer source revision with changed
content refreshes the target. Older, already published, and identical-content revisions return the latest successful
publication without writing or calling Embedding. Reusing the key for a different source still returns 409. Report the
outcome in `X-Publication-Outcome` as `created`, `skipped`, or `replaced`. Look up the key before projection preparation
and recheck it in the write transaction so concurrent requests cannot create duplicate Artifacts or move the publication backwards.

Missing revisions return 404. A missing required Topic Memory publication record is a storage invariant failure and must not write a target. Index or publication-record failure rolls back all target state. Validate publication through dedicated get/search, standard list/get, and restart integrity checks.

Expand Down
Loading
Loading