api¶
Programmatic API — the layer the CLI and the MCP server both wrap (verify, validate, scaffold, inspect_dataset).
api
¶
Programmatic API for the crossverify verification harness.
These functions are the single source of truth for running a verification: the
command-line interface (:mod:crossverify.cli) and the MCP server
(:mod:crossverify.mcp_server) are thin wrappers over them. Unlike the CLI, they
return structured data instead of printing and exiting, so a caller — a human
script or an autonomous agent — can branch on the result without parsing console
text.
The honest-scope caveat (:data:SCOPE_CAVEAT) is carried in every :func:verify
result so an automated caller cannot quietly over-claim a verified analysis.
_check_dict(result)
¶
Serialize a :class:~crossverify.checks.CheckResult to a plain dict.
Source code in crossverify/api.py
_output_paths(out_dir)
¶
Map the four written artifacts to their absolute paths under out_dir.
validate(project_path, *, force_contain=False)
¶
Load a project file and return its validation problems.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_path
|
Path to the YAML project file. |
required | |
force_contain
|
bool
|
When |
False
|
Returns:
| Type | Description |
|---|---|
list[str]
|
A list of human-readable problem strings; an empty list means the project |
list[str]
|
is valid and ready to :func: |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the project file does not exist. |
ValueError
|
If the project file omits the required |
Source code in crossverify/api.py
inspect_dataset(csv_path)
¶
Summarize a dataset (Phase-1 intake) without running an analysis.
Loads the CSV and reports shape, columns, and the Phase-1 intake checks and artifacts, so a caller can confirm the data matches the raw source before pointing an analysis at it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
csv_path
|
Path to the CSV dataset. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
A dict with |
dict
|
Phase-1 |
dict
|
|
Source code in crossverify/api.py
scaffold(target_dir)
¶
Scaffold a new project directory with starter config and analysis stubs.
Writes project.yaml, analysis.py, and analysis.R into target_dir
(created if needed). Existing files are left untouched, so re-running is
non-destructive.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target_dir
|
Directory to scaffold into. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
A dict with |
dict
|
|
Source code in crossverify/api.py
verify(project_path, *, phases=None, skip_r=False, seed=None, out=None, force_contain=False)
¶
Run the six-phase verification pipeline and return structured results.
Loads and validates the project, then runs the requested phases (1 intake,
2 transforms, 3 consistency, 4 reproducibility, 5 cross-tool triangulation),
and compiles the report artifacts. If the analysis adapter declares a
prepare() step, it is the single source of truth for the analyzed frame
(Phase-2 snapshot, Phase-3 ranges, and the frame handed to run() all derive
from it) and is called at most once, only when a phase actually needs it.
A failed check is a normal outcome (verdict == "fail"), not an exception;
only a structurally broken project raises. A project that fails validation
returns verdict == "invalid" with a problems list rather than running
any user code.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_path
|
Path to the YAML project file. |
required | |
phases
|
Iterable of phase numbers to run; |
None
|
|
skip_r
|
bool
|
If |
False
|
seed
|
Optional override for the project's random seed. |
None
|
|
out
|
Output directory for the artifacts; defaults to
|
None
|
|
force_contain
|
bool
|
When |
False
|
Returns:
| Type | Description |
|---|---|
dict
|
A dict carrying the overall |
dict
|
|
dict
|
includes |
dict
|
rows, environment fields, and |
dict
|
includes |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the project file does not exist. |
ValueError
|
If the project file omits the required |
Source code in crossverify/api.py
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 | |