Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
83d71ac
feat(desktop): integrate exact-Scope statistics through native IPC
WuShang-d Oct 24, 2026
34c61c5
feat(desktop): visualize current-Scope inventory and usage
WuShang-d Oct 24, 2026
bde9972
test(desktop): validate native statistics journeys and zoom
WuShang-d Oct 24, 2026
0cc9036
fix(desktop): sync statistics with master and repair docs links
WuShang-d Oct 24, 2026
7f6ef3c
fix(desktop): merge current master and refresh statistics qualification
WuShang-d Oct 26, 2026
434859f
fix(desktop): reconcile master and preserve server fixture cleanup
WuShang-d Oct 27, 2026
1c7911c
fix(desktop): wire inventory panel and integrate discovery
WuShang-d Oct 28, 2026
9341edb
fix(desktop): integrate current master and session observations
WuShang-d Oct 29, 2026
f13d065
docs(desktop): preserve qualification evidence when merging master
WuShang-d Oct 30, 2026
79ccd1c
fix(desktop): integrate current contracts and lockfile baseline
WuShang-d Oct 30, 2026
89e1553
fix(ci): align migration and Code fixtures with current master
WuShang-d Oct 31, 2026
9e7d8d8
fix(desktop): distinguish pending statistics context
WuShang-d Oct 31, 2026
4f0be5e
fix(desktop): qualify bundled statistics through product path
WuShang-d Nov 1, 2026
5bb0b7e
fix(desktop): preserve statistics qualification on receipt contract
WuShang-d Nov 2, 2026
eb30a2d
fix(desktop): integrate deployment fencing and current qualification
WuShang-d Nov 3, 2026
31e9294
ci: rerun validation after SQLite concurrency failure
WuShang-d Nov 3, 2026
daddf65
fix(desktop): integrate statistics with session observation UI
WuShang-d Nov 4, 2026
31e5392
fix(desktop): qualify statistics after ownership contract update
WuShang-d Nov 4, 2026
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 @@ -318,6 +318,7 @@ Coding and memory evaluations, performance benchmarks, and Skill regressions liv

## Learn more

- [Desktop preview: exact-Scope inventory and usage](desktop/README.md#current-scope-inventory-and-usage)
- [Get started](https://powercontext.oceanbase.io/en/docs/get-started/quickstart/)
- [Connect Agents](https://powercontext.oceanbase.io/en/docs/integrations/)
- [Manage context](https://powercontext.oceanbase.io/en/docs/workflows/)
Expand Down
1 change: 1 addition & 0 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ make test

## 进一步了解

- [桌面预览:精确范围的存量与用量](desktop/README.zh.md#当前范围的存量与用量)
- [开始使用](https://powercontext.oceanbase.io/zh/docs/get-started/quickstart/)
- [接入 Agent](https://powercontext.oceanbase.io/zh/docs/integrations/)
- [管理上下文](https://powercontext.oceanbase.io/zh/docs/workflows/)
Expand Down
16 changes: 15 additions & 1 deletion desktop/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,23 @@ Search uses FTS in the selected Scope and returns at most 10 matches. This is no

A successful save that returns no memory record is reported as an operation success without inventing a reference. A timeout or interrupted dispatched write is **unknown**, not a safe invitation to retry: inspect the original Server/Scope before deciding whether to submit again. Identical text alone cannot identify that operation. Desktop does not automatically replay writes or keep an offline queue. Switching context hides old results while retaining minimal original-operation metadata for this session. See [validation guide](VALIDATION.md) for tested behavior and qualification gaps.

## Current-Scope inventory and usage

In **Overview**, explicitly activate a qualified connection, select an exact Scope,
choose **Today**, **Last 7 days** or **Last 30 days**, then press **Load statistics**.
The view displays the Server timestamp, Scope coverage, inventory snapshot,
recorded UTC model usage and recall token estimates. Missing token counts remain
**Unknown**; estimates are not billing savings or quality scores. Every chart has
an equivalent table and keyboard-scrollable region. A statistics error does not
disable independent Memory actions. See the [developer contract](../docs/en/development/desktop-statistics.md)
and [qualification evidence](VALIDATION.md#current-scope-statistics-qualification).

Statistics require the explicit `sqlite-stats-bad4c0c2-v1` profile; the separately
qualified `sqlite-atomic-dd62723d-v1` profile covers Memory operations only.

## Contracts and resources

`pnpm --dir desktop generate` derives TypeScript schemas, the reviewed ten-operation manifest, and the Rust wire models from `openapi/powercontext.yaml`; `generate:check` detects drift, including a normalized contract SHA-256. The OpenAPI Generator CLI version is pinned in `desktop/openapitools.json`, and the limited Rust customization lives in `desktop/scripts/openapi-generator/rust/`. Generated `src-tauri/src/transport/wire.rs` must not be edited by hand: after changing the contract or generator template, run `pnpm --dir desktop generate`, then run `pnpm --dir desktop generate:check` in CI. Typed Rust adapters consume that generated manifest and generated wire schemas. No public route is independently handwritten in the application. The manifest is not an IPC permission grant.
`pnpm --dir desktop generate` derives TypeScript schemas, the reviewed eleven-operation manifest, and the Rust wire models from `openapi/powercontext.yaml`; `generate:check` detects drift, including a normalized contract SHA-256. The OpenAPI Generator CLI version is pinned in `desktop/openapitools.json`, and the limited Rust customization lives in `desktop/scripts/openapi-generator/rust/`. Generated `src-tauri/src/transport/wire.rs` must not be edited by hand: after changing the contract or generator template, run `pnpm --dir desktop generate`, then run `pnpm --dir desktop generate:check` in CI. Typed Rust adapters consume that generated manifest and generated wire schemas. No public route is independently handwritten in the application. The manifest is not an IPC permission grant.

`cargo run --locked --manifest-path desktop/src-tauri/Cargo.toml --example export_ipc` derives the TypeScript IPC request/receipt/error types from Rust. `ipc:check` verifies them. IPC exposes typed connection, Scope, memory and diagnostic operations to the main window only; no generic fetch, shell, file, database or secret-read command is granted.

Expand Down
14 changes: 13 additions & 1 deletion desktop/README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ pnpm --dir desktop desktop:dev

工程边界:

- OpenAPI 自动派生的 TypeScript schema 和十项 operation 映射,包含契约摘要及漂移检查。
- OpenAPI 自动派生的 TypeScript schema 和十一项 operation 映射,包含契约摘要及漂移检查。
- `desktop/openapitools.json` 固定 OpenAPI Generator CLI 版本,Rust 模板位于 `desktop/scripts/openapi-generator/rust/`。修改 OpenAPI 合同或模板后,在仓库根目录执行 `pnpm --dir desktop generate`,不要手动编辑生成的 `src-tauri/src/transport/wire.rs`;CI 通过 `pnpm --dir desktop generate:check` 检查生成结果是否漂移。
- Rust 自动派生的 IPC 类型与安全错误;凭据只写请求必须显式选择持久化或仅会话,成功回执只含存储模式,不含秘密或凭据标识。
- Windows Credential Manager 原生适配器;保存失败直接报错,只有显式选择才采用仅会话内存。秘密类型不支持序列化,不实现 Debug。
Expand Down Expand Up @@ -117,6 +117,18 @@ Desktop 在每次诊断前检查固定路径和摘要,然后只允许 `service

[验证说明](VALIDATION.md)列出可复现的检查方式和待完成的平台、产品验收项。

## 当前范围的存量与用量

统计需要显式选择 `sqlite-stats-bad4c0c2-v1` 配置;独立验证的
`sqlite-atomic-dd62723d-v1` 配置仅覆盖 Memory 操作。

在“总览”中显式启用已验证兼容的连接、选择精确范围和“今天/最近 7 天/最近
30 天”后,点击“加载统计”。页面展示 Server 时间、范围覆盖、存量快照、已记录
的 UTC 模型用量和召回 token 估算。缺失 token 数保持“未知”;估算不代表账单
节省或质量提升。每个图表均有等价表格,滚动区域可通过键盘聚焦。统计错误不禁用
独立的 Memory 操作。详见[开发契约](../docs/zh/development/desktop-statistics.md)和
[资格证据](VALIDATION.md#current-scope-statistics-qualification)。

## 远程安装包验收

Windows GitHub Actions 会构建未签名安装包,安装到临时中文路径,并通过匹配且验证 Microsoft 签名的 WebDriver 操作实际安装的 WebView2 页面。测试使用独立 SQLite Server,覆盖启用连接、精确范围选择、中文多行笔记保存、全文查找、精确阅读,以及正文和引用复制后的粘贴核对。Server 使用合成数据,测试结束后清理。
Expand Down
105 changes: 104 additions & 1 deletion desktop/VALIDATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,115 @@ cargo test --locked --manifest-path desktop/src-tauri/Cargo.toml

## Compatibility scope

[compatibility.json](src-tauri/src/connections/compatibility.json) preserves the recorded Server sources, normalized OpenAPI contract digests and qualification-wheel digests for the historical profiles below. The current contract has source-specific qualifications `sqlite-atomic-dd62723d-v1` and `sqlite-atomic-4ffdf4e9-v1` below. Ordinary builds require explicitly selecting the record whose tested Server source and wheel match the deployment, then checking the connection before business operations become available. The `dd62723d` record covers the migration-framework sources; the `4ffdf4e9` record covers the earlier release-preparation sources. The `sqlite-atomic-98275dbb-v1`, `sqlite-atomic-1da99747-v1`, `sqlite-atomic-8f10c560-v1`, `sqlite-atomic-d9a78567-v1`, `sqlite-atomic-caf2a35a-v1`, `sqlite-atomic-683e2db0-v1` and `sqlite-atomic-cab054db-v1` records qualify their corresponding Server source deployments and do not match this bundled contract. Historical records are disabled in the selector, and saved unavailable selections remain visible until explicitly replaced. CI builds have their own artifact identities and do not change product qualification.
[compatibility.json](src-tauri/src/connections/compatibility.json) preserves the recorded Server sources, normalized OpenAPI contract digests and qualification-wheel digests for the historical profiles below. The current contract has source-specific qualifications `sqlite-stats-bad4c0c2-v1` (including statistics), `sqlite-atomic-dd62723d-v1` and `sqlite-atomic-4ffdf4e9-v1` (Memory operations) below. Ordinary builds require explicitly selecting the record whose tested Server source and wheel match the deployment, then checking the connection before business operations become available. The `dd62723d` record covers the migration-framework sources; the `4ffdf4e9` record covers the earlier release-preparation sources. The `sqlite-stats-31ecdd61-v1`, `sqlite-stats-1da99747-v1`, `sqlite-atomic-98275dbb-v1`, `sqlite-atomic-1da99747-v1`, `sqlite-atomic-8f10c560-v1`, `sqlite-atomic-d9a78567-v1`, `sqlite-atomic-caf2a35a-v1`, `sqlite-atomic-683e2db0-v1` and `sqlite-atomic-cab054db-v1` records qualify their corresponding Server source deployments and do not match this bundled contract. Historical records are disabled in the selector, and saved unavailable selections remain visible until explicitly replaced. CI builds have their own artifact identities and do not change product qualification.

The real Server harness covers SQLite with anonymous loopback, static Bearer, HTTPS with explicit CA/base path, and injected-provider/enforced access. It exercises save/search/exact reads, identity changes, binding revocation, ambiguous writes without replay and Scope pagination. Installed UI checks cover repeated launches preserving the existing editor, late committed-save responses preserving a new Scope draft, explicit connection/Scope selection, clipboard copies, connection isolation, draft cancellation, byte limits and independent Server survival after Desktop exit.

Selecting a compatibility profile does not attest the remote binary identity. Existing `sqlite-1.1.1-v1` / `sqlite-63f918b7-v1` / `sqlite-ab43e3a7-v1` / `sqlite-f1089f4e-v1` / `sqlite-6e237568-v1` / `sqlite-legacy-58f7f4f6-v1` selections require explicitly choosing an available matching profile and rechecking the connection. Desktop reads memories only through Atomic Memory references, so Servers that answer only with Memory entry citations are not qualified. CLI diagnostics separately verify the registered executable path and digest, then validate the diagnostic response schema. The observed version is optional report information; a registration does not require a version.

### Current-Scope statistics qualification

#### Server bad4c0c2 statistics qualification

`sqlite-stats-bad4c0c2-v1` qualifies Server sources at
`bad4c0c23fb6f8febbb91d5da050a6765a5887a2`, normalized contract digest
`c12901b88b8e958c9cd63469298b9a04b9d5e2b0b4564d83b50f7ae95542519a`, and wheel
`powercontext-1.4.1.dev180+g7f6ef3c02.d20261027-py3-none-any.whl`, SHA-256
`0f5e5be815b143a63dc605d93c741b0251717e1db0af2c32fe1a98acad758c7d`.
All 609 packaged runtime files match the recorded Server commit byte for byte.
The sorted `path sha256` manifest, newline terminated, hashes to
`4d0dc40f50bdd5bfb151c1169ad6c41af3466ad777d7ee65a26a39f7852fb083`.
The wheel was built with local Desktop merge changes; Server runtime, OpenAPI
and dependency-lock sources match the recorded commit.

On 2026-10-27, macOS ARM64 with Python 3.12.13 and Rust 1.95.0 ran the native
`ConnectionManager` / `server_probe` against independent SQLite Server processes
from that wheel. Anonymous loopback, Bearer loopback, HTTPS with CA/base path and
enforced-provider modes passed. Exact-Scope statistics cover empty and persisted
inventory, today/7d/30d UTC periods, zero usage, partial token reports and permission
revocation without fallback. The partial reports are explicit inputs to the real
Runtime recorder, not evidence of model-provider calls. The merged harness retains
bounded request-completion diagnostics and Server cleanup; the four runs completed.
Source identity and harness output are generated under `.artifacts/stats-bad4c0c2/`
and `.artifacts/real-server.json`. This is protocol qualification for the recorded
sources and wheel; installed-platform and release acceptance remain separate.

#### Server 31ecdd61 statistics qualification

`sqlite-stats-31ecdd61-v1` qualifies Server sources at
`31ecdd61beadb7ac8de5da20998dead9a9e07845`, normalized contract digest
`3165f114185aa403b563c936d5fbd0829388628f4a37540d9d1519202a07871c`, and wheel
`powercontext-1.4.1.dev157+g0cc9036b0.d20261026-py3-none-any.whl`, SHA-256
`7a17cf9c641d1fa7ae9635204b605aedca8e33f0ceddc0bf8fcd9dd02667cb4b`.
All 552 packaged runtime files match that Server commit byte for byte. The sorted
`path sha256` manifest, newline terminated, hashes to
`9dbada6473027441b6b4934803d9efe718e84a48b4f77723d41b0de414eea125`.
The wheel was built with local Desktop merge changes; its Server runtime,
OpenAPI contract and dependency lock match the recorded sources.

On 2026-10-26, macOS ARM64 with Python 3.12.13 and Rust 1.95.0 ran the native
`ConnectionManager` / `server_probe` against independent SQLite processes from
that wheel. Anonymous loopback, Bearer loopback, HTTPS with CA/base path and
enforced-provider modes passed. The eleven operations include exact-Scope
statistics: empty and persisted inventory, today/7d/30d UTC periods, zero usage,
partial token reports and permission revocation. Partial reports are seeded via
the real Runtime recorder, not observed model-provider calls. Identity changes,
exact reads and ambiguous writes retain the existing harness checks.
Evidence is generated under `.artifacts/stats-31ecdd61/` and `.artifacts/real-server.json`.
This qualifies the recorded protocol and sources; installed UI and release
acceptance require the checks for their corresponding Desktop head.

#### Server 1da99747 statistics qualification (historical)

`sqlite-stats-1da99747-v1` records Server commit
`1da997476651c2850ff7141e2b7cd512d0152a90`, contract digest
`5878999ce9e239d6642e4da858074b281ed465629432c578b3584eec47cbce6c`, and wheel
`powercontext-1.4.1.dev139+g1da997476.d20261024-py3-none-any.whl` with SHA-256
`4eda168954bb5950aa4f0bbc0d534b2b2bdb15ff43f97de7df279963c46c70a8`.
All 457 Python runtime files in that wheel match the checkout's runtime sources;
their sorted `path sha256` manifest, newline terminated, hashes to
`49fe8325db1955ee250c3a76a8efad3d87fc393dc1007a95817524f38ded41ad`.
The Desktop adapter and harness had local changes during this run; the Server
runtime, OpenAPI contract and dependency lock matched the recorded commit.

On macOS 26.7 ARM64, Python 3.12.13 and Rust 1.95.0, the native `ConnectionManager`
and `ServerApi` passed the isolated built-wheel harness in anonymous loopback,
Bearer loopback, HTTPS with explicit CA/base path, and enforced-provider modes.
The eleven recorded operations include `get_stats`. Statistics checks exercise
the exact Scope, genuine empty inventory, `today`/`7d`/`30d` UTC periods,
persisted Memory inventory, no-model zero usage, and same-Principal permission
revocation without selection fallback. Partial provider usage is explicitly
seeded through the real Runtime recorder: two generation requests, unknown input
tokens and nine output tokens survive persistence, aggregation and native parsing.
This seeded input does not establish that an actual model provider emitted it.

Synthetic native tests separately cover cancellation, changed Scope, independent
Memory cancellation, response bounds, and invalid response selection/period.
The harness reports are generated under `.artifacts/`; reproduce them with
`fixture_qualification.py`, the `server_probe` example and `real_server.py`.
These results qualify the observed Server protocol.

The bundled macOS ARM64 debug app was also exercised against two isolated real
Servers on this host, using an isolated application identifier and an 800 × 600
window. The build used Desktop `34c61c5f` plus the main-window zoom permission
in this PR; its executable SHA-256 is
`43d0d149d3194739171ffb70a57736280c14d2cd3d63fe47001c8f2b3381065d`.
Observed results include explicit activation after restart, empty inventory,
Chinese and English partial-token displays, clearing on Scope/connection changes,
and the second Server's independent one-entry inventory with zero usage.
Command+0 followed by five Command+= steps exercised 200% webview zoom, including
a successful statistics reload. The zoom IPC permission is restricted to the
trusted local main window. This was a bundled debug-app check, not installer,
IME, screen-reader, signing or complete accessibility acceptance.

`installed_statistics.py` extends the Windows installed WebDriver journey with
independent real `/v1/stats` table comparisons, all three UTC periods, bilingual
unknown-token handling, and Scope/connection isolation. Its fixture and Python
checks ran locally; the Windows UI journey requires actual Windows execution.
Hosted workflows at `34c61c5f` required maintainer approval (`action_required`),
so that head had no Windows acceptance result. Intel and release gates remain
separate.

### Current Server protocol qualification

#### Server 4ffdf4e9 protocol qualification
Expand Down
1 change: 1 addition & 0 deletions desktop/scripts/generate.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const wanted = [
"remember_memory",
"search_memory",
"get_artifact_revision",
"get_stats",
];
const operations = {};
for (const [path, item] of Object.entries(contract.paths)) {
Expand Down
2 changes: 2 additions & 0 deletions desktop/src-tauri/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ fn main() {
"search_memory",
"atomic_memory_entry",
"cancel_memory_reads",
"get_stats",
"cancel_stats_reads",
"desktop_state",
"save_profile",
"remove_profile",
Expand Down
3 changes: 3 additions & 0 deletions desktop/src-tauri/capabilities/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@
"main"
],
"permissions": [
"core:webview:allow-set-webview-zoom",
"allow-foundation-info",
"allow-local-diagnostics",
"allow-remember-memory",
"allow-search-memory",
"allow-atomic-memory-entry",
"allow-cancel-memory-reads",
"allow-get-stats",
"allow-cancel-stats-reads",
"allow-desktop-state",
"allow-save-profile",
"allow-remove-profile",
Expand Down
7 changes: 5 additions & 2 deletions desktop/src-tauri/examples/export_ipc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ use powercontext_desktop::{
error::SafeError,
ipc::FoundationInfo,
transport::{
ApiFailure, AtomicMemoryDetail, MemorySaveResponse, MemorySearchHit, MemorySearchResponse,
wire,
ApiFailure, AtomicMemoryDetail, ExactRecallTokenStatistics, ExactScopeStatistics,
ExactScopeStatisticsItem, MemorySaveResponse, MemorySearchHit, MemorySearchResponse, wire,
},
};
use ts_rs::TS;
Expand Down Expand Up @@ -72,6 +72,9 @@ fn main() {
MemorySearchHit::decl(&config),
MemorySearchResponse::decl(&config),
AtomicMemoryDetail::decl(&config),
ExactScopeStatistics::decl(&config),
ExactRecallTokenStatistics::decl(&config),
ExactScopeStatisticsItem::decl(&config),
]
.into_iter()
.chain(wire::declarations(&config))
Expand Down
Loading
Loading