CoCo — The Constitutional Controller
Resin reasoning · ProMis mission design · CoFi tracking · CoCo control
The Constitutional Controller: Doubt-Calibrated Steering of Compliant Agents
Simon Kohaut, Felix Divo, Navid Hamid, Benedict Flade, Julian Eggert, Devendra Singh Dhami, Kristian Kersting
Paper · Project Page · Citation
CoCo couples low-level motion control with probabilistic logic by learning a self-doubt density, a Conditional Normalizing Flow that models an agent's control inaccuracies as a function of its operating conditions (e.g. velocity, heading). This doubt distribution is folded into a ProMis compliance landscape at query time, producing a doubt-calibrated landscape that accounts for where the agent will actually end up, not just where it intends to go.
The rules behind the landscape are written in Resin; see its language reference for their syntax and semantics. Paths can then be evaluated or steered to remain constitutionally compliant even under uncertainty. Since CoCo steers agents by a known constitution, other agents can rely on it: CoFi tracks the drones above from coarse, noisy observations by trusting them to follow the very same rules.
Installation
pip install python-coco
To install from source:
git clone https://github.com/simon-kohaut/CoCo
cd CoCo
pip install -e .
Quick Start
1. Learn a doubt density
import torch
from coco import DoubtDensity
# Control errors in meters, which grow with the velocity the agent flies at
velocity = torch.rand(2_000, 1) # m/s
errors = torch.randn(2_000, 2) * (0.05 + 0.2 * velocity)
# The doubt space: the features that condition the agent's inaccuracies
doubt_space = {"velocity": {"type": "continuous", "values": velocity}}
density = DoubtDensity(doubt_space, number_of_states=2, number_of_hidden_features=32, number_of_layers=4)
losses = density.fit(errors, doubt_space, number_of_epochs=20, batch_size=64)
density.save("doubt_density.pkl")
2. Compute where the agent is allowed to be
import time
import numpy as np
from promis import ProMis, StaRMap
from promis.geo import CartesianMap, CartesianPolygon, CartesianRasterBand, PolarLocation
# The constitution: stay off the obstacle
constitution = """
over(obstacle) <- source("/star_map/over/obstacle", Probability).
landscape if not over(obstacle).
landscape -> target("/landscape").
"""
# A 2 m x 1 m obstacle in a 10 m x 10 m area
obstacle = CartesianPolygon.from_numpy(np.array([[-1, 1, 1, -1], [-0.5, -0.5, 0.5, 0.5]]), location_type="obstacle")
area = CartesianMap(PolarLocation(0, 0), {"obstacle": [obstacle]})
points = CartesianRasterBand(PolarLocation(0, 0), (50, 50), 10, 10)
star_map = StaRMap(area)
star_map.initialize(points, number_of_random_maps=1, logic=constitution)
promis = ProMis(star_map, constitution, 50 * 50)
promis.initialize(points)
time.sleep(0.05) # Resin's writers deliver values asynchronously
landscape = promis.update()
3. Apply doubt to the landscape
from coco import ConstitutionalController, DoubtDensity
density = DoubtDensity.load("doubt_density.pkl")
controller = ConstitutionalController()
# Where the agent may go when flying at 1 m/s, given where its controller will actually take it
query = {"velocity": {"type": "continuous", "values": torch.tensor([[1.0]])}}
doubtful_landscape = controller.apply_doubt(landscape, density, query, number_of_samples=100, scaler=1.0)
The doubtful landscape spreads each obstacle by where the controller may actually take the agent; scaler converts the doubt's units to the landscape's.
4. Evaluate path compliance
# A path passing 30 cm above the obstacle, as (T, 2) positions in meters
path = np.stack([np.linspace(-3, 3, 13), np.full(13, 0.8)]).T
compliance = controller.compliance(path, landscape, density, query, number_of_samples=500)
# compliance: (T,) probability of complying at each waypoint
Citation
If you use CoCo, please cite the paper below. CoCo builds on ProMis.
@inproceedings{kohaut2026coco,
title = {The Constitutional Controller: Doubt-Calibrated Steering of Compliant Agents},
author = {Kohaut, Simon and Divo, Felix and Hamid, Navid and Flade, Benedict
and Eggert, Julian and Dhami, Devendra Singh and Kersting, Kristian},
booktitle = {Proceedings of the IEEE/RSJ International Conference on Intelligent
Robots and Systems (IROS)},
year = {2026}
}
Metadata
Release files for python-coco 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| python_coco-0.0.1.tar.gz | 7.7 kB | With provenance | Details for python_coco-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| python_coco-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for python_coco-0.0.1-py3-none-any.whl |
Total release size: 15.7 kB
Release files / python_coco-0.0.1.tar.gz
| Download URL | python_coco-0.0.1.tar.gz |
|---|---|
| Size | 7.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
70221d54745fa8c82ac9c9cc900ec375431b9a36a26a8f84d9a648688e337145
|
|
BLAKE2b-256 checksum How to use checksums |
68cbe48e91e1f030b0feb2e392bf957d83f551cda5c64738d4449e998169435d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.
Transparency logRelease files / python_coco-0.0.1-py3-none-any.whl
| Download URL | python_coco-0.0.1-py3-none-any.whl |
|---|---|
| Size | 8.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e250d802d8b2d11833b48b741d434cd86a325785aa9ef8442abea3f6503ffbdd
|
|
BLAKE2b-256 checksum How to use checksums |
c1ba55f4a0ddeb88a4c2dfba529600a5ab80b76ef002ef43b9a390f432d31698
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.
Transparency logSecurity for python-coco 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for python_coco-0.0.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 21, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.