agora.plan.predicate_registry

Named-predicate registry: the bridge between YAML plan references and runtime Predicates.

YAML plans reference postconditions by name + args. The registry maps name → factory(**args) → Predicate. Factories must accept only JSON- serializable kwargs — that constraint is what makes plans round-trippable.

The registered names and the predicate names the factories produce are kept byte-for-byte identical to the inline patterns used in the runner scripts (_postcond_file_exists etc.) so Specification.fingerprint hashes match for structural round-trip tests.

All six factories from agora.fleet.runtime_postconditions are registered eagerly at import, plus the four previously-inline helpers that are lifted out of the runner scripts into this module as public factories.

Functions

build_predicate(name[, args])

Construct a Predicate by registered name + kwargs.

describe_registered_predicates()

Return a structured catalog of every registered predicate.

list_registered_predicates()

Sorted list of registered predicate names (useful for generating docs + planner KB).

postcond_api_spec_covers_brief_deliverables([...])

rel must contain at least one method/function matching each brief deliverable's action verb.

postcond_api_spec_is_valid([rel])

rel (under work_dir) must parse as a valid API spec.

postcond_class_attributes_consistent(rel)

v2.9 Phase 3 gate: every self.X read must have a matching self.X = ... somewhere in the same class.

postcond_file_contains(rel, substring)

rel (under work_dir) must contain the literal substring.

postcond_file_exists(rel)

An artifact path containing rel must be recorded by the task.

postcond_mark_complete()

The task must have called mark_complete (directly or auto-synthesized).

postcond_max_line_length(rel[, max_chars])

Every non-blank line of rel (under work_dir) must be ≤ max_chars.

postcond_no_task_exceeds_complexity(plan_path)

Plan-level gate: no single task in plan_path exceeds the budget.

postcond_plan_draft_all_agents_valid()

Plan-builder gate: every agent in the draft passes validate_agent.

postcond_plan_draft_every_task_has_postcondition()

Plan-builder gate: every task in the draft must have ≥ 1 postcondition.

postcond_plan_draft_has_min_agents([min_agents])

Plan-builder gate: draft must carry ≥ min_agents agents.

postcond_plan_draft_has_min_tasks([min_tasks])

Plan-builder gate: ctx.plan_draft must carry at least min_tasks.

postcond_py_compiles(rel)

rel must parse via py_compile AND have no module-scope undefined names.

postcond_tests_have_assertions(rel)

rel (under work_dir) must be a test file where NO test_* function is a pure pytest.skip placeholder.

register_predicate(name)

Decorator: register factory under name.

agora.plan.predicate_registry.build_predicate(name, args=None)[source]

Construct a Predicate by registered name + kwargs.

agora.plan.predicate_registry.list_registered_predicates()[source]

Sorted list of registered predicate names (useful for generating docs + planner KB).

agora.plan.predicate_registry.postcond_file_contains(rel, substring)[source]

rel (under work_dir) must contain the literal substring.

agora.plan.predicate_registry.postcond_file_exists(rel)[source]

An artifact path containing rel must be recorded by the task.

agora.plan.predicate_registry.postcond_mark_complete()[source]

The task must have called mark_complete (directly or auto-synthesized).

agora.plan.predicate_registry.postcond_no_task_exceeds_complexity(plan_path, max_chars=3000, max_stages=3, max_postconditions=8)[source]

Plan-level gate: no single task in plan_path exceeds the budget.

Loads the YAML at plan_path (relative to work_dir), inspects every task, and fails if any task’s combined instruction length, stage count, or postcondition count exceeds the thresholds. Used by the plan-builder’s assemble_plan task to force decomposition via in-phase auto-retry.

agora.plan.predicate_registry.postcond_py_compiles(rel)[source]

rel must parse via py_compile AND have no module-scope undefined names.

agora.plan.predicate_registry.register_predicate(name)[source]

Decorator: register factory under name.

Factories must accept only JSON-serializable kwargs (str, int, float, bool, list, dict). Callers should not register from within tests at import time — see tests/plan/conftest.py for the cleanup pattern if a test needs to add a predicate temporarily.