Skip to content

fix(data): preserve historical metadata integrity#194

Merged
afc163 merged 3 commits into
mainfrom
codex/fix-historical-metadata-integrity
Jul 13, 2026
Merged

fix(data): preserve historical metadata integrity#194
afc163 merged 3 commits into
mainfrom
codex/fix-historical-metadata-integrity

Conversation

@afc163

@afc163 afc163 commented Jul 10, 2026

Copy link
Copy Markdown
Member

Summary

  • Keep historical component props sourced from their own snapshot/docs instead of copying from the latest major snapshot.
  • Clone resolved components before runtime backfills so resolving one command cannot mutate cached historical metadata used by later commands.

Verification

  • npm run build
  • npm run typecheck
  • Focused loader tests — 96 passed
  • npm audit --json — 0 vulnerabilities on the base dependency set
  • git diff --check

The default parallel full suite was also run; two existing lint --diff tests intermittently exceeded the 5-second test timeout under load. Both exact tests pass in isolation, and no lint files are changed in this PR.

Summary by CodeRabbit

  • 功能改进

    • 组件历史 API 数据仅使用所选版本快照及自身文档,避免从主版本回填 props 或子组件属性。
    • 缺失英文或中文描述时,仍可从最新主版本补全。
    • 解析组件时使用独立副本,避免修改已缓存的版本数据。
  • 测试

    • 更新组件解析与数据回填场景,验证描述补全、属性保留及缓存完整性。

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b5ba9dd4-acb9-45d6-8e6e-5fdbcf402dc0

📥 Commits

Reviewing files that changed from the base of the PR and between 19b04a7 and 53711e8.

📒 Files selected for processing (3)
  • spec.md
  • src/__tests__/version-loader.test.ts
  • src/data/loader.ts
💤 Files with no reviewable changes (2)
  • src/tests/version-loader.test.ts
  • src/data/loader.ts

📝 Walkthrough

Walkthrough

本次变更收紧组件快照回填规则:major 快照仅补充缺失的英文或中文描述,不再回填 props 或子组件 props;组件解析先浅拷贝缓存对象,并新增相应测试与数据层规范说明。

Changes

组件快照解析与回填

Layer / File(s) Summary
组件解析与回填策略
src/data/loader.ts, spec.md
resolveComponent 基于缓存组件浅拷贝执行解析;major 快照仅在描述缺失时补回描述字段,props 数据不再回退。
解析行为测试覆盖
src/__tests__/loader-internal.test.ts, src/__tests__/version-loader.test.ts
测试覆盖仅回填描述、历史文档解析 props、返回对象独立性及缓存快照不变。

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant resolveComponent
  participant ComponentStore
  participant ComponentDoc
  participant MajorSnapshot
  Caller->>resolveComponent: 请求解析组件
  resolveComponent->>ComponentStore: 查找缓存组件
  ComponentStore-->>resolveComponent: 返回 storedComp
  resolveComponent->>resolveComponent: 创建浅拷贝 comp
  resolveComponent->>ComponentDoc: 解析组件文档 API
  ComponentDoc-->>resolveComponent: 返回组件描述与 props
  resolveComponent->>MajorSnapshot: 描述缺失时读取描述
  MajorSnapshot-->>resolveComponent: 返回描述字段
  resolveComponent-->>Caller: 返回解析后的组件
Loading

Possibly related PRs

Poem

小兔挥爪改回填,
描述补上不乱添。
props 留在原快照,
浅拷贝里安心跑。
缓存清白,测试笑!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了此次修复的核心:保护历史组件元数据不被运行时回填污染。
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-historical-metadata-integrity

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.

@github-actions

github-actions Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

📦 Package Size Report

Metric Size Diff
Packed 25.69 MB -0.05 KB (-0.0%)
Unpacked 26.77 MB -0.37 KB (-0.0%)

@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.69%. Comparing base (abbbe31) to head (53711e8).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #194      +/-   ##
==========================================
- Coverage   99.69%   99.69%   -0.01%     
==========================================
  Files          40       40              
  Lines        2603     2598       -5     
  Branches      803      803              
==========================================
- Hits         2595     2590       -5     
  Misses          8        8              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request refactors the metadata loading and changelog generation logic. Key changes include limiting the metadata cache to 32 entries with an eviction policy, removing major-version API data backfilling (restricting backfills to descriptions), updating semver comparison to correctly handle prerelease identifiers, and removing speculative rename guessing for removed properties. The reviewer feedback highlights three main improvement opportunities: cleaning up dead code (replacement property and printing logic) left over from removing speculative renames, replacing the while loop with an if statement in the cache eviction logic for better readability, and performing a deeper clone of storedComp in resolveComponent to prevent nested arrays and objects from mutating the shared cache.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/commands/changelog.ts Outdated
Comment thread src/data/loader.ts Outdated
Comment thread src/data/loader.ts
@afc163 afc163 merged commit 45d0c31 into main Jul 13, 2026
11 checks passed
@afc163 afc163 deleted the codex/fix-historical-metadata-integrity branch July 13, 2026 06:47
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.

1 participant