feat(runtime-host): extract Usage/Pricing authority - #1596
Merged
Astro-Han merged 2 commits intoJul 29, 2026
Conversation
Astro-Han
pushed a commit
that referenced
this pull request
Aug 4, 2026
* refactor(desktop): remove consumer-less IPC bridge surface Deletes three renderer-dead bridge surfaces, all verified zero-consumer across renderer/overlay/e2e: - appWindow.subscribeOpenSettings + the window:openSettings wiring in app-shell-effects: the only sender (app-menu item) was removed in #390; Cmd/Ctrl+, keeps working through the renderer keydown handler. - dailyReview.list/get/delete aliases duplicating the live *Archive variants, plus the daily-review:delete channel end-to-end - retention cleanup calls store.deleteArchive directly and no renderer spelling of delete has a consumer. - The speculative maka.usage preload namespace, per the decision recorded on #1982: the main-side usage:* authority handlers (#1596) stay for the #2010 M4 client adapter, so the IPC surface contract test now carries a self-checking MAIN_ONLY_CHANNELS allowlist documenting that state. The third #1978 item (ungated cursor-subscription:logout) became moot when #2037 retired the whole Cursor subscription surface. Closes #1978. Ref #1982. Verification: desktop typecheck clean; main suite 1585/1585 including the IPC surface contract and app-shell effect stability contracts. * test(e2e): assert both Skill chips land before leaving the session The leave-and-return journey only asserted the first chip before navigating away; leaving while the second token is still committing races the draft snapshot and loses the chip on return, which is exactly how this spec failed on CI. Mirror the projectChip assertion for workspaceChip so the draft is known-complete before the navigation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
English
Summary
This extracts the Usage/Pricing domain as one complete Runtime Host authority slice:
v0Host operations for usage projection and pricing query/mutation;This is part of the M3 extraction tracked by #1167 and follows the ownership/lifecycle direction in #853.
Why these belong together
Runtime model and tool execution publish detailed telemetry, while cost projection resolves pricing against the same root-scoped usage history. Splitting the writer lifecycle from pricing mutation would leave either an unowned persistence path or an incomplete execution prerequisite.
The slice still keeps two projections separate:
SettingsStore.usageStats()remains the Session-derived dashboard projection.Neither projection becomes a compatibility alias for the other.
Authority and lifecycle
Promise<void>. Accepted publications participate in the facade barrier, so drain and close cannot silently abandon them.Existing data
An unversioned
telemetry.jsonmay contain LLM usage records, tool invocations, and embeddedpricingOverrides. Opening the authority:No compatibility layer is added to the unreleased integer
v0Host protocol.Protocol boundary
The Host exposes only three closed operations:
usage.querypricing.querypricing.mutateUsage pages have item and byte bounds. Pricing pages are pinned to a revision and use a strictly advancing numeric offset. Client-side response correlation rejects a valid-looking response whose source, request kind, revision, or offset does not match the canonical request.
Protocol-visible identity fields preserve ordinary short values. If control-character canonicalization or byte truncation would otherwise make distinct identities collide, the projection keeps a bounded readable prefix and a digest of the original JavaScript identity. Display labels remain plain bounded text.
Desktop and activation boundary
Desktop continues to host the raw compatibility writer in-process for M3. It resolves and validates the Interactive root before opening the embedded repository, but does not yet acquire the Runtime Host owner/lease. Current production Candidate wiring remains deliberately non-serving and cannot reach the execution composition that opens this authority, so the two writers cannot coexist through a supported product path in this milestone.
Removing this embedded writer and switching surfaces to the Host remain M4/M5 work. Acquiring ownership around the compatibility writer or completing that cutover is a hard gate before a serving production Host may open the same root.
Validation
简体中文
概要
本 PR 将 Usage/Pricing 领域作为一个完整的 Runtime Host authority slice 提取:
publication failure;
v0Host operation;本 PR 属于 #1167 追踪的 M3 提取,并遵循 #853 的 ownership/lifecycle 方向。
为什么放在同一个 Slice
Runtime 的模型与工具执行会发布细粒度 telemetry,而 cost projection 会针对同一个
root 的 usage history 解析 pricing。若将 writer lifecycle 与 pricing mutation 拆开,
会留下未归属的持久化路径,或一个不完整的 execution 前置。
本 slice 仍明确区分两种 projection:
SettingsStore.usageStats()继续提供从 Session facts 派生的 dashboard projection。两者都不会被降格为另一方的兼容别名。
Authority 与生命周期
要么返回已完整复制的 immutable detached snapshot。
facade 访问 telemetry 与 pricing。
实例状态;close 会等待 draining 前已经接纳的 load 与 mutation。
Promise<void>前取得并验证输入所有权。已接纳 publication会进入 facade barrier,因此 drain/close 不会静默丢弃它们。
commit outcome unknown,会 poison 后续读取并请求 Host drain。
drain;瞬态 setup/I/O failure 不会触发这一终态转换。
能提交;失败者取得当前 revision,并可在 query 后重试。
探测 persistence object shape。
现有数据
无版本
telemetry.json可能同时包含 LLM usage records、tool invocations 与内嵌pricingOverrides。authority 打开时会:本 PR 不为尚未发布的整数
v0Host protocol 增加兼容层。Protocol 边界
Host 只暴露三个封闭 operation:
usage.querypricing.querypricing.mutateUsage page 同时受 item 与 byte 上限约束。Pricing page 绑定 revision,并使用严格前进的
numeric offset。Client response correlation 会拒绝与 canonical request 的 source、
request kind、revision 或 offset 不匹配的“看似有效”回复。
普通短 identity 会原样保留。若 control-character canonicalization 或 byte truncation
可能使不同 identity 发生碰撞,projection 会保留有界、可读的 prefix,并附带原始
JavaScript identity 的 digest。display label 仍使用普通的有界文本投影。
Desktop 与激活边界
M3 阶段 Desktop 继续在进程内持有 raw 兼容 writer。它会先解析并验证 Interactive
root,再打开 embedded repository,但尚未取得 Runtime Host owner/lease。当前
production Candidate 接线刻意保持 non-serving,无法到达会打开本 authority 的
execution composition,因此本里程碑不存在受支持的双 writer 产品路径。
删除 embedded writer 并让各 surface 切换到 Host 仍属于 M4/M5。在启用 serving
production Host 前,必须先让兼容 writer 取得 owner,或完成 adapter cutover 并删除它。
验证