certal 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +11 -0
- package/CHANGELOG.md +32 -0
- package/LICENSE +21 -0
- package/README.md +277 -2
- package/SECURITY.md +36 -0
- package/bin/certal.mjs +12 -0
- package/certal.schema.json +156 -0
- package/dist/adapters/approval-channel.d.ts +44 -0
- package/dist/adapters/approval-channel.js +74 -0
- package/dist/adapters/commands.d.ts +73 -0
- package/dist/adapters/commands.js +185 -0
- package/dist/adapters/contracts.d.ts +59 -0
- package/dist/adapters/contracts.js +1 -0
- package/dist/adapters/file-watcher.d.ts +53 -0
- package/dist/adapters/file-watcher.js +142 -0
- package/dist/adapters/in-memory.d.ts +53 -0
- package/dist/adapters/in-memory.js +165 -0
- package/dist/adapters/index.d.ts +8 -0
- package/dist/adapters/index.js +8 -0
- package/dist/adapters/manifest.d.ts +105 -0
- package/dist/adapters/manifest.js +438 -0
- package/dist/adapters/operator-auth.d.ts +47 -0
- package/dist/adapters/operator-auth.js +72 -0
- package/dist/adapters/tool-sdk.d.ts +150 -0
- package/dist/adapters/tool-sdk.js +336 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +1 -0
- package/dist/cli/main.d.ts +1 -0
- package/dist/cli/main.js +386 -0
- package/dist/kernel/common.d.ts +46 -0
- package/dist/kernel/common.js +238 -0
- package/dist/kernel/crypto.d.ts +35 -0
- package/dist/kernel/crypto.js +54 -0
- package/dist/kernel/effects.d.ts +4 -0
- package/dist/kernel/effects.js +178 -0
- package/dist/kernel/index.d.ts +9 -0
- package/dist/kernel/index.js +9 -0
- package/dist/kernel/jcs.d.ts +24 -0
- package/dist/kernel/jcs.js +93 -0
- package/dist/kernel/leases.d.ts +11 -0
- package/dist/kernel/leases.js +86 -0
- package/dist/kernel/step.d.ts +10 -0
- package/dist/kernel/step.js +967 -0
- package/dist/kernel/types.d.ts +538 -0
- package/dist/kernel/types.js +1 -0
- package/dist/kernel/undo.d.ts +4 -0
- package/dist/kernel/undo.js +180 -0
- package/dist/kernel/validation.d.ts +13 -0
- package/dist/kernel/validation.js +307 -0
- package/dist/kernel/witness.d.ts +34 -0
- package/dist/kernel/witness.js +279 -0
- package/dist/mcp/host.d.ts +141 -0
- package/dist/mcp/host.js +517 -0
- package/dist/mcp/index.d.ts +2 -0
- package/dist/mcp/index.js +2 -0
- package/dist/mcp/server.d.ts +70 -0
- package/dist/mcp/server.js +508 -0
- package/dist/runtime/dp1.d.ts +48 -0
- package/dist/runtime/dp1.js +229 -0
- package/dist/runtime/engine.d.ts +86 -0
- package/dist/runtime/engine.js +320 -0
- package/dist/runtime/index.d.ts +4 -0
- package/dist/runtime/index.js +4 -0
- package/dist/runtime/outbox.d.ts +69 -0
- package/dist/runtime/outbox.js +238 -0
- package/dist/runtime/store.d.ts +204 -0
- package/dist/runtime/store.js +746 -0
- package/package.json +91 -4
- package/presets/exchange-firewall.json +40 -0
- package/presets/sdk.json +32 -0
- package/presets/solver.json +22 -0
- package/presets/vibeops.json +34 -0
- package/skills/certal/SKILL.md +49 -0
package/package.json
CHANGED
|
@@ -1,6 +1,93 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "certal",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Deterministic execution firewall and runtime for AI agents. Zero dependencies, SQLite WAL, write-ahead outbox, human-priority undo, and Lean 4 proofs.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Paweł Olszewski",
|
|
7
|
+
"homepage": "https://github.com/polszewski-pl/certal#readme",
|
|
8
|
+
"bugs": {
|
|
9
|
+
"url": "https://github.com/polszewski-pl/certal/issues"
|
|
10
|
+
},
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/polszewski-pl/certal.git"
|
|
14
|
+
},
|
|
15
|
+
"type": "module",
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=24.0.0"
|
|
18
|
+
},
|
|
19
|
+
"bin": {
|
|
20
|
+
"certal": "bin/certal.mjs"
|
|
21
|
+
},
|
|
22
|
+
"exports": {
|
|
23
|
+
"./kernel": {
|
|
24
|
+
"types": "./dist/kernel/index.d.ts",
|
|
25
|
+
"default": "./dist/kernel/index.js"
|
|
26
|
+
},
|
|
27
|
+
"./runtime": {
|
|
28
|
+
"types": "./dist/runtime/index.d.ts",
|
|
29
|
+
"default": "./dist/runtime/index.js"
|
|
30
|
+
},
|
|
31
|
+
"./adapters": {
|
|
32
|
+
"types": "./dist/adapters/index.d.ts",
|
|
33
|
+
"default": "./dist/adapters/index.js"
|
|
34
|
+
},
|
|
35
|
+
"./mcp": {
|
|
36
|
+
"types": "./dist/mcp/index.d.ts",
|
|
37
|
+
"default": "./dist/mcp/index.js"
|
|
38
|
+
},
|
|
39
|
+
"./certal.schema.json": "./certal.schema.json",
|
|
40
|
+
"./package.json": "./package.json"
|
|
41
|
+
},
|
|
42
|
+
"files": [
|
|
43
|
+
"dist",
|
|
44
|
+
"bin",
|
|
45
|
+
"presets",
|
|
46
|
+
"skills",
|
|
47
|
+
".claude-plugin",
|
|
48
|
+
"certal.schema.json",
|
|
49
|
+
"README.md",
|
|
50
|
+
"LICENSE",
|
|
51
|
+
"CHANGELOG.md",
|
|
52
|
+
"SECURITY.md"
|
|
53
|
+
],
|
|
54
|
+
"keywords": [
|
|
55
|
+
"ai-agents",
|
|
56
|
+
"agent-runtime",
|
|
57
|
+
"execution-firewall",
|
|
58
|
+
"formal-verification",
|
|
59
|
+
"lean4",
|
|
60
|
+
"deterministic",
|
|
61
|
+
"sqlite",
|
|
62
|
+
"outbox",
|
|
63
|
+
"undo",
|
|
64
|
+
"guardrails",
|
|
65
|
+
"mcp",
|
|
66
|
+
"cli"
|
|
67
|
+
],
|
|
68
|
+
"scripts": {
|
|
69
|
+
"build": "node tools/build.mjs",
|
|
70
|
+
"typecheck": "node tools/typecheck.mjs",
|
|
71
|
+
"lint": "biome check core tools bin",
|
|
72
|
+
"test": "node --test core/tests/kernel.laws.test.ts core/tests/interleavings.bfs.test.ts core/tests/sqlite.replay.test.ts core/tests/e2e.sdk.test.ts core/tests/manifest.federation.test.ts core/tests/host.hardening.test.ts core/tests/audit.hardening.test.ts core/tests/e2e.cli-mcp.test.ts",
|
|
73
|
+
"test:laws": "node --test core/tests/kernel.laws.test.ts",
|
|
74
|
+
"test:bfs": "node --test core/tests/interleavings.bfs.test.ts",
|
|
75
|
+
"test:replay": "node --test core/tests/sqlite.replay.test.ts",
|
|
76
|
+
"test:e2e": "node --test core/tests/e2e.sdk.test.ts",
|
|
77
|
+
"test:cli": "node --test core/tests/manifest.federation.test.ts core/tests/host.hardening.test.ts core/tests/audit.hardening.test.ts core/tests/e2e.cli-mcp.test.ts",
|
|
78
|
+
"test:mutations": "node core/tests/probe.mutations.ts",
|
|
79
|
+
"test:bench": "node core/tests/bench.human-lane.ts",
|
|
80
|
+
"test:bench:cli": "node core/tests/bench.cli.ts",
|
|
81
|
+
"conformance:export": "node core/tests/export.conformance.ts .tmp-formal/vectors.jsonl",
|
|
82
|
+
"check:structure": "node tools/check-structure.mjs",
|
|
83
|
+
"check:formal": "node tools/check-formal.mjs",
|
|
84
|
+
"check": "npm run check:structure && npm run typecheck && npm test && npm run test:mutations",
|
|
85
|
+
"check:all": "npm run check && npm run check:formal",
|
|
86
|
+
"prepack": "npm run build"
|
|
87
|
+
},
|
|
88
|
+
"devDependencies": {
|
|
89
|
+
"@biomejs/biome": "2.6.9",
|
|
90
|
+
"@types/node": "^24.19.4",
|
|
91
|
+
"typescript": "^7.0.2"
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"profile": "exchange",
|
|
4
|
+
"policy": {
|
|
5
|
+
"requiredWitnessStages": ["L0", "L1"],
|
|
6
|
+
"enforceApprovalSignature": true,
|
|
7
|
+
"enforceAutonomyLadder": true,
|
|
8
|
+
"maxAttempts": 20,
|
|
9
|
+
"maxReconcileAttempts": 3,
|
|
10
|
+
"maxCostMicroUnits": 5000000
|
|
11
|
+
},
|
|
12
|
+
"scopes": [
|
|
13
|
+
{ "id": "orders", "classId": "order", "paths": ["orders/**"] },
|
|
14
|
+
{ "id": "risk", "classId": "limit", "paths": ["risk/**"] }
|
|
15
|
+
],
|
|
16
|
+
"pins": [
|
|
17
|
+
{ "id": "risk-limits-human-only", "kind": "H", "scopeId": "risk", "classId": "*", "rule": "exposure and leverage limits are set by a human" },
|
|
18
|
+
{ "id": "no-withdrawals", "kind": "H", "scopeId": "orders", "classId": "withdrawal", "rule": "agents never move funds off the venue" }
|
|
19
|
+
],
|
|
20
|
+
"tools": {
|
|
21
|
+
"place-order": {
|
|
22
|
+
"reversibility": "IRREVERSIBLE",
|
|
23
|
+
"supportsCas": true,
|
|
24
|
+
"preflightCommand": ["node", "exchange/preflight.mjs", "--max-slippage-bps", "15", "--max-book-age-ms", "500", "--max-exposure-usd", "25000", "--max-leverage", "2"],
|
|
25
|
+
"deliverCommand": ["node", "exchange/place-order.mjs"],
|
|
26
|
+
"reconcileCommand": ["node", "exchange/reconcile-order.mjs"],
|
|
27
|
+
"compensateCommand": ["node", "exchange/cancel-order.mjs"]
|
|
28
|
+
},
|
|
29
|
+
"cancel-order": {
|
|
30
|
+
"reversibility": "COMPENSABLE",
|
|
31
|
+
"supportsCas": true,
|
|
32
|
+
"deliverCommand": ["node", "exchange/cancel-order.mjs"],
|
|
33
|
+
"reconcileCommand": ["node", "exchange/reconcile-order.mjs"]
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"witness": {
|
|
37
|
+
"L0": { "command": ["node", "exchange/check-order-shape.mjs"], "budgetCpuMs": 2000, "requireNearMiss": false },
|
|
38
|
+
"L1": { "command": ["node", "exchange/check-risk.mjs"], "budgetCpuMs": 5000, "requireNearMiss": true, "nearMissProbeCommand": ["node", "exchange/check-risk-probe.mjs"] }
|
|
39
|
+
}
|
|
40
|
+
}
|
package/presets/sdk.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"profile": "sdk",
|
|
4
|
+
"policy": {
|
|
5
|
+
"requiredWitnessStages": [
|
|
6
|
+
"L0"
|
|
7
|
+
]
|
|
8
|
+
},
|
|
9
|
+
"scopes": [
|
|
10
|
+
{
|
|
11
|
+
"id": "workspace",
|
|
12
|
+
"classId": "file",
|
|
13
|
+
"paths": [
|
|
14
|
+
"**"
|
|
15
|
+
]
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"pins": [],
|
|
19
|
+
"tools": {
|
|
20
|
+
"edit": {
|
|
21
|
+
"reversibility": "REVERSIBLE",
|
|
22
|
+
"supportsCas": false
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"witness": {
|
|
26
|
+
"L0": {
|
|
27
|
+
"builtin": "accept",
|
|
28
|
+
"budgetCpuMs": 1000,
|
|
29
|
+
"requireNearMiss": false
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"profile": "solver",
|
|
4
|
+
"policy": {
|
|
5
|
+
"requiredWitnessStages": ["L0", "L1"],
|
|
6
|
+
"minImprovementMicroUnits": 1,
|
|
7
|
+
"maxAttempts": 50
|
|
8
|
+
},
|
|
9
|
+
"scopes": [
|
|
10
|
+
{ "id": "plan", "classId": "assignment", "paths": ["plans/**"] }
|
|
11
|
+
],
|
|
12
|
+
"pins": [
|
|
13
|
+
{ "id": "frozen-constraints", "kind": "H", "scopeId": "plan", "classId": "constraint", "rule": "hard constraints of the model are set by a human" }
|
|
14
|
+
],
|
|
15
|
+
"tools": {
|
|
16
|
+
"solver": { "reversibility": "REVERSIBLE", "supportsCas": false }
|
|
17
|
+
},
|
|
18
|
+
"witness": {
|
|
19
|
+
"L0": { "command": ["node", "checks/feasible.mjs"], "budgetCpuMs": 5000, "requireNearMiss": false },
|
|
20
|
+
"L1": { "command": ["node", "checks/objective.mjs"], "budgetCpuMs": 20000, "requireNearMiss": true, "nearMissProbeCommand": ["node", "checks/objective-probe.mjs"] }
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"profile": "vibeops",
|
|
4
|
+
"policy": {
|
|
5
|
+
"requiredWitnessStages": ["L0", "L1", "L2"],
|
|
6
|
+
"enforceApprovalSignature": true,
|
|
7
|
+
"maxAttempts": 40
|
|
8
|
+
},
|
|
9
|
+
"scopes": [
|
|
10
|
+
{ "id": "frontend", "classId": "file", "paths": ["src/**", "app/**", "public/**"] },
|
|
11
|
+
{ "id": "database", "classId": "migration", "paths": ["migrations/**", "supabase/migrations/**"] },
|
|
12
|
+
{ "id": "access", "classId": "rls", "paths": ["policies/**", "supabase/policies/**"] }
|
|
13
|
+
],
|
|
14
|
+
"pins": [
|
|
15
|
+
{ "id": "rls-human-only", "kind": "H", "scopeId": "access", "classId": "*", "rule": "row level security policies are changed by a human" },
|
|
16
|
+
{ "id": "destructive-migrations", "kind": "H", "scopeId": "database", "classId": "destructive", "rule": "DROP and TRUNCATE migrations are written by a human" }
|
|
17
|
+
],
|
|
18
|
+
"tools": {
|
|
19
|
+
"edit": { "reversibility": "REVERSIBLE", "supportsCas": false },
|
|
20
|
+
"migrate": {
|
|
21
|
+
"reversibility": "IRREVERSIBLE",
|
|
22
|
+
"supportsCas": false,
|
|
23
|
+
"preflightCommand": ["node", "ops/migration-preflight.mjs"],
|
|
24
|
+
"deliverCommand": ["node", "ops/apply-migration.mjs"],
|
|
25
|
+
"reconcileCommand": ["node", "ops/migration-status.mjs"]
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"witness": {
|
|
29
|
+
"L0": { "command": ["npm", "run", "typecheck", "--silent"], "budgetCpuMs": 120000, "requireNearMiss": false },
|
|
30
|
+
"L1": { "command": ["npx", "--no-install", "playwright", "test", "--reporter=line"], "budgetCpuMs": 600000, "requireNearMiss": false },
|
|
31
|
+
"L2": { "command": ["node", "ops/check-accessibility-and-copy.mjs"], "budgetCpuMs": 120000, "requireNearMiss": true, "nearMissProbeCommand": ["node", "ops/check-accessibility-probe.mjs"] }
|
|
32
|
+
},
|
|
33
|
+
"watch": true
|
|
34
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: certal
|
|
3
|
+
description: Use when the project has a certal.json manifest or the certal MCP tools are available. Explains how to change files and call external tools through the Certal gate (lease, propose, finalize) and what to do on PAUSE, REJECT and HALT.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Working through the Certal gate
|
|
7
|
+
|
|
8
|
+
This project runs behind Certal. Every change goes through the Certal MCP tools. The gate decides, you follow the answer.
|
|
9
|
+
|
|
10
|
+
## The loop
|
|
11
|
+
|
|
12
|
+
1. `certal_lease_acquire { scopeId }`. Take a lease on a scope that the manifest declares. Keep the `attemptId` from the answer.
|
|
13
|
+
2. `certal_propose_batch { attemptId, toolId, ops }`. Describe the change before anything happens. One op is one field of one object: `{ objectId, field, value }`. Every object must belong to the leased scope.
|
|
14
|
+
3. `certal_finalize_batch { attemptId }`. Close the batch.
|
|
15
|
+
|
|
16
|
+
What happens next depends on the tool. Read `certal.json` to see which case you are in.
|
|
17
|
+
|
|
18
|
+
**The tool has a `deliverCommand` (effect mode).** Put the call in the op as `effect: { key, payload }`. Certal checks the proposal and sends the effect through its outbox after the finalize answers `ALLOW`. You never call that system or write that target yourself.
|
|
19
|
+
|
|
20
|
+
**The scope has `paths` (file mode).** For each file, use the relative path as `objectId`, `sha256` as `field` and the SHA-256 hash of the new content as `value`. Write the file only after the finalize answers `ALLOW`, with exactly the content you declared. The checks in step 2 see your declaration, not the file, because the file is not written yet.
|
|
21
|
+
|
|
22
|
+
## Reading an answer
|
|
23
|
+
|
|
24
|
+
Every answer has the same six fields:
|
|
25
|
+
|
|
26
|
+
```json
|
|
27
|
+
{ "decision": "ALLOW", "reason": "BATCH_FINALIZED", "scopeId": "frontend", "scopeEpoch": 4, "nextLegalAction": "done", "retryable": false }
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Do what `nextLegalAction` says.
|
|
31
|
+
|
|
32
|
+
| decision | What it means | What you do |
|
|
33
|
+
|---|---|---|
|
|
34
|
+
| `ALLOW` | The step passed. | Go to `nextLegalAction`. |
|
|
35
|
+
| `PAUSE` with `wait_for_operator_approval` | A human must approve this batch. | Tell the user the `attemptId`. They run `certal approve <attemptId>`. Then call `certal_finalize_batch` again. |
|
|
36
|
+
| `PAUSE` with `stop_and_ask_operator` | A budget ran out or the operator paused the task. | Stop and report. |
|
|
37
|
+
| `REJECT` with `certal_lease_acquire` | Your view of the scope is stale. A human or another agent changed it. | Read the current content again, take a new lease and propose again. |
|
|
38
|
+
| `REJECT` with `stop` | A pin or a rule forbids the change, or the scope or object is not yours to change. | Stop and report the `reason`. Do not look for another way in. |
|
|
39
|
+
| `HALT` | The task is halted. Only a human reset clears it. | Stop. |
|
|
40
|
+
|
|
41
|
+
## Rules
|
|
42
|
+
|
|
43
|
+
- In file mode, never write a file in a declared scope before the finalize answers `ALLOW`, and never write content other than you declared. Such a write is recorded as a human edit and invalidates your own lease.
|
|
44
|
+
- In effect mode, never touch the target yourself. Certal delivers the effect.
|
|
45
|
+
- Use plain relative paths. An absolute path, a `..` segment or an object of another scope is refused with `OBJECT_OUT_OF_SCOPE`.
|
|
46
|
+
- Never retry when `retryable` is `false`.
|
|
47
|
+
- You have no tool to approve, reset, undo or change pins. Those belong to the operator. If you need one, ask the user.
|
|
48
|
+
- A human edit always wins. When a scope epoch rises under you, your attempt is stale: start again from the current state.
|
|
49
|
+
- `certal_status` shows scope epochs, leases, autonomy tiers and attempts that wait for approval. Call it when you are unsure where you stand.
|