文档核心概念浅快照与脱敏 (Shallow Snapshots and Redaction)

浅快照(Shallow Snapshots)

快速概览

浅快照 类似于 Git 的浅克隆:保留当前状态,同时裁剪旧的历史。它是满足隐私合规、优化存储与提升性能的关键工具。

基本用法

const  = new ();
// ... 这里经历了大量编辑历史 ...
 
// 常规快照 —— 包含完整历史
const  = .({ : "snapshot" });
 
// 浅快照 —— 裁剪后的历史
const  = .({
  : "shallow-snapshot",
  : .(),
});
 
// 通常可以缩小 70%~90%
.(`Size reduction: ${100 - (. / . * 100)}%`);

内容删除(Redaction)

const  = new ();
const  = .("content");
 
// 写入敏感数据
.(0, "SSN: 123-45-6789. ");
.(18, "Public info.");
 
// 删除敏感部分
.(0, 18);
 
// 生成干净的快照
const  = .({
  : "shallow-snapshot",
  : .(),
});
// 历史中的敏感数据被永久移除

同步限制

⚠️ 注意:只有在浅快照时间点之后拥有版本的节点才能继续同步。

常见模式

归档并裁剪

async function (: ) {
  // 1. 归档完整历史
  const  = .({ : "snapshot" });
  await ();
  
  // 2. 为活跃使用生成浅快照
  const  = .({
    : "shallow-snapshot",
    : .(),
  });
  
  return ;
}
 
async function (: ) {
  // 保存到冷存储
}

隐私优先的设计

class  {
  constructor(private : ) {}
  
  async () {
    // 删除敏感内容
    this..("private").(0, this..("private").);
    
    // 生成干净的快照
    return this..({
      : "shallow-snapshot",
      : this..(),
    });
  }
}

最佳实践

  • 裁剪前先协调:确保所有节点已完成同步
  • 删除前先归档:如需保留完整历史,先做备份

相关文档