Commit Graph

146 Commits

Author SHA1 Message Date
yan
c380228b06 fix: 4 MagicLizi P1 复审修复
P1-1: UpgradeBanner i18n 五语文案去掉硬编码 Claude Code, 改为中性表述
P1-3: pi-harness.md 版本差升级描述修正为 defer+UpgradeBanner 实现
P1-4: 清掉 [pi-ssh-diag] 临时诊断日志 (6 处 console.error)

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: yan <yan233@xd.com>
2026-08-14 09:16:11 +08:00
yan
0647f4fb97 feat(pi): SSH remote 支持 + TS pi-manager daemon + Orca 协同
- PiAgent 支持 SSH remoteHostId:凭证路由/权限/远端 fs 通道全链路
- Python per-session 薄壳 daemon 升级为 TS 单例 pi-manager(unix socket RPC
  + per-host 常驻 + 条件 restart + 空闲回收 + 断链保活)
- 解锁 remote pi 创建 orca workers(worker 继承 lead.remoteHostId)
- spawn env 稳定性:sessionToken 改 HMAC 派生 + bridge token generation
  追踪, 修复会话重建被误 kill
- 远端安装/升级/卸载链(pi-manager installer + probe/ensure + 静默安装)
- maker-pi-manager 全量单测 + desktop/pi 集成测试(Linux CI 全绿)

Signed-off-by: yan <yan233@xd.com>
2026-08-14 09:15:41 +08:00
Lizi
a94d019579 feat(test): 本地提交默认只跑和改动相关的单测
本地门禁改为 pnpm test:unit:related:按相对 main 的全部改动选测。
改到测试调度或依赖清单时退回全量。CI 仍跑完整 pnpm test:unit。

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Lizi <jiali@magiclizi.com>
2026-08-14 01:24:44 +08:00
Lizi
274a4948d5 Merge pull request #1916 from Yuewei-LL/redo/plugin-approval-receipt-migration
fix(desktop): harden plugin approval migration and recovery
2026-08-13 19:14:58 +08:00
Dash
150f2545d1 fix(orca): UI 创建 Worker 时按需交接 Lead 上下文 (#2589)
* fix(orca): hand off lead context to UI workers

Signed-off-by: Dash <dashhuang@gmail.com>

* fix(orca): include pending lead input in UI handoff

Signed-off-by: Dash <dashhuang@gmail.com>

* fix(orca): defer UI worker handoff until lead context exists

Signed-off-by: Dash <dashhuang@gmail.com>

* fix(orca): recover deferred UI assignments safely

Signed-off-by: Dash <dashhuang@gmail.com>

---------

Signed-off-by: Dash <dashhuang@gmail.com>
2026-08-13 18:47:02 +08:00
Yuewei-LL
685da573db Merge origin/main into redo/plugin-approval-receipt-migration
Signed-off-by: Yuewei-LL <308228674+Yuewei-LL@users.noreply.github.com>
2026-08-13 16:47:48 +08:00
Lizi
a034e93a84 Merge pull request #2295 from xindong/codex/issue-2014-pi-approved-resource-assembly
为 Pi 装配已批准的项目技能
2026-08-13 10:49:05 +08:00
Yuewei-LL
403cd46e72 chore: merge origin/main into redo/plugin-approval-receipt-migration
Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Yuewei-LL <308228674+Yuewei-LL@users.noreply.github.com>
2026-08-11 20:51:26 +08:00
Dash
4d6c694b4f fix(desktop): 修复区域 userData 与共享实例登录态隔离 (#2457)
* fix(desktop): 修复区域 userData 与共享实例登录态隔离

Signed-off-by: Dash <dashhuang@gmail.com>

* fix(desktop): align regional dev storage consumers

Signed-off-by: Dash <dashhuang@gmail.com>

* fix(mobile): align realdata export with regional profile

Signed-off-by: Dash <dashhuang@gmail.com>

---------

Signed-off-by: Dash <dashhuang@gmail.com>
2026-08-11 20:33:18 +08:00
Yuewei-LL
0337d36889 chore: merge origin/main into redo/plugin-approval-receipt-migration
Resolve conflicts in bootstrap-electron.ts and ios-simulator.test.ts.
- bootstrap-electron.ts: keep our teardownGhostProjectionBoundary including
  device-link ownership release, lifecycleDbClient dispose, localDbCloseDb,
  agentIslandService reset, and AggregateError on blocking failures
- ios-simulator.test.ts: include both the new IOSSimulatorToolRegistry import
  from main and our vi.mock for isAppSessionBoundaryPending

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Yuewei-LL <308228674+Yuewei-LL@users.noreply.github.com>
2026-08-11 20:21:02 +08:00
DavidShenXD
a4f9ef4e40 perf(desktop): 资源用量窗口预热复用,消除打开延迟 (#2434)
* perf(desktop): 资源用量窗口预热复用,消除打开延迟

本次将资源用量窗口从点击后冷建改为后台预热+隐藏复用,对齐 Codex Desktop
独立浮窗的瞬开体验,并落地为仓库级约束规则。

核心变化:
- 新增 ResourceUsageWindowController:主窗口首帧后后台预热隐藏窗口及
  首份进程数据,用户点击仅 show+focus(约 6ms),关闭只隐藏不销毁
- 拆分 renderer 入口:index.tsx 仅做分发,新增 main-entry.tsx 承载
  主应用链路、resource-usage-entry.tsx 承载轻量资源窗口链路
- 独立 preload(resourceUsagePreload.ts):最小权限 bridge
- 双阶段就绪握手(renderer-ready / presentation-ready)+
  5s 超时兜底 Loading 壳
- 崩溃恢复有界、建窗异常隔离、隐藏时重置按钮交互态
- 新增约束规则 docs/dev-rules/electron-security-and-process-boundaries.md
  §3.1:后续独立辅助窗口必须复用此生命周期基线

验证:
- Desktop 全仓单测:23806/23806 通过
- Desktop typecheck:通过
- 相关定向测试:96/96 通过
- 实机打开/关闭/二次打开验收通过
- 移动端冷更:不涉及(纯 desktop Electron 窗口改动)

Signed-off-by: DavidShen <david@xd.com>

* fix(desktop): 允许会话副窗口打开资源用量

Signed-off-by: DavidShen <david@xd.com>

* fix(desktop): 保留旧资源用量页签

Signed-off-by: DavidShen <david@xd.com>

* fix(desktop): 同步资源用量窗口语言

Signed-off-by: DavidShen <david@xd.com>

---------

Signed-off-by: DavidShen <david@xd.com>
2026-08-11 19:35:43 +08:00
Yuewei-LL
3593497d40 fix(desktop): defer target-root scan until recovery candidates exist
In getLegacyGhostRecoveryStatus, the target-root scan now only runs
when there are legacy sources or pending recovery IDs.  In a normal
profile with no legacy plugins, a corrupt ghost.json in the owner root
could block the recovery-status IPC or report a spurious deferred
status (P2, review #3757054096).

Add checklist item 6.5a to plugin-security-and-authoring.md codifying
the TOCTOU defense pattern for path-based workers: pre-check (fast fail)
→ atomic operation → post-operation verification → identity-guarded
cleanup.  The pre-check-to-rename gap is the irreducible platform
boundary (Node.js does not expose renameat).

Add header comments to ghostSnapshotWorkerProcess.ts and
forgeScaffoldWorkerProcess.ts documenting their defense strategies,
identifying the platform hard boundary, and referencing the checklist
item so future reviewers understand the final achievable layer.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Yuewei-LL <308228674+Yuewei-LL@users.noreply.github.com>
2026-08-11 18:48:47 +08:00
Yuewei-LL
6b8712af39 Merge branch 'origin/main' into redo/plugin-approval-receipt-migration
Resolved conflicts in index.ts and nodeRuntimeBroker.ts:

index.ts (market update path): Union of both sides — keep main's
agent/errand slot clearing before rename (Windows EPERM fix) AND the PR's
expectedInstalledApproval receipt-token guard (required for receipt-based
authorization model).

index.ts (local .cindy install): Keep PR's lock ordering (owner lease
outside per-id install lock, per documented invariant that prevents
deadlock). Absorb main's runtime.stop + stopAndWait calls inside the
lock for safe directory replacement on Windows.

nodeRuntimeBroker.ts (child process dispatch): Union of three independent
safety gates — main's worker entry identity check (skip stale entries),
main's stoppedGhosts check (refuse fork during shutdown), and the PR's
ownerScopeUsable check (reject stale owner scope callbacks).

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Yuewei-LL <308228674+Yuewei-LL@users.noreply.github.com>
2026-08-11 16:20:55 +08:00
bobo
b247c2d324 refactor(protocol): 本地化跨端协议包 (#2373)
* refactor(protocol): localize shared protocol packages

Signed-off-by: xd-bobo <caojianbo@xd.com>

* fix(protocol): align localized contracts with consumers

Signed-off-by: xd-bobo <caojianbo@xd.com>

* fix(protocol): keep model currency optional

Signed-off-by: xd-bobo <caojianbo@xd.com>

* fix(protocol): align legacy model and plugin fields

Signed-off-by: xd-bobo <caojianbo@xd.com>

* fix(protocol): preserve plugin oauth metadata

Signed-off-by: xd-bobo <caojianbo@xd.com>

---------

Signed-off-by: xd-bobo <caojianbo@xd.com>
2026-08-11 15:31:27 +08:00
nana
2e97fbde75 fix(pi): snapshot approved project skills before launch
Signed-off-by: nana <823073145@qq.com>
2026-08-10 18:22:58 +08:00
nana
2a93b10604 Merge origin/main into codex/issue-2014-pi-approved-resource-assembly
Signed-off-by: nana <823073145@qq.com>
2026-08-10 17:17:13 +08:00
Yuewei-LL
d5e8c617f6 docs(dev-rules): drop per-merge decision logs from the repo
These merge decision records are working notes for the PR author; they are
kept locally (E:\Cindy\document) rather than shipped in the PR.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Yuewei-LL <308228674+Yuewei-LL@users.noreply.github.com>
2026-08-10 15:58:21 +08:00
Yuewei-LL
efa1fce9b9 fix(desktop): bump owner generation on same-owner projection repair
When the durable Ghost projection boundary is missing or quarantined while
the app session is already committed to the same owner, the repair tears down
the owner-bound Ghost runtime but commitActiveAppSession's same-owner early
return did not advance the owner generation. Async work that captured the
pre-repair activeOwnerScopeKey() could then pass the stale-scope guard after
the boundary was released.

commitActiveAppSession now accepts forceBumpGeneration to advance generation
even on the same-owner path, and withCloudOwnerCommit sets it after a
same-owner projection repair so the scope key changes across the teardown.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Yuewei-LL <308228674+Yuewei-LL@users.noreply.github.com>
2026-08-10 15:57:00 +08:00
Yuewei-LL
b93e7daa3d docs(dev-rules): record third main merge for PR #1916
Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Yuewei-LL <308228674+Yuewei-LL@users.noreply.github.com>
2026-08-10 15:28:46 +08:00
Yuewei-LL
ae5cfcb40a fix(desktop): make cross-process lock legacy takeover fail closed
A legacy lock without processStartIdentity whose pid is alive can be the
original holder still running mid-drain with a stale mtime, so it must never
be taken over. isRecordOwnerActive now treats a live non-self pid as the
active holder unconditionally (timing- and platform-independent), and a
PID-reuse takeover is only accepted when the recorded processStartIdentity
demonstrably does not match the current process.

This replaces a birthtime-based comparison that decided differently on
filesystems without a usable birthtime (Linux CI failed the PID-reuse test),
and a mtime-fallback that made the 'live owner must not be squeezed out'
guard depend on the parent process's age. The PID-reuse test now records a
mismatching identity ('start-ms:0') instead of relying on a sentinel
startedAt + stale mtime.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Yuewei-LL <308228674+Yuewei-LL@users.noreply.github.com>
2026-08-10 15:19:26 +08:00
Yuewei-LL
ce113f0333 Merge branch 'main' (9bcf7bd1a) into redo/plugin-approval-receipt-migration
Second merge of origin/main into the plugin-approval branch. Conflict
resolution and integration decisions are recorded in
docs/dev-rules/plugin-approval-main-merge-2026-08-10.md; the invariants from
the 2026-08-09 merge carry forward unchanged:

- GhostManager.ts: keep the PR's legacy approval projection, receipt-backed
  install/update/setEnabled/uninstall transactions, journal/quarantine, and
  no-follow checks; keep main's host-unsupported manifest hint. The mutable
  .cindy-trust.json mirror is not projected (removed readInstalledHostMetadata).
  Icon byte cap normalized to the shared GHOST_ICON_MAX_BYTES.
- index.ts: keep the owner-boundary pending guard on availableGhosts/
  findAvailableGhost and the exported *ForAuthorization helpers; keep the
  builtin approval reconcile loop and resident heal; every slot/broker keeps
  the durable owner scope instead of a bare list().find().
- shared/ghost.ts: keep the PR's superset permission fingerprint (kind,
  normalized labelKey, labelArgs, detail*) for baseline, diff, and unreviewed
  gates so a permission-surface change is never masked.
- crossProcessLock.ts: keep main's EBUSY/EPERM/EACCES retry handling together
  with the PR's nonce-bound release marker and malformed-gate fail-closed
  reclaim.
- Tests: keep the PR's legacy/update helpers and receipt-model assertions; add
  main's host-unsupported and ios-simulator suites (owner-boundary mock only
  overrides the module default for non-boundary suites; production code is
  byte-identical to origin/main).
- Docs: keep the receipt row in plugin-security-and-authoring.md alongside
  main's reformatted table and new paragraphs.

Signed-off-by: Yuewei-LL <308228674+Yuewei-LL@users.noreply.github.com>
2026-08-10 13:47:22 +08:00
Yuewei-LL
fa8b855053 fix(desktop): harden plugin approval migration, recovery, and market re-approval
- Legacy approval backfill no longer fails because an optional icon is missing,
  oversized, or unreadable: icon data is presentation-only and degrades to no
  icon instead of marking the migration failed (Codex P1). The projection hash
  stays deterministic (iconDataUrl ?? null).
- Mutable .cindy-trust.json mirrors no longer project trust; Host receipt is the
  only authorization fact, and a corrupted mirror cannot override a valid
  official receipt. Built-in provisioning writes cindy-github trust through the
  same staged swap under the durable seeded ledger claim.
- Cross-process reclaim gates publish a nonce-bound .released sidecar when the
  released record cannot be flushed, and malformed gates are reclaimed only
  after proving the owner died or the PID was reused; cleanup removes both the
  gate and its marker.
- Market default-plugin upgrades bind the confirmed approval token
  (expectedInstalledApproval) and re-verify it under the per-ghost lock; a
  legacy-unapproved/invalid plugin still requires the full host-side review and
  cannot be silently re-approved. Default-upgrade baseline now uses the
  installed manifest key, and a vanished installed record skips the upgrade.
- Windows ssh-add path probe treats win32 'UNKNOWN' errno on absolute paths as
  no_such_file.
- Adds zh-TW reapproval/legacy-recovery UI copy and updates the main-merge
  decision record.

Regression tests cover the optional-icon backfill, trust-mirror corruption,
reclaim-gate marker recovery, and default-upgrade approval binding.

Signed-off-by: Yuewei-LL <308228674+Yuewei-LL@users.noreply.github.com>
2026-08-10 12:59:39 +08:00
Yuewei-LL
0026124fce Merge branch 'main' (e78f44ae5) into redo/plugin-approval-receipt-migration
Resolve merge conflicts with origin/main per the decision record in
docs/dev-rules/plugin-approval-main-merge-2026-08-09.md:

- Trust and GhostManager: keep main's complete official-trust validation and
  the PR's rule that a mutable .cindy-trust.json cannot mint approval; keep the
  PR's receipt, approval projection, journal, owner, and failure-closed paths.
- Bounded reads: combine the PR's no-follow/stable-read implementation with
  main's optional non-blocking, hard-link, and stat-returning APIs.
- Built-in provisioning: retain the PR's seed fingerprint, link-free checks,
  durable tombstone/seed ledger, and rollback semantics; wrap the complete
  per-id installed-directory exchange in main's Ghost install lock.
- Market install/update: retain expectedInstalledApproval, reviewed manifest and
  baseline checks, and the receipt token at the final commit; also retain main's
  beforeCommitInLock callback and stale-baseline behavior.
- Permission fingerprints: use main's detailKey/detailArgs projection while
  preserving the PR's stable approval baseline and diff behavior.
- Auth cold start and subscription hooks: keep the PR's owner-bound recovery and
  captured-owner validation, incorporating main's fast paths and deadline-aware
  wake while remaining fail-closed.
- Tests and documentation: union of security regression tests and main
  behavioral tests.

Signed-off-by: Yuewei-LL <308228674+Yuewei-LL@users.noreply.github.com>
2026-08-10 12:59:07 +08:00
bobo
e11835029e chore(protocol): remove unused shared packages (#2324)
Signed-off-by: xd-bobo <caojianbo@xd.com>
2026-08-10 12:20:28 +08:00
JiangJiahao
255fbc2a13 Merge remote-tracking branch 'upstream/main' into feat/issue-397-ios-simulator-native-framebuffer
Signed-off-by: JiangJiahao <jiangjiahao@xd.com>

# Conflicts:
#	apps/desktop/src/shared/__tests__/ghost.test.ts
#	apps/desktop/src/shared/ghost.ts
#	i18n/glossary.json
2026-08-10 09:25:24 +08:00
Yuewei-LL
dc9614e172 fix(desktop): harden plugin approval owner boundaries
Signed-off-by: Yuewei-LL <308228674+Yuewei-LL@users.noreply.github.com>
2026-08-10 06:09:39 +08:00
Dash
e78f44ae56 feat(i18n): 支持繁体中文语言 (#2148)
* feat(i18n): add Traditional Chinese locale support

Signed-off-by: Dash <dashhuang@gmail.com>

* fix(i18n): align Traditional Chinese catalog keys

Signed-off-by: Dash <dashhuang@gmail.com>

* fix(i18n): align mobile language order and release fallback

Signed-off-by: Dash <dashhuang@gmail.com>

* fix(i18n): sync Traditional Chinese keys with main

Signed-off-by: Dash <dashhuang@gmail.com>

* fix(i18n): polish Traditional Chinese copy

Signed-off-by: Dash <dashhuang@gmail.com>

* fix(i18n): sync Traditional Chinese stream copy

Signed-off-by: Dash <dashhuang@gmail.com>

* fix(i18n): sync Traditional Chinese resume copy

Signed-off-by: Dash <dashhuang@gmail.com>

* fix(i18n): sync Traditional Chinese help copy

Signed-off-by: Dash <dashhuang@gmail.com>

* fix(i18n): unify Traditional Chinese plugin terminology

Signed-off-by: Dash <dashhuang@gmail.com>

* fix(i18n): localize session notifications

Signed-off-by: Dash <dashhuang@gmail.com>

* fix(plugin): preserve manifest locale compatibility

Signed-off-by: Dash <dashhuang@gmail.com>

* fix(i18n): close Traditional Chinese review gaps

Signed-off-by: Dash <dashhuang@gmail.com>

* fix(plugin): clamp app-context locale values

Signed-off-by: Dash <dashhuang@gmail.com>

* fix(i18n): localize presets and secure login preview

Signed-off-by: Dash <dashhuang@gmail.com>

* fix(desktop): scope nested dialog dismissal

Signed-off-by: Dash <dashhuang@gmail.com>

* fix(desktop): make dismissal and title formatting deterministic

Signed-off-by: Dash <dashhuang@gmail.com>

* fix(i18n): unify Traditional Chinese privacy policy term

Signed-off-by: Dash <dashhuang@gmail.com>

* fix(docs): align login QA locale coverage

Signed-off-by: Dash <dashhuang@gmail.com>

* fix(docs): derive locale QA from supported languages

Signed-off-by: Dash <dashhuang@gmail.com>

* fix(i18n): sync Traditional Chinese with latest main

Signed-off-by: Dash <dashhuang@gmail.com>

---------

Signed-off-by: Dash <dashhuang@gmail.com>
2026-08-10 03:25:41 +08:00
nana
f3ebdd8105 fix(pi): assemble approved project skills safely
Signed-off-by: nana <823073145@qq.com>
2026-08-10 01:09:45 +08:00
JiangJiahao
523d6d2d07 Merge remote-tracking branch 'upstream/main' into feat/issue-397-ios-simulator-native-framebuffer 2026-08-09 13:42:19 +08:00
nanaco
41f916f625 feat(pi): define Cindy project trust contract (#2056)
* feat(pi): define Cindy project trust contract

Signed-off-by: nana <823073145@qq.com>

* fix(pi): close project trust capability review gaps

Signed-off-by: nana <823073145@qq.com>

* docs(pi): clarify fresh session trust contract

Signed-off-by: nana <823073145@qq.com>

* test(pi): exercise settings projection validators

Signed-off-by: nana <823073145@qq.com>

* fix(pi): fail closed on unsafe Windows path folding

Signed-off-by: nana <823073145@qq.com>

* fix(pi): honor Windows case comparison identity

Signed-off-by: nana <823073145@qq.com>

* fix(pi): reject incomplete Windows UNC identities

Signed-off-by: nana <823073145@qq.com>

* fix(pi): require canonical skill path evidence

Signed-off-by: nana <823073145@qq.com>

* fix(pi): close trust projection boundary gaps

Signed-off-by: nana <823073145@qq.com>

* fix(pi): preserve canonical resource I/O paths

Signed-off-by: nana <823073145@qq.com>

---------

Signed-off-by: nana <823073145@qq.com>
Co-authored-by: nana <823073145@qq.com>
2026-08-09 03:52:54 +08:00
JiangJiahao
eda5c5cad5 Merge remote-tracking branch 'upstream/main' into feat/issue-397-ios-simulator-native-framebuffer 2026-08-09 02:23:43 +08:00
Dash
8986786609 fix(device-link): relay 拥塞断连(1013)引入独立重连冷却,掐断重连-重放-再被踢循环 (#2185)
* fix(device-link): relay 拥塞断连(1013)引入独立重连冷却,掐断重连-重放-再被踢循环

relay 因聚合出站速率过高以 close 1013(Try Again Later,reason=inbound
backpressure)主动断连时,现有退避把它当普通断线:上一条连接只要稳定
在线过 reconnectStableResetMs,退避就已归零,断后 ~1s 即重连,重连又
触发全量重放洪峰,立刻复现被踢条件(2026-08-08 线上:两次 1013 间隔
15s,第二条连接只活 7s,期间控制端全部超时熔断,手机显示「电脑端
未响应」)。

改动(全部 client 本机行为,协议零改动):

- 新增连续拥塞断连计数 congestionCloseStreak,驱动重连冷却下限:
  第 N 次连续 1013 后至少等 min(5s × 2^(N-1), 30s),与普通指数退避
  取 max,保留既有 0.7x–1.0x 向下抖动。
- 生命周期与 reconnectAttempt 刻意不同:握手成功不清零,只在稳定在线
  满 reconnectStableResetMs 后清零——拥塞信号不因「重连成功」而失效;
  start()(登录/切号)清零;connectNow/restartConnection(前台恢复/
  唤醒)不清零,立即重连可以,但再被踢则冷却加深。
- 延迟计算抽成纯函数 computeReconnectDelayMs 供确定性单测(random
  注入,不做计时断言)。
- 1013 断连记一条 WARN(含连击数),配合 #1385 的断开可观测方向。

故障半径:触发条件是第四层「relay 聚合背压」(非任何单个请求/peer);
恢复动作同半径——只调整整条连接的重连时机,不触碰 per-peer link、
pending 与在途请求(断线语义与既有路径完全一致)。多 peer 拓扑:本
改动不进入任何 peer 分支,peer 状态处理零变化,新增用例断言连击的
计入/保持/清零生命周期与延迟曲线;文档同步把第四层写进
remote-and-mobile-adaptation.md 的故障半径框架。

验证:packages/device-link vitest 170/170、tsc --noEmit 通过,根
pnpm test:unit 门禁通过(GATE_EXIT=0)。

Signed-off-by: Dash <dashhuang@gmail.com>

* fix(device-link): 拥塞冷却不被请求路径打穿,connectNow 冷却语义收口(review 收敛)

review 首轮三条,归为「冷却的旁路完整性」一族一并修:

- 请求路径不再打穿冷却(codex P1,要害):事故形态下在途请求经
  waitUntilOnline → connectNow 清掉冷却计时器,每次 1013 后仍立即
  重连,循环掐不断。connectNow 在拥塞冷却计时器运行期间默认 park
  (不清计时器、不触碰退避状态、直接返回);显式用户意图传
  overrideCongestionCooldown 保留立即重连(mobile 回前台已接线)。
- stopped 经 connectNow 拉起 = 新生命周期(greptile P1):与 start()
  对齐,清拥塞连击,不背上一世代的冷却档位。
- computeReconnectDelayMs 入参钳制 + 非稳定 API 声明(copilot P2):
  attempt/streak 取整夹到 ≥0、random 夹到 [0,1],非有限值按 0,
  不再可能产生 NaN/负延迟;注释明确它是包内部工具、为确定性单测
  保留导出,不属于稳定公共 API 面。

restartConnection(系统唤醒)保持既有语义:睡醒半开假活是独立故障
域,其重建不受拥塞冷却约束,与 mobile 回前台同属显式恢复意图。

新增用例:冷却期 waitUntilOnline 不 un-park(不新建连接、有界快速
失败)/ override 立即重连 / 非拥塞断线 un-park 行为不变 / stopped
拉起清连击 / 钳制边界。

验证:packages/device-link vitest 174/174、tsc --noEmit 通过,mobile
typecheck 通过,根 pnpm test:unit 门禁通过(GATE_EXIT=0)。

Signed-off-by: Dash <dashhuang@gmail.com>

* test(device-link): 补 1013 冷却的多 peer 拓扑回归(故障半径 §3)

review(codex P1)指出恢复路径改动必须带 ≥2 peer 用例,规则
remote-and-mobile-adaptation §3 亦如此要求——之前只有连接级计数与
延迟曲线断言,确实不足以证明「没引入新的不对称」。

新增用例:一条 relay 连接服务两个控制端(被控端拓扑),各持一条未
ACK 的在途 invoke-result;1013 拥塞断连后断言
- 冷却期内谁都拿不到新连接(一视同仁,没有 peer 被单独放行/惩罚);
- 冷却到点重连并重建两条 link 后,两个 peer 的 pending 各自按原 seq
  重放,一条不丢、不串 stream。

在途帧刻意用 invoke-result 而非 push:push 是 best-effort 镜像,建链
时会被可丢弃前缀清扫丢弃(#1375 既有设计),验证不了「pending 跨冷却
保留」;invoke-result 也正是「另一个 peer 的在途请求回包」本身。

验证:packages/device-link vitest 175/175、tsc --noEmit 通过,根
pnpm test:unit 门禁通过(GATE_EXIT=0)。

Signed-off-by: Dash <dashhuang@gmail.com>

---------

Signed-off-by: Dash <dashhuang@gmail.com>
2026-08-09 00:09:28 +08:00
JiangJiahao
429dc9ce5a Merge upstream/main at 0e910eeac
Signed-off-by: JiangJiahao <jiangjiahao@xd.com>
2026-08-08 09:00:30 +08:00
fmfsaisai
648d26721b feat(ghost): 插件花名册 system 段注入与渐进式发现链 (#2123)
* feat(ghost): align roster summary limit with manifest

Use the plugin-protocol 300-character summary limit for Desktop validation and cindy-tools roster truncation. Include the author-provided recall hint in live ghost_list results, preferring whenToUse over description.

Signed-off-by: fmfsaisai <fmfsaisai@gmail.com>

* feat(ghost): add precise ghost_info discovery tool (#2031)

Add the fixed read-only ghost_info tool for targeted plugin detail lookup while keeping ghost_list as the live full inventory.

Depends on feat/roster-desc-max-align for the recall field and shared visibleChipGhosts filtering.

Visibility behavior changes:
- missing or uninstalled targets now take precedence over stale workdir-disable preferences and return GHOST_NOT_FOUND
- account-unavailable targets now use the explicit #907 not-signed-in message
- workdir-disabled plus asleep targets consistently return GHOST_DISABLED_IN_WORKDIR in ghost_call and setup waiter revalidation
- initial, setup, grant, pre-dispatch, post-context, and coordinator waiter checks now share one visibility classifier

Signed-off-by: fmfsaisai <fmfsaisai@gmail.com>

* docs(ghost): align handbook wording with manifest constant

Signed-off-by: fmfsaisai <fmfsaisai@gmail.com>

* docs(ghost): define progressive discovery author contract

Document whenToUse as the scenario-only model discovery field and align the author flow with roster to ghost_info to ghost_call.

Require category-scoped RULES in list_tools(category) details and schema-plus-rules recovery for invalid call_tool arguments.

Depends on feat/ghost-info for the precise discovery step.

Signed-off-by: fmfsaisai <fmfsaisai@gmail.com>

* fix(ghost): guide missing ghost_info targets

Signed-off-by: fmfsaisai <fmfsaisai@gmail.com>

* feat(ghost): inject roster into harness system prompts

Signed-off-by: fmfsaisai <fmfsaisai@gmail.com>

* test(ghost): cover roster prompt harness injection

Signed-off-by: fmfsaisai <fmfsaisai@gmail.com>

* fix(ghost): harden roster prompt serialization

Signed-off-by: fmfsaisai <fmfsaisai@gmail.com>

* fix(ghost): wire Pi roster prompt dependency

Declare and forward the existing roster prompt callback so Pi receives the same system-prompt injection as the other harnesses. This closes the pre-existing 73ba2ae03 type/runtime wiring omission.

Signed-off-by: fmfsaisai <fmfsaisai@gmail.com>

* fix(ghost): escape roster block delimiters

Escape angle brackets in serialized roster records so author-controlled values cannot forge the fixed ghost-roster boundaries. JSON semantics remain unchanged after parsing.

Signed-off-by: fmfsaisai <fmfsaisai@gmail.com>

* test(ghost): cover Pi roster prompt assembly

Exercise buildPiAgent's explicit dependency wiring and verify the forwarded roster callback contributes to the composed Pi system prompt.

Signed-off-by: fmfsaisai <fmfsaisai@gmail.com>

* fix(ghost): fail closed remote roster injection

Remote Claude drops the in-process cindy MCP server and remote Codex only receives an HTTP allowlist that excludes the fixed ghost server. Keep both harnesses from injecting a roster when the session workingDir is remote and local workdir visibility preferences cannot be trusted.

Signed-off-by: fmfsaisai <fmfsaisai@gmail.com>

* test(ghost): strengthen roster injection coverage

Lock the sixteen-entry cache budget, pin U+2028/U+2029 folding, and exercise the desktop Pi host through a real PiAgent startSession while mocking only the RPC process and external host dependencies.

Signed-off-by: fmfsaisai <fmfsaisai@gmail.com>

* docs(ghost): document progressive discovery design

Add the authoritative design doc for the ghost progressive discovery chain (roster injection, ghost_info routing, runtime visibility gates) and index it from AGENTS.md.

Signed-off-by: fmfsaisai <fmfsaisai@gmail.com>

* fix(ghost): type ghost_info INTERNAL fallback in wire result

Signed-off-by: fmfsaisai <fmfsaisai@gmail.com>

---------

Signed-off-by: fmfsaisai <fmfsaisai@gmail.com>
2026-08-08 07:25:22 +08:00
JiangJiahao
da18662af0 Merge upstream/main at e8dfe4d7d
Signed-off-by: JiangJiahao <jiangjiahao@xd.com>
2026-08-07 22:14:49 +08:00
Chris Zhang
3c3a78f304 feat(desktop): support gh-cli plugin credentials (#2023)
* feat(desktop): support gh-cli plugin credentials

Signed-off-by: zqchris <chrisz83@gmail.com>

* fix(desktop): address gh auth bridge review security

Signed-off-by: zqchris <chrisz83@gmail.com>

* fix(desktop): cover Windows gh binary name

Signed-off-by: zqchris <chrisz83@gmail.com>

* fix(desktop): validate official gh-cli trust receipt

Signed-off-by: zqchris <chrisz83@gmail.com>

---------

Signed-off-by: zqchris <chrisz83@gmail.com>
2026-08-07 22:01:49 +08:00
JiangJiahao
fce7280cb1 Merge upstream/main into feat/issue-397-ios-simulator-native-framebuffer
Signed-off-by: JiangJiahao <jiangjiahao@xd.com>
2026-08-07 19:02:20 +08:00
JiangJiahao
1b5534f2b5 feat(ios-simulator): add plugin host capability and native recovery
Signed-off-by: JiangJiahao <jiangjiahao@xd.com>
2026-08-07 17:31:04 +08:00
fmfsaisai
dbc7682121 docs(orca): clarify selectable worker permission default
Signed-off-by: fmfsaisai <fmfsaisai@gmail.com>
2026-08-07 10:51:33 +08:00
fmfsaisai
234b87748b feat(orca): default new workers to full access
Signed-off-by: fmfsaisai <fmfsaisai@gmail.com>
2026-08-07 10:41:45 +08:00
fmfsaisai
17f2baa594 feat(orca): 支持记忆 Worker 权限默认值 (#1982)
* feat(orca): 支持记忆 Worker 权限默认值

Signed-off-by: fmfsaisai <fmfsaisai@gmail.com>

* fix(orca): require confirmation for Worker Full access

Signed-off-by: fmfsaisai <fmfsaisai@gmail.com>

---------

Signed-off-by: fmfsaisai <fmfsaisai@gmail.com>
2026-08-07 09:25:21 +08:00
fmfsaisai
17591e3f60 docs: align Codex proxy architecture (#1944)
Signed-off-by: fmfsaisai <fmfsaisai@gmail.com>
2026-08-07 04:00:28 +08:00
Yuewei-LL
bf994ccb83 Merge remote-tracking branch 'origin/main' into redo/plugin-approval-receipt-migration
Signed-off-by: Yuewei-LL <308228674+Yuewei-LL@users.noreply.github.com>
2026-08-07 01:32:22 +08:00
Chris Zhang
6318a44d0b docs(orca): 补充 Pi Lead 与 Worker 能力说明 (#1920)
* docs(orca): clarify Pi lead and worker support

Signed-off-by: Chris <4436110+zqchris@users.noreply.github.com>

* docs(orca): sync Pi capability boundary

Signed-off-by: Chris <4436110+zqchris@users.noreply.github.com>

---------

Signed-off-by: Chris <4436110+zqchris@users.noreply.github.com>
Co-authored-by: Chris <4436110+zqchris@users.noreply.github.com>
2026-08-06 22:02:12 +08:00
Yuewei-LL
0a954b4b87 Merge remote-tracking branch 'origin/main' into redo/plugin-approval-receipt-migration
Signed-off-by: Yuewei-LL <308228674+Yuewei-LL@users.noreply.github.com>

# Conflicts:
#	apps/desktop/src/main/cindy-brain/index.ts
#	apps/desktop/src/main/plugin-market/__tests__/service-custom-sources.test.ts
#	apps/desktop/src/main/plugin-market/__tests__/service.test.ts
#	apps/desktop/src/main/plugin-market/registerIpc.ts
#	apps/desktop/src/main/plugin-market/service.ts
#	apps/desktop/src/renderer/features/plugin/GhostPluginPage.tsx
#	apps/desktop/src/renderer/features/plugin/__tests__/updateAllController.test.ts
#	apps/desktop/src/renderer/features/plugin/lib/updateAllController.ts
#	apps/desktop/src/renderer/features/plugin/lib/updateAllModel.ts
#	apps/desktop/src/shared/__tests__/ghost.test.ts
#	apps/desktop/src/shared/ghost.ts
#	apps/desktop/src/shared/pluginMarket.ts
2026-08-06 21:57:14 +08:00
guyong-zapo
43be5a0b5b feat(desktop): 客户端日志上报(手动上传 + 崩溃自动补传) (#1661)
* feat(desktop): 客户端日志上报(手动 + 崩溃自动)

用户报障时只需点一下并报出上传编号,不再需要自己找日志目录、打包、发文件;
开启授权后崩溃现场能自动送达。上报目标按构建区域在打包期注入,cn 与 global
从 project 一级隔离。

上报内容边界靠四层收窄,客户端这套是唯一防线(日志直送日志服务,中间没有服务端
环节可以再过一遍):

1. 源白名单:只读 main-*.log 与 logs 根的 agent-*.ndjson(仅 proxy 源,崩溃时
   作上下文)。sessions/**(含对话正文)与 *cc-debug.raw.log(含请求响应原文)
   永不构造路径。
2. 记录白名单:deny-by-default。只放行生命周期/崩溃/网络/更新/数据库/鉴权/
   设备互联连接层这些基础设施来源,未知来源一律丢弃。不能用黑名单——调试级别
   的功能日志是用户内容的主要泄漏源,逐个封禁不收敛。
3. 正则红线:JWT、各家 key、Authorization/Cookie 整头、敏感字段值(含被转义的
   JSON 形态)、URL query 值、邮箱、家目录用户名。宁可多抹,不可漏。
4. 字段白名单 + 截断:只有 ts/level/src/scope/msg 五个字段离开本机。

同时闭合「记录边界不可被伪造」这条不变量:main 日志是纯文本按行解析的,上报侧
按行首特征识别记录边界并据此放行来源,因此写侧必须保证除记录首行外没有行以该
特征开头(emit() 走 escapeMainLogContinuationLines)。存量未转义文件由格式哨兵
(#cindy-log-format:2)划界,读侧跳过哨兵之前的内容。写读两侧是同一条不变量的
两半,共用 shared/mainLogRecordFormat.ts。

崩溃三条路径复用 lifecycle 的致命判定(自挂 process 事件会漏渲染进程崩溃、并把
可恢复的悬空 promise 误报成崩溃):

- 崩溃即时:onFatalShutdown 同步写标记后 fire-and-forget。不进 onQuit,因此不占
  disposer 超时预算、不推迟其起点。
- 启动补传(主力):崩溃当时的收尾日志此刻已完整落盘。窗口按最早一次未传崩溃放宽,
  条数裁剪以「离任一崩溃时刻最近」为锚点——取最新 N 条会让崩溃后堆积的新日志把
  崩溃现场整段挤掉。
- 原生崩溃兜底:启动尸检判定上次「异常退出且无任何退出记录」时补标记。

待补传标记带代次令牌 + 原子 rename 认领,只清自己认领的那一代(dev 与正式版共享
userData,并发实例仅靠时间戳会误删对方刚写的新崩溃标记);仅在确实传成功且非空时
才清除;授权被关闭时清空全部(含 claim 文件)。

上报目标走打包期注入(config/log-upload.json 真值不进仓,事实源在
cindy-build-scripts,打包机由 sync 脚本拷回),只烘焙本构建区域那一个目标——cn 包
里物理上不含 global 的 logstore 地址。运行期再与烘焙的区域身份交叉校验。原先由
Record<CindyRegion,…> 提供的 fail-closed 由构建脚本的硬校验替代:除 dev 外每个
区域必填、两区不得共用 project 或 logstore,缺失即打包失败。

隐私边界与可靠性全部有测试锁定(206 个用例),其中「被封禁来源多行内容里伪造的
放行来源记录头」「会话目录诱饵文件从未被打开」「未同意时零请求」是行为锁,
不允许为让改动通过而放宽。

Signed-off-by: guyong <guyong@xd.com>

* fix(desktop): 按 review 收紧日志上报的两处隐私边界与一处标记丢失风险

P1 哨兵子串匹配导致的隐私逃逸(mainLogReader):sentinelOffset 原先拿哨兵串去 indexOf
搜任意位置,于是升级前未转义的正文里只要出现过 `[logger] #cindy-log-format:2` 这段
文字(用户对话内容完全可以包含它),那一行就被认成哨兵、置位 sentinelAlreadySeen,
它后面被封禁来源里伪造的放行记录头全部绕过「哨兵之前一律丢弃」这道闸。改为按完整
记录头 + scope 为 logger + 正文恰好等于哨兵串校验整行。

同一处顺带修掉一个自带的 bug:偏移用的是 text.indexOf 的**字符**下标,而调用方拿它跟
字节偏移比较。日志正文里大量中文,字符下标会明显偏小,让「哨兵在窗口起点之前」的判断
偏向误判为真。改为按 Buffer.byteLength 累加;并且只认后面有换行符落在缓冲区内的
**完整**哨兵行(headBytes 边界可能把行截断,半行不该算)。

P1 device-link 根放行漏掉 device-link:ipc(sourceAllowlist):它在镜像缓存清理失败时把
MirrorCachePurgeError 整个写进日志,其中 root / remaining 是本地缓存文件路径。真正的
问题不是漏了这一个,而是「根放行 + 逐条排除」让**新增的子 scope 默认放行**,方向与
deny-by-default 相反。改为 ALLOWED_EXACT_SCOPES 精确匹配:只放行 device-link 本身与
device-link:cross-process-lock,其余(含将来新增的)默认不上报。DENIED_SUB_SCOPES 保留
作纵深防御。

P2 授权读取故障会永久丢掉崩溃现场(consentGate 接线):两个 store 都基于
createOverrideSettingsFile,它读到坏 JSON 会吞掉异常返回默认值,于是「文件损坏」与
「用户明确没同意 / 明确关掉开关」在返回值上一模一样。启动补传已经先 claim 了 marker,
闸把前者判成 denied 后 runUpload 会清空标记——一次设置文件读取故障就永久丢掉一个崩溃
现场,而闸里的 unknown 分支实际不可达。新增 isAnalyticsConsentRecordReadable() 与
isLogUploadSettingsReadable() 两个探针(取「现读盘」与「启动期 probe 结论」的交集——
store 读到坏文件会把它删掉,只现读就看不到了),接线层探到不可读时抛异常,让闸判
unknown:不传、也不清、留给下次启动。

安全门要求的测试样本形态:PEM 用例改成 BEGIN FAKE PRIVATE KEY + 一眼假的正文,
多秘密用例改用已有的运行时拼接常量,源码里不再出现 sk- 形态的完整字面量。

三处注释与文案纠正:auth-header 正则确实取到行尾(说明改为写明这是有意的 over-redact,
不是在分隔符处分段);上传编号的丢弃率是 6.25% 不是 <3%;构建期校验的报错文案原先
暗示「写 null 可以关掉某区域」,实际缺 key 与写 null 都会硬失败。

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: guyong <guyong@xd.com>

* fix(desktop): 日志上报的格式信任判据改为「文件第 0 字节是哨兵」

review 第二轮仍能伪造哨兵。上一轮把 `indexOf` 子串匹配改成整行精确校验,只是让伪造
变麻烦:哨兵行的形状(记录头 + `[logger]` + 固定串)完全由日志正文可以逐字构造,只要
判据是「文件里出现过哨兵」,未转义的存量文件里就能嵌一行伪造哨兵、后面跟若干伪造的
放行 scope 记录头,把对话正文当基础设施日志送出去。

判据换成**第 0 字节**:满足则整份文件可信,不满足整份不采。第 0 字节不可能是正文——
新版本新建当天文件后的第一次写入就是哨兵,旧版本的第 0 字节永远是它自己那条真实记录。
`parseMainLogText` 里那条「见到哨兵就置位 sawSentinel」也一并去掉,否则同一个伪造口
在解析路径上照旧成立。

代价是跨越升级那一刻的当天文件整份不可上报(前半段旧版本写的、后半段追加在哨兵之后),
只影响每台机器升级当天的那一个文件:更早的纯存量文件本来就一条都不放行,之后的文件哨兵
都在第 0 字节。跳过时计入 stats.filesSkippedLegacyFormat,让「升级当天采到 0 条」能一眼
归因。

顺带闭合 copilot 指出的读窗口问题:旧实现只扫开头 64KB 找哨兵,哨兵落在中段时定位读取
会把整段窗口丢掉。新判据与文件大小、窗口位置都无关。

其余三处:

- 脱敏漏抹「字段名 + 鉴权 scheme」(P1)。`token=Bearer <凭证>` 这类形态下
  sensitive-field-kv 的值取到空白为止,只抹掉 `Bearer` 这个词;而独立的 bearer 规则排在
  它之后,等它跑到时前缀已被替换、正则再也匹配不上,凭证本体全程无人处理。新增
  sensitive-field-auth-scheme 排在 kv 规则之前,一路抹到行尾(AWS4-HMAC-SHA256 这类凭证
  本身带逗号空格,在任何分隔符处收手都会漏)。规则顺序由用例钉住。
- 手动上传被崩溃开关的读取故障牵连(P2)。上一轮把「读不出来 ⇒ unknown」做进闸之后,
  一份损坏的 log-upload-settings.json 会让用户主动点的上传也拿到
  PRIVACY_CONSENT_REQUIRED —— 恰好是最需要交日志的时候。手动路径的放行条件里本来就没有
  这个开关,改成 reason === 'manual' 时连读都不读。
- log-upload 设置 store 缺启动期探针(P2)。createOverrideSettingsFile 读到坏 JSON 会把
  文件删掉,设置页挂载即读一次的 logUploadSettingsPayload() 远早于延迟执行的启动补传,
  于是「现读」再也看不到损坏、闸判成 crash-auto-off 并清空已认领的标记。补上与 analytics
  同款的 probeRecordOnce(),可读性判据取「现读」与「启动期结论」的交集。

构建期注入的用例改用 afterEach 统一回收临时目录,不再在测试执行期调 test.after() 注册
根级钩子(与 client-endpoint-build-env.test.mjs 一致)。

验证:desktop typecheck 通过;本功能定向测试 246 用例全绿(较上轮 +21,均为本轮回归锁,
含「完整合法哨兵出现在中段 ⇒ 不认」「>64KB 且窗口中段切入仍采到崩溃现场」「手动路径不
调用崩溃开关读取」「auth scheme 七种形态」);desktop 完整 unit tier 1723 文件 /
21290 用例全绿(--pool=forks);test:runner 361 / 0 fail;check:i18n / i18n-glossary / dco
通过。脱敏那条回归锁已确认在修复前的代码上会红。

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: guyong <guyong@xd.com>

* fix(desktop): proxy 崩溃上下文逐字段重建,不再搬整条正文

review 指出 agent 流会带走 prompt 原文,核实成立。proxy 自己就把请求体与上游错误体写进
日志上下文,而 logger.emit() 是 util.format(...args) —— 上下文对象被渲染进 msg,读侧原样搬
msg 等于把 dump 一起上报:

- logger.debug('▶ inbound request from client', { …, body: dumpBody(rawBody) })
  XDT_PROXY_DUMP_REQUEST_BODY=1 时带完整请求体,对 anthropic-compat proxy 就是整个 prompt;
- logger.warn('◀ upstream response (non-2xx)', { …, body: dumpBody(errBody) })
  只要 debug 等级开着就带上游错误体,而它发在 warn 级,光按等级过滤挡不住。

改成三道一起上:等级闸(只放行 info 及以上,等级缺失/不认识按 debug 处理)、标记截断(只取
渲染对象之前那截字面量,对象里的值因此不可能进标记)、标量字段白名单(PROXY_FIELDS 逐键配
窄正则,body 这类名单外的键没有出口,与等级无关)。带出的仍是状态码/字节数/耗时/错误类型
这些真正有排障价值的标量。形状写窄是要点 —— 用 .* 取值等于把「这个值安全」的判断让给写
日志的人。

另两处:

- 分批预算改按 UTF-8 字节算(Buffer.byteLength)。原先用 JSON.stringify(log).length 即
  UTF-16 码元数,中文 1 码元 / 3 字节、emoji 2 / 4,是低估而不是原注释写的「保守高估」,
  会让批在编码后超过服务端上限被整批拒收,崩溃标记于是留着反复重试。同时给 envelope
  留 4KB 余量、每条计 1 字节分隔符。
- findOffsetAtOrBefore 的注释与实现对齐:它返回的是「不晚于 targetMs 的读取起点」,
  精度到 probeBytes,不是「第一条 ≥ targetMs 的记录行首」。删掉 agentLogReader 里未使用的
  isAllowedScope import。

安全内容门第三次命中 redact.test.ts 的 PEM 样本。门只按 PRIVATE KEY 形状硬命中、不看
FAKE 标记,所以上一轮改成 BEGIN FAKE PRIVATE KEY 仍被拦。改成与文件里其它厂商样本同款的
运行期拼接,源码中不再出现连续字面量;redact() 拿到的输入逐字节不变。

验证:desktop typecheck 通过;本功能定向测试 259 用例全绿(+13,含新增
agentLogReader.test.ts 19 条);desktop 完整 unit tier 1724 文件 / 21311 用例全绿
(--pool=forks);test:runner 361 / 0 fail;check:i18n / i18n-glossary / dco 通过。
新增的 11 条隐私锁已确认在修复前的代码上会红(prompt 原文确实会进上报集合)。

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: guyong <guyong@xd.com>

* fix(desktop): 补齐上报必选头、按流格式定位 agent 日志、收紧开关文件可读判据

三条新 review 意见,均核实成立:

1. (P1) PutWebtracking 缺必选头 x-log-bodyrawsize。阿里云 SLS 文档明确该接口两个必选头
   是 x-log-apiversion 与 x-log-bodyrawsize(未压缩正文的字节数),缺任一部分区域直接 400 ——
   对一个「点一下上传日志」的功能就是线上不可用。补上,值取 Buffer.byteLength(body,'utf8')
   (不压缩,不发 x-log-compresstype;必须按 UTF-8 字节而非 body.length 的 UTF-16 码元)。

2. (P2) 超大 agent-*.ndjson 的定位读取用错解析器。findOffsetAtOrBefore 原先写死用 main
   记录头正则解时间戳,喂 NDJSON 时一条都解不出,二分恒收敛到 0,读窗口错定在最旧记录、
   彻底错过崩溃现场。把它参数化成接受 LineTimestampParser:main 传 parseMainHeadTimestamp,
   agent 传新增的 parseNdjsonTimestamp(只取 ts),collect 按 plan.kind 选。

3. (copilot) 开关文件可读判据太松。probeSettingsFile 原先「能解析成 object」就判 valid,
   会把 {} 也当可读。但本 store 的 writer 在 override 清空时删文件、从不落 {},写入时
   normalize 保证 crashAutoUploadEnabled 一定是 boolean —— 盘上出现空对象或非 boolean 值
   都不可能来自本 writer,是外部手改或半截写入。当成 valid 会让闸判 crash-auto-off 并清空
   待补传标记。收紧:空对象、或该键存在却非 boolean,一律判 invalid 走 unknown(不传也不清),
   与坏 JSON 同款保守处理。分类逻辑抽成纯函数 classifyProbe 便于单测。

验证:desktop typecheck 通过;本功能定向测试 270 用例全绿(+11:x-log-bodyrawsize 按字节、
NDJSON 定位对照 main 解析器恒收敛到 0、classifyProbe 六类形状、parseNdjsonTimestamp);
desktop 完整 unit tier 21521 passed(唯一 1 失败是 makerSendToSessionOrdering.test.ts,
经 stash 本轮改动复跑确认为主干合入带来的既有失败,不在本 PR diff 内、与 log-upload 无关);
test:runner 361/0;i18n-glossary / dco 通过。x-log-bodyrawsize 与 classifyProbe 两条回归锁
已确认在修复前的代码上会红。

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: guyong <guyong@xd.com>

* fix(desktop): 堵住带引号敏感值、收窄 localDb 放行、收紧 analytics 可读判据

三条新 review 意见,均核实成立:

1. (P1) util.format 渲染的带引号敏感值漏抹。main logger 用 util.format 渲染对象参数,
   { token: 'x' } 落进日志就是 token: 'x'(键无引号、值单引号)。sensitive-field-json 要求
   键带双引号不命中,sensitive-field-kv 的值类 [^\s&;,"'] 把引号排除在外、遇引号开头一个
   字符都匹配不到 —— 这个最常见的对象渲染形态两头漏网。新增 sensitive-field-quoted 规则,
   排在 kv 之前、auth-scheme 之后,连引号带内容整段抹掉(匹配成对闭合引号,\. 吃转义)。

2. (P1) localDb 根放行太宽。它的子 scope localDb/messages 打消息导入与媒体附件路径。改成
   精确放行(移到 ALLOWED_EXACT_SCOPES),bare localDb 只放行库打开/migration/完整性/fatal
   这些基础设施事件(dbPath 经家目录脱敏、userId 本就是上报身份),localDb/* 一律不跟着放行;
   localDb/messages 另加进 DENIED_SUB_SCOPES 作纵深防御。与 device-link 同款处理——根放行 +
   逐条排除会让新增子 scope 默认放行,方向与 deny-by-default 相反。
   (注:codex 举的 recentWorkdirs/sessions 两处 scope 本就不在名单、已被拒;真正的结构性
   风险是 localDb/messages 与将来的 localDb/*,按此修。)

3. (copilot) analytics 可读判据同 logUpload 上一轮的两个问题:isAnalyticsConsentRecordReadable
   没先跑 probeRecordOnce(仅靠 recordProbe 现值,启动快照可能没抓到就被 store 删了坏文件),
   且把 {} 当可读。抽出纯函数 classifyAnalyticsContent(空对象、已知 boolean 字段非 boolean
   一律 invalid),readable 判据开头先 probeRecordOnce()。迁移不受影响:migrate 只在 ==='none'
   时触发,{} 无论算 valid 还是 invalid 都 !=='none',结论一致。

验证:desktop typecheck 通过;本功能 + analytics 定向测试 312 全绿(+18:带引号 6 形态 +
转义引号 + 规则顺序 + 不误伤、localDb 精确匹配、classifyAnalyticsContent 六类);desktop
完整 unit tier 21540 passed(唯一 1 失败 makerSendToSessionOrdering.test.ts 经确认为主干合入
带来的既有失败,不在本 PR diff、与 log-upload 无关);test:runner 361/0;i18n-glossary / dco
通过。带引号 redact 与 localDb 两条回归锁已确认在修复前会红。

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: guyong <guyong@xd.com>

* fix(desktop): 崩溃日志按天定位、开源打包容忍缺配置、analytics 探针写后刷新

三条新 review 意见,均核实成立:

1. (P1) 跨天多崩溃时超大日志用错锚点。collect 对每个超预算文件都用全局 min(anchors) 定位;
   对晚一天的文件,该目标落在文件开头之前 → 二分收敛到 0 → 读到那天最旧的 8MB、错过当天靠后
   的崩溃,而上报里仍有更早那天的记录,runUpload 会把所有认领标记一起清掉 → 漏掉的崩溃现场
   永久丢失。新增 earliestAnchorOnDay(dateKey, anchors):只取落在本文件这一天内的最早锚点,
   这天没崩溃则读尾部。定位到当天崩溃后,清标记才安全。

2. (P1) 版本无关/开源打包缺 config/log-upload.json 时打包直接崩。该文件 gitignore、默认
   checkout 里不存在,而 package-desktop 无条件调 desktopLogUploadBuildEnv → loadLogUploadTargets
   在 Forge 跑起来前就抛,破坏了文档承诺的「拉仓即可打无版本包」。给 loadLogUploadTargets /
   desktopLogUploadBuildEnv 加 allowMissing:版本无关打包(versionless)传 true,文件缺失 ⇒ 注入
   空目标、功能整体关闭;发行(有版本)打包仍默认 false、缺失即硬失败。只放宽「缺失」——文件在
   但内容损坏两种模式都仍然抛(半截配置比没有更危险)。

3. (P2) analytics 探针成功写入后不刷新。首次分类为 invalid 后 probeRecordOnce 永远返回 invalid,
   本会话里 isAnalyticsConsentRecordReadable 一直判不可读 —— 用户即便重新同意,日志上报授权闸
   仍把同意当读取故障,手动上报卡 consent-required、崩溃补传卡到重启。加 refreshProbeAfterWrite
   (按写后 isCustomized 定 valid / none,能正确处理 clearOverride 删文件的情况),在 5 个写入
   路径成功后调用。与 logUploadSettingsStore 上一轮的处理对齐。

验证:desktop typecheck 通过;本功能 + analytics 定向测试 320 全绿,build-env node:test 23 全绿
(+16:earliestAnchorOnDay 六类、allowMissing 四类、探针写后刷新两类等);desktop 完整 unit tier
21548 passed(唯一 1 失败 makerSendToSessionOrdering.test.ts 经确认为主干合入带来的既有失败,
不在本 PR diff、与 log-upload 无关);test:runner 365/1(同一既有失败)... 实为 364 pass /
0 fail(runner 不含该 vitest 文件);i18n-glossary / dco 通过。三条回归锁均确认修复前会红。

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: guyong <guyong@xd.com>

* fix(desktop): 日志来源排除表匹配分隔符无关(纵深防御)

copilot 在上一轮 review 里(suppressed 建议)指出:DENIED_SUB_SCOPES 用 `/` 存了
`localDb/messages`,但仓库里子 scope 的 `/` 与 `:` 两种分隔符都在用,而排除匹配
(isUnderRoot)只按存进去的那种形式比 —— `localDb:messages`(冒号形式)不会被
`localDb/messages` 这条命中。当前靠 localDb 精确放行挡着不成问题,但这张表本是「万一有人
把某个根重新加回根放行」时的纵深防御,一旦那样,另一种分隔符就绕过去了。

新增 matchesDeniedSubScope:把两侧的 `:` 归一成 `/` 再比,`localDb:messages` 与
`localDb/messages` 视为同一个东西。对 device-link 那批冒号项同理生效(其 `/` 形式现在也挡)。

验证:desktop typecheck 通过;sourceAllowlist 定向测试 60 全绿(+2:每个排除项 / 与 : 两种
形式及更深层都命中、localDb 冒号形式的纵深防御);desktop 完整 unit tier 21550 passed(唯一 1
失败 makerSendToSessionOrdering.test.ts 为主干合入带来的既有失败,不在本 PR diff、与
log-upload 无关);test:runner 364/0;i18n-glossary / dco 通过。回归锁确认修复前会红。

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: guyong <guyong@xd.com>

* fix(desktop): 读侧堵回滚追加的未转义内容;崩溃标记按覆盖清除

两条 review P1:

1. (greptile, security) 「第 0 字节是哨兵 ⇒ 整份文件可信」有回滚漏洞:新版本当天建文件写下
   哨兵,用户同一天回滚到旧版本,旧 writer 往同一 main-<date>.log 追加**未转义**内容;仅凭首行
   哨兵会误信整份文件,旧多行正文里像放行记录头的行被当独立基础设施记录送走 = 用户内容离开
   设备。读侧补上记录边界不变量校验:转义格式下续行必以空格开头,出现「既非 head 又不以空格
   开头」的行即未转义污染,就地停止 —— 之前的真·转义记录保留,之后一律不信(fail closed)。
   残余的「全是伪造 head 行」形态退化为单行记录,仍走来源白名单 + 脱敏,与普通记录同风险。
   计入 stats.mainFilesStoppedAtViolation。

2. (codex) 同一天两次崩溃、当天日志超大时,单个 earliestAnchorOnDay 窗口只覆盖靠前那次,
   上报非空但没含靠后那次,runUpload 却清掉**所有**认领标记 → 靠后的崩溃现场永久丢失
   (跨天已在上一轮修 seek,这是同日残余)。collect 现返回 coveredAnchors:锚点那天没有文件
   (没东西可补)、整份读过、或落在已解析记录时间跨度内 = 覆盖;只有「文件在、超大、窗口没够到」
   才算未覆盖。runUpload 只清覆盖到的标记,未覆盖的还原(保留待补传),不再一次成功上报清掉
   没采到的崩溃。

验证:desktop typecheck 通过;本功能定向测试 297 全绿(+新增回滚停止、纯转义不误报、
coveredAnchors 三类、只清覆盖标记等);两条 P1 回归锁确认修复前会红。

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: guyong <guyong@xd.com>

* fix(desktop): 崩溃锚点覆盖判定按文件算,agent 不得替 main 背书

上一轮的 coveredAnchors 按**天**合并覆盖(whole = whole || wholeRead),于是同一天里一个整份
读到的小 agent-*.ndjson 会把 whole 置真,冒充覆盖了同一天那个「只读了靠前窗口的超大
main-*.log」—— 靠后那次崩溃的标记因此被误清(codex review P1)。

崩溃现场的主体在 main 流(FATAL/process、收尾序列),agent 只是补充上下文,不能替 main 背书。
改成**按文件**(天+流类型)记覆盖,key = `${dateKey}|${kind}`;覆盖判定以 main 为准:那天
有 main 就只看 main 的覆盖,只有压根没有 main(罕见 agent-only)才退回看 agent。判定逻辑抽成
纯函数 computeCoveredAnchors 便于单测。

验证:desktop typecheck 通过;本功能定向测试 302 全绿(+computeCoveredAnchors 五类:agent
不得冒充、main 整份覆盖、main 未读到、无文件、agent-only 兜底);desktop 完整 unit tier
22355 passed(7 失败全在 makerSendToSessionOrdering.test.ts,主干合入带来的既有失败,不在
本 PR diff、与 log-upload 无关,CI 对最新 main 合并结果已绿);test:runner 365/0;dco 通过。
masking 回归锁确认修复前会红。

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: guyong <guyong@xd.com>

* fix(desktop): 修窗口半行误判违规;再挡两个会打路径的日志来源

三条 review P1:

1. (greptile) 我上一版的记录边界读侧校验有回归:超预算窗口没读到 EOF 时,末行可能是被字节
   预算从记录头中间截断的半行(既不命中 head、又不以空格开头),会被误判成未转义污染而停止,
   于是合法的超大崩溃日志覆盖不到锚点、标记清不掉、下次重复上传。给 parseMainLogText 加
   windowEndsAtEof(collect 按 startOffset+buf.length>=size 传入):窗口未达 EOF 时末行按半行
   丢弃、不计违规。顺带修正违规处置——之前 pending=null 会连带丢掉「违规行之前那条完整记录」,
   改成先 flush 再停止(违规行是另起的一行、不属于 pending)。

2. (codex) auth-boundary 根放行里,登出/账号切换拆卸时的镜像缓存清理失败会把
   MirrorCachePurgeError 的 root/remaining 本地缓存路径写进日志。auth-boundary 根本身有价值
   (服务拆卸序列,shutdown 排查必需),所以把那三条 purge 日志(drain/clear/enqueue-retry)拆到
   独立子 scope auth-boundary:mirror-cache-purge(bootstrap-electron),再从来源白名单里排除;
   根上只剩不带路径的服务停止诊断。

3. (codex) legacy-xdmaker-migration 每条记录都带 rootDir(解析后的项目工作目录),脱敏只抹
   家目录段、项目目录名仍外泄。整个 scope 从放行名单移除,列入 NOTABLE_DENIED_ROOTS。
   (未被点名的 legacyUserDataMigration / ownerNamespaceMigration 保持放行,不做无据的连带移除。)

验证:desktop typecheck 通过;本功能定向测试 309 全绿(+半行不误判/EOF 处真违规/auth-boundary
purge 子 scope 排除/legacy-xdmaker 拒 等);desktop 完整 unit tier 22362 passed(7 失败全在
makerSendToSessionOrdering.test.ts,主干合入带来的既有失败,不在本 PR diff、CI 对最新 main 已绿);
test:runner 365/0;i18n-glossary / dco 通过。三条回归锁均确认修复前会红。

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: guyong <guyong@xd.com>

* fix(desktop): 未配置不清崩溃标记;manifestIO 实为 SkillHub、移出放行名单

两条 review P1:

1. (codex) runUpload 在 `not-configured` 也走了「清空所有待补传标记」这条(和用户撤回授权同处理)。
   但 not-configured 不是用户 opt-out,而是**这个构建传不了**(无版本/dev 包没有 config,或注入
   短暂异常)。dev 与正式版共享同一份 userData —— 用户「先用没配上报的构建打开」就会在正式版
   补传之前把崩溃标记永久清掉。改成:not-configured 只 release(保留标记)、绝不 clearAll;只有
   明确的用户 opt-out(no-consent / crash-auto-off)才清。

2. (codex) 放行名单里的 `manifestIO` 名字像端点清单落盘,实际仓库里唯一的
   createLogger('manifestIO') 是 SkillHub 注册表存储(skillhub/registry/manifestIO.ts),清单
   损坏 / 非法文件名时会打 `skillhub/manifests/<skill>.json` 路径与文件名 = 用户装的插件身份,
   与 skillhub 同属用户/第三方内容。移出 ALLOWED_ROOT_SCOPES、列入 NOTABLE_DENIED_ROOTS。
   端点清单拉取是另一个 scope(manifestService),仍放行。

验证:desktop typecheck 通过;本功能定向测试 311 全绿(+未配置保留标记、manifestIO 拒);
desktop 完整 unit tier 22364 passed(7 失败全在 makerSendToSessionOrdering.test.ts,主干合入
带来的既有失败,不在本 PR diff、CI 对最新 main 已绿);test:runner 365/0;dco 通过。
两条回归锁确认修复前会红。

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: guyong <guyong@xd.com>

* fix(desktop): 运行期校验上报接入域名形状,非 SLS 域一律 fail closed

review P1(codex):parseInjectedTarget 只校验 endpointHost 是纯主机名(不带协议/路径/project
前缀),没校验它是不是 SLS 接入域名。若有 dev .env 或异常打包链路绕过 loadLogUploadTargets 塞进
任意域名(如 evil.com),buildTrackUrl 会把用户日志免签 POST 到 https://<project>.evil.com/ ——
直接改投他人域,而不是 fail closed。

加运行期形状校验 SLS_ENDPOINT_HOST_RE = /^[a-z0-9][a-z0-9-]*\.log\.aliyuncs\.com$/,与构建脚本
slsEndpointHost() 的产物(区域代号同 SLS_REGION_RE)逐字对应。不匹配一律判「未配置」返回 null。
这个形状也顺带覆盖了原先手写的带协议/带路径/带 project 前缀三道检查(都不匹配)。

验证:desktop typecheck 通过;gateAndTarget 定向测试 42 全绿(+evil.com/后缀攻击/近似域名/
多一级子域伪装 判 null,合法 <region>.log.aliyuncs.com 放行);回归锁确认修复前会红。

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: guyong <guyong@xd.com>

* fix(desktop): 崩溃锚点覆盖判定改按裁剪后上报的记录

多次崩溃同批补传时,某次崩溃附近的日志风暴可能占满 MAX_RECORDS,把另一次崩溃附近
的记录整段挤掉;上报仍非空、仍成功,但那次崩溃的现场其实没进上报。原 coveredAnchors
按**读到的全部**(裁剪前)判覆盖,于是那次崩溃的标记被误清、现场永久丢失——正是需求
§11 想避免的既有教训。

改为在锚点裁剪后按**真正留下的记录**重建 fileCoverage(buildFileCoverage):whole
只在「整份读到且这份文件一条都没被 cap 裁掉」时才置位,否则退回按留下记录的时间跨度
判定。被挤掉那次崩溃附近若已无记录留下,其锚点落在跨度外、标记得以保留待下次以更聚焦
的锚点集重试,最终要么补上、要么随日志过保留期而自然清除,不会无限重传。

回归锁:同日两次崩溃、A1 风暴占满上限挤掉 A2 的记录 ⇒ A2 不算覆盖(修复前会因整份
读到冒充成已覆盖)。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: guyong <guyong@xd.com>

* fix(desktop): 资产准备告警拆出上报 + 补传归组令牌取最早标记

两处按 review 收紧崩溃补传:

P1(sourceAllowlist / auth-adapters):全局 skill/plugin/marketplace 资产准备的告警
(prepareSharedGlobalSkillLinks / Codex 全局桥接的 warnings)会带**用户自选的
skill·marketplace 名**与**绝对路径**(cannot link skill X from <path> to <path>),原先
整个走根放行的 `auth-adapters` scope,可随手动/崩溃上报出网。把这几条(shared/codex 资产
准备的 warn/error)改走独立的 `auth-adapters:asset-prep` 子 scope 并入 DENIED_SUB_SCOPES;
根 `auth-adapters` 只剩不带用户身份/路径的凭证生命周期诊断。本机日志照常写全,只是不上报。

P2(index / crashTriggers):多个待补传标记合并成一次上报时,归组 crashToken 原取
`claimed[0]`(claimAll 按 readdir 顺序返回,不保证最早),而 crashAtMs 取 `min(anchors)`,
两者可能来自不同崩溃 —— 补传带着「最早崩溃的时刻 + 另一次崩溃的令牌」,既归不进最早那次的
即时上报,又占用另一次的令牌。抽出 selectBackfillGrouping:token 与 crashAtMs 都从拥有最早
crashAtMs 的同一个标记取。

回归锁:auth-adapters:asset-prep 两种分隔符都不放行、根 auth-adapters 仍放行(修复前 asset-prep
被冒充放行);selectBackfillGrouping 不受 readdir 顺序影响、token/crashAtMs 同源。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: guyong <guyong@xd.com>

* fix(desktop): 运行期校验 project/logstore + 凭证文件路径拆出上报

两处按 review 继续收紧,均为「防绕过注入/deny-by-default」的一致性补强:

P1(logUploadTarget):上轮给 endpointHost 加了 SLS 域名形状校验,但 project/logstore 仍
只过 isNonEmptyString。buildTrackUrl 把 project 拼在**子域**位置
(https://<project>.<endpointHost>/logstores/<logstore>/track),project 含 `.`/`/`
(如 evil.com/p)就能把 host 顶成任意域,endpointHost 校验通过也照样把日志改投他人域;
logstore 含 `/` 能改写请求路径。运行期逐字镜像构建脚本的 SLS_NAME_RE(^[a-z0-9][a-z0-9-]*$)
校验 project/logstore,任一非 SLS 名一律 fail closed。

P1(auth-adapters / sourceAllowlist):拆出 asset-prep 后,根放行的 auth-adapters 仍有凭证
文件路径外泄——icacls/chmod 的 { file }、fsp.rm 与 relinkSharedCodexAuth 的 error.message
会带 auth.json / models_cache.json 等绝对路径,而脱敏只抹用户名段、路径其余部分仍在。把这几条
(共 8 处)改走独立的 auth-adapters:cred-path 子 scope 并入 DENIED_SUB_SCOPES;根只剩不带
路径的凭证生命周期诊断。本机日志照常写全,只是不上报。

回归锁:project/logstore 各种畸形(改投域名/含点/含斜杠/大写/路径细工)一律 null;
auth-adapters:cred-path 两种分隔符都不放行、根 auth-adapters 仍放行。均验证修复前红。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: guyong <guyong@xd.com>

* fix(desktop): 锚点覆盖去掉架桥误判 + owner 迁移插件身份拒上报

两处按 review 继续收紧崩溃补传:

P1(collect):上轮把覆盖判定从"读到的全部"改成"裁剪后留下的记录",但仍压成单一 [min,max]
跨度。同日多次崩溃时,cap 若只留住最早与最晚崩溃附近的记录、把**中间**那次的记录全裁掉,
中间锚点仍落在 min~max 之间(被两端架桥),却没有自己的现场进上报 → 标记被误清、现场丢失。
改 fileCovers 为**同时**要求「A 落在留下记录跨度内」(读取推进到 A 两侧;污染提前停止时 A 在
max 之后 → 判未覆盖)与「A 的崩溃邻域 ±ANCHOR_PRE_ROLL_MS 内有记录留下」(自己的现场没被裁
光)。前者挡住"读到一半停下",后者挡住架桥。FileCoverage 由 {minTs,maxTs} 改存 survivorTs。

P1(sourceAllowlist):ownerNamespaceMigration 做了根放行,但其遗留 ghost 恢复诊断打
`id: legacy.id`(= 用户已装的第三方插件目录名/身份)与 fs 移动失败的绝对路径,混着 path-free
的迁移状态。整体从 ALLOWED_ROOT_SCOPES 移除、并入 NOTABLE_DENIED_ROOTS(同 legacy-xdmaker /
manifestIO 的处置)。需要时再另拆一个不带 id/路径的子 scope。

回归锁:同日早/晚崩溃留下记录、中间那次被裁光 ⇒ 中间锚点不算覆盖(修复前被架桥冒充);
ownerNamespaceMigration 两种分隔符都不放行。均验证修复前红。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: guyong <guyong@xd.com>

* fix(desktop): 上报日志堵两处身份/密钥泄漏(插件路径 + 带引号头字段)

两处按 review 收紧:

P1(serverApiClient / plugin-market):serverApiClient 根放行,其 4xx/5xx 日志打 path=。
plugin-market 的 detail/download 未设 redactErrorDetails,not_ok 分支打**生 apiPath**
(`/api/plugins/<pluginId>[/releases/<id>/download]`);且 redactedLogPath 保留前 3 段,对
`/api/plugins/<id>` 这类"ID 在浅层"的路径仍会外泄用户装的第三方插件身份。给 ApiFetchOptions
加 logLabel 路由模板:带 ID 的调用方传一个不含身份/入参的模板,日志一律用它(两种分支都改
用 logLabel ?? path)。plugin-market 默认 fetcher 设 redactErrorDetails: true + logLabel:
'/api/plugins'。redactedLogPath 不动(billing 的 4 段路径行为不变)。

P1(redact):字段名被整体引起来时闭合引号夹在名与分隔符之间(`{ 'x-api-key': 'opaque' }`、
JSON `"x-api-key":"..."`、转义 JSON),auth-header/json/quoted/kv 四条全失配 —— 带连字符/前缀
的头(x-api-key 等)的值原样外泄,除非撞上某个厂商形态。新增 sensitive-field-quoted-key 规则,
在其它字段规则之前吃掉"引号包起来的键"(允许 x-/厂商前缀、单/双/反引号、转义引号),连值带引号
整段抹掉。

回归锁:引号包 x-api-key/authorization/x-goog-api-key/refresh-token 各形态值必被抹、非敏感键
(x-request-id/content-type)不误伤;serverApiFetch logLabel 在 redact 与非 redact 分支都代替真实
path、插件 ID 不进日志;plugin-market 默认 fetcher 带 redactErrorDetails + logLabel。均验证修复前红。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: guyong <guyong@xd.com>

* fix(desktop): 锚点覆盖改用最近锚点归属 + SkillHub 路径/消息不进上报

P1(collect,greptile):上轮的覆盖判定加了 `a ≤ max` 端点判定,但崩溃锚点由 beginShutdown
写日志**之后**才 Date.now() 生成,锚点必然略晚于最后一条日志;部分读取的超大 main 里
「最后一条 surviving record < 锚点」是常态 → 对真崩溃误判未覆盖、标记清不掉、每次启动重复上传。
改用**最近锚点归属**:锚点 A 覆盖 ⟺ 留下的记录里有一条离 A 比离任何其它锚点都近(trim 分配
记录的同一把尺子)。这对三种坑都对——架桥(中间崩溃被裁光)、锚点晚于末条日志(greptile)、
两次崩溃相隔 90s 时 A 的风暴挤掉 B。去掉了固定跨度/邻域窗。命中污染停止不再额外判未覆盖
(污染段永不解析、重试无益,有归属记录即清,避免无限重传)。

P1(serverApiClient/skillhub):plugin-market 修好后,SkillHub 仍未收敛。skillhubApiFetch 未设
logLabel,`/api/skills-hub/skills/<name>[/download]` 的 4xx/5xx 会把 skill 身份打进 not_ok
日志。给 skillhubApiFetch 传 logLabel: '/api/skills-hub';并让 serverApiClient 在设了 logLabel 时
连 `msg=`(上游消息可能回显 skill 名)一起省掉。**不**设 redactErrorDetails:SkillHub 依赖
ServerApiError.code(VERSION_RACE 等)做业务分支,logLabel 只改日志、不动抛出的错误。

回归锁:greptile(记录都早于锚点仍覆盖)、架桥、90s 双崩溃、污染停止转为覆盖;serverApiFetch
设 logLabel 时省 msg 且抛出 code 不变;skillhubApiFetch 传 logLabel。均验证修复前红。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: guyong <guyong@xd.com>

---------

Signed-off-by: guyong <guyong@xd.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-06 17:04:28 +08:00
Yuewei-LL
e590d7cd53 merge: integrate latest main plugin changes
Signed-off-by: Yuewei-LL <308228674+Yuewei-LL@users.noreply.github.com>
2026-08-06 13:02:13 +08:00
Yuewei-LL
7449ca8c80 merge: integrate main through 4fcd7fcd
Signed-off-by: Yuewei-LL <308228674+Yuewei-LL@users.noreply.github.com>
2026-08-06 11:22:03 +08:00
jiajiayao
e111acc875 fix(orca): default new workers to Auto-review (#1730)
* fix(orca): default new workers to auto approval

Signed-off-by: jiajiayao <48589551+jiajiayao@users.noreply.github.com>

* fix(orca): preserve worker permissions on resume

Signed-off-by: jiajiayao <48589551+jiajiayao@users.noreply.github.com>

* fix(orca): gate remote worker permission copy

Signed-off-by: jiajiayao <48589551+jiajiayao@users.noreply.github.com>

---------

Signed-off-by: jiajiayao <48589551+jiajiayao@users.noreply.github.com>
2026-08-06 03:41:50 +08:00
jiajiayao
4fcd7fcd66 fix(orca): resolve managed worker model aliases (#1571)
* fix(orca): resolve managed worker model aliases

Signed-off-by: jiajiayao <jiajiayaoabc@qq.com>

* fix(orca): validate resolved worker model routes

Signed-off-by: jiajiayao <48589551+jiajiayao@users.noreply.github.com>

* test(orca): cover canonical-only managed capabilities

Signed-off-by: jiajiayao <48589551+jiajiayao@users.noreply.github.com>

* fix(orca): verify managed alias model identity

Signed-off-by: jiajiayao <48589551+jiajiayao@users.noreply.github.com>

* fix(orca): route model-only worker defaults

Signed-off-by: jiajiayao <48589551+jiajiayao@users.noreply.github.com>

* fix(orca): snapshot worker routing catalog

Signed-off-by: jiajiayao <48589551+jiajiayao@users.noreply.github.com>

* chore: retrigger PR review after template update

Signed-off-by: jiajiayao <48589551+jiajiayao@users.noreply.github.com>

* fix(orca): preserve inherited lead provider routes

Signed-off-by: jiajiayao <48589551+jiajiayao@users.noreply.github.com>

---------

Signed-off-by: jiajiayao <jiajiayaoabc@qq.com>
Signed-off-by: jiajiayao <48589551+jiajiayao@users.noreply.github.com>
2026-08-05 15:34:11 +08:00