generated from coulomb/repo-seed
Implement refinement hardening workplan
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from phase_memory.models import LifecycleState, MemoryNode
|
||||
from phase_memory.lifecycle import plan_compaction
|
||||
from phase_memory.models import LifecycleAction, LifecycleActionKind, LifecycleState, MemoryNode
|
||||
from phase_memory.service import (
|
||||
HEALTH_REPORT_SCHEMA,
|
||||
KONTEXTUAL_DELEGATION_SCHEMA,
|
||||
@@ -76,6 +77,58 @@ def test_service_runner_handles_profile_driven_lifecycle_plan() -> None:
|
||||
assert ("event.restart", "refresh") in actions
|
||||
|
||||
|
||||
def test_service_runner_handles_package_compile_and_audit_query() -> None:
|
||||
runner = LocalServiceRunner()
|
||||
selection = {
|
||||
"schema_version": "markitect.memory.selection.v1",
|
||||
"id": "selection.service",
|
||||
"nodes": ["decision.boundary"],
|
||||
"events": ["event.activation"],
|
||||
}
|
||||
|
||||
compiled = runner.handle("package.compile", {"selection": selection, "source_ref": "service-test"})
|
||||
audit = runner.handle("audit.query", {"filters": {"operation": "package.compile"}})
|
||||
|
||||
assert compiled["operation"] == "package.compile"
|
||||
assert compiled["data"]["package_response"]["package_ref"] == "package:selection.service"
|
||||
assert audit["operation"] == "audit.query"
|
||||
assert audit["count"] == 1
|
||||
assert audit["events"][0]["source"]["ref"] == "service-test"
|
||||
assert audit["retention"]["mode"] == "in_memory"
|
||||
|
||||
|
||||
def test_service_runner_handles_review_gated_lifecycle_apply() -> None:
|
||||
runner = LocalServiceRunner()
|
||||
node = runner.runtime.graph_store.save_node(MemoryNode("node.review", "episode", "Review gated content"))
|
||||
compact = plan_compaction([node]).to_dict()
|
||||
|
||||
denied = runner.handle("lifecycle.apply", {"actions": [compact]})
|
||||
applied = runner.handle("lifecycle.apply", {"actions": [compact], "approval_marker": "review:service"})
|
||||
audit = runner.handle("audit.query", {"filters": {"operation": "lifecycle.apply", "dry_run": False}})
|
||||
|
||||
assert denied["valid"] is False
|
||||
assert denied["data"]["denied"][0]["reason"] == "review_required"
|
||||
assert applied["valid"] is True
|
||||
assert runner.runtime.graph_store.get_node(applied["data"]["applied"][0]["target_id"]).kind == "summary"
|
||||
assert audit["count"] == 2
|
||||
|
||||
|
||||
def test_service_runner_handles_non_review_lifecycle_apply() -> None:
|
||||
runner = LocalServiceRunner()
|
||||
runner.runtime.graph_store.save_node(MemoryNode("node.stale.service", "episode"))
|
||||
action = LifecycleAction(
|
||||
LifecycleActionKind.MARK_STALE,
|
||||
"node.stale.service",
|
||||
from_state=LifecycleState.ACTIVE,
|
||||
to_state=LifecycleState.STALE,
|
||||
)
|
||||
|
||||
applied = runner.handle("lifecycle.apply", {"actions": [action.to_dict()]})
|
||||
|
||||
assert applied["valid"] is True
|
||||
assert runner.runtime.graph_store.get_node("node.stale.service").lifecycle == LifecycleState.STALE
|
||||
|
||||
|
||||
def test_profile_driven_runtime_config_resolves_file_backed_adapters(tmp_path) -> None:
|
||||
config = RuntimeConfig.from_profile(
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user