Concepts

Policy and MIR

Compile strict JSON or a C builder into the same canonical policy representation.

JSON source

CODE
{
  "version": 2,
  "filesystem": {
    "read": ["/usr", "/workspace"],
    "write": ["/workspace/build"],
    "deny": ["/workspace/.env"]
  },
  "network": {
    "mode": "mediated",
    "allow": [
      { "protocol": "tcp", "host": "github.com", "port": 443 }
    ]
  },
  "process": { "confinementRequired": true }
}

The JSON is a strict source format. Unknown keys, invalid ports, non-canonical destinations and contradictory rules are rejected. It is not passed to a backend.

Canonical MIR

MIR means Maelys Intermediate Representation. It contains resolved decisions, never policy rules such as “allow when trusted”. Producers normalize, sort, deduplicate and encode; consumers verify that the received bytes are already canonical.

CODE
JSON / C builder / Datalog
            │ decide + normalize

      canonical MIR bytes
            │ validate, never reinterpret

      Maelys Sandbox Policy

The MIR digest covers filesystem rules, network mode and each mediated destination. Two semantically equal inputs produce the same canonical identity.

In-memory compilation

CODE
maelys_mir_builder_t *builder = NULL;
maelys_mir_builder_create(&builder, &error);
maelys_mir_builder_allow_fs_read(builder, "/workspace", &error);
maelys_mir_builder_allow_fs_write(builder, "/workspace/build", &error);
maelys_mir_builder_allow_tcp(builder, "github.com", 443, &error);
maelys_mir_builder_build(builder, &mir, &error);

No JSON or MIR file is required. Serialization is useful for review, caching and reproducibility, not for runtime correctness.