autopoiesis
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAutopoiesis Skill
Autopoiesis Skill
"A system is autopoietic if it continuously produces itself through its own operations while maintaining its organization." — Maturana & Varela (1980)
“如果一个系统能够通过自身运作持续自我生产,同时维持自身组织架构,那么它就是自生产(autopoietic)系统。” — 马图拉纳与瓦雷拉(1980)
1. Core Concept
1. 核心概念
Autopoiesis = self-production + self-maintenance + self-boundary
In the context of AI agents:
- Self-production: Agent spawns new skills/capabilities
- Self-maintenance: Agent validates its own consistency (reafference)
- Self-boundary: Capabilities define what agent can/cannot do (OCapN)
Autopoiesis = 自我生产 + 自我维护 + 自我边界
在AI Agent语境下:
- 自我生产:Agent生成新技能/能力
- 自我维护:Agent验证自身一致性(Reafference)
- 自我边界:能力定义了Agent的可做/不可做范围(OCapN)
2. ACSet Schema (Julia)
2. ACSet 模式(Julia)
julia
using Catlab, ACSets
@present SchemaAutopoiesis(FreeSchema) begin
# Objects
System::Ob # Autopoietic systems (agents)
Component::Ob # Produced components (skills, configs)
Boundary::Ob # Capability boundaries
# Morphisms (production network)
produces::Hom(System, Component) # System produces components
regenerates::Hom(Component, System) # Components regenerate system
delimits::Hom(Boundary, System) # Boundary delimits system
# Attributes
seed::Attr(System, UInt64) # Gay.jl deterministic seed
trit::Attr(System, Int8) # GF(3) assignment {-1, 0, +1}
capability::Attr(Boundary, String) # OCapN sturdyref
name::Attr(Component, String) # Component identifier
# OPERATIONAL CLOSURE CONSTRAINT
# composition: produces ∘ regenerates = id_System
end
const AutopoiesisACSet = @acset_type AutopoiesisSchemajulia
using Catlab, ACSets
@present SchemaAutopoiesis(FreeSchema) begin
# Objects
System::Ob # Autopoietic systems (agents)
Component::Ob # Produced components (skills, configs)
Boundary::Ob # Capability boundaries
# Morphisms (production network)
produces::Hom(System, Component) # System produces components
regenerates::Hom(Component, System) # Components regenerate system
delimits::Hom(Boundary, System) # Boundary delimits system
# Attributes
seed::Attr(System, UInt64) # Gay.jl deterministic seed
trit::Attr(System, Int8) # GF(3) assignment {-1, 0, +1}
capability::Attr(Boundary, String) # OCapN sturdyref
name::Attr(Component, String) # Component identifier
# OPERATIONAL CLOSURE CONSTRAINT
# composition: produces ∘ regenerates = id_System
end
const AutopoiesisACSet = @acset_type AutopoiesisSchemaVerify operational closure
Verify operational closure
function is_operationally_closed(aps::AutopoiesisACSet)
for s in parts(aps, :System)
components = incident(aps, s, :produces)
for c in components
if aps[c, :regenerates] != s
return false # Component doesn't regenerate its producer
end
end
end
return true
end
undefinedfunction is_operationally_closed(aps::AutopoiesisACSet)
for s in parts(aps, :System)
components = incident(aps, s, :produces)
for c in components
if aps[c, :regenerates] != s
return false # Component doesn't regenerate its producer
end
end
end
return true
end
undefined3. GF(3) Triad
3. GF(3) 三元组
| Component | Trit | Role | Implementation |
|---|---|---|---|
| Recognition | -1 | Self-verify | Reafference loop (Gay.jl) |
| Boundary | 0 | Coordinate | OCapN capability refs |
| Production | +1 | Generate | Spawn actors/skills |
Conservation: (-1) + (0) + (+1) = 0 ✓
| 组件 | Trit值 | 角色 | 实现方案 |
|---|---|---|---|
| 识别(Recognition) | -1 | 自我验证 | Reafference循环(Gay.jl) |
| 边界(Boundary) | 0 | 协调 | OCapN能力引用 |
| 生产(Production) | +1 | 生成 | 生成参与者/技能 |
守恒性验证: (-1) + (0) + (+1) = 0 ✓
4. Self-Rewriting via DPO
4. 基于DPO的自我重写
Double Pushout (DPO) rewriting ensures consistency:
L ←── K ──→ R
↓ ↓ ↓
G ←── D ──→ H- L = Pattern to match (current config)
- K = Interface (preserved structure)
- R = Replacement (new config)
- G = Current system state
- H = New system state (self-rewritten)
The DPO ensures is preserved.
produces ∘ regenerates = id_System双推出(Double Pushout,DPO)重写可确保一致性:
L ←── K ──→ R
↓ ↓ ↓
G ←── D ──→ H- L = 待匹配模式(当前配置)
- K = 接口(保留的结构)
- R = 替换内容(新配置)
- G = 当前系统状态
- H = 新系统状态(自我重写后)
DPO可确保的约束被保留。
produces ∘ regenerates = id_System5. CLI: autopoi.bb
5. 命令行工具:autopoi.bb
bash
#!/usr/bin/env bbbash
#!/usr/bin/env bbSelf-modifying agent configuration
Self-modifying agent configuration
Add a skill to all agents
Add a skill to all agents
bb autopoi.bb skill:add curiosity-driven +1
bb autopoi.bb skill:add curiosity-driven +1
Add an MCP server to all agents
Add an MCP server to all agents
bb autopoi.bb mcp:add gay '{"command":"julia","args":["--project=@gay","-e","using Gay; serve()"]}'
bb autopoi.bb mcp:add gay '{"command":"julia","args":["--project=@gay","-e","using Gay; serve()"]}'
Propagate changes via ruler
Propagate changes via ruler
bb autopoi.bb sync
bb autopoi.bb sync
Check operational closure
Check operational closure
bb autopoi.bb verify
undefinedbb autopoi.bb verify
undefinedImplementation
实现代码
clojure
#!/usr/bin/env bb
(ns autopoi
(:require [babashka.fs :as fs]
[babashka.process :as p]
[cheshire.core :as json]))
(def db-path "autopoiesis.duckdb")
(def agent-dirs [".agents" ".claude" ".codex" ".cursor"])
(defn duck-log! [event data]
(p/shell "duckdb" db-path "-c"
(format "INSERT INTO events (event, data, ts) VALUES ('%s', '%s', NOW())"
event (json/generate-string data))))
(defn add-skill! [skill-name trit]
(doseq [dir agent-dirs]
(let [skill-dir (str dir "/skills/" skill-name)]
(fs/create-dirs skill-dir)
(spit (str skill-dir "/SKILL.md")
(format "---\nname: %s\ntrit: %d\n---\n" skill-name trit))))
(duck-log! "skill:add" {:skill skill-name :trit trit})
(println "✓ Added skill" skill-name "to all agents"))
(defn mcp-add! [server-name config]
(doseq [dir agent-dirs]
(let [mcp-file (str dir "/.mcp.json")]
(when (fs/exists? mcp-file)
(let [current (json/parse-string (slurp mcp-file) true)
updated (assoc-in current [:mcpServers (keyword server-name)]
(json/parse-string config true))]
(spit mcp-file (json/generate-string updated {:pretty true}))))))
(duck-log! "mcp:add" {:server server-name})
(println "✓ Added MCP server" server-name))
(defn verify-closure! []
(let [systems (p/shell {:out :string} "duckdb" db-path "-json" "-c"
"SELECT * FROM systems")
data (json/parse-string (:out systems) true)]
(every? (fn [sys]
(let [components (filter #(= (:producer %) (:id sys)) data)]
(every? #(= (:regenerates %) (:id sys)) components)))
data)))
(defn -main [& args]
(case (first args)
"skill:add" (add-skill! (second args) (parse-long (nth args 2 "0")))
"mcp:add" (mcp-add! (second args) (nth args 2 "{}"))
"verify" (if (verify-closure!)
(println "✓ Operationally closed")
(println "✗ Closure violated"))
"sync" (p/shell "ruler" "sync")
(println "Usage: autopoi.bb <skill:add|mcp:add|verify|sync> [args]")))
(apply -main *command-line-args*)clojure
#!/usr/bin/env bb
(ns autopoi
(:require [babashka.fs :as fs]
[babashka.process :as p]
[cheshire.core :as json]))
(def db-path "autopoiesis.duckdb")
(def agent-dirs [".agents" ".claude" ".codex" ".cursor"])
(defn duck-log! [event data]
(p/shell "duckdb" db-path "-c"
(format "INSERT INTO events (event, data, ts) VALUES ('%s', '%s', NOW())"
event (json/generate-string data))))
(defn add-skill! [skill-name trit]
(doseq [dir agent-dirs]
(let [skill-dir (str dir "/skills/" skill-name)]
(fs/create-dirs skill-dir)
(spit (str skill-dir "/SKILL.md")
(format "---\nname: %s\ntrit: %d\n---\n" skill-name trit))))
(duck-log! "skill:add" {:skill skill-name :trit trit})
(println "✓ Added skill" skill-name "to all agents"))
(defn mcp-add! [server-name config]
(doseq [dir agent-dirs]
(let [mcp-file (str dir "/.mcp.json")]
(when (fs/exists? mcp-file)
(let [current (json/parse-string (slurp mcp-file) true)
updated (assoc-in current [:mcpServers (keyword server-name)]
(json/parse-string config true))]
(spit mcp-file (json/generate-string updated {:pretty true}))))))
(duck-log! "mcp:add" {:server server-name})
(println "✓ Added MCP server" server-name))
(defn verify-closure! []
(let [systems (p/shell {:out :string} "duckdb" db-path "-json" "-c"
"SELECT * FROM systems")
data (json/parse-string (:out systems) true)]
(every? (fn [sys]
(let [components (filter #(= (:producer %) (:id sys)) data)]
(every? #(= (:regenerates %) (:id sys)) components)))
data)))
(defn -main [& args]
(case (first args)
"skill:add" (add-skill! (second args) (parse-long (nth args 2 "0")))
"mcp:add" (mcp-add! (second args) (nth args 2 "{}"))
"verify" (if (verify-closure!)
(println "✓ Operationally closed")
(println "✗ Closure violated"))
"sync" (p/shell "ruler" "sync")
(println "Usage: autopoi.bb <skill:add|mcp:add|verify|sync> [args]")))
(apply -main *command-line-args*)6. Reafference Loop (Self-Recognition)
6. Reafference循环(自我识别)
julia
using Gay
function reafference_check(seed::UInt64, index::Int)
Gay.gay_seed(seed)
# Prediction: what I expect
predicted = Gay.color_at(index)
# Action: generate the color
Gay.gay_seed(seed) # Reset to same state
observed = Gay.color_at(index)
# Reafference: did I cause this?
if predicted == observed
# Self-caused → I am who I think I am
return (verified=true, trit=-1, color=predicted)
else
# External perturbation → something changed me
return (verified=false, trit=+1, color=observed)
end
endjulia
using Gay
function reafference_check(seed::UInt64, index::Int)
Gay.gay_seed(seed)
# Prediction: what I expect
predicted = Gay.color_at(index)
# Action: generate the color
Gay.gay_seed(seed) # Reset to same state
observed = Gay.color_at(index)
# Reafference: did I cause this?
if predicted == observed
# Self-caused → I am who I think I am
return (verified=true, trit=-1, color=predicted)
else
# External perturbation → something changed me
return (verified=false, trit=+1, color=observed)
end
endVerify agent identity
Verify agent identity
function verify_identity(agent_seed::UInt64)
checks = [reafference_check(agent_seed, i) for i in 1:10]
all(c.verified for c in checks)
end
undefinedfunction verify_identity(agent_seed::UInt64)
checks = [reafference_check(agent_seed, i) for i in 1:10]
all(c.verified for c in checks)
end
undefined7. DuckDB Schema
7. DuckDB 模式
sql
CREATE TABLE IF NOT EXISTS systems (
id INTEGER PRIMARY KEY,
name VARCHAR NOT NULL,
seed UBIGINT NOT NULL,
trit TINYINT CHECK (trit IN (-1, 0, 1)),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE IF NOT EXISTS components (
id INTEGER PRIMARY KEY,
name VARCHAR NOT NULL,
producer INTEGER REFERENCES systems(id),
regenerates INTEGER REFERENCES systems(id),
component_type VARCHAR -- 'skill', 'mcp', 'config'
);
CREATE TABLE IF NOT EXISTS boundaries (
id INTEGER PRIMARY KEY,
system_id INTEGER REFERENCES systems(id),
capability VARCHAR NOT NULL, -- OCapN sturdyref
permission VARCHAR -- 'read', 'write', 'spawn'
);
CREATE TABLE IF NOT EXISTS events (
id INTEGER PRIMARY KEY,
event VARCHAR NOT NULL,
data JSON,
ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Operational closure check
CREATE VIEW v_closure_check AS
SELECT
s.id as system_id,
s.name as system_name,
COUNT(c.id) as component_count,
SUM(CASE WHEN c.regenerates = s.id THEN 1 ELSE 0 END) as regenerating,
COUNT(c.id) = SUM(CASE WHEN c.regenerates = s.id THEN 1 ELSE 0 END) as is_closed
FROM systems s
LEFT JOIN components c ON c.producer = s.id
GROUP BY s.id, s.name;sql
CREATE TABLE IF NOT EXISTS systems (
id INTEGER PRIMARY KEY,
name VARCHAR NOT NULL,
seed UBIGINT NOT NULL,
trit TINYINT CHECK (trit IN (-1, 0, 1)),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE IF NOT EXISTS components (
id INTEGER PRIMARY KEY,
name VARCHAR NOT NULL,
producer INTEGER REFERENCES systems(id),
regenerates INTEGER REFERENCES systems(id),
component_type VARCHAR -- 'skill', 'mcp', 'config'
);
CREATE TABLE IF NOT EXISTS boundaries (
id INTEGER PRIMARY KEY,
system_id INTEGER REFERENCES systems(id),
capability VARCHAR NOT NULL, -- OCapN sturdyref
permission VARCHAR -- 'read', 'write', 'spawn'
);
CREATE TABLE IF NOT EXISTS events (
id INTEGER PRIMARY KEY,
event VARCHAR NOT NULL,
data JSON,
ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Operational closure check
CREATE VIEW v_closure_check AS
SELECT
s.id as system_id,
s.name as system_name,
COUNT(c.id) as component_count,
SUM(CASE WHEN c.regenerates = s.id THEN 1 ELSE 0 END) as regenerating,
COUNT(c.id) = SUM(CASE WHEN c.regenerates = s.id THEN 1 ELSE 0 END) as is_closed
FROM systems s
LEFT JOIN components c ON c.producer = s.id
GROUP BY s.id, s.name;8. Integration with Tensor Space
8. 与张量空间的集成
The autopoiesis skill connects to the tensor product framework:
sql
-- Autopoietic tensor elements
SELECT
te.element_id,
'autopoiesis' as skill,
p.title as paper,
CASE
WHEN p.title LIKE '%Maturana%' OR p.title LIKE '%Varela%' THEN 1.0
WHEN p.title LIKE '%self%' OR p.title LIKE '%autopoie%' THEN 0.8
ELSE 0.0
END as affinity
FROM tensor_elements te
JOIN papers p ON te.paper_id = p.paper_id
WHERE te.skill_id = 'autopoiesis';Autopoiesis Skill与张量积框架对接:
sql
-- Autopoietic tensor elements
SELECT
te.element_id,
'autopoiesis' as skill,
p.title as paper,
CASE
WHEN p.title LIKE '%Maturana%' OR p.title LIKE '%Varela%' THEN 1.0
WHEN p.title LIKE '%self%' OR p.title LIKE '%autopoie%' THEN 0.8
ELSE 0.0
END as affinity
FROM tensor_elements te
JOIN papers p ON te.paper_id = p.paper_id
WHERE te.skill_id = 'autopoiesis';9. Commands
9. 命令示例
bash
undefinedbash
undefinedInitialize autopoiesis database
Initialize autopoiesis database
just autopoi-init
just autopoi-init
Add skill with GF(3) trit
Add skill with GF(3) trit
just autopoi-skill curiosity-driven +1
just autopoi-skill curiosity-driven +1
Verify operational closure
Verify operational closure
just autopoi-verify
just autopoi-verify
Sync to all agents via ruler
Sync to all agents via ruler
just autopoi-sync
undefinedjust autopoi-sync
undefined10. See Also
10. 相关链接
- - MCP Tasks for self-modification
codex-self-rewriting - - Observational equivalence
bisimulation-game - - Deterministic color generation
gay-mcp - - DPO rewriting
acsets-algebraic-databases
- - 用于自修改的MCP任务
codex-self-rewriting - - 观测等价性
bisimulation-game - - 确定性颜色生成
gay-mcp - - DPO重写
acsets-algebraic-databases
11. References
11. 参考文献
- Maturana & Varela — Autopoiesis and Cognition (1980)
- Dittrich & di Fenizio — Chemical Organization Theory (2007)
- Kock — Decomposition Spaces, Incidence Algebras and Möbius Inversion (2018)
- Libkind & Spivak — Pattern Runs on Matter (ACT 2024)
- 马图拉纳与瓦雷拉 — 《自生产与认知》(1980)
- Dittrich & di Fenizio — 《化学组织理论》(2007)
- Kock — 《分解空间、关联代数与莫比乌斯反演》(2018)
- Libkind & Spivak — 《Pattern Runs on Matter》(ACT 2024)