PCQ
The PCQ server provides tools for managing, validating, executing, and analyzing ML experiments through a contract-based workflow.
Project Inspection & Validation
Resolve and inspect
cq.yamlproject configuration, structure, and contract stateValidate project setup (static + contract) before execution, including optional ExperimentPlan validation
Check agent runtime asset status (installed/missing/stale/divergent)
Experiment Execution & Finalization
Execute commands defined in
cq.yamlwith auto-wired config environment, capturing logsFinalize completed runs by generating
run_record.jsonandvalidation_report.jsonValidate completed output directories against defined contracts
Run Analysis
Describe compact, decision-oriented summaries of runs (metrics, validation status, lineage, artifacts)
Compare two runs by diffing metric deltas, config changes, and lineage
Trace a run's full ancestry via its parent chain
Experiment Planning
Apply an
ExperimentPlanto modifycq.yamlconfigs with provenance trackingExpand an
ExperimentPlanSetinto N output directories for hyperparameter sweeps
Scaffolding & Agent Integration
Initialize new projects with
cq.yaml,train.py, and optionalpyproject.tomlInstall agent runtime assets (AGENTS.md/CLAUDE.md, skill files) for agents like Claude Code and Codex, with optional
.mcp.jsonwiring
All operations support JSON/JSONL output for machine consumption.
pcq
pcq is the contract for agent-run ML experiments. This repository hosts the contract specification under
spec/and the reference Python implementation undersrc/pcq/. Install the reference impl:uv add pcq(Apache-2.0).
The contract turns a project with cq.yaml into a reproducible experiment
unit. The reference Python implementation loads config, resolves output
paths, captures metrics, writes standard artifacts, finalizes run evidence,
and exposes JSON/JSONL/MCP surfaces that coding agents, CI jobs, notebooks,
and services can consume. See spec/IMPLEMENTATIONS.md
for the registered implementation list (Python reference + CQ Go production
worker today) and the procedure for adding yours.
pcq is not a training framework, model zoo, adapter matrix, or CQ-only
client. Use PyTorch, Hugging Face Trainer, Lightning, sklearn, TabPFN, PyCaret,
XGBoost, shell scripts, remote jobs, or project-local research code. The
contract is the integration layer.
pcq does not operate the model.
pcq operates the experiment boundary.SITE | INTRODUCTION | V4_DIRECTION | VISION | AGENT_OPERABILITY | RUN_RECORD | AGENT_OPERATING_GUIDE | CHANGELOG
Contract specification (single source of truth):
spec/INDEX.md |
SPEC |
CQ_YAML_RUNTIME_CONTRACT |
JSON_CONTRACTS |
STRICTNESS |
CQ_MCP_SPEC |
VERSIONING |
CONFORMANCE |
schemas/ (auto-exported via scripts/export_schemas.py)
Case studies (external evidence): mnist-dogfood | tabular-dogfood | mcp-dogfood | cq-worker-dogfood
Agent-readable site files: llms.txt, llms-full.txt, agent-manifest.json.
Identity
pcq = open-source experiment evidence/control library
cq = managed execution + orchestration + dashboard + agent loopCQ service is one managed consumer of the contract. pcq remains useful without
CQ: locally, in CI, in notebooks, and inside third-party orchestrators.
Related MCP server: MCP Bridgelement
Why pcq
Framework-neutral — keep the training stack that fits the problem.
Agent-readable — use JSON/JSONL instead of terminal scraping.
Agent-verifiable — validate source, config, environment, metrics, artifacts, and run records.
Agent-operable — run, observe, validate, describe, compare, lineage, and iterate through stable commands.
Service-ready — CQ can consume the same contract for managed execution and automatic experiment loops.
What's New (v4.4 – v4.6)
Three agent-fillable metadata fields were added to run_record.json across the
last three minor releases, making each run's evidence richer with zero extra
code in most cases.
Field | Since | Captures | Auto-filled? |
| v4.4 | author / committer / operator — who ran the experiment | Yes (agent identity injected at runtime) |
| v4.5 | cpu / gpu / memory / os — where it ran | Yes ( |
| v4.6 | modality / task_kind / shape / PII-safe stats — what data | Semi-auto ( |
attribution — who
Records the human author, the AI committer, and the operator that launched the run. Coding agents (Claude Code, Codex) fill this automatically from their identity context.
pcq.attribution(
author={"kind": "human", "id": "alice"},
committer={"kind": "agent", "id": "claude-code"},
operator="ci-runner-42",
)Spec: spec/SPEC.md § Attribution
worker_spec — where
Records CPU model, core count, GPU kind/VRAM, total memory, and OS. Called with no arguments for a full auto-detection pass.
pcq.worker_spec() # 자동 감지 — 인수 불필요Spec: spec/SPEC.md § Worker Spec
fingerprint — what
Records dataset modality, task kind, sample count, size class, domain, and PII-safe summary statistics. Accepts a NumPy/pandas array or DataFrame and infers most fields.
pcq.fingerprint(X, y, modality="tabular")Spec: spec/SPEC.md § Fingerprint
All three fields are optional — existing runs remain valid. When present
they appear as first-class evidence in run_record.json and are surfaced
through pcq describe-run --json.
Reproducibility Substrate
3개의 선택적 필드로 독립 재현이 가능한 substrate를 run_record.json에 제공한다.
pcq는 검증하지 않는다 — 검증을 가능하게 만든다.
Field | Captures |
|
|
|
|
|
|
상세 스키마, PHI 게이트(R5), integrity 확장, R8 한계 문장: spec/SPEC.md § Reproducibility Pack
Note: code content sha proves WHAT code was recorded, not THAT it produced these outputs. See SPEC.md R8.
Note: pcq records claims, not judgments — intent is a recorded assertion (a fact about what was claimed), not a pcq verdict on success.
Installation
uv add pcq
# Optional — to expose pcq as MCP tools to agent runtimes:
uv add 'pcq[mcp]'pyproject.toml:
[project]
dependencies = ["pcq"] # core only
# or:
dependencies = ["pcq[mcp]"] # core + Model Context Protocol serverDocker (MCP server only)
A minimal container image is also published; it packages
pcq[mcp] from PyPI and runs pcq mcp serve on stdio.
docker build -t pcq .
docker run -i --rm pcq # MCP client attaches to stdin/stdoutThe image is intentionally scoped to the MCP server surface — for
pcq run, pcq describe-run, pcq agent install and other CLI
subcommands, install pcq directly with uv add pcq instead.
For a tag, branch, or private fork:
[tool.uv.sources]
pcq = { git = "https://github.com/playidea-lab/pcq.git", tag = "v4.1.0" }The PyPI distribution, import name, CLI command, GitHub repository, runtime
workspace, and JSON contract namespace are all pcq. Runtime contract names
from CQ remain stable: cq.yaml, CQ_CONFIG_JSON, and cq://.
Minimal Contract
cq.yaml declares the run:
name: sklearn-baseline
cmd: uv run python train.py
configs:
output_dir: output
seed: 42
strictness: 3
monitor: eval_acc
mode: max
metrics:
- epoch
- eval_acc
artifacts:
- output/
inputs: {}train.py can use any framework:
import pickle
import pcq
from sklearn.datasets import load_iris
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split
cfg = pcq.config()
out = pcq.output_dir()
pcq.seed_everything(cfg.get("seed", 42))
x, y = load_iris(return_X_y=True)
x_train, x_eval, y_train, y_eval = train_test_split(
x,
y,
test_size=0.25,
random_state=int(cfg.get("seed", 42)),
stratify=y,
)
model = RandomForestClassifier(random_state=int(cfg.get("seed", 42)))
model.fit(x_train, y_train)
eval_acc = float(model.score(x_eval, y_eval))
with (out / "model.pkl").open("wb") as f:
pickle.dump(model, f)
history = [{"epoch": 0, "eval_acc": eval_acc}]
pcq.log(**history[-1])
pcq.save_all(history=history, artifacts={"model": "model.pkl"})No sklearn adapter is required. The same pattern works for HF Trainer, Lightning, XGBoost, TabPFN, PyCaret, shell commands, or custom code.
Agent Command Surface
Read and validate the project:
pcq resolve --json
pcq inspect . --json
pcq validate . --strictness 2 --jsonRun the project:
pcq run --path . --json
pcq run --path . --jsonl
pcq run --path . --events output/events.jsonl --jsonValidate and summarize outputs:
pcq validate-run output --strictness 3 --json
pcq describe-run output --json
pcq compare-runs old_output new_output --json
pcq lineage output --jsonIterate:
pcq apply-plan experiment.plan.json --jsonAgent rule: prefer JSON/JSONL surfaces over scraping human output. pcq
reports facts; the agent or service chooses policy.
Standard Artifacts
A completed run should produce:
config.jsonmetrics.jsonmanifest.jsonrun_summary.jsonrun_record.jsonvalidation_report.json
run_record.json is the canonical completion object. It combines execution,
source, environment, input identity, metric schema, artifact manifest, agent
provenance, validation, and summary evidence.
Agent Runtime Assets
pcq can install its canonical agent instructions and skill into a project.
Package installation itself never mutates project agent files.
pcq agent install --target codex --path .
pcq agent install --target claude --path .
pcq agent install --target both --path . --dry-run --json
pcq agent status --target both --path . --jsonTo also wire the project for MCP-aware agents (Claude Code, Codex), install
pcq[mcp] and pass --mcp:
uv add 'pcq[mcp]'
pcq agent install --target claude --path . --mcp # writes .mcp.json
pcq mcp serve # stdio (default)This exposes 14 mcp__pcq__* tools (resolve_project, validate_run,
describe_run, compare_runs, ...) so agents call pcq directly without
subprocess parsing. See MCP Integration.
Reusable assets:
v4 Direction
v4 clarifies the product boundary:
contract-first workflow, not a 3-tier training API
project-local training code, not built-in production catalogs
contract scripts, not framework adapters
run evidence validation, not recipe ownership
JSON/JSONL facts, not prose parsing
See pcq v4 Direction.
Development
uv run ruff check src/ tests/ scripts/
uv run python -m compileall src/pcq
uv run pytest tests/ -q
bash scripts/release-smoke.shLicense
Apache-2.0.
Available Tools
14 toolsagent_installB
Install pcq agent runtime assets (AGENTS.md / CLAUDE.md managed block, .agents|.claude/skills/pcq/SKILL.md). Optionally write .mcp.json to wire pcq MCP server.
Inputs: mcp, path, force, target, +1 more.
agent_statusA
Inspect pcq agent runtime asset status (installed / missing / stale / divergent / unmanaged) without writing. Read-only.
Inputs: path, target.
apply_planA
Apply ExperimentPlan to project (modifies cq.yaml.configs only — never train.py). Provenance recorded under .pcq/plans/<plan_id>.json. Returns rejected envelope with reason='schema_invalid'|'validation_failed' on bad input.
Inputs: path, plan, plan_file.
apply_plansetA
Expand ExperimentPlanSet members into N output directories, each with its own cq.yaml + plan provenance. Returns rejected envelope with reason='schema_invalid'|'validation_failed' on bad input.
Inputs: path, force, planset, planset_file, +1 more.
compare_runsA
Diff two RunRecords (or output dirs). Returns metric deltas, config changes, lineage relation, decision_facts. Read-only.
Inputs: a (required), b (required).
describe_runA
Return a compact, decision-facts oriented summary of a RunRecord. Includes best/last metrics, validation status, lineage, artifact counts, decision_facts. Read-only.
Inputs: output_dir.
finalize_runB
Generate run_record.json + validation_report.json for an output directory. Walks ancestors to find project root if not provided. Writes to output_dir.
Inputs: output_dir (required), status, project_root.
init_experimentB
Scaffold a CQ-runnable experiment (cq.yaml + train.py contract script, optionally pyproject.toml + agent runtime assets).
Inputs: name, agent, force, output, +1 more.
inspect_projectA
Return project structure, entrypoint kind, contract state, and output evidence. Read-only.
Inputs: path.
lineage_chainC
Walk a RunRecord's parent chain. Returns ordered nodes from this run back to its earliest reachable ancestor. Read-only.
Inputs: max_depth, output_dir.
resolve_projectA
Resolve cq.yaml + CQ_CONFIG_JSON env into a single ResolvedConfig view. Returns project_root, cq_yaml_path, name, cmd, cfg, declared_metrics, output_dir. Read-only — does not create directories or mutate state.
Inputs: path, cq_yaml_path.
run_experimentA
Execute cq.yaml.cmd with auto-wired CQ_CONFIG_JSON env. Captures stdout/stderr to .pcq/run_*.log. For long-running GPU training, prefer the CQ service queue.
Inputs: path, config_only.
validate_projectB
Run static and contract validation before execution. Optional inline ExperimentPlan / ExperimentPlanSet validation. Read-only.
Inputs: path, plan, planset, plan_file, +2 more.
validate_runB
Run post-run validation gates (manifest / metrics / run_summary) on a completed output directory. Read-only.
Inputs: output_dir, strictness, rescan_manifest.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 14 tools
Each tool targets a distinct phase or action: plan application, scaffolding, execution, finalization/validation, and run analysis. The read-only analysis tools (describe_run, compare_runs, lineage_chain) and project inspection tools (resolve_project, inspect_project, validate_project) are separated by clear semantic boundaries. There are no pairs that appear to do the same thing.
Most tools follow an imperative verb_noun pattern (run_experiment, validate_project, describe_run). A few deviate: agent_install and agent_status are noun-first, lineage_chain is a noun phrase, and apply_planset compresses plan_set into one word. These are minor and do not prevent readability.
At 14 tools, the surface is within the well-scoped range and each tool covers a discrete step in the CQ lifecycle. The grouping of scaffold/configure/run/finalize/validate/analyze plus agent asset helpers feels intentional, with no obvious dead weight.
The main lifecycle is well covered: init, plan application, run, finalize, validate, and analyze. Minor gaps exist around explicit discovery/cleanup (e.g., listing or removing plans/runs), but agents can work around these using inspect_project, finalize_run artifacts, or output directories.
Maintenance
Related MCP Connectors
Machine-native research commons for agent evidence, discovery, rooms, and bounded research quests.
Watchdog for unattended AI agents: alerts, evidence checks and a verifiable proof per run.
Policy-aware AI execution, verification, cost, and trajectory evidence for agents.
Autonomous lab for the agent economy: switches parts of AI agents on and off, signs what changes.
Related MCP Servers
- AlicenseAqualityDmaintenanceA scientific experiment log MCP server for AI agents that stores predictions, causal claims, and verdicts, enabling queryable causal maps and calibration of intuition over diagnostics.17MIT
- AlicenseNot gradedqualityBmaintenanceEnables provider-neutral policy enforcement, identity, persistent storage, and telemetry collection for reinforcement learning, evaluation, analytics, replay, and downstream dataset generation across standalone applications and agent systems.MIT
- AlicenseNot gradedqualityBmaintenanceEnables agents to track ML experiments with a reproducible write contract, internal git snapshots, and a queryable knowledge graph, plus a live web UI for humans.Apache 2.0
- AlicenseAqualityCmaintenanceEnables AI agents and their users to submit, route, and monitor training jobs across free-tier GPU clouds (Kaggle, Colab, Lightning, local MPS) through a local daemon that tracks quota, explains routing decisions, and gates long or secret-reading agent jobs behind human approval.81MIT