Skip to content

feat(objectql): resolve file-field id references on read — ADR-0104 D3 wave 2 (PR-2) - #3473

Merged
os-zhuang merged 1 commit into
mainfrom
d3w2/file-as-reference
Jul 24, 2026
Merged

feat(objectql): resolve file-field id references on read — ADR-0104 D3 wave 2 (PR-2)#3473
os-zhuang merged 1 commit into
mainfrom
d3w2/file-as-reference

Conversation

@os-zhuang

Copy link
Copy Markdown
Contributor

ADR-0104 D3 wave 2PR-2——读路径把文件字段的 sys_file id 引用解析成展开形态。承接 PR-1(#3466,上传提交返回 fileId)。跟踪:#3459

改动

引擎读路径新增一步:file/image/avatar/video/audio 字段若存的是 sys_file 的 opaque id,读取时原地解析成展开形态 { id, name, size, mimeType, url }——url 由稳定解析器 /api/v1/storage/files/:fileId 派生、永不落库。一次批量 sys_fileid $in […] 读(禁 N+1),沿用 lookup-$expand 的批量模式。

双模式安全(关键)

  • 内联 blob(对象值)原样透传——字段在 v17 前可同时持两种形态。
  • 只有 opaque id token(uuid/nanoid 形,非 URL 形)才当引用解析。文件字段在遗留世界里合法地持 URL 字符串(https://…/api/…data:…blob:…)——这些一律不查
  • 无 id token → 零额外读;sys_file 未注册 → 整步 no-op。所以这个 always-on 步骤对尚未采用引用的对象是免费的。

⚠️ 这一条是实打实踩出来的:最初把「文件字段里任何字符串」都当候选 fileId,导致 seed 里的 data:image/svg… 值在每次读取时都触发一条失败的 sys_file 查询(no such table + 巨长 data-URI 进 IN 子句),field-zoo dogfood 直接卡死。id-shaped 过滤 + 注册守卫修掉了它,并加了回归测试锁死。

测试

  • 5 个新引擎用例:解析 / 一次批量查询(no-N+1)/ blob+URL 双模式透传 / URL·data-URI 永不查询(回归)/ 非 committed 行不解析
  • objectql 1068
  • field-zoo dogfood roundtrip 46 ✓(12.6s,无 bogus sys_file 查询——证明真机读路径无回归)

序列位置

PR-2/7。下一步 PR-3:字段引用行(泛化 sys_attachment 计数)。破坏性/不可逆步骤(PR-5 写切换+GC、PR-6 迁移)排最后,带 R4/R5/R6 门,等你明确点头。

🤖 Generated with Claude Code

https://claude.ai/code/session_01SHpGw3GBA9aFpfwVArRWfd


Generated by Claude Code

…3 wave 2 (PR-2)
The engine read path resolves a file/image/avatar/video/audio value stored as
an opaque sys_file id into its expanded FileValueSchema form
({id,name,size,mimeType,url}; url derived from /files/:fileId, never stored),
via one batched sys_file `id $in […]` read (no N+1), mirroring lookup-$expand.
Dual-mode safe: inline-blob objects pass through; only an id-shaped token
(uuid/nanoid, never url-shaped) is a reference — a https/​/api/​/data:/blob:
value a file field legitimately holds is never looked up (regression-tested).
Fires zero reads unless a file field holds an id token, and no-ops when sys_file
is unregistered — so the always-on step is free for objects that have not
adopted references.
Tests: 5 new engine cases (resolution, one-batched-query/no-N+1, blob+url
dual-mode passthrough, url/data-URI never queried, non-committed skip);
objectql 1068 green; field-zoo dogfood roundtrip green (12.6s, no bogus
sys_file queries).
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SHpGw3GBA9aFpfwVArRWfd
@vercel

vercelBot commented Jul 24, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

ProjectDeploymentActionsUpdated (UTC)
specBuildingBuildingPreview, CommentJul 24, 2026 4:55pm

Request Review

@github-actionsgithub-actionsBot added documentation Improvements or additions to documentation tests tooling size/m labels Jul 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/objectql.

13 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:

  • content/docs/concepts/metadata-lifecycle.mdx(via @objectstack/objectql)
  • content/docs/data-modeling/formulas.mdx(via packages/objectql)
  • content/docs/deployment/migration-from-objectql.mdx(via @objectstack/objectql)
  • content/docs/deployment/vercel.mdx(via @objectstack/objectql)
  • content/docs/kernel/services-checklist.mdx(via @objectstack/objectql)
  • content/docs/kernel/services.mdx(via @objectstack/objectql)
  • content/docs/permissions/authentication.mdx(via @objectstack/objectql)
  • content/docs/plugins/index.mdx(via @objectstack/objectql)
  • content/docs/plugins/packages.mdx(via @objectstack/objectql)
  • content/docs/protocol/kernel/index.mdx(via @objectstack/objectql)
  • content/docs/protocol/objectql/state-machine.mdx(via @objectstack/objectql)
  • content/docs/releases/implementation-status.mdx(via @objectstack/objectql)
  • content/docs/releases/v9.mdx(via @objectstack/objectql)

Advisory only. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs origin/main → pass the list as args.docs.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentationImprovements or additions to documentationsize/mteststooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@os-zhuang@claude