已合并
[feat] 数据湖链路平台化:中性命名统一(env 前缀 breaking)+ 配置单源化 + 双栈单一引擎 + 信封双名 #49
[feat] 数据湖链路平台化:中性命名统一(env 前缀 breaking)+ 配置单源化 + 双栈单一引擎 + 信封双名 #49
已合并
duanbingzhe创建于 3 天前
duanbingzhe成员
3 天前

数据湖链路平台化(4 个 refactor + 哨兵 + 修复,12 提交)

breaking(两条)

  • env 前缀统一 LAKE_*:旧前缀环境变量不再识别,部署脚本需迁移;CI/脚本改为直接写服务端配置文件
  • 服务端配置单源化:远端偏好(地址/分支/目录)唯一存储为本机 lake-config.json(0600),解析链「请求体(仅编辑态探测)> 服务端配置 > env」——此前 Viewer 等服务端消费面只认环境变量,与设置页配置脱节;换浏览器/服务端加载直接生效
  • 凭据仓更名 lake-auth.json:读旧写新,存量凭据无感迁移

架构收敛

  • 中性命名统一:模块 src/lib/lake/、API /api/ingest/lake、页面 lake_viewer(旧路由跳转保留)——数据湖功能与特定数据仓实现解耦;地址无占位默认,未配置 fail-fast 指引
  • 双栈统一单一引擎:Viewer 侧并行实现(镜像/远端/notes 三副本)并入 src/lib/lake/,异步克隆栈/详细列表/notes 链归位引擎;session 大文件只落一处
  • 平台差异唯一居所 lib/lake/platform.ts(host 归一/错误码分诊/属主反查)——引擎其余部分零平台假设,其他托管平台无需适配即用通用语义
  • 信封双名:扩展字段新键 x_lake(写侧双名过渡、读侧新键优先旧键兜底——存量数据零迁移,全链 17 读点/20+ 写点),下个大版本退役旧键
  • 默认仓概念退役:范式多根模式恒开(全仓顶层目录即注册表);嵌套自定义目录统一识别(一级范式/存量/嵌套三形态归一推导)

配置体验

  • 数据湖配置前移到使用现场(导入点直接配置);品牌显示名保持产品名(哨兵白名单制)

修复

  • 嵌套路径列表统一推导(清 3 个 e2e 遗留失败);Viewer 范式目标文件误判为根级会话(导入范式选择器幻影桶)
  • push 凭据链精化;远端偏好 API 落盘归一化 + 写失败 500 语义区分(自查审查修复,含四态 IT + 负向验证)

防回潮

  • 平台中性哨兵:双包 src 词表零容忍扫描(私仓/组织/用户名/env 旧前缀),信封写点双名锁(写侧不双名即红)——合入门禁拦截
likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 duanbingzhe 的贡献)
Dduanbingzhe成员
3 天前 创建了 pull request,commit e23de7ae
Dduanbingzhe成员
3 天前 关联了issue:[Bug-Report|缺陷反馈]: cannbay viewer加载失败
CANN-robotCANN-robot成员
3 天前 添加了label:stat/needs-squash
CANN-robotCANN-robot成员
3 天前 添加了label:cann-cla/yes
CANN-robot
CANN-robot成员
3 天前 评论:

Thanks for your pull-request.
The full list of commands accepted by me can be found at here.
You can get sig-info at here.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.


PR Approval Progress

✅ Congratulations! All modules have met the lgtm and approve requirements.

Module Approval Details

module lgtm status approve status
repo-cann/cannbot-sentry ✅ guanxinghua, qwren (2/2) ✅ guanxinghua (1/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

duanbingzhe, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
hangdu成员3 天前进行代码检视2
packages/insight/src/lib/lake/platform.ts
已过期
@@ -0,0 +35,4 @@
35+ try {
36+ const u = new URL(pullUrl);
37+ if (u.host !== 'gitcode.com') return null;
38+ const res = await fetch(`https://gitcode.com/api/v5/user?access_token=${encodeURIComponent(secret)}`, {
hangdu3 天前评论:

tokenOwner 把令牌放在 URL query 参数里(?access_token=…)。query 参数会进入 HTTP 访问日志 / 反向代理日志,属于公认的凭据泄露反模式;gitcode v5 API 本身支持 Authorization: Bearer <token> 头(本仓库自身工具链也是这么调的)。建议改走 header 传令牌,避免令牌被日志侧录走。

likedislike
System
系统消息系统
2 天前 评论:

changed this line on 197314e9 view diff detail

hangdu成员3 天前进行代码检视2
packages/insight/src/lib/lake/server-config.ts
已过期
@@ -0,0 +60,4 @@
60+ fs.mkdirSync(path.dirname(file), { recursive: true });
61+ const tmp = `${file}.tmp-${process.pid}-${Date.now()}`;
62+ try {
63+ fs.writeFileSync(tmp, JSON.stringify(sanitize(cfg) ?? { address: cfg.address.trim() }, null, 2) + '\n', { mode: 0o600 });
hangdu3 天前评论:

兜底表达式 sanitize(cfg) ?? { address: cfg.address.trim() } 有隐患:sanitize 只在 address 为空/非字符串时返回 null,此时兜底会写一个只有(空)address 的文件,并静默丢掉 branch / directory / lfs。当前 PUT 路由已先拦空地址,但这是导出函数,任何未来调用方传入脏 address 都会得到「字段被悄悄丢弃」而非报错。建议改成显式抛错(或归一化后再写),避免静默丢字段。

likedislike
System
系统消息系统
2 天前 评论:

changed this line on 197314e9 view diff detail

hangdu成员3 天前进行代码检视1
packages/insight/src/lib/shared/envelope.ts
@@ -0,0 +11,4 @@
11+// (老版本读方不丢),下个大版本退役旧键。中立位置(shared/)——ingest
12+// 与 lake 两域都可引,无环。
13+ 
14+export const ENVELOPE_KEY = 'x_lake';
hangdu3 天前评论:

这个新模块(ENVELOPE_KEY / readEnvelope / envelopeFields)在仓库里没有任何引用——信封双名(x_lake 优先 / x_cannbay 兜底)的读写实际是散落在 mirror.ts(readSessionMetas / bareDirHoldsNativeRecording)、export.ts(xLake 手工双写)里内联字符串字面量完成的,与这里声明的「中立位置,两域都可引」意图脱节。建议要么把这些读/写点收口到本模块,要么删掉这个死模块——否则「下个大版本退役旧键」时每个内联字面量点都要单独改,防回潮哨兵也无法借单一真身判定。

likedislike
Dduanbingzhe成员
2 天前 预合并成功(commit_id: ea27a0096eec0bc9b1615cc164ad2d2ca49102b0)
Dduanbingzhe成员
2 天前 推送  1 个提交:197314e9-[fix] PR #49 审查意见修复:凭据属主反查改走认证头(不入 URL 防日志侧录),远端偏好落盘脏输入显式报错,信封双名读写收口单一真身模块
Dduanbingzhe成员
2 天前 预合并成功(commit_id: 1e7cb8d6be92919471151df65338b667bdc4f4b2)
CANN-robotCANN-robot成员
2 天前 删除了label:cann-cla/yes
CANN-robotCANN-robot成员
2 天前 添加了label:cann-cla/yes
Dduanbingzhe成员
2 天前 解决了最后一个问题
hangdu成员2 天前进行代码检视2
packages/insight/src/components/LakeTokenDialog.tsx
已过期
@@ -112,0 +120,4 @@
120+ headers: { 'Content-Type': 'application/json' },
121+ body: JSON.stringify({ address: address.replace(/\/+$/, '') }),
122+ })
123+ if (!cfgRes.ok) throw new Error(String((await cfgRes.json()).error ?? '地址保存失败'))
hangdu2 天前评论:

if (!cfgRes.ok) throw new Error(...) 在 try/catch 之外:handleSave 由 onClick 直接调用(未 await 的 async 函数),这里的 throw 会变成 unhandled promise rejection——setError 不会触发,弹窗零反馈,用户只看到「连接数据仓」按钮点了没反应。unconfigured 首次配置路径很容易踩到:地址含 FORBIDDEN_ADDRESS_CHARS(引号/$/;/&/|,例如从文档粘贴的带弯引号 URL)时 PUT 返回 400,静默失败;cfgRes.json() 在非 JSON 错误响应上同样裸抛。建议把这段落进下方 try/catch(或单独 catch 后 setError 再 return)。

likedislike
System
系统消息系统
2 天前 评论:

changed this line on 9047cfd6 view diff detail

hangdu成员2 天前进行代码检视2
packages/insight/src/lib/lake-config.ts
已过期
@@ -65,3 +64,3 @@
6564 if (typeof window === "undefined") return null
6665 try {
67- const raw = localStorage.getItem(CANNBAY_CONFIG_STORAGE_KEY)
66+ const raw = localStorage.getItem(LAKE_CONFIG_STORAGE_KEY)
hangdu2 天前评论:

loadLakeConfig() 只读新键 cannbot-insight-lake-config,但存量用户的偏好存在旧键 cannbot-insight-cannbay-config(上一版 saveCannbayConfig 写入)——PR 描述与文件头注释声称的「localStorage 降级为存量预填源(保存即迁移)」实际不会发生:升级用户打开设置页表单为空,地址/分支/目录需要全部重填(服务端 lake-config.json 此时还不存在,没有别的迁移源)。clearLakeConfig() 也只清新键,旧键永久残留,与「清旧键防复活」的注释不符。建议 loadLakeConfig 新键 miss 后回落读旧键,clearLakeConfig 同时移除两个键。

likedislike
System
系统消息系统
2 天前 评论:

changed this line on 9047cfd6 view diff detail

hangdu成员2 天前进行代码检视2
packages/insight/src/lib/lake/mirror.ts
已过期
@@ -564,0 +607,4 @@
607+ const nestedRe = new RegExp(`^${escapeRegExp(nested)}(baseline\/)?${escapeRegExp(folder)}\/`);
608+ const found = files.some(f => nestedRe.test(f));
609+ if (found) {
610+ safe.push({ root: remote.rootDir, baseline: false, recording });
hangdu2 天前评论:

嵌套 rootDir 兜底分支把 baseline 硬编码为 false:nestedRe 的 (baseline\/)? 可选组能匹配 <rootDir>/baseline/<sid>/,但命中后 push 的 loc 是 { root: rootDir, baseline: false }——locationPath 解析成 <rootDir>/<sid>/(错误位置)。后果:materializeSession 对该会话报「Session folder not found in lake」,uploadFolder 的 staleLocs 清理也指向错误路径。旧版单根路径对 <rootDir>/baseline/<sid>/ 与普通位都正确识别(rootDir 不含 / 时走多根正则同样正确),这是嵌套 directory + baseline 组合的回归。建议按 rootLevel/rootBaseline 同款方式分别判定两种形态,或循环里记录 m[2] 是否命中 baseline 段。

likedislike
System
系统消息系统
2 天前 评论:

changed this line on 9047cfd6 view diff detail

Dduanbingzhe成员
2 天前 预合并成功(commit_id: e6bf91e3926d552f5f8b4bc14832a21c43dc0e6d)
此处折叠了5条事件消息 查看更多
Hhangdu成员
2 天前 解决了最后一个问题
duanbingzhe成员
2 天前 评论:

/compile

likedislike
Dduanbingzhe成员
2 天前 预合并成功(commit_id: 1f75dad46c6c16030d5c7a16e297ec223d6f3dd4)
CANN-robot
CANN-robot成员
2 天前 评论:
🚀 CI 流水线已启动
📋 执行详情: 点击查看流水线
likedislike
CANN-robotCANN-robot成员
2 天前 添加了label:ci-pipeline-running
CANN-robotCANN-robot成员
2 天前 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
2 天前 添加了label:ci-pipeline-passed
guanxinghua成员
2 天前 评论:

/approve

likedislike
CANN-robotCANN-robot成员
2 天前 添加了label:approved
qwren成员
2 天前 评论:

/lgtm

likedislike
CANN-robotCANN-robot成员
2 天前 添加了label:lgtm
CANN-robotCANN-robot成员
2 天前 关闭了关联的issue
CANN-robotCANN-robot成员
2 天前 合入了pull request