Project Memory Guard
Validate every memory write against project and writeback rules. Prevent contamination and schema drift.
Input
Required fields:
- -
raw_content — the content attempting to enter project memory - INLINECODE1 — the project being written to
- INLINECODE2 — type of memory: note, finding, task, summary, record, etc.
- INLINECODE3 — where this came from: user message, paper, tool output, etc.
- INLINECODE4 — ISO-8601 timestamp of when the content was created
- INLINECODE5 — confidence score 0.0–1.0 for project assignment
Output Schema
CODEBLOCK0
Hard Rules
| Condition | Decision |
|---|
| Missing INLINECODE6 | reject — never enter formal project memory |
| Missing INLINECODE7 |
reject — no formal writeback |
| Missing
timestamp |
reject — no formal writeback |
| Confidence < 0.6 |
reroute to inbox |
| Cross-project ambiguity |
reroute to inbox or cleanup mode |
| All fields present + high confidence |
accept |
Reroute Destinations
- -
inbox — unverified content waiting for manual review - INLINECODE10 — ambiguous content needing disambiguation
- Specific project_id — when rerouting to a known project
Normalization
When decision is accept or reroute, normalize the record:
- - Strip identifying metadata not in schema
- Add
validated_at timestamp - Add
guard_version = "1.0" - Preserve original
raw_content in INLINECODE17
Failure Handling
If uncertain about any field:
- - Do not guess projectid or memorytype
- Set
decision = "reroute" with INLINECODE19 - List
missing_fields explicitly - Explain in INLINECODE21
Never force acceptance when validation fails.
项目记忆守卫
根据项目和回写规则验证每次内存写入。防止污染和模式漂移。
输入
必填字段:
- - rawcontent — 试图进入项目记忆的内容
- candidateprojectid — 正在写入的项目
- memorytype — 记忆类型:笔记、发现、任务、摘要、记录等
- source — 来源:用户消息、论文、工具输出等
- timestamp — 内容创建时的ISO-8601时间戳
- confidence — 项目分配的置信度评分0.0–1.0
输出模式
decision: accept | reject | reroute
destination: string | null # project_id 或 inbox 或 null
normalized_record: object | null # 接受/重路由后的清理记录
contamination_risk: none | low | medium | high
missing_fields: string[] | null
reason: string
硬性规则
| 条件 | 决策 |
|---|
| 缺少 projectid | 拒绝 — 不得进入正式项目记忆 |
| 缺少 memorytype |
拒绝 — 不得正式回写 |
| 缺少 timestamp |
拒绝 — 不得正式回写 |
| 置信度 < 0.6 |
重路由 至收件箱 |
| 跨项目歧义 |
重路由 至收件箱或清理模式 |
| 所有字段齐全 + 高置信度 |
接受 |
重路由目标
- - inbox — 等待人工审核的未验证内容
- cleanup — 需要消歧的歧义内容
- 特定project_id — 重路由至已知项目时
标准化
当 decision 为 accept 或 reroute 时,对记录进行标准化:
- - 剥离不在模式中的标识性元数据
- 添加 validatedat 时间戳
- 添加 guardversion = 1.0
- 在 normalizedrecord.raw 中保留原始 rawcontent
失败处理
若对任何字段不确定:
- - 不要猜测projectid或memorytype
- 设置 decision = reroute,destination = inbox
- 明确列出 missing_fields
- 在 reason 中说明
验证失败时绝不强制接受。