Skip to content

Persist v0.2.0

Choose a tag to compare

@github-actions github-actions released this 28 May 03:18

Persist v0.2.0

概述

Persist v0.2.0 — Memory-aware Execution Runtime

在 v0.1 Stateful Chat Runtime 上引入 Summary-based Runtime Continuity Memory:bounded-context injection、持久化 continuity artifact、post-execution summary generation、可审计 replay。

Persist is fundamentally an execution runtime with persistence and replayability.

Added

  • Monorepo 结构(pnpm workspaces,在 v0.1 基础上扩展)

    • @persist/shared — 唯一契约源(Session / Message / RuntimeChunk / MemoryEntry / MemoryInjectionSnapshot / Ports)
    • @persist/memory — orchestration / policy(resolveInjectionplanMemoryGeneration 等纯函数,无 I/O)
    • @persist/runtime — persistence-aware executeChat(injection → provider → generation pipeline)
    • @persist/providerQwenProvider + LlmSummaryMemoryGenerator(generation 仅 provider.chat,不经 executeChat
    • @persist/storage — SQLite + Drizzle;SqliteSessionStore / SqliteMemoryStore / SqliteInjectionSnapshotStore
    • @persist/api — Fastify + SSE transport adapter
    • @persist/web — Next.js UI shell(含只读 Runtime Continuity Memory 面板)
  • Runtime Continuity Memory(v0.2 核心)

    • Summary-based continuity artifact(MemoryEntrytype: 'summary'
    • Bounded Context Execution:Active Summary(system)+ 最近 K 条 messages(默认 K=6)
    • Post-execution generation:done(completed) 且 message 数 ≥ 阈值(默认 8)后生成 / 更新 summary
    • replaceActiveSummary 原子 supersede(IC-MEM-03)
    • MemoryInjectionSnapshot:审计「模型当时看到的 resolvedMessages
  • RuntimeChunk 事件流(Runtime-native,非 OpenAI delta 直通)

    • Execution:message-start / text-delta / message-end / usage / error / done
    • Observability(不驱动 message lifecycle):memory-injected / memory-generated
  • REST API(v0.2)

    • POST /api/sessions — 创建 Session
    • GET /api/sessions/:id — 获取 Session 与消息
    • POST /api/sessions/:id/messages — 流式 Chat(SSE)
    • GET /api/sessions/:id/replay — 历史 reconstruction(含 memoriesinjectionSnapshots;不重新调用 LLM)
    • GET /api/sessions/:id/memories — 列出 Session 内 continuity artifacts(inspect)
  • 持久化模型

    • Session:userId nullable、metadata JSON
    • Message:Runtime artifact(completionStateproviderMetadata、timestamps)
    • MemoryEntry:continuity summary(supersededBy 保留历史,不删除)
    • MemoryInjectionSnapshot:triggerMessageIdresolvedMessagesinjectedMemoryIds
  • 测试 — Vitest(32 tests):shared memory contracts、memory policy、runtime injection/generation、storage supersede、provider generator

  • CI/CD

    • CI:Prettier → ESLint → typecheck → test → build
    • CD:main 分支构建产物(Actions Artifacts)
    • Release:tag v*.*.* 触发 GitHub Release(runtime / api / web 构建包)

Architecture

  • Core(shared / memory / runtime)与 Integration(provider / storage / api)分层
  • runtime 仅依赖 ChatProvider 接口,禁止绑定具体 Provider
  • provider 不依赖 runtime(Vendor Protocol Adaptation only)
  • memory 包无 HTTP / SQLite / Provider 实现依赖(NFR-MEM-03)
  • Memory = Runtime Continuity Artifact(非 RAG / 非 chat history UI state)
  • Provider-neutral:ChatRequest 未扩展;injection 在 runtime + memory 组装
  • Persistence-first:injection snapshot、message stream、memory generation 均嵌入 executeChat 生命周期
  • Per-session only;无 cross-session continuity

明确未包含(后续 Phase)

  • Cross-session / User Profile Memory(需 identity / Auth)
  • 即时 fact 写入 API(如 POST /summarize 绕过 runtime)
  • Tool Runtime(MCP)
  • Planning Runtime
  • Auth / 多用户 / Vector DB / RAG / Agent Loop / Event Bus

快速开始

pnpm install
# 在项目根目录创建 .env(勿提交),配置 DASHSCOPE_API_KEY 等
pnpm -r run build
pnpm dev          # API :3001
pnpm dev:web      # Web :3000

同 Session 内累计约 8 条消息 后,Web 右侧 Runtime Continuity Memory 面板将出现 Active summary(跨 Session 不继承,见 Architecture)。

贡献者

  • lens68