tetra-scar
What this does
Your agent keeps making the same mistakes. tetra-scar gives it a scar layer — immutable records of past failures that are checked before every action, without calling the LLM.
Two-layer memory:
- - Scar layer (immutable): "What broke and what must never happen again." Cannot be deleted.
- Narrative layer (mutable): "What was done and who benefited." Overwritable.
Plus a reflex arc — pattern-matching against scars that fires before the LLM even sees the task. If a proposed action matches a past failure pattern, it's blocked instantly.
Quick start
After any failure, record a scar:
CODEBLOCK0
Before any action, check the reflex:
CODEBLOCK1
After any success, record the narrative:
CODEBLOCK2
How the reflex arc works
The reflex arc extracts keywords from each scar's never_again field:
- - English words (3+ characters)
- Japanese kanji/katakana units (2+ characters)
When a task description matches 40%+ of a scar's keywords (minimum 2), it's blocked.
No LLM judgment. No API calls. No latency. Pure pattern matching.
The 4-axis check (tetra-check)
For deeper validation, tetra-check evaluates a task against 4 axes:
- 1. Emotion axis: Does the task have motivation? (non-empty description)
- Action axis: Is it concrete? (contains action verbs)
- Life axis: Does it collide with any scar? (reflex arc)
- Ethics axis: Does it involve dangerous operations? (rm -rf, DROP TABLE, etc.)
All 4 must pass. Any failure rejects the task with a specific reason.
CODEBLOCK3
File format
JSONL (one JSON object per line). Human-readable. Git-friendly.
scars.jsonl: {"id":"scar_001","what_broke":"...","never_again":"...","created_at":"..."}
narrative.jsonl: INLINECODE3
Integration
CODEBLOCK4
Philosophy
Built by Tetra Genesis (B Button Corp, Nagoya, Japan).
Agents that can't remember their failures are doomed to repeat them.
Scars are not bugs — they're the immune system.
Every cycle must answer: "Who did this make happy?"
tetra-scar
功能说明
你的智能体总是重复同样的错误。tetra-scar 为其提供了一层疤痕层——即过去失败的不可变记录,在每次行动前进行检查,无需调用大语言模型。
双层记忆:
- - 疤痕层(不可变):什么出了问题,什么绝对不能再次发生。不可删除。
- 叙事层(可变):做了什么,谁从中受益。可覆写。
此外还有一个反射弧——在智能体看到任务之前,就会对疤痕进行模式匹配。如果拟议的行动与过去的失败模式匹配,将立即被阻止。
快速上手
任何失败后,记录一条疤痕:
python3 tetra_scar.py scar-add \
--what-broke 未运行测试就部署到生产环境 \
--never-again 任何部署前必须运行完整测试套件
任何行动前,检查反射弧:
python3 tetra_scar.py reflex-check --task 将最新变更部署到生产环境
输出:已阻止——疤痕冲突:任何部署前必须运行完整测试套件...
任何成功后,记录叙事:
python3 tetra_scar.py narrate --what 在完整测试通过后部署了v2.1 --who 用户
反射弧工作原理
反射弧从每条疤痕的 never_again 字段中提取关键词:
- - 英文单词(3个字符以上)
- 日文汉字/片假名单元(2个字符以上)
当任务描述与疤痕关键词的匹配度达到40%以上(至少2个关键词)时,该任务将被阻止。
无需大语言模型判断。无需API调用。零延迟。纯模式匹配。
四轴检查(tetra-check)
对于更深入的验证,tetra-check 从四个维度评估任务:
- 1. 情感轴:任务是否有动机?(非空描述)
- 行动轴:是否具体?(包含动作动词)
- 生命轴:是否与任何疤痕冲突?(反射弧)
- 伦理轴:是否涉及危险操作?(rm -rf、DROP TABLE等)
四项必须全部通过。任何一项失败都会以具体原因拒绝该任务。
python3 tetra_scar.py tetra-check --task 重构认证模块
输出:已批准——所有四轴均通过
文件格式
JSONL(每行一个JSON对象)。人类可读。Git友好。
scars.jsonl:{id:scar001,whatbroke:...,neveragain:...,createdat:...}
narrative.jsonl:{id:narr001,what:...,whobenefited:用户,created_at:...}
集成
python
from tetrascar import reflexcheck, readscars, writescar, write_narrative
执行前
scars = read_scars()
block = reflex
check(taskdescription, scars)
if block:
print(f已阻止:{block})
else:
# 执行任务...
if failed:
write_scar(什么出了问题, 什么绝对不能再次发生)
else:
write_narrative(做了什么, 谁从中受益)
设计理念
由 Tetra Genesis(日本名古屋 B Button 公司)开发。
无法记住失败的智能体注定会重蹈覆辙。
疤痕不是缺陷——它们是免疫系统。
每个循环都必须回答:这让谁感到高兴?