Skip to content

Commit 453365f

Browse files
sylvansysclaude
andauthored
Test: GitHub Orchestration Stacked PR Workflow (#312)
* test: Add stacked PR workflow test tracking file Test file to track the stacked PR workflow test execution and results for issue #311. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(github-orchestration): Fix parent transcript path in getTaskEdits The getTaskEdits() function was constructing the wrong path for the parent session transcript. Agent transcripts are stored at: .../project/{sessionId}/subagents/agent-{agentId}.jsonl But the code was looking for parent at: .../project/{sessionId}/subagents/{sessionId}.jsonl When it should be at: .../project/{sessionId}.jsonl This fix correctly navigates up from the subagents directory to find the parent transcript. Also adds test results documenting the stacked PR workflow testing: - sync-task-to-subissue.ts: ✅ Working - create-subagent-branch.ts: ✅ Working - stacked-pr-subagent-stop.ts: ❌ Fixed in this commit Closes #311 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 535db14 commit 453365f

3 files changed

Lines changed: 122 additions & 1 deletion

File tree

plugins/github-orchestration/shared/hooks/utils/task-state.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,13 @@ export async function getTaskEdits(
336336
}
337337

338338
// Find parent session transcript
339-
const dir = path.dirname(agentTranscriptPath);
339+
// Agent transcripts are at: .../project/{sessionId}/subagents/agent-{agentId}.jsonl
340+
// Parent transcripts are at: .../project/{sessionId}.jsonl
341+
let dir = path.dirname(agentTranscriptPath); // .../sessionId/subagents/
342+
if (path.basename(dir) === 'subagents') {
343+
dir = path.dirname(dir); // .../sessionId/
344+
}
345+
dir = path.dirname(dir); // .../project/
340346
const parentPath = path.join(dir, `${sessionId}.jsonl`);
341347

342348
try {
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# Stacked PR Workflow Test Results
2+
3+
## Test Date
4+
2026-01-23
5+
6+
## Test Branch
7+
`311-fix/can-u-test-out-the-gh-orchestration-plug`
8+
9+
## Parent Issue
10+
#311
11+
12+
## Hooks Under Test
13+
14+
| Hook | Event | Status |
15+
|------|-------|--------|
16+
| `sync-task-to-subissue.ts` | PostToolUse[Task] | Pending |
17+
| `create-subagent-branch.ts` | SubagentStart | Pending |
18+
| `stacked-pr-subagent-stop.ts` | SubagentStop | Pending |
19+
20+
## Expected Flow
21+
22+
1. Main PR created (this branch → main)
23+
2. Subagent task launched
24+
3. Subissue created and linked to #311
25+
4. Subagent branch created
26+
5. Subagent completes work
27+
6. Stacked PR created (subagent-branch → this branch)
28+
7. PR references subissue with "Closes #X"
29+
30+
## Results
31+
32+
### Test Run 1 (07:33 UTC)
33+
- **Subissue #313** ✅ Created with labels `task`, `subissue`
34+
- **Native sub-issue API** ❌ Returns `[]` (using markdown fallback)
35+
- **Stacked branch** ❌ Not created (no active PR detected yet)
36+
37+
### Test Run 2 (07:35 UTC)
38+
- **Subissue #315** ✅ Created with labels `task`, `subissue`
39+
- **Stacked branch** ✅ Created: `311-fix/can-u-test-out-the-gh-orchestration-plug-subagent-a18c360`
40+
- **Stacked PR** ❌ Failed - Bug in `getTaskEdits()` (wrong parent transcript path)
41+
- **Branch cleanup** ✅ Ran (deleted branch due to error)
42+
43+
### Bug Found
44+
**File**: `plugins/github-orchestration/shared/hooks/utils/task-state.ts:340`
45+
46+
**Issue**: `getTaskEdits()` constructs wrong path for parent transcript
47+
- Agent transcript: `.../project/{sessionId}/subagents/agent-{agentId}.jsonl`
48+
- Code looked for: `.../project/{sessionId}/subagents/{sessionId}.jsonl`
49+
- Should look for: `.../project/{sessionId}.jsonl`
50+
51+
**Fix Applied**: Go up two directory levels from agent transcript path
52+
53+
### Test Run 3 (07:38 UTC)
54+
- **Subissue #316** ✅ Created with labels `task`, `subissue`
55+
- **Stacked branch** ✅ Created but cleaned up due to error
56+
- **Stacked PR** ❌ Still failing (fix not in plugin cache yet)
57+
- **Note**: Fix applied to source but hooks run from `~/.claude/plugins/cache/constellos-local/`
58+
59+
## Summary
60+
61+
| Hook | Status | Notes |
62+
|------|--------|-------|
63+
| `sync-task-to-subissue.ts` | ✅ Working | Creates subissues linked to parent |
64+
| `create-subagent-branch.ts` | ✅ Working | Creates branch when PR exists |
65+
| `stacked-pr-subagent-stop.ts` | ❌ Bug | Path calculation error - fixed in source |
66+
67+
### Issues Created During Test
68+
- #313, #315, #316 - All linked to parent #311
69+
70+
### PRs Created
71+
- #312 - Main PR (this branch → main)
72+
- No stacked PRs (blocked by bug)
73+
74+
### Fix Required
75+
File: `plugins/github-orchestration/shared/hooks/utils/task-state.ts`
76+
77+
Before:
78+
```typescript
79+
const dir = path.dirname(agentTranscriptPath);
80+
const parentPath = path.join(dir, `${sessionId}.jsonl`);
81+
```
82+
83+
After:
84+
```typescript
85+
let dir = path.dirname(agentTranscriptPath);
86+
if (path.basename(dir) === 'subagents') {
87+
dir = path.dirname(dir);
88+
}
89+
dir = path.dirname(dir);
90+
const parentPath = path.join(dir, `${sessionId}.jsonl`);
91+
```
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* Formats a test result with a pass/fail prefix.
3+
* @param passed - Whether the test passed
4+
* @param message - The test result message
5+
* @returns Formatted string like "[PASS] message" or "[FAIL] message"
6+
*/
7+
export function formatTestResult(passed: boolean, message: string): string {
8+
const prefix = passed ? '[PASS]' : '[FAIL]';
9+
return `${prefix} ${message}`;
10+
}
11+
12+
export function assertTestPassed(condition: boolean, testName: string): void {
13+
if (!condition) {
14+
throw new Error(`Test failed: ${testName}`);
15+
}
16+
console.log(formatTestResult(true, testName));
17+
}
18+
19+
let testCounter = 0;
20+
21+
export function getNextTestId(): string {
22+
testCounter++;
23+
return `test-${testCounter}`;
24+
}

0 commit comments

Comments
 (0)