Store secrets apart from settings and guard open listeners #63

Merged
weichen merged 4 commits from feature/sillytavern-review into main 2026-10-04 19:42:36 +00:00
Owner

feature/sillytavern-review 任务卡

任务主记录:<PR 链接,task-finish 时填写>;状态:进行中;owner:weichen

基线与授权

  • 权威仓:ssh://git@git-ssh.u1680832.nyat.app:31411/weichen/Agent-System-Dev.git;目标分支:main;R0(initial_base_sha)= 4fd03eee6230f82464def08f2543adab27aba948
  • 工作区:/home/weichen/projects/Agent-System-Dev-wt-feature-sillytavern-review(worktree);分支:feature/sillytavern-review
  • 授权与交付终点:调研记录、已核实的安全缺口,以及方案里的批次 A–D 都在本任务实现。完成后推送、建 PR、合入,并在 worktree 内 make task-finish。不拷 SillyTavern 代码或文案。不轮换 Tavily 密钥,只在验收说明里建议轮换。不改认证默认 auto,不加 CSRF token,不加 CSP 上报端点。

目标与非目标

  • 目标:Documents 记录与提案 §2.5;HTML 清洗与安全响应头;来源校验与非回环无认证拒绝启动;密钥独立存储与设置快照;个人指令、会话要求、条件注入、上下文分段估算与消息整形;复制、成组排除、追加式候选回复;用户 / 命令展开成提示词且不自动触发。
  • 契约:Message 增加 excluded / variantGroup / variantIndex。Conversation 增加 sessionNote。ContextObservation 增加 sections 与 prefixHash。新表见 Backend 迁移 v16。设置新增 context.userInstructions、context.contextWindow、context.messageShape。
  • 兼容:反向代理或用主机名从局域网访问时,必须把对外域名写入 allowedHosts,否则未开认证时 Host 校验返回 403。旧设置里的明文密钥在启动时迁入 secret_keys 后从设置 JSON 清除;运行时仍接受尚未迁走的旧字段。
  • 非目标:缓存断点、编辑重发、会话分支、窗口外召回、世界书概率/递归/分组/定时、密钥静态加密、i18n、出站代理、画像导入导出、扩展系统、宏、群聊、角色卡、自定义 CSS、删除消息、自动触发的快捷回复。

同步记录

节点 sync_base_sha tested_head_sha checked_at
启动 4fd03eee6230f82464def08f2543adab27aba948 4fd03eee6230f82464def08f2543adab27aba948 2026-10-04T17:06:46Z

结果与验证(完成后填写)

  • 结果:安全缺口 S1–S4 与批次 A–D 已在本分支实现。Documents 记录写明 A–D 在本任务落地。指针:core 0b5c774,agent-native 3a110a7,agent-squad 5a57636,ui 6b2589c,frontend eb6502f,documents f3f823e,backend c05832d,Dev 4ba1d49。
  • 验证:Dev make test 退出码 0(boundaries、pins、三库、core、backend、frontend vitest 16 文件 78 项、knip 43、ui tsc/vitest/knip 55、agent-command)。make build 退出码 0,产出 bin/agent-system。Backend GOWORK=off go vet ./... 退出码 0。
  • 影响与剩余项:合入前还要 task-sync、推送、PR、dev 验收。Tavily 密钥建议轮换,本任务不轮换。暂缓项与拒绝项仍不做。
    | 同步前验收 | 4fd03eee6230f82464def08f2543adab27aba948 | cd6be001414759f3ad00cf860ae095b70593e296 | 2026-10-04T18:42:56Z |
    | 同步前验收 | 4fd03eee6230f82464def08f2543adab27aba948 | ce551683256e770d96c18fdaf93df49df4e0e3b1 | 2026-10-04T18:45:12Z |
# feature/sillytavern-review 任务卡 任务主记录:<PR 链接,task-finish 时填写>;状态:进行中;owner:weichen ## 基线与授权 - 权威仓:ssh://git@git-ssh.u1680832.nyat.app:31411/weichen/Agent-System-Dev.git;目标分支:main;R0(initial_base_sha)= 4fd03eee6230f82464def08f2543adab27aba948 - 工作区:/home/weichen/projects/Agent-System-Dev-wt-feature-sillytavern-review(worktree);分支:feature/sillytavern-review - 授权与交付终点:调研记录、已核实的安全缺口,以及方案里的批次 A–D 都在本任务实现。完成后推送、建 PR、合入,并在 worktree 内 `make task-finish`。不拷 SillyTavern 代码或文案。不轮换 Tavily 密钥,只在验收说明里建议轮换。不改认证默认 `auto`,不加 CSRF token,不加 CSP 上报端点。 ## 目标与非目标 - 目标:Documents 记录与提案 §2.5;HTML 清洗与安全响应头;来源校验与非回环无认证拒绝启动;密钥独立存储与设置快照;个人指令、会话要求、条件注入、上下文分段估算与消息整形;复制、成组排除、追加式候选回复;用户 `/` 命令展开成提示词且不自动触发。 - 契约:`Message` 增加 `excluded` / `variantGroup` / `variantIndex`。`Conversation` 增加 `sessionNote`。`ContextObservation` 增加 `sections` 与 `prefixHash`。新表见 Backend 迁移 v16。设置新增 `context.userInstructions`、`context.contextWindow`、`context.messageShape`。 - 兼容:反向代理或用主机名从局域网访问时,必须把对外域名写入 `allowedHosts`,否则未开认证时 Host 校验返回 403。旧设置里的明文密钥在启动时迁入 `secret_keys` 后从设置 JSON 清除;运行时仍接受尚未迁走的旧字段。 - 非目标:缓存断点、编辑重发、会话分支、窗口外召回、世界书概率/递归/分组/定时、密钥静态加密、i18n、出站代理、画像导入导出、扩展系统、宏、群聊、角色卡、自定义 CSS、删除消息、自动触发的快捷回复。 ## 同步记录 | 节点 | sync_base_sha | tested_head_sha | checked_at | |---|---|---|---| | 启动 | 4fd03eee6230f82464def08f2543adab27aba948 | 4fd03eee6230f82464def08f2543adab27aba948 | 2026-10-04T17:06:46Z | ## 结果与验证(完成后填写) - 结果:安全缺口 S1–S4 与批次 A–D 已在本分支实现。Documents 记录写明 A–D 在本任务落地。指针:core `0b5c774`,agent-native `3a110a7`,agent-squad `5a57636`,ui `6b2589c`,frontend `eb6502f`,documents `f3f823e`,backend `c05832d`,Dev `4ba1d49`。 - 验证:Dev `make test` 退出码 0(boundaries、pins、三库、core、backend、frontend vitest 16 文件 78 项、knip 43、ui tsc/vitest/knip 55、agent-command)。`make build` 退出码 0,产出 `bin/agent-system`。Backend `GOWORK=off go vet ./...` 退出码 0。 - 影响与剩余项:合入前还要 task-sync、推送、PR、dev 验收。Tavily 密钥建议轮换,本任务不轮换。暂缓项与拒绝项仍不做。 | 同步前验收 | 4fd03eee6230f82464def08f2543adab27aba948 | cd6be001414759f3ad00cf860ae095b70593e296 | 2026-10-04T18:42:56Z | | 同步前验收 | 4fd03eee6230f82464def08f2543adab27aba948 | ce551683256e770d96c18fdaf93df49df4e0e3b1 | 2026-10-04T18:45:12Z |
weichen added 4 commits 2026-10-04 18:46:27 +00:00
Why: The embedded tier starts without auth, and nothing checked Origin or Host, so a public bind or a foreign page could call write APIs.
Evidence: go test ./internal/config ./internal/server covering listen policy, origin rejection, and response headers.
Impact: Non-loopback without auth exits before opening the database. HTML artifacts get a sandbox CSP. Reverse proxies must list their public host in allowedHosts.
Refs: feature/sillytavern-review
Co-authored-by: Cursor <cursoragent@cursor.com>
Why: Masks must not be the only copy of a key, and personal instructions, lore hits, and candidate replies have to reach the model without rewriting the system prefix or deleting history.
Evidence: go test ./internal/store ./internal/ctxasm ./internal/settings ./internal/runtime ./internal/server. Migration v16 upgrades and rolls back. Startup snapshots settings before moving raw keys.
Impact: One labeled key is active per service. Excluding a message hides its whole run from the model. Regenerating appends another candidate and rewinds files to the user turn. User slash commands expand to prompt text and do not fire on their own.
Refs: docs/records/2026-10-04-sillytavern-review.md
Why: The pin check requires Backend's squad gitlink to match Dev, and that squad commit must itself pin the message-shaping agent-native.
Evidence: Squad commit 5a57636 points agent-native at 3a110a7.
Impact: Backend and Dev resolve the same squad and native trees.
Refs: docs/records/2026-10-04-sillytavern-review.md
Pin agent-system-core after the contract type cleanup
ci / vet-and-test (pull_request) Successful in 43s
c05832dd6a
Why: Dev and the backend checkout must name the same core commit, and the section type is no longer a separate export.
Evidence: modules/core is 0b5c774. The nested checkout is detached at that commit.
Impact: Backend still compiles the same Go observation type. Only the TypeScript export changed.
Refs: .task/feature-sillytavern-review.md
Co-authored-by: Cursor <cursoragent@cursor.com>
weichen merged commit 272d4d6d1c into main 2026-10-04 19:42:36 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: weichen/Agent-System-Backend#63