Skip to content

Add mutation boundary prompt guardrails#139

Merged
azalio merged 2 commits into
mainfrom
codex/2604-040-constraint-provider-rules
May 20, 2026
Merged

Add mutation boundary prompt guardrails#139
azalio merged 2 commits into
mainfrom
codex/2604-040-constraint-provider-rules

Conversation

@azalio
Copy link
Copy Markdown
Owner

@azalio azalio commented May 20, 2026

Summary

  • add Mutation Boundary Constraints to write-capable Claude and Codex provider surfaces
  • add regression coverage for source and shipped mutation-boundary prompt guardrails
  • close improvement-plan item 2604.040 and capture reusable learning/docs

User impact

Installed MAP workflows now tell agents not to edit unrelated files, change dependencies, or refactor neighboring code unless the current task/subtask explicitly requires it. Required scope expansion should be reported as a blocker or tradeoff instead of silently widening the diff.

Validation

  • pytest tests/test_skills.py::TestSkillStructure::test_write_capable_claude_surfaces_have_constraint_first_boundaries tests/test_skills.py::TestSkillStructure::test_write_capable_codex_surfaces_have_mutation_boundaries tests/test_template_sync.py -v
  • generated Claude/Codex mapify init smoke inspecting installed provider files
  • make lint
  • pytest -m "not slow"
  • pytest tests/test_skills.py tests/test_template_sync.py -v
  • PYTHONPATH=src python -m mapify_cli.skill_ir src/mapify_cli/templates/skills src/mapify_cli/templates/codex/skills --format json
  • make test-e2e

Validation boundary

  • Full pytest and the slow Claude SDK module were attempted, but each exceeded the 30-minute tool timeout without a deterministic failure message.

Copilot AI review requested due to automatic review settings May 20, 2026 15:38
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

Adds “Mutation Boundary Constraints” guardrails to MAP’s write-capable Claude and Codex prompt surfaces so agents avoid silently expanding diffs (unrelated files, dependency churn, neighboring refactors) unless explicitly required by the current task/subtask contract. This is reinforced with regression tests that scan both source and shipped templates, plus documentation updates capturing the invariant and review checks.

Changes:

  • Introduces mutation-boundary constraint sections across write-capable Claude skill/agent surfaces and Codex scaffolds (source + shipped templates).
  • Adds regression tests to ensure required guardrail wording is present (and partially ordered constraint-before-directive).
  • Documents the new maintainer guardrail and records the improvement-plan completion/learned checks.

Reviewed changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tests/test_skills.py Adds mutation-boundary regression tests and shared phrase/pattern definitions.
src/mapify_cli/templates/skills/map-task/SKILL.md Adds Mutation Boundary Constraints section to shipped /map-task.
src/mapify_cli/templates/skills/map-fast/SKILL.md Adds Mutation Boundary Constraints section + reinforces constraint wording inside the Actor prompt block.
src/mapify_cli/templates/skills/map-efficient/SKILL.md Adds Mutation Boundary Constraints section + reinforces constraint wording inside the Actor <task> block.
src/mapify_cli/templates/skills/map-debug/SKILL.md Adds Mutation Boundary Constraints section + reinforces constraint wording in fix prompt block.
src/mapify_cli/templates/codex/skills/map-fast/SKILL.md Adds Mutation Boundary Constraints to shipped Codex $map-fast scaffold.
src/mapify_cli/templates/codex/AGENTS.md Adds Mutation Boundary Constraints to shipped Codex AGENTS.md.
src/mapify_cli/templates/agents/actor.md Adds Mutation Boundary Constraints to shipped Claude Actor agent prompt.
README.md Documents mutation-boundary constraints as a product behavior.
docs/USAGE.md Documents the maintainer guardrail and points to the enforcing tests.
docs/learned/testing-strategies.md Captures learned guidance about regression testing mutation-boundary wording.
docs/learned/review-checks.md Adds a review check to require mutation boundaries near direct-edit prompts.
docs/learned/commands.md Adds suggested commands for running the new mutation-boundary tests.
docs/learned/architecture-patterns.md Records the pattern of pairing write directives with explicit negative constraints.
docs/improvement-plan.md Removes the completed 2604.040 plan section now that it’s implemented.
docs/improvement-loop-log.md Logs the 2604.040 decision, validation, and reusable commands/invariants.
docs/improvement-done.md Records completion summary for 2604.040 and validation steps.
docs/ARCHITECTURE.md Adds “Mutation Boundary Constraints” to the architecture overview bullets.
.codex/skills/map-fast/SKILL.md Adds Mutation Boundary Constraints to the repo’s Codex source scaffold.
.codex/AGENTS.md Adds Mutation Boundary Constraints to the repo’s Codex source AGENTS.md.
.claude/skills/map-task/SKILL.md Adds Mutation Boundary Constraints to the repo’s Claude /map-task.
.claude/skills/map-fast/SKILL.md Adds Mutation Boundary Constraints + reinforces constraint wording in Actor prompt block.
.claude/skills/map-efficient/SKILL.md Adds Mutation Boundary Constraints + reinforces constraint wording in Actor <task> block.
.claude/skills/map-debug/SKILL.md Adds Mutation Boundary Constraints + reinforces constraint wording in fix prompt block.
.claude/agents/actor.md Adds Mutation Boundary Constraints to the repo’s Claude Actor agent prompt.

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

Comment on lines +41 to +48
## Mutation Boundary Constraints

Every write must stay inside the current subtask contract.

- Do not edit unrelated files, even if they are nearby or easy to clean up.
- Do not add, remove, or upgrade dependencies unless the current contract explicitly names that dependency change.
- Do not refactor neighboring code unless the validation criteria cannot pass without that exact refactor.
- If a dependency change, broad refactor, or scope expansion seems necessary, stop and report it as a blocker/tradeoff instead of doing it silently.
Comment on lines +24 to +28
## Mutation Boundary Constraints

- Do not edit unrelated files, even if they are nearby or easy to clean up.
- Do not add, remove, or upgrade dependencies unless the task explicitly names that dependency change.
- Do not refactor neighboring code unless the acceptance criteria cannot pass without that exact refactor.
Comment thread .codex/skills/map-fast/SKILL.md Outdated
Comment on lines +24 to +28
## Mutation Boundary Constraints

- Do not edit unrelated files, even if they are nearby or easy to clean up.
- Do not add, remove, or upgrade dependencies unless the task explicitly names that dependency change.
- Do not refactor neighboring code unless the acceptance criteria cannot pass without that exact refactor.
Comment thread .claude/agents/actor.md Outdated
Comment on lines +41 to +48
## Mutation Boundary Constraints

Every write must stay inside the current subtask contract.

- Do not edit unrelated files, even if they are nearby or easy to clean up.
- Do not add, remove, or upgrade dependencies unless the current contract explicitly names that dependency change.
- Do not refactor neighboring code unless the validation criteria cannot pass without that exact refactor.
- If a dependency change, broad refactor, or scope expansion seems necessary, stop and report it as a blocker/tradeoff instead of doing it silently.
Comment thread tests/test_skills.py Outdated
Comment on lines +112 to +114
MUTATION_DIRECTIVE_PATTERN = re.compile(
r"\b(?:Apply changes directly|Use Edit/Write|Implement exactly|"
r"Implement this subtask|Implement a fix|make changes)\b",
@azalio
Copy link
Copy Markdown
Owner Author

azalio commented May 20, 2026

Addressed Copilot review comments in e5b3325..HEAD follow-up: moved Actor and Codex -fast mutation-boundary sections before their first direct-write directives, expanded the directive pattern to include 'Apply the fix directly', and now applies ordering checks to Actor and Codex surfaces as well. Revalidated focused prompt/template tests, generated Claude/Codex ordering smoke, make lint, and pytest -m "not slow".

@azalio azalio merged commit cfcac81 into main May 20, 2026
6 checks passed
@azalio azalio deleted the codex/2604-040-constraint-provider-rules branch May 20, 2026 15:59
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