Goal Contract Reference
A goal contract (@picasso/goals GoalContract) defines what Picasso should finish, where it may work, how much budget it may spend, and — critically — how completion is judged by machine-verifiable signals rather than the agent's word.
Contracts are validated by validateGoalContract / assertValidGoalContract and persisted to goals.json. Every field below maps directly to the implementation in packages/goals/src/contract.ts.
Shape
id: 123e4567-e89b-42d3-a456-426614174000
objective: Migrate the auth module and keep the repository green.
completionCriteria:
- type: all-tests-pass
testCommand: pnpm test
- type: command-exits-zero
command: pnpm typecheck
- type: agent-self-assesses-complete
rubric: The diff is scoped to the auth migration and verification passes.
budget:
maxWallTime: 24h
maxCostUSD: 25
maxSteps: 1000
maxSubagentSpawns: 20
scope:
allowedTools: [read_file, edit_file, exec, spawn_subagent]
allowedSubagents: [codebase_investigator, test_writer, generalist]
permissionMode: safe
workspaceRoot: /workspace/picasso
rejectUnparseableEdits: true
escalation:
onRepeatedFailure: escalate
repeatedFailureThreshold: 3
onBudgetExhausted: pause
notifications:
onComplete: [dashboard]
onStuck: [dashboard, webhook]
onBudgetMilestone: [50, 80, 95]
audit:
deliverables:
- path: packages/auth/src/index.ts
note: argon2id migration entry point
failOnDebris: falseBudget fields (budget)
maxWallTime: real-time cap as a duration string (30m,24h,7d).maxCostUSD: provider cost cap.maxSteps: loop step cap.maxSubagentSpawns: subagent fan-out cap.
Scope fields (scope)
allowedTools: tools the runtime may expose (e.g.read_file,edit_file,exec).allowedSubagents: subagent roles the goal may spawn.permissionMode:safe,auto,yolo, orparanoid.workspaceRoot: absolute path the goal is bound to.rejectUnparseableEdits(optional): when true, a write-time guardrail reverts
an edit that leaves a touched file unparseable and feeds the error back (defaults on for every mode except yolo).
Escalation fields (escalation)
onRepeatedFailure:escalate,pivot, orabort.repeatedFailureThreshold: failing assessments before escalation.onBudgetExhausted:pauseorabort.
Notifications fields (notifications)
onComplete/onStuck: channels (dashboard,email,slack,webhook).onBudgetMilestone: percentage thresholds (e.g.[50, 80, 95]).
Completion criteria (completionCriteria)
Every contract must contain at least one machine-verifiable criterion — agent self-assessment alone is rejected by validation. The machine-verifiable set is: all-tests-pass, specific-tests-pass, file-matches, command-exits-zero, lint-clean, pr-mergeable, custom-script, and score-improves.
all-tests-pass
- type: all-tests-pass
testCommand: pnpm testPasses when the test command exits zero.
specific-tests-pass
- type: specific-tests-pass
testCommand: pnpm --filter @picasso/auth test
testPaths:
- packages/auth/test/**/*.test.tsPasses when the scoped test command exits zero.
file-matches
- type: file-matches
path: packages/auth/src/index.ts
pattern: argon2idPasses when the file exists and its contents match the regular expression.
command-exits-zero
- type: command-exits-zero
command: pnpm typecheckPasses when the command exits zero.
lint-clean
- type: lint-clean
lintCommand: pnpm lintPasses when the lint command exits zero.
pr-mergeable
- type: pr-mergeable
prRef: owner/repo#123Passes when the pull request is mergeable (checks green, not changes-requested).
custom-script
- type: custom-script
scriptPath: scripts/verify-goal.shPasses when the script exists and exits zero.
score-improves
- type: score-improves
scoreCommand: node bench.js # prints a single number to stdout
direction: higher # or: lower
baseline: 87.5 # optional; captured at pre-flight when omitted
minDelta: 0.5 # optional; default 0 (strictly better)Runs scoreCommand, parses the trailing number, and passes when it improves on baseline by at least minDelta in direction. When baseline is omitted it is captured during pre-flight and persisted on the goal record.
agent-self-assesses-complete
- type: agent-self-assesses-complete
rubric: The summary names behavior changes, risk, and verification.Recorded as trust-prior evidence. It never re-runs in the final audit and never counts toward the coverage numerator — it cannot, on its own, complete a goal.
Audit config (audit, optional)
deliverables: declared output paths the final ship audit checks against
the full working tree (committed + staged + unstaged + untracked). A missing deliverable fails the audit.
failOnDebris: when true, the cleanliness scan failing (debug prints, stray
TODO/FIXME, dead imports on added lines) fails the audit instead of just warning.
Verification lifecycle
- Pre-flight — before the loop, the deduplicated machine commands run once.
A red baseline aborts the run (override with --skip-preflight). score-improves baselines are captured here.
- Loop — plan → act → observe → assess with drift detection and
self-correction; criteria are evaluated each iteration.
- Final ship audit — after the loop reports complete, every machine
criterion is independently re-verified, declared deliverables are checked against the full working tree, and a coverage score (re-verified / (re-verified + trusted)) is reported. Coverage under 70% emits an "eyeball before merge" warning. A failed audit downgrades the goal to blocked rather than reporting success.
Related CLI flags
goal create --deliverable <path>(repeatable) — declare audit deliverables.goal create --parent <id>— link a depth-1 subgoal (a parent completes only
when all children complete and pass their own audits).
goal run --skip-preflight— bypass the pre-flight baseline check.goal run --allow-unverified— run without a real machine oracle (discouraged).goal run --fail-on-debris— fail the final audit when debris is found.
Resume behavior
When a cap is hit, the goal persists a checkpoint and returns a resume token. Resuming reloads the latest safe checkpoint and continues with the remaining scope and updated budget. The oracle gate and final audit also apply on resume.