Skip to content

feat(worker): 保留原始 IFC 檔名追蹤 - #17

Merged
monkey1sai merged 1 commit into
mainfrom
codex/impl/add-worker-original-filename-tracking
May 8, 2026
Merged

monkey1sai merged 1 commit into
mainfrom
codex/impl/add-worker-original-filename-tracking

Conversation

@monkey1sai

Copy link
Copy Markdown
Owner

變更摘要

本次讓 _worker 在 source artifact metadata、source index、API response、conversion result 與 callback payload 中保留 original_filename,並讓 _bim-control 在收到 callback 時用原始 IFC 檔名顯示 source artifact name。

修改原因

中文 IFC 檔名經過 _worker 的 on-disk filename sanitize 後,原始檔名會遺失,導致多筆相近 IFC 副本進入轉檔流程後無法從 metadata 或 _bim-control artifact name 回溯實際來源檔名。

主要變更

  • _worker/app/store.py:source metadata、source index、source artifact response 與 conversion result payload 新增 original_filename。
  • _worker/app/main.py:selected dev IFC conversion response 回傳 original_filename。
  • _bim-control/app/main.py:conversion-result callback 帶 original_filename 時,source IFC artifact name 優先使用原檔名,未帶時維持「原始 IFC」fallback。
  • _worker/tests/test_worker_api.py、_worker/tests/test_worker_store.py、_bim-control/tests/test_conversion_results_api.py:補上 original filename、legacy fallback、真實 IFC bytes 多筆 worker adapter,以及 opt-in Kit/HOOPS real USDC smoke 測試。
  • _worker/README.md、docs/contracts/worker-api.md、OpenSpec change artifacts:補上欄位 contract、demo adapter 與 real Kit/HOOPS smoke 的差異說明。

驗證方式

  • openspec validate add-worker-original-filename-tracking
  • _worker: C:\Repos\active\iot\AI-BIM-governance\.venv\Scripts\python.exe -m pytest tests -q -p no:cacheprovider,結果:72 passed, 1 skipped, 1 warning
  • _bim-control: C:\Repos\active\iot\AI-BIM-governance\.venv\Scripts\python.exe -m pytest tests -q -p no:cacheprovider,結果:28 passed, 1 warning
  • Opt-in real USDC smoke: WORKER_RUN_REAL_USDC_SMOKE=1 ... test_real_ifc_files_convert_to_kit_openable_usdc_when_enabled,結果:1 passed,兩筆真實 IFC 透過 Kit/HOOPS 輸出 .usdc,stage inspect prim_count=10872
  • 手動 real conversion smoke:輸出至 C:\tmp\codex-real-usdc-smoke,兩筆 .usdc 各 28,458,344 bytes
  • git diff --cached --check
  • GitNexus detect_changes:worktree staged scope 回報 changed_files=10、risk_level=critical

風險與影響

  • API / callback payload 增加 additive 欄位 original_filename。
  • _bim-control callback 接收端仍以 dict[str, Any] 處理,不會拒絕舊 payload。
  • _worker 預設 conversion adapter 仍是 demo placeholder,不宣稱產出 Kit-ready USDC;真實 Kit/HOOPS smoke 需 WORKER_RUN_REAL_USDC_SMOKE=1 才執行。
  • GitNexus detect_changes 回報 critical,原因是變更觸及 worker artifact/conversion 與 bim-control callback 流程;已用 targeted/full tests 與 real smoke 覆蓋主要風險。

向前相容性

本次新增的 original_filename 是 additive metadata 欄位,不會改變既有 disk object key、artifact id、conversion job id 或 callback endpoint 路徑。

既有 _worker metadata / _index/source_artifacts.json 若沒有 original_filename,讀取端會以 .get("original_filename") 容錯,不會拒絕舊 artifact。

_bim-control 的 conversion-result callback 仍以 dict[str, Any] 接收 payload;當 callback 沒帶 original_filename 時,source IFC artifact name 會 fallback 為既有的「原始 IFC」,因此舊 callback 仍可運作。

回滾方式

  • Revert 本 PR commit。
  • 已寫入 JSON metadata 的 original_filename 是額外欄位;舊程式可忽略,不需要資料 migration 或清理大型檔案。

後續建議

  • 若要讓 _worker 直接產出 Kit-ready USDC,應另開 OpenSpec change,把目前 demo adapter 與 Kit/HOOPS converter adapter 正式分層。
  • 可把 opt-in real converter smoke 納入具備 Kit/HOOPS 環境的 nightly 或手動 CI job。

Copilot AI review requested due to automatic review settings May 8, 2026 04:13
@coderabbitai

coderabbitai Bot commented May 8, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@monkey1sai has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 55 minutes and 41 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b3c87220-8e86-412f-a597-442fc6712c69

📥 Commits

Reviewing files that changed from the base of the PR and between 568f4cf and 3d58075.

📒 Files selected for processing (10)
  • _bim-control/app/main.py
  • _bim-control/tests/test_conversion_results_api.py
  • _worker/README.md
  • _worker/app/main.py
  • _worker/app/store.py
  • _worker/tests/test_worker_api.py
  • _worker/tests/test_worker_store.py
  • docs/contracts/worker-api.md
  • openspec/changes/add-worker-original-filename-tracking/design.md
  • openspec/changes/add-worker-original-filename-tracking/tasks.md
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/impl/add-worker-original-filename-tracking

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@monkey1sai
monkey1sai merged commit e7edbe3 into main May 8, 2026
4 checks passed
@monkey1sai
monkey1sai deleted the codex/impl/add-worker-original-filename-tracking branch May 8, 2026 04:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds end-to-end tracking of the client-provided IFC filename by introducing an additive original_filename field throughout the _worker artifact/conversion pipeline and using it in _bim-control to display the source IFC artifact name from conversion-result callbacks.

Changes:

  • _worker: persist/return original_filename in source metadata, source index, dev-source conversion responses, and conversion results (for callbacks + GET result).
  • _bim-control: when callback payload includes original_filename, prefer it for the source IFC artifact name, with a legacy fallback.
  • Tests + docs: expand coverage for filename preservation and document the updated contract.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
openspec/changes/add-worker-original-filename-tracking/tasks.md Marks the change tasks as completed.
openspec/changes/add-worker-original-filename-tracking/design.md Design rationale/goals for preserving raw filenames as metadata.
docs/contracts/worker-api.md Documents original_filename in responses/results and describes the preservation behavior.
_worker/app/store.py Writes original_filename into metadata, source index, and conversion result payloads.
_worker/app/main.py Adds original_filename to dev IFC source conversion response payload.
_worker/README.md Notes new original_filename behavior and clarifies demo vs real converter smoke tests.
_worker/tests/test_worker_store.py Adds unit test asserting original_filename is stored/returned.
_worker/tests/test_worker_api.py Adds API tests for original_filename propagation + opt-in real conversion smoke.
_bim-control/app/main.py Uses result.get('original_filename') to name the source IFC artifact when present.
_bim-control/tests/test_conversion_results_api.py Adds tests for original_filename name preference and fallback behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread _worker/app/store.py
Comment on lines 58 to 61
source_artifact_id = f"artifact_src_{uuid4().hex[:12]}"
original_filename = request.filename
filename = safe_filename(request.filename)
content = self._content_bytes(request)
Comment on lines +303 to +306
def test_store_create_source_artifact_preserves_original_filename_in_metadata():
store_root = Path(__file__).resolve().parents[1] / "pytest-cache-files-store" / uuid4().hex
store_root.mkdir(parents=True, exist_ok=False)
store = make_store(store_root)
Comment on lines 97 to 98
"result_url": "http://127.0.0.1:8005/api/conversions/conv_.../result",
"readiness_url": "http://127.0.0.1:8005/api/artifact-groups/ag_xxx/readiness"
cursor Bot pushed a commit that referenced this pull request May 8, 2026
主要更新:
- 加入 7 層目標架構(v2 圖):使用者/權限層、Client/Portal層、
  核心業務服務層、Omniverse Runtime/Simulation層、平台能力層、
  DevOps/營運治理層
- 新增 IFC → USD 品質保證管線(7 步驟,標記 step 5 為最重要技術風險點)
- 補入 D. ai-rule-carbon-service 與 E. notification/webhook service
- 補入 Revit Plugin、Admin Console、External API/Webhook Consumer
- 補入 SSO / JWT / RBAC / API Key 認證方式與 5 種使用者角色
- 補入租戶權限階層:公司 - 租戶 - 區 - 棟 - 戶 - 號
- 補入驗證證據分層(runtime-verification-evidence capability):
  non-GPU contract / single Kit GPU / dedicated multi-Kit / stress
- 補入 2026-05-08 端對端驗證結果(控制面已驗證、GPU render 與
  multi-Kit routing 屬 blocked 狀態並已記錄前置條件)
- 補入 PR #17 original_filename 追蹤完成
- KPI 從 6 大擴充為 8 大(新增 IFC-USD 品質 Gate、多租戶+RBAC)
- Phase 5 升級為 Omniverse 平台能力最大化 + AI Service
  涵蓋真實 IFC-USDC converter、RTX/PhysX/MDL、IAQ/HVAC/感測模擬
- Phase 6 補入完整 SaaS 維度
- 9 份 capability spec 對應到各 phase 的進度表

行數:636 - 884 (+530 / -282)

Co-authored-by: monkey1sai <monkey1sai@users.noreply.github.com>
monkey1sai added a commit that referenced this pull request May 11, 2026
* docs: 新增專案開發流程設計文件

- 基於兩張架構圖(PoC → SaaS、目標架構)分析當前進度
- 定義六大開發階段(Phase 0-6)的目標、交付物與驗收標準
- 包含技術架構演進路徑、資料流設計、API 規格
- 新增測試金字塔與品質保證策略(Unit/Integration/E2E/Load tests)
- 提供部署與維運計畫(Local/Staging/Production)
- 定義團隊協作流程(Git branching、PR review checklist)

此文件將作為後續 Phase 1-6 實作的規劃依據。

Co-authored-by: monkey1sai <monkey1sai@users.noreply.github.com>

* docs: 調整專案開發流程文件格式

- 統一 markdown 表格格式
- 調整列表縮排與標點

Co-authored-by: monkey1sai <monkey1sai@users.noreply.github.com>

* docs: 依新版架構圖 v2 重寫專案開發流程

- 對齊新架構:_s3_storage + _conversion-service 已合併為 _worker
- 對應 OpenSpec 7 個 capability spec(worker-artifact-pipeline、
  review-session-request-lifecycle、multi-artifact-kit-routing 等)
- 連結現有 docs/contracts/ 7 份 API 合約
- 反映實際進度:Phase 0/1/2 完成、Phase 3 進行中、Phase 4-6 待規劃
- 補充每階段對應的 PR / commit 證據
- 6 大 KPI 對應架構圖 ④ 區塊
- 加入 Source of Truth 文件對應表與 OpenSpec PR workflow 速查

關鍵變更:
- Phase 0 基線穩定化 (完成)
- Phase 1 _worker 收攏 (完成,PR #11/#14)
- Phase 2 review-session-request 閉環 (完成,PR #13)
- Phase 3 Session lifecycle 多 artifact / 多 instance (進行中)
- Phase 4 高併發平台化 (待規劃)
- Phase 5 Omniverse 平台能力最大化 (待規劃)
- Phase 6 Production & SaaS 營運 (待規劃)

Co-authored-by: monkey1sai <monkey1sai@users.noreply.github.com>

* docs: v3 依新版架構圖 v1+v2 重寫專案開發流程

主要更新:
- 加入 7 層目標架構(v2 圖):使用者/權限層、Client/Portal層、
  核心業務服務層、Omniverse Runtime/Simulation層、平台能力層、
  DevOps/營運治理層
- 新增 IFC → USD 品質保證管線(7 步驟,標記 step 5 為最重要技術風險點)
- 補入 D. ai-rule-carbon-service 與 E. notification/webhook service
- 補入 Revit Plugin、Admin Console、External API/Webhook Consumer
- 補入 SSO / JWT / RBAC / API Key 認證方式與 5 種使用者角色
- 補入租戶權限階層:公司 - 租戶 - 區 - 棟 - 戶 - 號
- 補入驗證證據分層(runtime-verification-evidence capability):
  non-GPU contract / single Kit GPU / dedicated multi-Kit / stress
- 補入 2026-05-08 端對端驗證結果(控制面已驗證、GPU render 與
  multi-Kit routing 屬 blocked 狀態並已記錄前置條件)
- 補入 PR #17 original_filename 追蹤完成
- KPI 從 6 大擴充為 8 大(新增 IFC-USD 品質 Gate、多租戶+RBAC)
- Phase 5 升級為 Omniverse 平台能力最大化 + AI Service
  涵蓋真實 IFC-USDC converter、RTX/PhysX/MDL、IAQ/HVAC/感測模擬
- Phase 6 補入完整 SaaS 維度
- 9 份 capability spec 對應到各 phase 的進度表

行數:636 - 884 (+530 / -282)

Co-authored-by: monkey1sai <monkey1sai@users.noreply.github.com>

* docs(workflow): 對齊 SaaS 路線圖 2026-05(命名/狀態/P2.5 候選/凍結標記)

把 docs/PROJECT_DEVELOPMENT_WORKFLOW.md 與 main 上 docs/plans/AI-BIM-governance-saas-roadmap-2026-05.md
完整對齊,避免兩份文件分歧 source of truth。確立角色分工:workflow v3 = 開發流程入口,
roadmap = 技術決策/OpenSpec 候選權威,互相 cross-reference。

事實校正(A):
- §4.1 Phase 3:runtime 部分 blocked → 在另一分支驗證中(非 environment-blocked)
- §4.2 Dedicated Multi-Kit Routing:blocked → 🟡 在另一分支驗證中
- §4.2 Single Kit GPU Render:補同步 PR #20 (commit 0e94a5b) same-Kit 並行驗證
- §5 風險表:補對應 SaaS 路線圖候選編號

命名對齊(B):
- §6.2 / §6.3 / §7 Phase 5 / §8 / §12.1:ifc-to-usdc-real-converter → worker-real-conversion-quality
- ifc-usd-quality-gate 整合進 #1 KPI(#1 land 後再評估是否拆分獨立 spec)
- gpu-kit-pool-scheduler → streaming-multi-instance-orchestration(業務語意層)
- async-worker-pool-and-redis / object-storage-abstraction:標記為 Phase 4 細項,不開新 spec
- ai-rule-carbon-service-foundation → ai-rule-carbon-result-contract
- rtx-physx-mdl-rendering:Kit base 已內建,啟動 app 加 dependency 即可
- sensor-simulation-overlay:Isaac Sim 獨立部署
- api-gateway-and-rate-limiting:Phase 6 凍結

補入內容(C):
- §7 Phase 4 開頭加 NVIDIA Multi-Kit 並行官方定義 cross-reference(roadmap §11.4)
- §7 Phase 4 / Phase 5 各任務後加採用標籤(✅ / ⚠ / ❌)
- §7 Phase 3 待補清單末加業務語意層 vs runtime infrastructure 層註解
- §10 source of truth 表格加 SaaS 路線圖列
- §12 新增 §12.4 P2.5 候選(#1A presence_layer / #2A OVAS Helm)
- §12 新增 §12.5 P3-frozen 候選(#7/#8/#9)
- 頂部 metadata 加文件分工說明

Phase 6 凍結標記(D):
- §7 Phase 6 標題加 ⏸ 凍結中
- §7 Phase 6 段首加凍結決策說明與解凍程序
- §12.5 列出 #7/#8/#9 候選

Lineage 認知(E):§5 風險表加 row 9(lineage graph query API 尚未實作 → 對應 P1 候選 #3)
候選 #4(F):§12.2 補入 coordinator-session-lifecycle-events-audit

收斂後:
- workflow v3 不重述 roadmap 的決策矩陣、spec id、§11.4 Multi-Kit 定義、硬體 §9
- roadmap 不重述 workflow v3 的 sequence diagram、PR checklist、服務測試命令
- 兩份文件互補不替代,互相 cross-reference

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* docs(workflow): 補 review follow-up(§10.1 / §4.2 / metadata)

依 PR #8 code review 補正:

W1. §10.1 Capability Spec 對應 Phase(行 814+)
- 標題「9 份」→「10 份」
- 加 row `runtime-verification-task-status` Phase 3 ✅
- 表頭上方加「對應 SaaS 路線圖 §1.4 OpenSpec 已歸檔 change → 現行 spec 溯源表」cross-reference
- main 上 openspec/specs/ 實際有 10 個 capability(PR #20 之後新增)

W2. §4.2 驗證證據分層(行 262)
拆「Single Kit GPU Render」一個 row 為 3 個 row,並區分 dedicated 為第 4 個:
- Single Kit GPU Render (real IFC→USDC)            🚫 blocked → 對應 P0 候選 #1
- Single Kit GPU Render (worker-hosted fixture)    ✅ 通過(PR #20 commit `0e94a5b`)
- Same-Kit Concurrent Stream (primary + spectator) ✅ 通過(PR #20 commit `0e94a5b`)
- Dedicated Multi-Kit Routing (≥2 Kit processes)   🟡 在另一分支驗證中
避免一個 cell 混合 blocked 與 passed 兩種狀態。

Suggestions 補正:
- 頂部 metadata(行 7、14)markdown link display text 由 path 字串改為語意化
  「SaaS 路線圖 2026-05」label,避免 raw markdown 中 display 與 href 不一致
- 頂部 metadata(行 11)「9 份 spec」→「10 份 spec」(補 runtime-verification-task-status)
- §10.1 衝突解決順序段(行 831)補一句說明本文件與 SaaS 路線圖屬 OpenSpec 補充
  planning artifact,不在優先順序內覆蓋 openspec/specs/ 權威

對應 PR #8 review (#8 (comment))
的 Warnings + Suggestions。

git diff --check: ✓ no whitespace issues

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: monkey1sai <monkey1sai@users.noreply.github.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
monkey1sai added a commit that referenced this pull request Jun 2, 2026
harden-web-viewer-test-resilience: #17 vitest+jsdom 骨架(34 test) / #27 timer / #8 terminate(false) / #28 poll 上限 / #15 spectator binding / #16 spectator_ready gate / #18 env boundary / #32 GFN 動態載入。雙層 review(opus 5-lens + Copilot/Codex/CodeRabbit)。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants