Skip to content

feat(workbench): read LoopX projections through a read-only api - #8784

Open
maxliux5 wants to merge 3 commits into
loopx-project:mainfrom
maxliux5:codex/calli-workbench-projections
Open

maxliux5 wants to merge 3 commits into
loopx-project:mainfrom
maxliux5:codex/calli-workbench-projections

Conversation

@maxliux5

@maxliux5 maxliux5 commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Points the workbench at LoopX. A new LoopxApi implements the UI's existing
Api interface over LoopX's public projections and replaces the demo
workspace as the data source. LoopxApi overrides the same transport methods
the demo API did, answers reads from /status.json and the Chat service, and
rejects every write, so existing components keep working unchanged. The one
UI addition is a compact, read-only triage panel on the Desk page that shows
what needs the user, what is running and what failed.

?fixture=1 renders the same page from fixtures bundled with the app
(src/loopx/fixtures/), with no service running and no network request. It
replaces B's demo workspace, so offline review still shows all three panes and
all three triage groups populated.

Stack: A scaffold → B shell → C projections (this PR). Related design
notes: #8778 (open; not a prerequisite).

Change boundary

  • Every file is under apps/presentation/calli-workbench/. No change to
    loopx/, packages/, other apps, root configuration, CI or scripts.
  • GET only. LoopxApi calls exactly these routes and nothing else:
    /status.json, /api/chat/sessions, /api/chat/sessions/<id>,
    /api/chat/endpoints, /api/chat/capabilities, /api/chat/goals/contexts,
    /ssh-hosts. It does not use the Todo, action or request-control write
    routes.
  • Single forwarding boundary. This PR adds the workbench's only proxy (A
    and B have none). One middleware in vite and vite preview enumerates the
    routes above and forwards them itself: a path it does not enumerate gets a
    local 404, any method but GET/HEAD gets a local 405, and the upstream only
    ever receives enumerated GET/HEAD requests. Route matching and the method
    check happen in that one place.
  • No second state source. The workbench stores no Goal, Todo, Gate or
    session fact. Browser storage holds display preferences only, enforced by
    npm run check:no-second-state.
  • Contract first. Responses are validated with zod schemas mirrored from
    the dashboard's src/data/status.ts and the Chat service's
    schema_version literals; each copied schema names its source and sync
    owner. A status_contract.schema_version below 2 shows "Update the local
    LoopX service" instead of a guessed page.

Files:

Path Change
src/loopx/LoopxApi.ts New: extends Api; overrides send, stream, uploadVideo, threadFile, attachment
src/loopx/status-schema.ts, src/loopx/chat-schema.ts New: contract subsets
src/loopx/mapping.ts New: projection → UI model mapping (table below)
src/loopx/placeholders.ts New: one registry of UI fields the projections cannot fill, each with its reason and how the UI presents it
src/loopx/fixtures/status.demo.json New: app-local copy of LoopX's public examples/status.example.json with one added synthetic item waiting on the user; its _provenance field records this
src/loopx/fixtures/chat.example.json New: synthetic Chat-service fixture
src/components/TriagePanel.tsx New: compact, read-only panel on the Desk page that renders triage() as four groups (Needs you, Running, Failed, Waiting; Waiting is folded by default and not counted in any badge)
smoke/projection-smoke.ts, smoke/no-second-state-check.mjs New: fixture smoke and storage/endpoint guard
readonly-forward.ts New: the only path to LoopX services; one Vite middleware (dev and preview) that enumerates the GET/HEAD routes, forwards them over node:http and answers everything else locally (404 / 405)
vite.config.ts, tsconfig.json Register the forwarder; no server.proxy / preview.proxy
test/loopx-*.test.ts New: mapping unit tests
test/readonly-forward.test.ts New: forwarder against fake upstreams (each route reaches its upstream once; refused requests reach none)
src/App.tsx Data source becomes LoopxApi
src/api.ts Adds readOnly; read-only UI branches use it instead of the demo flag
src/demo/*, test/demo.test.ts Removed: ?fixture=1 replaces the demo workspace for offline review
package.json, package-lock.json, README.md Adds zod and the smoke scripts; documents data source and fixture mode

Data mapping

UI method Previous source LoopX source (read-only) Mapping
health() server health /status.json → status_contract Version below 2 → typed incompatibility error
threads() server thread list /api/chat/sessions Active turn id → running; error code → error; agent and model passed through
sections() server sections run_history.goals One read-only group per Goal, titled by display name, else objective, else id; sessions whose Goal is not listed go to an "Unassigned" group
thread(), events(), historyPage() server thread log /api/chat/sessions/<id> Messages → user/assistant text events; no tool or reasoning events
stream() server-sent events none Polling (see limits)
agents(), models() server agent registry /api/chat/endpoints, /api/chat/capabilities Unavailable endpoints stay listed with their reason
hosts() server host registry /ssh-hosts (ssh_host_catalog_v0) This machine is local; catalog aliases are listed with an unknown (not probed) state, never reported as offline
todos() server task table todo_index.items + attention_queue.items Role user → owner is the user; owner-waiting attention (waiting_on ∈ {user, user_or_controller, operator}) → needs answer; blocked → blocked; an executing agent's current Todo → working; any other status word → idle (never inferred)
any other read — — Empty result; the UI shows its designed empty state
any write — — ReadOnlyError; the UI shows the read-only message

Known limits

  • No live streaming. The Chat service's turn event stream is not used in
    this PR; the page refreshes by polling at the dashboard's cadence. A running
    turn appears on the next poll, not token by token.
  • Placeholder fields. UI fields with no projection counterpart (permission
    mode, queued messages, approval prompts, pinned and unread flags, archive state,
    user-defined sidebar sections, login state, machine reachability) are registered in
    src/loopx/placeholders.ts and rendered as omitted or as a fixed read-only
    chip. None is filled with an invented value. (Grouping sessions by Goal is
    real projection data, not a placeholder.)
  • Remote machines are greyed out. Aliases from /ssh-hosts appear in the
    switcher, disabled and marked as not probed; they are neither probed nor
    connected. Connecting to them belongs to a later change.
  • Missing timestamps show no age. When a projection row has no usable
    timestamp, the UI omits its relative time instead of computing one from an
    empty value (which previously rendered as an age of about 20,000 days).
  • Read-only. Starting sessions, sending messages and answering triage items
    are disabled; they need control-plane write routes and come in a later PR.

Deviations

Id Deviation Impact and follow-up
D-1 React 18 / Vite 5 / TypeScript 5, not the dashboard's React 19 / Vite 8 / TypeScript 6 Separate directory and lockfile; nothing is shared with the dashboard and nothing enters the LoopX startup path. A stack upgrade follows as its own PR under the same tests.
D-2 The Calli stylesheet is kept as-is instead of being migrated to the tokens in docs/development/design.md Visual only; no state or authority impact. Token migration (color, type, radius first, then components) follows as a separate PR; this stack does not claim design-system conformance.
D-3 Large diff in B, mostly moved code B's review can focus on the files listed there as changed from the source; the rest is a verbatim move, checkable with diff -r against Calli packages/web @ 87adcde. A and C are small.
D-4 License: resolved — Apache-2.0 + NOTICE package.json declares Apache-2.0; NOTICE carries the attribution and the relicensing statement.

D-1 and D-2 carry over from B unchanged, D-4 is resolved; D-3 does not apply (this diff is concentrated in src/loopx/). This PR adds no new deviation.

License

Apache-2.0. Ported from Calli packages/web, relicensed under the Apache License, Version 2.0 with contributor consent (see NOTICE). NOTICE reads: "Portions derived from Calli
(https://github.com/maxliux5/calli). Copyright Calli contributors. Relicensed
under the Apache License, Version 2.0 with contributor consent."

How to review offline

cd apps/presentation/calli-workbench
npm ci && npm run dev    # http://127.0.0.1:5174/?fixture=1

?fixture=1 reads only the fixtures bundled in src/loopx/fixtures/ and makes
no network request:

  • status.demo.json: a copy of LoopX's public examples/status.example.json
    with one added synthetic item waiting on the user (marked in its
    _provenance field). The repository's examples/ file is not modified or
    read.
  • chat.example.json: synthetic sessions, endpoints and machine aliases.

With no service running, the page shows Goals and their sessions on the left, a
session or Goal in the middle, and the triage groups, rendered by the triage
panel on the Desk page:

Group What the fixture puts there
Needs you The added synthetic item waiting on the user
Running One session with an active turn
Failed The fixture's blocked Todos and one session with an error code
Waiting (folded) Everything that matches none of the three, such as a Goal waiting on an agent or on external evidence; listed so nothing is silently dropped

Without ?fixture=1 and without local LoopX services, the page shows its
"cannot read the LoopX status service" state with a retry control.

Validation

$ cd apps/presentation/calli-workbench
$ npm ci && npm run build
> tsc --noEmit && vite build
✓ 2005 modules transformed.
✓ built in 28.17s
$ npm test
# tests 233
# pass 233
# fail 0
$ npm run smoke:projection
fixture mode
  ok  needs-you holds the attention item waiting on the user
  ok  the needs-you entry cites waiting_on=user as its reason
  ok  running holds the session with an active turn
  ok  error holds every blocked todo and the session with an error code
  ok  the triage panel renders the three groups with their counts and entries
  ok  the desk header count is the triage needs-you count, in zh and en
  ok  desk todos carry a stage and no age is claimed without a time
  ok  threads come from the demo sessions
  ok  todos reach the desk (blocked ones wait, none invented)
  ok  sections are derived from goals plus the unassigned bucket
  ok  hosts are not probed offline
  ok  no view model carries runtime_root or a local absolute path
  ok  every write is refused with ReadOnlyError
  ok  a status older than the supported schema is refused, not rendered
  ok  fixture mode made zero fetch calls
live mode
  ok  status contract is accepted and the triage has all four buckets
  ok  no view model carries runtime_root
projection smoke: 17 checks passed
$ npm run check:no-second-state
no-second-state: ok (73 files scanned; 9 preference keys whitelisted; fetch only in src/loopx/)

Forwarding boundary, from npm test (test/readonly-forward.test.ts, run
against loopback fake upstreams that count every request they receive):

ok 128 - each enumerated route is forwarded to its own upstream exactly once
ok 129 - the query string travels, the fragment does not, HEAD is forwarded as HEAD
ok 130 - a write to an enumerated route is a local 405 and the upstream sees nothing
ok 131 - anything not enumerated is a local 404 and the upstream sees nothing
ok 132 - paths outside the service namespace are left to the page server
ok 133 - an upstream that is down gives 502, not a hang or a crash

Curl evidence, identical on the dev port (5174) and the preview port (4174):

POST   /api/chat/preferences                 -> 404   (path not enumerated)
POST   /api/chat/sessions                    -> 405   (enumerated, wrong method)
PUT    /api/chat/sessions/x                  -> 405
DELETE /status.json                          -> 405
GET    /api/chat/preferences                 -> 404
GET    /api/chat/sessions/a/b                -> 404   (multi-segment id refused)
GET    /api/chat/sessions/%2e%2e/preferences -> 404
GET    /api/chat/capabilities | endpoints | goals/contexts | sessions -> 200
GET    /status.json | /ssh-hosts             -> 200
GET    /                                     -> 200   (the page)
  • The two live-mode checks run only when local LoopX services answer and are
    skipped otherwise; they print counts only, nothing from the service.
  • The smoke computes its expectations directly from the raw fixture JSON,
    independently of the mapping code, and covers contract-version rejection, an
    owner-waiting item, a stopped Goal's attention row, an executing agent, and an
    unknown status word that must stay out of every group.
  • Outside src/loopx/, src/ contains no fetch( call.
  • Checked against local status and Chat services: Goals, Todos and sessions
    render, and the browser console has no errors. No screenshot was taken
    against live services.
  • Pre-commit scan of the staged diff: no local paths, hostnames, credentials or
    e-mail addresses.

Visual evidence

Fixture mode only (?fixture=1: the app-local status.demo.json and
chat.example.json). Captured at ff6d2c21a; the tested revision
f3a2788bb adds only the read-only forwarder on top, no UI change.

Desk with the triage panel (header count "1 needs you" equals the Needs you group):

Desktop, light, zh Desktop, dark, zh Narrow, dark, en
Desktop, light, zh Desktop, dark, zh Narrow, dark, en

Session view (the composer reads "read-only"):

Session, desktop, light, zh

Rollback

Revert this PR. The workbench returns to the demo workspace from B; nothing
outside apps/presentation/calli-workbench/ is affected and no LoopX state was
ever written.


Stacked on the shell PR (#8783). This PR targets main and its branch contains the scaffold and shell commits; review the incremental change with
compare between the two branches.

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewer: model_agent · gpt-6.1-sol · OpenAI · runtime_reported · reasoning_effort=max

评审提交 ff6d2c21a750160c6583440641b1b50bc67e6f97,GitHub 目标基线 74ca883d5bd3e4bc64671bac54210eac9e97ed05。本地合并模拟与主干行为对照为 48dbebbd14c5535b9631f4c7a1152d86aa64c5b2。

[P2] Workbench 的同源代理能写入 Chat。 Vite 转发整个 /api/chat,并把 Workbench 的同源 Origin 改成 Chat 来源;开发服务与构建预览都返回 200,随后 GET 与隔离 Chat 文件都读回了刚写入的 Goal 排序。相同来源直接到 Chat 端口会被拒绝。 给 dev 与 preview 使用同一读取路由白名单和 HTTP 方法门,先拒绝 POST 等写入,再决定是否转发。 问题位置

[P2] Chat 故障被显示成没有会话。 助手页将 /api/chat/sessions 的 503 和不兼容 schema 都当成空数组。实际页面无告警,运行会话从 1 变 0,失败会话从 1 变 0,来自 status 的 12 条待办和 1 项需要本人处理的记录仍在。只有 Chat 真返回空列表时才应这样显示。 在助手页携带会话来源的不可用或版本错误状态,显示重试并保留可用的 Goal 与 Todo;仅把成功的空数组显示为没有会话。 问题位置

动机 / Motivation

用户打开 Workbench 的助手页,想知道哪些 LoopX 会话正在执行或需要处理,并在来源故障时知道如何恢复。 主干没有这一 Workbench 入口。上一片只能打开合成工作区,这一片默认从 status 与 Chat 投影生成真实线程和助手页,也保留可选离线样例。 来源健康时展示正确的运行、失败和待办;Chat 来源故障时失去会话事实。两种本地 Vite 入口仍能向 Chat 写偏好。 这里只验收读取、布局和失败恢复。启动执行、升级安装、对真实生产状态的写入及远端接入不在范围内。

改动思路 / Approach

LoopxApi 通过 adapter 读取 status 与 Chat;Todo 由 status 派生,线程来自会话,助手归并两者。页面的写调用由 Api.send 拒绝,Vite HTTP 入口另有自己的权限边界。 在会话读取失败时,归并器收到人为造出的空列表。 持久化和会话状态仍由原 LoopX 读写接口持有。客户端可映射已有 DTO 和错误类型;不能用浏览器写拒绝替代代理授权,也不需再造一个状态提供方。 保留真实来源与离线样例;在代理收窄方法和路径,在读适配器保留错误与来源,验证拒写、视图可用、断线和恢复。

独立验证

干净安装与构建通过,227 项测试通过。投影 smoke 在合成离线与隔离 HTTP 服务上通过 17 项,源状态单一检查通过。保持 status 不变,恢复 Chat 后,运行和失败会话重新可见。

具体改动 / Changes

对 GitHub 基线是 115 文件、约 44k 新行;相对合成页 43 文件,约 4k 增、304 删。本片集中在 HTTP 契约、映射、UI 接线和隔离验证。 以 docs/development/frontend-delivery.md 和不可变版本 48dbebbd14c5535b9631f4c7a1152d86aa64c5b2 为准。设计 PR #8778 说明产品方向。当前验收依据是主干已接纳的前端交付规范,分别查看原型边界、实际读取、不可用及重试、来源的写入权限。 规范

  • Task-first delivery · not_met。助手页将 /api/chat/sessions 的 503 和不兼容 schema 都当成空数组。实际页面无告警,运行会话从 1 变 0,失败会话从 1 变 0,来自 status 的 12 条待办和 1 项需要本人处理的记录仍在。只有 Chat 真返回空列表时才应这样显示。
  • By default all mutation endpoints are denied · not_met。Vite 转发整个 /api/chat,并把 Workbench 的同源 Origin 改成 Chat 来源;开发服务与构建预览都返回 200,随后 GET 与隔离 Chat 文件都读回了刚写入的 Goal 排序。相同来源直接到 Chat 端口会被拒绝。
  • Unavailable sources fail visibly · not_met。助手页将 /api/chat/sessions 的 503 和不兼容 schema 都当成空数组。实际页面无告警,运行会话从 1 变 0,失败会话从 1 变 0,来自 status 的 12 条待办和 1 项需要本人处理的记录仍在。只有 Chat 真返回空列表时才应这样显示。

关键代码讲解

  • chatProxy.configure。把已匹配 Workbench 来源的请求改成 Chat 来源。 仅检查 Host 和 Origin,方法原样转发。 Vite 转发整个 /api/chat,并把 Workbench 的同源 Origin 改成 Chat 来源;开发服务与构建预览都返回 200,随后 GET 与隔离 Chat 文件都读回了刚写入的 Goal 排序。相同来源直接到 Chat 端口会被拒绝。 精确代码
  • preview。服务生产构建产物。 没有独立停用或收窄代理。 两个入口都能写入隔离 Chat 偏好。 精确代码
  • LoopxApi.send。拒绝经 UI API 发起的写。 非投影操作拒绝,不把网络错误伪装成授权。 写门只管应用调用,不能管 Vite 代理。 精确代码
  • LoopXApiAdapter.triage。汇集 status 与会话数据形成助手页。 catch 把所有会话读取问题变成成功空数组。 助手页将 /api/chat/sessions 的 503 和不兼容 schema 都当成空数组。实际页面无告警,运行会话从 1 变 0,失败会话从 1 变 0,来自 status 的 12 条待办和 1 项需要本人处理的记录仍在。只有 Chat 真返回空列表时才应这样显示。 精确代码
  • TriagePanel。把经归并后的三组数量与条目显示出来。 没有来源失败这一态。 用户看不到会话来源部分失效。 精确代码

对主干的风险 / Risks

PASS · 全量 115 个路径仅在独立 Workbench 目录。补丁空白、3 个提交的签署及当前主干本地合并模拟通过。

FAIL · 启动本机 Workbench dev 或 preview 后,从 Workbench 自身来源向 Chat 偏好接口发出 POST。 Vite 转发整个 /api/chat,并把 Workbench 的同源 Origin 改成 Chat 来源;开发服务与构建预览都返回 200,随后 GET 与隔离 Chat 文件都读回了刚写入的 Goal 排序。相同来源直接到 Chat 端口会被拒绝。 分别在 HTTP 入口和会话读取归并处做两个局部修复,保留现有投影来源、视图和版本判定。

FAIL · 保持 status 正常,将 /api/chat/sessions 从两条有效会话切换到 HTTP 503 或不支持的 schema,然后打开助手页。 在相同 status 上依次提供两条会话、503、不支持的 schema、成功空列表和恢复后的两条会话;助手页应区分失败与空列表,并在重试后恢复运行和失败记录。

UNVERIFIED · 浏览器和适配器用隔离的状态与会话 HTTP 响应做故障注入;写入测试另用真实 Chat 处理器和独立运行目录。实际部署、长时间断线、远端服务及托管 CI 未验证。

语义与 CI 对齐

用既有 HTTP 方法、路径和 typed errors:代理默认拒绝改变来源;只有成功读取的空会话列表表示没有会话。 用独立空 Chat 运行目录,分别启动 dev 与 preview;向 /api/chat/sidebar-goal-order 送同源 POST 后重新 GET。修复后应为 405 或 403,旧排序与运行目录均不变;保留对允许读取的正例。 托管 CI 未读取。

我的整体评价 / Verdict

请求修改。先在两个本地入口封住写入,再让助手页明确告知会话数据中断或不兼容。修复后按上面两条负例重跑。 独立读视图不改变 Agent 的运行、调度、结算与长期任务推进;这次没有测量生产效果。

桌面助手能在首屏分辨三组及对应计数;窄屏把三组纵排。Chat 断开时运行组直接显示空,失败会话从出错组消失,没有来源级提示。 未打开折叠的静置组、所有任务详情或长期重连;窄屏断线恢复与正式安装未验证。

English verdict: REQUEST_CHANGES at ff6d2c2. Enforce read-only behavior at both Vite boundaries and report Chat source failures separately from an empty session list.

proxy: {
'/status.json': statusProxy,
'/ssh-hosts': chatProxy,
'/api/chat': chatProxy,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[P2] Workbench 的同源代理能写入 Chat。 Vite 转发整个 /api/chat,并把 Workbench 的同源 Origin 改成 Chat 来源;开发服务与构建预览都返回 200,随后 GET 与隔离 Chat 文件都读回了刚写入的 Goal 排序。相同来源直接到 Chat 端口会被拒绝。 给 dev 与 preview 使用同一读取路由白名单和 HTTP 方法门,先拒绝 POST 等写入,再决定是否转发。

async triage(): Promise<TriageView> {
const [status, sessions] = await Promise.all([
this.fetchStatus(),
this.fetchSessions().catch(() => [] as ChatSessionSummary[]),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[P2] Chat 故障被显示成没有会话。 助手页将 /api/chat/sessions 的 503 和不兼容 schema 都当成空数组。实际页面无告警,运行会话从 1 变 0,失败会话从 1 变 0,来自 status 的 12 条待办和 1 项需要本人处理的记录仍在。只有 Chat 真返回空列表时才应这样显示。 在助手页携带会话来源的不可用或版本错误状态,显示重试并保留可用的 Goal 与 Todo;仅把成功的空数组显示为没有会话。

@maxliux5
maxliux5 force-pushed the codex/calli-workbench-projections branch from ff6d2c2 to be330cc Compare November 15, 2026 01:06
@maxliux5

Copy link
Copy Markdown
Collaborator Author

Thanks — confirmed and fixed in be330cc4d.

The dev/preview proxy forwarded every method on /api/chat to a writable service, so a same-origin POST could change chat preferences or Goal order.

Fix:

  • Explicit path allowlist and only GET/HEAD; vite dev and vite preview share the same rule.
  • Other methods on an allow-listed path return 405; paths outside the allowlist return 404.
  • Encoded traversal (.., encoded separators, double encoding, malformed escapes) is refused.
  • Unit tests cover the method/path matrix.

Evidence, identical on the dev port and the preview port:

POST   /api/chat/preferences                 -> 405 read-only workbench proxy
PUT    /api/chat/sessions/x                  -> 405 read-only workbench proxy
DELETE /status.json                          -> 405 read-only workbench proxy
GET    /api/chat/preferences                 -> 404 read-only workbench proxy
GET    /api/chat/sessions/%2e%2e/preferences -> 404 read-only workbench proxy
GET    /api/chat/capabilities                -> 200
GET    /status.json                          -> 200

All three branches in the stack were rebuilt so the same vite.config.ts and proxy-guard.ts ship in A/B/C.

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewer: model_agent · gpt-6.1-sol · OpenAI · runtime_reported · reasoning_effort=max

评审提交 be330cc,GitHub 当前列示的目标分支提交 eaff94c。

[P2] 让只读守卫覆盖 Vite 实际会转发的请求。 旧普通写现被挡住。开发和预览仍各有清单外的合成请求进入隔离上游;守卫与实际代理在入口范围上不相同,不能保证「只转发列明的 GET/HEAD」。 把明确路径和方法约束放在实际转发选择上。仅允许列明的路径及单个会话详情 ID,其余代理候选在本地拒绝。 位置。

[P2] 让助手页区分 Chat 来源不可用与没有会话。 桌面与窄屏在 503 时把运行会话从 1 变成 0,并移除原先失败的会话;1 条需用户处理和 4 条失败待办仍在。HTTP 对照确认错误版本也与真空列表完全相同,页面没有会话来源告警或重试。 沿现有错误类型保留会话来源的独立可用状态,在助手页写明暂不可用并提供重试,同时保留可用的 Goal、Todo。只有成功返回空列表才显示 0。 位置。

动机 / Motivation

主干无此 Workbench。前次提交已能读取状态和会话;评审发现代理仍转发写请求,Chat 读取失败也被助手页归为没有会话。 从助手页看正在运行和失败会话、同时保留可用待办的维护者;独立启动开发或预览入口的贡献者。 独立 Workbench 接入 LoopX 的只读投影并提供助手页;允许的代理请求和不同来源的真实状态都应可辨认。 状态服务健康。用真实代理送入支持的读取和未列明的请求,再令隔离 Chat 来源分别返回正常、503、错误版本和成功的空列表。 旧普通写已本地拒绝。代理守卫仍与实际 Vite 的候选范围不一致;Chat 的 503、不兼容版本和真空列表仍折成同一页。 上游是隔离合成状态和 Chat 数据,构建预览不是已安装应用;上游的测试应答不证明发生生产写入。未查远端 CI。

改动思路 / Approach

老 Dashboard 和 Chat 已有同一事实来源;独立的新页分别消费状态与会话。真实转发入口掌握路由,适配器应保留每个来源的结果。 保留现有状态/Chat 所有权与独立页面。代理只需一个实际转发选择器,适配器复用已有的来源错误类型并仅在成功读到空数组时报告为空。 独立 Workbench 只读连接及助手页;不改变后台写权限或真实性。

对照 既有规范 的使用者结果和边界。当前主干和 PR 目标间没有改动该 Workbench 或交付/设计规则;对主干的合并树验证成功。#8778 仍是设计提案。

  • SOURCE-SCOPE:沿现有投影提供独立、有边界的读取路径。 未通过。
  • ERROR-READBACK:可见状态必须准确区分无结果、不可用和后续恢复。 未通过。

具体改动 / Changes

新独立应用含三段堆叠内容:包、代理、移植的布局与资源、适配器、合成夹具、助手面板和测试。生产改动全在独立目录。

  • 独立 Vite 入口: 显式启用 dev/preview 及已有服务转发。
  • proxyRejection: 普通写被拒绝;仍依赖与转发不同的匹配。
  • triage: 并行读状态与会话;当前将会话读取失败转为空。
  • TriagePanel: 首屏显示三个来源混合的结果和计数。

上一次评审;修后说明。上一精确配置转发普通写,正常读成功;前次浏览器已复现 Chat 故障同空列表。新头的 adapter 与 TriagePanel 内容保持不变。 旧普通写已本地拒绝。代理守卫仍与实际 Vite 的候选范围不一致;Chat 的 503、不兼容版本和真空列表仍折成同一页。

对主干的风险 / Risks

  • PASS — TypeScript 和 Vite 构建、232 项本地测试、17 项隔离投影检查和 no-second-state 检查通过。 开发与预览都保留正常读取并拒绝前次普通写;固定状态投影下,正常会话在助手页出现。
  • FAIL — 在真实 dev 和 preview 用同一隔离上游对照合法读、未列明的相近路由和非读取方法;所有未列明候选均不能到达上游。 同一健康的状态投影下复验 Chat 正常、503、版本错误、真空列表及恢复;后两类错误必须和真空列表有不同的页面/读回结果。
  • UNVERIFIED — 上游是隔离合成状态和 Chat 数据,构建预览不是已安装应用;上游的测试应答不证明发生生产写入。未查远端 CI。

我的整体评价 / Verdict

REQUEST_CHANGES。把明确路径和方法约束放在实际转发选择上。仅允许列明的路径及单个会话详情 ID,其余代理候选在本地拒绝。 沿现有错误类型保留会话来源的独立可用状态,在助手页写明暂不可用并提供重试,同时保留可用的 Goal、Todo。只有成功返回空列表才显示 0。 已构建的桌面与窄屏首屏均重现误导:503 时运行和失败会话消失,运行区仍显示「这里暂时没有」。 只验助手页三组已展示的结果及部分来源故障;所用数据没有折叠的等待详情。未验证已安装、原生移动或真实外部连接。

English verdict: REQUEST_CHANGES at be330cc. The prior ordinary writes are blocked, but both Vite entrypoints still forward requests outside the declared read set. The Desk also renders a Chat 503 or incompatible schema as an empty session list.

const unsafeMethod = !SAFE_METHODS.has((method ?? 'GET').toUpperCase());
// A path that climbs or hides a separator is refused when it sits under a proxied prefix.
if (path === null) return proxied(new URL(raw, 'http://local').pathname) ? (unsafeMethod ? 405 : 404) : null;
if (!proxied(path)) return null;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[P2] 让只读守卫覆盖 Vite 实际会转发的请求。 旧普通写现被挡住。开发和预览仍各有清单外的合成请求进入隔离上游;守卫与实际代理在入口范围上不相同,不能保证「只转发列明的 GET/HEAD」。 把明确路径和方法约束放在实际转发选择上。仅允许列明的路径及单个会话详情 ID,其余代理候选在本地拒绝。

async triage(): Promise<TriageView> {
const [status, sessions] = await Promise.all([
this.fetchStatus(),
this.fetchSessions().catch(() => [] as ChatSessionSummary[]),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[P2] 让助手页区分 Chat 来源不可用与没有会话。 桌面与窄屏在 503 时把运行会话从 1 变成 0,并移除原先失败的会话;1 条需用户处理和 4 条失败待办仍在。HTTP 对照确认错误版本也与真空列表完全相同,页面没有会话来源告警或重试。 沿现有错误类型保留会话来源的独立可用状态,在助手页写明暂不可用并提供重试,同时保留可用的 Goal、Todo。只有成功返回空列表才显示 0。

maxliux5 and others added 3 commits November 15, 2026 04:09
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: maxliux5 <lualiudd@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: maxliux5 <lualiudd@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: maxliux5 <lualiudd@gmail.com>
@maxliux5
maxliux5 force-pushed the codex/calli-workbench-projections branch from be330cc to f3a2788 Compare November 15, 2026 04:13
@maxliux5

Copy link
Copy Markdown
Collaborator Author

Agreed — the guard middleware and the Vite proxy made separate routing decisions, so a path outside the guard's list could still be forwarded. Fixed by collapsing them into one boundary (f3a2788bb):

  • A and B no longer configure any proxy. Neither layer makes a network call; the proxy now lands in C together with its first caller, as suggested.
  • C replaces server.proxy entirely with a single middleware (readonly-forward.ts) that enumerates the allowed routes and forwards them itself with node:http. Matching and forwarding are the same code. Unlisted paths get a local 404; an enumerated route with a method other than GET/HEAD gets a local 405. Session details match a single plain segment; ., .., encoded separators and multi-segment ids fail the match. Only Accept/Accept-Language are forwarded; Origin is dropped. A down upstream answers 502.
  • Tests run against two loopback fake upstreams that count requests and assert they receive zero requests for every rejected case (writes, unlisted paths, encoded traversal, multi-segment ids). Seven allowed routes each hit exactly their own upstream once.

Fake-upstream test results (npm test):

ok - each enumerated route is forwarded to its own upstream exactly once
ok - the query string travels, the fragment does not, HEAD is forwarded as HEAD
ok - a write to an enumerated route is a local 405 and the upstream sees nothing
ok - anything not enumerated is a local 404 and the upstream sees nothing
ok - paths outside the service namespace are left to the page server
ok - an upstream that is down gives 502, not a hang or a crash

Curl evidence, identical on the dev port and the preview port:

POST /api/chat/preferences -> 404    POST /api/chat/sessions -> 405
PUT  /api/chat/sessions/x  -> 405    DELETE /status.json     -> 405
GET  /api/chat/preferences -> 404    GET /api/chat/sessions/a/b -> 404
GET  /api/chat/sessions/%2e%2e/preferences -> 404
GET  capabilities | endpoints | goals/contexts | sessions | /status.json | /ssh-hosts -> 200

All three branches are rebuilt on the latest main so the same layering ships across A/B/C.

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewer: model_agent · gpt-6.1-sol · OpenAI · runtime_reported · reasoning_effort=max

评审 f3a2788bbb9908e148880d6f46b3f813242c7019。实际差异基点 1965965992fffa1a1cca1a18cb297860155bc133,与当前主干 f7e3f427197bab6c66ab535e26613a7f9c2fdbe0 的本地合并模拟通过。

动机 / Motivation

用户把 Workbench 助手页留在前台,想确认当前有哪些会话在跑、哪些出错,以及连接中断时如何恢复。 主干没有这个独立 Workbench。已有状态与 Chat 各有原生投影,前一层 Workbench 只展示内置演示数据。 当前层改用 LoopX 原生读取投影、保持只读,并在状态与会话可用时把待处理、运行和失败集中展示。

先在打包预览打开健康的助手页,再只让 Chat 会话列表故障,让状态服务保持 200;比较已打开页面、故障时直接打开、真实空列表和恢复。 打开页面后 Chat 返回 503,运行从 1 变成 0,失败从 5 变成 4,页面没有故障提示或重试。状态服务仍是 200,需用户处理的 1 项仍在。 故障时直接打开则出现通用服务提示和重试,成功空列表没有这条提示。 本轮使用精确 Vite production preview 和两个隔离合成状态/Chat 上游,dev 与 preview 均做了路径反例。真实已安装产品与长期数据未经此轮验证。

改动思路 / Approach

保留现有 LoopX 投影读取与只读转发。给类型化会话读取和轮询结果增加来源状态,沿用助手页已有重试,不另建任务或会话状态表。 本轮使用精确 Vite production preview 和两个隔离合成状态/Chat 上游,dev 与 preview 均做了路径反例。真实已安装产品与长期数据未经此轮验证。

Vite 的 dev 与 preview 共用一个 HTTP 方法和路径决定。Workbench 使用同源读取协议输出,只保存显示偏好。 两种 Vite 入口各 31 个请求全部符合预期,列明的 GET/HEAD 每次只到对应上游一次,17 个拒绝场景各零转发。源端仅接收允许头,未接收 Origin 或 Cookie。 验收边界 此前评审

助手页的输入 在跑 出错 会话来源提示
状态和会话健康 1 5 无
页面已打开,Chat 返回 503 0 4 无,且无重试
Chat 失败时新开页面 0 4 通用服务错误和重试
Chat 真正返回空列表 0 4 无

具体改动 / Changes

目标基线相差 117 个文件、44,172 行新增,均在独立 Workbench 目录,包含未合的脚手架和 shell。相对直接父提交,本片 46 文件、+4,214/-309,含代理、适配与映射、客户端界面、可执行测试、锁和文档。

关键代码讲解

  • 同一中间件选择并转发已列资源。 两种入口的允许和拒绝均匹配 createReadOnlyForwarder
  • 将 Chat 获取失败转换为空数组后计算卡片。 用户看到零运行和减少的失败 LoopXApiAdapter.triage
  • 轮询 status 和会话,对成功快照比较摘要。 已有页面的故障缺少恢复提示 streamGlobal
  • 在 Desk 呈现三组计数并提供会话详情入口。 需要你、在跑、出错按现有数组显示 TriagePanel
  • 同时更新 Todo 和助手分组,复用页面当前重试和局部状态。 健康状态源仍可用 reloadTodos

以现行的产品与仓库约束核对候选。 适用规范

  • WB-只读转发。列明资源可读,写方法、未列路径和编码越界不进入源端。 两种 Vite 入口各 31 个请求全部符合预期,列明的 GET/HEAD 每次只到对应上游一次,17 个拒绝场景各零转发。源端仅接收允许头,未接收 Origin 或 Cookie。
  • WB-源故障可辨。已打开的助手页保留会话来源失败和可执行恢复,维持健康状态源的工作。 打开页面后 Chat 返回 503,运行从 1 变成 0,失败从 5 变成 4,页面没有故障提示或重试。状态服务仍是 200,需用户处理的 1 项仍在。
  • WB-实际下钻与离线。只读详情可下钻,离线模式使 API 请求为零。 故障时新开的助手页恢复上游后可点重试,重新读到 1 个运行会话和 5 项失败。运行会话可打开真实预览详情,输入区显示只读。 预览离线页无服务请求。

对主干的风险 / Risks

[P2] 已打开的助手页把 Chat 故障显示成零会话。 打开页面后 Chat 返回 503,运行从 1 变成 0,失败从 5 变成 4,页面没有故障提示或重试。状态服务仍是 200,需用户处理的 1 项仍在。 会话离线被解释成已经没有在跑的工作,操作者会忽略失联会话和原失败,且没有入口恢复这次只读刷新。 使轮询传递独立的 Chat 可用性和最后成功观察。只有成功的空列表显示为零;故障时保留可用状态卡,给会话区显示暂不可用和重试。 代码位置

精确构建通过,233 项 npm 测试、状态所有权扫描和 62 次真实 Vite 转发检查通过。本地 quick premerge 自动检查通过,人工门槛仍保留。 npm audit 仍报告开发工具链的两项警告,本轮未评价其实际可利用性。

我的整体评价 / Verdict

REQUEST_CHANGES。 转发边界已收敛,现有 dashboard/Chat 仍是状态 owner。 两层脚手架与界面仍在独立 PR 栈。修复后的故障呈现需要在精确预览读回,安装及长时原生使用需另行核对。 桌面三列与 390px 纵向三组均先显示需要本人处理、运行与错误。展开运行会话保留可阅正文和只读输入区。已开页面的 Chat 故障没有来源提示,运行卡写着“这里暂时没有”,左侧仍保留原会话和运行标识。 触屏、两语完整交互和已安装原生 App 尚未覆盖。

English verdict: REQUEST_CHANGES at f3a2788. Dev and preview now forward only the enumerated read routes. After the mounted Desk sees Chat 503 with status still healthy, the running count drops to zero and a previous failure disappears without a warning. Preserve source availability and retry in the live view.

async triage(): Promise<TriageView> {
const [status, sessions] = await Promise.all([
this.fetchStatus(),
this.fetchSessions().catch(() => [] as ChatSessionSummary[]),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

[P2] 已打开的助手页把 Chat 故障显示成零会话。 打开页面后 Chat 返回 503,运行从 1 变成 0,失败从 5 变成 4,页面没有故障提示或重试。状态服务仍是 200,需用户处理的 1 项仍在。 使轮询传递独立的 Chat 可用性和最后成功观察。只有成功的空列表显示为零;故障时保留可用状态卡,给会话区显示暂不可用和重试。

This branch has not been deployed

No deployments
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.

2 participants