feat(phase3-step9): Background Execution + Permission Gate#19
Merged
Conversation
…r missing plan_hash
This was referenced May 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase 3 Step 9 — Background Execution + Permission Gate. The runtime layer.
codec-agent-runnerPM2 daemon picks upstatus=approvedplans (from Step 8), executes their checkpoints autonomously via Qwen-3.6 ↔ skill loops. Permission gate enforces the manifest on every action. Strict-consent gate (Step 3 §1.7 reuse) on destructive ops. Resume after PM2 restart from last atomic checkpoint (Q5). Multi-agent concurrency cap = 3 (Q6, Q8 blocked occupies slot). Plan-hash tamper detection at run start (Q13).No UI yet — Step 10 picks that up. Step 9 alone is shippable: agents actually run; you observe via
audit.log+notifications.json.Reference
docs/PHASE3-BLUEPRINT.md§3docs/PHASE3-STEP9-PLAN.mdFiles
codec_agent_runner.pytests/test_agent_runner.pycodec_audit.pyPHASE3_STEP9_EVENTSfrozensetcodec_agent_plan.py_VALID_TRANSITIONSwith Step 9 runtime statusesroutes/agents.pyecosystem.config.jsAGENTS.mdAudit envelope
8 new schema:1 events.
agent_startedopens the per-agent operation envelope; subsequentagent_*events all share that single correlation_id (multi-emit op per Step 1 §1.4 contract).Permission gate (the core safety enforcement)
Every
Actionreturned by Qwen goes throughpermission_gate(action, agent_grants, global_grants):PermissionViolation(skill_not_authorized)PermissionViolation(path_not_authorized)PermissionViolation(domain_not_authorized)Destructive ops STILL hit Step 3 §1.7 strict-consent (universal floor) — even pre-approved.
State machine extension
completed,aborted,rejectedare terminal.Process supervision (Q15 adapted)
Q15 in the blueprint asked for
codec-heartbeatHTTP probe ofcodec-agent-runner. On implementation,codec-heartbeatonly probes HTTP services (LLM, Whisper, Kokoro, Vision) andcodec-agent-runneris a daemon by design (no HTTP). PM2'sautorestart: trueprovides crash recovery automatically; no additional probe needed. Documented in AGENTS.md §10.Test plan
tests/test_agent_runner.py→ 30 passed_run_agentpaths (happy / blocked / aborted / tampered / resume) testedAGENT_RUNNER_ENABLED=falseglobal kill switch testedgit pull pm2 start ecosystem.config.js --only codec-agent-runner pm2 restart codec-dashboard # picks up new abort/pause/resume/grant endpointsPOST /api/agentswith a project description, approve via/api/agents/{id}/approve, watch~/.codec/audit.logforagent_started+agent_checkpoint_*events. With Qwen-3.6 alive, the agent should actually run the plan to completion (or block on permission if manifest is tight)One plan deviation
The plan's
_VALID_TRANSITIONSmap omittedapproved → aborted— needed for the plan-tamper code path which detects tampering before transitioning torunning. Added"aborted"toapproved's frozenset. The Task 2 test asserts"running" in _VALID_TRANSITIONS["approved"](subset check, not equality), so it remains green.Out of scope (Step 10)
messages.jsonlfor agent timeline UI🤖 Generated with Claude Code