refactor(service-storage): 摘除 Local/S3 适配器的 list(prefix) 实现与测试 (#5541) - #6061
Draft
hotlong wants to merge 1 commit into
Draft
refactor(service-storage): 摘除 Local/S3 适配器的 list(prefix) 实现与测试 (#5541)#6061hotlong wants to merge 1 commit into
list(prefix) 实现与测试 (#5541)#6061hotlong wants to merge 1 commit into
Conversation
The implementation half of the #5540 contract retirement (ADR-0049 enforce-or-remove; analysis #5266). #5983 landed the spec member and the SwappableStorageService passthrough atomically; this removes what it left: - `LocalStorageAdapter.list` (single-level readdir, directories returned as files) and `S3StorageAdapter.list` (recursive ListObjectsV2, silently truncated at 1000 objects, IsTruncated/ContinuationToken never read); - the `'list'` label in each adapter's private `track()` metrics vocabulary, which no site can produce anymore; - the tests that pinned those two dialects, plus the dead `FakeAdapter.list` in the swappable proxy's test. Zero in-repo consumers: after #5983 the only surviving references were the two producers and their own tests. The absence is held by a new runtime pin, `storage-adapter-list-retirement.test.ts`. tsc cannot hold this line -- a class may carry members its interface does not declare, which is exactly what the #5540 changeset promised adapter authors -- verified by restoring both methods: the pin goes red on both adapters while `pnpm --filter @objectstack/service-storage build` (tsup DTS, i.e. tsc) still exits 0. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015a5qkLzpGXhLL2F5gvJ7dD
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Contributor
📓 Docs Drift CheckThis PR changes 1 package(s): 4 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
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 #5541
#5540摘掉了IStorageService.list?(prefix)这个契约成员;本 PR 是它的实现半 —— 摘掉两个出厂适配器自己的list实现、它们的测试,以及各自track()指标词表里那个再也产不出来的'list'标签。范围核对(⛔ 不重做 PR #5983 已完成的部分)
开工第一步读了
efedd28(PR #5983)的终态 diff。它已原子落地:spec 契约成员 +SwappableStorageService.list代理透传 + 该文件两处测试 + 文档 + ADR-0087 D3 登记。这些一律没有再动。swappable-storage-service.ts:74-76留的指向本单的注释也保持原样。本 PR 只做剩下的四处(两个生产者 + 它们的测试):
local-storage-adapter.tslist(单层readdir、把子目录当文件返回);track()词表去掉'list's3-storage-adapter.tslist(单发ListObjectsV2,IsTruncated/ContinuationToken都不读,过 1000 个对象静默截断);track()词表去掉'list'local-storage-adapter.test.tslocal-storage-adapter.metrics.test.tslist() does not double-count head per entry整条退役(它钉的是被删实现的内部细节)swappable-storage-service.test.tsFakeAdapter.list—— #5983 之后它已无人调用,是个「真适配器都没有的表面」的假体残留storage-adapter-list-retirement.test.ts(新增)list零消费方证据(全仓引用面)
摘除前后同一条查询,
packages/services/service-storage/内:改前的四处全部是测试,没有一处产品代码调用 —— 这与 #5266 的分析一致:唯一的仓内调用点是 #5983 已删掉的代理透传。跨包声明式 + 带引号精确名两种查法(
storage.list(/storageService.list(/adapter.list(/async list(/list?(prefix)在packages/examples/apps/scripts/全仓扫过,除packages/spec的退役登记文本外,命中的async list(...)全是同名不同物:metadata loader 的list(type)、messaging outbox 的list(filter)、suspended-run-store的list(),与存储无关。存储侧零残余。必答项:
StorageFileInfo是否随之退役?不退役 —— 它仍有消费方,
list从来不是它唯一的生产者。 实测:IStorageService.getInfo(key)的返回类型就是它,而getInfo是契约的必选成员(packages/spec/src/contracts/storage-service.ts:124),spec: 按 ADR-0049 摘除IStorageService.list(prefix)契约成员(零消费方,双适配器语义分叉 —— #5266 方案 2,维护者已批) #5540 没有动它;local-storage-adapter.ts:184、s3-storage-adapter.ts:198、swappable-storage-service.ts:70;getInfo的返回标注。所以 changeset 措辞按「成员摘除、类型保留」写,没有任何类型退役的语句。
反向验证(方向先声明,再跑)
预判写在动手之前:把
list加回两个适配器,新留钉应变红,而包的 build(tsup DTS,即 tsc)应保持绿。后半句才是这条钉子存在的理由 —— class 携带接口未声明的多余成员不是类型错误,这正是 #5540 changeset 对适配器作者的承诺原文(「an implementation left in place still compiles」),所以 tsc 守不住这条线。两半都如预判:
随后已还原,
git diff --stat与还原前逐字节一致。留钉里第三条用例(仍暴露upload/download/delete/exists/getInfo)是防镜像失效的:一个「适配器什么方法都没有」的空壳同样会让前两条绿。验证
门是从
.github/workflows/lint.yml逐条枚举跑的,不是凭记忆挑的。pnpm --filter @objectstack/service-storage test→ 22 files / 282 tests passed(含新留钉 3 条)pnpm --filter @objectstack/service-storage build→ DTS 成功(该包无typecheckscript,tsc 走 tsup DTS 这条道,与 refactor(spec)!: 按 ADR-0049 摘除IStorageService.list(prefix)—— 零消费方、双适配器语义分叉 (#5540) #5983 commit message 记录的一致)turbo run build(service-storage + 全部三个下游cli/plugin-dev/dogfood及其依赖闭包)→ 62 tasks successful,证明删除对下游零类型影响lint(ESLint)、check:slot-lookup、check:query-options-erasure、check:nul-bytes、check:doc-authoring、check:docs-audit-scope、check:role-word、check:adr-anchors、check:org-identifier、check:authz-resolver、check:service-providers、check:route-envelope、check:error-code-casing、check:wildcard-fallthrough、check:init-service-contract、check:durability-log-level、check:startup-registry-verdict、check:objectui-changeset、check:release-notes、check:release-body、check:node-version、check:workflow-status-functions、check:published-files、check:engine-double-contract、check:resume-authority-declared、check:type-check-coverage、check:driver-conformance、check:stall-guard、check:skill-frame-sync、check:i18n、check:i18n-coverage→ 全 PASSpackages/spec,未重生成任何 spec 产物(git status -- packages/spec content/docs docs/为空)changeset
.changeset/storage-adapter-list-implementations-removed.md,@objectstack/service-storage: patch。按约束写得响亮:两个方言各自错在哪、该成员从未有过仓内消费方、以及未来按需回归的形状指引 —— 回来时是带游标的list(prefix, { cursor, limit }),返回一页 + 续传 token,并要求 nested keys / 目录项 / 超 1000 对象三类 adapter-conformance 用例证明两个后端答案一致,不继承坏签名(#5266 维护者裁决原文)。取 patch 而非 major:契约破坏是 #5540 的、已在那里发布;这里同时如实列出直接持有具体类LocalStorageAdapter/S3StorageAdapter调.list()的下游该改成什么,没有藏。Generated by Claude Code