feat(phase3-step8): Plan + Permission Contract#17
Merged
Conversation
Add 6 named audit event constants and PHASE3_STEP8_EVENTS frozenset to codec_audit.py; introduce tests/test_agent_plan.py with initial TDD test. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…add cid to grant emits, simplify _ask_user fallback
3 tasks
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 8 — Plan + Permission Contract. Drop-a-project planning layer.
User describes a project → Qwen-3.6 drafts structured plan with permission manifest → user approves in PWA → grants persisted to
~/.codec/agents/<id>/grants.jsonwithplan_hashfor Step 9 tamper detection.No execution yet — Step 9 picks that up. Step 8 alone is shippable: drafted plans sit in
awaiting_approval, approved plans sit inapprovedwaiting for the runner.Reference
docs/PHASE3-BLUEPRINT.md§2 (approved 2026-05-03)docs/PHASE3-STEP8-PLAN.md(19 tasks, 89 atomic steps)What ships
codec_agent_plan.py(NEW)routes/agents.py(extended)tests/test_agent_plan.py(NEW)codec_audit.py(modified)codec_dashboard.py(modified)AGENTS.md(modified)Audit envelope
6 new schema:1 events, all paired correlation_ids per Step 1 §1.4 contract:
agent_plan_drafted(info) — agent_id, checkpoint_count, estimated_duration_minutes, skills_count, domains_countagent_plan_approved(info) — agent_id, plan_hash (sha256), checkpoint_count, skills_count, domains_countagent_plan_rejected(warning) — agent_id, reasonagent_plan_revised(info) — agent_id, checkpoint_countagent_global_grant_added(info) — kind, valueagent_global_grant_removed(info) — kind, valuePHASE3_STEP8_EVENTSfrozenset exposed.Permission model (Q4 — plan-and-grant + global allowlist)
Per-agent grants (extracted from plan): valid for that agent's lifetime, written to
~/.codec/agents/<id>/grants.jsonat approval. Plan-hash (sha256) computed at approval; Step 9 will verify on every daemon tick (Q13 tamper detection).Global allowlist (
~/.codec/agent_global_grants.json): cross-agent permissions. Items already in global → markedauto_approvedin per-agent grants. User manages via/api/agent_global_grantsGET/POST/DELETE. 4 grant kinds:network_domains,read_paths,write_paths,skills.Vague-description handling (Q3)
Up to 3 rounds of
codec_ask_user.askclarifying questions before drafting. After 3 rounds without convergence: status=plan_failed, reason=description_too_vague. Tunable viaMAX_CLARIFYING_ROUNDSconstant (default 3).State machine
Step 9 will extend with: approved → running → checkpoint_completed / blocked_* / aborted / completed.
Kill switches
AGENT_PLANNING_ENABLED=false— drafting disabled (existing plans untouched)Test plan
tests/test_agent_plan.py→ 31 passedcodec_skill_registrypm2 restart codec-dashboard(no skill install needed; module is in repo root)POST /api/agentswith a project description, verify drafted plan appears,POST /api/agents/{id}/approve, verifygrants.json+plan_hashwrittenOut of scope (Step 9 + 10)
codec_agent_runner.pydaemon (Step 9)Implementation note
Plan + Implementation Plan documents (
docs/PHASE3-BLUEPRINT.md+docs/PHASE3-STEP8-PLAN.md) approved by user 2026-05-03 via thesuperpowers:brainstorming+superpowers:writing-plansskill flow. Implementation followed TDD strictly: every commit has a failing test → implementation → passing test cycle.🤖 Generated with Claude Code