Skip to content

Commit aa9462e

Browse files
committed
planning: decompose 2.1-remove-jvmscope-claudeenv-duplicates into 4 sub-issues
1 parent 929d4c4 commit aa9462e

9 files changed

Lines changed: 286 additions & 2 deletions

File tree

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
issue: 2.1-jvmenv-w1-claudeenv
3+
parent: 2.1-remove-jvmscope-claudeenv-duplicates
4+
sequence: 1 of 4
5+
---
6+
7+
# Plan: jvmenv-w1-claudeenv
8+
9+
## Objective
10+
11+
Rename three `ClaudeEnv` methods that carry redundant `Claude` prefixes, and add a `ClaudeEnv`
12+
field to `AbstractJvmScope` with a `getClaudeEnv()` accessor exposed via `JvmScope`.
13+
14+
## Scope
15+
16+
### ClaudeEnv renames
17+
18+
File: `client/src/main/java/io/github/cowwoc/cat/hooks/ClaudeEnv.java`
19+
20+
- Rename `getClaudeSessionId()``getSessionId()`
21+
- Rename `getClaudePluginRoot()``getPluginRoot()`
22+
- Rename `getClaudeEnvFile()``getEnvFile()`
23+
- Update Javadoc for each renamed method.
24+
25+
### Add getClaudeEnv() to JvmScope interface
26+
27+
File: `client/src/main/java/io/github/cowwoc/cat/hooks/JvmScope.java`
28+
29+
Add declaration:
30+
```java
31+
/**
32+
* Returns the Claude environment accessor for this scope.
33+
*
34+
* @return the ClaudeEnv instance
35+
* @throws IllegalStateException if this scope is closed
36+
*/
37+
ClaudeEnv getClaudeEnv();
38+
```
39+
40+
### Update AbstractJvmScope
41+
42+
File: `client/src/main/java/io/github/cowwoc/cat/hooks/AbstractJvmScope.java`
43+
44+
- Add `final ClaudeEnv claudeEnv` field.
45+
- Add protected constructor parameter `AbstractJvmScope(ClaudeEnv claudeEnv)`.
46+
- Implement `getClaudeEnv()` returning the field.
47+
- Update derived methods to use `claudeEnv`:
48+
- `getCatDir()`: `claudeEnv.getProjectPath().resolve(Config.CAT_DIR_NAME)`
49+
- `getClaudeSessionsPath()`: `getClaudeConfigDir().resolve("projects").resolve(encodeProjectPath(claudeEnv.getProjectPath().toString()))`
50+
- `getClaudeSessionPath()`: `getClaudeSessionsPath().resolve(claudeEnv.getSessionId())`
51+
- `getCatWorkPath()`: `claudeEnv.getProjectPath().resolve(".cat").resolve("work")`
52+
- `getCatSessionPath()`: `getCatWorkPath().resolve("sessions").resolve(claudeEnv.getSessionId())`
53+
- `derivePluginPrefix()`: `claudeEnv.getPluginRoot().toAbsolutePath().normalize()`
54+
55+
## Dependencies
56+
57+
- None (first in sequence)
58+
59+
## Post-conditions
60+
61+
- [ ] `ClaudeEnv` exposes `getSessionId()`, `getPluginRoot()`, `getEnvFile()` (old names removed)
62+
- [ ] `JvmScope` declares `getClaudeEnv()`
63+
- [ ] `AbstractJvmScope` stores `ClaudeEnv` in a field and implements `getClaudeEnv()`
64+
- [ ] Derived methods in `AbstractJvmScope` delegate to `claudeEnv` field
65+
- [ ] `mvn -f client/pom.xml test` passes (may fail until Wave 2 updates concrete impls — compile only must succeed)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# State
2+
3+
- **Status:** open
4+
- **Progress:** 0%
5+
- **Dependencies:** []
6+
- **Blocks:** []
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
issue: 2.1-jvmenv-w2-interface
3+
parent: 2.1-remove-jvmscope-claudeenv-duplicates
4+
sequence: 2 of 4
5+
---
6+
7+
# Plan: jvmenv-w2-interface
8+
9+
## Objective
10+
11+
Remove `getClaudeSessionId()`, `getProjectPath()`, `getClaudePluginRoot()`, and `getClaudeEnvFile()`
12+
from the `JvmScope` interface and their implementations in `MainJvmScope` and `TestJvmScope`.
13+
14+
## Dependencies
15+
16+
- `2.1-jvmenv-w1-claudeenv` must be merged first (`getClaudeEnv()` accessor must exist)
17+
18+
## Scope
19+
20+
### JvmScope interface
21+
22+
File: `client/src/main/java/io/github/cowwoc/cat/hooks/JvmScope.java`
23+
24+
- Remove declarations of `getClaudeSessionId()`, `getProjectPath()`, `getClaudePluginRoot()`,
25+
`getClaudeEnvFile()`.
26+
27+
### MainJvmScope
28+
29+
File: `client/src/main/java/io/github/cowwoc/cat/hooks/MainJvmScope.java`
30+
31+
- Remove `ConcurrentLazyReference` fields `claudeProjectPath`, `claudePluginRoot`, `claudeSessionId`,
32+
`claudeEnvFile` and their `@Override` methods.
33+
- Change the constructor to call `super(new ClaudeEnv())`.
34+
35+
### TestJvmScope
36+
37+
File: `client/src/test/java/io/github/cowwoc/cat/hooks/test/TestJvmScope.java`
38+
39+
- Remove `@Override getProjectPath()`, `@Override getClaudePluginRoot()`,
40+
`@Override getClaudeSessionId()`, `@Override getClaudeEnvFile()` method bodies and their backing
41+
fields (`claudeProjectPath`, `claudePluginRoot`, `claudeSessionId`, `claudeEnvFile`).
42+
- In each constructor, build a `Map<String, String>` from the constructor parameters and pass
43+
`SharedSecrets.newClaudeEnv(map)` to `super()`. Map keys:
44+
- `CLAUDE_PROJECT_DIR``claudeProjectPath.toString()`
45+
- `CLAUDE_PLUGIN_ROOT``claudePluginRoot.toString()`
46+
- `CLAUDE_SESSION_ID``claudeSessionId` (default: `"test-session"`)
47+
- `CLAUDE_ENV_FILE``claudeEnvFile.toString()`
48+
- Keep all existing constructor signatures unchanged.
49+
50+
## Post-conditions
51+
52+
- [ ] No method named `getClaudeSessionId`, `getProjectPath`, `getClaudePluginRoot`, or
53+
`getClaudeEnvFile` exists in `JvmScope`, `MainJvmScope`, or `TestJvmScope`
54+
- [ ] `MainJvmScope` and `TestJvmScope` pass a `ClaudeEnv` to `AbstractJvmScope` via `super()`
55+
- [ ] Code compiles (call sites in Wave 3/4 are updated next)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# State
2+
3+
- **Status:** open
4+
- **Progress:** 0%
5+
- **Dependencies:** [2.1-jvmenv-w1-claudeenv]
6+
- **Blocks:** []
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
---
2+
issue: 2.1-jvmenv-w3-main
3+
parent: 2.1-remove-jvmscope-claudeenv-duplicates
4+
sequence: 3 of 4
5+
---
6+
7+
# Plan: jvmenv-w3-main
8+
9+
## Objective
10+
11+
Update all main-source call sites to use the new `scope.getClaudeEnv()` accessor instead of
12+
the removed scope methods.
13+
14+
## Dependencies
15+
16+
- `2.1-jvmenv-w2-interface` must be merged first
17+
18+
## Substitutions
19+
20+
For each file listed below:
21+
- `scope.getClaudeSessionId()``scope.getClaudeEnv().getSessionId()`
22+
- `scope.getProjectPath()``scope.getClaudeEnv().getProjectPath()`
23+
- `scope.getClaudePluginRoot()``scope.getClaudeEnv().getPluginRoot()`
24+
- `scope.getClaudeEnvFile()``scope.getClaudeEnv().getEnvFile()`
25+
26+
## Files to Update
27+
28+
- `client/src/main/java/io/github/cowwoc/cat/hooks/write/WarnBaseBranchEdit.java` (3 occurrences of getProjectPath)
29+
- `client/src/main/java/io/github/cowwoc/cat/hooks/write/EnforceWorktreePathIsolation.java`
30+
- `client/src/main/java/io/github/cowwoc/cat/hooks/SessionEndHook.java`
31+
- `client/src/main/java/io/github/cowwoc/cat/hooks/task/EnforceApprovalBeforeMerge.java`
32+
- `client/src/main/java/io/github/cowwoc/cat/hooks/task/EnforceCollectAfterAgent.java`
33+
- `client/src/main/java/io/github/cowwoc/cat/hooks/task/EnforceCommitBeforeSubagentSpawn.java`
34+
- `client/src/main/java/io/github/cowwoc/cat/hooks/util/WorkPrepare.java` (getClaudeSessionId + 2x getProjectPath)
35+
- `client/src/main/java/io/github/cowwoc/cat/hooks/util/SkillDiscovery.java`
36+
- `client/src/main/java/io/github/cowwoc/cat/hooks/util/IssueDiscovery.java`
37+
- `client/src/main/java/io/github/cowwoc/cat/hooks/util/RecordLearning.java`
38+
- `client/src/main/java/io/github/cowwoc/cat/hooks/util/RootCauseAnalyzer.java` (verify if already uses ClaudeEnv)
39+
- `client/src/main/java/io/github/cowwoc/cat/hooks/util/MergeAndCleanup.java`
40+
- `client/src/main/java/io/github/cowwoc/cat/hooks/util/GetSkill.java`
41+
- `client/src/main/java/io/github/cowwoc/cat/hooks/util/InvestigationContextExtractor.java`
42+
- `client/src/main/java/io/github/cowwoc/cat/hooks/licensing/Entitlements.java`
43+
- `client/src/main/java/io/github/cowwoc/cat/hooks/licensing/LicenseValidator.java`
44+
- `client/src/main/java/io/github/cowwoc/cat/hooks/bash/BlockWorktreeIsolationViolation.java`
45+
- `client/src/main/java/io/github/cowwoc/cat/hooks/bash/BlockMainRebase.java`
46+
- `client/src/main/java/io/github/cowwoc/cat/hooks/bash/BlockUnsafeRemoval.java`
47+
- `client/src/main/java/io/github/cowwoc/cat/hooks/bash/BlockUnauthorizedMergeCleanup.java`
48+
- `client/src/main/java/io/github/cowwoc/cat/hooks/bash/RequireSkillForCommand.java`
49+
- `client/src/main/java/io/github/cowwoc/cat/hooks/skills/GetNextIssueOutput.java`
50+
- `client/src/main/java/io/github/cowwoc/cat/hooks/skills/GetStatuslineOutput.java`
51+
- `client/src/main/java/io/github/cowwoc/cat/hooks/skills/GetAddOutput.java`
52+
- `client/src/main/java/io/github/cowwoc/cat/hooks/skills/GetCheckpointOutput.java`
53+
- `client/src/main/java/io/github/cowwoc/cat/hooks/skills/GetStatusOutput.java`
54+
- `client/src/main/java/io/github/cowwoc/cat/hooks/skills/GetWorkOutput.java`
55+
- `client/src/main/java/io/github/cowwoc/cat/hooks/skills/GetCleanupOutput.java`
56+
- `client/src/main/java/io/github/cowwoc/cat/hooks/skills/GetConfigOutput.java`
57+
- `client/src/main/java/io/github/cowwoc/cat/hooks/skills/GetTokenReportOutput.java`
58+
- `client/src/main/java/io/github/cowwoc/cat/hooks/skills/DisplayUtils.java`
59+
- `client/src/main/java/io/github/cowwoc/cat/hooks/session/InjectSubAgentRules.java`
60+
- `client/src/main/java/io/github/cowwoc/cat/hooks/session/InjectMainAgentRules.java`
61+
- `client/src/main/java/io/github/cowwoc/cat/hooks/session/InjectEnv.java`
62+
- `client/src/main/java/io/github/cowwoc/cat/hooks/session/CheckDataMigration.java`
63+
- `client/src/main/java/io/github/cowwoc/cat/hooks/session/CheckUpdateAvailable.java`
64+
- `client/src/main/java/io/github/cowwoc/cat/hooks/session/SessionEndHandler.java`
65+
66+
## Post-conditions
67+
68+
- [ ] No call site in `client/src/main/` references `scope.getClaudeSessionId()`,
69+
`scope.getProjectPath()`, `scope.getClaudePluginRoot()`, or `scope.getClaudeEnvFile()`
70+
- [ ] Code compiles
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# State
2+
3+
- **Status:** open
4+
- **Progress:** 0%
5+
- **Dependencies:** [2.1-jvmenv-w2-interface]
6+
- **Blocks:** []
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
issue: 2.1-jvmenv-w4-tests
3+
parent: 2.1-remove-jvmscope-claudeenv-duplicates
4+
sequence: 4 of 4
5+
---
6+
7+
# Plan: jvmenv-w4-tests
8+
9+
## Objective
10+
11+
Update all test-source call sites to use the new `scope.getClaudeEnv()` accessor, fix the
12+
`ClaudeEnvTest` method names, and verify the full test suite passes.
13+
14+
## Dependencies
15+
16+
- `2.1-jvmenv-w3-main` must be merged first
17+
18+
## Substitutions
19+
20+
For each file listed below:
21+
- `scope.getClaudeSessionId()``scope.getClaudeEnv().getSessionId()`
22+
- `scope.getProjectPath()``scope.getClaudeEnv().getProjectPath()`
23+
- `scope.getClaudePluginRoot()``scope.getClaudeEnv().getPluginRoot()`
24+
25+
## Files to Update
26+
27+
- `PostToolUseFailureHookTest.java`: `scope.getClaudeSessionId()``scope.getClaudeEnv().getSessionId()`
28+
- `PostToolUseHookTest.java`: same
29+
- `SetPendingAgentResultTest.java`: same
30+
- `SessionEndHandlerTest.java`: same (3 occurrences)
31+
- `JvmScopePathResolutionTest.java`: same (2 occurrences)
32+
- `InjectMainAgentRulesTest.java`: getProjectPath (4 occurrences) and getClaudePluginRoot (3 occurrences)
33+
- `WarnApprovalWithoutRenderDiffTest.java`: getProjectPath (3 occurrences)
34+
- `SubagentStartHookTest.java`: getProjectPath (3 occurrences)
35+
- `InjectSubAgentRulesTest.java`: getProjectPath (6 occurrences) and getClaudePluginRoot (3 occurrences)
36+
- `GetAddOutputPlanningDataTest.java`: all getProjectPath occurrences
37+
- `SessionEndHookTest.java`: getProjectPath
38+
- `TestJvmScopeTest.java` line 82: getProjectPath
39+
- `ClaudeEnvTest.java`: update method names in test method bodies and Javadoc:
40+
`getClaudeSessionId()``getSessionId()`, `getClaudePluginRoot()``getPluginRoot()`,
41+
`getClaudeEnvFile()``getEnvFile()`
42+
- `EnforceJvmScopeEnvAccessTest.java` line 82: update comment text mentioning `getClaudeSessionId()`
43+
44+
## Post-conditions
45+
46+
- [ ] No call site in `client/src/test/` references `scope.getClaudeSessionId()`,
47+
`scope.getProjectPath()`, or `scope.getClaudePluginRoot()` as direct scope methods
48+
- [ ] `ClaudeEnvTest.java` uses the new method names
49+
- [ ] `mvn -f client/pom.xml test` exits 0 with no compilation errors or test failures
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# State
2+
3+
- **Status:** open
4+
- **Progress:** 0%
5+
- **Dependencies:** [2.1-jvmenv-w3-main]
6+
- **Blocks:** []
Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,27 @@
11
# State
22

3-
- **Status:** open
3+
- **Status:** in-progress
44
- **Progress:** 0%
55
- **Dependencies:** []
6-
- **Blocks:** []
6+
- **Blocks:** []
7+
8+
## Decomposed Into
9+
10+
<!-- IMPORTANT: Use fully-qualified names (VERSION_PREFIX + bare-name). -->
11+
- 2.1-jvmenv-w1-claudeenv
12+
- 2.1-jvmenv-w2-interface
13+
- 2.1-jvmenv-w3-main
14+
- 2.1-jvmenv-w4-tests
15+
16+
## Parallel Execution Plan
17+
18+
### Wave 1 (Sequential - each depends on previous)
19+
| Issue | Est. Tokens | Dependencies |
20+
|-------|-------------|--------------|
21+
| 2.1-jvmenv-w1-claudeenv | ~40K | None |
22+
| 2.1-jvmenv-w2-interface | ~30K | 2.1-jvmenv-w1-claudeenv |
23+
| 2.1-jvmenv-w3-main | ~80K | 2.1-jvmenv-w2-interface |
24+
| 2.1-jvmenv-w4-tests | ~60K | 2.1-jvmenv-w3-main |
25+
26+
**Total sub-issues:** 4
27+
**Execution:** Sequential (each wave depends on previous)

0 commit comments

Comments
 (0)