Skip to content

fix(persona): back up COS persona before regeneration - #657

Open
RerankerGuo wants to merge 1 commit into
TencentCloud:feat/server_teamfrom
RerankerGuo:fix/persona-storage-backup
Open

fix(persona): back up COS persona before regeneration#657
RerankerGuo wants to merge 1 commit into
TencentCloud:feat/server_teamfrom
RerankerGuo:fix/persona-storage-backup

Conversation

@RerankerGuo

Copy link
Copy Markdown

Description | 描述

Restore the L3 persona backup guarantee in service/COS mode.

PersonaGenerator backs up the current persona.md before allowing the LLM tool runner to overwrite it. The filesystem path retained the configured backups, but the StorageAdapter path explicitly skipped BackupManager, leaving COS-backed instances with no prior persona copy when regeneration failed or produced bad content.

Changes:

  • Extend BackupManager.backupFile() with an optional StorageAdapter mode.
  • Use object-key-safe POSIX paths for backup destinations.
  • Preserve object content type and metadata through StorageAdapter.copyFile().
  • Apply the existing timestamp/tag naming and maxKeep retention semantics by listing and pruning old backup objects best-effort.
  • Route PersonaGenerator through the same backup call in both filesystem and StorageAdapter modes.
  • Add focused tests for retaining the newest two persona backups and treating a missing source object as a no-op.

Scope boundary:

  • Directory backup/restore for scene blocks is unchanged.
  • This PR creates rollback material but does not introduce automatic persona restore policy.
  • No storage schema, LLM prompt, checkpoint, or API changes.

Related Issue | 关联 Issue

No existing issue. Implements the explicit StorageAdapter backup TODO in MemoryCore/src/core/persona/persona-generator.ts discovered during default-branch maintenance.

Change Type | 修改类型

  • Bug fix | Bug 修复
  • New feature | 新功能
  • Documentation update | 文档更新
  • Code optimization | 代码优化

Self-test Checklist | 自测清单

  • Verified locally | 本地验证通过
  • No existing features affected | 无影响现有功能

Additional Notes | 其他说明

Validation in MemoryCore (Node v26.5.0, npm v11.17.0):

npm test -- src/utils/backup.test.ts
# 1 file, 2 tests passed

npm run build:plugin
npm run build:migrate-sqlite-to-vdb
npm run build:export-tencent-vdb
npm run build:read-local-memory
# all passed

git diff --check
# passed

The branch-wide npm run build still reaches the unrelated missing scripts/seed-v2/tsconfig.json baseline target. PR #652 removes that incomplete target; this PR is otherwise independent and can be reviewed separately.

Extend BackupManager file backups to StorageAdapter object keys, preserving object metadata and applying the existing maxKeep retention policy.

Use the same backup path before COS-backed persona regeneration and add focused tests for backup rotation and missing-source behavior.

Signed-off-by: RerankerGuo <121015044+RerankerGuo@users.noreply.github.com>
@Maxwell-Code07

Copy link
Copy Markdown
Collaborator

Thank you for your interest and contributions! We will review your code and get back to you as soon as possible!

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