-
Notifications
You must be signed in to change notification settings - Fork 0
feat(workflow): email 프리셋 + 요청 체인 (채널 에이전트 토대) #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
docs/superpowers/specs/2026-08-04-workflow-email-presets-chain-design.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| # Maestro Workflow 이메일 프리셋 + 요청 체인 설계 | ||
|
|
||
| - 날짜: 2026-08-04 | ||
| - 상태: 확정 (비전 §4(d) 채널 에이전트 구상의 Workflow측 토대 2건) | ||
| - 범위: `workflow/` 하위만 (경계 규칙 준수) | ||
|
|
||
| ## 1. 프리셋 subjectType 2종 (표시 전용 — 서버는 유형을 모름) | ||
|
|
||
| `presets.js` `formatPresetHighlight` 확장: | ||
|
|
||
| - `email-reply`: payload `{ to, subject, draft }` — label `↩ {to}`, | ||
| detail은 subject(없으면 draft 앞부분). `to` 없으면 null(프리셋 미적용). | ||
| - `email-triage`: payload `{ from, subject, proposedAction }` — label | ||
| `✉ {from}`, detail은 proposedAction(없으면 subject). `from` 없으면 null. | ||
|
|
||
| ## 2. 요청 체인 (`parentRequestId`) | ||
|
|
||
| - `createDecisionRequest`가 선택 필드 `parentRequestId`를 받는다. | ||
| 존재하지 않는 부모면 `PARENT_REQUEST_NOT_FOUND` (라우트에선 404). | ||
| 저장 필드는 항상 존재(`null` 기본). | ||
| - `listRequestChain(requestId)`: 루트까지 조상 추적 후 자손 BFS — | ||
| createdAt 오름차순 정렬로 반환. 미존재 요청은 null. | ||
| - 라우트 `GET /api/decision-requests/:id/chain` (운영자 토큰): | ||
| `{ items }`. 404 = 요청 없음. | ||
| - `REQUEST_CREATED` 이력 엔트리에 `parentRequestId` 포함(체인 감사 추적). | ||
| - 영속화는 기존 스토어 직렬화로 자동 포함. | ||
|
|
||
| ## 3. 대시보드 최소 표시 | ||
|
|
||
| DecisionSheet에 `parentRequestId`가 있으면 "체인 이전 요청: <id>" 라인 표시. | ||
| 체인 시각화(레인 묶음)는 후속. | ||
|
|
||
| ## 4. 테스트 | ||
|
|
||
| - presets 단위: 2종 하이라이트 + 필수 필드 누락 시 null. | ||
| - 서버: 체인 생성(A→B→C) 후 chain 조회가 3건 오름차순, 미존재 부모 404, | ||
| 엄격 모드에서 chain 401. | ||
| - UI: DecisionSheet 부모 라인 렌더. | ||
|
|
||
| ## 5. 비범위 | ||
|
|
||
| 커넥터/발송(에이전트 몫), 체인 레인 시각화, actor의 chain 조회(운영자 전용 시작). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| // 요청 체인 (스펙 2026-08-04 §2): parentRequestId 연결과 chain 조회. | ||
| import test from 'node:test'; | ||
| import assert from 'node:assert/strict'; | ||
| import { startServer, cleanupDataDir, authHeaders } from './helpers.mjs'; | ||
|
|
||
| const SERVER_TOKEN = 'wf-server-secret'; | ||
|
|
||
| async function setupActor(server, actorId) { | ||
| const res = await fetch(`http://127.0.0.1:${server.port}/api/actors/register`, { | ||
| method: 'POST', | ||
| headers: { 'Content-Type': 'application/json', ...authHeaders(SERVER_TOKEN) }, | ||
| body: JSON.stringify({ actorId }), | ||
| }); | ||
| return (await res.json()).actorToken; | ||
| } | ||
|
|
||
| async function postRequest(server, token, payload) { | ||
| const res = await fetch(`http://127.0.0.1:${server.port}/api/decision-requests`, { | ||
| method: 'POST', | ||
| headers: { 'Content-Type': 'application/json', ...authHeaders(token) }, | ||
| body: JSON.stringify(payload), | ||
| }); | ||
| return res; | ||
| } | ||
|
|
||
| test('parentRequestId로 체인을 만들고 chain 조회가 오름차순 전체를 돌려준다', async () => { | ||
| const server = await startServer({ serverToken: SERVER_TOKEN }); | ||
| try { | ||
| const token = await setupActor(server, 'agent_mail'); | ||
| const first = await (await postRequest(server, token, { | ||
| subjectType: 'email-triage', | ||
| subject: { title: '메일 분류: 계약 검토', payload: { from: 'boss@corp.com' } }, | ||
| })).json(); | ||
| const second = await (await postRequest(server, token, { | ||
| subjectType: 'email-reply', | ||
| subject: { title: '답장 초안 v1' }, | ||
| parentRequestId: first.item.requestId, | ||
| })).json(); | ||
| const third = await (await postRequest(server, token, { | ||
| subjectType: 'email-reply', | ||
| subject: { title: '답장 초안 v2 (반려 반영)' }, | ||
| parentRequestId: second.item.requestId, | ||
| })).json(); | ||
|
|
||
| assert.equal(second.item.parentRequestId, first.item.requestId); | ||
| assert.equal(first.item.parentRequestId, null); | ||
|
|
||
| // 체인 조회는 중간 노드 기준으로도 전체를 돌려준다 | ||
| const chainRes = await fetch( | ||
| `http://127.0.0.1:${server.port}/api/decision-requests/${second.item.requestId}/chain`, | ||
| { headers: authHeaders(SERVER_TOKEN) }, | ||
| ); | ||
| assert.equal(chainRes.status, 200); | ||
| const chain = (await chainRes.json()).items; | ||
| assert.deepEqual( | ||
| chain.map((item) => item.requestId), | ||
| [first.item.requestId, second.item.requestId, third.item.requestId], | ||
| ); | ||
| } finally { | ||
| await server.stop(); | ||
| cleanupDataDir(server.dataDir); | ||
| } | ||
| }); | ||
|
|
||
| test('존재하지 않는 부모는 404 PARENT_REQUEST_NOT_FOUND', async () => { | ||
| const server = await startServer({ serverToken: SERVER_TOKEN }); | ||
| try { | ||
| const token = await setupActor(server, 'agent_mail'); | ||
| const res = await postRequest(server, token, { | ||
| subjectType: 'email-reply', | ||
| subject: { title: '고아 요청' }, | ||
| parentRequestId: 'dcr_missing', | ||
| }); | ||
| assert.equal(res.status, 404); | ||
| assert.equal((await res.json()).error, 'PARENT_REQUEST_NOT_FOUND'); | ||
| } finally { | ||
| await server.stop(); | ||
| cleanupDataDir(server.dataDir); | ||
| } | ||
| }); | ||
|
|
||
| test('엄격 모드에서 chain 조회는 운영자 토큰을 요구한다', async () => { | ||
| const server = await startServer({ serverToken: SERVER_TOKEN }); | ||
| try { | ||
| const res = await fetch(`http://127.0.0.1:${server.port}/api/decision-requests/dcr_x/chain`); | ||
| assert.equal(res.status, 401); | ||
| } finally { | ||
| await server.stop(); | ||
| cleanupDataDir(server.dataDir); | ||
| } | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a chained request is created, this call appears to add
parentRequestIdto the audit trail, butappendHistory()rebuilds entries from a fixed whitelist and does not copyinput.parentRequestId, so/api/historyand persisted history still lose the chain link. In any email/request-chain flow that relies on history for auditability, the created event cannot be tied back to its parent unless the history entry schema is updated to store this field.Useful? React with 👍 / 👎.