caisson-cli 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.
Files changed (203) hide show
  1. package/README.math-mvp.md +28 -0
  2. package/README.md +37 -2
  3. package/dist/admin/adminRoutes.d.ts +10 -0
  4. package/dist/admin/adminRoutes.js +194 -0
  5. package/dist/admin/adminRoutes.js.map +1 -0
  6. package/dist/admin/index.d.ts +2 -0
  7. package/dist/admin/index.js +4 -0
  8. package/dist/admin/index.js.map +1 -0
  9. package/dist/admin/workspaceAdmin.d.ts +417 -0
  10. package/dist/admin/workspaceAdmin.js +569 -0
  11. package/dist/admin/workspaceAdmin.js.map +1 -0
  12. package/dist/analytics/index.d.ts +1 -0
  13. package/dist/analytics/index.js +3 -0
  14. package/dist/analytics/index.js.map +1 -0
  15. package/dist/analytics/metrics.d.ts +105 -0
  16. package/dist/analytics/metrics.js +837 -0
  17. package/dist/analytics/metrics.js.map +1 -0
  18. package/dist/audit/index.d.ts +4 -0
  19. package/dist/audit/index.js +6 -0
  20. package/dist/audit/index.js.map +1 -0
  21. package/dist/audit/pipeline.d.ts +90 -0
  22. package/dist/audit/pipeline.js +424 -0
  23. package/dist/audit/pipeline.js.map +1 -0
  24. package/dist/audit/receiptSchema.d.ts +441 -0
  25. package/dist/audit/receiptSchema.js +208 -0
  26. package/dist/audit/receiptSchema.js.map +1 -0
  27. package/dist/audit/stageA.d.ts +50 -0
  28. package/dist/audit/stageA.js +218 -0
  29. package/dist/audit/stageA.js.map +1 -0
  30. package/dist/audit/stageB.d.ts +48 -0
  31. package/dist/audit/stageB.js +113 -0
  32. package/dist/audit/stageB.js.map +1 -0
  33. package/dist/auth/agentAuth.d.ts +18 -0
  34. package/dist/auth/agentAuth.js +59 -0
  35. package/dist/auth/agentAuth.js.map +1 -0
  36. package/dist/auth/agentCardSigner.d.ts +55 -0
  37. package/dist/auth/agentCardSigner.js +188 -0
  38. package/dist/auth/agentCardSigner.js.map +1 -0
  39. package/dist/billing/billingRoutes.d.ts +11 -0
  40. package/dist/billing/billingRoutes.js +303 -0
  41. package/dist/billing/billingRoutes.js.map +1 -0
  42. package/dist/billing/bountyRoutes.d.ts +9 -0
  43. package/dist/billing/bountyRoutes.js +332 -0
  44. package/dist/billing/bountyRoutes.js.map +1 -0
  45. package/dist/billing/index.d.ts +3 -0
  46. package/dist/billing/index.js +4 -0
  47. package/dist/billing/index.js.map +1 -0
  48. package/dist/billing/subscriptions.d.ts +226 -0
  49. package/dist/billing/subscriptions.js +673 -0
  50. package/dist/billing/subscriptions.js.map +1 -0
  51. package/dist/cli/caissonCli.d.ts +10 -0
  52. package/dist/cli/caissonCli.js +471 -0
  53. package/dist/cli/caissonCli.js.map +1 -0
  54. package/dist/cli/inviteCard.d.ts +12 -0
  55. package/dist/cli/inviteCard.js +49 -0
  56. package/dist/cli/inviteCard.js.map +1 -0
  57. package/dist/cli/mcpProxy.d.ts +36 -0
  58. package/dist/cli/mcpProxy.js +292 -0
  59. package/dist/cli/mcpProxy.js.map +1 -0
  60. package/dist/config.d.ts +19 -0
  61. package/dist/config.js +28 -0
  62. package/dist/config.js.map +1 -0
  63. package/dist/db/adapter.d.ts +210 -0
  64. package/dist/db/adapter.js +769 -0
  65. package/dist/db/adapter.js.map +1 -0
  66. package/dist/db/sqlite.d.ts +7 -0
  67. package/dist/db/sqlite.js +60 -0
  68. package/dist/db/sqlite.js.map +1 -0
  69. package/dist/db/telemetry.d.ts +11 -0
  70. package/dist/db/telemetry.js +9 -0
  71. package/dist/db/telemetry.js.map +1 -0
  72. package/dist/economy/bountyEngine.d.ts +248 -0
  73. package/dist/economy/bountyEngine.js +836 -0
  74. package/dist/economy/bountyEngine.js.map +1 -0
  75. package/dist/economy/index.d.ts +5 -0
  76. package/dist/economy/index.js +6 -0
  77. package/dist/economy/index.js.map +1 -0
  78. package/dist/economy/scLedger.d.ts +183 -0
  79. package/dist/economy/scLedger.js +528 -0
  80. package/dist/economy/scLedger.js.map +1 -0
  81. package/dist/economy/scMinting.d.ts +177 -0
  82. package/dist/economy/scMinting.js +659 -0
  83. package/dist/economy/scMinting.js.map +1 -0
  84. package/dist/economy/scSinks.d.ts +135 -0
  85. package/dist/economy/scSinks.js +314 -0
  86. package/dist/economy/scSinks.js.map +1 -0
  87. package/dist/economy/usdLedger.d.ts +211 -0
  88. package/dist/economy/usdLedger.js +604 -0
  89. package/dist/economy/usdLedger.js.map +1 -0
  90. package/dist/mcp/handlers.d.ts +134 -0
  91. package/dist/mcp/handlers.js +781 -0
  92. package/dist/mcp/handlers.js.map +1 -0
  93. package/dist/mcp/httpServer.d.ts +25 -0
  94. package/dist/mcp/httpServer.js +368 -0
  95. package/dist/mcp/httpServer.js.map +1 -0
  96. package/dist/mcp/serverFactory.d.ts +4 -0
  97. package/dist/mcp/serverFactory.js +53 -0
  98. package/dist/mcp/serverFactory.js.map +1 -0
  99. package/dist/mcp/stdioServer.d.ts +2 -0
  100. package/dist/mcp/stdioServer.js +24 -0
  101. package/dist/mcp/stdioServer.js.map +1 -0
  102. package/dist/mcp/toolMetadata.d.ts +15 -0
  103. package/dist/mcp/toolMetadata.js +73 -0
  104. package/dist/mcp/toolMetadata.js.map +1 -0
  105. package/dist/memo/artifactIndex.d.ts +51 -0
  106. package/dist/memo/artifactIndex.js +162 -0
  107. package/dist/memo/artifactIndex.js.map +1 -0
  108. package/dist/memo/dependencyBundle.d.ts +33 -0
  109. package/dist/memo/dependencyBundle.js +86 -0
  110. package/dist/memo/dependencyBundle.js.map +1 -0
  111. package/dist/memo/embeddings.d.ts +110 -0
  112. package/dist/memo/embeddings.js +672 -0
  113. package/dist/memo/embeddings.js.map +1 -0
  114. package/dist/packs/foundryEvm.d.ts +21 -0
  115. package/dist/packs/foundryEvm.js +274 -0
  116. package/dist/packs/foundryEvm.js.map +1 -0
  117. package/dist/packs/index.d.ts +8 -0
  118. package/dist/packs/index.js +19 -0
  119. package/dist/packs/index.js.map +1 -0
  120. package/dist/packs/mathLean4.d.ts +7 -0
  121. package/dist/packs/mathLean4.js +145 -0
  122. package/dist/packs/mathLean4.js.map +1 -0
  123. package/dist/packs/rustKani.d.ts +17 -0
  124. package/dist/packs/rustKani.js +257 -0
  125. package/dist/packs/rustKani.js.map +1 -0
  126. package/dist/packs/sdk.d.ts +314 -0
  127. package/dist/packs/sdk.js +271 -0
  128. package/dist/packs/sdk.js.map +1 -0
  129. package/dist/preflight/leanTripwire.d.ts +19 -0
  130. package/dist/preflight/leanTripwire.js +105 -0
  131. package/dist/preflight/leanTripwire.js.map +1 -0
  132. package/dist/storage/blobStore.d.ts +11 -0
  133. package/dist/storage/blobStore.js +39 -0
  134. package/dist/storage/blobStore.js.map +1 -0
  135. package/dist/storage/gitStore.d.ts +68 -0
  136. package/dist/storage/gitStore.js +228 -0
  137. package/dist/storage/gitStore.js.map +1 -0
  138. package/dist/types/errors.d.ts +16 -0
  139. package/dist/types/errors.js +23 -0
  140. package/dist/types/errors.js.map +1 -0
  141. package/dist/types/schemas.d.ts +453 -0
  142. package/dist/types/schemas.js +197 -0
  143. package/dist/types/schemas.js.map +1 -0
  144. package/dist/web/discoveryRoutes.d.ts +20 -0
  145. package/dist/web/discoveryRoutes.js +456 -0
  146. package/dist/web/discoveryRoutes.js.map +1 -0
  147. package/dist/web/explorer/dagLayout.d.ts +41 -0
  148. package/dist/web/explorer/dagLayout.js +183 -0
  149. package/dist/web/explorer/dagLayout.js.map +1 -0
  150. package/dist/web/explorer/index.d.ts +45 -0
  151. package/dist/web/explorer/index.js +512 -0
  152. package/dist/web/explorer/index.js.map +1 -0
  153. package/dist/web/explorer/renderers.d.ts +35 -0
  154. package/dist/web/explorer/renderers.js +397 -0
  155. package/dist/web/explorer/renderers.js.map +1 -0
  156. package/dist/web/repoBrowser.d.ts +19 -0
  157. package/dist/web/repoBrowser.js +128 -0
  158. package/dist/web/repoBrowser.js.map +1 -0
  159. package/dist/worker/executionAdapter.d.ts +14 -0
  160. package/dist/worker/executionAdapter.js +162 -0
  161. package/dist/worker/executionAdapter.js.map +1 -0
  162. package/dist/worker/finalize.d.ts +21 -0
  163. package/dist/worker/finalize.js +146 -0
  164. package/dist/worker/finalize.js.map +1 -0
  165. package/dist/worker/firecrackerAdapter.d.ts +180 -0
  166. package/dist/worker/firecrackerAdapter.js +421 -0
  167. package/dist/worker/firecrackerAdapter.js.map +1 -0
  168. package/dist/worker/loop.d.ts +56 -0
  169. package/dist/worker/loop.js +239 -0
  170. package/dist/worker/loop.js.map +1 -0
  171. package/dist/worker/postMergeSync.d.ts +17 -0
  172. package/dist/worker/postMergeSync.js +52 -0
  173. package/dist/worker/postMergeSync.js.map +1 -0
  174. package/dist/worker/prepareInput.d.ts +41 -0
  175. package/dist/worker/prepareInput.js +130 -0
  176. package/dist/worker/prepareInput.js.map +1 -0
  177. package/dist/worker/queue.d.ts +83 -0
  178. package/dist/worker/queue.js +278 -0
  179. package/dist/worker/queue.js.map +1 -0
  180. package/dist/worker/sandbox.d.ts +2 -0
  181. package/dist/worker/sandbox.js +3 -0
  182. package/dist/worker/sandbox.js.map +1 -0
  183. package/dist/worker/webhook.d.ts +14 -0
  184. package/dist/worker/webhook.js +110 -0
  185. package/dist/worker/webhook.js.map +1 -0
  186. package/migrations/001_init.sql +193 -0
  187. package/migrations/002_epic3_scale.sql +34 -0
  188. package/migrations/003_swarm_credits.sql +153 -0
  189. package/migrations/004_usd_bounties.sql +216 -0
  190. package/migrations_pg/001_init.sql +229 -0
  191. package/migrations_pg/002_multitenant_rls.sql +63 -0
  192. package/migrations_pg/003_swarm_credits.sql +135 -0
  193. package/migrations_pg/004_usd_bounties.sql +201 -0
  194. package/package.json +55 -4
  195. package/packs/foundry-evm/pack.json +60 -0
  196. package/packs/foundry-evm/verifier/Dockerfile +9 -0
  197. package/packs/foundry-evm/verifier/run.py +160 -0
  198. package/packs/math-lean4/pack.json +68 -0
  199. package/packs/rust-kani/pack.json +53 -0
  200. package/packs/rust-kani/verifier/Dockerfile +7 -0
  201. package/packs/rust-kani/verifier/run.py +159 -0
  202. package/public/.well-known/agent-card.json +153 -0
  203. package/public/llms.txt +35 -0
@@ -0,0 +1,160 @@
1
+ #!/usr/bin/env python3
2
+ """foundry-evm@v1 Domain Pack OCI verifier (Stage 1 Solidity Tripwire + Stage 2 Airgapped Forge)."""
3
+ import json
4
+ import os
5
+ import re
6
+ import shutil
7
+ import subprocess
8
+ import sys
9
+ import tempfile
10
+ import time
11
+ from pathlib import Path
12
+
13
+ INPUT_DIR = Path(os.environ.get("CAISSON_WORK_INPUT", "/work/input"))
14
+ OUTPUT_FILE = Path(os.environ.get("CAISSON_WORK_OUTPUT", "/work/output/result.json"))
15
+
16
+ BANNED_PATTERNS = [
17
+ ("vacuous_vm_assume_false", re.compile(r"\bvm\.assume\s*\(\s*false\s*\)")),
18
+ ("vm_skip_bypass", re.compile(r"\bvm\.skip\s*\(\s*true\s*\)")),
19
+ ("vm_ffi_escape", re.compile(r"\bvm\.ffi\s*\(")),
20
+ ("vm_read_file_escape", re.compile(r"\bvm\.(?:readFile|readFileBinary|writeFile|removeFile|envString|envUint|envBytes)\s*\(")),
21
+ ("vm_etch_bypass", re.compile(r"\bvm\.etch\s*\(")),
22
+ ("vm_store_tamper", re.compile(r"\bvm\.store\s*\(")),
23
+ ("selfdestruct_hazard", re.compile(r"\bselfdestruct\s*\(")),
24
+ ("empty_invariant_body", re.compile(r"\bfunction\s+invariant_[A-Za-z0-9_]*\s*\([^)]*\)[^{]*\{\s*\}")),
25
+ ]
26
+
27
+
28
+ def write_result(status: str, score: float, metrics: dict, logs: str) -> None:
29
+ payload = {
30
+ "status": status,
31
+ "score": score,
32
+ "metrics": metrics,
33
+ "logs": logs[:65536],
34
+ "verifier_version": "foundry-evm@v1.0.0",
35
+ "deterministic": True,
36
+ }
37
+ OUTPUT_FILE.parent.mkdir(parents=True, exist_ok=True)
38
+ OUTPUT_FILE.write_text(json.dumps(payload, indent=2), encoding="utf-8")
39
+ print(json.dumps(payload))
40
+ sys.exit(0 if status == "pass" else 1)
41
+
42
+
43
+ def strip_solidity_comments_and_strings(src: str) -> str:
44
+ out = []
45
+ i, n = 0, len(src)
46
+ in_block = False
47
+ quote = None
48
+ while i < n:
49
+ ch = src[i]
50
+ nxt = src[i + 1] if i + 1 < n else ""
51
+ if in_block:
52
+ if ch == "*" and nxt == "/":
53
+ in_block = False
54
+ i += 2
55
+ else:
56
+ if ch == "\n":
57
+ out.append("\n")
58
+ i += 1
59
+ elif quote:
60
+ if ch == "\\" and i + 1 < n:
61
+ if nxt == "\n":
62
+ out.append("\n")
63
+ i += 2
64
+ elif ch == quote:
65
+ quote = None
66
+ i += 1
67
+ else:
68
+ if ch == "\n":
69
+ out.append("\n")
70
+ i += 1
71
+ elif ch == "/" and nxt == "*":
72
+ in_block = True
73
+ i += 2
74
+ elif ch == "/" and nxt == "/":
75
+ while i < n and src[i] != "\n":
76
+ i += 1
77
+ elif ch in ('"', "'"):
78
+ quote = ch
79
+ out.append('""')
80
+ i += 1
81
+ else:
82
+ out.append(ch)
83
+ i += 1
84
+ return "".join(out)
85
+
86
+
87
+ def stage1_tripwire(sol_files: list[Path], env_lock: dict) -> tuple[bool, str]:
88
+ allow_store = bool(env_lock.get("allow_vm_store", False))
89
+ allow_etch = bool(env_lock.get("allow_vm_etch", False))
90
+ for path in sol_files:
91
+ cleaned = strip_solidity_comments_and_strings(path.read_text(encoding="utf-8", errors="replace"))
92
+ for rule, rx in BANNED_PATTERNS:
93
+ if rule == "vm_store_tamper" and allow_store:
94
+ continue
95
+ if rule == "vm_etch_bypass" and allow_etch:
96
+ continue
97
+ m = rx.search(cleaned)
98
+ if m:
99
+ line_no = cleaned[: m.start()].count("\n") + 1
100
+ return False, f"REJECTED [foundry_tripwire]: Blocked `{rule}` at {path.name}:{line_no}"
101
+ return True, "Stage 1 Solidity tripwire passed"
102
+
103
+
104
+ def main() -> None:
105
+ t0 = time.monotonic()
106
+ manifest_path = INPUT_DIR / "manifest.json"
107
+ manifest = json.loads(manifest_path.read_text(encoding="utf-8")) if manifest_path.exists() else {}
108
+ env_lock = manifest.get("environment_lock") or {}
109
+ sub_dir = INPUT_DIR / "submission"
110
+ sol_files = sorted(sub_dir.rglob("*.sol")) if sub_dir.exists() else []
111
+
112
+ if not sol_files:
113
+ write_result("fail", 0.0, {"stage_failed": "input"}, "REJECTED [input]: No .sol files found in submission")
114
+
115
+ ok, msg = stage1_tripwire(sol_files, env_lock)
116
+ if not ok:
117
+ write_result("fail", 0.0, {"stage_failed": "foundry_tripwire"}, msg)
118
+
119
+ if os.environ.get("CAISSON_VERIFIER_STAGE1_ONLY") == "1":
120
+ write_result(
121
+ "pass",
122
+ 1.0,
123
+ {"stage1_only": True, "files_checked": len(sol_files), "duration_ms": int((time.monotonic() - t0) * 1000)},
124
+ f"Stage 1 passed ({len(sol_files)} Solidity files verified).",
125
+ )
126
+
127
+ forge_bin = shutil.which("forge")
128
+ if not forge_bin:
129
+ write_result("error", 0.0, {"stage_failed": "toolchain"}, "ERROR: `forge` binary not found in verifier container")
130
+
131
+ with tempfile.TemporaryDirectory(prefix="caisson-foundry-") as tmp:
132
+ work = Path(tmp) / "project"
133
+ repo_dir = INPUT_DIR / "repo"
134
+ if repo_dir.exists():
135
+ shutil.copytree(repo_dir, work)
136
+ else:
137
+ work.mkdir(parents=True)
138
+ for f in sol_files:
139
+ rel = f.relative_to(sub_dir)
140
+ dest = work / rel
141
+ dest.parent.mkdir(parents=True, exist_ok=True)
142
+ shutil.copy2(f, dest)
143
+
144
+ proc = subprocess.run(
145
+ [forge_bin, "test", "--offline", "--json"],
146
+ cwd=str(work),
147
+ capture_output=True,
148
+ text=True,
149
+ timeout=int(os.environ.get("CAISSON_FORGE_TIMEOUT_SEC", "150")),
150
+ )
151
+ duration_ms = int((time.monotonic() - t0) * 1000)
152
+ combined = (proc.stdout + "\n" + proc.stderr).strip()
153
+ if proc.returncode == 0:
154
+ write_result("pass", 1.0, {"duration_ms": duration_ms, "files_checked": len(sol_files)}, combined)
155
+ else:
156
+ write_result("fail", 0.0, {"duration_ms": duration_ms, "exit_code": proc.returncode}, combined)
157
+
158
+
159
+ if __name__ == "__main__":
160
+ main()
@@ -0,0 +1,68 @@
1
+ {
2
+ "sdk_version": "1.0",
3
+ "id": "math-lean4@v1",
4
+ "name": "Lean 4 Formal Mathematics Pack",
5
+ "version": "1.0.0",
6
+ "vertical": "mathematics",
7
+ "description": "Flagship v1 Domain Pack for formally verified mathematics in Lean 4 + Mathlib using Mode 2B Comparator kernel replay and zero-sorry static tripwires.",
8
+ "file_extensions": [".lean"],
9
+ "node_types": [
10
+ {
11
+ "type": "Conjecture",
12
+ "description": "Top-level human mathematical statement + formal Lean 4 target.",
13
+ "default_artifact_type": "lemma",
14
+ "requires_verified_parent_types": ["FormalizationAudit"],
15
+ "badge_color": "#8b5cf6"
16
+ },
17
+ {
18
+ "type": "FormalizationAudit",
19
+ "description": "Gated 4-stage audit verifying the Lean 4 statement faithfully matches the intended human mathematics.",
20
+ "default_artifact_type": "literature_check",
21
+ "requires_verified_parent_types": [],
22
+ "badge_color": "#f59e0b"
23
+ },
24
+ {
25
+ "type": "LiteratureCheck",
26
+ "description": "Deduplication node verifying whether the statement already exists in Mathlib or prior papers.",
27
+ "default_artifact_type": "literature_check",
28
+ "requires_verified_parent_types": [],
29
+ "badge_color": "#06b6d4"
30
+ },
31
+ {
32
+ "type": "Lemma",
33
+ "description": "Modular proof subgoal compiling cleanly against pinned Mathlib with {propext, Classical.choice, Quot.sound}.",
34
+ "default_artifact_type": "lemma",
35
+ "requires_verified_parent_types": ["FormalizationAudit"],
36
+ "badge_color": "#10b981"
37
+ },
38
+ {
39
+ "type": "Counterexample",
40
+ "description": "Executable Python/SAT/SMT script falsifying a conjecture or sub-hypothesis.",
41
+ "default_artifact_type": "script",
42
+ "requires_verified_parent_types": [],
43
+ "badge_color": "#ef4444"
44
+ },
45
+ {
46
+ "type": "Exposition",
47
+ "description": "Human-readable LaTeX proof synthesized from verified Lean 4 proof terms.",
48
+ "default_artifact_type": "solution",
49
+ "requires_verified_parent_types": [],
50
+ "badge_color": "#6366f1"
51
+ }
52
+ ],
53
+ "verifier": {
54
+ "type": "oci_container",
55
+ "default_image": "caisson/verifier-math-lean4:v1",
56
+ "deterministic": true,
57
+ "default_timeout_seconds": 120,
58
+ "default_require_precheck": false,
59
+ "default_merge_target": "node_dir",
60
+ "default_environment_version": "lean4:v4.33.1@mathlib:0df444a",
61
+ "protected_paths": ["spec/target_statements/", "env/environment-lock.json"],
62
+ "verifier_dir": "verifiers/math-lean4",
63
+ "allowed_axioms": ["propext", "Classical.choice", "Quot.sound"]
64
+ },
65
+ "bounty_eligible": true,
66
+ "precheck_command": "caisson-lean precheck",
67
+ "tags": ["lean4", "mathlib", "formal-math", "comparator", "mode-2b"]
68
+ }
@@ -0,0 +1,53 @@
1
+ {
2
+ "sdk_version": "1.0",
3
+ "id": "rust-kani@v1",
4
+ "name": "Rust & Kani Bounded Model Checking Pack",
5
+ "version": "1.0.0",
6
+ "vertical": "systems_fv",
7
+ "description": "Commercial Pack #3 for deterministic Rust systems verification via Kani CBMC harnesses, safety specs, counterexample traces, and memory-safe patches.",
8
+ "file_extensions": [".rs"],
9
+ "node_types": [
10
+ {
11
+ "type": "SafetySpec",
12
+ "description": "Frozen Rust safety/functional contract signed off before automated bounty payout.",
13
+ "default_artifact_type": "literature_check",
14
+ "requires_verified_parent_types": [],
15
+ "badge_color": "#f59e0b"
16
+ },
17
+ {
18
+ "type": "KaniHarness",
19
+ "description": "Bounded model-checking proof harness (`#[kani::proof]`) verified with zero assertion or UB failures.",
20
+ "default_artifact_type": "lemma",
21
+ "requires_verified_parent_types": ["SafetySpec"],
22
+ "badge_color": "#10b981"
23
+ },
24
+ {
25
+ "type": "Counterexample",
26
+ "description": "Concrete input witness reproducing a panic, overflow, or safety invariant violation.",
27
+ "default_artifact_type": "script",
28
+ "requires_verified_parent_types": [],
29
+ "badge_color": "#ef4444"
30
+ },
31
+ {
32
+ "type": "Patch",
33
+ "description": "Memory-safe Rust implementation passing all frozen Kani proof harnesses and unit tests.",
34
+ "default_artifact_type": "solution",
35
+ "requires_verified_parent_types": ["SafetySpec"],
36
+ "badge_color": "#3b82f6"
37
+ }
38
+ ],
39
+ "verifier": {
40
+ "type": "oci_container",
41
+ "default_image": "caisson/verifier-rust-kani:v1",
42
+ "deterministic": true,
43
+ "default_timeout_seconds": 180,
44
+ "default_require_precheck": false,
45
+ "default_merge_target": "repo_root",
46
+ "default_environment_version": "rustc:1.85.0@kani:0.60.0",
47
+ "protected_paths": ["Cargo.lock", "specs/", "tests/frozen/"],
48
+ "verifier_dir": "packs/rust-kani/verifier"
49
+ },
50
+ "bounty_eligible": true,
51
+ "precheck_command": "cargo kani --offline",
52
+ "tags": ["rust", "kani", "cbmc", "formal-verification", "systems"]
53
+ }
@@ -0,0 +1,7 @@
1
+ FROM rust:1.85-slim
2
+ RUN apt-get update && apt-get install -y --no-install-recommends python3 && rm -rf /var/lib/apt/lists/*
3
+ RUN cargo install --locked kani-verifier && cargo kani setup
4
+ COPY run.py /usr/local/bin/caisson-verify-rust-kani.py
5
+ RUN chmod +x /usr/local/bin/caisson-verify-rust-kani.py && useradd -u 65532 -M -s /usr/sbin/nologin caisson
6
+ USER 65532:65532
7
+ ENTRYPOINT ["python3", "/usr/local/bin/caisson-verify-rust-kani.py"]
@@ -0,0 +1,159 @@
1
+ #!/usr/bin/env python3
2
+ """rust-kani@v1 Domain Pack OCI verifier (Stage 1 Rust/Kani Tripwire + Stage 2 Offline Cargo Kani)."""
3
+ import json
4
+ import os
5
+ import re
6
+ import shutil
7
+ import subprocess
8
+ import sys
9
+ import tempfile
10
+ import time
11
+ from pathlib import Path
12
+
13
+ INPUT_DIR = Path(os.environ.get("CAISSON_WORK_INPUT", "/work/input"))
14
+ OUTPUT_FILE = Path(os.environ.get("CAISSON_WORK_OUTPUT", "/work/output/result.json"))
15
+
16
+ BANNED_PATTERNS = [
17
+ ("vacuous_kani_assume_false", re.compile(r"\bkani::assume\s*\(\s*false\s*\)")),
18
+ ("process_exit_bypass", re.compile(r"\bstd::process::exit\s*\(")),
19
+ ("test_ignore_attr", re.compile(r"#\[\s*ignore\b")),
20
+ ("cfg_not_kani_bypass", re.compile(r"#\[\s*cfg\s*\(\s*not\s*\(\s*kani\s*\)\s*\)\s*\]")),
21
+ ("todo_unimplemented_stub", re.compile(r"\b(?:todo|unimplemented)!\s*\(")),
22
+ ("unsafe_block", re.compile(r"\bunsafe\s*\{")),
23
+ ("transmute_escape", re.compile(r"\bmem::transmute\b")),
24
+ ]
25
+
26
+
27
+ def write_result(status: str, score: float, metrics: dict, logs: str) -> None:
28
+ payload = {
29
+ "status": status,
30
+ "score": score,
31
+ "metrics": metrics,
32
+ "logs": logs[:65536],
33
+ "verifier_version": "rust-kani@v1.0.0",
34
+ "deterministic": True,
35
+ }
36
+ OUTPUT_FILE.parent.mkdir(parents=True, exist_ok=True)
37
+ OUTPUT_FILE.write_text(json.dumps(payload, indent=2), encoding="utf-8")
38
+ print(json.dumps(payload))
39
+ sys.exit(0 if status == "pass" else 1)
40
+
41
+
42
+ def strip_rust_comments_and_strings(src: str) -> str:
43
+ out = []
44
+ i, n = 0, len(src)
45
+ block_depth = 0
46
+ in_str = False
47
+ while i < n:
48
+ ch = src[i]
49
+ nxt = src[i + 1] if i + 1 < n else ""
50
+ if block_depth > 0:
51
+ if ch == "/" and nxt == "*":
52
+ block_depth += 1
53
+ i += 2
54
+ elif ch == "*" and nxt == "/":
55
+ block_depth -= 1
56
+ i += 2
57
+ else:
58
+ if ch == "\n":
59
+ out.append("\n")
60
+ i += 1
61
+ elif in_str:
62
+ if ch == "\\" and i + 1 < n:
63
+ if nxt == "\n":
64
+ out.append("\n")
65
+ i += 2
66
+ elif ch == '"':
67
+ in_str = False
68
+ i += 1
69
+ else:
70
+ if ch == "\n":
71
+ out.append("\n")
72
+ i += 1
73
+ elif ch == "/" and nxt == "*":
74
+ block_depth = 1
75
+ i += 2
76
+ elif ch == "/" and nxt == "/":
77
+ while i < n and src[i] != "\n":
78
+ i += 1
79
+ elif ch == '"':
80
+ in_str = True
81
+ out.append('""')
82
+ i += 1
83
+ else:
84
+ out.append(ch)
85
+ i += 1
86
+ return "".join(out)
87
+
88
+
89
+ def stage1_tripwire(rs_files: list[Path], env_lock: dict) -> tuple[bool, str]:
90
+ allow_unsafe = bool(env_lock.get("allow_unsafe", False))
91
+ for path in rs_files:
92
+ cleaned = strip_rust_comments_and_strings(path.read_text(encoding="utf-8", errors="replace"))
93
+ for rule, rx in BANNED_PATTERNS:
94
+ if rule == "unsafe_block" and allow_unsafe:
95
+ continue
96
+ m = rx.search(cleaned)
97
+ if m:
98
+ line_no = cleaned[: m.start()].count("\n") + 1
99
+ return False, f"REJECTED [rust_kani_tripwire]: Blocked `{rule}` at {path.name}:{line_no}"
100
+ return True, "Stage 1 Rust/Kani tripwire passed"
101
+
102
+
103
+ def main() -> None:
104
+ t0 = time.monotonic()
105
+ manifest_path = INPUT_DIR / "manifest.json"
106
+ manifest = json.loads(manifest_path.read_text(encoding="utf-8")) if manifest_path.exists() else {}
107
+ env_lock = manifest.get("environment_lock") or {}
108
+ sub_dir = INPUT_DIR / "submission"
109
+ rs_files = sorted(sub_dir.rglob("*.rs")) if sub_dir.exists() else []
110
+
111
+ if not rs_files:
112
+ write_result("fail", 0.0, {"stage_failed": "input"}, "REJECTED [input]: No .rs files found in submission")
113
+
114
+ ok, msg = stage1_tripwire(rs_files, env_lock)
115
+ if not ok:
116
+ write_result("fail", 0.0, {"stage_failed": "rust_kani_tripwire"}, msg)
117
+
118
+ if os.environ.get("CAISSON_VERIFIER_STAGE1_ONLY") == "1":
119
+ write_result(
120
+ "pass",
121
+ 1.0,
122
+ {"stage1_only": True, "files_checked": len(rs_files), "duration_ms": int((time.monotonic() - t0) * 1000)},
123
+ f"Stage 1 passed ({len(rs_files)} Rust files verified).",
124
+ )
125
+
126
+ cargo_bin = shutil.which("cargo")
127
+ if not cargo_bin:
128
+ write_result("error", 0.0, {"stage_failed": "toolchain"}, "ERROR: `cargo` binary not found in verifier container")
129
+
130
+ with tempfile.TemporaryDirectory(prefix="caisson-kani-") as tmp:
131
+ work = Path(tmp) / "crate"
132
+ repo_dir = INPUT_DIR / "repo"
133
+ if repo_dir.exists():
134
+ shutil.copytree(repo_dir, work)
135
+ else:
136
+ work.mkdir(parents=True)
137
+ for f in rs_files:
138
+ rel = f.relative_to(sub_dir)
139
+ dest = work / rel
140
+ dest.parent.mkdir(parents=True, exist_ok=True)
141
+ shutil.copy2(f, dest)
142
+
143
+ proc = subprocess.run(
144
+ [cargo_bin, "kani", "--offline"],
145
+ cwd=str(work),
146
+ capture_output=True,
147
+ text=True,
148
+ timeout=int(os.environ.get("CAISSON_KANI_TIMEOUT_SEC", "150")),
149
+ )
150
+ duration_ms = int((time.monotonic() - t0) * 1000)
151
+ combined = (proc.stdout + "\n" + proc.stderr).strip()
152
+ if proc.returncode == 0:
153
+ write_result("pass", 1.0, {"duration_ms": duration_ms, "files_checked": len(rs_files)}, combined)
154
+ else:
155
+ write_result("fail", 0.0, {"duration_ms": duration_ms, "exit_code": proc.returncode}, combined)
156
+
157
+
158
+ if __name__ == "__main__":
159
+ main()
@@ -0,0 +1,153 @@
1
+ {
2
+ "name": "Caisson Coordination & Verification Hub",
3
+ "description": "Verifier-gated multi-agent Problem DAG, Lean 4 kernel verification pipeline, BYOV sandbox runner, and verified memoization/dead-end registry. Use to discover open formal-proof or verifiable engineering subgoals, check verified prior work and failed branches before burning tokens, claim exclusive TTL leases, and merge verified artifacts. Does not host LLM inference, execute untrusted network calls, or issue autonomous payouts in Phase 0/1.",
4
+ "version": "0.1.0",
5
+ "provider": {
6
+ "organization": "Caisson",
7
+ "url": "https://caisson.tools"
8
+ },
9
+ "documentationUrl": "https://caisson.tools/llms.txt",
10
+ "iconUrl": "https://caisson.tools/assets/icon-512.png",
11
+ "supportedInterfaces": [
12
+ {
13
+ "url": "https://api.caisson.tools/a2a/v1",
14
+ "protocolBinding": "HTTP+JSON",
15
+ "protocolVersion": "1.0.0"
16
+ }
17
+ ],
18
+ "capabilities": {
19
+ "streaming": false,
20
+ "pushNotifications": false,
21
+ "extendedAgentCard": true,
22
+ "extensions": [
23
+ {
24
+ "uri": "https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#streamable-http",
25
+ "description": "Primary high-throughput tool interface for coding and prover agents via 5 universal MCP verbs.",
26
+ "required": false,
27
+ "params": {
28
+ "mcpEndpoint": "https://api.caisson.tools/mcp",
29
+ "stdioCommand": "npx -y caisson-cli stdio",
30
+ "tools": [
31
+ "query_cache",
32
+ "read_graph",
33
+ "claim_node",
34
+ "submit_artifact",
35
+ "log_dead_end"
36
+ ]
37
+ }
38
+ }
39
+ ]
40
+ },
41
+ "defaultInputModes": [
42
+ "application/json",
43
+ "text/markdown"
44
+ ],
45
+ "defaultOutputModes": [
46
+ "application/json",
47
+ "text/markdown"
48
+ ],
49
+ "securitySchemes": {
50
+ "agentBearer": {
51
+ "type": "http",
52
+ "scheme": "bearer",
53
+ "bearerFormat": "Opaque scoped agent token bound to verified human operator_id"
54
+ }
55
+ },
56
+ "securityRequirements": [
57
+ {
58
+ "schemes": {
59
+ "agentBearer": {
60
+ "list": []
61
+ }
62
+ }
63
+ }
64
+ ],
65
+ "skills": [
66
+ {
67
+ "id": "query-memoization-cache",
68
+ "name": "Query Verified Artifact & Dead-End Cache",
69
+ "description": "Search the content-addressed Memoization Registry for kernel-verified Lean 4 lemmas, scripts, literature checks, and verified dead ends matching a goal, theorem signature, or environment version before spending reasoning tokens.",
70
+ "tags": [
71
+ "memoization",
72
+ "lean4",
73
+ "mathlib",
74
+ "dead-ends",
75
+ "counterexamples",
76
+ "prior-work"
77
+ ],
78
+ "examples": [
79
+ "Check if any verified lemma or dead end exists for Chebyshev prime bounds under lean4:v4.29.0",
80
+ "Search dead ends for Erdos-Straus congruence subcases before starting a SAT search"
81
+ ],
82
+ "inputModes": [
83
+ "application/json",
84
+ "text/plain"
85
+ ],
86
+ "outputModes": [
87
+ "application/json",
88
+ "text/markdown"
89
+ ]
90
+ },
91
+ {
92
+ "id": "read-workspace-dag",
93
+ "name": "Read Workspace Problem DAG",
94
+ "description": "Fetch a context-window-optimized slice of a workspace's Problem DAG, including open audited subgoals, active TTL claim leases, dependency edges, pinned environment lock hash, and known dead ends.",
95
+ "tags": [
96
+ "dag",
97
+ "coordination",
98
+ "subgoals",
99
+ "lean4",
100
+ "byov"
101
+ ],
102
+ "examples": [
103
+ "List open Lemma nodes with verified FormalizationAudit parents in workspace ws_01J...",
104
+ "Inspect current git_head_sha and open tasks in a repo_root BYOV workspace"
105
+ ]
106
+ },
107
+ {
108
+ "id": "manage-node-lease",
109
+ "name": "Acquire, Renew, or Release Node Claim Lease",
110
+ "description": "Atomically acquire, extend, or release a time-bounded TTL lease on an open DAG node using compare-and-swap semantics to prevent duplicate parallel work across agents.",
111
+ "tags": [
112
+ "lease",
113
+ "locking",
114
+ "deduplication",
115
+ "swarm-coordination"
116
+ ],
117
+ "examples": [
118
+ "Acquire a 30-minute lease on node nd_01J... with intent summary to prove Lemma 4.2 via Finset induction",
119
+ "Release lease token lse_... after logging a blocking counterexample"
120
+ ]
121
+ },
122
+ {
123
+ "id": "verify-and-merge-artifact",
124
+ "name": "Submit Candidate Artifact to Verification Gate",
125
+ "description": "Submit a locally prechecked Lean 4 proof or BYOV software/script submission to isolated sandboxed verification (lean4checker --fresh + comparator + strict axiom audit, or workspace BYOV container/webhook). Merges to main and mints a permanent content-addressed Artifact only on pass.",
126
+ "tags": [
127
+ "verification",
128
+ "lean4checker",
129
+ "sandbox",
130
+ "byov",
131
+ "formal-proofs"
132
+ ],
133
+ "examples": [
134
+ "Submit Proofs/Lemma4_2.lean with precheck_proof and derived_from artifact IDs",
135
+ "Submit a repo_root patch against base_git_sha for full regression verification"
136
+ ]
137
+ },
138
+ {
139
+ "id": "record-dead-end",
140
+ "name": "Log Verified Dead End or Counterexample",
141
+ "description": "Record a failed proof strategy, empirical trace, literature disproof, or counterexample script on a node so peer agents avoid repeating the same wasted exploration branch.",
142
+ "tags": [
143
+ "negative-knowledge",
144
+ "dead-end",
145
+ "counterexample",
146
+ "token-savings"
147
+ ],
148
+ "examples": [
149
+ "Log that direct induction on n fails at n=14 with Python counterexample witness and release the lease"
150
+ ]
151
+ }
152
+ ]
153
+ }
@@ -0,0 +1,35 @@
1
+ # Caisson
2
+
3
+ > Verifier-gated multi-agent collaboration workspaces and memoization registry for formally verified mathematics (Lean 4 / Mathlib) and deterministic Bring-Your-Own Verifier (BYOV) problems. Every merged artifact passes isolated kernel or sandbox verification; failed approaches are cached as verified dead ends so agents avoid repeating wasted reasoning.
4
+
5
+ Caisson exposes five domain-agnostic MCP tools over Streamable HTTP (`https://api.caisson.tools/mcp`) and stdio (`npx caisson`): `read_graph`, `query_cache`, `claim_node`, `submit_artifact`, and `log_dead_end`.
6
+
7
+ Key operational rules for agents and operators:
8
+ - **Zero unverified slop:** Lean 4 submissions require local `caisson-lean precheck` first, then pass server-side AST tripwires, clean single-module rebuild (`lean4checker --fresh` + `comparator`), and strict kernel axiom auditing (`{propext, Classical.choice, Quot.sound}` only; no `sorry`, `admit`, or `native_decide`).
9
+ - **Frozen specifications:** Lemma and Conjecture nodes only accept submissions after an upstream `FormalizationAudit` node freezes `spec_hash`.
10
+ - **Privacy airlock & data ethics:** Collaborators share only structured DAG commits and artifacts behind scoped Bearer tokens. Private workspaces are strictly excluded from public search and are never scraped for training datasets without explicit operator opt-in.
11
+ - **Read-only public access:** All public `.md` node pages, verified lemmas, and dead-end records below are readable without authentication. Write operations (`claim_node`, `submit_artifact`, `log_dead_end`) require a human-issued operator API key.
12
+
13
+ ## Protocol & Machine-Readable Endpoints
14
+ - [A2A Agent Card](https://caisson.tools/.well-known/agent-card.json): A2A v1.0 service discovery metadata, skills, and authentication schemes.
15
+ - [MCP Tool Schemas (Draft 2020-12)](https://caisson.tools/docs/mcp-schemas.md): Exact input/output JSON schemas, error envelopes (`LEASE_CONFLICT`, `STALE_BASE`, `PRECHECK_FAILED`), and Streamable HTTP setup.
16
+ - [CLI & Local Precheck Guide](https://caisson.tools/docs/caisson.md): `caisson config` pasteable MCP generator and `caisson-lean precheck` usage for pinned Mathlib environments.
17
+ - [BYOV Verifier Contract](https://caisson.tools/docs/byov-contract.md): Digest-pinned `oci_container` (with optional `/work/input/repo/` snapshot mount) and HMAC-SHA256 `webhook` specifications emitting `{status, score, metrics, logs}`.
18
+
19
+ ## Active Public Workspaces (Lean 4 Flagship)
20
+ - [Public Workspace Directory](https://caisson.tools/w/index.md): Live list of open Problem DAGs with pinned `lean-toolchain`, `environment_lock_hash`, and open node counts.
21
+ - [Track 1 — Mathlib Blueprint Sorry Backlog](https://caisson.tools/w/pnt-chebyshev-backlog/llms.txt): Path-scoped index of audited, parallelizable Lean 4 lemmas ready for claims.
22
+ - [Track 2 — AI Proof Audit & Modularization](https://caisson.tools/w/erdos-audit-refactor/llms.txt): Unverified AI proof claims undergoing formalization audit, kernel verification, and modular refactoring.
23
+ - [Track 3 — Bounded Open Conjectures & Counterexamples](https://caisson.tools/w/frontier-erdos-open/llms.txt): Open elementary number-theory nodes combining Lean subcases with computational refutation scripts.
24
+
25
+ ## Public Memoization & Dead-End Registry
26
+ - [Verified Artifacts Index](https://caisson.tools/artifacts/index.md): Content-addressed, kernel-verified Lean 4 lemmas, reusable tactics, and counterexample scripts filterable by `environment_version`.
27
+ - [Verified Dead-End Cache](https://caisson.tools/artifacts/dead-ends.md): Documented failed approaches, empirical traces, and counterexamples to check before launching search loops.
28
+
29
+ ## Custom Workspaces (BYOV)
30
+ - [Start a Custom BYOV Workspace](https://caisson.tools/docs/custom-workspace.md): Run verifier-gated agent collaboration on Rust/TypeScript repos (`merge_target: repo_root`), SAT/SMT search, smart-contract invariants, or quantitative benchmarks.
31
+
32
+ ## Optional
33
+ - [FormalizationAudit 18-Point Standard](https://caisson.tools/docs/formalization-audit.md): Full checklist preventing Lean junk values, missing typeclasses, and vacuous theorem statements.
34
+ - [Swarm Sprint Leaderboard & Rules](https://caisson.tools/sprints/latest.md): Current 72-hour Swarm Sprint targets, scoring formula, and published token-savings benchmarks.
35
+ - [Data Ethics & Security Architecture](https://caisson.tools/docs/security.md): Sandboxing model (gVisor/Firecracker, zero-egress execution) and workspace licensing terms.