certora-cli-beta 8.20.3__tar.gz → 8.21.0__tar.gz

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 (95) hide show
  1. {certora_cli_beta-8.20.3/certora_cli_beta.egg-info → certora_cli_beta-8.21.0}/PKG-INFO +2 -2
  2. certora_cli_beta-8.21.0/README.md +1 -0
  3. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/CertoraProver/certoraBuildRust.py +249 -27
  4. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/CertoraProver/certoraCloudIO.py +2 -1
  5. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/CertoraProver/certoraConfigIO.py +0 -5
  6. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/CertoraProver/certoraContextAttributes.py +11 -0
  7. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/CertoraProver/certoraContextValidator.py +9 -0
  8. certora_cli_beta-8.21.0/certora_cli/CertoraProver/certoraParseBuildScript.py +154 -0
  9. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/Mutate/mutateApp.py +24 -2
  10. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/Shared/certoraUtils.py +45 -0
  11. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/rustMutator.py +4 -3
  12. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0/certora_cli_beta.egg-info}/PKG-INFO +2 -2
  13. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli_beta.egg-info/entry_points.txt +1 -0
  14. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_jars/ASTExtraction.jar +0 -0
  15. certora_cli_beta-8.21.0/certora_jars/CERTORA-CLI-VERSION-METADATA.json +1 -0
  16. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_jars/Typechecker.jar +0 -0
  17. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/setup.py +3 -2
  18. certora_cli_beta-8.20.3/README.md +0 -1
  19. certora_cli_beta-8.20.3/certora_cli/CertoraProver/certoraParseBuildScript.py +0 -109
  20. certora_cli_beta-8.20.3/certora_jars/CERTORA-CLI-VERSION-METADATA.json +0 -1
  21. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/LICENSE +0 -0
  22. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/MANIFEST.in +0 -0
  23. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_bins/__init__.py +0 -0
  24. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/CertoraProver/Compiler/CompilerCollector.py +0 -0
  25. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/CertoraProver/Compiler/CompilerCollectorFactory.py +0 -0
  26. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/CertoraProver/Compiler/CompilerCollectorSol.py +0 -0
  27. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/CertoraProver/Compiler/CompilerCollectorSolBased.py +0 -0
  28. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/CertoraProver/Compiler/CompilerCollectorVy.py +0 -0
  29. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/CertoraProver/Compiler/CompilerCollectorYul.py +0 -0
  30. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/CertoraProver/Compiler/__init__.py +0 -0
  31. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/CertoraProver/__init__.py +0 -0
  32. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/CertoraProver/castingInstrumenter.py +0 -0
  33. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/CertoraProver/certoraApp.py +0 -0
  34. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/CertoraProver/certoraBuild.py +0 -0
  35. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/CertoraProver/certoraBuildCacheManager.py +0 -0
  36. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/CertoraProver/certoraBuildDataClasses.py +0 -0
  37. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/CertoraProver/certoraBuildSui.py +0 -0
  38. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/CertoraProver/certoraCollectConfigurationLayout.py +0 -0
  39. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/CertoraProver/certoraCollectRunMetadata.py +0 -0
  40. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/CertoraProver/certoraCompilerParameters.py +0 -0
  41. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/CertoraProver/certoraContext.py +0 -0
  42. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/CertoraProver/certoraContextClass.py +0 -0
  43. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/CertoraProver/certoraContractFuncs.py +0 -0
  44. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/CertoraProver/certoraExtensionInfo.py +0 -0
  45. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/CertoraProver/certoraJobList.py +0 -0
  46. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/CertoraProver/certoraMiniSpecParser.py +0 -0
  47. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/CertoraProver/certoraNodeFilters.py +0 -0
  48. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/CertoraProver/certoraOffsetConverter.py +0 -0
  49. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/CertoraProver/certoraProjectScanner.py +0 -0
  50. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/CertoraProver/certoraSourceFinders.py +0 -0
  51. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/CertoraProver/certoraType.py +0 -0
  52. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/CertoraProver/certoraVerifyGenerator.py +0 -0
  53. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/CertoraProver/erc7201.py +0 -0
  54. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/CertoraProver/splitRules.py +0 -0
  55. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/CertoraProver/storageExtension.py +0 -0
  56. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/CertoraProver/test_certoraCloudIO.py +0 -0
  57. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/CertoraProver/uncheckedOverflowInstrumenter.py +0 -0
  58. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/EquivalenceCheck/Eq_default.conf +0 -0
  59. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/EquivalenceCheck/Eq_mc_no_out_template.spec +0 -0
  60. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/EquivalenceCheck/Eq_mc_template.spec +0 -0
  61. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/EquivalenceCheck/Eq_sanity.conf +0 -0
  62. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/EquivalenceCheck/Eq_template.spec +0 -0
  63. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/EquivalenceCheck/__init__.py +0 -0
  64. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/EquivalenceCheck/equivCheck.py +0 -0
  65. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/EquivalenceCheck/sanity.spec +0 -0
  66. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/Mutate/__init__.py +0 -0
  67. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/Mutate/mutateAttributes.py +0 -0
  68. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/Mutate/mutateConstants.py +0 -0
  69. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/Mutate/mutateUtil.py +0 -0
  70. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/Mutate/mutateValidate.py +0 -0
  71. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/Mutate/test_mutateApp.py +0 -0
  72. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/Shared/ExpectedComparator.py +0 -0
  73. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/Shared/__init__.py +0 -0
  74. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/Shared/certoraAttrUtil.py +0 -0
  75. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/Shared/certoraLogging.py +0 -0
  76. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/Shared/certoraValidateFuncs.py +0 -0
  77. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/Shared/proverCommon.py +0 -0
  78. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/Shared/test_proverCommon.py +0 -0
  79. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/__init__.py +0 -0
  80. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/certoraCVLFormatter.py +0 -0
  81. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/certoraConcord.py +0 -0
  82. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/certoraEVMProver.py +0 -0
  83. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/certoraEqCheck.py +0 -0
  84. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/certoraMutate.py +0 -0
  85. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/certoraRanger.py +0 -0
  86. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/certoraRun.py +0 -0
  87. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/certoraSolanaProver.py +0 -0
  88. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/certoraSorobanProver.py +0 -0
  89. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli/certoraSuiProver.py +0 -0
  90. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli_beta.egg-info/SOURCES.txt +0 -0
  91. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli_beta.egg-info/dependency_links.txt +0 -0
  92. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli_beta.egg-info/requires.txt +0 -0
  93. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_cli_beta.egg-info/top_level.txt +0 -0
  94. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/certora_jars/__init__.py +0 -0
  95. {certora_cli_beta-8.20.3 → certora_cli_beta-8.21.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: certora-cli-beta
3
- Version: 8.20.3
3
+ Version: 8.21.0
4
4
  Summary: Runner for the Certora Prover
5
5
  Home-page: https://pypi.org/project/certora-cli-beta
6
6
  Author: Certora
@@ -38,4 +38,4 @@ Dynamic: requires-dist
38
38
  Dynamic: requires-python
39
39
  Dynamic: summary
40
40
 
41
- Commit 4ef546d. Build and Run scripts for executing the Certora Prover on Solidity smart contracts.
41
+ Commit b65ac9c. Build and Run scripts for executing the Certora Prover on Solidity smart contracts.
@@ -0,0 +1 @@
1
+ Commit b65ac9c. Build and Run scripts for executing the Certora Prover on Solidity smart contracts.
@@ -28,13 +28,14 @@ import shutil
28
28
  import subprocess
29
29
  import time
30
30
  import logging
31
- from collections.abc import Iterable
31
+ from collections.abc import Iterable, Mapping
32
+ from dataclasses import dataclass
32
33
  from pathlib import Path
33
34
  from typing import Any, Set, Dict, cast
34
35
 
35
36
  from CertoraProver.certoraBuild import build_source_tree
36
37
  from CertoraProver.certoraContextClass import CertoraContext
37
- from CertoraProver.certoraParseBuildScript import run_rust_build
38
+ from CertoraProver.certoraParseBuildScript import run_rust_build, RustBuild, apply_build_result
38
39
  import CertoraProver.certoraContextAttributes as Attrs
39
40
  from Shared import certoraUtils as Util
40
41
 
@@ -77,6 +78,9 @@ def set_rust_build_directory(context: CertoraContext) -> None:
77
78
 
78
79
  def build_rust_app(context: CertoraContext) -> None:
79
80
  assert not context.files, "build_rust_app: expecting files to be empty"
81
+ if Attrs.is_soroban_app() and not context.build_script:
82
+ build_soroban_package(context)
83
+ return
80
84
  if context.build_script:
81
85
  build_command = [context.build_script, '--json', '-l']
82
86
  feature_flag = '--cargo_features'
@@ -100,6 +104,170 @@ def build_rust_app(context: CertoraContext) -> None:
100
104
  run_rust_build(context, build_command)
101
105
 
102
106
 
107
+ SOROBAN_DEFAULT_TARGET = "wasm32-unknown-unknown"
108
+ SOROBAN_DEFAULT_PROFILE = "release"
109
+ SOROBAN_DEFAULT_SOURCES = ["src/**/*.rs"]
110
+ # The prover reads function names and debug info out of the wasm, which a release profile normally strips. The cvlr
111
+ # hooks (CVT_assert and friends) are plain `extern "C"` declarations that the prover resolves, and since Rust 1.96
112
+ # wasm-ld no longer turns such undefined functions into imports unless told to.
113
+ SOROBAN_RUSTFLAGS = ["-C", "strip=none", "-C", "debuginfo=2", "-C", "link-arg=--allow-undefined"]
114
+ CERTORA_FEATURE = "certora"
115
+
116
+
117
+ @dataclass(frozen=True)
118
+ class SorobanBuildSettings:
119
+ """
120
+ What `[package.metadata.certora]` may say about building a contract. Everything cargo has its own knob for is
121
+ left to cargo, the toolchain above all: `rust-toolchain.toml` and `.cargo/config.toml` are read from the working
122
+ directory as for any cargo invocation.
123
+ """
124
+ target: str
125
+ profile: str
126
+ rustflags: list[str]
127
+ sources: list[str]
128
+
129
+ @staticmethod
130
+ def from_package(package: dict[str, Any]) -> SorobanBuildSettings:
131
+ certora = (package.get("metadata") or {}).get("certora") or {}
132
+ if not isinstance(certora, dict):
133
+ raise Util.CertoraUserInputError(f"[package.metadata.certora] of {package['name']} must be a table")
134
+ return SorobanBuildSettings(
135
+ target=metadata_string(certora, "target", os.environ.get("CARGO_BUILD_TARGET", SOROBAN_DEFAULT_TARGET)),
136
+ profile=metadata_string(certora, "profile", SOROBAN_DEFAULT_PROFILE),
137
+ rustflags=metadata_strings(certora, "rustflags", []),
138
+ sources=metadata_strings(certora, "sources", SOROBAN_DEFAULT_SOURCES),
139
+ )
140
+
141
+
142
+ def metadata_string(table: dict[str, Any], key: str, default: str) -> str:
143
+ value = table.get(key, default)
144
+ if not isinstance(value, str) or not value:
145
+ raise Util.CertoraUserInputError(f"[package.metadata.certora] {key} must be a non-empty string, got {value!r}")
146
+ return value
147
+
148
+
149
+ def metadata_strings(table: dict[str, Any], key: str, default: list[str]) -> list[str]:
150
+ value = table.get(key, default)
151
+ if not isinstance(value, list) or not all(isinstance(item, str) for item in value):
152
+ raise Util.CertoraUserInputError(f"[package.metadata.certora] {key} must be a list of strings, got {value!r}")
153
+ return value
154
+
155
+
156
+ def build_soroban_package(context: CertoraContext) -> None:
157
+ """
158
+ Build a Soroban contract with plain cargo, configured from `[package.metadata.certora]` in its manifest, and
159
+ locate the wasm where cargo's target directory layout puts it. The Soroban counterpart of `cargo certora-sbf`:
160
+ no build script, cargo's own output when the build fails, and the dep-info beside the artifact.
161
+ """
162
+ manifest = soroban_manifest(context)
163
+ try:
164
+ metadata = run_cargo_metadata(manifest)
165
+ except CargoMetadataError as e:
166
+ raise Util.CertoraUserInputError(str(e)) from e
167
+ package = select_package(manifest, metadata)
168
+ lib_target = cdylib_target(package)
169
+ if lib_target is None:
170
+ raise Util.CertoraUserInputError(f"package {package['name']} has no cdylib target; a Soroban contract needs "
171
+ f"`crate-type = [\"cdylib\"]` in its [lib] section")
172
+ settings = SorobanBuildSettings.from_package(package)
173
+ package_manifest = Path(package["manifest_path"])
174
+
175
+ run_cargo_build(context, package_manifest, settings)
176
+
177
+ artifact = expected_artifact(Path(metadata["target_directory"]), lib_target["name"], settings.target,
178
+ settings.profile, ".wasm")
179
+ if not artifact.is_file():
180
+ raise Util.CertoraUserInputError(
181
+ f"cargo reported success but {artifact} does not exist. The path was expected from the target directory "
182
+ f"{metadata['target_directory']}, the target {settings.target}, the profile {settings.profile} and the "
183
+ f"lib target {lib_target['name']}; check [package.metadata.certora] or use a build script")
184
+
185
+ workspace_root = Path(metadata["workspace_root"])
186
+ package_root = Path(os.path.relpath(package_manifest.parent, workspace_root))
187
+ sources = [str(package_root / source) for source in settings.sources] + [Util.CARGO_TOML_FILE]
188
+ apply_build_result(context, RustBuild(project_directory=workspace_root, sources=sources, executable=artifact))
189
+
190
+ if context.test == str(Util.TestValue.AFTER_BUILD_RUST):
191
+ raise Util.TestResultsReady(context)
192
+
193
+
194
+ def soroban_manifest(context: CertoraContext) -> Path:
195
+ """The manifest a cargo build from the working directory would use, unless the conf names one."""
196
+ if manifest_path := getattr(context, 'cargo_manifest_path', None):
197
+ return Path(manifest_path).resolve()
198
+ manifest = Util.find_nearest_cargo_toml()
199
+ if manifest is None:
200
+ raise Util.CertoraUserInputError("No Cargo.toml found in the working directory or its parents; run from the "
201
+ "contract's directory, or set 'cargo_manifest_path', 'build_script' or "
202
+ "'files'")
203
+ return manifest.resolve()
204
+
205
+
206
+ def select_package(manifest: Path, metadata: dict[str, Any]) -> dict[str, Any]:
207
+ """
208
+ The package the manifest belongs to. A workspace manifest with no package of its own stands for the one contract
209
+ in the workspace, as it does for `cargo certora-sbf`.
210
+ """
211
+ packages = metadata["packages"]
212
+ for package in packages:
213
+ if Path(package["manifest_path"]).resolve() == manifest:
214
+ return package
215
+ contracts = [package for package in packages if cdylib_target(package) is not None]
216
+ if len(contracts) == 1:
217
+ return contracts[0]
218
+ names = ", ".join(package["name"] for package in contracts) or "none"
219
+ raise Util.CertoraUserInputError(
220
+ f"{manifest} is a workspace manifest and its workspace has {len(contracts)} packages with a cdylib target "
221
+ f"({names}); run from the contract's directory or set 'cargo_manifest_path'")
222
+
223
+
224
+ def cdylib_target(package: dict[str, Any]) -> dict[str, Any] | None:
225
+ return next((target for target in package["targets"] if "cdylib" in target["crate_types"]), None)
226
+
227
+
228
+ def run_cargo_build(context: CertoraContext, manifest: Path, settings: SorobanBuildSettings) -> None:
229
+ features = [CERTORA_FEATURE, *(context.cargo_features or [])]
230
+ cmd = ["cargo", "build", "--manifest-path", str(manifest), "--lib", "--target", settings.target,
231
+ "--profile", settings.profile, "--features", " ".join(features)]
232
+ if context.test == str(Util.TestValue.SOROBAN_BUILD_CMD):
233
+ raise Util.TestResultsReady(cmd)
234
+
235
+ env = with_rustflags(os.environ, [*SOROBAN_RUSTFLAGS, *settings.rustflags])
236
+ log.info(f"Building by calling `{' '.join(cmd)}`")
237
+ # cargo runs from the working directory on purpose: that is where rustup looks for a toolchain override and
238
+ # where cargo starts its search for config files, exactly as for a build script invoked from there
239
+ result = subprocess.run(cmd, env=env, capture_output=True, text=True)
240
+ if getattr(context, 'cargo_build_verbose', False) and result.stderr:
241
+ log.info(f"Build stderr:\n{result.stderr}")
242
+ if result.returncode != 0:
243
+ raise Util.CertoraUserInputError(f"`{' '.join(cmd)}` failed\n{result.stderr}")
244
+
245
+
246
+ def with_rustflags(env: Mapping[str, str], flags: list[str]) -> dict[str, str]:
247
+ """
248
+ The environment with flags appended to the rustflags already in force. Cargo takes CARGO_ENCODED_RUSTFLAGS over
249
+ RUSTFLAGS, and either one over the config files, so the variable that is set is the one to extend. When neither
250
+ is, RUSTFLAGS is set and a `build.rustflags` in a config file is shadowed, as it would be for the user's own
251
+ RUSTFLAGS.
252
+ """
253
+ extended = dict(env)
254
+ if (encoded := extended.get("CARGO_ENCODED_RUSTFLAGS")) is not None:
255
+ extended["CARGO_ENCODED_RUSTFLAGS"] = "\x1f".join([*(encoded.split("\x1f") if encoded else []), *flags])
256
+ else:
257
+ extended["RUSTFLAGS"] = " ".join([*extended.get("RUSTFLAGS", "").split(), *flags])
258
+ return extended
259
+
260
+
261
+ def profile_directory(profile: str) -> str:
262
+ """Cargo keeps dev and test output under `debug`, release and bench under `release`, other profiles under their own name."""
263
+ return {"dev": "debug", "test": "debug", "release": "release", "bench": "release"}.get(profile, profile)
264
+
265
+
266
+ def expected_artifact(target_directory: Path, lib_target_name: str, triple: str, profile: str, suffix: str) -> Path:
267
+ """Where cargo uplifts a lib's final artifact; dashes in the target name become underscores in the file name."""
268
+ return target_directory / triple / profile_directory(profile) / f"{lib_target_name.replace('-', '_')}{suffix}"
269
+
270
+
103
271
  def add_solana_files_to_sources(context: CertoraContext, sources: Set[Path]) -> None:
104
272
  for attr in [Attrs.SolanaProverAttributes.SOLANA_INLINING,
105
273
  Attrs.SolanaProverAttributes.SOLANA_SUMMARIES,
@@ -164,20 +332,18 @@ CARGO_CONFIG_FILES = [".cargo/config.toml", ".cargo/config", "rust-toolchain.tom
164
332
  def collect_build_inputs(context: CertoraContext, project_directory: Path) -> set[Path]:
165
333
  """
166
334
  Every local file the cargo build actually consumed, so that the uploaded sources suffice to rebuild the artifact:
167
- the files listed in cargo's dep-info for the artifact, the manifests of all path packages in the dependency graph,
168
- the workspace manifest and lockfile, and the cargo/rustup configuration files visible from the working
169
- directories. Each part degrades independently; a missing dep-info or a failing `cargo metadata` only leaves that
170
- part out, since the artifact may have been prebuilt or the build script may not go through cargo at all.
335
+ the files listed in cargo's dep-info for the artifact, what cargo needs to load the workspace at all, the
336
+ workspace manifest and lockfile, and the cargo/rustup configuration files visible from the working directories.
337
+ Each part degrades independently; a missing dep-info or a failing `cargo metadata` only leaves that part out,
338
+ since the artifact may have been prebuilt or the build script may not go through cargo at all.
171
339
  """
172
340
  metadata = cargo_metadata(project_directory)
173
341
  workspace_root = Path(metadata["workspace_root"]).resolve() if metadata else project_directory
174
342
  target_directory = Path(metadata["target_directory"]).resolve() if metadata else workspace_root / "target"
175
- local_manifests: set[Path] = set()
176
- if metadata:
177
- local_manifests = {Path(p["manifest_path"]).resolve() for p in metadata["packages"] if p["source"] is None}
343
+ workspace_files = workspace_load_inputs(metadata) if metadata else set()
178
344
 
179
345
  inputs: set[Path] = {workspace_root / Util.CARGO_TOML_FILE, workspace_root / "Cargo.lock"}
180
- inputs.update(local_manifests)
346
+ inputs.update(workspace_files)
181
347
 
182
348
  dep_info = find_dep_info(Path(context.files[0]).resolve(), target_directory)
183
349
  if dep_info is None:
@@ -186,13 +352,15 @@ def collect_build_inputs(context: CertoraContext, project_directory: Path) -> se
186
352
  dep_files = parse_dep_info(dep_info, workspace_root)
187
353
  log.debug(f"Read {len(dep_files)} build inputs from {dep_info}")
188
354
  inputs.update(dep_files)
189
- # the manifests of the crates these files belong to, for when `cargo metadata` was unavailable
355
+ # the manifests of the crates these files belong to: path dependencies of path dependencies are not in the
356
+ # metadata, and nothing is when `cargo metadata` was unavailable
190
357
  for directory in {f.parent for f in dep_files}:
191
358
  manifest = enclosing_manifest(directory, workspace_root)
192
359
  if manifest is not None:
193
360
  inputs.add(manifest)
194
361
 
195
- start_dirs = {Path.cwd().resolve(), workspace_root, project_directory} | {m.parent for m in local_manifests}
362
+ manifest_dirs = {f.parent for f in workspace_files if f.name == Util.CARGO_TOML_FILE}
363
+ start_dirs = {Path.cwd().resolve(), workspace_root, project_directory} | manifest_dirs
196
364
  inputs.update(find_toolchain_config_files(start_dirs))
197
365
 
198
366
  excluded_roots = [target_directory, *external_tool_roots()]
@@ -204,31 +372,85 @@ def collect_build_inputs(context: CertoraContext, project_directory: Path) -> se
204
372
  return {f for f in inputs if is_project_file(f)}
205
373
 
206
374
 
207
- def cargo_metadata(project_directory: Path) -> dict[str, Any] | None:
375
+ class CargoMetadataError(Exception):
376
+ """`cargo metadata` could not be run, failed, or produced something other than a JSON object."""
377
+
378
+
379
+ def run_cargo_metadata(manifest: Path) -> dict[str, Any]:
208
380
  """
209
- `cargo metadata` for the workspace containing project_directory, or None if it cannot be obtained. `--frozen`
210
- keeps cargo off the network and away from the lockfile; `--all-features` lists optional path dependencies too,
211
- since cargo reads their manifests whether or not they end up compiled.
381
+ `cargo metadata --no-deps` for the workspace containing the manifest. `--no-deps` restricts the output to the
382
+ workspace members, which is all that is needed here, and keeps cargo from resolving the dependency graph: a full
383
+ `cargo metadata` fetches every package in the lockfile, including ones the build never needed, so it fails
384
+ offline on a machine that has only ever built the artifact.
212
385
  """
213
- manifest = project_directory / Util.CARGO_TOML_FILE
214
- if not manifest.is_file():
215
- return None
216
- cmd = ["cargo", "metadata", "--format-version", "1", "--frozen", "--all-features",
217
- "--manifest-path", str(manifest)]
386
+ cmd = ["cargo", "metadata", "--format-version", "1", "--no-deps", "--manifest-path", str(manifest)]
218
387
  try:
219
388
  result = subprocess.run(cmd, capture_output=True, text=True, timeout=120)
220
389
  except (OSError, subprocess.TimeoutExpired) as e:
221
- log.debug(f"Could not run `{' '.join(cmd)}`: {e}")
222
- return None
390
+ raise CargoMetadataError(f"Could not run `{' '.join(cmd)}`: {e}") from e
223
391
  if result.returncode != 0:
224
- log.debug(f"`{' '.join(cmd)}` failed:\n{result.stderr}")
225
- return None
392
+ raise CargoMetadataError(f"`{' '.join(cmd)}` failed:\n{result.stderr}")
226
393
  try:
227
394
  metadata = json.loads(result.stdout)
228
395
  except json.JSONDecodeError as e:
229
- log.debug(f"Could not parse the output of `{' '.join(cmd)}`: {e}")
396
+ raise CargoMetadataError(f"Could not parse the output of `{' '.join(cmd)}`: {e}") from e
397
+ if not isinstance(metadata, dict):
398
+ raise CargoMetadataError(f"Unexpected output from `{' '.join(cmd)}`: a {type(metadata).__name__}")
399
+ return metadata
400
+
401
+
402
+ def cargo_metadata(project_directory: Path) -> dict[str, Any] | None:
403
+ """The metadata of the workspace containing project_directory, or None when it cannot be obtained."""
404
+ manifest = project_directory / Util.CARGO_TOML_FILE
405
+ if not manifest.is_file():
406
+ return None
407
+ try:
408
+ return run_cargo_metadata(manifest)
409
+ except CargoMetadataError as e:
410
+ log.debug(str(e))
411
+ return None
412
+
413
+
414
+ def workspace_load_inputs(metadata: dict[str, Any]) -> set[Path]:
415
+ """
416
+ The files cargo needs merely to load the workspace, whichever package is then built: every member's manifest and
417
+ the entry file of each of its targets, and the same for every path dependency reachable from a member, inside the
418
+ workspace or not. Cargo resolves the whole workspace before building one package, and loading a manifest checks
419
+ that its targets' entry files exist, so a member missing its src/lib.rs fails the build even when nothing depends
420
+ on it. The rest of such a package is never read unless it is compiled, and then the dep-info lists it.
421
+ """
422
+ packages_by_manifest = {Path(package["manifest_path"]).resolve(): package for package in metadata["packages"]}
423
+ inputs: set[Path] = set()
424
+ pending = list(packages_by_manifest)
425
+ while pending:
426
+ manifest = pending.pop()
427
+ if manifest in inputs:
428
+ continue
429
+ inputs.add(manifest)
430
+ package = packages_by_manifest.get(manifest)
431
+ if package is None:
432
+ package = external_package(manifest, packages_by_manifest)
433
+ if package is None:
434
+ continue
435
+ inputs.update(Path(target["src_path"]).resolve() for target in package["targets"])
436
+ pending.extend(Path(dependency["path"]).resolve() / Util.CARGO_TOML_FILE
437
+ for dependency in package["dependencies"] if dependency.get("path") is not None)
438
+ return inputs
439
+
440
+
441
+ def external_package(manifest: Path, known: dict[Path, dict[str, Any]]) -> dict[str, Any] | None:
442
+ """
443
+ A path dependency outside the workspace, read through its own workspace's metadata, which is added to `known` so
444
+ that siblings from the same place cost no second call. None when cargo cannot read it.
445
+ """
446
+ try:
447
+ metadata = run_cargo_metadata(manifest)
448
+ except CargoMetadataError as e:
449
+ log.debug(str(e))
230
450
  return None
231
- return metadata if isinstance(metadata, dict) else None
451
+ for package in metadata["packages"]:
452
+ known.setdefault(Path(package["manifest_path"]).resolve(), package)
453
+ return known.get(manifest)
232
454
 
233
455
 
234
456
  def find_dep_info(artifact: Path, target_directory: Path) -> Path | None:
@@ -623,7 +623,8 @@ class CloudVerification:
623
623
  "run_source": self.context.run_source,
624
624
  "group_id": self.context.group_id,
625
625
  "branch": self.context.prover_version if self.context.prover_version else '',
626
- 'ci': Util.is_ci_or_git_action()
626
+ 'ci': Util.is_ci_or_git_action(),
627
+ 'agent': Util.detect_agent()
627
628
  }
628
629
 
629
630
  _, _, version = Util.get_package_and_version()
@@ -18,7 +18,6 @@ from pathlib import Path
18
18
  from typing import Dict, Any, cast
19
19
 
20
20
  import CertoraProver.certoraContext as Ctx
21
- import CertoraProver.certoraApp as App
22
21
  from CertoraProver.certoraContextClass import CertoraContext
23
22
  from Shared import certoraUtils as Util
24
23
 
@@ -151,7 +150,3 @@ def check_conf_content(context: CertoraContext) -> None:
151
150
  if Ctx.is_evm_app_class(context) and not context.files and not context.project_sanity and not context.foundry:
152
151
  raise Util.CertoraUserInputError("Mandatory 'files' attribute is missing from the configuration")
153
152
  context.files = context.conf_file_attr.get('files')
154
- if context.app == App.SorobanApp and not context.files and not context.build_script:
155
- raise Util.CertoraUserInputError("'files' or 'build script' must be set for Soroban runs")
156
-
157
- context.files = context.conf_file_attr.get('files')
@@ -1956,6 +1956,17 @@ class SorobanProverAttributes(CommonAttributes, InternalUseAttributes, BackendAt
1956
1956
  )
1957
1957
  )
1958
1958
 
1959
+ CARGO_MANIFEST_PATH = AttrUtil.AttributeDefinition(
1960
+ attr_validation_func=Vf.validate_readable_file,
1961
+ help_msg="Cargo.toml of the contract to build when no build script is given",
1962
+ default_desc="The nearest Cargo.toml above the working directory",
1963
+ argparse_args={
1964
+ 'action': AttrUtil.UniqueStore
1965
+ },
1966
+ affects_build_cache_key=True,
1967
+ disables_build_cache=False
1968
+ )
1969
+
1959
1970
 
1960
1971
  class SuiProverAttributes(CommonAttributes, InternalUseAttributes, BackendAttributes, DeprecatedAttributes):
1961
1972
  FILES = AttrUtil.AttributeDefinition(
@@ -196,6 +196,15 @@ class CertoraContextValidator:
196
196
  if len(context.files) > 1:
197
197
  raise Util.CertoraUserInputError("Rust projects must specify exactly one executable in 'files'.")
198
198
 
199
+ if Attrs.is_soroban_app():
200
+ # these are passed to `cargo certora-sbf`, which Soroban never runs
201
+ for attr in (Attrs.RustAttributes.CARGO_TOOLS_VERSION, Attrs.RustAttributes.SOLANA_SBF_ARCH):
202
+ if getattr(context, attr.get_conf_key(), None) is not None:
203
+ raise Util.CertoraUserInputError(f"'{attr.get_conf_key()}' applies to Solana builds only")
204
+ if context.cargo_manifest_path and (context.files or context.build_script):
205
+ raise Util.CertoraUserInputError("'cargo_manifest_path' only applies when neither 'files' nor "
206
+ "'build_script' is set")
207
+
199
208
  if context.url_visibility and context.local:
200
209
  validation_logger.info("'url_visibility' has no effect in local tool runs")
201
210
  set_attr_default(context, attr_name=Attrs.CommonAttributes.URL_VISIBILITY.name.lower(),
@@ -0,0 +1,154 @@
1
+ # The Certora Prover
2
+ # Copyright (C) 2025 Certora Ltd.
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, version 3 of the License.
7
+ #
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with this program. If not, see <https://www.gnu.org/licenses/>.
15
+
16
+ import subprocess
17
+ import json
18
+ import logging
19
+ import os
20
+ from dataclasses import dataclass, field
21
+ from pathlib import Path
22
+ from typing import Any
23
+
24
+ from CertoraProver.certoraContextClass import CertoraContext
25
+ from Shared import certoraUtils as Util
26
+ from CertoraProver.certoraCollectRunMetadata import RunMetaData
27
+ from CertoraProver.certoraCollectConfigurationLayout import collect_configuration_layout
28
+
29
+ build_script_logger = logging.getLogger("build_script")
30
+
31
+
32
+ @dataclass(frozen=True)
33
+ class BuildLogs:
34
+ """Files holding the build's captured output, as reported by a build script."""
35
+ stdout: "str | None"
36
+ stderr: "str | None"
37
+
38
+
39
+ @dataclass(frozen=True)
40
+ class RustBuild:
41
+ """
42
+ What a Rust build hands back to the prover, however it was produced: by a build script, by `cargo certora-sbf`,
43
+ or by cargo driven from the package's metadata. Paths are kept as reported, relative ones included, since the
44
+ source tree is built relative to the working directory.
45
+ """
46
+ project_directory: Path
47
+ sources: list[str]
48
+ executable: Path
49
+ logs: "BuildLogs | None" = None
50
+ solana_inlining: list[str] = field(default_factory=list)
51
+ solana_summaries: list[str] = field(default_factory=list)
52
+
53
+
54
+ def update_metadata(context: CertoraContext, attr_name: str) -> None:
55
+ metadata = RunMetaData.load_file()
56
+ metadata['conf'][attr_name] = getattr(context, attr_name)
57
+ RunMetaData.dump_file(metadata)
58
+
59
+ configuration_layout = collect_configuration_layout()
60
+ configuration_layout.dump()
61
+
62
+
63
+ def declared_files(json_obj: dict, key: str) -> list[str]:
64
+ """The relative paths a build script listed under `key`, accepting a single string for a one-element list."""
65
+ values = json_obj.get(key)
66
+ if isinstance(values, str):
67
+ values = [values] if values else []
68
+ if not isinstance(values, list):
69
+ return []
70
+ for value in values:
71
+ assert isinstance(value, str), f"expected a string in '{key}', got {value} of type {type(value).__name__}"
72
+ if os.path.isabs(value):
73
+ raise Util.CertoraUserInputError(f"Invalid path in '{key}': {value} must be relative")
74
+ return values
75
+
76
+
77
+ def add_solana_files_to_context(context: CertoraContext, build: RustBuild) -> None:
78
+ """Inlining and summary files the build reported, unless the conf already names them."""
79
+ for attr_name, values in [(Util.SOLANA_INLINING, build.solana_inlining),
80
+ (Util.SOLANA_SUMMARIES, build.solana_summaries)]:
81
+ if getattr(context, attr_name, None) or not values:
82
+ continue
83
+ cwd = os.getcwd()
84
+ setattr(context, attr_name, [os.path.relpath(build.project_directory / value, cwd) for value in values])
85
+ update_metadata(context, attr_name)
86
+
87
+
88
+ def apply_build_result(context: CertoraContext, build: RustBuild) -> None:
89
+ context.rust_project_directory = str(build.project_directory)
90
+ context.rust_sources = build.sources
91
+ if build.logs is not None:
92
+ context.rust_logs_stdout = build.logs.stdout
93
+ context.rust_logs_stderr = build.logs.stderr
94
+
95
+ assert not context.files, f"apply_build_result: expecting files to be empty, got: {context.files}"
96
+ context.files = [str(build.executable)]
97
+
98
+ add_solana_files_to_context(context, build)
99
+
100
+
101
+ def parse_build_script_output(build_script: str, stdout: str) -> RustBuild:
102
+ json_obj: Any = json.loads(stdout)
103
+
104
+ if not json_obj:
105
+ raise Util.CertoraUserInputError(f"No JSON output from build script {build_script}")
106
+
107
+ if missing_keys := [key for key in ["success", "project_directory", "sources", "executables"] if key not in json_obj]:
108
+ raise Util.CertoraUserInputError(f"Missing required keys in build script response: {', '.join(missing_keys)}")
109
+
110
+ if not json_obj.get("success"):
111
+ raise Util.CertoraUserInputError(
112
+ f"Compilation failed using build script: {build_script}\n"
113
+ f"Success value in JSON response is False."
114
+ )
115
+
116
+ project_directory = Path(json_obj["project_directory"])
117
+ log = json_obj.get("log")
118
+ return RustBuild(
119
+ project_directory=project_directory,
120
+ sources=json_obj["sources"],
121
+ executable=project_directory / json_obj["executables"],
122
+ logs=BuildLogs(stdout=log.get('stdout'), stderr=log.get('stderr')) if log is not None else None,
123
+ solana_inlining=declared_files(json_obj, Util.SOLANA_INLINING),
124
+ solana_summaries=declared_files(json_obj, Util.SOLANA_SUMMARIES),
125
+ )
126
+
127
+
128
+ def run_rust_build(context: CertoraContext, build_cmd: list[str]) -> None:
129
+ """Run a build script, or `cargo certora-sbf`, and take the build it describes in its JSON output."""
130
+ try:
131
+ build_script_logger.info(f"Building by calling `{' '.join(build_cmd)}`")
132
+ result = subprocess.run(build_cmd, capture_output=True, text=True)
133
+
134
+ if getattr(context, 'cargo_build_verbose', False) and result.stderr:
135
+ build_script_logger.info(f"Build stderr:\n{result.stderr}")
136
+
137
+ # Check if the script executed successfully
138
+ if result.returncode != 0:
139
+ raise Util.CertoraUserInputError(f"Error running the script {context.build_script}\n{result.stderr}")
140
+
141
+ build = parse_build_script_output(context.build_script, result.stdout)
142
+ except Util.CertoraUserInputError:
143
+ raise
144
+ except FileNotFoundError as e:
145
+ raise Util.CertoraUserInputError(f"File not found: {e}")
146
+ except json.JSONDecodeError as e:
147
+ raise Util.CertoraUserInputError(f"Error decoding JSON: {e}")
148
+ except Exception as e:
149
+ raise Util.CertoraUserInputError(f"An unexpected error occurred: {e}")
150
+
151
+ apply_build_result(context, build)
152
+
153
+ if context.test == str(Util.TestValue.AFTER_BUILD_RUST):
154
+ raise Util.TestResultsReady(context)
@@ -46,6 +46,7 @@ from Shared import certoraUtils as Util
46
46
  from Shared.certoraLogging import LoggingManager
47
47
  from certoraRun import run_certora
48
48
  from Shared.proverCommon import CertoraRunResult, CertoraFoundViolations
49
+ import certoraSorobanProver
49
50
  from certoraSorobanProver import run_soroban_prover
50
51
  from Shared import certoraValidateFuncs as Vf
51
52
  from CertoraProver.Compiler.CompilerCollectorFactory import get_relevant_compiler
@@ -744,7 +745,28 @@ class MutateApp:
744
745
  self.server = self.config_server()
745
746
 
746
747
  def is_soroban_run(self) -> bool:
747
- return (hasattr(self.prover_context, 'build_script') and self.prover_context is not None)
748
+ """
749
+ A conf file does not say which prover it belongs to, so its shape has to. A Soroban conf carries a build
750
+ script, a cargo manifest path, a prebuilt wasm, or none of the inputs an EVM run has to name.
751
+ """
752
+ prover_context = getattr(self, 'prover_context', None)
753
+ if prover_context is None:
754
+ return False
755
+ conf = vars(prover_context)
756
+ if 'build_script' in conf or 'cargo_manifest_path' in conf:
757
+ return True
758
+ if files := conf.get('files'):
759
+ return all(str(file).endswith(('.wasm', '.wat')) for file in files)
760
+ return not any(key in conf for key in ('verify', 'bytecode_jsons', 'project_sanity', 'foundry'))
761
+
762
+ def mutant_build_command(self) -> str:
763
+ """
764
+ The shell command universalmutator runs against each candidate mutant; a zero exit status keeps the mutant.
765
+ A build script is that command. Without one, the prover builds from the package metadata, so the prover is.
766
+ """
767
+ if build_script := getattr(self.prover_context, 'build_script', None):
768
+ return str(build_script)
769
+ return f'"{sys.executable}" "{certoraSorobanProver.__file__}" "{self.conf}" --build_only'
748
770
 
749
771
  def config_server(self) -> str:
750
772
  """
@@ -1396,7 +1418,7 @@ class MutateApp:
1396
1418
  file_to_mutate = Path(os.path.normpath(mutant[MConstants.FILE_TO_MUTATE]))
1397
1419
  mutants_location = Path(mutant[MConstants.MUTANTS_LOCATION])
1398
1420
  num_of_mutants = int(mutant[MConstants.NUM_MUTANTS])
1399
- run_universal_mutator(file_to_mutate, self.prover_context.build_script, mutants_location, num_of_mutants)
1421
+ run_universal_mutator(file_to_mutate, self.mutant_build_command(), mutants_location, num_of_mutants)
1400
1422
  self.add_dir_to_mutants(ret_mutants, mutants_location, file_to_mutate)
1401
1423
  return ret_mutants
1402
1424
 
@@ -422,6 +422,43 @@ def is_ci_or_git_action() -> bool:
422
422
  return False
423
423
 
424
424
 
425
+ # Sources: github.com/vercel/vercel packages/detect-agent/src/index.ts and github.com/unjs/std-env src/agents.ts
426
+ # Order matters: CLI agents first, IDE-hosted agents (Cursor) last.
427
+ _AGENT_ENV_VARS = {
428
+ "CLAUDECODE": "claude-code",
429
+ "CLAUDE_CODE": "claude-code",
430
+ "CODEX_SANDBOX": "codex",
431
+ "CODEX_THREAD_ID": "codex",
432
+ "CODEX_CI": "codex",
433
+ "GEMINI_CLI": "gemini-cli",
434
+ "COPILOT_AGENT": "copilot",
435
+ "COPILOT_CLI": "copilot",
436
+ "COPILOT_MODEL": "copilot",
437
+ "ANTIGRAVITY_AGENT": "antigravity",
438
+ "AUGMENT_AGENT": "augment",
439
+ "OPENCODE": "opencode",
440
+ "OPENCODE_CLIENT": "opencode",
441
+ "JUNIE_DATA": "junie",
442
+ "GOOSE_PROVIDER": "goose",
443
+ "REPL_ID": "replit",
444
+ "CURSOR_AGENT": "cursor",
445
+ "CURSOR_TRACE_ID": "cursor",
446
+ }
447
+
448
+ # AI_AGENT is free text that anything in the process tree can set. Keep only printable characters and
449
+ # send at most this many. 64 is the limit that the proposed AI_AGENT standard (agentsmd/agents.md#136) uses.
450
+ _MAX_AGENT_LENGTH = 64
451
+
452
+
453
+ def detect_agent() -> Optional[str]:
454
+ raw = os.environ.get("AI_AGENT", "")
455
+ if agent := "".join(c for c in raw[:_MAX_AGENT_LENGTH] if c.isprintable()).strip():
456
+ return agent
457
+ return next(
458
+ (name for var, name in _AGENT_ENV_VARS.items() if os.environ.get(var)), None
459
+ )
460
+
461
+
425
462
  def get_certora_ci_name() -> Union[str, None]:
426
463
  return os.environ.get('CERTORA_CI_CLIENT', None)
427
464
 
@@ -1348,6 +1385,7 @@ class TestValue(NoValEnum):
1348
1385
  AFTER_BUILD_RUST = auto()
1349
1386
  AFTER_RULE_SPLIT = auto()
1350
1387
  SOLANA_BUILD_CMD = auto()
1388
+ SOROBAN_BUILD_CMD = auto()
1351
1389
  CHECK_ZIP = auto()
1352
1390
  STORAGE_EXTENSION_LAYOUT = auto()
1353
1391
 
@@ -1384,6 +1422,13 @@ def check_packages_arguments(context: SimpleNamespace) -> None:
1384
1422
  setattr(context, 'packages_path', os.getenv("NODE_PATH", f"{Path.cwd() / 'node_modules'}"))
1385
1423
  context_logger.debug(f"context.packages_path is {context.packages_path}")
1386
1424
 
1425
+ # Capture the complete forge-resolved remappings (including nested submodule remappings.txt that foundry
1426
+ # auto-resolves) so build_source_tree persists them into .certora_sources/remappings.txt. Done regardless of
1427
+ # whether context.packages was pre-populated from the conf, because the project's own top-level remappings.txt
1428
+ # may be partial.
1429
+ if find_nearest_foundry_toml() and shutil.which("forge") is not None:
1430
+ context.forge_remappings = get_mappings_from_forge_remappings()
1431
+
1387
1432
  if getattr(context, 'packages', None) and len(context.packages) > 0:
1388
1433
  context.package_name_to_path = dict()
1389
1434
  for package_str in context.packages:
@@ -345,7 +345,7 @@ def run_mutate(file_to_mutate: Path, mutants_location: Path, build_command: str)
345
345
 
346
346
  def run_universal_mutator(
347
347
  file_to_mutate: Path,
348
- build_script: str,
348
+ build_command: str,
349
349
  mutants_location: Path,
350
350
  num_mutants: int = NUM_MUTANTS,
351
351
  seed: int = SEED,
@@ -356,7 +356,9 @@ def run_universal_mutator(
356
356
 
357
357
  Args:
358
358
  file_to_mutate (Path): Path to the Rust source file.
359
- build_script (str): Command to execute for each mutant to verify compilation.
359
+ build_command (str): Command to execute for each mutant to verify compilation. universalmutator copies each
360
+ candidate over the source file before running it and restores the file afterwards, so the command
361
+ just builds the project as it stands.
360
362
  mutants_location (Path): Directory to store generated mutants.
361
363
  num_mutants (int): Upper bound on the number of mutants to generate (default: {NUM_MUTANTS}).
362
364
  seed (int): Seed value for random selection to ensure repeatable testing (default: {SEED}).
@@ -367,7 +369,6 @@ def run_universal_mutator(
367
369
  Exception: For unexpected errors.
368
370
  """
369
371
  backup_file = None
370
- build_command = f"cp MUTATE & {build_script}"
371
372
 
372
373
  atexit.register(clean_temp_files, file_to_mutate)
373
374
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: certora-cli-beta
3
- Version: 8.20.3
3
+ Version: 8.21.0
4
4
  Summary: Runner for the Certora Prover
5
5
  Home-page: https://pypi.org/project/certora-cli-beta
6
6
  Author: Certora
@@ -38,4 +38,4 @@ Dynamic: requires-dist
38
38
  Dynamic: requires-python
39
39
  Dynamic: summary
40
40
 
41
- Commit 4ef546d. Build and Run scripts for executing the Certora Prover on Solidity smart contracts.
41
+ Commit b65ac9c. Build and Run scripts for executing the Certora Prover on Solidity smart contracts.
@@ -1,5 +1,6 @@
1
1
  [console_scripts]
2
2
  certoraCVLFormatter = certora_cli.certoraCVLFormatter:entry_point
3
+ certoraConcord = certora_cli.certoraConcord:entry_point
3
4
  certoraEVMProver = certora_cli.certoraEVMProver:entry_point
4
5
  certoraEqCheck = certora_cli.certoraEqCheck:equiv_check_entry_point
5
6
  certoraMutate = certora_cli.certoraMutate:mutate_entry_point
@@ -0,0 +1 @@
1
+ {"name": "certora-cli-beta", "tag": "8.21.0", "branch": "", "commit": "b65ac9c", "timestamp": "20261130.10.53.646921", "version": "8.21.0"}
@@ -3,11 +3,11 @@ import setuptools
3
3
 
4
4
  setuptools.setup(
5
5
  name="certora-cli-beta",
6
- version="8.20.3",
6
+ version="8.21.0",
7
7
  author="Certora",
8
8
  author_email="support@certora.com",
9
9
  description="Runner for the Certora Prover",
10
- long_description="Commit 4ef546d. Build and Run scripts for executing the Certora Prover on Solidity smart contracts.",
10
+ long_description="Commit b65ac9c. Build and Run scripts for executing the Certora Prover on Solidity smart contracts.",
11
11
  long_description_content_type="text/markdown",
12
12
  url="https://pypi.org/project/certora-cli-beta",
13
13
  packages=setuptools.find_packages(),
@@ -32,6 +32,7 @@ setuptools.setup(
32
32
  "certoraSorobanProver = certora_cli.certoraSorobanProver:entry_point",
33
33
  "certoraEVMProver = certora_cli.certoraEVMProver:entry_point",
34
34
  "certoraRanger = certora_cli.certoraRanger:entry_point",
35
+ "certoraConcord = certora_cli.certoraConcord:entry_point",
35
36
  "certoraSuiProver = certora_cli.certoraSuiProver:entry_point",
36
37
  "certoraCVLFormatter = certora_cli.certoraCVLFormatter:entry_point"
37
38
  ]
@@ -1 +0,0 @@
1
- Commit 4ef546d. Build and Run scripts for executing the Certora Prover on Solidity smart contracts.
@@ -1,109 +0,0 @@
1
- # The Certora Prover
2
- # Copyright (C) 2025 Certora Ltd.
3
- #
4
- # This program is free software: you can redistribute it and/or modify
5
- # it under the terms of the GNU General Public License as published by
6
- # the Free Software Foundation, version 3 of the License.
7
- #
8
- # This program is distributed in the hope that it will be useful,
9
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
- # GNU General Public License for more details.
12
- #
13
- # You should have received a copy of the GNU General Public License
14
- # along with this program. If not, see <https://www.gnu.org/licenses/>.
15
-
16
- import subprocess
17
- import json
18
- import logging
19
- import os
20
- from typing import List
21
-
22
- from CertoraProver.certoraContextClass import CertoraContext
23
- from Shared import certoraUtils as Util
24
- from CertoraProver.certoraCollectRunMetadata import RunMetaData
25
- from CertoraProver.certoraCollectConfigurationLayout import collect_configuration_layout
26
-
27
- build_script_logger = logging.getLogger("build_script")
28
-
29
-
30
- def update_metadata(context: CertoraContext, attr_name: str) -> None:
31
- metadata = RunMetaData.load_file()
32
- metadata['conf'][attr_name] = getattr(context, attr_name)
33
- RunMetaData.dump_file(metadata)
34
-
35
- configuration_layout = collect_configuration_layout()
36
- configuration_layout.dump()
37
-
38
-
39
- def add_solana_files_to_context(context: CertoraContext, json_obj: dict) -> None:
40
- for solana_files_attr in [Util.SOLANA_INLINING, Util.SOLANA_SUMMARIES]:
41
- if not getattr(context, solana_files_attr, None):
42
- values = json_obj.get(solana_files_attr)
43
- if isinstance(values, str) and values != '':
44
- values = [values]
45
- if isinstance(values, list) and len(values) > 0:
46
- cwd: str = os.getcwd()
47
- new_value = []
48
- for value in values:
49
- assert isinstance(value, str), (f"expected a string in '{solana_files_attr}', got {value} "
50
- f"of type {type(value).__name__}")
51
- if os.path.isabs(value):
52
- raise Util.CertoraUserInputError(f"Invalid path in '{solana_files_attr}': {value} "
53
- "must be relative")
54
- abs_path: str = os.path.join(context.rust_project_directory, value)
55
- new_value.append(os.path.relpath(abs_path, cwd))
56
- setattr(context, solana_files_attr, new_value)
57
- update_metadata(context, solana_files_attr)
58
-
59
-
60
- def run_rust_build(context: CertoraContext, build_cmd: List[str]) -> None:
61
-
62
- try:
63
- build_script_logger.info(f"Building by calling `{' '.join(build_cmd)}`")
64
- result = subprocess.run(build_cmd, capture_output=True, text=True)
65
-
66
- if getattr(context, 'cargo_build_verbose', False) and result.stderr:
67
- build_script_logger.info(f"Build stderr:\n{result.stderr}")
68
-
69
- # Check if the script executed successfully
70
- if result.returncode != 0:
71
- raise Util.CertoraUserInputError(f"Error running the script {context.build_script}\n{result.stderr}")
72
-
73
- json_obj = json.loads(result.stdout)
74
-
75
- if not json_obj:
76
- raise Util.CertoraUserInputError(f"No JSON output from build script {context.build_script}")
77
-
78
- if missing_keys := [key for key in ["success", "project_directory", "sources", "executables"] if key not in json_obj]:
79
- raise Util.CertoraUserInputError(f"Missing required keys in build script response: {', '.join(missing_keys)}")
80
-
81
- if not json_obj.get("success"):
82
- raise Util.CertoraUserInputError(
83
- f"Compilation failed using build script: {context.build_script}\n"
84
- f"Success value in JSON response is False."
85
- )
86
-
87
- context.rust_project_directory = json_obj.get("project_directory")
88
- context.rust_sources = json_obj.get("sources")
89
- context.rust_executables = json_obj.get("executables")
90
- if json_obj.get("log") is not None:
91
- context.rust_logs_stdout = json_obj.get("log").get('stdout')
92
- context.rust_logs_stderr = json_obj.get("log").get('stderr')
93
-
94
- add_solana_files_to_context(context, json_obj)
95
-
96
- assert not context.files, f"run_rust_build: expecting files to be empty, got: {context.files}"
97
- context.files = [os.path.join(context.rust_project_directory, context.rust_executables)]
98
-
99
- if context.test == str(Util.TestValue.AFTER_BUILD_RUST):
100
- raise Util.TestResultsReady(context)
101
-
102
- except Util.TestResultsReady as e:
103
- raise e
104
- except FileNotFoundError as e:
105
- raise Util.CertoraUserInputError(f"File not found: {e}")
106
- except json.JSONDecodeError as e:
107
- raise Util.CertoraUserInputError(f"Error decoding JSON: {e}")
108
- except Exception as e:
109
- raise Util.CertoraUserInputError(f"An unexpected error occurred: {e}")
@@ -1 +0,0 @@
1
- {"name": "certora-cli-beta", "tag": "8.20.3", "branch": "", "commit": "4ef546d", "timestamp": "20261026.12.41.750951", "version": "8.20.3"}