agora.core.contract
Manifold Specification Pattern.
Position: the ground-truth layer of the whole framework. A task’s postconditions —
not the model’s mark_complete self-report — decide whether it passed; the
orchestrator and the phase gate evaluate these predicates after the agent’s turn.
Every downstream verification (local gates F10, re-runnable run_check records
F20, phase-0 re-validation) is a predicate evaluated through this shape.
A Specification combines preconditions (must hold before execution) and
postconditions (must hold after). Each specification has a deterministic
fingerprint derived from its content; identical fingerprints drive retry
deduplication in later sprints.
Predicates are callables of shape (context: dict) -> (passed: bool, reason: str).
They are pure — they do not mutate the context (so re-evaluating a spec over a
workspace is side-effect-free, which is what makes mechanical gate re-eval safe).
Functions
|
Return |
|
Return |
|
Convenience constructor for predicates. |
Classes
A named condition evaluated against a context dict. |
|
Pre/post conditions that gate task execution. |
- class agora.core.contract.Predicate[source]
Bases:
objectA named condition evaluated against a context dict.
- __init__(name, description, evaluate)
- class agora.core.contract.Specification[source]
Bases:
objectPre/post conditions that gate task execution.
A
Specificationis attached to eachTask. The framework evaluatespreconditionsbefore the task runs andpostconditionsafter; a task is consideredsuccessiff every postcondition evaluatesTrue. The LLM’smark_completecall is observed but does not determine outcome — postconditions are the ground truth.All fields are immutable; the
fingerprintproperty derives a stable SHA-256 identity fromdescriptionplus the canonicalised predicate set. Identical fingerprints across two specifications mean they evaluate the same conditions, which the framework uses to deduplicate retries and learnings.- property fingerprint: str
description + sorted predicate identities.
- Type:
SHA-256 over canonical content
- __init__(preconditions=(), postconditions=(), description='')
- agora.core.contract.evaluate_preconditions(spec, context)[source]
Return
[(predicate_name, failure_reason), ...]for failed preconditions.