Skip to content

Add contract-sized subtask guardrails#120

Merged
azalio merged 1 commit into
mainfrom
codex/2604-039-concern-guardrails
May 17, 2026
Merged

Add contract-sized subtask guardrails#120
azalio merged 1 commit into
mainfrom
codex/2604-039-concern-guardrails

Conversation

@azalio
Copy link
Copy Markdown
Owner

@azalio azalio commented May 17, 2026

Summary

  • Add a deterministic blueprint contract gate so /map-plan and /map-efficient fail oversized, mixed-concern, malformed, duplicate-ID, dangling-dependency, or untraceable subtasks before implementation starts.
  • Align Claude/Codex planner and decomposer prompts, Actor context, Monitor/FinalVerifier checks, shipped templates, and BLUEPRINT_SCHEMA around the same subtask contract metadata.
  • Close improvement-plan item 2604.039 as a shipped runtime slice while leaving hard/soft constraint typing and deeper artifact lineage as follow-up work.

Validation

  • make lint
  • pytest -m "not slow"
  • uv run --no-sync mapify init /var/folders/3j/zmvdy5_56bjcg1kmrx05dltcf7yldq/T/opencode/mapify-contract-guardrails-2604-039-rerun4 --no-git --mcp none
  • Generated-project smoke: python3 .map/scripts/map_step_runner.py validate_blueprint_contract valid-blueprint.json
  • Generated-project smoke: invalid nested blueprint fails with validator errors for unknown dependency, oversized/mixed subtask, non-logical step, and missing validation criteria
  • Independent review pass: no actionable findings

Copilot AI review requested due to automatic review settings May 17, 2026 13:12
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a deterministic blueprint contract gate that prevents /map-plan and /map-efficient from proceeding to implementation with oversized, mixed-concern, malformed, duplicate-ID, dangling-dependency, or untraceable subtasks. The new validate_blueprint_contract function in map_step_runner.py is shipped as the runtime enforcement point, with corresponding metadata (expected_diff_size, concern_type, one_logical_step, split_rationale, concern_justification, coverage_map) wired through planner/decomposer prompts, Actor context, Monitor/FinalVerifier checks, and BLUEPRINT_SCHEMA. Docs and improvement-plan tracking are updated to mark this as the shipped first slice of item 2604.039.

Changes:

  • Add validate_blueprint_contract() to .map/scripts/map_step_runner.py (and the templated copy) with broad regression tests for sizing/concern/coverage rules, duplicate IDs, and bad dependencies.
  • Extend BLUEPRINT_SCHEMA to require new contract metadata and support nested {"blueprint": {...}} payloads; surface contract fields in Actor XML packets and context block.
  • Align Claude/Codex planner skills, decomposer agents, Monitor, FinalVerifier, README, USAGE, ARCHITECTURE, and roadmap/improvement docs around the same contract.

Reviewed changes

Copilot reviewed 26 out of 26 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/mapify_cli/templates/map/scripts/map_step_runner.py Adds validate_blueprint_contract, CLI dispatch, Actor packet/context fields, and nested-blueprint unwrap in load_blueprint.
.map/scripts/map_step_runner.py Mirror of the runtime script with the same additions.
src/mapify_cli/schemas.py Adds contract fields, ST-NNN patterns, coverage_map, and blueprint-wrapper anyOf to BLUEPRINT_SCHEMA.
src/mapify_cli/templates/skills/map-plan/SKILL.md, .claude/skills/map-plan/SKILL.md Require new metadata, replace inline validator with validate_blueprint_contract, surface fields in human plan.
src/mapify_cli/templates/codex/skills/map-plan/SKILL.md, .codex/skills/map-plan/SKILL.md Same updates for the Codex skill.
src/mapify_cli/templates/skills/map-efficient/SKILL.md, .claude/skills/map-efficient/SKILL.md Add contract metadata requirements and the validator call into the efficient flow.
src/mapify_cli/templates/agents/task-decomposer.md, .claude/agents/task-decomposer.md Add coverage_map and contract metadata to the decomposer output schema and checklist.
src/mapify_cli/templates/codex/agents/decomposer.toml, .codex/agents/decomposer.toml Codex decomposer equivalent.
src/mapify_cli/templates/agents/monitor.md, .claude/agents/monitor.md Add subtask contract violation as an auto-reject signal.
src/mapify_cli/templates/agents/final-verifier.md, .claude/agents/final-verifier.md Add blueprint contract row and verification step.
tests/test_map_step_runner.py New regression coverage for validate_blueprint_contract and contract fields in the context block.
tests/test_decomposition.py New schema tests for contract metadata, nested decomposer output, and dependency/coverage patterns.
tests/test_skills.py Regression tests asserting planning prompts and decomposer agents reference the new fields.
README.md, docs/USAGE.md, docs/ARCHITECTURE.md, docs/roadmap.md, docs/improvement-plan.md, docs/improvement-done.md Doc updates describing and tracking the shipped contract gate.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@azalio azalio merged commit 4386f8c into main May 17, 2026
10 checks passed
@azalio azalio deleted the codex/2604-039-concern-guardrails branch May 17, 2026 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants