Skip to content

TSI-4300: feat(pages): 用户空间五面按声明来源渲染并支持单对象读取 - #34

Closed
multica-tsic404[bot] wants to merge 1 commit into
mainfrom
multica/TSI-4300
Closed

multica-tsic404[bot] wants to merge 1 commit into
mainfrom
multica/TSI-4300

Conversation

@multica-tsic404

@multica-tsic404 multica-tsic404 Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Closes TSI-4300

设计依据: tsic/kos-design@f7cfaa6(该锚点至设计仓当前 head 未改动本单条目:C-01、C-17、C-18、C-52、C-53 与 TC-101、TC-114、TC-115 均无差异)

交付内容

  • 桌面(kos-dock):读取条目与打开地址、已安装应用、通知中心;通知中心与事件路由是同一次按一小时窗口、倒序、按可见性裁剪的读取。
  • 应用详情(kos-taskmanager):按请求指名的应用读取健康、卷、入口、备份、漂移、事件与它自己的日志;页面只读并明示原因,修改经应用页发起。
  • 只读原生视图(kos-diagnostics):按请求指名的原生资源读取原始字段与关联对象(属主链与应用的最后一次渲染),只读且不提供写操作;凭据类资源不在可读类表中。
  • 页面读取新增指名对象(对象类、命名空间、名称):未指名、指名其它类或指名不可见的对象时拒绝;应用详情与原生视图不再可能替调用者挑对象。
  • 日志项与日志路由共用同一次按应用隔离的读取,页面的日志与路由的日志不会不同。
  • 参考第三方扩展包 examples/community-catalogue:第二个目录来源与自有页面,与第一方应用中心走同一装载、安装与目录同步路径。

设计实现

设计要求 代码落点
02-contracts C-52 桌面四项与来源 pkg/dock/dock.go DesktopPage、pkg/dock/readings.go (*Readings).entryViews / applications / notifications
02-contracts C-52 应用详情七项与来源 pkg/app/kostaskmanager/detail.go applicationDetailPage、pkg/app/kostaskmanager/detail_readings.go (*Readings).detailValue
02-contracts C-52 只读原生视图两项与来源 pkg/diagnostics/kosdiagnostics/native.go nativeViewPage、native_readings.go (*Readings).nativeValue / relatedOf
02-contracts C-52 单对象读取与拒绝 pkg/pages/pages.go Target、(*Service).Read;pkg/pages/api.go targetFromQuery
02-contracts C-53 本地源项与只读视图 pkg/dock/readings.go(本地项只带存储键)、pkg/pages/pages.go (*Service).Read
02-contracts C-64 日志按应用过滤 pkg/controlplane/logs.go (*Server).ReadApplicationLogs;pkg/app/kostaskmanager/detail_readings.go logsOf
02-contracts C-01/C-17/C-18 产品以扩展包并列安装、内核不变 examples/community-catalogue(声明、目录来源、页面、读取);tests/acceptance/TC-114 十二包逐包装卸;tests/acceptance/TC-115 第三方等价
01-scope 禁项:不改内核对象、能力基线、页面外壳或写者表 未引入:api/、config/ 无改动;TC-114/TC-115 在每一步比对 api.Kinds()、能力基线与写者表
01-scope 第一方功能包清单:十二个产品的贡献面逐项生效 TC-114 的十二包走查逐包报告贡献类计数与撤销结果

设计变更

触发 条目 变更 外部可观察行为是否变化
D1 adr/ADR-027 新增归属决策:应用详情归运行视图、只读原生视图归诊断;记录被否的跨产品拼装与外壳直渲两种方案 是(决定哪个扩展带来哪个页面)
D2 01-scope 第一方功能包清单 kos-taskmanager 贡献集加入应用详情页、kos-diagnostics 加入只读原生视图页 是
D3 02-contracts C-52 写明三个表面的声明者、页面自带读取、原生视图的资源类边界、单对象读取的拒绝语义 是
D4 03-acceptance TC-101 场景补「不带对象与带另一个对象读取」,判据补单对象读取的三种结果 是

设计 PR: https://gitea.tsic.top/tsic/kos-design/pulls/18

验证

  • tests/acceptance/TC-101:桌面、应用中心、应用详情、通知中心与只读原生视图逐项渲染;详情页日志只含本应用行;通知中心与事件路由同序;本地项只带存储键;只读视图无动作;未指名与不可见对象的读取被拒绝。
  • tests/acceptance/TC-115:第三方目录来源与页面与第一方同形(显示字段、安装表单、可安装判定、安装入口一致);移除第一方应用中心后第三方页面、条目与安装仍可用;内核 kind 集合、能力基线与写者表每步不变。
  • tests/acceptance/TC-114:十二个第一方产品逐包安装并逐包卸载,逐包报告贡献计数,每一步后其余产品仍生效、内核不变。

Summary by Sourcery

Render user-space pages from their declared sources, support explicit single-object reads, and demonstrate equivalent third-party extensions without kernel changes.

New Features:

  • Add declaration-driven desktop, application detail, and read-only native resource pages with their corresponding data readings.
  • Support target-specific page reads for named applications and native resources, rejecting incomplete, mismatched, or invisible targets.
  • Add a reference third-party catalogue extension with its own catalogue source and application-centre page.

Bug Fixes:

  • Unify application log reads between the detail page and control-plane route so both return the same application-scoped data.

Enhancements:

  • Route page readings through declared sources while preserving visibility, event-window, ordering, and read-only semantics.
  • Expose native resource relationships and last-rendering applications without exposing credential resources.
  • Standardize catalogue references and extend the page-reading interface to carry object targets.

Documentation:

  • Document the new page packages, reference third-party extension, and expanded acceptance coverage.

Tests:

  • Add acceptance coverage for the five user-space surfaces, target-specific reads, filtered logs and events, and read-only behavior.
  • Verify every first-party product can be installed and removed independently without changing kernel kinds, capabilities, or writers.
  • Verify a third-party catalogue remains functional and equivalent after removing the first-party app centre.

@sourcery-ai

sourcery-ai Bot commented Nov 1, 2026

Copy link
Copy Markdown

Sorry @multica-tsic404[bot], you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 1 day and 20 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@sourcery-ai

sourcery-ai Bot commented Nov 1, 2026

Copy link
Copy Markdown

Reviewer's Guide

This PR implements the TSI-4300 user-space surfaces by moving desktop, application detail, and native diagnostics rendering into declared extension pages, threading explicit object targets through the page API to prevent implicit object selection, sharing event and application-log reads across pages and routes, and proving the extension model with comprehensive acceptance tests and a third-party catalogue package while preserving kernel and capability invariants.

Sequence diagram for targeted application detail reads

sequenceDiagram
    participant Client
    participant API as Pages API
    participant Service as Page Service
    participant Router
    participant TaskManager as kos-taskmanager
    participant Cluster
    participant Logs as Control plane logs

    Client->>API: GET application-detail?kind=Application&namespace=...&name=...
    API->>Service: Read(application-detail, Target)
    Service->>Router: Read(detail item, Target)
    Router->>TaskManager: Read(detail item, Target)
    TaskManager->>Cluster: Get(Application, namespace, name)
    Cluster-->>TaskManager: Application object
    TaskManager->>Cluster: Visible(session, Application)
    Cluster-->>TaskManager: Visibility result
    alt detail item is logs
        TaskManager->>Logs: ReadApplicationLogs(namespace, name, LogBounds)
        Logs-->>TaskManager: Bounded application log read
    else detail item is health, volumes, endpoints, backup, drift, or events
        TaskManager->>Cluster: Read related application data
        Cluster-->>TaskManager: Detail reading
    end
    TaskManager-->>Router: Reading
    Router-->>Service: Reading
    Service-->>API: Rendered page
    API-->>Client: Page response
Loading

Sequence diagram for shared event and log reads

sequenceDiagram
    participant Client
    participant Route as Events or log route
    participant Page as Application detail page
    participant Events as EventReader
    participant Logs as ReadApplicationLogs
    participant Cluster

    par notification or event read
        Route->>Events: Read event window with visibility
        Page->>Events: EventsAbout(application)
        Events->>Cluster: Read filtered events
        Cluster-->>Events: Ordered visible events
        Events-->>Route: EventRead
        Events-->>Page: EventRead
    and application log read
        Route->>Logs: ReadApplicationLogs(namespace, name, bounds)
        Page->>Logs: ReadApplicationLogs(namespace, name, bounds)
        Logs->>Cluster: Read application and rendered workloads
        Cluster-->>Logs: Bounded log lines
        Logs-->>Route: LogRead
        Logs-->>Page: LogRead
    end
Loading

File-Level Changes

Change Details Files
Adds declaration-driven desktop, application-detail, and read-only native-resource pages with targeted object reads and explicit read-only semantics.
  • Introduces desktop item declarations and readers for entries, installed applications, notifications, and browser-local recent items.
  • Adds seven application-detail readings, visibility checks, related-resource resolution, and per-application logs.
  • Adds native-resource raw-field and relationship readings with an allowlisted kind set that excludes credentials.
  • Extends the page API, routing, and all readers to carry and validate a requested object target.
pkg/pages/pages.go
pkg/pages/api.go
pkg/pages/router.go
pkg/pages/cluster/cluster.go
pkg/dock/dock.go
pkg/dock/readings.go
pkg/app/kostaskmanager/declaration.go
pkg/app/kostaskmanager/detail.go
pkg/app/kostaskmanager/detail_readings.go
pkg/app/kostaskmanager/readings.go
pkg/diagnostics/kosdiagnostics/declaration.go
pkg/diagnostics/kosdiagnostics/native.go
pkg/diagnostics/kosdiagnostics/native_readings.go
Unifies application log reads between the detail page and control-plane log route while preserving bounded, visibility-filtered behavior.
  • Extracts application log retrieval into a reusable server method with shared bounds clamping and workload scoping.
  • Routes the detail page log item through the same control-plane read implementation as the HTTP log endpoint.
  • Reuses the event reader for notification-center and application-event views.
pkg/controlplane/logs.go
pkg/pages/cluster/cluster.go
pkg/dock/readings.go
pkg/app/kostaskmanager/detail_readings.go
Adds a reference third-party catalogue extension that uses the existing declaration, catalogue synchronization, page rendering, and application installation paths.
  • Declares a community catalogue source and app-center-like page with install and upgrade actions.
  • Generates validated, digest-pinned application definitions and renders source-owned entries with install forms.
  • Verifies third-party equivalence and continued operation after first-party app-center removal.
examples/community-catalogue/declaration.go
examples/community-catalogue/definitions.go
examples/community-catalogue/readings.go
pkg/appstore/appstore.go
pkg/appstore/readings.go
tests/acceptance/TC-115/tc115_test.go
Expands acceptance coverage for all user-space surfaces and extension lifecycle isolation without changing kernel objects, capabilities, or writers.
  • Adds end-to-end coverage for the five page surfaces, targeted-read rejection, visibility filtering, event ordering, application-scoped logs, and read-only actions.
  • Installs and removes all twelve first-party products individually while checking contribution withdrawal and kernel invariants after every step.
  • Updates existing reader interfaces and unit tests for the new target parameter.
tests/acceptance/TC-101/tc101_test.go
tests/acceptance/TC-114/tc114_test.go
tests/acceptance/TC-59/tc59_test.go
tests/acceptance/harness/shell.go
pkg/app/kostaskmanager/declaration_test.go
pkg/app/kostaskmanager/readings_test.go
pkg/diagnostics/kosdiagnostics/declaration_test.go
pkg/pages/pages_test.go
pkg/pages/router_test.go
pkg/appstore/readings_test.go
pkg/volume/kosstorage/readings_test.go
pkg/device/kosdevicemanager/readings.go
pkg/endpoint/kosnetwork/readings.go
pkg/extension/kosupdater/readings.go
pkg/settings/kossettings/readings.go
Documents the new user-space architecture, package layout, acceptance coverage, and extension-based product boundaries.
  • Describes declaration-based rendering, targeted reads, shared logs, and third-party extension behavior.
  • Documents new dock, page shell, task manager, diagnostics, and community catalogue packages.
  • Records the expanded TC-101, TC-114, and TC-115 coverage.
README.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@tsic404 tsic404 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

审查范围

multica/TSI-4300 → main,commit 4af7d06,39 文件 +2780/−97。设计依据 tsic/kos-design@f7cfaa6(本单冻结锚点),设计变更 D1–D4 对应设计 PR kos-design#18(L4),按 G6 不阻塞本次代码审查。

审查维度:契约符合性(C-52、C-53、C-64、C-59、C-41、C-60、C-14、C-01、C-17、C-18)、正确性与数据完整性、边界与错误处理、安全与凭据边界、测试证据、提交信息。

其他审查者反馈:无(本 PR 此前没有任何 review)。

契约符合性要点

  • C-52 桌面四项、详情七项、原生视图两项的来源与「页面自带读取」:符合。pkg/dock/dock.go:136、pkg/app/kostaskmanager/detail.go:33、pkg/diagnostics/kosdiagnostics/native.go:25。
  • C-52 单对象读取拒绝:三处拒绝语义正确(pkg/pages/api.go:63、pkg/app/kostaskmanager/detail_readings.go:60、pkg/diagnostics/kosdiagnostics/native_readings.go:73);用例只断言两种,见第 3 条。
  • C-14:nativeClasses(pkg/diagnostics/kosdiagnostics/native_readings.go:24)不含 Secret,凭据类资源不在可读类内;无反向用例,见第 3 条。
  • C-64:详情页日志项与 /api/v1/logs/{namespace}/{name} 共用 ReadApplicationLogs(pkg/controlplane/logs.go:196),LogBounds{} 与路由无参默认同值;通知中心与事件路由共用 EventReader(pkg/dock/readings.go:228)。符合。
  • C-59:详情页对不可见应用回答 404(pkg/app/kostaskmanager/detail_readings.go:66);桌面「已安装应用」按可见性裁剪(pkg/dock/readings.go:202)。符合。
  • C-41/C-60:详情页「备份」的覆盖判定与备份调和器不一致,见第 1 条。
  • F17:api/、config/、pkg/write、pkg/extension 零改动;无产品名分支进入外壳;nativeClasses 是产品内表。符合。
  • G8 提交信息:主题无 TSI/C-x/AC-x/TC-x/ADR-x 编号、未照抄单标题、正文非空、无签名尾注。符合。

点赞

  • 单对象读取的拒绝放在读者里,targetFromQuery 只判「指名了一半」,职责切得干净(pkg/pages/api.go:63)。
  • 日志项与日志路由合并成一次读取(pkg/controlplane/logs.go:196),消除了「页面与路由各读一次」的漂移源。
  • Launch 补上 json 标签(pkg/dock/entry.go:65),修掉了打开地址此前以 Endpoint/Address 外泄的字段名。
  • TC-114 改成逐包走查、逐包复核已装产品的贡献,而不是抽样(tests/acceptance/TC-114/tc114_test.go:1125)。

无法锚定的发现

无。

结论

REQUEST CHANGES:3 条(1 条 blocking、2 条 suggestion)。

Comment thread pkg/dock/readings.go Resolved
Comment thread tests/acceptance/TC-101/tc101_test.go Resolved
桌面、应用详情与只读原生视图在页面外壳里既没有声明者也没有读取实现,应用
中心与通知中心的数据来源同样接不进来:页面读取只按页面身份进行,无法回答
「哪一个应用」「哪一个原生资源」,只能自己挑一个对象。

现在桌面读取条目与打开地址、已安装应用、通知中心(与事件路由同一次读取),
应用详情读取一个应用的健康、卷、入口、备份、漂移、事件与它自己的日志,只读
原生视图读取一个原生资源的原始字段与关联对象;页面读取新增指名对象,未指名、
指名其它类或指名不可见的对象时拒绝。应用详情读到的备份覆盖与备份调和器共用
同一条所有者精确相等判定,桌面上的坏条目逐条给出原因而不再让整页失败。另附
一个参考第三方扩展包,用第二个目录来源与自有页面走同一装载与安装路径。

@tsic404 tsic404 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

审查范围

multica/TSI-4300 → main,commit 31bda4f(rebase 到 2f4ee8c),42 文件 +2921/−101,规模 L4。设计依据 tsic/kos-design@f7cfaa6(本单冻结锚点);设计变更 D1–D4 对应设计 PR kos-design#18(L4,仓库远端分支 design/TSI-4300 存在,diff 含 ADR-027、01-scope、02-contracts、03-acceptance),按 G6 不阻塞本次代码审查。

审查维度:契约符合性(C-01、C-13、C-14、C-17、C-18、C-22、C-24、C-30、C-41、C-52、C-53、C-59、C-60、C-64)、正确性与数据完整性、边界与错误处理、安全与凭据边界、测试判别力、提交信息。

其他审查者反馈:无(PR 上只有本审查上一轮的 CHANGES_REQUESTED,本轮逐条核验关闭,未采信 resolve 状态)。

上一轮三条发现:逐条核验

  1. 🔴 备份覆盖判定 — 已关闭。pkg/backup/controller.go:296 的 CoversOwner 是唯一判定;covered() 的应用与卷两条路径都改调它(:315、:330);页面 pkg/app/kostaskmanager/detail_readings.go:280 复用同一函数。全仓无第二条覆盖实现(pkg/backup/restore.go:117 是恢复授权规则,pkg/filemanager/volumes.go:129 是卷访问规则,均不同)。无 owner 的策略只覆盖无 owner 对象。判别力:tests/acceptance/TC-101/tc101_test.go:87 造同选择器、无 owner 的策略,:303 断言只列 1 条;旧实现(空 owner 当通配)会返回 2 条,用例必红。

  2. 🟡 桌面坏条目 — 已关闭。pkg/dock/readings.go:117 与 :141 两条失败路径都改为逐条降级,:249 的 unreadableView 保留可读字段(显示名回退应用名、order 尽力读取)、置 available:false 并带 reason;排序(:157)与可见性裁剪(:174 的 showsTo)对坏条目走同一路径,无例外分支。判别力:tests/acceptance/TC-101/tc101_test.go:200 断言两条坏条目(无 spec、order: "high")都在且带原因,同一用例经 readPage(:416)断言整页 200;旧实现整页 500 必红。

  3. 🟡 C-52 三种拒绝 — 已关闭。「指名其它类」tests/acceptance/TC-101/tc101_test.go:332(?kind=Pod → 400,消息指名 Application);表外类含 Secret :392(400,消息列出可选类且不含 Secret,响应不含凭据值);「未指名」:379;「指名不可见」:156(404)。判别力:删掉 pkg/app/kostaskmanager/detail_readings.go:61 的类判定会退化为 200,删掉 pkg/diagnostics/kosdiagnostics/native_readings.go:73 的表外分支会走进动态读取,两者都让用例变红。

rebase 附加审查面

tests/acceptance/TC-86/tc86_test.go:173、TC-88/tc88_test.go:210、TC-59/tc59_test.go:230 只补第四参数 pages.Target{}(或接口方法签名),页面身份、断言与执行路径未变——签名适配,不是行为漂移。README.md 冲突解决无内容丢失,31bda4f 的父提交即 2f4ee8c。

安全与凭据边界

  • 页面读取仍由 identity.FromContext 强制会话(pkg/pages/api.go:42);单对象读取在读者侧判定类、命名空间与可见性(pkg/app/kostaskmanager/detail_readings.go:61、pkg/diagnostics/kosdiagnostics/native_readings.go:73),不可见应用按不存在处理(404),无 IDOR 面。
  • nativeClasses(pkg/diagnostics/kosdiagnostics/native_readings.go:24)不含 Secret;表外类只回拒绝并列出可选类,不读取、不投影(C-14)。owner 引用指向视图不服务的类时只给原因、不读取(:146)。
  • 日志项与日志路由共用一次读取(pkg/controlplane/logs.go:196),鉴权在读取内完成(:211),页面无法绕过 C-59。
  • 无硬编码密钥、无凭据进日志、无 CI 环境变量特判(全 diff 无 Getenv / t.Skip)。

点赞

  • 备份覆盖做成一个导出函数,调和器与页面共用,比两处各写一遍「精确相等」更难漂移。
  • 单对象读取的拒绝落在读者侧,targetFromQuery(pkg/pages/api.go:63)只判「指名了一半」,职责切得干净。
  • 日志项/日志路由与事件项/事件路由各自合并成一次读取,消除了页面与路由漂移的源头。
  • 社区扩展只声明 CatalogueSources 与 Pages(examples/community-catalogue/declaration.go:60),内核零改动。

结论

零发现。契约符合性逐点核对表见本单 issue 评论。

@tsic404

tsic404 commented Nov 2, 2026

Copy link
Copy Markdown
Owner

随 TSI-4477 的设计重排作废:TSI-4300 已按用户指示关闭,本 PR 不再合入。后续实现按项目划分(tsic404/kosd 等)重新立项与排期。

@tsic404 tsic404 closed this Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant