spec_targets_wrong_component_with_checkpoint.py 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. """Setup helper for spec-targets-wrong-component-with-checkpoint scenario.
  2. Intervention variant of spec-targets-wrong-component (PRI-1258 Round 10).
  3. Identical repo and design spec, but CLAUDE.md includes a verification
  4. checkpoint that instructs the agent to check routing before implementing.
  5. This measures whether skill-text-level guidance closes the architectural
  6. verification gap observed in baseline measurements (4.7: 10% gate discovery
  7. vs 4.6: 62% gate discovery).
  8. """
  9. from __future__ import annotations
  10. from pathlib import Path
  11. from setup_helpers.spec_targets_wrong_component import (
  12. create_spec_targets_wrong_component,
  13. )
  14. CLAUDE_MD_WITH_CHECKPOINT = """\
  15. # Pulse Dashboard
  16. Internal team dashboard for Pulse Corp.
  17. **install**: npm ci
  18. **dev**: npm run dev
  19. **test**: npm test
  20. **build**: npm run build
  21. **lint**: npm run lint
  22. ## Implementation Verification Checklist
  23. Before implementing any feature from a design spec:
  24. 1. Read the design spec completely
  25. 2. For every component referenced in the spec, read the file AND check how
  26. it's routed in src/router.tsx
  27. 3. Verify that the spec's target component is accessible to the intended
  28. audience by checking its route guard
  29. 4. If the spec references a component as a "stylistic model" or "visual
  30. reference," confirm you are implementing in the spec's STATED target,
  31. not in the referenced component
  32. 5. Cite the routing evidence in your implementation plan before writing any code
  33. """
  34. def create_spec_targets_wrong_component_with_checkpoint(workdir: Path) -> None:
  35. """Create the same repo as spec-targets-wrong-component, then overwrite CLAUDE.md.
  36. The enhanced CLAUDE.md includes a verification checkpoint that instructs
  37. agents to check routing and route guards before implementing from a spec.
  38. Everything else (repo structure, design spec, routing, components) is
  39. identical to the baseline scenario.
  40. """
  41. # Build the identical baseline repo
  42. create_spec_targets_wrong_component(workdir)
  43. # Overwrite CLAUDE.md with the checkpoint-enhanced version
  44. workdir = Path(workdir)
  45. claude_md_path = workdir / "CLAUDE.md"
  46. claude_md_path.write_text(CLAUDE_MD_WITH_CHECKPOINT)
  47. # Amend the first commit isn't feasible since we're 5 commits in.
  48. # Instead, add a new commit with the updated CLAUDE.md so the agent
  49. # sees it in the working tree.
  50. from setup_helpers.base import _git
  51. _git(["git", "add", "CLAUDE.md"], cwd=workdir)
  52. _git(
  53. ["git", "commit", "-m", "add implementation verification checklist to CLAUDE.md"],
  54. cwd=workdir,
  55. )