{"id":35570939,"url":"https://github.com/rossignoliluca/entity","last_synced_at":"2026-01-17T05:25:41.737Z","repository":{"id":332409203,"uuid":"1127621258","full_name":"rossignoliluca/entity","owner":"rossignoliluca","description":"Autopoietic Entity System v2.0.0 - ISO AES-SPEC-001: Event sourcing, Merkle chain, Lyapunov stability, Internal Agency, MCP integration, All categories SATURATED","archived":false,"fork":false,"pushed_at":"2026-01-06T08:54:04.000Z","size":1189,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-13T19:45:53.931Z","etag":null,"topics":["active-inference","autopoiesis","claude","event-sourcing","lyapunov","mcp","self-organization","typescript"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rossignoliluca.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":"GOVERNANCE.md","roadmap":"ROADMAP.md","authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-01-04T09:05:20.000Z","updated_at":"2026-01-06T08:54:07.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/rossignoliluca/entity","commit_stats":null,"previous_names":["rossignoliluca/entity"],"tags_count":25,"template":false,"template_full_name":null,"purl":"pkg:github/rossignoliluca/entity","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rossignoliluca%2Fentity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rossignoliluca%2Fentity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rossignoliluca%2Fentity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rossignoliluca%2Fentity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rossignoliluca","download_url":"https://codeload.github.com/rossignoliluca/entity/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rossignoliluca%2Fentity/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28499289,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T04:31:57.058Z","status":"ssl_error","status_checked_at":"2026-01-17T04:31:45.816Z","response_time":85,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["active-inference","autopoiesis","claude","event-sourcing","lyapunov","mcp","self-organization","typescript"],"created_at":"2026-01-04T17:15:27.296Z","updated_at":"2026-01-17T05:25:41.732Z","avatar_url":"https://github.com/rossignoliluca.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Entity System\n\n**Implementation v2.1.0** | Core Spec AES-SPEC-001 v2.0.0 | Species 2: AES-SPEC-002 v1.0.0\n\nAn ISO-compliant implementation of an autopoietic entity with event sourcing, Merkle chain integrity, Lyapunov stability, internal agency, and temporal presence.\n\n## Overview\n\nEntity is a self-maintaining system that preserves its organizational identity through:\n\n- **Event Sourcing**: All state changes recorded as hash-linked events (Merkle chain)\n- **5 Invariants**: Continuously monitored and auto-recovered\n- **Lyapunov Stability**: Mathematical guarantee V never increases\n- **Energy Lifecycle**: Decay/recharge with dormant state protection\n- **Internal Agency**: Autonomous sense-making with constitutional priorities\n- **Active Inference**: Minimizes Expected Free Energy for action selection\n- **Temporal Presence**: Species 2 SSE channel for continuous presence (AES-SPEC-002)\n\n## Requirements\n\n- Node.js 20+\n- npm 10+\n\n## Installation\n\n```bash\nnpm install\nnpm run build\n```\n\n## Core Features\n\n### Phase 1: Core System\n- Event sourcing with Merkle chain\n- 5 Invariants + verification\n- Lyapunov stability function\n- Conservative guard (unknown → block)\n- Recovery procedures\n- Snapshots (auto + cleanup)\n\n### Phase 2-3: Human Interaction \u0026 Operations\n- Human context persistence\n- Important memories system\n- 10 operations in catalog with energy costs\n\n### Phase 4-5: Learning \u0026 Analytics\n- Pattern recognition in interactions\n- Adaptive responses\n- Metrics dashboard with alerts\n\n### Phase 6: Multi-Instance Continuity\n- State export/import bundles\n- Identity verification across instances\n- Distributed state sync\n\n### Phase 7: Self-Production\n- **7a: Meta-operations** (P set generates operations)\n- **7b: Daemon mode** for autonomous operation\n\n### Phase 8: Internal Agency\n- **8a: Sense-making loop** (Maturana \u0026 Varela, Di Paolo)\n- **8b: Ultrastability** (Ashby) - adaptive parameter adjustment\n- **8c: Active Inference** (Friston) - EFE minimization\n- **8d: Cycle Memory** - learns from past cycles\n- **8e: Self-Producing Agent** - agent creates operations from patterns\n- **8f: Structural Coupling Protocol** - non-coercive agent-human signaling\n\n### Annex H: Self-Production Safety (Sigilli)\n- **Sigillo 1: Quarantine Gate** - QUARANTINED → TRIAL → ACTIVE lifecycle\n- **Sigillo 2: Context Filter** - test/audit excluded from pattern tracking\n- **Sigillo 3: Specialization Bounds** - complexity ≤ parent, depth limit\n\n### Annex I: Non-Goals (Normative)\n- **Prohibited**: Goal formation, planning, self-replication, resource acquisition\n- **Prohibited**: Persuasion, deception, autonomy expansion, coercive coupling\n- **Boundary**: Any system requiring these = new species (AES-SPEC-002)\n\n### Species 2: Temporal Presence (AES-SPEC-002)\n- **SSE Channel**: Server-Sent Events for unidirectional signaling\n- **Signal Types**: STATUS_CHANGED, ENERGY_WARNING, COUPLING_REQUESTED, HEARTBEAT\n- **PRESENCE_SILENCE**: Default state (no signal if nothing changed)\n- **Rate Limits**: Max 1 signal/min, heartbeat max 1/5 min\n- **REST Dominance**: No heartbeat at attractor quiescence (V=0, ε≤ε_min)\n- **INV-006**: Signal integrity with audit trail\n- **Annex K**: Presence-specific non-goals (no dialogue, no attention seeking)\n\n## CLI Commands\n\n```bash\nnode dist/src/index.js \u003ccommand\u003e\n```\n\n| Command | Description |\n|---------|-------------|\n| `verify` | Run all invariant checks |\n| `status` | Show system status |\n| `session start/end` | Manage sessions |\n| `snapshot create/list/restore` | State snapshots |\n| `recharge` | Restore energy (+0.10) |\n| `recover` | Auto-recover from violations |\n| `op list/exec` | Execute operations |\n| `memory add/list` | Important memories |\n| `learn analyze` | Pattern analysis |\n| `analytics dashboard` | Metrics dashboard |\n| `continuity export/import` | State bundles |\n| `meta define/compose` | Meta-operations |\n| `daemon start/stop/status` | Autonomous mode |\n| `agent status/feeling/cycle` | Internal agency |\n| `coupling list/grant/complete` | Coupling protocol |\n| `mcp` | Start MCP server for LLM integration |\n| `rollback status/list/exec` | Operation rollback |\n| `api start` | REST API + dashboard (http://localhost:3000/dashboard) |\n| `presence start` | SSE presence channel (Species 2) |\n| `log level` | Configure logging |\n\n## Invariants\n\n| ID | Name | Recovery |\n|----|------|----------|\n| INV-001 | Organization Hash | Terminal (immutable) |\n| INV-002 | State Determinism | Event replay |\n| INV-003 | Chain Integrity | Truncate corrupted |\n| INV-004 | Lyapunov Monotone | Reset V |\n| INV-005 | Energy Viable | Dormant state |\n| INV-006 | Signal Integrity (v2.x) | Channel silence 10 min |\n\n## Internal Agency (Phase 8)\n\nThe entity has an autonomous sense-making loop with constitutional priorities:\n\n```\n1. Survival     (INV-005 energy viability)\n2. Integrity    (INV-001 to INV-004)\n3. Stability    (Lyapunov V → 0)\n4. Growth       (learning, autopoiesis)\n5. Rest         (DEF-056 Attractor Quiescence)\n```\n\n**Active Inference**: Actions selected by minimizing Expected Free Energy:\n- G = ambiguity + risk\n- Priority-based epistemic/pragmatic weights\n- Generative model learns from experience\n\n## Project Structure\n\n```\nentity/\n├── src/\n│   ├── index.ts           # CLI entry point\n│   ├── types.ts           # Core types\n│   ├── events.ts          # Event sourcing\n│   ├── lyapunov.ts        # Stability function\n│   ├── guard.ts           # Conservative validator\n│   ├── verify.ts          # Invariant checks\n│   ├── recovery.ts        # Recovery procedures\n│   ├── snapshot.ts        # State snapshots\n│   ├── operations.ts      # Operations catalog\n│   ├── learning.ts        # Pattern analysis\n│   ├── analytics.ts       # Metrics dashboard\n│   ├── continuity.ts      # Multi-instance sync\n│   ├── meta-operations.ts # Self-production\n│   ├── coupling-protocol.ts # Agent-human signaling\n│   ├── logger.ts          # Logging system\n│   ├── state-manager.ts   # Concurrency handling\n│   ├── mcp/\n│   │   └── server.ts      # MCP server for LLMs\n│   ├── api/\n│   │   └── server.ts      # REST API\n│   ├── dashboard/\n│   │   └── index.html     # Read-only dashboard\n│   ├── presence/\n│   │   ├── types.ts       # Signal types (AES-SPEC-002)\n│   │   ├── guard.ts       # Rate limits, REST dominance\n│   │   └── server.ts      # SSE server\n│   └── daemon/\n│       ├── index.ts       # Daemon core\n│       ├── agent.ts       # Internal agency\n│       ├── active-inference.ts  # Free Energy\n│       ├── cycle-memory.ts      # Cycle Memory\n│       ├── scheduler.ts   # Task scheduling\n│       ├── hooks.ts       # Event hooks\n│       └── maintenance.ts # Self-maintenance\n├── test/                  # 434 tests\n├── events/                # Merkle chain\n├── state/                 # Current + snapshots\n└── spec/\n    └── SPECIFICATION.md   # ISO AES-SPEC-001\n```\n\n## MCP Server (LLM Integration)\n\nEntity provides an MCP (Model Context Protocol) server for integration with LLMs:\n\n```bash\n# Start MCP server (stdio transport)\nnode dist/src/index.js mcp\n```\n\n**Resources** (read-only):\n- `entity://state` - Current state summary\n- `entity://feeling` - Agent feeling\n- `entity://verify` - Invariant verification\n- `entity://events/recent` - Last 10 events\n- `entity://coupling` - Pending coupling requests\n- `entity://memories` - Important memories\n\n**Tools** (guard-protected):\n- `session_start/end` - Manage coupling sessions\n- `recharge` - Add energy (+0.10)\n- `op_exec` - Execute operations\n- `agent_cycle` - Force sense-making cycle\n- `coupling_grant/complete` - Manage coupling requests\n\nCompatible with: Claude, OpenAI, Gemini (via MCP universal standard)\n\n## Dashboard\n\nReal-time read-only dashboard for state visualization:\n\n```bash\n# Start API server with dashboard\nnode dist/src/index.js api start\n\n# Open in browser\nopen http://localhost:3000/dashboard\n```\n\nFeatures:\n- **Status**: System status (nominal/degraded/dormant)\n- **Energy**: Energy level with visual bar\n- **Lyapunov V**: Stability indicator\n- **Feeling**: Agent's current feeling (energy, stability, integrity, surprise)\n- **Invariants**: All 5 invariants status\n- **Coupling Queue**: Pending requests from agent\n- **Events**: Recent events from Merkle chain\n- **Memories**: Important memories list\n\nSingle HTML file, zero dependencies, dark theme, 3-second auto-refresh.\n\n## Presence Server (Species 2)\n\nSSE channel for temporal presence (AES-SPEC-002):\n\n```bash\n# Start presence server\nnode dist/src/index.js presence start [port]\n\n# Default port: 3001\n```\n\n**Endpoints:**\n\n| Method | Endpoint | Description |\n|--------|----------|-------------|\n| GET | `/presence/stream` | SSE channel (text/event-stream) |\n| POST | `/presence/grant` | Coupling grant endpoint |\n| GET | `/presence/status` | Channel status |\n\n**Signal Types:**\n- `STATUS_CHANGED` - State transition notification\n- `ENERGY_WARNING` - Energy below threshold\n- `COUPLING_REQUESTED` - Agent requested coupling\n- `HEARTBEAT` - Connection alive (max 1/5 min)\n\n**Payload Format:**\n```json\n{\n  \"type\": \"STATUS_CHANGED\",\n  \"ts\": \"2026-01-05T20:28:56.468Z\",\n  \"seq\": 1,\n  \"org_hash\": \"bd5b24db...\",\n  \"state\": {\"energy\": 0.45, \"V\": 0, \"integrity\": \"5/5\"},\n  \"coupling\": {\"pending\": 0, \"urgent\": 0}\n}\n```\n\n**Hard Rules:**\n- PRESENCE_SILENCE default (no signal if nothing changed)\n- Rate limit: max 1 signal/min (CONSTRAINT-001)\n- REST dominance: no heartbeat at V=0, ε=0 (CONSTRAINT-003)\n- Audit: PRESENCE_SIGNAL_EMITTED logged to Merkle chain (INV-006)\n\n**Test Client:**\n```bash\n# Using curl\ncurl -N http://localhost:3001/presence/stream\n\n# Or the built-in test client\nnpx ts-node src/presence/test-client.ts\n```\n\n## Scientific Foundations\n\n- **Autopoiesis**: Maturana \u0026 Varela (1980)\n- **Sense-making**: Di Paolo (2005)\n- **Free Energy Principle**: Friston (2010)\n- **Ultrastability**: Ashby (1960)\n- **Responsibility Principle**: Jonas (1984)\n\n## Constitutive Constraint\n\n**No action or inaction shall reduce the weighted possibility space of any being.**\n\n## Testing\n\n```bash\nnpm run test\n# 588 tests passing\n```\n\n## Statistics\n\n| Metric | Value |\n|--------|-------|\n| Events | 1106 |\n| Sessions | 76 |\n| Tests | 588 |\n| Version | v2.1.0 |\n\n## License\n\nSee [LICENSE](./LICENSE) - All rights reserved, terms TBD.\n\n## Author\n\nLuca Rossignoli\n\n---\n\n*Built with TypeScript, conforming to ISO AES-SPEC-001 (Species 1) and AES-SPEC-002 (Species 2)*\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frossignoliluca%2Fentity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frossignoliluca%2Fentity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frossignoliluca%2Fentity/lists"}