docs(examples): showcase 的 cacheTtl 注释写成 private —— 运行时发的就是它,且它是安全规则 (#5244) - #5395
Merged
Merged
Conversation
…5244) `examples/app-showcase/src/system/apis/index.ts` 里 `TaskFeedEndpoint.cacheTtl` 上方的注释把响应头写成 `Cache-Control: public, max-age=30`,运行时发的是 `private, max-age=30`(`packages/runtime/src/endpoint-policy.ts` 的 `computeCacheControl`;PR #5230 的真实 boot 探针 P1 也打印了实测值)。 `private` 在这条链上不是调优选择而是安全规则:任何一条响应都可能按调用者被 RLS 裁剪,共享缓存绝不能存下来再发给别人。而这份文件是声明式端点唯一的一手示例,是 AI 作者最可能整段抄走的那份 —— 抄走 `public` 正好得出该规则要挡住的推断。 因此除了把 `public` 改成 `private`,注释还点明它不是本示例的调优选择(在 `authRequired: false` 上同样成立),并**引用** `computeCacheControl` 的文档块而不是 复述第二套规则;顺带把 `cacheTtl: 0` 的语义(`no-store`,不是「不发头」)一并指过去。 注释的后半句(只随成功答案上线、不随 401/429/5xx、GET-only)本来就是对的,保留。 零行为变更:不动运行时,不动声明本身(`cacheTtl: 30` 是对的)。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VkPSGsX9o17MsGv3Lbxu2w
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
自查时发现上一版注释里「the runtime emits it for every ttl」本身就不准:`private` 只出现在正 ttl 上,`cacheTtl: 0` 走的是 `no-store`,并不带 `private`。这正是本 PR 要 消灭的那一类失真,故就地收紧为「every positive ttl」,与紧随其后的 `cacheTtl: 0` 说明自洽。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VkPSGsX9o17MsGv3Lbxu2w
baozhoutao
marked this pull request as ready for review
August 5, 2026 07:24
baozhoutao
enabled auto-merge
August 5, 2026 07:24
This was referenced Aug 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5244
纯注释修真,零行为变更。改动面只有一个文件的一段注释:
examples/app-showcase/src/system/apis/index.ts(TaskFeedEndpoint.cacheTtl上方)。前提复核(按 origin/main 逐条验过)
publicexamples/app-showcase/src/system/apis/index.ts:80(改前)privatepackages/runtime/src/endpoint-policy.ts的computeCacheControl:return+ 反引号模板private, max-age=${Math.floor(ttl)}cacheTtl: 0→no-storeprivate是安全规则而非调优computeCacheControl上方文档块已成文,并说明它在authRequired: false上同样成立前提成立,且只有
public这一个词是错的 —— 注释后半句(只随成功答案上线、不随401/429/5xx、GET-only)本来就对,原样保留。
为什么这一个词值得一个 PR
private在这条链上是安全规则:任何一条响应都可能按调用者被 RLS 裁剪,共享缓存绝不能存下来再发给别人。而这份文件是声明式端点唯一的一手示例,是 AI 作者最可能整段抄走的
那份 —— 抄走
public的作者会顺理成章地推断「共享缓存可以存这条响应」,而这正是该规则要挡住的推断。
改法(按 issue 口径)
public→private;authRequired: false上同样成立—— 这是抄走后最容易出的第二层错误推断;
packages/runtime/src/endpoint-policy.ts的computeCacheControl文档块,避免在示例里养出第二套会各自漂移的说法;cacheTtl: 0的语义(no-store,而不是「不发头」;「什么都不说」是靠省略这个键来表达的)一并指过去 —— issue 让核一下是否值得点一句,这里能自然接在同一句引用后面,
故点了。
措辞与
endpoint-policy.ts文档块、以及content/docs/protocol/kernel/http-protocol.mdx的口径一致(后者早已写的是
private,showcase 是最后一处public)。边界
cacheTtl: 30是对的)、不动content/docs/releases/。public, max-age的其余命中都是真·公共面(OIDC discovery、静态资源、marketplace 公共目录),不在本次范围内,也没有发现同类失真。
验证
在专用 worktree 里做的,重活都走
flock /tmp/os-heavy-verify.lock+ 4G 堆上限:首轮 typecheck 曾整屏
TS2307 Cannot find module '@objectstack/*'—— 是新 worktree 未建依赖所致(报错无一落在本次改动的文件上),补
^...build 后转全绿。changeset
没有加 changeset,请打
skip-changeset标签。 理由:@objectstack/example-showcase("private": true)里的一段注释,不发布任何东西,AGENTS.md 也写明纯修正类改动不强制 changeset;
.github/workflows/release.yml记着空 changeset 会静默卡死已 version 的发布:Release run 全绿,但 npm 和 Docker 什么都没发(17.0.0-rc.2 现在就卡着) #4898 的教训:main 上只剩空 changeset 时 changesets 会打印 "All changesets are empty;
not creating PR" 并直接返回,白吃掉一整轮发布。所以这里选标签而不是空 changeset。
随手记
packages/qa/dogfood/test/showcase-declarative-endpoints.dogfood.test.ts:202这条真实boot 断言只
toMatch(/max-age=30/),并不钉private/public这一位。已按 PrimeDirective #10 另开 observation 单,不在本 PR 修。
🤖 Generated with Claude Code
https://claude.ai/code/session_01VkPSGsX9o17MsGv3Lbxu2w
Generated by Claude Code