Skip to content

Commit aebff88

Browse files
committed
refactor: remove closed-issue filtering from migration scripts
1 parent 2344020 commit aebff88

5 files changed

Lines changed: 100 additions & 32 deletions

File tree

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
{"status": "open"}
1+
{
2+
"status" : "closed",
3+
"resolution" : "implemented",
4+
"target_branch" : "v2.1"
5+
}

.cat/issues/v2/v2.1/migrate-closed-issues-convention/plan.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,41 @@ the format of planning files. Update all migration scripts (1.0.8.sh, 1.0.9.sh,
77
2.0.sh, 2.1.sh) to process closed issues. Update all relevant convention files to reflect
88
the new policy.
99

10+
## Research Findings
11+
12+
Investigation of the current codebase reveals:
13+
14+
1. **CLAUDE.md** contains the rule: "Do not update closed issue files: Never modify PLAN.md or STATE.md of closed
15+
issues unless the user explicitly instructs you to. Closed issues are historical records." This rule applies to
16+
manual agent edits but does not exempt migration scripts. It needs to be updated to clarify that migration scripts
17+
are an exception.
18+
19+
2. **2.1.sh** has two phases that explicitly skip closed issues:
20+
- Phase 13 (lines 1095-1100): Skips closed issues when removing deprecated Last Updated, Completed, and Closed
21+
fields from STATE.md files
22+
- Phase 14 (lines 1156-1165): Skips closed issues when renaming ## Satisfies → ## Parent Requirements in PLAN.md
23+
- All other phases (1-12, 15-21) already process all issues including closed ones
24+
25+
3. **1.0.8.sh, 1.0.9.sh, 1.0.10.sh, 2.0.sh**: None of these scripts filter by issue status. They already process
26+
all issues (open and closed).
27+
28+
4. **`.claude/rules/common.md`** § "No Backwards Compatibility" mentions migration scripts must be idempotent but
29+
does not address whether closed issues should be migrated.
30+
31+
5. **Multiple closed issue plan.md files** reference "closed issues are historical records" as rationale for skipping
32+
them during migration. These are historical records themselves and should not be modified.
33+
34+
## Risk Assessment
35+
- **Risk Level:** LOW
36+
- **Concerns:** Migration scripts touching closed issue files could theoretically corrupt historical data
37+
- **Mitigation:** Changes are idempotent (sed replacements are no-ops if already migrated); convention update
38+
explicitly scopes the exception to automated migration scripts only
39+
40+
## Files to Modify
41+
- `CLAUDE.md` - Update "Do not update closed issue files" rule to exempt migration scripts
42+
- `.claude/rules/common.md` - Add guidance that migration scripts must process all issues including closed ones
43+
- `plugin/migrations/2.1.sh` - Remove closed-issue skipping from phases 13 and 14
44+
1045
## Pre-conditions
1146

1247
(none)
@@ -19,3 +54,48 @@ the new policy.
1954
- [ ] CLAUDE.md and all relevant convention files updated to reflect the new policy
2055
- [ ] Tests passing
2156
- [ ] E2E: Run an updated migration script on a repo with closed issues and verify they are migrated
57+
58+
## Jobs
59+
60+
### Job 1
61+
- Update `CLAUDE.md` § "Do not update closed issue files" to add an exception for automated migration scripts.
62+
The updated text should clarify that the rule applies to manual agent edits during normal workflow, but
63+
automated migration scripts (under `plugin/migrations/`) must process all issues including closed ones to
64+
ensure consistent file formats across the entire issue tree.
65+
- Files: `CLAUDE.md`
66+
- Update `.claude/rules/common.md` § "No Backwards Compatibility" to add a paragraph after the "Idempotency"
67+
paragraph stating that migration scripts must process all issues regardless of status (open or closed).
68+
Closed issues contain the same file formats as open issues and must be migrated to maintain consistency.
69+
The existing CLAUDE.md rule about not modifying closed issues applies only to manual agent edits, not
70+
automated migrations.
71+
- Files: `.claude/rules/common.md`
72+
- Update `plugin/migrations/2.1.sh` Phase 13 (around lines 1090-1126):
73+
1. Remove the `phase13_skipped=0` variable initialization (line 1090)
74+
2. Remove the 6-line "Skip closed issues" block (lines 1095-1100) that checks for `**Status:** closed` and
75+
continues
76+
3. Update the phase title comment (line 1074): change `from open issue-level STATE.md` to
77+
`from issue-level STATE.md`
78+
4. Update the log message (line 1077): change `from open issue-level STATE.md` to
79+
`from issue-level STATE.md`
80+
5. Update the summary log (line 1126): change
81+
`"Phase 13 complete: $phase13_changed files changed, $phase13_skipped closed issues skipped"` to
82+
`"Phase 13 complete: $phase13_changed files changed"`
83+
- Files: `plugin/migrations/2.1.sh`
84+
- Update `plugin/migrations/2.1.sh` Phase 14 (around lines 1146-1173):
85+
1. Remove the `phase14_skipped=0` variable initialization (line 1146)
86+
2. Remove the 10-line "Skip closed issues" block (lines 1156-1165) that checks STATE.md for closed status
87+
and continues
88+
3. Update the phase title comment (line 1130): change `in open issue PLAN.md files` to
89+
`in issue PLAN.md files`
90+
4. Update the log message (line 1133): change `in open issue PLAN.md files` to `in issue PLAN.md files`
91+
5. Update the summary log (line 1173): change
92+
`"Phase 14 complete: $phase14_changed files changed, $phase14_skipped closed issues skipped"` to
93+
`"Phase 14 complete: $phase14_changed files changed"`
94+
- Files: `plugin/migrations/2.1.sh`
95+
- Update `plugin/migrations/2.1.sh` header comments (lines 34-37): Remove the "(closed issues are not modified)"
96+
annotations from items 13 and 14 in the changes list.
97+
- Files: `plugin/migrations/2.1.sh`
98+
- Verify that 1.0.8.sh, 1.0.9.sh, 1.0.10.sh, and 2.0.sh already process all issues (no closed-issue filtering).
99+
No changes expected — this is a verification step only.
100+
- Run `mvn -f client/pom.xml test` to verify all tests pass
101+
- Update index.json to status: closed, progress: 100%

.claude/rules/common.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,10 @@ and write all code against the new design only.
324324
run. Scripts should check current state before making changes (e.g., skip renaming a file that's already renamed, skip
325325
adding a field that already exists).
326326

327+
**Closed issue coverage:** Migration scripts must process all issues regardless of status (open or closed). Closed
328+
issues contain the same file formats as open issues and must be migrated to maintain consistency. The CLAUDE.md rule
329+
about not modifying closed issues applies only to manual agent edits, not automated migrations.
330+
327331
**Planning file schema changes:** When an issue modifies the schema of planning files (STATE.md, PLAN.md headings,
328332
field names, section structure), the issue MUST include updating the current version's `plugin/migrations/` script to
329333
transform existing files. The migration is part of the same issue — do not defer it to a separate issue.

CLAUDE.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
- **STATE.md belongs with implementation:** When closing an issue, STATE.md updates belong in the SAME commit as the implementation work, using the implementation's commit type (feature:/bugfix:/docs:/etc), NOT in a separate planning: commit
2222
- If a commit would touch both docs and non-docs files, split it into separate commits
2323
- **Do not update closed issue files:** Never modify PLAN.md or STATE.md of closed issues unless the user explicitly
24-
instructs you to. Closed issues are historical records.
24+
instructs you to. Closed issues are historical records. **Exception:** Automated migration scripts under
25+
`plugin/migrations/` must process all issues including closed ones to ensure consistent file formats across the
26+
entire issue tree.
2527

2628
## Issue Workflow vs Direct Implementation
2729

plugin/migrations/2.1.sh

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,8 @@ set -euo pipefail
3131
# 10. Remove legacy worktree-locks directory
3232
# 11. Migrate cross-session dirs (locks/, worktrees/, verify/) to .cat/work/ inside project workspace
3333
# 12. Migrate terminalWidth to fileWidth + displayWidth in cat-config.json
34-
# 13. Remove deprecated Last Updated and Completed fields from open issue-level STATE.md files
35-
# (closed issues are not modified)
36-
# 14. Rename ## Satisfies → ## Parent Requirements in open issue-level PLAN.md files
37-
# (closed issues are not modified)
34+
# 13. Remove deprecated Last Updated and Completed fields from issue-level STATE.md files
35+
# 14. Rename ## Satisfies → ## Parent Requirements in issue-level PLAN.md files
3836
# 15. Rename ## Execution Waves → ## Sub-Agent Waves in PLAN.md files
3937
# (all issues, including closed ones)
4038
# 16. Rename cat-config.json → config.json and cat-config.local.json → config.local.json
@@ -1071,10 +1069,10 @@ else
10711069
fi
10721070
fi
10731071

1074-
# Phase 13: Remove deprecated Last Updated, Completed, and Closed fields from open issue-level STATE.md
1072+
# Phase 13: Remove deprecated Last Updated, Completed, and Closed fields from issue-level STATE.md
10751073
# ──────────────────────────────────────────────────────────────────────────────
10761074

1077-
log_migration "Phase 13: Remove deprecated Last Updated, Completed, and Closed fields from open issue-level STATE.md"
1075+
log_migration "Phase 13: Remove deprecated Last Updated, Completed, and Closed fields from issue-level STATE.md"
10781076

10791077
# Issue-level STATE.md files live at .cat/issues/v*/v*.*/issue-name/STATE.md (depth 5 from issues/).
10801078
issue_state_files=$(find .cat/issues -path "*v*.*/*" -name "STATE.md" -mindepth 5 -maxdepth 5 -type f \
@@ -1087,18 +1085,10 @@ else
10871085
log_migration "Found $totalCount issue-level STATE.md files to check"
10881086

10891087
phase13_changed=0
1090-
phase13_skipped=0
10911088

10921089
while IFS= read -r state_file; do
10931090
[[ -z "$state_file" ]] && continue
10941091

1095-
# Skip closed issues
1096-
if grep -q '^\*\*Status:\*\* closed' "$state_file" 2>/dev/null || \
1097-
grep -q '^- \*\*Status:\*\* closed' "$state_file" 2>/dev/null; then
1098-
((phase13_skipped++)) || true
1099-
continue
1100-
fi
1101-
11021092
changed=false
11031093

11041094
if grep -q '^- \*\*Last Updated:\*\*' "$state_file" 2>/dev/null; then
@@ -1123,14 +1113,14 @@ else
11231113

11241114
done <<< "$issue_state_files"
11251115

1126-
log_migration "Phase 13 complete: $phase13_changed files changed, $phase13_skipped closed issues skipped"
1116+
log_migration "Phase 13 complete: $phase13_changed files changed"
11271117
fi
11281118

11291119
# ──────────────────────────────────────────────────────────────────────────────
1130-
# Phase 14: Rename ## Satisfies → ## Parent Requirements in open issue PLAN.md files
1120+
# Phase 14: Rename ## Satisfies → ## Parent Requirements in issue PLAN.md files
11311121
# ──────────────────────────────────────────────────────────────────────────────
11321122

1133-
log_migration "Phase 14: Rename ## Satisfies → ## Parent Requirements in open issue PLAN.md files"
1123+
log_migration "Phase 14: Rename ## Satisfies → ## Parent Requirements in issue PLAN.md files"
11341124

11351125
# Issue-level PLAN.md files live at .cat/issues/v*/v*.*/issue-name/PLAN.md (depth 4 from issues/).
11361126
issue_plan_files=$(find .cat/issues -path "*v*.*/*" -name "PLAN.md" -mindepth 4 -maxdepth 4 -type f \
@@ -1143,7 +1133,6 @@ else
11431133
log_migration "Found $totalCount issue-level PLAN.md files to check"
11441134

11451135
phase14_changed=0
1146-
phase14_skipped=0
11471136

11481137
while IFS= read -r planFile; do
11491138
[[ -z "$planFile" ]] && continue
@@ -1153,24 +1142,13 @@ else
11531142
continue
11541143
fi
11551144

1156-
# Skip closed issues - check corresponding STATE.md
1157-
issue_dir=$(dirname "$planFile")
1158-
state_file="${issue_dir}/STATE.md"
1159-
if [[ ! -f "$state_file" ]]; then
1160-
log_migration " Warning: STATE.md missing for $planFile — treating as open issue"
1161-
elif grep -q '^\*\*Status:\*\* closed' "$state_file" 2>/dev/null || \
1162-
grep -q '^- \*\*Status:\*\* closed' "$state_file" 2>/dev/null; then
1163-
((phase14_skipped++)) || true
1164-
continue
1165-
fi
1166-
11671145
sed -i 's/^## Satisfies$/## Parent Requirements/' "$planFile"
11681146
((phase14_changed++)) || true
11691147
log_migration " Updated: $planFile"
11701148

11711149
done <<< "$issue_plan_files"
11721150

1173-
log_migration "Phase 14 complete: $phase14_changed files changed, $phase14_skipped closed issues skipped"
1151+
log_migration "Phase 14 complete: $phase14_changed files changed"
11741152
fi
11751153

11761154
# ──────────────────────────────────────────────────────────────────────────────

0 commit comments

Comments
 (0)