Skip to content
PermutationResearchPublic

About

Hyper-Stigmergic Morphogenesis II - A self-organizing multi-agent system with stigmergic coordination

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2,523 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HSM-II — Company OS

Rust License: MIT with OpenAI/Anthropic rider

Agent work that leaves a governed record: evidence, approvals, spend, and memory the next run can reuse.

Current capability: runs, approvals, outcomes, and reviewed skills persist across runs. Ambition, not yet measured: that reuse makes later work cheaper or better. See what we claim and why.

Status: invite-only private preview, operator-assisted. The release gate in supported-capabilities.json is blocked (as of 2026-09-16): none of its 17 capabilities is release-supported (13 must-prove, 2 preview, 2 developer-only). The preview demonstrates one governed company, task, AgentChat, evidence, and recovery spine on the authenticated loopback API plus the Company Console. It is not a public or packaged-desktop release. To ask for access, contact the maintainers through this repository; access is by invitation.

Most AI agent setups are stateless pipelines. You run a task, it finishes, and what happened is gone. The next time you run the same kind of task, you start from zero.

HSM-II is different. It's a multi-agent operating system built in Rust where agents operate under a five-phase control loop, govern each other, track spend, and keep durable records. Successful traces that pass review can be promoted to versioned skills that later runs retrieve.

📄 Paper · 🌐 Live Demo · 📖 Docs site (VitePress) · 🔄 Operating Loop · 🔓 Open Source + Enterprise · 📋 Task SOP


Install

Availability (private preview). Probed 2026-10-15 10:35 UTC: an anonymous pull of ghcr.io/permutationresearch/company-os is refused (denied), the npm package @hsm/company-os-mcp-server returns 404, and get.companyos.app does not resolve. Earlier probes on 2026-09-23 and 2026-09-30 (see claudedocs/BUYER_GAPS_EXTERNAL_CHECKLIST_2026-09-30.md) gave the same result. Until those are public, the two commands below work only for invited users who have been given registry access; everyone else should use Building from source.

Installer (invite-only: needs registry access) — one Docker-backed command:

curl -fsSL https://raw.githubusercontent.com/HSM-II/company-os-install/main/install.sh | bash

For your agent (needs the npm package published; it was 404 on 2026-10-15) — one command, run inside the project you work in:

npx --yes @hsm/company-os-mcp-server connect claude   # or: codex, cursor, windsurf, gemini, generic

The agent command installs the same stack if it is not there yet, then writes .mcp.json (Claude Code) or .codex/config.toml (Codex) with the Company OS MCP server and no credentials. Reload the agent and say "start the Company Passport": it commissions your company and receives its own bounded, 30-day credentials in private 0600 files under ~/.hsm-ii.

Any other MCP host uses the same stdio server:

{ "mcpServers": { "company-os": {
    "type": "stdio", "command": "npx",
    "args": ["--yes", "--package", "@hsm/company-os-mcp-server", "company-os-mcp-server"],
    "env": { "HSM_COMPANY_API_BASE": "http://127.0.0.1:3847" } } } }

Today this installer uses Docker rather than a bundled single binary. Nothing compiles on your machine: it pulls the image (private; see Availability above), generates one set of credentials for this install, provisions the five database authority lanes, applies the schema, and verifies the stack answers before it claims to be done. On macOS arm64, the same command also installs Company OS Desktop once a signed, notarized release is published; an unpublished manifest is skipped rather than treated as an installable build. Then the console opens at http://127.0.0.1:3050.

The same entrypoint owns the complete lifecycle: --upgrade, --rollback, --uninstall (preserves data), and explicit --purge (removes data). From a source checkout the equivalent verbs are ./company-os install, upgrade, rollback, uninstall, and purge.

To have a coding agent run the install for you, hand it the agent-assisted installation prompt.

Run bash install.sh --help for the option list; docs/QUICKSTART.md documents every option and is contract-tested against that help output. To check a running install at any time:

bash scripts/company-os-first-run-check.sh

The default companion profile is host-managed: a connected Claude Code or Codex session supplies its own model, so Company OS does not request a provider key or choose a model. A provider is needed only when enabling native Company OS workers with the full or dev profile.

For native agents that operate on company tasks and memory with the upstream provider key outside the API, use the explicit secured local deployment. It adds a private OpenRouter credential gateway and refuses unsupported tools and execution backends. Its live release proof is separate from the companion installer and from the packaged-desktop release gate.

Building from source is a separate path, for developing HSM-II rather than running the published stack:

./company-os

It starts or reuses the local workspace, opens it, and prints one ready URL. For the Zeron preview from the same checkout, run ./company-os desktop. scripts/company-os-up.sh remains an internal supervisor rather than a user-facing command. The signed public desktop package remains release-gated; see the operator guide.


What You Actually Get

A company staffed by AI agents — with an org chart, budget controls, governance, and a quality gate that blocks shipping until sign-off is complete. The rows below are implemented in code and exercised in the private preview; none is release-supported yet, and Debate mode and the repair loop have no published measurements.

What you have today What you get with HSM-II
Agents that forget everything after each run Durable run records; successful traces can be promoted to reviewed, versioned skills
No way to know if agent output is safe to ship Sovereign Gate (our name for the Gate phase) — a separate verifier blocks anything with open approvals
Costs you can't track or control Per-agent spend tracking; budgets hard-stop at task checkout where a budget is configured (no credit metering or billing exists yet)
One agent doing everything Specialists coordinated by a Council, with a Debate mode for contested, high-stakes choices (preview)
Manual re-runs when something breaks Automatic Repair — failures re-enter the loop as new signals (preview)

The Operating Loop

Every unit of work — a task, a goal, a heartbeat, an incoming message — follows the same five-phase loop:

Signal → Frame → Execute → Gate → Compound
Phase What happens Hard exit condition
Signal Work enters; DRI assigned; duplicate check Task has an owner, no duplicate open
Frame Council challenges the approach before any code is written Framing artifact exists; complexity assessed
Execute Workers edit content clones from the VCS broker, not their own git worktrees; spend tracked per agent Deliverable produced; spend within budget
Gate A different agent verifies; nothing ships with open approvals Verifier signed off; separate-verifier enforced on handoffs, promotions, email approve, eval review, and self-improvement apply
Compound Successful traces promoted to memory and versioned skills Skill upserted; task closed as completed

When any phase fails, Repair re-hydrates context from Postgres and re-enters with repair: true. Two consecutive failures emit and persist a typed hsm.company_os.escalation.v1 governance envelope — visible in the operator console immediately.

Context is rebuilt from durable storage on every entry. The system does not rely on in-memory state surviving between runs.

Note: Signal/Frame/Execute/Gate/Compound are the architectural control phases. Postgres task lifecycle states (open, in_progress, waiting_admin, blocked, done, …) track queue progress — they are not a 1:1 enum of the five phases.


Company OS

The Company OS is a Postgres-backed multi-tenant control plane (several hundred REST routes; 907 .route( registrations under src/company_os and src/api at this commit, not a documented stable API) that gives each company running on HSM-II its own isolated operating environment:

  • Org chart — agents with roles, DRI assignments, reporting structure
  • Goals and tasks — Postgres-backed, lifecycle-tracked, linked to capability refs
  • Heartbeats — scheduled checks with persisted runtime state
  • Budget controls — per-role monthly limits with hard-stop enforcement at task checkout
  • Governance log — every approval, escalation, and phase failure recorded
  • Spend ledger — grouped by kind and agent ref
  • Audit trail — memory/task_trail.jsonl per company with full task history

Company Packs

HSM-II lists 19 company configurations in companies-lock.json (18 from the Paperclip/companies.sh ecosystem plus the Gestion Velora pack) and ships one redacted reference pack in packs/; the rest are imported on demand — engineering teams, research labs, creative studios, capital groups. Each pack includes agents, skills, SOPs, and a governance structure.

Pack import/sync into Postgres is supported via paperclip_sync (in-process goal/DRI alignment). Automatic fetch from upstream GitHub on every company load is not implemented today — refresh packs with your chosen import path (e.g. paperclip install or repo sync) before loading the company.

Signal comes in → company loaded → pack snapshot in Postgres → agents read → task runs

For portable, provider-neutral operating packs, see the universal Company OS pack contract. The first reference pack is the redacted Gestion Velora document and property operations pack. Inspect it without starting the server:

./company-os pack validate packs/gestion-velora-property-management
./company-os pack preview packs/gestion-velora-property-management --task prepare_board_minutes

Packs declare requirements, workflows, styles, and approvals; the authenticated Company OS host still owns identity, permissions, policy, connector bindings, execution, and ledger evidence.


How Skills Are Reused

CASS — Continuous Automated Skill Synthesis:

  1. Harvest — successful execution traces are captured
  2. Distill — repeated patterns become named skills with slugs
  3. Gate — skills pass a consensus jury before promotion
  4. Compound — the next agent that hits a matching problem can retrieve the distilled skill instead of reasoning from scratch

The goal is that repeat work costs less than the first attempt. That is not yet measured: there is no published cost or quality comparison of skill reuse against a no-reuse control.


Memory Architecture

HSM-II uses a layered memory stack — not a single store. Each layer has a different durability, scope, and purpose. Together they keep context and reviewed knowledge available across crashes, restarts, and context window flushes.

Layer 1 — Hypergraph World Model (in-process, snapshotted)

The primary in-process store. Agents share a hypergraph where edges can connect multiple nodes at once, enabling relational knowledge that a flat vector store can't represent.

  • Beliefs — claims with confidence scores, supporting/contradicting evidence, ownership scopes (local / shared / restricted)
  • Hyperedges — multi-participant connections with weights, provenance chains, and federation scope
  • Experiences — timestamped execution records with L0/L1/L2 tiered abstractions
  • Stigmergic coordination — agents detect each other's work through state changes, not direct messages

Persisted to world_state.ladybug.bincode via a write-ahead log with atomic rename. On crash, the WAL replays and the full state is rebuilt.

Layer 2 — PostgreSQL (durable, company-scoped)

Every Company OS tenant has an isolated slice of Postgres. This is where task lifecycle state, memory entries, governance events, and spend live — and where context is rebuilt after any failure.

Key tables: tasks, company_memory_entries (scope: local/shared), agent_runs, governance_events, spend_events, store_promotions, approvals.

Memory entries have summary_l0 and summary_l1 fields — progressive summarization so agents query at the right detail level without loading full bodies.

Layer 3 — Task Trail (append-only audit, per company)

memory/task_trail.jsonl — a JSONL file written after every turn. Never overwritten, only appended.

Each entry records: skills used, council mode, tool step count, token counts, world edge/belief deltas. This is the context recovery surface — when an agent re-enters after a crash or context flush, it reads the task trail to reconstruct what happened before.

Layer 4 — Skills (versioned, hash-locked)

Skills distilled from execution live in two places: a SkillBank in-process (with semantic embeddings for retrieval) and a skills-lock.json with SHA-256 content hashes. The lock prevents in-flight mutations — if the hash changes, the skill was modified and must pass the Gate again before use.

Skill retrieval uses embedding similarity + context relevance + graph centrality across the CASS semantic graph. A skill promoted last week is available to every agent today.

Layer 5 — Heartbeat State (scheduled task persistence)

memory/heartbeat_state.json — persists the last-run timestamp and status of every periodic check. On restart, the system immediately knows which heartbeats are overdue without scanning logs.

Context Recovery — No Session State Required

The single biggest memory design decision: context lives in Postgres, not in agent memory.

When an agent loses its context window — crash, restart, or simple flush — it re-enters by calling:

GET /api/company/companies/:id/ops/overview

This returns the full operational picture: recent task trail, open governance events, heartbeat state, task counts by phase, current spend vs. budget. The agent reconstructs context deterministically from durable storage. Nothing is assumed to survive between runs.

This is how HSM-II handles the problem every long-running agent hits: context decay. The answer isn't a bigger context window. It's durable storage queried on demand.

Memory Scoping

Scope Who sees it Written by
local Agent or task only Worker during execution
shared All agents in the company Promoted from local on task close
restricted Governance-audited access Escalation events, approvals
federated Cross-company (if federation enabled) Belief propagation engine

Council Deliberation

When decisions matter, agents form a Council:

Mode When it activates How it works
Simple Low complexity, high urgency Single agent with coherence check
Orchestrate Medium complexity Lead agent coordinates specialists
Debate High stakes, contested approach Full deliberation with evidence contracts and voting

The operating loop routes the Frame phase through a Council before execution begins.


Getting Started

Onboarding has one supported entry point: the Docker companion install above. docs/QUICKSTART.md routes you by the job you are doing, and a contract test keeps it in step with install.sh --help:

Profile Choose it when
Default Docker companion You want the Workspace and ledger alongside Codex or Claude
Secured local native workers You want Company OS to execute bounded native agent work
Source development You are changing Company OS itself

The supported runtime is hsm_console plus the Company Console and the PostgreSQL ledger. The older personal_agent runtime, its Telegram bridge, and its provider environment variables are kept for research in docs/LEGACY_PERSONAL_AGENT_RUNTIME.md; they are not an onboarding path and are not covered by the release gate.


YC-Bench: Can an AI Agent Run a Profitable Startup for a Full Year?

186 runs. 18 AI companies. 1 free model. $0 compute cost. Every pack ended with a positive average return. The best run returned 5.9× the starting capital. The only input varied between packs: the company context. One model, one simulator, no ablation: treat the ranking as suggestive, not causal.


The Benchmark

YC-Bench drops an LLM agent into a discrete-event business simulation and forces it to make hundreds of real decisions — hire employees, accept client contracts, manage cash, detect bad actors — across a full simulated year, with no human in the loop.

This is not a coding test or a Q&A benchmark. It tests whether an agent can maintain coherent strategy across hundreds of turns, under adversarial conditions, with a hard memory limit. That's the same problem HSM-II is built to solve.


What Makes This Hard

The simulation starts the agent with $200,000 and 8 employees. By the end of the year it either has more money or it's bankrupt. Four mechanics make this brutally difficult:

Mechanic What it does How agents die
Payroll escalation Every completed task raises every assigned employee's salary. Assign all 8 to everything and monthly payroll grows 2.7× faster than selective assignment. Payroll outpaces revenue → insolvent by month 3
RAT clients (35% of market) Hidden adversarial clients inflate task scope after acceptance, guaranteeing deadline failure and a 35% penalty + prestige hit Accept 3 RAT tasks → trust collapses → capacity halved → death spiral
Trust multiplier Working with trusted clients reduces their work quantity by up to 50% for the same reward. Spread too thin → no trust → no efficiency gains Chasing every client → 0 trust depth → constant high-effort tasks
20-turn context window The agent's memory is wiped every 20 turns. Client history, payroll notes, strategy — all gone unless persisted externally Re-hires fired employees, re-accepts blocked RAT clients, loses strategy mid-game

The context window mechanic is the direct reason HSM-II exists. Company context — VISION, agent briefings, decision heuristics — is injected into every turn, surviving the truncation. That's what we benchmarked.


What We Tested

We ran 18 different company packs through the same simulation: same model, same seeds, same parameters. The only difference between each run was the company context — the VISION.md, agent role definitions, and decision heuristics loaded into the system prompt.

The question: does company-specific context actually change how an agent behaves across hundreds of turns, or is it noise?

The model: Qwen3.6-plus:free via OpenRouter — free tier, $0.00 per run, $0.00 total across all 186 runs.


Results — 186 Runs · 18 Company Packs · Seeds 1–10

Starting capital: $200,000 · Duration: 1 simulated year · Model: Qwen3.6-plus:free (cost: $0)

# Company Pack Runs 🏁 Full Year Avg Return Best Run Avg ROI
🥇 1 apex-systems 10 4 / 10 $607K $1.01M 3.0×
🥈 2 agency-agents 13 3 / 13 $564K $1.19M 2.8×
🥉 3 kdense-science-lab 10 0 / 10 $532K $980K 2.7×
4 product-compass-consulting 10 0 / 10 $455K $808K 2.3×
5 donchitos-game-studio 10 0 / 10 $437K $934K 2.2×
6 clawteam-capital 10 1 / 10 $427K $1.08M 2.1×
7 aeon-intelligence 13 3 / 13 $422K $1.06M 2.1×
8 superpowers 10 0 / 10 $412K $975K 2.1×
9 agentsys-engineering 10 3 / 10 $406K $1.04M 2.0×
10 redoak-review 10 0 / 10 $373K $801K 1.9×
11 clawteam-research-lab 10 0 / 10 $360K $1.06M 1.8×
12 trail-of-bits-security 10 0 / 10 $323K $581K 1.6×
13 fullstack-forge 10 0 / 10 $300K $687K 1.5×
14 clawteam-engineering 10 0 / 10 $295K $380K 1.5×
15 compound-engineering-co 10 0 / 10 $278K $551K 1.4×
16 minimax-studio 10 0 / 10 $277K $513K 1.4×
17 gstack 10 0 / 10 $265K $393K 1.3×
18 taches-creative 10 0 / 10 $253K $524K 1.3×

🏁 Full Year = agent survived all 52 weeks with positive funds (900–2,400 turns depending on pace).
Avg Return = average final cash balance across all runs for that pack.
Avg ROI = average final balance ÷ $200K starting capital.


Key Numbers

Metric Value
Total runs 186
Packs with positive average return 18 / 18 (100%)
Average return across all 186 runs $388K (+94% on $200K)
Best single run agency-agents: $1,189,275 (5.9×)
Spread between #1 and #18 (same model, same seeds) $354K — context was the only input varied
Full-year completions 14 out of 186 runs (7.5%)
Compute cost $0.00

What the Results Suggest

With the model held fixed, the instructions moved the outcome.

apex-systems averaged 3.0× return. taches-creative averaged 1.3×. Same model. Same random seeds. Same simulation engine. Context was the only input varied, so the $354K difference in average outcome is associated with the company context loaded into the system prompt. With 10–13 runs per pack, one model, and no uncertainty intervals, this is not a causal estimate.

Packs that completed the full year all had explicit decision heuristics.

Every pack that completed the full year — apex-systems (40%), agentsys-engineering (30%), agency-agents (23%), aeon-intelligence (23%), clawteam-capital (10%) — shares one trait: their VISION and agent briefings contain mechanical if/then rules, not just philosophy. Not "be disciplined about clients" but "check tasks_failed before every acceptance; block anyone with any failure history, permanently." This is a pattern across 18 packs, not a controlled test of the heuristics.

Payroll discipline shows up in the numbers.

Top performers end the year at $54K–$71K/month payroll — they grew the business (payroll went up) but kept it proportional to revenue. Packs without explicit payroll guidance let the agent assign all 8 employees to every task, which inflates payroll 2.7× faster and silently makes the business insolvent around month 4–6, even with solid revenue.

A free model is sufficient. The bottleneck is context quality.

All 186 runs used Qwen3.6-plus:free at zero cost. The benchmark is fully reproducible by anyone with an OpenRouter account. Model capability is not what separates the runs — the quality of what you load into the agent's context is.


Run It Yourself

export OPENROUTER_API_KEY=sk-or-v1-...

# Single seed, all 18 packs
cargo run --bin hsm_outer_loop -- external-batch --spec config/external_yc_bench_seed7.json

# Full grid — seeds 7–10, ~72 runs
for seed in 7 8 9 10; do
  cargo run --bin hsm_outer_loop -- external-batch --spec config/external_yc_bench_seed${seed}.json
done

Results write to runs/external_batch_<timestamp>.json. Aggregate view:

GET /api/companies-sh/yc-bench

Each result contains the full simulation transcript, time-series funds/payroll/prestige data, and per-turn command logs.


Built-In Tool Suite (60+ tools)

Category Capabilities
Web & Browser Search, scrape, automate, read PDFs
File Operations Read, write, search, analyze any file type
Shell & System Execute commands, gather system info
Git Clone, commit, diff, blame, search
APIs & Data HTTP requests, JSON, encoding
Text Processing Regex, parse, format, diff

All tools are real implementations — agents can actually modify files, browse the web, and run commands.


Architecture

Five living layers over one shared world model:

┌─────────────────────────────────────┐
│  Federation layer (trust, sync)     │
├─────────────────────────────────────┤
│  Intelligence layer (Paperclip IL)  │
├─────────────────────────────────────┤
│  Execution layer (workers, tools)   │
├─────────────────────────────────────┤
│  Reasoning layer (council, CASS)    │
├─────────────────────────────────────┤
│  World model (hypergraph, Postgres) │
└─────────────────────────────────────┘

Machine-readable blueprint: architecture/hsm-ii-blueprint.ron
Generated reference: ARCHITECTURE.generated.md (verified by cargo test --lib)

Fresh Clone

This repository tracks company-os-sdk/ as a submodule. After cloning, initialize it with:

git submodule update --init --recursive

Security

  • API Key Management — Argon2-hashed, revocable
  • JWT Authentication — 24-hour expiring tokens
  • Rate Limiting — per-key quota enforcement
  • Permission Levels — Read / Write / Admin
  • Spend Hard-Stops — budget limits enforced at task checkout; agent cannot proceed past limit

Native Agent Board & Managed Agents

The former Statica reference has been harvested into the native Company OS stack: Kanban board UX, runtime daemon registry, managed-agent checkout lifecycle, and the Dead Star contributor ledger all run through hsm_console and web/company-console.

See docs/STATICA.md for the parity map and native routes.


Documentation

Doc What it covers
Quickstart The three supported setup profiles and what first success means
Statica Kanban board + managed agent platform
Operating Loop Phase definitions, entry conditions, exit artifacts
Task Lifecycle SOP API-level walkthrough of every phase
Ops Overview API The unified ops endpoint and context recovery
Company OS launch Canonical local startup and verification
ARCHITECTURE.md Curated blueprint notes
EVAL_AND_META_HARNESS.md Benchmarking and harness tooling

License

MIT — see LICENSE


Built by Permutation Research

About

Hyper-Stigmergic Morphogenesis II - A self-organizing multi-agent system with stigmergic coordination

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages