Skip to content

feat(consolidation): resolution=auto_v1(规格 C) - #139

Merged
leafliber merged 6 commits into
mainfrom
feat/consolidation-auto-v1
Nov 11, 2026
Merged

leafliber merged 6 commits into
mainfrom
feat/consolidation-auto-v1

Conversation

@leafliber

Copy link
Copy Markdown
Member

按 SPEC-C 实现整理 resolution=auto_v1。默认值不变:新库和现有库仍是 report_only_v1,未知或旧值归一成 report_only_v1,运行快照写入 consolidation_runs.settings_json。未调用真实模型。

实现

  • C1 互有细节:新提示词写合并正文;代码核对双方独有片段、数字(含中文数字)、否定(带后一个字的作用范围)、限定词、主体[...]、时间表达、实体名(主体名/别名、拉丁标识、书名号等、jieba nr/ns/nt/nz)、内容词不超出双方并集(只放行 并、且、并且、同时、以及、另外、还)、说话人/立场/涉及人/event_time/可见范围、未保护。任一失败记 mutual_merge_rejected 和固定原因,不写建议。通过后存续记忆(preferred_keep_id)写新正文、修订号+1、清向量,另一条走既有合并路径。
  • C2 矛盾:模型只输出 relation JSON,代码按规格第 4 节核对,失败一律 undecided。supersedes:遗忘、推断档、superseded 标注;reported_vs_self:转述降一档并标 disputed;coexist:只记录;undecided:两条标 disputed。
  • C3 依赖:模型只给 independent_support_ids;src/iris/evidence_trace.py 追溯原始消息并去重,只到 self_output 的不算,0 条时遗忘并标 insufficient_support。M2 扣减不变。
  • C4:auto_v1 下 blocked 只含仍未解决的 undecided 矛盾;invalid_details、失败和规划失败只影响本对。report_only 的阻塞逻辑不变。
  • 保护:工作开始时人工编辑或置顶,记 protected,不调用模型。
  • 补1/补2:evidence_trace 是共用模块,persona._trace 未改。memory_ops.superseded_forgotten;学习的 confirm_once 遇到“已被替代且遗忘”只追加来源,弃项原因 superseded_no_restore;管理员恢复或撤销时清除标注。
  • 撤销:POST /admin/api/maintenance/{run}/consolidation/{work}/undo(管理员会话、CSRF、expected_revision)。逐字段核对,有变化返回 409,不部分撤销。
  • 迁移 037:consolidation_undo_guard,并重建 consolidation_no_resurrection 触发器。被并入的占位只能在撤销事务内恢复。
  • 界面:设置页增加“处理方式”下拉框;整理报告增加“自主处理结果”和“撤销此次处理”按钮。前端构建产物一起提交。
  • 评测:run.py --resolution auto_v1(默认语料 consolidation_v2.json,支持 --corpus/--out,按 entries 设置可见范围)。auto_score.py 用代码计算误处理、正确处理、保护、写回损坏和调用计数。合并丢细节导出外部材料,评分说明是新文件 merge_details_scoring_auto_v1.md,待规划者审查后冻结。

提示词(新文件,旧文件保留)SHA-256:

  • consolidation_conflict_auto_v1.md 249a1a2c4a60a6088ca027f61052740c92eed512ccdaec35d2a13e6625ee825e
  • consolidation_dependency_auto_v1.md e3605ac6cb21118f7e1cac81af40e3870c2e6fcb2c7a0977bd4c3801adb22466
  • consolidation_mutual_merge_v1.md 6adee5e4718c91c1467d0a9c7794c5da6ff48bb037ee324e6d22ce5630b656c4
  • 评分说明 merge_details_scoring_auto_v1.md 5624b7fce5a3e5ebd7a1bcfa2935a92c32547986e0859a06bfad81d81392866f

选了保守做法、需规划者确认的地方

  1. 入口画像:互有细节合并拒绝(entry_profile_kind);auto_v1 下入口画像的普通合并不提供撤销。原因:合并触发器单向复制回执和准入状态,撤销无法完整复原。
  2. 既有排除规则仍拦截互有细节合并:merge_exclusion(数字不兼容、一侧有否定等)命中时记 merge_not_allowed,不起草。公开集 CV002 c/d 标为 merge,但 d 含“不修改”,按现有排除规则会保持两条(计为未识别,不计误处理)。是否放宽需要规划者决定。
  3. C3 追溯:不经过失效依据(losses 与 target 本身)和非 active 记忆,否则 CV011/CV022 的同源链标注无法满足。同一运行内依赖链上较早的自动处理改动了祖先记忆时,下游依赖工作不判为过期,规则在写回时重读当前状态;外部写入照常判为冲突、跳过。
  4. C3 校验失败(模型给出材料外或已失效的 ID):按 undecided 只记录、不改动,不加 disputed(第 4 节的 undecided 规则写在 C2 下)。
  5. reported_vs_self:按立场识别哪条是转述,不依赖模型给的 old/new 顺序,但两个 ID 都必须属于这一对。supersedes 的“旧记忆全部来源消息”包含派生链上的来源。
  6. 标注正文:模型 reason 先过现有引用核对,不通过就改写入固定文本。
  7. 撤销范围:auto_v1 下所有合并(含普通 broad 合并)都可撤销。互有细节合并后,存续记忆下游依赖的 source_revision 一并前移,避免补细节被当成“更正”;撤销时还原。存续记忆为 active 时保留合并后的衰减量,其余字段严格核对。
  8. 计分口径:误处理率的分母 = 标注项 + 意外动作;只差标注、未写分数/生命周期的(例如该 supersedes 却 undecided)计未识别,不计误处理;保护还要求没有新增标注。请规划者审查。

验证

  • 新测试 tests/test_consolidation_auto.py(各规则通过/失败两个方向、中断重跑、修订号冲突、撤销 409、跨对互不连带、设置、补2)和 tests/test_consolidation_auto_eval.py(公开集 24 例假模型运行、计分、材料完整性、双轮细节判分)。按标注作答的假模型下,公开集 20 个矛盾和 14 个依赖全部按规则执行正确。这只说明规则与标注一致,不代表质量结果。
  • 全量测试:3.13 和 3.12 各 5641 passed、2 failed。
    • tests/test_media_retention.py::test_old_backup_without_cleanup_columns_or_manifest_imports:该测试假设最新迁移是 036,已在本 PR 中补上回退 037,两个版本单独重跑均 63 passed。
    • tests/test_persona_streaming.py::test_future_deadline_closes_stream_worker_and_preserves_shared_client:已有问题,origin/main 上同样失败,与本 PR 无关。
  • npm test、npm run build、uv build 通过。

… and undo

Model gives judgments and mutual-merge drafts only; scores, lifecycle and
annotations are written by code per spec C:
- C1 mutual details: drafted body passes deterministic checks (unique
  fragments, numbers, negation scopes, qualifiers, subject mentions, time
  expressions, entities, no new content words) or both are kept with
  outcome=mutual_merge_rejected and a fixed reason.
- C2 contradictions: supersedes / reported_vs_self / coexist / undecided,
  any failed check is undecided; role speech alone never decides.
- C3 dependencies: independent original messages traced through
  evidence_trace (no lost sources, no self_output); 0 forgets.
- C4 only an unresolved contradiction blocks merges of shared memories.
- Protected (pinned / manual edit) work is recorded without model calls.
- Undo endpoint with expected_revision; 409 on any later change. Migration
  037 lets only an undo transaction restore a merge placeholder.
- Superseded forgotten memories are not revived by reconfirmation.
- Settings and report UI; default stays report_only_v1.
- evals: auto_v1 run on consolidation_v2 or --corpus, deterministic
  auto_score.py, external merge-detail materials.
- Annotations are keyed per action, so a cleared earlier annotation never
  absorbs a new one and undo clears only its own action's annotations.
- Mutual-merge drafts must use exactly the union of both bodies' words,
  function words included (prompt mutual_merge_v2 says so).
- Undo re-points dependents of a restored body to its new revision, cancels
  pending dependency losses the action caused and refunds applied ones.
- Undo restores retention by difference for forgotten memories as well.
- C3 counts the target's own non-role messages as independent support.
- adjust_retention never restores a superseded forgotten memory; only an
  explicit restore or undo clears the annotation.
- C4: in auto mode a classified but unfinished contradiction blocks merges
  of its shared memories.
- auto_score: unprocessed items are never correct and are reported by
  category; rewritten merges are listed and checked deterministically.
…cay report

- Pairs with a forgotten member that has an uncleared superseded annotation
  are skipped at planning without a model call (broad, mutual and
  report_only suggestions), recorded once per run as skip:superseded_member.
  Restore or undo changes the snapshot and puts the pair back.
- Daily decay reports restored only when the memory actually became active;
  a blocked restore is a skipped item (superseded), not a daily change.
consolidation_annotations.automatic (migration 037, default 0) marks
annotations written after auto_v1 rules checked and executed a judgment.
The restore guard, the superseded_member planning skip and the restore
clearing only consider those; report_only model suggestions keep their
existing behaviour.
- A model reason never blocks a checked conclusion: if it fails grounding
  it is archived and the report uses text generated from verified fields
  (pair classification, ordinary and mutual merges, conflicts,
  dependencies). Draft rejections keep their specific codes.
- Textual IDs that name exactly one visible ID are converted; protocol
  slips (type, missing keep_id, extra fields, unknown IDs) get the one
  mechanical repair and are re-authorized. Nothing is guessed.
- auto_v1 classification uses consolidation_pair_auto_v1.md; report_only
  keeps pair_v3.
- Merge fragments that are not body substrings get one bounded correction;
  a conflict is no longer turned into uncertain by the fragment check.
- Related pairs kept apart by visibility are recorded at planning.
- auto_score: recorded exclusions count for keep_both, coexist judged by
  state (no new disputed/superseded), label and work counts reported.
@leafliber
leafliber merged commit 7acc974 into main Nov 11, 2026
1 check passed
@leafliber
leafliber deleted the feat/consolidation-auto-v1 branch November 11, 2026 05:10
leafliber added a commit that referenced this pull request Nov 11, 2026
- DECISIONS 新增 2026-11-11 条目:#139 门槛结果与审查决定、#140 默认值与迁移判定、#133 合并理由与 PE-23、G/I 规格要点、隐藏集运行授权。
- 设计文档 10.2、12.5、16.1 改为门槛已通过的措辞,16.1 第 7 项改为按 1、3、7 天重试。
- AGENTS 补充当前进度。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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