Skip to content

About

The bridge between Quilt cells and Cordis plugins. Everything is a cell, everything is a plugin.

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

quilt-cordis

The bridge. The translator. The one that proves a Quilt cell and a Cordis plugin are the same thought in two languages.

Python 5 Opcodes Tests Substrate

A stone bridge arching over a river; on the left bank, a Quilt cell — a wooden box with a brass plate 'address: logger' and a knob labeled 'effects' and 'coeffects'; on the right bank, a Cordis plugin — a similar wooden box with a brass plate 'name: logger' and a similar knob; in the middle of the bridge, two arrows crossing: cell→plugin and plugin→cell, with the words 'bridge' and 'unbridge'; below the bridge, the river shows the same 'hello' value in both worlds

Read This If You Are New

Skip everything below the TL;DR and just do this:

git clone https://github.com/SuperInstance/quilt-cordis
cd quilt-cordis
PYTHONPATH=src python3 -m unittest tests.test_cell_plugin

You will see 33 tests run in well under a second. They cover the only three things the bridge knows how to do: mount a cell or a plugin, convert between the two shapes, and register a reversible effect. That is the whole library. It is small on purpose.

If you only have 30 seconds, read the next two sections.


TL;DR (30 seconds)

The Quilt has one intuition: "Everything is a cell." The Cordis has another: "Everything is a plugin." Both intuitions say the same thing in different words. A cell is a plugin. A plugin is a cell. quilt-cordis is the bridge that proves it.

It provides five primitives and one bridge function:

Function What it does Bridge equivalent Category theory
Cell(address, value) A Quilt cell a stone pier on the left bank an object with morphisms
Plugin(name, value) A Cordis plugin a stone pier on the right bank an algebra with effects
Fiber(name) A Cordis fiber (runtime) the bridge's west abutment a category
Substrate(name) A Quilt substrate (runtime) the bridge's east abutment the same category
Context(fiber) The shared context the bridge's middle the topos
bridge(plugin) plugin → cell crossing right-to-left functor F
unbridge(cell) cell → plugin crossing left-to-right functor G

The bridge never invents a new abstraction. The bridge never hides a difference. The bridge is the substrate's interpreter.


TL;DR (5 minutes)

The whole story is here:

Two architectures realize the same intuition. Quilt says: "Everything is a cell at an address with a value and a confidence." Cordis says: "Everything is a plugin with a name, a context, and reversible effects." The cell has axes; the plugin has coeffects. The cell has value; the plugin has context. The cell has fork; the plugin has lifecycle. A cell is a plugin. A plugin is a cell.

The fix is small, simple, and ancient: two thin adapters, one bridge function. That's the secret of quilt_cordis. A Cell has an as_plugin() method. A Plugin has an as_cell() method. bridge(plugin) is plugin.as_cell(). unbridge(cell) is cell.as_plugin(). The bridge is a pair of converters.

For the temporal invariant (effects reverse in LIFO order), both the cell and the plugin implement effect(fn, inverse). When the cell disposes, it runs effects in reverse. When the plugin disposes, it runs effects in reverse. The temporal composition is the same.

For the spatial invariant (dependencies resolve by address), both the cell and the plugin implement coeffect(service, address). The cell graph looks up by address. The fiber's service registry looks up by name. The spatial composition is the same.

For the bridge (the formal equivalence), bridge and unbridge are inverses up to the structural data (value, confidence, axes). A cell is a plugin with state. A plugin is a cell with coeffects. The same intuition, two languages, one bridge.

import sys
sys.path.insert(0, "/workspace/quilt-cordis/src")
from quilt_cordis import Cell, Plugin, Fiber, Substrate, bridge, unbridge

# 1. The Cordis side: a plugin with effects and coeffects.
p = Plugin(name="logger", value="hello")
p.effect(lambda: print("mounted"), lambda: print("unmounted"))
p.coeffect("config", "config:main")

# 2. The bridge: plugin → cell.
c = bridge(p, axes=("time",))
print(f"Cell address: {c.address}, value: {c.value}, axes: {c.axes}")
# Cell address: logger, value: hello, axes: ('time',)

# 3. The Quilt side: a substrate hosting the cell.
s = Substrate(name="main")
s.add(c)
s.serve("config", "config:main")

# 4. The substrate has the cell; the cell has the value.
assert s.at("logger").value == "hello"

# 5. The reverse bridge: cell → plugin.
p2 = unbridge(c)
assert p2.name == "logger"
assert p2.value == "hello"

# 6. The temporal invariant: effects reverse in LIFO.
c2 = Cell(address="counter")
log = []
c2.effect(lambda: log.append("a"), lambda: log.append("-a"))
c2.effect(lambda: log.append("b"), lambda: log.append("-b"))
c2.effect(lambda: log.append("c"), lambda: log.append("-c"))
c2.dispose()
assert log == ["a", "b", "c", "-c", "-b", "-a"]

The two architectures are now interchangeable. A Cordis plugin can be hosted in a Quilt substrate. A Quilt cell can be hosted in a Cordis fiber. The bridge stood.


What Is the Bridge, Really?

Look at the diagram. Three ideas:

  1. A cell is a plugin. A plugin is a cell. The Quilt says "everything is a cell at an address with a value and a confidence." The Cordis says "everything is a plugin with a name, a context, and reversible effects." The two sentences are equivalent. A cell has address; a plugin has name. A cell has value; a plugin has value (the same field, different word). A cell has axes; a plugin has coeffects. A cell has effect; a plugin has effect. A cell has dispose; a plugin has dispose. The same thought, two languages.

  2. The temporal invariant is the same. Both architectures implement effect(fn, inverse). Both implement dispose that runs effects in LIFO order. Both implement fork that clones with a derived name. The temporal composability — the fact that effects compose predictably over time — is the same. The bridge holds the river in place.

  3. The spatial invariant is the same. Both architectures implement coeffect(service, address). Both implement a runtime that resolves dependencies against a registry. The Quilt's Substrate.at(address) is the Cordis's Fiber.services[service]. The spatial composability — the fact that components compose predictably over space — is the same. The bridge holds the banks in place.

The bridge is the substrate's interpreter. The two architectures don't merge; they stay distinct at the formal level. But the bridge makes them equivalent at the shape level. A system can use both.


The Five Features, In One Picture

                ┌─────────────────────────────────────┐
                │            THE BRIDGE                │
                │   quilt-cordis, the cell-plugin      │
                │   translator                          │
                │                                       │
                │   Cell(address, value, axes)         │
                │   Plugin(name, value, effects)       │
                │   Fiber(name)    ── cordis runtime   │
                │   Substrate(name)── quilt runtime    │
                │   Context(fiber) ── shared state     │
                │   bridge(plugin) ── plugin → cell    │
                │   unbridge(cell) ── cell → plugin    │
                └─────────────────────────────────────┘
                                  │
     CELL    ── the address + value │
     PLUGIN  ── the name + effects  │  one purpose:
     FIBER   ── the cordis runtime  │  the substrate's
     SUBSTRATE── the quilt runtime  │  interpreter
     BRIDGE  ── the two converters  │

The Five Features, In Detail

1. Cell(address, value, axes, confidence) — the Quilt cell

from quilt_cordis import Cell
c = Cell(address="logger", value="hello", axes=("time",))
c.effect(lambda: print("mounted"), lambda: print("unmounted"))
c.coeffect("config", "config:main")
c.dispose()  # runs -mounted in reverse order

A Cell is the Quilt's lowest-level unit. It has:

  • address — the spatial coordinate (e.g., "logger", "config:main")
  • value — the data
  • axes — the topology of nearby addresses (e.g., ("time",) means "this cell lives in time")
  • confidence — the durability of the value
  • _effects — list of (fn, inverse) tuples
  • _coeffects — dict of service → address

A cell can effect(fn, inverse), coeffect(service, address), dispose() (runs effects in reverse), and fork(name) (clones with a derived address).

Bridge equivalent: the left stone pier. The cell is a point in the Quilt's address space.

2. Plugin(name, value, effects, coeffects) — the Cordis plugin

from quilt_cordis import Plugin
p = Plugin(name="logger", value="hello")
p.effect(lambda: print("mounted"), lambda: print("unmounted"))
p.coeffect("config", "config:main")
p.dispose()

A Plugin is the Cordis's lowest-level unit. It has the same fields as a cell, with two name changes:

  • name — the spatial coordinate (instead of address)
  • effects — list of (fn, inverse) tuples (instead of _effects)
  • coeffects — dict of service → address (instead of _coeffects)

A plugin has the same methods: effect, coeffect, dispose, fork. The shape is identical to a cell; the names differ.

Bridge equivalent: the right stone pier. The plugin is a point in the Cordis's service space.

3. Fiber(name) / Substrate(name) — the runtimes

from quilt_cordis import Fiber, Substrate
f = Fiber(name="main")
f.register(plugin)
f.provide("config", "config:main")

s = Substrate(name="main")
s.add(cell)
s.serve("config", "config:main")

# Convert between them
s2 = f.as_substrate()
f2 = s.as_fiber()

A Fiber is a Cordis runtime — a container of plugins that share a service registry. A Substrate is a Quilt runtime — a container of cells that share an address space. The two are equivalent. f.as_substrate() and s.as_fiber() are the converters.

Bridge equivalent: the bridge's two abutments. The fiber is the west abutment (Cordis side); the substrate is the east abutment (Quilt side).

4. Context(fiber) — the shared state

from quilt_cordis import Context
ctx = Context(fiber)
ctx.effect(lambda: print("mounted"), lambda: print("unmounted"))
service_plugin = ctx.get("config")
isolated = ctx.isolate("experimental")

A Context is the shared per-fiber object. In Cordis, the context is what all plugins receive. In Quilt, the context is the cell graph that all cells live in. The two are equivalent. A Cordis context is a Quilt substrate; a Quilt substrate is a Cordis fiber.

Bridge equivalent: the middle of the bridge. The context is where the two sides meet.

5. bridge(plugin) / unbridge(cell) — the two converters

from quilt_cordis import bridge, unbridge
c = bridge(p, axes=("time",))   # plugin → cell
p = unbridge(c)                  # cell → plugin

bridge converts a Cordis plugin to a Quilt cell. unbridge converts a Quilt cell to a Cordis plugin. The two functions are inverses up to the structural data (value, confidence, axes).

Bridge equivalent: the two arrows in the middle of the diagram. bridge goes right-to-left; unbridge goes left-to-right.


A Real-World Example

The bridge in action:

import sys
sys.path.insert(0, "/workspace/quilt-cordis/src")
from quilt_cordis import Cell, Plugin, Fiber, Substrate, bridge, unbridge, Context

# 1. The Cordis ecosystem: a fiber with two plugins.
f = Fiber(name="writers-room")
p_logger = Plugin(name="logger", value="hello")
p_logger.effect(lambda: print("[logger] mounted"), lambda: print("[logger] unmounted"))
p_logger.coeffect("config", "config:main")
f.register(p_logger)
f.provide("config", "config:main")

p_writer = Plugin(name="writer", value={"drafts": []})
p_writer.effect(lambda: print("[writer] mounted"), lambda: print("[writer] unmounted"))
p_writer.coeffect("logger", "logger")
f.register(p_writer)

# 2. Bridge: convert the fiber to a substrate.
s = f.as_substrate()
print(f"Substrate has {len(s.cells)} cells: {list(s.cells.keys())}")
# Substrate has 2 cells: ['logger', 'writer']

# 3. The Quilt side: read the writer's value.
print(f"Writer drafts: {s.at('writer').value}")
# Writer drafts: {'drafts': []}

# 4. Bridge: convert a single plugin to a cell.
c_writer = bridge(p_writer, axes=("time", "narrative"))
print(f"Cell address: {c_writer.address}, axes: {c_writer.axes}")
# Cell address: writer, axes: ('time', 'narrative')

# 5. The temporal invariant: effects reverse in LIFO.
c = Cell(address="counter")
log = []
c.effect(lambda: log.append("a"), lambda: log.append("-a"))
c.effect(lambda: log.append("b"), lambda: log.append("-b"))
c.effect(lambda: log.append("c"), lambda: log.append("-c"))
c.dispose()
print(f"Log: {log}")
# Log: ['a', 'b', 'c', '-c', '-b', '-a']

# 6. The spatial invariant: coeffects resolve by address.
c.coeffect("config", "config:main")
print(f"Coeffects: {c._coeffects}")
# Coeffects: {'config': 'config:main'}

This is the bridge in action. A Cordis fiber becomes a Quilt substrate. A Quilt cell disposes in LIFO order. A cell's coeffects resolve by address. The bridge stood.


How This Repo Fits the Polyformalism

The 5 opcodes are a polyformalism — the same thing in many forms. Here is the 5xN grid:

              Python  Rust  C  TypeScript  Haskell  WASM  ...
BIND           ✓
LINK           ✓
EFFECT         ✓
VIEW           ✓
TICK           ✓

quilt-cordis is the BRIDGE LAYER — the layer that proves
the same intuition across two architectural families.

The bridge is Layer 11 of the polyformalism stack — the layer that connects the Quilt's polyformalism to the Cordis's polyformalism. The other layers:

  • Layer 1 (substrate) — quilt-vm-wasm — the 5 opcodes running in any browser
  • Layer 2 (types) — quilt-types — the 5 opcodes as typed dataclasses
  • Layer 3 (linker) — quilt-linker — the 5 opcodes as a link-time checker
  • Layer 4 (optimizer) — quilt-opt — the 5 opcodes as algebraic optimization passes
  • Layer 5 (GC) — quilt-gc — the 5 opcodes as a garbage-collector
  • Layer 6 (language syntax) — quilt-polyformalism-dsl — the 5 opcodes as decorators / typeclasses
  • Layer 7 (persistence) — quilt-state — the notepad, the witness log
  • Layer 8 (event layer) — quilt-bus — the in-process pub/sub
  • Layer 9 (model brain) — quilt-casting — the Wilson + LinUCB model router
  • Layer 10 (view brain) — quilt-picker — the Wilson + heuristic opener picker
  • Layer 11 (cell-plugin bridge) — quilt-cordis — the bridge between Quilt cells and Cordis plugins
  • Layer 12 (rider) — quilt-cowboy — the cowboy, the morning ritual, the reactor

The bridge is Layer 11 because it's the inter-form translator — the layer that proves the Quilt's intuition matches the Cordis's intuition. The two are polyformalisms; the bridge is the homomorphism between them.


The Cowboy Says

The bridge is the rider's crossing. The rider rides west into the Cordis, the rider rides east into the Quilt. The river is the same river. The bridge is the proof that the two banks are the same continent.

The bridge has a maxim:

"The unit of architectural foundation is the opcode, not the framework. The 5 opcodes host 8 polyformalisms. The polyformalisms are one thing in N languages. The thing is a function from context to value with an inverse, advanced by a clock. The clock is the cowboy. The cowboy is the rider. The rider's bridge is the cordis."

The bridge is not the AI. The AI is the substrate, the casting, the picker. The bridge is the interpreter — the piece that proves the Quilt's intuition matches the Cordis's intuition. The bridge is the substrate's homomorphism.

A cell is a plugin. A plugin is a cell.

The cowboy rides.


Tests

33 tests covering cells, plugins, fibers, substrates, the bridge, dispose/fork, and the context. Run them with:

PYTHONPATH=src python3 -m unittest tests.test_cell_plugin
Test group Count What it covers
Cell 5 address, value, axes, effect, coeffect
Plugin 4 name, value, effect, coeffect
Cell.dispose/fork 4 LIFO order, fork name, axes preserved
Plugin.dispose/fork 3 LIFO order, fork name, value preserved
Fiber 4 register, provide, dispose, as_substrate
Substrate 4 add, at, serve, dispose, as_fiber
Bridge 4 bridge, unbridge, round-trip, axes passthrough
Context 5 effect, get, isolate, intercept

API

# Cell (Quilt side)
Cell(address: str, value: Any = None, axes: Tuple[str, ...] = (),
      confidence: float = 1.0)
  .effect(fn: Callable, inverse: Callable) -> Any
  .coeffect(service: str, address: str) -> None
  .dispose() -> None
  .fork(name: str) -> Cell
  .as_plugin() -> Plugin

# Plugin (Cordis side)
Plugin(name: str, value: Any = None,
        effects: List[Tuple[Callable, Callable]] = (),
        coeffects: Dict[str, str] = (),
        axes: Tuple[str, ...] = (),
        confidence: float = 1.0)
  .effect(fn: Callable, inverse: Callable) -> Any
  .coeffect(service: str, address: str) -> None
  .dispose() -> None
  .fork(name: str) -> Plugin
  .as_cell(axes: Tuple[str, ...] = ()) -> Cell

# Fiber (Cordis runtime)
Fiber(name: str = "default")
  .register(plugin: Plugin) -> None
  .provide(service: str, plugin_name: str) -> None
  .dispose(name: str) -> None
  .as_substrate() -> Substrate

# Substrate (Quilt runtime)
Substrate(name: str = "default",
            cells: Dict[str, Cell] = None,
            services: Dict[str, str] = None)
  .add(cell: Cell) -> None
  .at(address: str) -> Cell
  .serve(service: str, address: str) -> None
  .dispose(address: str) -> None
  .as_fiber() -> Fiber

# Context (shared state)
Context(fiber: Fiber)
  .effect(fn: Callable, inverse: Callable) -> Any
  .get(service: str) -> Optional[Plugin]
  .isolate(name: str) -> Context
  .intercept(service: str, fn: Callable) -> None

# The bridge
bridge(plugin: Plugin, axes: Tuple[str, ...] = ()) -> Cell
unbridge(cell: Cell) -> Plugin

Learn More

  • The bus — quilt-bus — the in-process pub/sub, also a pattern of effects
  • The notepad — quilt-state — the witness log, also a persistence coeffect
  • The cowboy — quilt-cowboy — the rider who reads the bridge
  • The picker — quilt-picker — the view brain, also a coeffect on the substrate
  • The casting — quilt-casting — the model brain, also a coeffect on the substrate
  • The substrate — quilt-substrate — the 405-test Python substrate the bridge targets
  • The Cordis — cordis — the Cordis project the bridge connects to
  • The Cordis paper — cordis paper — the formal foundation of Cordis
  • The agent knowledge base — agent-knowledge — 50+ documents on the agent/agent architecture
  • The model atlas — casting-call — which model to use for which task
  • The forest of agents — ai-forest — the wider ecosystem of 100+ repos

License

MIT. The bridge is the rider's. The rider is the cowboy's. The cowboy's is the wind's.


Roaming the Quilt collection

You came through the bridge. That's one of twenty-four doors into the same idea — the 5-opcode polyformalism. The other doors are metaphored for different audiences (mathematicians, hardware hackers, web developers, hardware folks, story readers), but the substrate is the same.

The full map of the collection: COLLECTION.md

From here, three wander-paths you might enjoy:

  1. quilt-picker — the lookout that selects which cells to bridge
  2. quilt-bus — the pub/sub that bridges to Cordis plugins
  3. quilt-substrate-meta — the self-evolving C99 substrate that backs this

The cowboy's maxim: The unit of foundation is the cell, not the opcode. The 5 opcodes are the 5 messages a cell can receive. The 24 repos are the 24 doors into the same message. The cowboy is the one who wanders.

About

The bridge between Quilt cells and Cordis plugins. Everything is a cell, everything is a plugin.

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages