src/rune/effect_mediation.py: singleton registry with scopes; eight-path outcomes (success/error/timeout/cancel/crash/duplicate/retry/compensation; retry non-terminal; scope-crash marks pending effects for owner review); duplicate idempotency keys; opt-in audit enforcement (subprocess/file- write/delete/rename/network watched — undeclared events UNMEDIATED-> INELIGIBLE); missing telemetry = outcome unknown -> INELIGIBLE, never 'no effect'. Sieve: pass = ELIGIBLE_FOR_FURTHER_EVALUATION only; protected/shared-credential/live-ContextBroker/canonical-write -> OWNER_REVIEW; non-restorable -> INELIGIBLE. Bound: tool_executor, operator, plugin, child workers, store. 42/42 red-first incl. cheapest- disproof matrix (declared write + hidden effect under all 8 paths). Main-session verify: green own run.
124 lines
4.9 KiB
Python
124 lines
4.9 KiB
Python
"""Admission dispatch for the wave-K7-mediation build (openspec task 0.7,
|
|
DEP06).
|
|
|
|
classify + activate + admit (the headless scaffolding entry law,
|
|
scripts/admit_wave_seam_registry.py pattern): one enforced effect-mediation
|
|
registry + eligibility sieve on the existing rune project, user-dispatch
|
|
approved (approval_ref='user:wave-K7-mediation dispatch').
|
|
"""
|
|
import json
|
|
import os
|
|
import sys
|
|
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "src"))
|
|
|
|
from rune import construction_activation as cact # noqa: E402
|
|
from rune import construction_admission as cadm # noqa: E402
|
|
from rune import construction_mode as cmode # noqa: E402
|
|
from rune import scaffold as sc # noqa: E402
|
|
|
|
ROOT = os.path.join(os.path.dirname(__file__), "..")
|
|
|
|
OBJECTIVE = (
|
|
"DEP06 effect-mediation registry (openspec task 0.7): ONE enforced "
|
|
"registry (src/rune/effect_mediation.py) + eligibility sieve across "
|
|
"success/error/timeout/cancel/crash/duplicate/retry/compensation paths, "
|
|
"binding tool_executor/operator/plugin/child/subprocess/store boundaries "
|
|
"(store binds at scaffold.commit — structural_store stays import-neutral "
|
|
"shared core per the frozen test_no_rune_module_imports law); hidden/"
|
|
"uninstrumented effect fixtures return UNKNOWN/ineligible (audit "
|
|
"enforcement observes subprocess/file-write/network events against "
|
|
"declared mediation records); missing telemetry is never interpreted as "
|
|
"no effect (pending effects stay in the report as outcome unknown → "
|
|
"INELIGIBLE); sieve pass = ELIGIBLE_FOR_FURTHER_EVALUATION only, never "
|
|
"semantic safety; flagged classes (protected/shared-credential/"
|
|
"live-ContextBroker/canonical-write/non-restorable) block or route to "
|
|
"owner review"
|
|
)
|
|
AFFECTED = [
|
|
"src/rune/effect_mediation.py",
|
|
"src/rune/tool_executor.py",
|
|
"src/rune/rune_operator.py",
|
|
"src/rune/microkernel.py",
|
|
"src/rune/orchestration/workers.py",
|
|
"src/rune/memory_store.py",
|
|
"src/rune/scaffold.py",
|
|
"src/rune/structural_store.py",
|
|
"tests/test_effect_mediation.py",
|
|
"scripts/admit_wave_effect_mediation.py",
|
|
]
|
|
|
|
|
|
def main() -> int:
|
|
store = os.path.join(ROOT, "store", "scaffold")
|
|
scaffold = sc.Scaffold(store, "rune")
|
|
|
|
md = cmode.classify_mode(
|
|
OBJECTIVE,
|
|
target_project="rune",
|
|
project_exists=True,
|
|
affected_surface=AFFECTED,
|
|
)
|
|
print("classified mode:", md.mode)
|
|
|
|
need = {
|
|
"need_id": "need-wave-K7-mediation",
|
|
"objective": OBJECTIVE,
|
|
"origin": "worker",
|
|
"project": "rune",
|
|
"task_ref": "wave-K7-mediation",
|
|
"affected_surface": AFFECTED,
|
|
"evidence_refs": [
|
|
"docs/openspec/changes/add-native-rune-tui/tasks.md",
|
|
"research/harness-survey/self-transformation/synthesis.json",
|
|
],
|
|
}
|
|
act = cact.activate(md, need=need, scaffold=scaffold,
|
|
builder="wave-K7-mediation")
|
|
print("activated:", act.get("activated"), act.get("mode"))
|
|
|
|
env = cadm.admit(
|
|
act,
|
|
objective=OBJECTIVE,
|
|
builder="wave-K7-mediation",
|
|
affected_surface=AFFECTED,
|
|
evidence_refs=need["evidence_refs"],
|
|
origin="worker",
|
|
task_ref="wave-K7-mediation",
|
|
expected_new_entities=[
|
|
"src/rune/effect_mediation.py (the ONE registry: scopes, "
|
|
"eight-path outcomes, audit enforcement, eligibility sieve)",
|
|
"tests/test_effect_mediation.py (frozen red-first battery, "
|
|
"42 tests incl. the cheapest-disproof matrix: one declared "
|
|
"write + one hidden effect under every path)",
|
|
"scripts/admit_wave_effect_mediation.py (this dispatch)",
|
|
],
|
|
expected_runtime_effects=[
|
|
"tool_executor/_execute_tool_now + _run_command, operator "
|
|
"send_task, microkernel.fire hooks, orchestration workers.run_all, "
|
|
"memory_store.add_entry and scaffold.commit record one "
|
|
"boundary effect per call inside any open mediation scope; "
|
|
"no-op outside scopes",
|
|
"enable_audit_enforcement() makes undeclared subprocess/"
|
|
"file-write/network events inside a scope INELIGIBLE "
|
|
"(unmediated_effect) under every outcome path",
|
|
],
|
|
verification_obligations=[
|
|
"RUNE_CA_CORE=python RUNE_CM_CORE=python PYTHONPATH=src "
|
|
"python -m pytest tests/test_effect_mediation.py green (42)",
|
|
"ruff check on all touched files passes",
|
|
"tests/test_structural_store.py::test_no_rune_module_imports "
|
|
"stays green (shared-core neutrality preserved)",
|
|
],
|
|
approval_ref="user:wave-K7-mediation dispatch",
|
|
contract_id="ADMIT-wave-K7-mediation",
|
|
project_store=store,
|
|
project_id="rune",
|
|
)
|
|
print(json.dumps(env, indent=2, default=str)[:2400])
|
|
return 0 if env.get("success") else 1
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|