deer-flow/backend/tests/fixtures/skill_evolution_consumer.py
Ryker_Feng d1d0958bea
feat(skills): add guarded evolution host APIs (#5645)
* feat(skills): add guarded evolution host APIs

* docs(agents): avoid growing saturated guidance chains

* fix(skills): address mutation host review findings

* fix(skills): order name fence before projection lock

* fix(skills): preserve composite toggle lock order

* fix(skills): address catalog and pagination review feedback

* docs: keep subagent guidance within merged instruction budget

---------

Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
2026-10-18 21:17:02 +08:00

26 lines
1.7 KiB
Python

"""External-consumer contract fixture: imports only the standalone public API."""
from deerflow_extension_api import ExtensionRuntimeDeps
async def exercise(deps: ExtensionRuntimeDeps, *, thread_id: str, run_id: str, name: str):
evidence, skills = deps.completed_run_evidence, deps.skill_mutations
assert evidence is not None and skills is not None
snapshot = await evidence.get_snapshot(thread_id=thread_id, run_id=run_id)
assert snapshot.seal_state == "sealed"
await evidence.read_events(snapshot_ref=snapshot.snapshot_ref)
skill = await skills.read_skill(source_ref=snapshot.snapshot_ref, name=name)
proposal = await skills.stage(source_refs=(snapshot.snapshot_ref,), target_ref=skill.target_ref, expected_revision=skill.revision, content=skill.content + "\nA fixed test improvement.\n", idempotency_key="fixture-stage")
bundle = await skills.read_proposal_bundle(proposal_id=proposal.proposal_id)
assert bundle.base_revision == skill.revision
result = await skills.check(proposal_id=proposal.proposal_id)
assert result.decision == "allow"
operation = await skills.commit(proposal_id=proposal.proposal_id, idempotency_key="fixture-commit")
assert operation.publication == "APPLIED"
assert await skills.get_operation(operation_id=operation.operation_id) == operation
assert await skills.find_operation(idempotency_key="fixture-commit") == operation
reverted = await skills.revert(operation_id=operation.operation_id, expected_current_revision=operation.after_revision, idempotency_key="fixture-revert")
assert reverted.publication == "APPLIED"
assert reverted.after_revision.mutation_seq > operation.after_revision.mutation_seq
return operation, reverted