Repository navigation
v7.13.9 测试不再能写真实数据;被污染的中枢能体检、能修 - #16
Merged
Merged
Conversation
…gnosed and repaired 2026-09-13 incident: tests wrote 107 synthetic memories into the production ID hub (not in the journal), real memories were overwritten, and the agent repeated fabricated facts. Reproduced on v7.13.8: running the suite with NEXSANDBASE_HOME pointing at (or defaulting to) the real data dir appends synthetic records to the real journal. Prevention: - tests/conftest.py forces a per-session temp data dir before any import - core/prodguard.py: in pytest processes, opening a DB, appending to a journal, or resolving the data dir outside the temp dir raises (override: NYX_ALLOW_PROD_DB=1); production processes are unaffected - tests/test_prod_guard.py replays the incident with and without conftest Repair (python3 -m nexsandglass.repair, core/forensics.py): - read-only diagnosis by content identity: aligned / misplaced / overwritten / missing / synthetic orphans / stray tombstones (incl. false leaks) / unfinished erasures; counts and seq ranges only - --apply: backup, then rewrite the hub to match the journal under the journal lock; keep mem_ids and bound provenance; never resurrect forgotten memories; remove synthetic derived data by mem_id (triples, engram, entities, vectors) and reopen real beliefs truncated by synthetic facts; journal untouched unless --finish-erasures - erasure selector: sender/senders (narrows when combined) - doctor points to the repair tool and warns against forgetting by seq - tests/test_incident_0913.py stages the incident and verifies the repair Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019ZZeQFn5F6mEbmX8vPsf4g
…the lock - Redacted journal lines are matched to deleted hub rows by their mem= marker before any positional fallback, so a legacy (marker-less) line can no longer take the row another line's marker names; legacy lines match by (ts, sender) before seq. Quarantine restore keeps working after a repair. - Text that contains \r reads back from the journal as \n; compare normalized text so such memories are not treated as synthetic orphans. - Take the backup while holding the journal lock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019ZZeQFn5F6mEbmX8vPsf4g
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
2026-09-13 生产事故:测试把 107 条合成记忆(sender=golden / test / e2e / mcp)写进了生产 ID 中枢(日志里没有),真实记忆被覆盖,agent 把「用户喜欢喝拿铁」「预算 2000 欧」当成真记忆说了出来。
doctor三项红:hub_vs_journal、fts_index、erasure_integrity。在 v7.13.8 上复现:
NEXSANDBASE_HOME指着真实数据目录(或不设)时跑测试,真实日志里会多出合成记录。防复发
tests/conftest.py:测试会话一开始、任何模块 import 之前,把数据目录无条件改到临时目录core/prodguard.py:pytest 进程里,开临时目录以外的库、往那里的日志追加、把数据目录解析到那里,都直接报错。生产进程不受影响(判据是PYTEST_CURRENT_TEST/PYTEST_VERSION;单凭_pytest已加载不算)。豁免:NYX_ALLOW_PROD_DB=1tests/test_prod_guard.py:指着一个「生产目录」真跑一个会写合成记忆的测试文件,带 conftest 与--noconftest各一次,「生产目录」必须一个字节不变修复工具
python3 -m nexsandglass.repair(core/forensics.py)按内容身份(
mem_id= 原文哈希)逐条核对,不按 seq:--apply:mem_id与写入时绑定的来源都保留mem=标记认,隔离区还原仍然有效mem_id撤下:信念三元组、engram、实体、向量--finish-erasures:在日志里抹掉没做完的遗忘,只动身份已核实的那几行--forget-senders:对齐之后,把这些发送者的记录送进隔离区另外:
erasure._select支持sender/senders;和别的条件一起用时是收窄,不会扩大选中范围doctor这三项红时会提示先体检,并提醒不要按 seq 去forget验证
tests/test_incident_0913.py(12 项):原样造出事故现场,验收以下各项:\r的记忆不被误撤doctor全绿🤖 Generated with Claude Code
https://claude.ai/code/session_019ZZeQFn5F6mEbmX8vPsf4g