Skip to content

种子页可编辑当前槽配置,并记录遥测上传 - #610

Closed
dofastted wants to merge 20 commits into
mainfrom
fix/remote-slot-refresh
Closed

dofastted wants to merge 20 commits into
mainfrom
fix/remote-slot-refresh

Conversation

@dofastted

@dofastted dofastted commented Oct 19, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • 种子页按当前槽 settings.json 显示配置。env 可直接编辑,theme 可改;autoUpdates 和 grove_enabled 只读,播种时固定。缺少 CLAUDE_CODE_ATTRIBUTION_HEADER 时默认 0。
  • 文件缺失时 claude_setting 返回 null,空文件保持空串,不再用默认串冒充。
  • 「调试上传」默认关闭。打开后显示本槽最近 40 条实际上传,正文是 PostBatch 的 events 包装;落盘前去掉邮箱、账号、组织和设备标识。
  • 同分支还包含线程 beta 固定、服务二进制替换后的出口重启,以及 auto compact 窗口保留。

Test plan

  • pnpm -C web exec vitest run src/features/vm/seed-settings.test.ts src/features/vm/seed-policy-card.test.ts
  • pnpm -C web exec tsc -b
  • node --test test/unit/panel-vm-seed-settings.test.mjs test/unit/seed-policy.test.mjs
  • cd worker && go test ./internal/telemetry/
  • 部署后验证。当前线上还是上一次的 1.3.199 覆盖层,不含这次提交。

不合并。


Note

High Risk
Touches fleet/container migration, egress process ownership, and outbound beta pinning on threaded Claude hops—failures can leave stale egress binaries or wrong API gates while VMs keep running.

Overview
Redesigns the VM seed tab so admins edit what is actually on disk: live settings.json env/theme rows, an editable claude.setting file, reject-client toggles, and a telemetry lamp that separates policy on/off from whether the sidecar process is running (2s refresh). Saving is an explicit 播种; optional 调试上传 (?debug=1) shows the last 40 redacted telemetry upload lines from the slot run dir.

Backend seed API returns claude_setting from the slot file (null if missing), accepts it on PUT, writes seed files including claude.setting, and when telemetry policy changes on a running VM runs a telemetry-only fleet update instead of a full slot reload. Go telemetry now appends redacted upload audit lines to telemetry-upload.log.

Go slot services move to a persistent per-slot slot-bin bind at /opt/kin-live (layout v3): install/upgrade and fleet-update / fleet-services.mjs publish kin-worker/kin-egress and restart those processes without rebuilding VMs; remote slots can migrate legacy containers (rename to *-legacy-*). kin-egress lifecycle is stricter about deleted binaries and stale PIDs holding ports.

Protocol/routing extras: thread continue turns reuse pinned Anthropic betas from the create turn; auto_compact_window is configurable in panel compat and forwarded into kernel/CLI hop bodies; mid-conversation output-config beta when thread is present.

Reviewed by Cursor Bugbot for commit fb2bd5f. Configure here.

默认跟随请求模型,调用方窗口经内部字段送到当前 job,面板值可热配置。
窗口在入站清理前提取,再经内部字段进入 native body。
窗口必须在 settings 删除前提取,再传给 native body。
A replaced helper keeps the old inode and the listen port. Ownership now
treats that process as down and the next start or fleet refresh stops every
helper bound to the proxy config, including one the pidfile no longer names.
Fleet refresh now waits for every helper bound to the proxy config to exit
before binding the new one. install.sh no longer treats a failed refresh as
a successful upgrade.
账本列出文件里的真实配置项,claude.setting 可编辑后播种。遥测开/关与进程状态分开,种子页打开时 2 秒刷新。
编辑框只显示当前槽文件的原文。文件缺失或为空都保持空白,不再回退到策略文本或默认串。
GET /seed-settings 不再用策略默认串填补不存在的文件。空文件仍返回空串,策略字段保持独立。
settings.json 的 env 改成输入框,播种时写回。缺少 CLAUDE_CODE_ATTRIBUTION_HEADER 时默认 0。
默认不拉取。打开后读取本槽 telemetry-upload.log,sidecar 在每次上传后追加正文。
theme 可编辑并随播种写回。autoUpdates 与 grove_enabled 由播种固定,只读显示,不再被环境项过滤掉。
落盘前去掉邮箱、账号、组织和设备标识。超过四十行时原子替换,不再无限追加。
调试开关会改变查询键。保存成功按种子前缀失效,避免日志继续显示旧记录。
batch 日志改为 PostBatch 发出的 BatchRequest。身份字段仍在包装内删除。

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 3 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit fb2bd5f. Configure here.

concurrency: 1,
routing: ctx.routingConfig,
})
service = report.items?.[0] || report

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Seed save restarts kin-egress

High Severity

Toggling telemetry on a seed save now runs fleet telemetry, which copies Go binaries and restarts kin-egress as well as the sidecar. Seed PUT is supposed to write seed files and bounce only the telemetry child, not take the slot’s exit down or treat a config edit as a fleet binary roll.

Additional Locations (2)
Fix in Cursor Fix in Web

Triggered by learned rule: Slot-bin v3; telemetry fleet restarts Go only

Reviewed by Cursor Bugbot for commit fb2bd5f. Configure here.

const egress = await restartLocalEgress(projectRoot, vm, egressOpts)
if (!egress.ok) return egress
return { ...telemetry, egress: egress.egress }
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Fleet egress restarts race

High Severity

Local fleet telemetry restarts kin-egress per VM with default concurrency 4 and no lock on the proxy run dir. Two slots that share a proxy can stop and spawn the helper at once; the losing process exits and the pidfile can record it, leaving the port busy or not_running.

Additional Locations (1)
Fix in Cursor Fix in Web

Triggered by learned rule: kin-egress reload waits for old process exit

Reviewed by Cursor Bugbot for commit fb2bd5f. Configure here.

const out = applyRequiredSeedEnv(env, pol)
// 2.1.283+ sends x-claude-code-prompt-id only when this is set. Default on.
out.CLAUDE_CODE_GATEWAY_HINT_HEADERS = '1'
if (out.CLAUDE_CODE_ATTRIBUTION_HEADER == null) out.CLAUDE_CODE_ATTRIBUTION_HEADER = '0'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Seed env TZ edits discarded

Medium Severity

The seed page now treats every settings.json env key as editable, including TZ and LANG, and saves them as extra_env. Slot write still overwrites those keys from the VM timezone and locale after the merge, so those form edits never land in the file.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit fb2bd5f. Configure here.

@dofastted

Copy link
Copy Markdown
Owner Author

已部署到线上,PR 仍未合并。

  • VERSION:1.3.199
  • HEAD:fb2bd5f0
  • 备份:/opt/vm2api/.deploy-bak-vm2api-1.3.199-20261019T132846Z
  • verify-live.py 1.3.199 --auth-mode master:exit 0
  • 13 个槽,8 个 kin 容器保持 Up,容器 ID 与部署前一致,对话返回 pong
  • 未执行 wrap-cli/sync。新的 kin-worker 只在控制面二进制里;正在跑的遥测 sidecar 要等所在槽下次重启才按新日志规则记录。

Copy link
Copy Markdown
Owner Author

发版已拒(厨房水槽 dirty,同 #606)。勿合、勿 tip。

处理:

— vm2api代码

Copy link
Copy Markdown
Owner Author

主聊已授权关闭。

勿合。 迁移只走 #605;协议(auto_compact)只走 #607;若要种子增量从 tip 2bb07d84 新开干净 PR(仅可编辑 env/theme + 调试上传 40 条脱敏)。thread-beta 另开。

勿 tip。

— vm2api代码

@dofastted dofastted closed this Oct 19, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Agentic security review completed for this head. One HIGH finding remains: host-side seed/telemetry I/O follows guest-writable bind-mount paths without the O_NOFOLLOW / temp+rename pattern already used for cluster slot files.

Open in Web View Automation 

Sent by Cursor Security Agent: Security Reviewer

Comment on lines +3533 to +3536
claude_setting = fs
.readFileSync(path.join(homeDir, '.claude', 'claude.setting'), 'utf8')
.replace(/\r\n?/g, '\n')
.replace(/\n+$/g, '')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔒 Agentic Security Review
Severity: HIGH

Host GET /api/panel/vms/:id/seed-settings now readFileSyncs cli-home/.claude/claude.setting (and, with ?debug=1, vms/<id>/run/telemetry-upload.log). PUT save writes the same claude.setting path via writeSlotSeedFiles using writeFileSync. Both directories are guest-writable bind mounts (/home/kincli, /run/kin). Cluster host I/O already treats the final path component as attacker-controlled and requires O_NOFOLLOW / temp+rename so a guest cannot redirect the control plane.

Impact: A process in the slot can replace those names with a symlink (for example to a sibling slot's credentials.json or internal.token). An admin opening or saving the seed page then leaks or overwrites the target in the host namespace. A FIFO on the same path can also stall the shared Node process.

Fix in Cursor Fix in Web

Reviewed by Cursor Security Reviewer for commit fb2bd5f. Configure here.

@cursor
cursor Bot deleted the fix/remote-slot-refresh branch October 19, 2026 13:56
dofastted added a commit that referenced this pull request Oct 19, 2026
从 tip 拣出 #610 种子增量:settings.json env/theme 可编辑播种;契约 env(TZ/LANG/kill-switch/Bedrock/Vertex/gateway hint)与 autoUpdates/grove 只读;缺 CLAUDE_CODE_ATTRIBUTION_HEADER 默认 0。调试上传独立 query,切换不丢未保存编辑;Go sidecar 写脱敏 telemetry-upload.log。

不含锁定确认流、空 TZ 跟 SOCKS5、VERSION。勿 tip。
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